本文整理汇总了PHP中vB_Library::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_Library::instance方法的具体用法?PHP vB_Library::instance怎么用?PHP vB_Library::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB_Library
的用法示例。
在下文中一共展示了vB_Library::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_product
/**
* 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;
}
示例2: handleUpdateEvents
/**
* 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;
}
示例3: __construct
/**
* 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();
}
示例4: getPageTitleByGuid
/**
* 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];
}
示例5: import
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);
}
}
}
}
示例6: fetch
/**
* 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;
}
}
示例7: call
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;
}
示例8: addAdditionalRecipients
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();
}
示例9: show_inline_mod_login
/**
* 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'))));
}
示例10: buddylist
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));
}
示例11: appendAttachments
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
}
}
}
}
示例12: getNewRouteInfo
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();
}
示例13: buildOutputFromItems
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();
}
示例14: addAdditionalRecipients
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();
}
示例15: addAdditionalRecipients
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();
}