} print json_encode($result); break; case "delete_article": $article = new cms_article($id); $res = $article->delete(); if ($res !== true) { $result = array("status" => "ko", "error_message" => $charset != "uft-8" ? utf8_encode($res) : $res); } else { $result = array('status' => "ok"); } print json_encode($result); break; case "duplicate_section": $section = new cms_section($id); $section->duplicate($recursive); break; case "duplicate_article": $article = new cms_article($id); $article->duplicate(); break; case "edit_logo": $logo = new cms_logo($id, $quoi); print $logo->get_field(); break; case 'update_article': header('Content-type: text/html;charset=' . $charset); $articles = explode(",", $articles); $order = 1; foreach ($articles as $id_article) { $article = new cms_article($id_article);
public function duplicate($recursive, $num_parent = 0) { global $dbh; if (!$num_parent) { $num_parent = $this->num_parent; } //on place la nouvelle rubrique à la fin par défaut $query = "SELECT id_section FROM cms_sections WHERE section_num_parent=" . addslashes($num_parent); $result = pmb_mysql_query($query, $dbh); if ($result) { $order = ",section_order = '" . (pmb_mysql_num_rows($result) + 1) . "' "; } else { $order = ",section_order = 1"; } $insert = "insert into cms_sections set\r\n\t\tsection_title = '" . addslashes($this->title) . "',\r\n\t\tsection_resume = '" . addslashes($this->resume) . "',\n\t\tsection_logo = '" . addslashes($this->logo->data) . "',\r\n\t\tsection_publication_state ='" . addslashes($this->publication_state) . "',\r\n\t\tsection_start_date = '" . addslashes($this->start_date) . "',\r\n\t\tsection_end_date = '" . addslashes($this->end_date) . "',\r\n\t\tsection_num_parent = '" . addslashes($num_parent) . "' ,\r\n\t\tsection_num_type = '" . $this->num_type . "' ,\r\n\t\tsection_creation_date=sysdate() " . $order; pmb_mysql_query($insert, $dbh); $id = pmb_mysql_insert_id(); //au tour des descripteurs... for ($i = 0; $i < count($this->descriptors); $i++) { $rqt = "insert into cms_sections_descriptors set num_section = '" . $id . "', num_noeud = '" . $this->descriptors[$i] . "',section_descriptor_order='" . $i . "'"; pmb_mysql_query($rqt, $dbh); } //on crée la nouvelle instance $new_section = new cms_section($id); //enfin les éléments du type de contenu $types = new cms_editorial_types("section"); $types->duplicate_type_form($this->num_type, $id, $this->id); $new_section->maj_indexation(); $new_section->documents_linked = $this->documents_linked; $new_section->save_documents(); //audit audit::insert_creation(AUDIT_EDITORIAL_SECTION, $id); if ($recursive) { //on duplique les rubriques enfants $query = "select id_section from cms_sections where section_num_parent = " . $this->id . " order by section_order"; $result = pmb_mysql_query($query, $dbh); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { $child = new cms_section($row->id_section); $child->duplicate($recursive, $id); } } //on duplique les articles enfants $query = "select id_article from cms_articles where num_section = " . $this->id . " order by article_order"; $result = pmb_mysql_query($query, $dbh); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { $article = new cms_article($row->id_article); $article->duplicate($id); } } } }