/** * Deletes all the associated data for a specific from the database. * Only known master (volatile) data is removed. For example, customized versions * of the templates are left. * * @param string Product ID to delete * @param string Whether the deletion needs to work on a 3.5 DB (for vB upgrade scripts) * @param string True if you are calling this for a product upgrade. Old master templates will be moved instead of removed. */ function delete_product($productid, $compliant_35 = false, $for_product_upgrade = false) { $assertor = vB::getDbAssertor(); $options = vB::getDatastore()->getValue('options'); $assertor->delete('product', array('productid' => $productid)); $assertor->delete('productcode', array('productid' => $productid)); $assertor->delete('phrasetype', array('product' => $productid)); $assertor->delete('template', array('product' => $productid, 'styleid' => -10)); $assertor->delete('setting', array('product' => $productid, 'volatile' => 1)); $assertor->delete('settinggroup', array('product' => $productid, 'volatile' => 1)); $assertor->delete('vBForum:adminhelp', array('product' => $productid, 'volatile' => 1)); $assertor->delete('moderatorlog', array('product' => $productid)); if (!$for_product_upgrade) { $assertor->delete('vBForum:phrase', array('product' => $productid)); } else { $assertor->delete('vBForum:phrase', array('product' => $productid, 'languageid' => -1)); } if (!$compliant_35) { $assertor->delete('productdependency', array('productid' => $productid)); $assertor->delete('cron', array('product' => $productid, 'volatile' => 1)); $assertor->delete('vBForum:faq', array('product' => $productid, 'volatile' => 1)); } // Stuff to do only if version is vBulletin 5+ require_once DIR . '/includes/adminfunctions_template.php'; if (is_newer_version($options['templateversion'], '5.0.0 Alpha 1', true)) { $assertor->delete('hook', array('product' => $productid)); // Dont zap these on an upgrade. if (!$for_product_upgrade) { $assertor->delete('widget', array('product' => $productid)); $assertor->delete('widgetdefinition', array('product' => $productid)); $assertor->delete('page', array('product' => $productid)); $assertor->delete('pagetemplate', array('product' => $productid)); $assertor->delete('routenew', array('product' => $productid)); $channels = $assertor->getRows('vBForum:channel', array('product' => $productid)); $channelLib = vB_Library::instance('content_channel'); foreach ($channels as $channel) { $channelLib->delete($channel['nodeid']); } } } if ($for_product_upgrade) { $assertor->assertQuery('removePackageTemplate', array('productid' => $productid)); $assertor->update('template', array('styleid' => -10), array('product' => $productid, 'styleid' => -1)); } else { $assertor->delete('template', array('product' => $productid, 'styleid' => -1)); $ids = array(); if (!$compliant_35) { $types = $assertor->getRows('removePackageTypesFetch', array('productid' => $productid)); foreach ($types as $type) { $ids[] = $type['contenttypeid']; } if (!empty($ids)) { foreach ($ids as $TypeId) { vB_Library::instance('Content_Attach')->zapAttachmentType($TypeId); } } } } return true; }
/** * Returns the phrased page title based on the GUID * * @param string Page GUID */ public function getPageTitleByGuid($guid) { $phraseLib = vB_Library::instance('phrase'); $phraseVarname = 'page_' . $phraseLib->cleanGuidForPhrase($guid) . '_title'; $phrases = vB_Api::instanceInternal('phrase')->fetch(array($phraseVarname)); return $phrases[$phraseVarname]; }
/** * Handle update events. The required data in $eventData depends on the particular event. * Children may also handle their specific events. * * @param String $event One of the event strings in static::$updateEvents * @param Array $eventData When $event is 'read_topic'|'read_channel', expects: * int 'nodeid' * int 'userid' (Optional) */ public static function handleUpdateEvents($event, $eventData) { if (!static::validateUpdateEvent($event)) { return false; } $types = vB_Library::instance('Notification')->getNotificationTypes(); $typeid = $types[static::TYPENAME]['typeid']; $assertor = vB::getDbAssertor(); switch ($event) { case 'deleted_user': $userid = (int) $eventData['userid']; $check = $assertor->getRow('user', array('userid' => $userid)); if (empty($check)) { // remove any notification owned by deleted user. $assertor->assertQuery('vBForum:notification', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'recipient' => $userid, 'typeid' => $typeid)); // remove any userrelation notifications sent from now-deleted user. $assertor->assertQuery('vBForum:notification', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'sender' => $userid, 'typeid' => $typeid)); } break; default: break; } // skip parent handler. Nothing valid there that isn't already handled here. return; }
/** * Constructor, no direct instantiation */ protected function __construct() { parent::__construct(); $this->library = vB_Library::instance('Content_Infraction'); $this->infractionChannel = $this->nodeApi->fetchInfractionChannel(); $this->assertor = vB::getDbAssertor(); }
protected function __construct() { parent::__construct(); $this->storage = vB::getDatastore()->getOption('attachfile'); $this->filePath = vB::getDatastore()->getOption('attachpath'); $this->assertor = vB::getDbAssertor(); }
protected function import() { if (empty($this->parsedXML['page'])) { $this->parsedXML['page'] = array(); } // get all columns but the key $screenLayoutTable = $this->db->fetchTableStructure('screenlayout'); $screenLayoutTableColumns = array_diff($screenLayoutTable['structure'], array($screenLayoutTable['key'])); $phraseLib = vB_Library::instance('phrase'); $screenLayouts = $this->parsedXML['screenlayout']; foreach ($screenLayouts as $screenLayout) { // insert the screenlayout record $screenLayoutId = 0; $existing = $this->db->getRow('screenlayout', array('guid' => $screenLayout['guid'])); if ($existing) { if ($this->options & self::OPTION_OVERWRITE) { // overwrite $guid = $screenLayout['guid']; unset($screenLayout['guid']); $this->db->update('screenlayout', $screenLayout, array('guid' => $guid)); } $screenLayoutId = $existing['screenlayoutid']; } else { // insert new $screenLayoutId = $this->db->insert('screenlayout', $screenLayout); if (is_array($screenLayoutId)) { $screenLayoutId = array_pop($screenLayoutId); } } } }
/** * Fetches announcements by channel ID * * @param int $channelid (optional) Channel ID * @param int $announcementid (optional) Announcement ID * * @throws vB_Exception_Api no_permission if the user doesn't have permission to view the announcements * * @return array Announcements, each element is an array containing all the fields * in the announcement table and username, avatarurl, and the individual * options from the announcementoptions bitfield-- dohtml, donl2br, * dobbcode, dobbimagecode, dosmilies. */ public function fetch($channelid = 0, $announcementid = 0) { $usercontext = vB::getUserContext(); $userapi = vB_Api::instanceInternal('user'); $channelapi = vB_Api::instanceInternal('content_channel'); $parentids = array(); // Check channel permission if ($channelid) { // This is to verify $channelid $channelapi->fetchChannelById($channelid); if (!$usercontext->getChannelPermission('forumpermissions', 'canview', $channelid)) { throw new vB_Exception_Api('no_permission'); } $parents = vB_Library::instance('node')->getParents($channelid); foreach ($parents as $parent) { if ($parent['nodeid'] != 1) { $parentids[] = $parent['nodeid']; } } } $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'startdate', 'value' => vB::getRequest()->getTimeNow(), 'operator' => vB_dB_Query::OPERATOR_LTE), array('field' => 'enddate', 'value' => vB::getRequest()->getTimeNow(), 'operator' => vB_dB_Query::OPERATOR_GTE))); if ($parentids) { $parentids[] = -1; // We should always include -1 for global announcements $data[vB_dB_Query::CONDITIONS_KEY][] = array('field' => 'nodeid', 'value' => $parentids); } elseif ($channelid) { $channelid = array($channelid, -1); // We should always include -1 for global announcements $data[vB_dB_Query::CONDITIONS_KEY][] = array('field' => 'nodeid', 'value' => $channelid); } else { $data[vB_dB_Query::CONDITIONS_KEY][] = array('field' => 'nodeid', 'value' => '-1'); } $announcements = $this->assertor->getRows('vBForum:announcement', $data, array('field' => array('startdate', 'announcementid'), 'direction' => array(vB_dB_Query::SORT_DESC, vB_dB_Query::SORT_DESC))); if (!$announcements) { return array(); } else { $results = array(); $bf_misc_announcementoptions = vB::getDatastore()->getValue('bf_misc_announcementoptions'); foreach ($announcements as $k => $post) { $userinfo = $userapi->fetchUserinfo($post['userid'], array(vB_Api_User::USERINFO_AVATAR, vB_Api_User::USERINFO_SIGNPIC)); $announcements[$k]['username'] = $userinfo['username']; $announcements[$k]['avatarurl'] = $userapi->fetchAvatar($post['userid']); $announcements[$k]['dohtml'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowhtml']; if ($announcements[$k]['dohtml']) { $announcements[$k]['donl2br'] = false; } else { $announcements[$k]['donl2br'] = true; } $announcements[$k]['dobbcode'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowbbcode']; $announcements[$k]['dobbimagecode'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowbbcode']; $announcements[$k]['dosmilies'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowsmilies']; if ($announcements[$k]['dobbcode'] and $post['announcementoptions'] & $bf_misc_announcementoptions['parseurl']) { require_once DIR . '/includes/functions_newpost.php'; $announcements[$k]['pagetext'] = convert_url_to_bbcode($post['pagetext']); } } return $announcements; } }
public function call($forumid, $perpage = 20, $pagenumber = 1) { $contenttype = vB_Api::instance('contenttype')->fetchContentTypeIdFromClass('Channel'); $forum = vB_Api::instance('node')->getNodeFullContent($forumid); if (empty($forum) or isset($forum['errors'])) { return array("response" => array("errormessage" => array("invalidid"))); } $forum = $forum[$forumid]; $modPerms = vB::getUserContext()->getModeratorPerms($forum); $foruminfo = array('forumid' => $forum['nodeid'], 'title' => vB_String::unHtmlSpecialChars($forum['title']), 'description' => $forum['description'], 'title_clean' => $forum['htmltitle'], 'description_clean' => strip_tags($forum['description']), 'prefixrequired' => 0); $nodes = vB_Api::instance('node')->fetchChannelNodeTree($forumid, 3); $channels = array(); if (!empty($nodes) and empty($nodes['errors']) and isset($nodes['channels']) and !empty($nodes['channels'])) { foreach ($nodes['channels'] as $node) { $channels[] = vB_Library::instance('vb4_functions')->parseForum($node); } } $forumbits = $channels; $topics = array(); $topics_sticky = array(); $page_nav = vB_Library::instance('vb4_functions')->pageNav(1, $perpage, 1); $search = array("channel" => $forumid); $search['view'] = vB_Api_Search::FILTER_VIEW_TOPIC; $search['depth'] = 1; $search['include_sticky'] = true; $search['sort']['lastcontent'] = 'desc'; $search['nolimit'] = 1; $topic_search = vB_Api::instanceInternal('search')->getInitialResults($search, $perpage, $pagenumber, true); if (!isset($topic_search['errors']) and !empty($topic_search['results'])) { $topic_search['results'] = vB_Api::instance('node')->mergeNodeviewsForTopics($topic_search['results']); foreach ($topic_search['results'] as $key => $node) { if ($node['content']['contenttypeclass'] == 'Channel' or $node['content']['starter'] != $node['content']['nodeid']) { unset($topic_search['results'][$key]); } else { $topic = vB_Library::instance('vb4_functions')->parseThread($node); if ($topic['thread']['sticky']) { $topics_sticky[] = $topic; } else { $topics[] = $topic; } } } $page_nav = vB_Library::instance('vb4_functions')->pageNav($topic_search['pagenumber'], $perpage, $topic_search['totalRecords']); } $inlinemod = $forum['canmoderate'] ? 1 : 0; $subscribed = vB_Api::instance('follow')->isFollowingContent($forum['nodeid']); $subscribed = $subscribed ? 1 : 0; $forumsearch = vB::getUserContext()->hasPermission('forumpermissions', 'cansearch'); $response = array(); $response['response']['forumbits'] = $forumbits; $response['response']['foruminfo'] = $foruminfo; $response['response']['threadbits'] = $topics; $response['response']['threadbits_sticky'] = $topics_sticky; $response['response']['pagenav'] = $page_nav; $response['response']['pagenumber'] = intval($pagenumber); $response['show'] = array('subscribed_to_forum' => $subscribed, 'inlinemod' => $inlinemod, 'spamctrls' => $modPerms['candeleteposts'] > 0 ? 1 : 0, 'openthread' => $modPerms['canopenclose'] > 0 ? 1 : 0, 'approvethread' => $modPerms['canmoderateposts'] > 0 ? 1 : 0, 'movethread' => $modPerms['canmassmove'] > 0 ? 1 : 0, 'forumsearch' => $forumsearch, 'stickies' => count($topics_sticky) > 0 ? 1 : 0); return $response; }
protected function addAdditionalRecipients() { $nodeid = $this->notificationData['sentbynodeid']; $poll = vB_Library::instance('node')->getNodeBare($nodeid); // Note, isVisitorMessage() check is in validateAndCleanNotificationData(). if (!empty($poll['userid']) and $poll['userid'] != $this->notificationData['sender']) { return array($poll['userid']); } return array(); }
/** * Shows the form for inline mod authentication. */ function show_inline_mod_login($showerror = false) { global $vbulletin, $vbphrase, $show; $show['inlinemod_form'] = true; $show['passworderror'] = $showerror; if (!$showerror) { $vbulletin->url = SCRIPTPATH; } $forumHome = vB_Library::instance('content_channel')->getForumHomeChannel(); eval(standard_error(fetch_error('nopermission_loggedin', $vbulletin->userinfo['username'], vB_Template_Runtime::fetchStyleVar('right'), vB::getCurrentSession()->get('sessionurl'), $vbulletin->userinfo['securitytoken'], vB5_Route::buildUrl($forumHome['routeid'] . 'home|fullurl')))); }
public function buddylist() { $followers = vB_Api::instance('follow')->getFollowers($userid, array('page' => $pagenumber, 'perpage' => $perpage)); if ($followers === null || isset($followers['errors'])) { return vB_Library::instance('vb4_functions')->getErrorResponse($followers); } $friends = array(); foreach ($followers['results'] as $friend) { $friends[] = array('buddy' => array('userid' => $friend['userid'], 'username' => $friend['username'])); } return array('response' => array('offlineusers' => $friends)); }
protected function buildOutputFromItems($items, $options) { parent::buildOutputFromItems($items, $options); if ($this->rssinfo['ttl'] <= 60) { $updateperiod = 'hourly'; $updatefrequency = round(60 / $this->rssinfo['ttl']); } else { $updateperiod = 'daily'; $updatefrequency = round(1440 / $this->rssinfo['ttl']); } $xml = new vB_Xml_Builder(); $xml->add_group('rdf:RDF', array('xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:syn' => 'http://purl.org/rss/1.0/modules/syndication/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns' => 'http://purl.org/rss/1.0/')); $xml->add_group('channel', array('rdf:about' => $this->rssinfo['link'])); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->add_tag('description', $this->rssinfo['description']); $xml->add_tag('syn:updatePeriod', $updateperiod); $xml->add_tag('syn:updateFrequency', $updatefrequency); $xml->add_tag('syn:updateBase', '1970-01-01T00:00Z'); $xml->add_tag('dc:language', $this->defaultLang['languagecode']); $xml->add_tag('dc:creator', 'vBulletin'); $xml->add_tag('dc:date', gmdate('Y-m-d\\TH:i:s') . 'Z'); $xml->add_group('items'); $xml->add_group('rdf:Seq'); $xml->add_tag('rdf:li', '', array('rdf:resource' => $this->rssinfo['link'] . '/')); $xml->close_group('rdf:Seq'); $xml->close_group('items'); $xml->add_group('image'); $xml->add_tag('url', $this->rssinfo['icon']); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->close_group('image'); $xml->close_group('channel'); // gather channel info $channelsInfo = $this->getItemsChannelInfo($items); $items = $this->formatItems($items, $options); foreach ($items as $id => $item) { $item = $item['content']; $xml->add_group('item', array('rdf:about' => vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']))); $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title'])); $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true); $xml->add_tag('description', $this->getItemDescription($item['rawtext'], $options)); if (empty($options['nohtml'])) { $xml->add_tag('content:encoded', vB_Library::instance('bbcode')->doParse($item['rawtext'])); } $xml->add_tag('dc:date', gmdate('Y-m-d\\TH:i:s', $item['publishdate']) . 'Z'); $xml->add_tag('dc:creator', vB_String::unHtmlSpecialChars($item['authorname'])); $xml->add_tag('dc:subject', $channelsInfo[$item['channelid']]['htmltitle']); $xml->close_group('item'); } $xml->close_group('rdf:RDF'); return $xml->fetch_xml(); }
function appendAttachments($nodeid, $posthash) { if (!empty($posthash) and !empty($nodeid)) { $filedataids = vB_Library::instance('vb4_posthash')->getFiledataids($posthash); foreach ($filedataids as $filedataid) { $result = vB_Api::instance('node')->addAttachment($nodeid, array('filedataid' => $filedataid['filedataid'])); if (empty($result) || !empty($result['errors'])) { // Ignore attachment errors } } } }
protected function getNewRouteInfo() { // go to home page if path is exactly like prefix if (count($this->matches) == 1 and empty($this->queryParameters)) { $blogHomeChannelId = vB_Api::instance('blog')->getBlogChannel(); $blogHomeChannel = vB_Library::instance('content_channel')->getBareContent($blogHomeChannelId); $blogHomeChannel = $blogHomeChannel[$blogHomeChannelId]; return $blogHomeChannel['routeid']; } $this->oldcontenttypeid = vB_Api_ContentType::OLDTYPE_BLOGCHANNEL; return parent::getNewRouteInfo(); }
protected function addAdditionalRecipients() { $nodeid = $this->notificationData['sentbynodeid']; $node = vB_Library::instance('node')->getNodeBare($nodeid); // Is this a reply? if ($node['parentid'] == $node['starter']) { $starter = vB_Library::instance('node')->getNodeBare($node['starter']); if (!empty($starter['userid']) and $starter['userid'] != $this->notificationData['sender']) { return array($starter['userid']); } } return array(); }
protected function addAdditionalRecipients() { $nodeid = $this->notificationData['sentbynodeid']; $node = vB_Library::instance('node')->getNodeBare($nodeid); // If this is not a topic starter, and is not a reply, then it's a comment if ($node['nodeid'] != $node['starter'] and $node['parentid'] != $node['starter']) { $parent = vB_Library::instance('node')->getNodeBare($node['parentid']); if (!empty($parent['userid']) and $parent['userid'] != $this->notificationData['sender']) { return array($parent['userid']); } } return array(); }
/** * Children of this class will be grouped by the starter of the sentbynodeid. * * @return String[String] * * @access protected */ protected static final function defineUnique($notificationData, $skipValidation) { $nodeid = $notificationData['sentbynodeid']; if ($skipValidation) { $node = array(); $node['starter'] = (int) $notificationData['starter']; } else { $node = vB_Library::instance('node')->getNodeBare($nodeid); if (!isset($node['starter'])) { throw new Exception("Missing data! node.starter"); } } return array('starter' => (int) $node['starter']); }
public function editpost($postid) { $cleaner = vB::getCleaner(); $postid = $cleaner->clean($postid, vB_Cleaner::TYPE_UINT); $post = vB_Api::instance('node')->getFullContentforNodes(array($postid)); if (empty($post)) { return array("response" => array("errormessage" => array("invalidid"))); } $post = $post[0]; $prefixes = vB_Library::instance('vb4_functions')->getPrefixes($postid); $options = vB::getDatastore()->getValue('options'); $out = array('show' => array('tag_option' => 1), 'vboptions' => array('postminchars' => $options['postminchars'], 'titlemaxchars' => $options['titlemaxchars']), 'response' => array('prefix_options' => $prefixes, 'poststarttime' => 0, 'posthash' => vB_Library::instance('vb4_posthash')->getNewPosthash())); return $out; }
public function docopythread($threadid, $destforumid) { $cleaner = vB::getCleaner(); $threadid = $cleaner->clean($threadid, vB_Cleaner::TYPE_UINT); $destforumid = $cleaner->clean($destforumid, vB_Cleaner::TYPE_UINT); if (empty($threadid) || empty($destforumid)) { return array('response' => array('errormessage' => 'invalidid')); } $result = vB_Api::instance('node')->cloneNodes(array($threadid), $destforumid); if ($result === null || isset($result['errors'])) { return vB_Library::instance('vb4_functions')->getErrorResponse($result); } else { return array('response' => array('errormessage' => array('redirect_movethread'))); } }
public function __construct($routeInfo, $matches, $queryString = '', $anchor = '') { parent::__construct($routeInfo, $matches, $queryString, $anchor); if (isset($this->arguments['pageid']) and !empty($this->arguments['pageid'])) { $this->setPageKey('pageid'); $page = $this->getPage(); if ($page) { switch ($page['guid']) { case vB_Page::PAGE_SOCIALGROUP: $this->checkStyle(vB_Channel::DEFAULT_SOCIALGROUP_PARENT); break; case vB_Page::PAGE_BLOG: $this->setUserAction('viewing_blog_home'); $this->checkStyle(vB_Channel::DEFAULT_BLOG_PARENT); break; case vB_Page::PAGE_ONLINE: case vB_Page::PAGE_MEMBERLIST: $this->setUserAction('viewing_whos_online'); break; case vB_Page::PAGE_SEARCH: case vB_Page::PAGE_SEARCHRESULT: $this->setUserAction('searching_forums'); break; case vB_Page::PAGE_HOME: default: // TODO: should pages have a link by default? $this->setUserAction('viewing_x', $page['title'], $this->getFullUrl('fullurl')); } } } // RSS for channel pages (blog, group). Assuming that if a channelid argument is set, it's a channel // and the RSS xml exporter can create one for this. This should also set head links if (isset($this->arguments['channelid'])) { $channel = vB_Library::instance('Content_Channel')->getBareContent($this->arguments['channelid']); if (is_array($channel)) { $channel = array_pop($channel); } if ($channel['rss_enabled']) { $this->arguments['rss_enabled'] = $channel['rss_enabled']; $this->arguments['rss_route'] = $channel['rss_route']; $this->arguments['rss_title'] = $channel['title']; // because conversation routes also add their parent channel's rss info into the arguments, // this flag helps us tell channels apart from conversations when we're adding the RSS icon next to the page title $this->arguments['rss_show_icon_on_pagetitle'] = true; } } }
function construct_stylevar_form($title, $stylevarid, $values, $styleid) { global $vbulletin; $stylecache = vB_Library::instance('Style')->fetchStyles(false, false); $editstyleid = $styleid; if (isset($values[$stylevarid][$styleid])) { // customized or master if ($styleid == -1) { // master $hide_revert = true; } } else { // inherited while (!isset($values[$stylevarid][$styleid])) { $styleid = $stylecache[$styleid]['parentid']; if (!isset($stylecache[$styleid]) and $styleid != -1) { trigger_error('Invalid style in tree: ' . $styleid, E_USER_ERROR); break; } } $hide_revert = true; } $stylevar = $values[$stylevarid][$styleid]; $hide_revert = $hide_revert ? 'hide_revert' : ''; if ($stylevar['value'] == '') { // blank for value? use fall back $stylevar['value'] = $stylevar['failsafe']; } $svinstance = vB_StyleVar_factory::create($stylevar['datatype']); $svinstance->set_stylevarid($stylevarid); $svinstance->set_styleid($styleid); $svinstance->set_definition($stylevar); $svinstance->set_value(unserialize($stylevar['value'])); // remember, our value in db is ALWAYS serialized! if ($stylevar['stylevarstyleid'] == -1) { $svinstance->set_inherited(0); } else { if ($stylevar['stylevarstyleid'] == $vbulletin->GPC['dostyleid']) { $svinstance->set_inherited(-1); } else { $svinstance->set_inherited(1); } } $editor = $svinstance->print_editor(); return $editor; }
public function getCanonicalRoute($node = false) { if (!isset($this->canonicalRoute)) { if (empty($this->title)) { if (empty($node)) { $node = vB_Library::instance('node')->getNodeBare($this->arguments['nodeid']); } if (empty($node) or !empty($node['errors'])) { return FALSE; } $this->title = self::prepareTitle($node['title']); } $routeInfo = array('routeid' => $this->routeId, 'prefix' => $this->prefix, 'regex' => $this->regex, 'nodeid' => $this->nodeid, 'title' => $this->title, 'controller' => $this->controller, 'pageid' => $this->arguments['contentid']); $this->canonicalRoute = new vB5_Route_Album($routeInfo, array('nodeid' => $this->nodeid), http_build_query($this->queryParameters)); } return $this->canonicalRoute; }
public function newthread($forumid) { $cleaner = vB::getCleaner(); $forumid = $cleaner->clean($forumid, vB_Cleaner::TYPE_UINT); $forum = vB_Api::instance('node')->getFullContentforNodes(array($forumid)); if (empty($forum)) { return array("response" => array("errormessage" => array("invalidid"))); } $forum = $forum[0]; $foruminfo = vB_Library::instance('vb4_functions')->parseForumInfo($forum); $prefixes = vB_Library::instance('vb4_functions')->getPrefixes($forumid); $options = vB::getDatastore()->getValue('options'); $postattachment = $forum['content']['createpermissions']['vbforum_attach']; $postattachment = empty($postattachment) ? 0 : intval($postattachment); $usercontext = vB::getUserContext($this->currentUserId); $maxtags = $usercontext->getChannelLimits($forumid, 'maxstartertags'); $out = array('show' => array('tag_option' => 1), 'vboptions' => array('postminchars' => $options['postminchars'], 'titlemaxchars' => $options['titlemaxchars'], 'maxtags' => $maxtags), 'response' => array('forumrules' => array('can' => array('postattachment' => $postattachment)), 'prefix_options' => $prefixes, 'foruminfo' => $foruminfo, 'poststarttime' => vB::getRequest()->getTimeNow(), 'posthash' => vB_Library::instance('vb4_posthash')->getNewPosthash())); return $out; }
public function sendemail($postid, $reason) { $cleaner = vB::getCleaner(); $postid = $cleaner->clean($postid, vB_Cleaner::TYPE_UINT); $reason = $cleaner->clean($reason, vB_Cleaner::TYPE_STR); if (empty($postid)) { return array('response' => array('errormessage' => array('invalidid'))); } if (empty($reason)) { return array('response' => array('errormessage' => array('invalidid'))); } $userinfo = vB_Api::instance('user')->fetchUserinfo(); $data = array('reportnodeid' => $postid, 'rawtext' => $reason, 'created' => vB::getRequest()->getTimeNow(), 'userid' => $userinfo['userid'], 'authorname' => $userinfo['username']); $result = vB_Api::instance('content_report')->add($data, array('wysiwyg' => false)); if ($result === null || isset($result['errors'])) { return vB_Library::instance('vb4_functions')->getErrorResponse($result); } return array('response' => array('errormessage' => array('redirect_reportthanks'))); }
public function newreply($threadid, $disablesmilies = false) { $cleaner = vB::getCleaner(); $threadid = $cleaner->clean($threadid, vB_Cleaner::TYPE_UINT); $thread = vB_Api::instance('node')->getFullContentforNodes(array($threadid)); if (empty($thread)) { return array("response" => array("errormessage" => array("invalidid"))); } $thread = $thread[0]; $prefixes = vB_Library::instance('vb4_functions')->getPrefixes($threadid); $options = vB::getDatastore()->getValue('options'); $postattachment = $thread['content']['createpermissions']['vbforum_attach']; $postattachment = empty($postattachment) ? 0 : intval($postattachment); /* additional options' checked checkboxes array... */ $checked = array('parseurl' => 1, 'signature' => "", "subscribe" => $thread['content']['subscribed']); // SIGNATURE $userContext = vB::getUserContext(); $currentUserId = $userContext->fetchUserId(); $signature = vB_Api::instanceInternal('user')->fetchSignature($currentUserId); if (!empty($signature)) { $checked['signature'] = 1; } // DISABLESMILIES // getDataForParse converts channel.options into bbcodeoptions, and this is used by the // frontend nodetext / bbcode parsers $textDataArray = vB_Api::instanceInternal('content_text')->getDataForParse(array($threadid)); $channelAllowsSmilies = $textDataArray[$threadid]['bbcodeoptions']['allowsmilies']; if ($channelAllowsSmilies) { if (!empty($disablesmilies)) { $checked['disablesmilies'] = 1; } else { $checked['disablesmilies'] = ""; } $show['smiliebox'] = 1; } else { $show['smiliebox'] = 0; } $out = array('show' => array('tag_option' => 1, 'smiliebox' => $show['smiliebox']), 'vboptions' => array('postminchars' => $options['postminchars'], 'titlemaxchars' => $options['titlemaxchars']), 'response' => array('title' => '', 'forumrules' => array('can' => array('postattachment' => $postattachment)), 'prefix_options' => $prefixes, 'poststarttime' => 0, 'posthash' => vB_Library::instance('vb4_posthash')->getNewPosthash()), 'checked' => $checked); return $out; }
protected function addAdditionalRecipients() { $nodeid = $this->notificationData['sentbynodeid']; $node = vB_Library::instance('node')->getNode($nodeid, false, true); // we need the rawtext. $quotedUsers = array(); if (isset($node['rawtext'])) { // don't send a notification if the user mention is inside a [NOPARSE] tag. $find = array('#\\[NOPARSE\\].*\\[/NOPARSE\\]#siU'); $replace = ''; $rawtext = preg_replace($find, $replace, $node['rawtext']); /* * Note, this currently has issues with names with closing brackets ] in them, VBV-14607 */ if (preg_match_all('#\\[QUOTE=(?<username>[^\\]]+)(;(?<node>(n?\\d+)))?\\].*\\[/QUOTE\\]#siU', $rawtext, $matches)) { /* * Fetch userids based on found usernames. */ if (!empty($matches['username'])) { $fetchUsers = array(); foreach ($matches['username'] as $username) { /* * Testing indicates that ajax/fetch-quotes will escape the names for us. * If we expect the usernames to be raw unescaped names, similar to a username that * would come in through the user API login, use the the "raw" to "DB-expected" * conversion below, taken from vB_Api_User::login() & vB_User::verifyAuthentication() * respectively : #$username = vB_String::htmlSpecialCharsUni($username); #$username = vB_String::convertStringToCurrentCharset($username); */ $fetchUsers[$username] = $username; } $useridsQuery = vB::getDbAssertor()->getRows('user', array(vB_Db_Query::COLUMNS_KEY => array('userid', 'username'), 'username' => $fetchUsers)); foreach ($useridsQuery as $row) { $quotedUsers[$row['userid']] = $row['userid']; } } } unset($rawtext, $find, $replace, $matches); } return $quotedUsers; }
protected function getNewRouteInfo() { // go to home page if path is exactly like prefix if (count($this->matches) == 1 and empty($this->queryParameters)) { $forumHomeChannel = vB_Library::instance('content_channel')->getForumHomeChannel(); return $forumHomeChannel['routeid']; } // capture old id $argument =& $this->arguments; $oldid = $argument['oldid']; // calculate old contenttypeid $oldtype = array('t' => 'Thread', 'f' => 'Forum'); $oldcontenttypeid = vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => $oldtype[$this->matches['nodetype']])); $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid)); if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $argument['nodeid'] = $node['nodeid']; return $node['routeid']; }
/** * Returns a list of all page templates and widget instances associated with them. * * @param int The pagetemplateid for the current page (when editing) * * @return array An array of pagetemplates. Each array element contains the fields * from the pagetemplate table, a 'title' element, and a 'widgetinstances' * element. Each element in 'widgetinstances' contains the fields from * the widgetinstance table, and a 'title' element. */ public function fetchPageTemplateList($pagetemplateid) { $pagetemplateid = (int) $pagetemplateid; if ($pagetemplateid < 0) { $pagetemplateid = 0; } $db = vB::getDbAssertor(); // get all page templates that are not in the process of being created // always return the current page's page template, regardless $values = array('pagetemplateid' => $pagetemplateid); $result = $db->assertQuery('fetch_page_template_list', $values, 'title'); $phraseLib = vB_Library::instance('phrase'); $phrasestofetch = array(); foreach ($result as $row) { $phrasestofetch[] = 'pagetemplate_' . $phraseLib->cleanGuidForPhrase($row['guid']) . '_title'; } $vbphrases = vB_Api::instanceInternal('phrase')->fetch(array_unique($phrasestofetch)); $pageTemplates = array(); foreach ($result as $row) { $guidforphrase = $phraseLib->cleanGuidForPhrase($row['guid']); $phrasename = 'pagetemplate_' . $guidforphrase . '_title'; if (!empty($vbphrases[$phrasename])) { $row['title'] = $vbphrases[$phrasename]; } $pageTemplates[$row['pagetemplateid']] = $row; } foreach ($pageTemplates as $k => $v) { $pageTemplates[$k]['widgetinstances'] = array(); } $widgets = $db->getRows('widget', array(), '', 'widgetid'); $widgetInstances = $db->getRows('widgetinstance', array(), array('displaysection', 'displayorder')); foreach ($widgetInstances as $widgetInstance) { $pageTemplateId = $widgetInstance['pagetemplateid']; if (isset($pageTemplates[$pageTemplateId])) { $widgetInstance['title'] = (empty($widgetInstance['widgetid']) or empty($widgets[$widgetInstance['widgetid']])) ? '' : $widgets[$widgetInstance['widgetid']]['title']; $pageTemplates[$pageTemplateId]['widgetinstances'][] = $widgetInstance; } } // remove the page template ID as the array indices return array_values($pageTemplates); }
protected function addAdditionalRecipients() { $nodeid = $this->notificationData['sentbynodeid']; $node = vB_Library::instance('node')->getNode($nodeid, false, true); // we need the rawtext. $usermentions = array(); if (isset($node['rawtext'])) { // don't send a notification if the user mention is inside a [QUOTE] or [NOPARSE] tag. $find = array('#\\[QUOTE[^\\]]*\\].*\\[/QUOTE\\]#siU', '#\\[NOPARSE\\].*\\[/NOPARSE\\]#siU'); $replace = ''; $rawTextForUserMentions = preg_replace($find, $replace, $node['rawtext']); if (preg_match_all('#\\[USER=(["\'])?([0-9]+)(\\1)?\\](.*)\\[/USER\\]#siU', $rawTextForUserMentions, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $userid = (int) $match[2]; $usermentions[$userid] = $userid; } } unset($rawTextForUserMentions, $find, $replace, $matches); } return $usermentions; }
protected function buildOutputFromItems($items, $options) { parent::buildOutputFromItems($items, $options); $xml = new vB_Xml_Builder(); $xml->add_group('rss', array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/')); $xml->add_group('channel'); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->add_tag('description', $this->rssinfo['description']); $xml->add_tag('language', $this->defaultLang['languagecode']); $xml->add_tag('lastBuildDate', gmdate('D, d M Y H:i:s') . ' GMT'); $xml->add_tag('generator', 'vBulletin'); $xml->add_tag('ttl', $this->rssinfo['ttl']); $xml->add_group('image'); $xml->add_tag('url', $this->rssinfo['icon']); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->close_group('image'); // gather channel info $channelsInfo = $this->getItemsChannelInfo($items); $items = $this->formatItems($items, $options); foreach ($items as $id => $item) { $item = $item['content']; $xml->add_group('item'); $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title'])); $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true); $xml->add_tag('pubDate', gmdate('D, d M Y H:i:s', $item['publishdate']) . ' GMT'); $xml->add_tag('description', $this->getItemDescription($item['rawtext'], $options)); if (empty($options['nohtml'])) { $xml->add_tag('content:encoded', vB_Library::instance('bbcode')->doParse($item['rawtext'])); } $xml->add_tag('category', $channelsInfo[$item['channelid']]['htmltitle'], array('domain' => vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['channelid']))); $xml->add_tag('dc:creator', vB_String::unHtmlSpecialChars($item['authorname'])); $xml->add_tag('guid', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array('isPermaLink' => 'true')); $xml->close_group('item'); } $xml->close_group('channel'); $xml->close_group('rss'); return $xml->fetch_xml(); }