Exemplo n.º 1
0
 /**
  * delete the current entry
  */
 private function delete()
 {
     if (!$this->entry['pid']) {
         return false;
     }
     if (!$this->sqlitehelper->ready()) {
         msg('BlogTNG plugin: failed to load sqlite helper plugin', -1);
         return false;
     }
     // delete comment
     if (!$this->commenthelper) {
         $this->commenthelper = plugin_load('helper', 'blogtng_comments');
     }
     $this->commenthelper->delete_all($this->entry['pid']);
     // delete tags
     if (!$this->taghelper) {
         $this->taghelper = plugin_load('helper', 'blogtng_tags');
     }
     $this->taghelper->setPid($this->entry['pid']);
     $this->taghelper->setTags(array());
     //empty tag set
     $this->taghelper->save();
     // delete entry
     $sql = "DELETE FROM entries WHERE pid = ?";
     $ret = $this->sqlitehelper->getDB()->query($sql, $this->entry['pid']);
     $this->entry = $this->prototype();
     return (bool) $ret;
 }
Exemplo n.º 2
0
 /**
  * Save the blog related meta data of a page to the sqlite DB
  *
  * @param Doku_Event $event
  * @param $param
  */
 function handle_action_act_preprocess(Doku_Event $event, $param)
 {
     list($type) = $param;
     switch ($type) {
         case 'before':
             if (is_array($event->data)) {
                 list($this->preact) = array_keys($event->data);
             } else {
                 $this->preact = $event->data;
             }
             break;
         case 'after':
             global $ID;
             if ($this->preact != 'save' || $event->data != 'show') {
                 return;
             }
             // does the page still exist? might be a deletion
             if (!page_exists($ID)) {
                 return;
             }
             $blog = $this->tools->getParam('post/blog');
             $blogs = $this->entryhelper->get_blogs();
             if (!in_array($blog, $blogs)) {
                 $blog = null;
             }
             if ($blog === null) {
                 $this->entryhelper->poke();
             } else {
                 $pid = md5($ID);
                 $this->entryhelper->load_by_pid($pid);
                 $entry = $this->_collectInfoForEntry();
                 $this->entryhelper->set($entry);
                 $this->entryhelper->entry['blog'] = $blog;
                 $this->entryhelper->entry['commentstatus'] = $this->tools->getParam('post/commentstatus');
                 if (empty($this->entryhelper->entry['page'])) {
                     $this->entryhelper->entry['page'] = $ID;
                 }
                 // allow to override created date
                 if ($this->tools->getParam('post/date') && $this->getConf('editform_set_date')) {
                     foreach (array('hh', 'mm', 'MM', 'DD') as $key) {
                         $_REQUEST['btng']['post']['date'][$key] = $_REQUEST['btng']['post']['date'][$key][0] == 0 ? $_REQUEST['btng']['post']['date'][$key][1] : $_REQUEST['btng']['post']['date'][$key];
                     }
                     $time = mktime($this->tools->getParam('post/date/hh'), $this->tools->getParam('post/date/mm'), 0, $this->tools->getParam('post/date/MM'), $this->tools->getParam('post/date/DD'), $this->tools->getParam('post/date/YY'));
                     $this->entryhelper->entry['created'] = $time;
                 }
                 $this->entryhelper->save();
                 $tags = $this->_get_post_tags();
                 if ($tags === false) {
                     $tags = array();
                 }
                 $allowed_tags = $this->_get_allowed_tags();
                 if (count($allowed_tags) > 0) {
                     foreach ($tags as $n => $tag) {
                         if (!in_array($tag, $allowed_tags)) {
                             unset($tags[$n]);
                         }
                     }
                 }
                 $this->taghelper->load($pid);
                 $this->taghelper->setTags($tags);
                 $this->taghelper->save();
             }
             break;
     }
 }