public static function delete_static_route($news_article_id)
 {
     return cms_route_manager::del_static('', 'News', $news_article_id);
 }
 /**
  * Delete the current content object from the database.
  *
  * @todo this function should return something, or throw an exception
  */
 function Delete()
 {
     $gCms = cmsms();
     global $debug_errors;
     $config = $gCms->GetConfig();
     Events::SendEvent('Core', 'ContentDeletePre', array('content' => &$this));
     $db = $gCms->GetDb();
     $result = false;
     if (-1 > $this->mId) {
         if (true == $config["debug"]) {
             # :TODO: Translate the error message
             $debug_errors .= "<p>Could not delete content : invalid Id</p>\n";
         }
     } else {
         $query = "DELETE FROM " . cms_db_prefix() . "content WHERE content_id = ?";
         $dbresult = $db->Execute($query, array($this->mId));
         if (!$dbresult) {
             if (true == $config["debug"]) {
                 # :TODO: Translate the error message
                 $debug_errors .= "<p>Error deleting content</p>\n";
             }
         }
         // Fix the item_order if necessary
         $query = "UPDATE " . cms_db_prefix() . "content SET item_order = item_order - 1 WHERE parent_id = ? AND item_order > ?";
         $result = $db->Execute($query, array($this->ParentId(), $this->ItemOrder()));
         $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php';
         @unlink($cachefilename);
         // DELETE properties
         $query = 'DELETE FROM ' . cms_db_prefix() . 'content_props WHERE content_id = ?';
         $result = $db->Execute($query, array($this->mId));
         $this->_props = null;
         // Delete additional editors.
         $query = 'DELETE FROM ' . cms_db_prefix() . 'additional_users WHERE content_id = ?';
         $result = $db->Execute($query, array($this->mId));
         $this->mAdditionalEditors = null;
         // Delete route
         if ($this->mURL != '') {
             cms_route_manager::del_static($this->mURL);
         }
     }
     Events::SendEvent('Core', 'ContentDeletePost', array('content' => &$this));
 }
Exemple #3
0
 public function CreateStaticRoutes()
 {
     $db = cmsms()->GetDb();
     cms_route_manager::del_static('', $this->GetName());
     try {
         $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)\\/d,(?P<detailtemplate>.*?)$/', $this->GetName());
         cms_route_manager::add_static($route);
         $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)$/', $this->GetName());
         cms_route_manager::add_static($route);
         $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)$/', $this->GetName());
         cms_route_manager::add_static($route);
         $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)$/', $this->GetName(), array('returnid' => $this->GetPreference('detail_returnid', -1)));
         cms_route_manager::add_static($route);
     } catch (Exception $e) {
         audit('', $this->GetName(), 'Error updating routes');
     }
     $query = 'SELECT news_id,news_url FROM ' . cms_db_prefix() . 'module_news
           WHERE status = ? AND news_url != ? AND ' . '(' . $db->ifNull('start_time', $db->DbTimeStamp(1)) . ' < NOW()) AND ' . '((' . $db->IfNull('end_time', $db->DbTimeStamp(1)) . ' = ' . $db->DbTimeStamp(1) . ') OR (end_time > NOW()))';
     $query .= ' ORDER BY news_date DESC';
     $tmp = $db->GetArray($query, array('published', ''));
     if (is_array($tmp)) {
         foreach ($tmp as $one) {
             try {
                 news_admin_ops::register_static_route($one['news_url'], $one['news_id']);
             } catch (Exception $e) {
                 audit('', $this->GetName(), 'Error updating routes');
             }
         }
     }
 }