示例#1
0
 public function save()
 {
     if ($this->id) {
         $save = "update ";
         $order = "";
         $clause = "where id_article = '" . $this->id . "'";
     } else {
         $save = "insert into ";
         //on place le nouvel article à la fin par défaut
         $query = "SELECT id_article FROM cms_articles WHERE num_section=" . addslashes($this->num_parent);
         $result = mysql_query($query);
         $order = ",article_order = '" . (mysql_num_rows($result) + 1) . "' ";
         $clause = "";
     }
     $save .= "cms_articles set \n\t\tarticle_title = '" . addslashes($this->title) . "', \n\t\tarticle_resume = '" . addslashes($this->resume) . "', \n\t\tarticle_contenu = '" . addslashes($this->contenu) . "',\n\t\tarticle_publication_state ='" . addslashes($this->publication_state) . "', \n\t\tarticle_start_date = '" . addslashes($this->start_date) . "', \n\t\tarticle_end_date = '" . addslashes($this->end_date) . "', \n\t\tnum_section = '" . addslashes($this->num_parent) . "', \n\t\tarticle_num_type = '" . $this->num_type . "' " . (!$this->id ? ",article_creation_date=sysdate() " : "") . "\n\t\t{$order}" . "\n\t\t{$clause}";
     mysql_query($save);
     if (!$this->id) {
         $this->id = mysql_insert_id();
     }
     //au tour des descripteurs...
     //on commence par tout retirer...
     $del = "delete from cms_articles_descriptors where num_article = '" . $this->id . "'";
     mysql_query($del);
     for ($i = 0; $i < count($this->descriptors); $i++) {
         $rqt = "insert into cms_articles_descriptors set num_article = '" . $this->id . "', num_noeud = '" . $this->descriptors[$i] . "',article_descriptor_order='" . $i . "'";
         mysql_query($rqt);
     }
     //et maintenant le logo...
     $this->save_logo();
     //enfin les éléments du type de contenu
     $types = new cms_editorial_types("article");
     $types->save_type_form($this->num_type, $this->id);
     $this->maj_indexation();
     $this->save_documents();
 }
 public function save()
 {
     global $dbh;
     $audit_id = $this->id;
     if ($this->id) {
         $save = "update ";
         $order = "";
         $clause = "where id_section = '" . $this->id . "'";
     } else {
         $save = "insert into ";
         //on place la nouvelle rubrique à la fin par défaut
         $query = "SELECT id_section FROM cms_sections WHERE section_num_parent=" . addslashes($this->num_parent);
         $result = pmb_mysql_query($query, $dbh);
         $order = ",section_order = '" . (pmb_mysql_num_rows($result) + 1) . "' ";
         $clause = "";
     }
     $save .= "cms_sections set \n\t\tsection_title = '" . addslashes($this->title) . "', \n\t\tsection_resume = '" . addslashes($this->resume) . "', \n\t\tsection_publication_state ='" . addslashes($this->publication_state) . "', \n\t\tsection_start_date = '" . addslashes($this->start_date) . "', \n\t\tsection_end_date = '" . addslashes($this->end_date) . "', \n\t\tsection_num_parent = '" . addslashes($this->num_parent) . "' ,\n\t\tsection_num_type = '" . $this->num_type . "'  " . (!$this->id ? ",section_creation_date=sysdate() " : "") . "\n\t\t{$order}" . "\n\t\t{$clause}";
     pmb_mysql_query($save, $dbh);
     if (!$this->id) {
         $this->id = pmb_mysql_insert_id();
     }
     //au tour des descripteurs...
     //on commence par tout retirer...
     $del = "delete from cms_sections_descriptors where num_section = '" . $this->id . "'";
     pmb_mysql_query($del, $dbh);
     for ($i = 0; $i < count($this->descriptors); $i++) {
         $rqt = "insert into cms_sections_descriptors set num_section = '" . $this->id . "', num_noeud = '" . $this->descriptors[$i] . "',section_descriptor_order='" . $i . "'";
         pmb_mysql_query($rqt, $dbh);
     }
     //et maintenant le logo...
     $this->save_logo();
     //enfin les éléments du type de contenu
     $types = new cms_editorial_types("section");
     $types->save_type_form($this->num_type, $this->id);
     $this->maj_indexation();
     $this->save_documents();
     //bouton pour le cache
     $upd = "UPDATE cms_sections SET section_update_timestamp = now() WHERE id_section = '" . $this->id . "'";
     pmb_mysql_query($upd, $dbh);
     //Audit
     if (!$audit_id) {
         audit::insert_creation(AUDIT_EDITORIAL_SECTION, $this->id);
     } else {
         audit::insert_modif(AUDIT_EDITORIAL_SECTION, $this->id);
     }
 }