Exemplo n.º 1
0
 /**
  * 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));
 }
Exemplo n.º 2
0
 /**
  * Create a blog channel.
  *
  * @param array $input
  * @param int $channelid
  * @param int $channelConvTemplateid
  * @param int $channelPgTemplateId
  * @param int $ownerSystemGroupId
  *
  * @return int The nodeid of the new blog channel
  */
 public function createChannel($input, $channelid, $channelConvTemplateid, $channelPgTemplateId, $ownerSystemGroupId)
 {
     $input['parentid'] = $channelid;
     $input['inlist'] = 1;
     // we don't want it to be shown in channel list, but we want to move them
     $input['protected'] = 0;
     if (empty($input['userid'])) {
         $input['userid'] = vB::getCurrentSession()->get('userid');
     }
     if (!isset($input['publishdate'])) {
         $input['publishdate'] = vB::getRequest()->getTimeNow();
     }
     $input['templates']['vB5_Route_Channel'] = $channelPgTemplateId;
     $input['templates']['vB5_Route_Conversation'] = $channelConvTemplateid;
     // add channel node
     $channelLib = vB_Library::instance('content_channel');
     $input['page_parentid'] = 0;
     $result = $channelLib->add($input, array('skipFloodCheck' => true, 'skipDupCheck' => true));
     //Make the current user the channel owner.
     $userApi = vB_Api::instanceInternal('user');
     $usergroup = vB::getDbAssertor()->getRow('usergroup', array('systemgroupid' => $ownerSystemGroupId));
     if (empty($usergroup) or !empty($usergroup['errors'])) {
         //This should never happen. It would mean an invalid parameter was passed
         throw new vB_Exception_Api('invalid_request');
     }
     vB_User::setGroupInTopic($input['userid'], $result['nodeid'], $usergroup['usergroupid']);
     vB_Cache::allCacheEvent(array('nodeChg_' . $this->blogChannel, "nodeChg_{$channelid}"));
     vB::getUserContext()->rebuildGroupAccess();
     vB_Channel::rebuildChannelTypes();
     // clear follow cache
     vB_Api::instanceInternal('follow')->clearFollowCache(array($input['userid']));
     return $result['nodeid'];
 }
