/** * Get cache object * @return CampCache */ public function getCache() { if ($this->cache === NULL) { $this->cache = CampCache::singleton(); } return $this->cache; }
/** * Legacy admin bootstrap */ protected function _initNewscoop() { global $ADMIN, $g_user, $prefix, $Campsite; defined('WWW_DIR') || define('WWW_DIR', realpath(APPLICATION_PATH . '/../')); defined('LIBS_DIR') || define('LIBS_DIR', WWW_DIR . '/admin-files/libs'); $GLOBALS['g_campsiteDir'] = WWW_DIR; require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php'; require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php'; // goes to install process if configuration files does not exist yet if (!file_exists(CS_PATH_CONFIG . DIR_SEP . 'configuration.php') || !file_exists(CS_PATH_CONFIG . DIR_SEP . 'database_conf.php')) { header('Location: ' . $Campsite['SUBDIR'] . '/install/'); exit; } require_once CS_PATH_CONFIG . DIR_SEP . 'database_conf.php'; require_once CS_PATH_SITE . DIR_SEP . 'include' . DIR_SEP . 'campsite_init.php'; require_once CS_PATH_SITE . DIR_SEP . 'classes' . DIR_SEP . 'CampTemplateCache.php'; // detect extended login/logout files $prefix = file_exists(CS_PATH_SITE . DIR_SEP . 'admin-files' . DIR_SEP . 'ext_login.php') ? '/ext_' : '/'; require_once CS_PATH_SITE . '/admin-files/camp_html.php'; require_once CS_PATH_CLASSES . DIR_SEP . 'SecurityToken.php'; if (php_sapi_name() !== 'cli') { set_error_handler(function ($p_number, $p_string, $p_file, $p_line) { error_log(sprintf('Newscoop error: %s in %s:%d', $p_string, $p_file, $p_line)); global $Campsite; require_once $Campsite['HTML_DIR'] . "/admin-files/bugreporter/bug_handler_main.php"; camp_bug_handler_main($p_number, $p_string, $p_file, $p_line); }, error_reporting()); } if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) { CampCache::singleton()->clear('user'); unlink($GLOBALS['g_campsiteDir'] . '/reset_cache'); } }
public function delete() { $deleted = parent::delete(); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $deleted; }
/** * Delete the language, this will also delete the language files unless * the parameter specifies otherwise. * * @return boolean */ public function delete($p_deleteLanguageFiles = true) { if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) { unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php'); } $tmpData = $this->m_data; $success = parent::delete(); if ($success) { CampCache::singleton()->clear('user'); } return $success; }
/** * Legacy admin bootstrap */ protected function _initNewscoop() { global $ADMIN_DIR, $ADMIN, $g_user, $prefix, $Campsite; defined('WWW_DIR') || define('WWW_DIR', realpath(APPLICATION_PATH . '/../')); defined('LIBS_DIR') || define('LIBS_DIR', WWW_DIR . '/admin-files/libs'); $GLOBALS['g_campsiteDir'] = WWW_DIR; require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php'; require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php'; // goes to install process if configuration files does not exist yet if (!file_exists(CS_PATH_CONFIG . DIR_SEP . 'configuration.php') || !file_exists(CS_PATH_CONFIG . DIR_SEP . 'database_conf.php')) { header('Location: ' . $Campsite['SUBDIR'] . '/install/'); exit; } require_once CS_PATH_CONFIG . DIR_SEP . 'database_conf.php'; require_once CS_PATH_SITE . DIR_SEP . 'include' . DIR_SEP . 'campsite_init.php'; require_once CS_PATH_SITE . DIR_SEP . 'classes' . DIR_SEP . 'CampTemplateCache.php'; // detect extended login/logout files $prefix = file_exists(CS_PATH_SITE . DIR_SEP . 'admin-files' . DIR_SEP . 'ext_login.php') ? '/ext_' : '/'; require_once CS_PATH_SITE . DIR_SEP . $ADMIN_DIR . DIR_SEP . 'camp_html.php'; require_once CS_PATH_CLASSES . DIR_SEP . 'SecurityToken.php'; // load if possible before setting camp_report_bug error handler // to prevent error messages include_once 'HTML/QuickForm.php'; include_once 'HTML/QuickForm/RuleRegistry.php'; include_once 'HTML/QuickForm/group.php'; if (!defined('IN_PHPUNIT') && !getenv('PLZSTOPTHISERRORHANDLERBIZNIS')) { set_error_handler(function ($p_number, $p_string, $p_file, $p_line) { if (($p_number & error_reporting()) === 0) { return; // respect php settings } global $ADMIN_DIR, $Campsite; require_once $Campsite['HTML_DIR'] . "/{$ADMIN_DIR}/bugreporter/bug_handler_main.php"; camp_bug_handler_main($p_number, $p_string, $p_file, $p_line); }, E_ALL); } camp_load_translation_strings("api"); $plugins = CampPlugin::GetEnabled(true); foreach ($plugins as $plugin) { camp_load_translation_strings("plugin_" . $plugin->getName()); } // Load common translation strings camp_load_translation_strings('globals'); require_once APPLICATION_PATH . "/../{$ADMIN_DIR}/init_content.php"; if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) { CampCache::singleton()->clear('user'); unlink($GLOBALS['g_campsiteDir'] . '/reset_cache'); } }
public function indexAction() { global $controller; $controller = $this; require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php'; require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php'; $local_path = dirname(__FILE__) . '/include'; set_include_path($local_path . PATH_SEPARATOR . get_include_path()); require_once CS_PATH_INCLUDES . DIR_SEP . 'campsite_init.php'; if (file_exists(CS_PATH_SITE . DIR_SEP . 'reset_cache')) { CampCache::singleton()->clear('user'); @unlink(CS_PATH_SITE . DIR_SEP . 'reset_cache'); } // initializes the campsite object $campsite = new CampSite(); // loads site configuration settings $campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php'); // starts the session $campsite->initSession(); if (file_exists(CS_PATH_SITE . DIR_SEP . 'conf' . DIR_SEP . 'upgrading.php')) { $this->upgrade(); exit(0); } // initiates the context $campsite->init(); // dispatches campsite $campsite->dispatch(); // triggers an event before render the page. // looks for preview language if any. $previewLang = $campsite->event('beforeRender'); if (!is_null($previewLang)) { require_once $GLOBALS['g_campsiteDir'] . '/template_engine/classes/SyntaxError.php'; set_error_handler('templateErrorHandler'); // loads translations strings in the proper language for the error messages display camp_load_translation_strings('preview', $previewLang); } else { set_error_handler(create_function('', 'return true;')); } if ($this->_request->getParam('logout') == 'true') { $this->_redirect('/auth/logout/?url=' . urlencode($this->getRequest()->getPathInfo())); } // renders the site $campsite->render(); // triggers an event after displaying $campsite->event('afterRender'); }
public static function RunIndexer($p_timeLimit = null, $p_articlesLimit = null, $p_lastModifiedFirst = true) { global $g_ado_db; $startTime = microtime(true); $rowsLimit = 0; if (!is_null($p_timeLimit)) { $rowsLimit = (int)$p_timeLimit * 5; } if (!is_null($p_articlesLimit)) { $rowsLimit = $rowsLimit > 0 ? min($rowsLimit, $p_articlesLimit) : $p_articlesLimit; } $lockFile = fopen($GLOBALS['g_campsiteDir'].'/newscoop-indexer.lock', "w+"); if ($lockFile === false) { return new PEAR_Error("Unable to create single process lock control!"); } if (!flock($lockFile, LOCK_EX | LOCK_NB)) { // do an exclusive lock return new PEAR_Error("Another indexer process is already running!"); } try { if ($p_lastModifiedFirst) { $order = 'time_updated DESC'; } else { $order = 'Number ASC'; } $limit = $rowsLimit > 0 ? "LIMIT 0, $rowsLimit" : null; // selects articles not yet indexed $sql_query = 'SELECT art.IdPublication, art.NrIssue, art.NrSection, art.Number, ' . "art.IdLanguage, art.Type, art.Keywords, art.Name \n" . "FROM Articles as art \n" . "WHERE art.IsIndexed = 'N' ORDER BY $order $limit"; $sql_result = $g_ado_db->GetAll($sql_query); if ($sql_result === false) { throw new Exception('Error selecting articles not yet indexed'); } $sql = "SELECT COUNT(*) FROM Articles WHERE IsIndexed = 'N'"; $total_art = $g_ado_db->GetOne($sql); $nr_art = 0; $nr_new = 0; $nr_word = 0; $word_cache_hits = 0; $articleWordsBatch = array(); $wordInsertQueries = 0; $existing_words = array(); foreach ($sql_result as $row) { $sql = "SELECT GROUP_CONCAT(CONCAT_WS(' ', first_name, last_name) SEPARATOR ', ')" . "FROM Authors AS au, ArticleAuthors AS aa " . "WHERE au.id = aa.fk_author_id AND aa.fk_article_number = " . (int)$row['Number'] . " AND aa.fk_language_id = " . (int)$row['IdLanguage']; $article['AuthorName'] = $g_ado_db->GetOne($sql); $article['IdPublication'] = ($row['IdPublication']) ? (int)$row['IdPublication'] : 0; $article['NrIssue'] = ($row['NrIssue']) ? (int)$row['NrIssue'] : 0; $article['NrSection'] = ($row['NrSection']) ? (int)$row['NrSection'] : 0; $article['Number'] = ($row['Number']) ? (int)$row['Number'] : 0; $article['IdLanguage'] = ($row['IdLanguage']) ? (int)$row['IdLanguage'] : 0; $article['Type'] = ($row['Type']) ? $row['Type'] : ''; $article['Keywords'] = ($row['Keywords']) ? $row['Keywords'] : ''; $article['Name'] = ($row['Name']) ? $row['Name'] : ''; // deletes from index $sql_query = 'DELETE FROM ArticleIndex ' . 'WHERE IdPublication = ' . $article['IdPublication'] . ' AND IdLanguage = ' . $article['IdLanguage'] . ' AND NrIssue = ' . $article['NrIssue'] . ' AND NrSection = ' . $article['NrSection'] . ' AND NrArticle = ' . $article['Number']; if (!$g_ado_db->Execute($sql_query)) { throw new Exception('Error deleting the old article index'); } $nr_art++; $keywordsHash = array(); self::BuildKeywordsList($article, $keywordsHash); foreach ($keywordsHash as $keyword=>$isSet) { if (empty($keyword)) { continue; } $nr_word++; if (isset($existing_words[$keyword])) { $kwd_id = $existing_words[$keyword]; $word_cache_hits++; } else { $sql_query = 'SELECT Id FROM KeywordIndex ' . "WHERE Keyword = '" . $g_ado_db->escape($keyword) ."'"; $kwd_id = 0 + $g_ado_db->GetOne($sql_query); $existing_words[$keyword] = $kwd_id; } if ($kwd_id == 0) { $sql_query = 'SELECT MAX(Id) AS Id FROM KeywordIndex'; $last_kwd_id = 0 + $g_ado_db->GetOne($sql_query); $kwd_id = $last_kwd_id + 1; // inserts in keyword list $sql_query = 'INSERT IGNORE INTO KeywordIndex ' . "SET Keyword = '" . $g_ado_db->escape($keyword) . "', " . "Id = $kwd_id"; if (!$g_ado_db->Execute($sql_query)) { throw new Exception('Error adding keyword'); } $existing_words[$keyword] = $kwd_id; $nr_new++; } if (!self::BatchAddArticleWord($articleWordsBatch, $article, $kwd_id, $wordInsertQueries)) { throw new Exception('Error adding article to index'); } } self::RunArticleWordBatch($articleWordsBatch, $wordInsertQueries); unset($article['Name']); unset($article['Keywords']); unset($article['Type']); $sql_query = "UPDATE Articles SET IsIndexed = 'Y' " . 'WHERE IdPublication = ' . $article['IdPublication'] . ' AND NrIssue = ' . $article['NrIssue'] . ' AND NrSection = ' . $article['NrSection'] . ' AND Number = ' . $article['Number'] . ' AND IdLanguage = ' . $article['IdLanguage']; if (!$g_ado_db->Execute($sql_query)) { throw new Exception('Error updating the article'); } if ($p_articlesLimit > 0 && $nr_art >= $p_articlesLimit) { break; } $runTime = microtime(true) - $startTime; $articleTime = $runTime / $nr_art; if ($p_timeLimit > 0 && $runTime >= ($p_timeLimit - $articleTime)) { break; } } } catch (Exception $ex) { CampCache::singleton()->clear('user'); flock($lockFile, LOCK_UN); // release the lock return new PEAR_Error($ex->getMessage() . ': ' . $g_ado_db->ErrorMsg()); } CampCache::singleton()->clear('user'); flock($lockFile, LOCK_UN); // release the lock $totalTime = microtime(true) - $startTime; $articleTime = $nr_art > 0 ? $totalTime / $nr_art : 0; return array('articles'=>$nr_art, 'words'=>$nr_word, 'new words'=>$nr_new, 'total articles'=>$total_art, 'total time'=>$totalTime, 'article time'=>$articleTime, 'word cache hits'=>$word_cache_hits, 'word insert queries'=>$wordInsertQueries); } // fn RunIndexer
public static function DeleteActionsFromCache() { if (CampCache::IsEnabled()) { return CampCache::singleton()->delete(self::CACHE_KEY_LIST_OF_ACTIONS); } return false; }
/** * Method to call parent::setProperty * with clening the cache. * * @param string $p_name * @param sring $p_value */ function setProperty($p_name, $p_value) { $return = parent::setProperty($p_name, $p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; }
public function deleteFromCache() { if (CampCache::IsEnabled()) { CampCache::singleton()->delete($this->getCacheKey()); } }
function delete() { $entry_id = $this->getProperty('entry_id'); $blog_id = $this->getProperty('fk_blog_id'); foreach (BlogComment::getComments(array('entry_id' => $this->getProperty('entry_id'))) as $Comment) { $Comment->delete(); } parent::delete(); BlogImageHelper::RemoveImageDerivates('entry', $entry_id); BlogentryTopic::OnBlogentryDelete($entry_id); Blog::TriggerCounters($blog_id); $CampCache = CampCache::singleton(); $CampCache->clear('user'); }
/** * Set the article workflow on issue status change. Articles to be * published with the issue will be published on article publish. * Published articles are set to "publish with issue" on issue * unpublish. * * @param int $p_publicationId * @param int $p_languageId * @param int $p_issueNo * @param int $p_publish */ public static function OnIssuePublish($p_publicationId, $p_languageId, $p_issueNo, $p_publish = true) { global $g_ado_db; settype($p_publicationId, 'integer'); settype($p_languageId, 'integer'); settype($p_issueNo, 'integer'); $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo); if (!$issueObj->exists()) { return false; } if (($issueObj->isPublished() && $p_publish) || (!$issueObj->isPublished() && !$p_publish)) { return false; } $fromState = $p_publish ? 'M' : 'Y'; $toState = $p_publish ? 'Y' : 'M'; $sql = "UPDATE Articles SET Published = '$toState' WHERE " . "IdPublication = $p_publicationId AND IdLanguage = $p_languageId" . " AND NrIssue = $p_issueNo AND Published = '$fromState'"; $res = $g_ado_db->Execute($sql); CampCache::singleton()->clear('user'); if (CampTemplateCache::factory()) { CampTemplateCache::factory()->update(array( 'language' => $p_languageId, 'publication' => $p_publicationId, 'issue' => $p_issueNo, 'section' => null, 'article' => null, )); } return $res; }
/** * Get all comments associated with the given article. * * @param int $p_articleNumber * @param int $p_languageId * @param string $p_status * This can be NULL if you dont care about the status, * "approved" or "unapproved". * @param boolean $p_countOnly * @return array */ public static function GetArticleComments($p_articleNumber, $p_languageId, $p_status = null, $p_countOnly = false, $p_skipCache = true) { global $PHORUM, $g_ado_db; if (CampCache::IsEnabled() && !$p_skipCache) { $cacheKey = __METHOD__ . '_' . (int)$p_articleNumber . '_' . (int)$p_languageId . '_' . $p_status . '_' . (int)$p_count_only; $result = CampCache::singleton()->fetch($cacheKey); if ($result !== false) { return $result; } } $threadId = ArticleComment::GetCommentThreadId($p_articleNumber, $p_languageId); if (!$threadId) { $result = $p_countOnly ? 0 : null; if (CampCache::IsEnabled()) { CampCache::singleton()->store($cacheKey, $result); } return $result; } // Are we counting or getting the comments? $selectClause = "*"; if ($p_countOnly) { $selectClause = "COUNT(*)"; } // Only getting comments with a specific status? $whereClause = ""; if (!is_null($p_status)) { if ($p_status == "approved") { $whereClause = " AND status=".PHORUM_STATUS_APPROVED; } elseif ($p_status == "unapproved") { $whereClause = " AND status=".PHORUM_STATUS_HIDDEN; } } $queryStr = "SELECT $selectClause " ." FROM ".$PHORUM['message_table'] ." WHERE thread=$threadId" ." AND message_id != thread" . $whereClause ." ORDER BY message_id"; if ($p_countOnly) { $result = $g_ado_db->GetOne($queryStr); } else { $result = DbObjectArray::Create("Phorum_message", $queryStr); } if (CampCache::IsEnabled() && !$p_skipCache) { CampCache::singleton()->store($cacheKey, $result, self::DEFAULT_TTL); } return $result; } // fn GetArticleComments
/** * Execute all pending actions. * @return void */ public static function DoPendingActions() { $actions = IssuePublish::GetPendingActions(); foreach ($actions as $issuePublishObj) { $issuePublishObj->doAction(); } if (count($actions) > 0) { CampCache::singleton()->clear('user'); } return count($actions); }
public function setProperty($p_name, $p_value) { switch ($p_name) { case 'question': case 'answer': if ($this->getProperty($p_name) == '') { parent::setProperty($p_name.'_date', date('Y-m-d H:i:s')); } break; } $return = parent::setProperty($p_name, $p_value); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; }
/** * Update order for all items in tree. * * @param array $order * $parent => array( * $order => $topicId * ); * @return bool */ public static function UpdateOrder(array $p_order) { global $g_ado_db; $orderChanged = false; foreach ($p_order as $parentId => $order) { list(, $parentId) = explode('_', $parentId); $parentTopic = new Topic((int) $parentId); $subtopics = $parentTopic->getSubtopics(true); if (count($subtopics) != count($order)) { return false; } foreach ($order as $newTopicOrder => $topicId) { list(, $topicId) = explode('_', $topicId); if ($subtopics[$newTopicOrder] != $topicId) { $oldTopicOrder = array_search($topicId, $subtopics); self::SwitchTopics($subtopics[$newTopicOrder], $topicId, $parentTopic); $subtopics[$oldTopicOrder] = $subtopics[$newTopicOrder]; $subtopics[$newTopicOrder] = $topicId; $orderChanged = true; } } } if ($orderChanged) { CampCache::singleton()->clear('user'); } return TRUE; }
private static function DeleteCachePluginsInfo() { if (CampCache::IsEnabled()) { $cacheListObj = new CampCacheList(array(), self::CACHE_KEY_PLUGINS_ALL); $cacheListObj->deleteFromCache(); return CampCache::singleton()->delete(self::CACHE_KEY_PLUGINS_LIST); } return false; }
/** * Deletes the current article type field. */ public function delete() { global $g_ado_db; if (!$this->exists()) { return false; } $orders = $this->getOrders(); $translation = new Translation(null, $this->getPhraseId()); $translation->deletePhrase(); if ($this->getPrintName() != 'NULL') { $queryStr = "ALTER TABLE `X" . $this->m_data['type_name'] . "` DROP COLUMN `" . $this->getName() . "`"; $success = $g_ado_db->Execute($queryStr); } if ($success || $this->getPrintName() == 'NULL') { $myType = $this->getType(); if ($myType == self::TYPE_TOPIC) { $queryStr = "DELETE FROM TopicFields WHERE ArticleType = '" . $g_ado_db->escape($this->m_data['type_name']) . "' and FieldName = '" . $g_ado_db->escape($this->m_data['field_name']) . "'"; $g_ado_db->Execute($queryStr); $this->m_rootTopicId = null; } $fieldName = $this->m_data['field_name']; $success = parent::delete(); } // reorder if ($success) { $newOrders = array(); foreach ($orders as $k => $v) { if ($v != $this->m_data['field_name']) $newOrders[] = $v; } $newOrders = array_reverse($newOrders); $this->setOrders($newOrders); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Article type field "$1" deleted', $fieldName); Log::Message($logtext, null, 72); CampCache::singleton()->clear('user'); } return $success; } // fn delete
/** * Delete record from database. * * @return boolean */ function delete() { // delete correspondending Attachment object if not used by other DebateAnswers $DebateAnswerAttachments = DebateAnswerAttachment::getDebateAnswerAttachments(null, null, $this->getProperty('fk_attachment_id')); if (count($DebateAnswerAttachments) === 1) { $DebateAnswerAttachment = current($DebateAnswerAttachments); $DebateAnswerAttachment->getAttachment()->delete(); } // Delete record from the database $deleted = parent::delete(); /* if ($deleted) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Article #$1: "$2" ($3) deleted.', $this->m_data['Number'], $this->m_data['Name'], $this->getLanguageName()) ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", " ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", " ." ".getGS("Section")." ".$this->m_data['NrSection'].")"; Log::Message($logtext, null, 32); } */ $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $deleted; }
$request = camp_session_get("request_$requestId", ''); if (!empty($request)) { $request = unserialize($request); // Update security token. $token_field = SecurityToken::SECURITY_TOKEN; $request['post'][$token_field] = SecurityToken::GetToken(); // Set values. foreach ($request['post'] as $key => $val) { $_POST[$key] = $_REQUEST[$key] = $val; } } if (file_exists($Campsite['HTML_DIR'] . '/reset_cache')) { CampCache::singleton()->clear('user'); unlink($GLOBALS['g_campsiteDir'] . '/reset_cache'); } require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/init_content.php"); // Get the main content ob_start(); require_once($path_name); $content = ob_get_clean(); // We create the top menu AFTER the main content because // of the localizer screen. It will update the strings, which // need to be reflected immediately in the menu. $_top_menu = ''; if ($needs_menu) { ob_start();
/** * Delete the language, this will also delete the language files unless * the parameter specifies otherwise. * * @return boolean */ public function delete($p_deleteLanguageFiles = true) { if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) { unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php'); } if ($p_deleteLanguageFiles) { $result = Localizer::DeleteLanguageFiles($this->getCode()); if (PEAR::isError($result)) { return result; } } $tmpData = $this->m_data; $success = parent::delete(); if ($success) { CampCache::singleton()->clear('user'); } return $success; }
public static function DeleteBlogentryTopics($p_blogentry_id) { global $g_ado_db; $query = "DELETE FROM ".BlogentryTopic::$s_dbTableName." WHERE fk_entry_id = $p_blogentry_id"; $return = $g_ado_db->execute($query); $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $return; }
// initiates the campsite site $campsite = new CampSite(); // loads site configuration settings $campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php'); // starts the session $campsite->initSession(); $session = CampSite::GetSessionInstance(); $configDb = array('hostname' => $Campsite['db']['host'], 'hostport' => $Campsite['db']['port'], 'username' => $Campsite['db']['user'], 'userpass' => $Campsite['db']['pass'], 'database' => $Campsite['db']['name']); $session->setData('config.db', $configDb, 'installation'); // upgrading the database $res = camp_upgrade_database($Campsite['DATABASE_NAME'], true, true); if ($res !== 0) { display_upgrade_error("While upgrading the database: {$res}"); } CampCache::singleton()->clear('user'); CampCache::singleton()->clear(); SystemPref::DeleteSystemPrefsFromCache(); // replace $campsite by $gimme require_once $g_documentRoot . '/classes/TemplateConverterNewscoop.php'; $template_files = camp_read_files($g_documentRoot . '/templates'); $converter = new TemplateConverterNewscoop(); if (!empty($template_files)) { foreach ($template_files as $template_file) { $converter->read($template_file); $converter->parse(); $converter->write(); } } // update plugins CampPlugin::OnUpgrade(); CampRequest::SetVar('step', 'finish');
public static function GetInvalidURLTemplate($p_pubId, $p_issNr = NULL, $p_lngId = NULL, $p_isPublished = true) { global $g_ado_db; $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); if (CampCache::IsEnabled()) { $paramString = $p_lngId . '_' . $p_pubId . '_' . $p_issNr; $cacheKey = __CLASS__ . '_IssueTemplate_' . $paramString; $issueTemplate = CampCache::singleton()->fetch($cacheKey); if ($issueTemplate !== false && !empty($issueTemplate)) { return $issueTemplate; } } $publication = null; if (is_null($p_lngId)) { $publication = new Publication($p_pubId); if (!$publication->exists()) { $template = null; } $p_lngId = $publication->getLanguageId(); } if (is_null($p_issNr) && (!is_null($publication) || !is_null($p_pubId))) { if (is_null($publication)) { $publication = new Publication($p_pubId); } $lastIssue = self::GetLastIssue($publication, $p_lngId, $p_isPublished); if (is_null($lastIssue)) { $template = null; } $p_issNr = $lastIssue[0]; } if (!is_null($p_issNr)) { $resourceId = new ResourceId('template_engine/classes/CampSystem'); $outputService = $resourceId->getService(IOutputService::NAME); if (!\Zend_Registry::isRegistered('webOutput')) { $cacheKeyWebOutput = $cacheService->getCacheKey(array('OutputService', 'Web'), 'outputservice'); if ($cacheService->contains($cacheKeyWebOutput)) { \Zend_Registry::set('webOutput', $cacheService->fetch($cacheKeyWebOutput)); } else { $webOutput = $outputService->findByName('Web'); $cacheService->save($cacheKeyWebOutput, $webOutput); \Zend_Registry::set('webOutput', $webOutput); } } $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME); $issueObj = new Issue($p_pubId, $p_lngId, $p_issNr); $template = $templateSearchService->getErrorPage($issueObj->getIssueId(), Zend_Registry::get('webOutput')); } if (empty($template)) { $template = null; } if (CampCache::IsEnabled()) { CampCache::singleton()->store($cacheKey, $template); } return $template; }
/** * */ protected function execute() { $input = CampRequest::GetInput('post'); $session = CampSession::singleton(); $this->m_step = (!empty($input['step'])) ? $input['step'] : $this->m_defaultStep; switch($this->m_step) { case 'precheck': break; case 'license': $session->unsetData('config.db', 'installation'); $session->unsetData('config.site', 'installation'); $session->unsetData('config.demo', 'installation'); $this->preInstallationCheck(); break; case 'database': $this->license(); break; case 'mainconfig': $prevStep = (isset($input['this_step'])) ? $input['this_step'] : ''; if ($prevStep != 'loaddemo' && $this->databaseConfiguration($input)) { $session->setData('config.db', $this->m_config['database'], 'installation', true); } break; case 'loaddemo': $prevStep = (isset($input['this_step'])) ? $input['this_step'] : ''; if ($prevStep != 'loaddemo' && $this->generalConfiguration($input)) { $session->setData('config.site', $this->m_config['mainconfig'], 'installation', true); } break; case 'cronjobs': if (isset($input['install_demo'])) { $session->setData('config.demo', array('loaddemo' => $input['install_demo']), 'installation', true); if ($input['install_demo'] != '0') { if (!$this->loadDemoSite()) { break; } } } break; case 'finish': if (isset($input['install_demo'])) { $session->setData('config.demo', array('loaddemo' => $input['install_demo']), 'installation', true); if ($input['install_demo'] != '0') { if (!$this->loadDemoSite()) { break; } } } $this->saveCronJobsScripts(); if ($this->finish()) { $this->saveConfiguration(); self::InstallPlugins(); require_once($GLOBALS['g_campsiteDir'].'/classes/SystemPref.php'); SystemPref::DeleteSystemPrefsFromCache(); // clear all cache require_once($GLOBALS['g_campsiteDir'].'/classes/CampCache.php'); CampCache::singleton()->clear('user'); CampCache::singleton()->clear(); CampTemplate::singleton()->clearCache(); } break; } } // fn execute
/** * Delete the language, this will also delete the language files unless * the parameter specifies otherwise. * * @return boolean */ public function delete($p_deleteLanguageFiles = true) { if (is_link($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php')) { unlink($GLOBALS['g_campsiteDir'] . '/' . $this->getCode() . '.php'); } if ($p_deleteLanguageFiles) { $result = Localizer::DeleteLanguageFiles($this->getCode()); if (PEAR::isError($result)) { return result; } } $tmpData = $this->m_data; $success = parent::delete(); if ($success) { CampCache::singleton()->clear('user'); if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Language "$1" ($2) deleted', $tmpData['Name'], $tmpData['OrigName']); Log::Message($logtext, null, 102); } return $success; } // fn delete
/** * Deletes the current article type field. */ public function delete() { global $g_ado_db; if (!$this->exists()) { return false; } $oldFieldName = $this->m_data['field_name']; $typeName = $this->m_data['type_name']; $typeType = $this->getType(); $orders = $this->getOrders(); $translation = new Translation(null, $this->getPhraseId()); $translation->deletePhrase(); $success = false; if ($this->getPrintName() != 'NULL') { $queryStr = "ALTER TABLE `X" . $this->m_data['type_name'] . "` DROP COLUMN `" . $this->getName() . "`"; $success = $g_ado_db->Execute($queryStr); } if ($success || $this->getPrintName() == 'NULL') { $myType = $this->getType(); if ($myType == self::TYPE_TOPIC) { $queryStr = "DELETE FROM TopicFields WHERE ArticleType = " . $g_ado_db->escape($this->m_data['type_name']) . " and FieldName = " . $g_ado_db->escape($this->m_data['field_name']); $g_ado_db->Execute($queryStr); $this->m_rootTopicId = null; } $fieldName = $this->m_data['field_name']; $success = parent::delete(); } if ($success) { if ($typeType == self::TYPE_COMPLEX_DATE) { $em = Zend_Registry::get('container')->getService('em'); $repo = $em->getRepository('Newscoop\\Entity\\ArticleDatetime'); $repo->deleteField($typeName, array('old' => $oldFieldName)); } } // reorder if ($success) { $newOrders = array(); foreach ($orders as $k => $v) { if (array_key_exists('field_name', $this->m_data)) { if ($v != $this->m_data['field_name']) { $newOrders[] = $v; } } } $newOrders = array_reverse($newOrders); $this->setOrders($newOrders); CampCache::singleton()->clear('user'); } return $success; }
private function storeInCache() { if (CampCache::IsEnabled()) { CampCache::singleton()->store($this->getCacheKey(), $this, $this->m_defaultTTL); } }
/** * Delete record from database. * * @return boolean */ function delete() { // Delete record from the database $deleted = parent::delete(); /* if ($deleted) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('Article #$1: "$2" ($3) deleted.', $this->m_data['Number'], $this->m_data['Name'], $this->getLanguageName()) ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", " ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", " ." ".getGS("Section")." ".$this->m_data['NrSection'].")"; Log::Message($logtext, null, 32); } */ $CampCache = CampCache::singleton(); $CampCache->clear('user'); return $deleted; }
/** * Returns the last published issue for the given publication / language. * Returns null if no issue was found. * * @param int $p_publicationId * @param int $p_languageId * @return mixed */ public static function GetCurrentIssue($p_publicationId, $p_languageId = null) { global $g_ado_db; if (CampCache::IsEnabled()) { $paramString = $p_publicationId . '_'; $paramString.= (is_null($p_languageId)) ? 'null_' : $p_languageId . '_'; $cacheKey = __CLASS__ . '_CurrentIssue_' . $paramString; $issue = CampCache::singleton()->fetch($cacheKey); if ($issue !== false && is_object($issue)) { return $issue; } } $queryStr = "SELECT Number, IdLanguage FROM Issues WHERE Published = 'Y' AND " . "IdPublication = $p_publicationId"; if (!is_null($p_languageId)) { $queryStr .= " AND IdLanguage = $p_languageId"; } $queryStr .= " ORDER BY Number DESC LIMIT 0, 1"; $result = $g_ado_db->GetRow($queryStr); if (is_null($result)) { return null; } $issue = new Issue($p_publicationId, $result['IdLanguage'], $result['Number']); if (CampCache::IsEnabled()) { CampCache::singleton()->store($cacheKey, $issue); } return $issue; } // fn GetCurrentIssue