/** * fetches the help hierarchy, title phrases are included but text phrases are not * @return array * * titles contains the hierarchy which sub-help items under the 'children' key * * firstItem contains the first help item to display */ public function getTitles() { $cache = vB_Cache::instance(vB_Cache::CACHE_LARGE); $titles = $cache->read('vb_FAQ_Titles'); if (empty($titles)) { $assertor = vB::getDbAssertor(); $phrases = $assertor->getColumn('vBForum:phrase', 'text', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'fieldname' => array('faqtext', 'faqtitle'), 'languageid' => array(-1, 0, vB::getCurrentSession()->get('languageid'))), false, 'varname'); $faqs = $assertor->getRows('vBForum:faq', array(), 'displayorder', 'faqname'); foreach ($faqs as $faqname => &$faq) { if ($faqname == 'faqroot') { continue; } $faq['title_phrase'] = $faq['faqname'] . '_gfaqtitle'; $faq['text_phrase'] = $faq['faqname'] . '_gfaqtext'; $faq['title'] = $phrases[$faq['title_phrase']]; $faq['text'] = $phrases[$faq['text_phrase']]; $parentPath = ''; $parent = $faq['faqparent']; while ($parent != 'faqroot' and isset($faqs[$parent])) { $parentPath = $faqs[$parent]['faqname'] . '/' . $parentPath; $parent = $faqs[$parent]['faqparent']; } $faq['path'] = $parentPath . $faq['faqname']; $faqs[$faq['faqparent']]['children'][$faq['faqname']] =& $faq; } $titles = $faqs['faqroot']['children']; $cache->write('vb_FAQ_Titles', $titles, 300, 'vB_FAQ_chg'); } return array('titles' => $titles, 'firstItem' => $this->findFirst($titles)); }
public static function parse($text, $options = array(), $attachments = array(), $cacheInfo = array()) { //if we have a nodeid, let's try to cache this. if (!empty($cacheInfo)) { //TODO- Find a caching method that doesn't break collapsed mode. if (!empty($cacheInfo['nodeid'])) { $cacheKey = 'vbNodeText' . $cacheInfo['nodeid']; } else { if (!empty($cacheInfo['signatureid'])) { $cacheKey = 'vbSig' . $cacheInfo['signatureid']; } } if (!empty($cacheKey)) { $cacheKey .= strval($options); $parsed = vB_Cache::instance()->read($cacheKey); if ($parsed) { return $parsed; } } } $result = self::parseInternal(new vB5_Template_BbCode(), $text, $options, $attachments); if (!empty($cacheKey)) { if (!empty($cacheInfo['nodeid'])) { $cacheEvent = 'nodeChg_' . $cacheInfo['nodeid']; } else { if (!empty($cacheInfo['signatureid'])) { $cacheEvent = 'userChg_' . $cacheInfo['signatureid']; } } vB_Cache::instance()->write($cacheKey, $result, 86400, $cacheEvent); } return $result; }
/** * discard all query parameters * caches the new route and return it every time * this is the simplest form of redirection * if subclass is any complicate than this, override is needed */ public function getRedirect301() { $this->queryParameters = array(); $cache = vB_Cache::instance(vB_Cache::CACHE_STD); $cacheKey = get_class($this); $data = $cache->read($cacheKey); if (!$data) { $data = $this->getNewRouteInfo(); $cache->write($cacheKey, $data, 86400); } return $data; }
function getFullCategoryList(&$channelInfoArray = array(), $tabsize = 1, $tabchar = "--", $tabspace = " ") { $cache = vB_Cache::instance(vB_Cache::CACHE_STD); $cacheKey = "vBAdminCP_CMS_Categories"; $categories = $cache->read($cacheKey); $writeCache = false; $cacheEvents = array(); if (empty($categories)) { $categories = vB::getDbAssertor()->getRows('vBAdminCP:getCMSChannels', array('articleChannelId' => vB_Api::instanceInternal('node')->fetchArticleChannel(), 'channelcontenttype' => vB_Api::instanceInternal('ContentType')->fetchContentTypeIdFromClass('Channel'))); $writeCache = true; } $categoriesList = array(); // The query result is sorted by depth first. We have to group/sort into a hierarchical order, such that // children come immediately after a parent. $parent_position = array(); // parentid => position $nodeid_index = array(); // nodeid => search result index foreach ($categories as $index => $category) { $cacheEvents[] = 'nodeChg_' . $category['nodeid']; $parentid = $category['parentid']; $nodeid_index[$category['nodeid']] = $index; if (empty($parent_position)) { $parent_position[$category['nodeid']] = 0; } else { $position = $parent_position[$parentid] + 1; // increment positions of parents whose positions are after $position foreach ($parent_position as $pid => $pos) { if ($pos >= $position) { $parent_position[$pid]++; } } // node will be positioned after its parent, but above any siblings. This is why all but the depth is sort order DESC in the query. $parent_position[$category['nodeid']] = $position; } } // sort parent_position by position asort($parent_position); foreach ($parent_position as $nodeid => $position) { $category = $categories[$nodeid_index[$nodeid]]; $channelInfoArray[$category['nodeid']] = array("title" => $category['htmltitle'], "parentid" => $category['parentid'], "showpublished" => $category['showpublished'], "textcount" => $category['textcount'], "displayorder" => $category['displayorder'], "description" => $category['description']); $tab = str_repeat($tabchar, $category['depth'] * $tabsize) . $tabspace; $categoriesList[$category['nodeid']] = $tab . $category['htmltitle']; } if ($writeCache) { $cache->write($cacheKey, $categories, 1440, $cacheEvents); } return $categoriesList; }
protected function getPage() { if ($this->page === NULL and isset($this->arguments['pageid'])) { $cache = vB_Cache::instance(vB_Cache::CACHE_FAST); $hashkey = 'vbPage_' . $this->arguments['pageid']; $this->page = $cache->read($hashkey); if (empty($this->page)) { $this->page = vB::getDbAssertor()->getRow('page', array('pageid' => intval($this->arguments['pageid']))); // use phrased page title & meta desc for breadcrumb $guidforphrase = vB_Library::instance('phrase')->cleanGuidForPhrase($this->page['guid']); $phrases = vB_Api::instanceInternal('phrase')->fetch(array('page_' . $guidforphrase . '_title', 'page_' . $guidforphrase . '_metadesc')); $this->page['title'] = !empty($phrases['page_' . $guidforphrase . '_title']) ? $phrases['page_' . $guidforphrase . '_title'] : $this->page['title']; $this->page['metadescription'] = !empty($phrases['page_' . $guidforphrase . '_metadesc']) ? $phrases['page_' . $guidforphrase . '_metadesc'] : $this->page['metadescription']; $cache->write($hashkey, $this->page, 86400, 'vbPageChg_' . $this->arguments['pageid']); } } return $this->page; }
public function getUrl() { $cache = vB_Cache::instance(vB_Cache::CACHE_FAST); $hashKey = 'vbRouteURLIndent_' . $this->arguments['nodeid']; $urlident = $cache->read($hashKey); if (empty($urlident)) { $node = vB_Library::instance('node')->getNodeBare($this->arguments['nodeid']); $urlident = $node['urlident']; $cache->write($hashKey, $urlident); } elseif (is_array($urlident) and !empty($urlident['urlident'])) { $urlident = $urlident['urlident']; } $url = '/album/' . $this->arguments['nodeid'] . '-' . $urlident; if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
/** this deletes an existing permission * * @return mixed either permissionid(single or array), or nodeid and usergroupid. A single Nodeid is required and usergroup is optional and may be an array ***/ public function deletePerms($params) { if (!empty($params['permissionid'])) { //We don't allow deleting permissions from page 1. $existing = vB::getDbAssertor()->getRow('vBForum:permission', array('permissionid' => $params['permissionid'])); if (empty($existing) or !empty($existing['errors']) or $existing['nodeid'] == 1) { return false; } $qryParams['permissionid'] = $params['permissionid']; } else { if (!empty($params['nodeid']) and intval($params['nodeid'])) { $qryParams['nodeid'] = intval($params['nodeid']); if (!empty($params['groupid'])) { $qryParams['groupid'] = $params['groupid']; } } else { return false; } } $qryParams[vB_dB_Query::TYPE_KEY] = vB_dB_Query::QUERY_DELETE; $result = vB::getDbAssertor()->assertQuery('vBForum:permission', $qryParams); vB_Cache::instance()->event('perms_changed'); //force reloading the group access cache vB::getUserContext()->rebuildGroupAccess(); return $result; }
} } foreach ($productcodes_versions as $version) { foreach ($productcodes_grouped["{$version}"] as $productcode) { eval($productcode['uninstallcode']); } } //remove some common resources that a product may have registered. //tags $db->query_write("\r\n\t\tDELETE tagcontent\r\n\t\tFROM " . TABLE_PREFIX . "package AS package JOIN\r\n\t\t\t" . TABLE_PREFIX . "contenttype AS contenttype ON\r\n\t\t\t\tcontenttype.packageid = package.packageid JOIN\r\n\t\t\t" . TABLE_PREFIX . "tagcontent AS tagcontent ON\r\n\t\t\t\tcontenttype.contenttypeid = tagcontent.contenttypeid\r\n\t\tWHERE productid = '{$safe_productid}'\r\n\t"); // Packages, routes, actions, contenttypes $db->query_write("\r\n\t\tDELETE package, route, action, contenttype\r\n\t\tFROM " . TABLE_PREFIX . "package AS package\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "route AS route\r\n\t\t\tON route.packageid = package.packageid\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "action AS action\r\n\t\t\tON action.routeid = route.routeid\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "contenttype AS contenttype\r\n\t\t\tON contenttype.packageid = package.packageid\r\n\t\tWHERE productid = '{$safe_productid}'\r\n\t"); // Clear routes from datastore build_datastore('routes', serialize(array()), 1); //clear the type cache. vB_Cache::instance()->purge('vb_types.types'); // need to remove the language columns for this product as well require_once DIR . '/includes/class_dbalter.php'; $db_alter = new vB_Database_Alter_MySQL($db); if ($db_alter->fetch_table_info('language')) { $phrasetypes = $db->query_read("\r\n\t\t\tSELECT fieldname\r\n\t\t\tFROM " . TABLE_PREFIX . "phrasetype\r\n\t\t\tWHERE product = '" . $db->escape_string($vbulletin->GPC['productid']) . "'\r\n\t\t"); while ($phrasetype = $db->fetch_array($phrasetypes)) { $db_alter->drop_field("phrasegroup_{$phrasetype['fieldname']}"); } } delete_product($vbulletin->GPC['productid']); build_all_styles(); vBulletinHook::build_datastore($db); require_once DIR . '/includes/adminfunctions_language.php'; build_language(); build_options();
/** * Additional tasks to perform before a delete. * * Return false to indicate that the entire delete process was not a success. * * @param mixed - The result of execDelete() */ protected function preDelete($result) { $this->assertItem(); require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, vB_Types::instance()->getContentTypeID("vBCms_Article"), intval($this->item->getId())); $taggable->delete_tag_attachments(); vB::$db->query_write(" DELETE FROM " . TABLE_PREFIX . "cms_nodecategory WHERE nodeid = " . intval($this->item->getNodeId()) ); vB::$db->query_write(" DELETE FROM " . TABLE_PREFIX . "cms_article WHERE contentid = " . intval($this->item->getId()) ); vB_Cache::instance()->event('categories_updated'); return parent::preDelete($result); }
/** * Permanently deletes a node * @param integer The nodeid of the record to be deleted * * @return boolean */ public function delete($nodeid) { //We need to update the parent counts, but first we need to get the status $node = $this->assertor->getRow('vBForum:node', array('nodeid' => $nodeid)); //We have to get this before we delete if ($node['showpublished']) { $parents = vB_Library::instance('Node')->getParents($nodeid); } //do the delete parent::delete($nodeid); //delete videoitems $this->assertor->assertQuery('videoitem', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'nodeid' => $nodeid)); vB_Cache::instance(vB_Cache::CACHE_FAST)->event("nodeChg_{$nodeid}"); vB_Cache::instance()->event("nodeChg_{$nodeid}"); }
// get usergroups who should be displayed on showgroups // Scans too many rows. Usergroup Rows * User Rows // VBIV-6689 Caching. $groupcache = array(); if ($vbulletin->options['flcache']) { $groupcache = vB_Cache::instance()->read('showgroups.groupcache'); } if (empty($groupcache)) { $users = $db->query_read_slave("\n\t\tSELECT user.*,\n\t\t\tusergroup.title,\n\t\t\tuser.options, usertextfield.buddylist,\n\t\t\t" . ($show['locationfield'] ? 'userfield.field2,' : '') . "\n\t\t\tIF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid\n\t\t\t" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,\n\t\t\tcustomavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, \n\t\t\tfiledata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" : "") . "\n\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON(usergroup.usergroupid = user.usergroupid OR FIND_IN_SET(usergroup.usergroupid, user.membergroupids))\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid=user.userid)\n\t\t" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) \n\t\t\tLEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t{$hook_query_joins}\n\t\tWHERE (usergroup.genericoptions & " . $vbulletin->bf_ugp_genericoptions['showgroup'] . ")\n\t\t{$hook_query_where}\n\t"); while ($user = $db->fetch_array($users)) { $t = strtoupper($user['title']); $u = strtoupper($user['username']); $groupcache["{$t}"]["{$u}"] = $user; } if ($vbulletin->options['flcache']) { vB_Cache::instance()->write('showgroups.groupcache', $groupcache, $vbulletin->options['flcache']); } } $usergroups = ''; if (sizeof($groupcache) >= 1) { ksort($groupcache); // alphabetically sort usergroups foreach ($groupcache as $users) { ksort($users); // alphabetically sort users $usergroupbits = ''; foreach ($users as $user) { exec_switch_bg(); $user = process_showgroups_userinfo($user); if ($vbulletin->options['enablepms'] and $vbulletin->userinfo['permissions']['pmquota'] and ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or $user['receivepm'] and $user['permissions']['pmquota'] and (!$user['receivepmbuddies'] or can_moderate() or strpos(" {$user['buddylist']} ", ' ' . $vbulletin->userinfo['userid'] . ' ') !== false))) { $show['pmlink'] = true;
/** * Performs additional queries or tasks after saving. * Updates the node description with the title. * * @param mixed - The save result * @param bool $deferred - Save was deferred * @param bool $replace - Save used REPLACE * @param bool $ignore - Save used IGNORE if inserting * @return bool - Whether the save can be considered a success */ protected function postSave($result, $deferred, $replace, $ignore) { //result will normally be the nodeid if this was an insert. Let's check. if ($this->isUpdating()) { $nodeid = $this->item->getNodeId(); } else if (is_array($result)) { $nodeid = $result['nodeid']; } else { $nodeid = $result; } if (!$result) { return false; } parent::postSave($result, $deferred, $replace, $ignore); //We need to update category information. Let's figure out what the current categories // are and only make the necessary changes. vB::$vbulletin->input->clean_array_gpc('r', array('categoryids' =>TYPE_ARRAY)); //if we don't have a categoryids variable around, we don't want to update categories. if (vB::$vbulletin->GPC_exists['categoryids']) { $newcategories = array(); $currcategories = array(); foreach (vB::$vbulletin->GPC['categoryids'] as $categoryid) { if (isset($_REQUEST["cb_category_$categoryid"])) { $newcategories[]= $categoryid; } } $newcategories = array_unique($newcategories); if ($rst = vB::$vbulletin->db->query_read("SELECT categoryid FROM " . TABLE_PREFIX . "cms_nodecategory WHERE nodeid =" . $nodeid)) { while($row = vB::$vbulletin->db->fetch_array($rst)) { $currcategories[] = $row['categoryid']; } } if (count($update = array_diff($newcategories, $currcategories))) { foreach ($update as $categoryid) { vB::$vbulletin->db->query_write("INSERT INTO ". TABLE_PREFIX . "cms_nodecategory (nodeid, categoryid) values (" . $nodeid . ", $categoryid) "); } } if (count($update = array_diff($currcategories, $newcategories))) { vB::$vbulletin->db->query_write("DELETE FROM ". TABLE_PREFIX . "cms_nodecategory WHERE nodeid =" . $nodeid . " AND categoryid in (" . implode(', ', $update) . ")" ); } vB_Cache::instance()->event('categories_updated'); vB_Cache::instance()->event($this->item->getContentCacheEvent()); } if ($this->index_search) { $this->indexSearchContent(); } vB_Cache::instance()->event('cms_count_published'); }
/** * Additional data to update after a save call (such as denormalized values in other tables). * * @param boolean Do the query? */ function post_save_each($doquery = true) { $moderatorid = $this->fetch_field('moderatorid'); // update usergroupid / membergroupids if (!$this->condition and !in_array($this->moderator['userid'], explode(',', $this->config['SpecialUsers']['undeletableusers'])) and can_administer('canadminusers')) { $update_usergroupid = $this->info['usergroupid'] > 0; $update_membergroup = (!empty($this->info['membergroupids']) and is_array($this->info['membergroupids'])); if ($update_usergroupid or $update_membergroup) { $userdata = new vB_Datamanager_User($this->registry, vB_DataManager_Constants::ERRTYPE_SILENT); if (!$this->info['user'] and $this->moderator['userid']) { $this->info['user'] = fetch_userinfo($this->moderator['userid']); } $userdata->set_existing($this->info['user']); cache_permissions($this->info['user'], false); $displaygroupid = $update_usergroupid ? $this->info['usergroupid'] : $this->info['user']['displaygroupid']; $this->usergroupcache = vB::getDatastore()->get_value('usergroupcache'); $userdata->set_usertitle($this->info['user']['customtitle'] ? $this->info['user']['usertitle'] : '', false, $this->usergroupcache["{$displaygroupid}"], ($this->info['user']['customtitle'] == 1 or $this->info['user']['permissions']['genericpermissions'] & $this->bf_ugp_genericpermissions['canusecustomtitle']) ? true : false, $this->info['user']['customtitle'] == 1 ? true : false); $userdata->set_failure_callback(array(&$this, 'update_user_failed_insert')); if ($update_usergroupid) { $userdata->set('usergroupid', $this->info['usergroupid']); $userdata->set('displaygroupid', $this->info['usergroupid']); } if ($update_membergroup) { $membergroupids = preg_split('#,#', $this->info['user']['membergroupids'], -1, PREG_SPLIT_NO_EMPTY); $membergroupids = array_unique(array_merge($membergroupids, $this->info['membergroupids'])); if ($key = array_search($this->info['user']['usergroupid'], $membergroupids)) { unset($membergroupids["{$key}"]); } sort($membergroupids); $userdata->set('membergroupids', $membergroupids); } if ($userdata->errors) { $this->errors = array_merge($this->errors, $userdata->errors); return; } $userdata->save(); } } if (!$this->condition and !$this->options['ignoremods']) { $rebuild_ignore_list = array(); $ignored_moderators = $this->assertor->getRows('userlist', array('relationid' => $this->fetch_field('userid'), 'type' => 'ignore')); foreach ($ignored_moderators as $ignored_moderator) { $rebuild_ignore_list[] = $ignored_moderator['userid']; } if (!empty($rebuild_ignore_list)) { require_once DIR . '/includes/functions_databuild.php'; $this->assertor->delete('userlist', array('relationid' => $this->fetch_field('userid'), 'type' => 'ignore')); foreach ($rebuild_ignore_list as $userid) { build_userlist($userid); } } } // Legacy Hook 'moderatordata_postsave' Removed // vB_Cache::instance(vB_Cache::CACHE_FAST)->event('userPerms_' . $this->moderator['userid']); }
/** * Build URLs using a single instance for the class. It does not check permissions * @param string $className * @param array $URLInfoList * - route * - data * - extra * - anchor * - options * @return array */ protected static function bulkFetchUrls($className, $URLInfoList) { $results = array(); $cache = vB_Cache::instance(vB_Cache::CACHE_FAST); foreach ($URLInfoList as $hash => $info) { try { // we need different instances, since we need to instantiate different action classes $route = new $className($info['routeInfo'], $info['data'], http_build_query($info['extra']), $info['anchor']); $options = explode('|', $info['route']); $routeId = $options[0]; $fullURL = $route->getFullUrl($options); $cache->write($info['innerHash'], $fullURL, 1440, array('routeChg_' . $routeId)); } catch (Exception $e) { $fullURL = ''; } $results[$hash] = $fullURL; } return $results; }
/** * Cleans the cache of all of the parent sections. */ protected function cleanContentCache() { $events = $this->getCleanCacheEvents(); vB_Cache::instance()->event($this->getCleanCacheEvents())->cleanNow(); }
/** This gets the following parameters- not the content * * @param int option userid * * @return mixed array of content, user, member. Each is an array of integers. ***/ public function getFollowingParameters($userid = false) { //Must have a userid if (!$userid or !intval($userid)) { $userid = vB::getCurrentSession()->get('userid'); } $result = array('content' => array(), 'user' => array(), 'member' => array()); if ($userid < 1) { return $result; } $hashKey = "flwParams_{$userid}"; $cacheResult = vB_Cache::instance(vB_Cache::CACHE_FAST)->read($hashKey); if ($cacheResult) { return $cacheResult; } $assertor = vB::getDbAssertor(); //First content if (isset($this->subscriptions[$userid])) { foreach ($this->subscriptions[$userid] as $discussionid) { $result['content'][] = $discussionid; } } else { $this->subscriptions[$userid] = array(); $qry = $assertor->assertQuery('vBForum:subscribediscussion', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'userid' => $userid)); foreach ($qry as $follow) { $result['content'][] = $follow['discussionid']; $this->subscriptions[$userid][$follow['discussionid']] = $follow['discussionid']; } } //Next users $params = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'userid' => intval($userid), 'type' => 'follow', 'friend' => 'yes'); ksort($params); $cacheKey = md5(json_encode($params)); if (!isset($this->userListCache[$cacheKey])) { $this->userListCache[$cacheKey] = $this->assertor->getRows('userlist', $params); } foreach ($this->userListCache[$cacheKey] as $follow) { $result['user'][] = $follow['relationid']; } //Now blogs or social groups where you are a member. $members = vB_Library::instance('user')->getGroupInTopic($userid); foreach ($members as $member) { $result['member'][] = $member['nodeid']; } vB_Cache::instance(vB_Cache::CACHE_FAST)->write($hashKey, $result, 1440, "followChg_{$userid}", "userChg_{$userid}"); return $result; }
/** * Writes the model info to the cache. * * @return int */ protected function writeCache() { if ($this->cachable and is_callable(array($this, 'getContentCacheHash')) and is_callable(array($this, 'getContentCacheEvent'))) { $item = array(); $item->values = array(); $hash = $this->getContentCacheHash(); $write_lock = true; if ($item = vB_Cache::instance()->read($hash, $write_lock)) { $this->itemid = $item->itemid; $item->loaded_info |= $this->loaded_info; foreach (array_merge($item->item_properties, $this->content_properties) as $key) { $item->values[$key] = $item->key; } return true; } $hashevent = $this->getContentCacheEvent(); if ($write_lock) { vB_Cache::instance()->write($hash, $item, 1440, $hashevent); } } return false; }
function create_associated_thread($article) { $foruminfo = fetch_foruminfo(vB::$vbulletin->options['vbcmsforumid']); if (!$foruminfo) { return false; } $dataman =& datamanager_init('Thread_FirstPost', vB::$vbulletin, ERRTYPE_ARRAY, 'threadpost'); //$dataman->set('prefixid', $post['prefixid']); // set info $dataman->set_info('preview', ''); $dataman->set_info('parseurl', true); $dataman->set_info('posthash', ''); $dataman->set_info('forum', $foruminfo); $dataman->set_info('thread', array()); $dataman->set_info('show_title_error', false); // set options $dataman->set('showsignature', true); $dataman->set('allowsmilie', false); // set data //title and message are needed for dupcheck later $title = new vB_Phrase('vbcms', 'comment_thread_title', htmlspecialchars_decode($article->getTitle())); $message = new vB_Phrase('vbcms', 'comment_thread_firstpost', vBCms_Route_Content::getURL(array('node' => $article->getUrlSegment()))); $dataman->set('userid', $article->getUserId()); $dataman->set('title', $title); $dataman->set('pagetext', $message); $dataman->set('iconid', ''); $dataman->set('visible', 1); $dataman->setr('forumid', $foruminfo['forumid']); $errors = array(); $dataman->pre_save(); $errors = array_merge($errors, $dataman->errors); vB_Cache::instance()->event($article->getCacheEvents()); if (sizeof($errors) > 0) { return false; } if (!($id = $dataman->save())) { throw new vB_Exception_Content('Could not create comments thread for content'); } return $id; }
/** * Activate an user with an activate ID * * @param int $userid User ID * @param string $activateid Activate ID * * @throws vB_Exception_Api * @return string User status after activation. Possible values: * 1) moderateuser: user is put into moderate queue * 2) emailchanged: user's email address has been updated successfully * 3) registration_complete: user's registration is completed */ public function activateUser($userid, $activateid) { $dbassertor = vB::getDbAssertor(); $userinfo = vB_User::fetchUserinfo($userid); $usercontext = vB::getUserContext($userid); $userid = intval($userid); $usergroupcache = vB::getDatastore()->getValue('usergroupcache'); $vboptions = vB::getDatastore()->getValue('options'); if (!$userinfo) { throw new vB_Exception_Api('invalidid', array(vB_Phrase::fetchSinglePhrase('user'), vB5_Route::buildUrl('contact-us|fullurl'))); } if ($userid == 0) { throw new vB_Exception_Api('invalidactivateid', array(vB5_Route::buildUrl('activateuser|fullurl'), vB5_Route::buildUrl('activateemail|fullurl'), vB5_Route::buildUrl('contact-us|fullurl'))); } else { if ($userinfo['usergroupid'] == 3) { // check valid activation id $user = $dbassertor->getRow('useractivation', array('activationid' => $activateid, 'userid' => $userid, 'type' => 0)); if (!$user or $activateid != $user['activationid']) { // send email again throw new vB_Exception_Api('invalidactivateid', array(vB5_Route::buildUrl('activateuser|fullurl'), vB5_Route::buildUrl('activateemail|fullurl'), vB5_Route::buildUrl('contact-us|fullurl'))); } // delete activationid $dbassertor->delete('useractivation', array('userid' => $userid, 'type' => 0)); if (empty($user['usergroupid'])) { $user['usergroupid'] = 2; // sanity check } // ### DO THE UG/TITLE UPDATE ### $getusergroupid = $userinfo['displaygroupid'] != $userinfo['usergroupid'] ? $userinfo['displaygroupid'] : $user['usergroupid']; $user_usergroup =& $usergroupcache["{$user['usergroupid']}"]; $display_usergroup =& $usergroupcache["{$getusergroupid}"]; // init user data manager $userdata = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_STANDARD); $userdata->set_existing($userinfo); $userdata->set('usergroupid', $user['usergroupid']); $userdata->set_usertitle(!empty($user['customtitle']) ? $user['usertitle'] : '', false, $display_usergroup, $usercontext->hasPermission('genericpermissions', 'canusecustomtitle') ? true : false, $usercontext->isAdministrator() ? true : false); if ($userinfo['coppauser'] or $vboptions['moderatenewmembers'] and !$userinfo['posts']) { // put user in moderated group $userdata->save(); return array('moderateuser', $this->fetchUserName($userid), vB5_Route::buildUrl('home|fullurl')); } else { // activate account $userdata->save(); // rebuild stats so new user displays on forum home require_once DIR . '/includes/functions_databuild.php'; build_user_statistics(); vB_Cache::instance(vB_Cache::CACHE_FAST)->event(array("userPerms_{$userid}", "userChg_{$userid}")); vB_Cache::instance(vB_Cache::CACHE_LARGE)->event(array("userPerms_{$userid}", "userChg_{$userid}")); $username = unhtmlspecialchars($userinfo['username']); if (!$user['emailchange']) { if ($vboptions['welcomemail']) { // Send welcome mail $maildata = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('welcomemail', array($username, $vboptions['bbtitle']), array($vboptions['bbtitle']), isset($user['languageid']) ? $user['languageid'] : vB::getDatastore()->getOption('languageid')); vB_Mail::vbmail($userinfo['email'], $maildata['subject'], $maildata['message'], true); } $userdata->send_welcomepm(null, $userid); } if ($user['emailchange']) { return 'emailchanged'; } else { return array('registration_complete', vB_String::htmlSpecialCharsUni($username), vB5_Route::buildUrl('profile|fullurl', $userinfo), vB5_Route::buildUrl('settings|fullurl', array('tab' => 'account')), vB5_Route::buildUrl('settings|fullurl', array('tab' => 'account')), vB5_Route::buildUrl('home|fullurl')); } } } else { if ($userinfo['usergroupid'] == 4) { // In Moderation Queue return 'activate_moderation'; vB_Cache::instance(vB_Cache::CACHE_FAST)->event(array("userPerms_{$userid}", "userChg_{$userid}")); vB_Cache::instance(vB_Cache::CACHE_LARGE)->event(array("userPerms_{$userid}", "userChg_{$userid}")); } else { // Already activated throw new vB_Exception_Api('activate_wrongusergroup'); } } } }
/** * Insert a new usergroup or update an existing usergroup * * @param array $usergroup Usergroup information to be inserted or updated * @param int $ugid_base Usergroup ID. New inserted usergroup's forum permission will based on this usergroup. * @param int $usergroupid when updating an existing usergroup, pass usergroup ID as this parameter * @return int New or existing usergroup ID */ public function save($usergroup, $ugid_base = 0, $usergroupid = 0) { $this->checkHasAdminPermission('canadminpermissions'); $bf_ugp = vB::getDatastore()->get_value('bf_ugp'); $bf_ugp_adminpermissions = vB::getDatastore()->get_value('bf_ugp_adminpermissions'); $bf_ugp_genericpermissions = vB::getDatastore()->get_value('bf_ugp_genericpermissions'); $bf_ugp_genericoptions = vB::getDatastore()->get_value('bf_ugp_genericoptions'); $bf_misc_useroptions = vB::getDatastore()->get_value('bf_misc_useroptions'); $usergroupcache = vB::getDatastore()->get_value('usergroupcache'); $bf_misc_prefixoptions = vB::getDatastore()->get_value('bf_misc_prefixoptions'); // create bitfield values require_once DIR . '/includes/functions_misc.php'; foreach ($bf_ugp as $permissiongroup => $fields) { if ($permissiongroup == 'createpermissions' or $permissiongroup == 'forumpermissions2') { continue; } $usergroup["{$permissiongroup}"] = convert_array_to_bits($usergroup["{$permissiongroup}"], $fields, 1); } if (!empty($usergroupid)) { // update if (!($usergroup['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel'])) { // check that not removing last admin group $checkadmin = vB::getDbAssertor()->getField('usergroup_checkadmin', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'cancontrolpanel' => $bf_ugp_adminpermissions['cancontrolpanel'], 'usergroupid' => $usergroupid)); if ($usergroupid == 6) { // stop them turning no control panel for usergroup 6, seems the most sensible thing throw new vB_Exception_Api('invalid_usergroup_specified'); } if (!$checkadmin) { throw new vB_Exception_Api('cant_delete_last_admin_group'); } } $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array('usergroupid' => $usergroupid)); $data = array_merge($data, $usergroup); vB::getDbAssertor()->assertQuery('usergroup', $data); if (!($usergroup['genericpermissions'] & $bf_ugp_genericpermissions['caninvisible'])) { if (!($usergroup['genericoptions'] & $bf_ugp_genericoptions['allowmembergroups'])) { // make the users in this group visible vB::getDbAssertor()->assertQuery('usergroup_makeuservisible', array('invisible' => $bf_misc_useroptions['invisible'], 'usergroupid' => $usergroupid)); } else { // find all groups allowed to be invisible - don't change people with those as secondary groups vB::getDbAssertor()->assertQuery('updateInvisible', array('caninvisible' => $bf_ugp_genericpermissions['caninvisible'], 'invisible' => $bf_misc_useroptions['invisible'], 'usergroupid' => $usergroupid)); } } if ($usergroup['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel']) { $ausers = vB::getDbAssertor()->assertQuery('usergroup_fetchausers', array('usergroupid' => $usergroupid)); foreach ($ausers as $auser) { $userids[] = $auser['userid']; } if (!empty($userids)) { foreach ($userids as $userid) { $admindm =& datamanager_init('Admin', $vbulletin, ERRTYPE_SILENT); $admindm->set('userid', $userid); $admindm->save(); unset($admindm); } } } else { if ($usergroupcache["{$usergroupid}"]['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel']) { // lets find admin usergroupids $ausergroupids = array(); $usergroupcache["{$usergroupid}"]['adminpermissions'] = $usergroup['adminpermissions']; foreach ($usergroupcache as $ausergroupid => $ausergroup) { if ($ausergroup['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel']) { $ausergroupids[] = $ausergroupid; } } $ausers = vB::getDbAssertor()->assertQuery('fetchAdminusersFromUsergroup', array('ausergroupids' => $ausergroupids, 'usergroupid' => $usergroupid)); foreach ($ausers as $auser) { $userids[] = $auser['userid']; } if (!empty($userids)) { foreach ($userids as $userid) { $info = array('userid' => $userid); $admindm =& datamanager_init('Admin', $vbulletin, ERRTYPE_ARRAY); $admindm->set_existing($info); $admindm->delete(); unset($admindm); } } } } vB_Cache::instance()->event('perms_changed'); vB::getUserContext()->clearChannelPermissions($usergroupid); } else { // insert /*insert query*/ $newugid = vB::getDbAssertor()->insert('usergroup', $usergroup); if ($ugid_base <= 0) { // use usergroup registered as default foreach ($usergroupcache as $ausergroup) { if ($ausergroup['systemgroupid'] == self::REGISTERED_SYSGROUPID) { $ugid_base = $ausergroup['usergroupid']; } } } if ($ugid_base > 0) { $fperms = vB::getDbAssertor()->assertQuery('vBForum:forumpermission', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'usergroupid' => $ugid_base)); foreach ($fperms as $fperm) { unset($fperm['forumpermissionid']); $fperm['usergroupid'] = $newugid; /*insert query*/ $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERT); $data += $fperm; vB::getDbAssertor()->assertQuery('vBForum:forumpermission', $data); } $cperms = vB::getDbAssertor()->assertQuery('vBForum:calendarpermission', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'usergroupid' => $ugid_base)); foreach ($cperms as $cperm) { unset($cperm['calendarpermissionid']); $cperm['usergroupid'] = $newugid; /*insert query*/ $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERT); $data += $cperm; vB::getDbAssertor()->assertQuery('vBForum:calendarpermission', $data); } $perms = vB::getDbAssertor()->assertQuery('vBForum:permission', array('groupid' => $ugid_base)); foreach ($perms as $perm) { unset($perm['permissionid']); $perm['groupid'] = $newugid; vB::getDbAssertor()->insert('vBForum:permission', $perm); } vB::getUserContext()->clearChannelPermissions(); } vB::getDbAssertor()->assertQuery('usergroup_insertprefixpermission', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'newugid' => $newugid, 'deny_by_default' => $bf_misc_prefixoptions['deny_by_default'])); } vB::getUserContext()->rebuildGroupAccess(); $markups = vB::getDbAssertor()->getRows('usergroup_fetchmarkups', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED)); $usergroupmarkup = array(); foreach ($markups as $markup) { $usergroupmarkup["{$markup['usergroupid']}"]['opentag'] = $markup['opentag']; $usergroupmarkup["{$markup['usergroupid']}"]['closetag'] = $markup['closetag']; } require_once DIR . '/includes/adminfunctions.php'; require_once DIR . '/includes/functions_databuild.php'; build_channel_permissions(); build_birthdays(); // could be changing sig perms -- this is unscientific, but empty the sig cache vB::getDbAssertor()->assertQuery('truncateTable', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'table' => 'sigparsed')); if ($newugid) { return $newugid; } else { return $usergroupid; } }
/** Returns a list of common routes. We check these to see if we can avoid the far most expensive selectBestRoute call * * #return array of string => string map of url to route class. **/ public static function fetchCommonRoutes() { if ($common = vB_Cache::instance(vB_Cache::CACHE_STD)->read('vB_CommonRoutes') and !empty($common)) { return $common; } $guids = array(vB_Channel::MAIN_CHANNEL, vB_Channel::DEFAULT_FORUM_PARENT, vB_Channel::MAIN_FORUM, vB_Channel::MAIN_FORUM_CATEGORY, vB_Channel::DEFAULT_BLOG_PARENT, vB_Channel::DEFAULT_SOCIALGROUP_PARENT, vB_Channel::PRIVATEMESSAGE_CHANNEL, vB_Channel::VISITORMESSAGE_CHANNEL); // todo, also add empty prefix channel route for when home page has been changed? $routes = vB::getDbAssertor()->assertQuery('vBForum:getRouteFromChGuid', array('guid' => $guids)); $common = array(); foreach ($routes as $route) { $common[$route['prefix']] = $route; $common[$route['prefix']]['length'] = strlen($route['prefix']); } vB_Cache::instance(vB_Cache::CACHE_STD)->write('vB_CommonRoutes', $common, 1440, 'vB_routesChgMultiple'); return $common; }
/** * This sets up the search parameters, gets the query results, * and renders them * * @param array $config * @return string */ private function getResults($config) { include_once DIR . '/includes/functions_misc.php'; $search_core = vB_Search_Core::get_instance(); //first see if we can get cached results $hashkey = $this->getHash(); $cache_data = vB_Cache::instance()->read($hashkey, false, false); if ($cache_data) { //If there are no id's, we're done. if (empty($cache_data['ids'])) { return false; } $controller = vB_Search_Core::get_instance()->get_search_type_from_id($config['contenttypeid']); if (method_exists($controller, 'create_array')) { $results = $controller->create_array($cache_data['ids']); } else if(method_exists($controller, 'create_item')) { $results = array(); foreach ($cache_data['ids'] as $resultid) { $result = $controller->create_item($resultid); if ($result) { $results[] = $result; } } } else { return false; } return array('results' => $results, 'criteria' => $cache_data['criteria']); } $rst = vB::$vbulletin->db->query_read("SELECT relationid FROM " . TABLE_PREFIX . "userlist WHERE friend='yes' AND userid = " . vB::$vbulletin->userinfo['userid'] ); if (!$rst) { return false; } $userids = array(); while($row = vB::$vbulletin->db->fetch_row($rst)) { $userids[] = $row[0]; } //If there are no friends there's no friend information. if (! count($userids)) { return ''; } if ($config['contenttypeid'] == null) { $config['contenttypeid']= array(); } else if (!is_array($config['contenttypeid'])) { $config['contenttypeid'] = array($config['contenttypeid']); } if (!count($userids)) { new vB_Phrase('global', 'your_friends_list_is_empty'); } $criteria = vB_Search_Core::get_instance()->create_criteria(vB_Search_Core::SEARCH_ADVANCED); $criteria->add_contenttype_filter($config['contenttypeid']); $criteria->set_advanced_typeid($contenttypeid); $criteria->add_userid_filter($userids, false); $criteria->set_grouped(vB_Search_Core::GROUP_NO); $timelimit = TIMENOW - (86400 * $config['days']); $criteria->add_date_filter(vB_Search_Core::OP_GT, $timelimit); $criteria->set_sort('dateline', 'desc'); $current_user = new vB_Legacy_CurrentUser(); $results = vB_Search_Results::create_from_cache($current_user, $criteria); if (!$results) { $results = vB_Search_Results::create_from_criteria($current_user, $criteria); } if (empty($results)) { return false; } $page_results = $results->get_page(1, $config['count'], 1); //prepare types for render $items_by_type = array(); foreach ($page_results as $item) { $typeid = $item->get_contenttype(); if ($typeid) { $items_by_type[$typeid][] = $item; $ids[] = $item->get_id(); } } foreach ($items_by_type as $contenttype => $items) { $type = vB_Search_Core::get_instance()->get_search_type_from_id($contenttype); $type->prepare_render($results->get_user(), $items); } vB_Cache::instance()->write($hashkey, array('ids' => $ids, 'criteria' =>$criteria), $this->cache_ttl, 'widget_config_' . $this->widget->getId()); return array('results' => $page_results, 'criteria' => $criteria); }
$id = vB::getDbAssertor()->assertQuery('vBForum:permission', $params); } } break; case 'deny': $usergroupcache =& vB::getDatastore()->getValue('usergroupcache'); foreach ($usergroupcache as $group) { /*insert query*/ vB::getDbAssertor()->assertQuery('replacePermissions', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'nodeid' => $vbulletin->GPC['nodeid'], 'usergroupid' => $group['usergroupid'], 'forumpermissions' => 0, 'moderatorpermissions' => 0, 'createpermissions' => 0, 'forumpermissions2' => 0, 'edit_time' => 2, 'require_moderate' => 1, 'maxtags' => 0, 'maxstartertags' => 0, 'maxothertags' => 0, 'maxattachments' => 0, 'maxchannels' => 0, 'channeliconmaxsize' => 0)); } break; default: print_stop_message2('invalid_quick_set_action'); } build_channel_permissions(); vB_Cache::instance()->event('perms_changed'); vB::getUserContext()->rebuildGroupAccess(); print_stop_message2('saved_channel_permissions_successfully', 'forumpermission', array('do' => 'modify', 'n' => $vbulletin->GPC['nodeid'])); } // ###################### Start fpgetstyle ####################### function fetch_forumpermission_style($permissions) { global $vbulletin; if (!($permissions & $vbulletin->bf_ugp_forumpermissions['canview'])) { return " style=\"list-style-type:circle;\""; } else { return ''; } } // ###################### Start modify ####################### if ($_REQUEST['do'] == 'modify') {
/** * Resets the css cachebuster date. */ public function setCssDate() { vB_Cache::instance()->event('vB_Library_Style_stylevar_cache'); $options = vB::getDatastore()->getValue('miscoptions'); $options['cssdate'] = vB::getRequest()->getTimeNow(); vB::getDatastore()->build('miscoptions', serialize($options), 1); }
/** * Fetches the standard page view for a widget. * * @return vBCms_View_Widget - The resolved view, or array of views */ public function getPageView() { global $vbphrase, $vbulletin; // Ensure the model is loaded $this->assertWidget(); // Normalise widget config $config = $this->widget->getConfig(); // Use fallback template name if none configured $config['template_name'] = (isset($config['template_name']) AND $config['template_name']) ? $config['template_name'] : 'vbcms_widget_rss_page'; // Sanitize max items $config['max_items'] = max(min($config['max_items'], 20), 1); // Load RSS $rss = array(); if (!($rss = vB_Cache::instance()->read($this->getHash($this->widget->getId()), false, true))) { // get feed require_once DIR . '/includes/class_rss_poster.php'; $feed = new vB_RSS_Poster($vbulletin); $feed->fetch_xml($config['url']); // TODO: Add config values for encoding behaviour $feed->parse_xml(false, true, false, true); // get rss elements if ($rss['items'] = $feed->fetch_normalised_items()) { $rss['title'] = $feed->xml_array['channel']['title']; $rss['description'] = $feed->xml_array['channel']['description']; $rss['link'] = $feed->xml_array['channel']['link']; // check quantity if (sizeof($rss['items']) > $config['max_items']) { $rss['more'] = true; $rss['items'] = array_slice($rss['items'], 0, $config['max_items']); } $rss['url'] = vB::$vbulletin->input->xss_clean_url($config['url']); } // write cache vB_Cache::instance()->write($this->getHash($this->widget->getId()), $rss, $this->cache_ttl); } // Create view $view = new vBCms_View_Widget($config['template_name']); if (!$rss['items']) { $view->setDisplayView(false); } // Add widget details $view->class = $this->widget->getClass(); $view->title = $this->widget->getTitle(); $view->description = $this->widget->getDescription(); $view->widget_title = $this->widget->getTitle(); // Add rss $view->addArray($rss, 'rss_'); // Phrases $view->no_items = empty($rss['items']) ? $vbphrase['invalid_data'] : false; return $view; }
private static function getComments($nodeid, $userinfo, &$permissions, $associatedthreadid) { require_once DIR . '/vb/cache.php'; if ($comments = vB_Cache::instance()->read( self::getStaticHash($nodeid), true)) { return $comments; } $sql = "SELECT distinct post.postid, post.visible, post.dateline FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $associatedthreadid AND parentid != 0 AND visible = 1 ORDER BY post.dateline ASC"; if (! ($rst = vB::$vbulletin->db->query_read($sql))) { return false; } $ids = array(); //Now we compare the fields. We need to check fields from the third // to the end of the row. If the value is different from the previous row, // we add a record. while($row = vB::$vbulletin->db->fetch_array($rst)) { if (self::canViewPost($row, $permissions)) { $ids[] = $row['postid']; } } if ((count($ids) == 1) and !intval($ids[0])) { $ids = false; } //Now we have a list of posts. vB_Cache::instance()->write(self::getStaticHash($nodeid), $ids, self::$static_cache_ttl, array('cms_comments_change_' . $associatedthreadid)); return $ids; }
/** * Disable a product, not delete * */ public function disable($productid = null) { $productid = $productid ? $productid : $this->productinfo['productid']; $this->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "product\n\t\t\tSET active = 0\n\t\t\tWHERE productid = '" . $this->db->escape_string($productid) . "'\n\t\t"); vBulletinHook::build_datastore($this->db); build_product_datastore(); // build bitfields to remove/add this products bitfields require_once DIR . '/includes/class_bitfield_builder.php'; vB_Bitfield_Builder::save($this->db); // Products can enable a cron entries, so we need to rebuild that as well require_once DIR . '/includes/functions_cron.php'; build_cron_next_run(); // Purge cache -- doesn't apply to pre-vB4 versions if (class_exists('vB_Cache')) { vB_Cache::instance()->purge('vb_types.types'); } // Reload blocks and block types -- doesn't apply to pre-vB4 versions if (class_exists('vB_BlockManager')) { $blockmanager = vB_BlockManager::create($this->registry); $blockmanager->reloadBlockTypes(); $blockmanager->getBlocks(true, true); } }
protected function saveData() { // collect error messages $errors = array(); vB::$vbulletin->input->clean_array_gpc('p', array( 'do' => vB_Input::TYPE_STR, 'html' => vB_Input::TYPE_STR, 'title' => vB_Input::TYPE_STR, 'new_parentid' => TYPE_INT, 'html_title' => vB_Input::TYPE_STR, 'publicpreview' => TYPE_INT, 'item_id' => vB_Input::TYPE_INT )); if (vB::$vbulletin->GPC['do'] == 'movenode' and vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid'])) { vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']); $new_sectionid = vB::$vbulletin->GPC['new_parentid']; } $new_values = array(); // create DM and save $dm = $this->content->getDM(); $dm->set('contentid', $this->content->getId()); $dm->set('item_id', $this->content->getId()); if (vB::$vbulletin->GPC_exists['html_title']) { $new_values['html_title'] = vB::$vbulletin->GPC['html_title']; $dm->set('html_title', vB::$vbulletin->GPC['html_title']); } if (vB::$vbulletin->GPC_exists['html']) { $new_values['html'] = vB::$vbulletin->GPC['html']; $dm->set('html', vB::$vbulletin->GPC['html']); } if (vB::$vbulletin->GPC_exists['comments_enabled']) { $new_values['comments_enabled'] = vB::$vbulletin->GPC['comments_enabled']; $dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']); } if (vB::$vbulletin->GPC_exists['title']) { $new_values['title'] = vB::$vbulletin->GPC['title']; $dm->set('title', vB::$vbulletin->GPC['title']); } if (vB::$vbulletin->GPC_exists['publicpreview']) { $new_values['publicpreview'] = vB::$vbulletin->GPC['publicpreview']; $dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']); } // add node info $dm->setNodeTitle($title); // set the node segment if it's empty if (!$this->content->getUrlTitle()) { $dm->setNodeURLSegment($title); } $success = $dm->saveFromForm($this->content->getNodeId()); //invalidate the navigation cache. vB_Cache::instance()->event(array('sections_updated' )); vBCms_Content::cleanContentCache(); if ($dm->hasErrors()) { $fieldnames = array( 'html' => new vB_Phrase('vbcms', 'html') ); $view->errors = $dm->getErrors(array_keys($fieldnames)); $view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames); $view->status = $view->error_view->title; } else { $view->status = new vB_Phrase('vbcms', 'content_saved'); $this->cleanContentCache(); } // postback content $view->html_title = $new_values['html_title']; $view->title = $new_values['title']; }
// ######################### START MAIN SCRIPT ############################ // ######################################################################## $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "session\n\tWHERE lastactivity < " . intval(TIMENOW - $vbulletin->options['cookietimeout']) . "\n"); $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "cpsession\n\tWHERE dateline < " . ($vbulletin->options['timeoutcontrolpanel'] ? intval(TIMENOW - $vbulletin->options['cookietimeout']) : TIMENOW - 3600) . "\n"); require_once DIR . '/vb/search/results.php'; vB_Search_Results::clean(); // expired lost passwords and email confirmations after 4 days $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "useractivation\n\tWHERE dateline < " . (TIMENOW - 345600) . " AND\n\t(type = 1 OR (type = 0 and usergroupid = 2))\n"); // old forum/thread read marking data $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "threadread\n\tWHERE readtime < " . (TIMENOW - $vbulletin->options['markinglimit'] * 86400)); $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "forumread\n\tWHERE readtime < " . (TIMENOW - $vbulletin->options['markinglimit'] * 86400)); $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "groupread\n\tWHERE readtime < " . (TIMENOW - $vbulletin->options['markinglimit'] * 86400)); $vbulletin->db->query_write("\n\tDELETE FROM " . TABLE_PREFIX . "discussionread\n\tWHERE readtime < " . (TIMENOW - $vbulletin->options['markinglimit'] * 86400)); // delete expired thread redirects $threads = $vbulletin->db->query_read("\n\tSELECT threadid\n\tFROM " . TABLE_PREFIX . "threadredirect\n\tWHERE expires < " . TIMENOW . "\n"); while ($thread = $vbulletin->db->fetch_array($threads)) { $thread['open'] = 10; $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); $threadman->set_existing($thread); $threadman->delete(false, true, NULL, false); unset($threadman); } vB_Cache::instance()->clean(); ($hook = vBulletinHook::fetch_hook('cron_script_cleanup_hourly')) ? eval($hook) : false; log_cron_action('', $nextitem, 1); /*======================================================================*\ || #################################################################### || # Downloaded: 03:13, Sat Sep 7th 2013 || # CVS: $RCSfile$ - $Revision: 62098 $ || #################################################################### \*======================================================================*/
" ); } } $upgrade->execute(); } if ($vbulletin->GPC['step'] == 3) { require_once(DIR . '/includes/class_bootstrap_framework.php'); vB_Bootstrap_Framework::init(); //clear the cache. There are some values that are incorrect because of code changes, //make sure that we don't allow those values to be used after the upgrade. vB_Cache::instance()->clean(false); } // ############################################################################# // FINAL step (notice the SCRIPTCOMPLETE define)\ //clear cache if ($vbulletin->GPC['step'] == 4) { // tell log_upgrade_step() that the script is done define('SCRIPTCOMPLETE', true); } // ############################################################################# print_next_step();