Exemplo n.º 3
0
 /**
  * Create an article category channel. This function works basically like the blog library's version
  *
  * @param array 	$input						data array, should have standard channel data like title, parentid, 
  * @param int 		$channelid					parentid that the new channel should fall under. 
  * @param int		$channelConvTemplateid		"Conversation" level pagetemplate to use. Typically vB_Page::getArticleConversPageTemplate()
  * @param int 		$channelPgTemplateId		"Channel" level pagetemplate to use. Typically  vB_Page::getArticleChannelPageTemplate()
  * @param int 		$ownerSystemGroupId
  *
  * @return int The nodeid of the new blog channel
  */
 public function createChannel($input, $channelid, $channelConvTemplateid, $channelPgTemplateId, $ownerSystemGroupId)
 {
     if (!isset($input['parentid']) or intval($input['parentid']) < 1) {
         $input['parentid'] = $channelid;
     }
     $input['inlist'] = 1;
     // we don't want it to be shown in channel list, but we want to move them
     $input['protected'] = 0;
     if (empty($input['userid'])) {
         $input['userid'] = vB::getCurrentSession()->get('userid');
     }
     if (!isset($input['publishdate'])) {
         $input['publishdate'] = vB::getRequest()->getTimeNow();
     }
     $input['templates']['vB5_Route_Channel'] = $channelPgTemplateId;
     $input['templates']['vB5_Route_Article'] = $channelConvTemplateid;
     $input['childroute'] = 'vB5_Route_Article';
     // add channel node
     $channelLib = vB_Library::instance('content_channel');
     $input['page_parentid'] = 0;
     $result = $channelLib->add($input, array('skipNotifications' => true, 'skipFloodCheck' => true, 'skipDupCheck' => true));
     //Make the current user the channel owner.
     $userApi = vB_Api::instanceInternal('user');
     $usergroup = vB::getDbAssertor()->getRow('usergroup', array('systemgroupid' => $ownerSystemGroupId));
     vB_Cache::allCacheEvent(array('nodeChg_' . $this->articleHomeChannel, "nodeChg_{$channelid}"));
     vB::getUserContext()->rebuildGroupAccess();
     vB_Channel::rebuildChannelTypes();
     // clear follow cache
     vB_Api::instanceInternal('follow')->clearFollowCache(array($input['userid']));
     return $result['nodeid'];
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 /**
  * 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;
 }
Exemplo n.º 6
0
 /**
  * Constructor public to allow for separate automated unit testing. Actual code should use
  * vB_Cache::instance();
  * @see vB_Cache::instance()
  */
 public function __construct($cachetype)
 {
     parent::__construct($cachetype);
     $this->requestStart = vB::getRequest()->getTimeNow();
     $config = vB::getConfig();
     $this->cachetype = $cachetype;
     if (!isset($config['Cache']['fileCachePath'])) {
         throw new vB_Exception_Cache('need_filecache_location');
     }
     $this->cacheLocation = $config['Cache']['fileCachePath'];
     if (!is_dir($this->cacheLocation) or !is_writable($this->cacheLocation)) {
         throw new vB_Exception_Cache('invalid_filecache_location- ' . $this->cacheLocation);
     }
 }
Exemplo n.º 7
0
 /**
  * Returns an instance of the global cache.
  * The cache type used is defined in options.
  *
  * @return vB_Cache							- Reference to instance of the cache handler
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         // TODO: Use config to determine the cache types to use
         self::$instance = vB_Cache_Db::instance();
         // TODO: Get appropriate class from options
         self::$instance->attachObserver(vB_Cache_Observer_Db::instance(self::$instance));
         vB::$vbulletin->shutdown->add(array(self::$instance, 'shutdown'));
     }
     if (vB::$vbulletin->debug and $_REQUEST['nocache']) {
         vB::$vbulletin->options['nocache'] = 1;
     }
     return self::$instance;
 }
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 /** 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;
 }
Exemplo n.º 11
0
     }
 }
 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();
Exemplo n.º 12
0
	/**
	* 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);
	}
Exemplo n.º 13
0
 /** 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;
 }
Exemplo n.º 14
0
 protected static function updateContentRoute($oldRouteInfo, $newRouteInfo)
 {
     $db = vB::getDbAssertor();
     $events = array();
     // update redirect301 fields
     $updateIds = $db->assertQuery('get_update_route_301', array('oldrouteid' => $oldRouteInfo['routeid']));
     if (!empty($updateIds)) {
         $routeIds = array();
         foreach ($updateIds as $route) {
             $routeid = $route['routeid'];
             $events[] = "routeChg_{$routeid}";
             $routeIds[] = $routeid;
         }
         $db->update('routenew', array('redirect301' => $newRouteInfo['routeid'], 'name' => vB_dB_Query::VALUE_ISNULL), array('routeid' => $routeIds));
     }
     // don't modify the routeid for default pages, as it will still be used
     $updateIds = $db->assertQuery('page', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::COLUMNS_KEY => array('pageid'), vB_dB_Query::CONDITIONS_KEY => array('routeid' => $oldRouteInfo['routeid'], 'pagetype' => vB_Page::TYPE_CUSTOM)));
     if (!empty($updateIds)) {
         $pageIds = array();
         foreach ($updateIds as $page) {
             $pageid = $page['pageid'];
             $events[] = "pageChg_{$pageid}";
             $pageIds[] = $pageid;
         }
         $db->update('page', array('routeid' => $newRouteInfo['routeid']), array('pageid' => $pageIds));
     }
     vB_Cache::allCacheEvent($events);
 }
Exemplo n.º 15
0
	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;

	}
Exemplo n.º 16
0
 /**
  * Rebuild the style datastore.
  */
 public function buildStyleDatastore()
 {
     $this->setCssDate();
     $stylecache = $this->fetchStyles(true, false, array('themes' => true));
     foreach ($stylecache as $key => $style) {
         // VBV-4174: we don't want stylevars in the datastore
         if (isset($style['newstylevars'])) {
             unset($stylecache[$key]['newstylevars']);
         }
     }
     vB::getDatastore()->build('stylecache', serialize($stylecache), 1);
     vB_Cache::allCacheEvent('vbCachedFullPage');
     vB_Library::instance('template')->rebuildTextonlyDS();
     return $stylecache;
 }
Exemplo n.º 17
0
 /**
  * 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');
             }
         }
     }
 }
Exemplo n.º 18
0
	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'];
	}
Exemplo n.º 19
0
// 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;
Exemplo n.º 20
0
				"
			);
		}
	}

	$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();
Exemplo n.º 21
0
 /**
  * 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}");
 }
Exemplo n.º 22
0
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// if (!is_object($vbulletin->db))
// {
// 	exit;
// }
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
$timenow = vB::getRequest()->getTimeNow();
vB::getDbAssertor()->delete('session', array(array('field' => 'lastactivity', 'value' => $timenow - vB::getDatastore()->getOption('cookietimeout'), vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_LT)));
vB::getDbAssertor()->delete('cpsession', array(array('field' => 'dateline', 'value' => vB::getDatastore()->getOption('timeoutcontrolpanel') ? $timenow - vB::getDatastore()->getOption('cookietimeout') : $timenow - 3600, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_LT)));
vB_Api::instanceInternal('search')->clean();
// expired lost passwords and email confirmations after 4 days
vB::getDbAssertor()->assertQuery('cleanupUA', array('time' => $timenow - 345600));
vB::getDbAssertor()->delete('noderead', array(array('field' => 'readtime', 'value' => $timenow - vB::getDatastore()->getOption('markinglimit') * 86400, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_LT)));
vB_Api_Wol::buildSpiderList();
// Remove expired cache items
vB_Cache::resetCache(true);
log_cron_action('', $nextitem, 1);
/*=========================================================================*\
|| #######################################################################
|| # Downloaded: 15:45, Tue Sep 8th 2015
|| # CVS: $RCSfile$ - $Revision: 83432 $
|| #######################################################################
\*=========================================================================*/
Exemplo n.º 23
0
                    $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') {
Exemplo n.º 24
0
 /** 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;
 }
Exemplo n.º 25
0
	/**
	 * 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;
	}
Exemplo n.º 26
0
	public function shutdown()
	{
		if (sizeof($this->purged))
		{
			vB::$db->query_write("
				DELETE FROM " . TABLE_PREFIX . "cache
				WHERE cacheid IN ('" . implode('\',\'', $this->purged) . "')
			");
		}
		$this->purged = array();

		if (sizeof($this->expired))
		{
			vB::$db->query_write("
				UPDATE " . TABLE_PREFIX . "cache
				SET expires = " . (TIMENOW - 1) . "
				WHERE cacheid IN ('" . implode('\',\'', $this->expired) . "')"
			);
		}
		$this->expired = array();

		parent::shutdown();
	}
Exemplo n.º 27
0
 /**
  * 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);
     }
 }
Exemplo n.º 28
0
 /**
  * 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;
 }
Exemplo n.º 29
0
// ######################### 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 $
|| ####################################################################
\*======================================================================*/
Exemplo n.º 30
0
	/**
	 * 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');

	}