|
@@ 76-87 (lines=12) @@
|
| 73 |
|
* @return bool |
| 74 |
|
* function to add a category |
| 75 |
|
*/ |
| 76 |
|
public function setAddCategory($name) { |
| 77 |
|
$dbc = App::getDb(); |
| 78 |
|
|
| 79 |
|
if ($this->getTestCategoryExist($name) !== false) { |
| 80 |
|
FlashMessage::setFlash("Cette catégorie existe déjà, merci de changer de nom"); |
| 81 |
|
return false; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
$dbc->insert("category", $name)->insert("url_category", ChaineCaractere::setUrl($name))->into("_blog_category")->set(); |
| 85 |
|
FlashMessage::setFlash("Votre catégorie a été correctement ajoutée", "success"); |
| 86 |
|
return true; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
/** |
| 90 |
|
* @param $name |
|
@@ 95-108 (lines=14) @@
|
| 92 |
|
* @return bool |
| 93 |
|
* function to edit the name of a category |
| 94 |
|
*/ |
| 95 |
|
public function setEditCategory($name, $id) { |
| 96 |
|
$dbc = App::getDb(); |
| 97 |
|
|
| 98 |
|
if ($this->getTestCategoryExist($name, $id) !== false) { |
| 99 |
|
FlashMessage::setFlash("Cette catégorie existe déjà, merci de changer de nom"); |
| 100 |
|
return false; |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
$dbc->update("category", $name)->update("url_category", ChaineCaractere::setUrl($name)) |
| 104 |
|
->from("_blog_category")->where("ID_category", "=", $id)->set(); |
| 105 |
|
|
| 106 |
|
FlashMessage::setFlash("Votre catégorie a été correctement ajoutée", "success"); |
| 107 |
|
return true; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
/** |
| 111 |
|
* @param $categories |