本文整理汇总了PHP中vB_Api::instanceInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_Api::instanceInternal方法的具体用法?PHP vB_Api::instanceInternal怎么用?PHP vB_Api::instanceInternal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB_Api
的用法示例。
在下文中一共展示了vB_Api::instanceInternal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setBreadcrumbs
/**
* Sets the breadcrumbs for the route
*
* @return array
*/
protected function setBreadcrumbs()
{
$this->breadcrumbs = array();
$phrase = 'create_new_topic';
if (isset($this->arguments['nodeid']) && $this->arguments['nodeid']) {
$onlyAddTopParent = false;
$channelInfo = vB_Api::instanceInternal('Content_Channel')->fetchChannelById(intval($this->arguments['nodeid']));
if ($channelInfo) {
switch ($channelInfo['channeltype']) {
case 'blog':
$phrase = 'create_new_blog_entry';
break;
case 'group':
$phrase = 'create_new_topic';
break;
case 'article':
$phrase = 'create_new_article';
// when creating an article, the breadcrumb should
// always be home > articles > create article
// since you can choose the category when creating the article
$onlyAddTopParent = true;
break;
default:
break;
}
}
$this->addParentNodeBreadcrumbs($this->arguments['nodeid'], $onlyAddTopParent);
}
$this->breadcrumbs[] = array('phrase' => $phrase);
}
示例2: createChannel
/**
* 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'];
}
示例3: createChannel
/**
* 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'];
}
示例4: do_get_conversations
function do_get_conversations()
{
$userinfo = vB_Api::instance('user')->fetchUserInfo();
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('page' => vB_Cleaner::TYPE_UINT, 'perpage' => vB_Cleaner::TYPE_UINT));
if (!$userinfo['userid']) {
return json_error(ERR_INVALID_LOGGEDIN, RV_NOT_LOGGED_IN);
}
$pm_out = array();
$totalmessages = 0;
$page = $cleaned['page'] ? $cleaned['page'] : 1;
$perpage = $cleaned['perpage'] ? $cleaned['perpage'] : 10;
$folders = vB_Api::instanceInternal('content_privatemessage')->listFolders();
$folderid = array_search("Inbox", $folders);
$order = "desc";
$messages = vB_Api::instanceInternal('content_privatemessage')->listMessages(array("folderid" => $folderid, "page" => $page, "perpage" => $perpage, "sortDir" => $order));
if ($messages == false) {
json_error("Invalid PM Folder");
}
$totalmessages = vB_Api::instance('content_privatemessage')->getFolderMsgCount($folderid);
$totalmessages = $totalmessages['count'];
foreach ($messages as $message) {
$pm_out[] = fr_parse_conversation($message);
}
return array('conversations' => $pm_out, 'total_conversations' => $totalmessages, 'canstart' => true);
}
示例5: construct_user_ip_table
function construct_user_ip_table($userid, $previpaddress, $depth = 2)
{
global $vbulletin, $vbphrase;
if (VB_AREA == 'AdminCP') {
$userscript = 'usertools.php';
} else {
$userscript = 'user.php';
}
$depth--;
$ips = vB_Api::instanceInternal('user')->searchIP($userid, $depth);
$retdata = '';
// @TODO user api currently returns only 1 IP per user.
$result = array('ipaddress' => $ips['regip']);
foreach ($result as $ip) {
$retdata .= '<li>' . "<a href=\"{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&ip={$ip['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$ip['ipaddress']}</a> " . construct_link_code($vbphrase['find_more_users_with_this_ip_address'], "{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=doips&ipaddress={$ip['ipaddress']}&hash=" . CP_SESSIONHASH) . "</li>\n";
if ($depth > 0) {
$retdata .= construct_ip_usage_table($ip['ipaddress'], $userid, $depth);
}
}
if (empty($retdata)) {
return '';
} else {
return '<ul>' . $retdata . '</ul>';
}
}
示例6: getCanonicalRoute
public function getCanonicalRoute()
{
if (!isset($this->canonicalRoute)) {
if (empty($this->arguments['nodeid'])) {
throw new vB_Exception_NodePermission();
}
$nodeApi = vB_Api::instanceInternal('node');
try {
// this method will return an error if the user does not have permission
$node = $nodeApi->getNode($this->arguments['nodeid']);
} catch (vB_Exception_Api $ex) {
// throw the proper NodePermission exception to return a 403 status instead of a 500 internal error
if ($ex->has_errors('no_permission')) {
throw new vB_Exception_NodePermission($this->arguments['nodeid']);
} else {
// otherwise, just let the caller catch the exception
throw $ex;
}
}
$contentApi = vB_Api_Content::getContentApi($node['contenttypeid']);
if (!$contentApi->validate($node, vB_Api_Content::ACTION_VIEW, $node['nodeid'], array($node['nodeid'] => $node))) {
throw new vB_Exception_NodePermission($node['nodeid']);
}
$parent = $nodeApi->getNode($node['starter']);
$parent['innerPost'] = $this->arguments['nodeid'];
$this->canonicalRoute = self::getRoute($node['routeid'], $parent, $this->queryParameters);
}
return $this->canonicalRoute;
}
示例7: buildOutputFromItems
protected function buildOutputFromItems($items, $options)
{
parent::buildOutputFromItems($items, $options);
$xml = new vB_Xml_Builder();
$xml->add_group('rss', array('version' => '0.91'));
$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_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');
$dateformat = vB::getDatastore()->getOption('dateformat');
$timeformat = vB::getDatastore()->getOption('timeformat');
// 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('description', vB_Phrase::fetchSinglePhrase('rss_91_forum_w_posted_by_x_post_time_y_at_z', array($channelsInfo[$item['channelid']]['htmltitle'], $item['authorname'], $this->callvBDate($dateformat, $item['publishdate']), $this->callvBDate($timeformat, $item['publishdate']))));
$xml->close_group('item');
}
$xml->close_group('channel');
$xml->close_group('rss');
$output .= '<!DOCTYPE rss PUBLIC "-//RSS Advisory Board//DTD RSS 0.91//EN" "http://www.rssboard.org/rss-0.91.dtd">' . "\r\n";
$output .= $xml->output();
return $xml->fetch_xml_tag() . $output;
}
示例8: 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];
}
示例9: 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;
}
}
示例10: loadRssInfo
/**
* Loads information needed for RSS output
*
* @param array Options to be considered for feed.
*/
protected function loadRssInfo($options)
{
$description = $this->getPhraseFromGuid(vB_Page::PAGE_HOME, 'metadesc');
$stylevars = vB_Api::instanceInternal('style')->fetchStylevars(array(vB::getDatastore()->getOption('styleid')));
$imgdir = (!empty($stylevars['imgdir_misc']) and !empty($stylevars['imgdir_misc']['imagedir'])) ? $stylevars['imgdir_misc']['imagedir'] : '';
$this->rssinfo = array('title' => vB::getDatastore()->getOption('bbtitle'), 'link' => vB::getDatastore()->getOption('frontendurl'), 'icon' => vB::getDatastore()->getOption('bburl') . '/' . $imgdir . '/rss.png', 'description' => $description, 'ttl' => 60);
$this->rssinfo = $this->applyRssOptions($options, $this->rssinfo);
}
示例11: setBreadcrumbs
/**
* Sets the breadcrumbs for the route
*/
protected function setBreadcrumbs()
{
//if we are coming in for a route (instead of generating a URL) then the $this->arguments['username'] is the
//url slug, which we don't want. The API call is cached and will be called later anyway to generate the
//profile page so its not a bit performance hit to load this way.
$userInfo = vB_Api::instanceInternal('user')->fetchProfileInfo($this->arguments['userid']);
$this->breadcrumbs = array(0 => array('title' => $userInfo['username'], 'url' => ''));
}
示例12: 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;
}
示例13: fetchAll
/**
* Fetch all subscriptions that an user can join and already joined
* It also fetches active payment APIs
*
* @param bool $isreg Whether to fetch subscriptions for signup page
* @return array Paid subscriptions info for the user.
*/
public function fetchAll($isreg = false)
{
try {
$this->checkStatus();
} catch (vB_Exception_Api $e) {
return array();
}
$userinfo = vB::getCurrentSession()->fetch_userinfo();
$usercontext = vB::getUserContext();
$membergroupids = fetch_membergroupids_array($userinfo);
$allow_secondary_groups = $usercontext->hasPermission('genericoptions', 'allowmembergroups');
$subscribed = $this->fetchSubscribed();
$vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('day', 'week', 'month', 'year', 'days', 'weeks', 'months', 'years', 'length_x_units_y_recurring_z', 'recurring'));
$lengths = array('D' => $vbphrase['day'], 'W' => $vbphrase['week'], 'M' => $vbphrase['month'], 'Y' => $vbphrase['year'], 'Ds' => $vbphrase['days'], 'Ws' => $vbphrase['weeks'], 'Ms' => $vbphrase['months'], 'Ys' => $vbphrase['years']);
$cansubscribesubscriptions = array();
$subscribedsubscriptions = array();
foreach ($this->subobj->subscriptioncache as $subscription) {
$subscriptionid =& $subscription['subscriptionid'];
$subscription['cost'] = unserialize($subscription['cost']);
$subscription['newoptions'] = @unserialize($subscription['newoptions']);
foreach ($subscription['cost'] as $key => $currentsub) {
if ($currentsub['length'] == 1) {
$currentsub['units'] = $lengths["{$currentsub['units']}"];
} else {
$currentsub['units'] = $lengths[$currentsub['units'] . 's'];
}
$subscription['cost'][$key]['subscription_length'] = construct_phrase($vbphrase['length_x_units_y_recurring_z'], $currentsub['length'], $currentsub['units'], $currentsub['recurring'] ? " ({$vbphrase['recurring']})" : '');
}
if (isset($subscribed["{$subscription['subscriptionid']}"])) {
// This subscription has been subscribed by the user
$subscribedsubscriptions[$subscriptionid] = $subscription;
$subscribedsubscriptions[$subscriptionid]['subscribed'] = $subscribed["{$subscription['subscriptionid']}"];
}
if ($subscription['active']) {
if ($isreg and empty($subscription['newoptions']['regshow'])) {
// Display paid subscription during registration is set to false
continue;
}
// Check whether to show the subscription to the user.
if (!empty($subscription['deniedgroups']) and ($allow_secondary_groups and !count(array_diff($membergroupids, $subscription['deniedgroups'])) or !$allow_secondary_groups and in_array($userinfo['usergroupid'], $subscription['deniedgroups']))) {
continue;
}
// List allowed payment apis
$allowedapis = array();
foreach ((array) $subscription['newoptions']['api'] as $api => $options) {
if (!empty($options['show'])) {
$allowedapis[] = $api;
}
}
$subscription['allowedapis'] = json_encode($allowedapis);
$cansubscribesubscriptions[$subscriptionid] = $subscription;
}
}
if (!$cansubscribesubscriptions and !$subscribedsubscriptions) {
return array();
}
return array('subscribed' => $subscribedsubscriptions, 'cansubscribe' => $cansubscribesubscriptions, 'paymentapis' => $this->apicache, 'currencysymbols' => $this->subobj->_CURRENCYSYMBOLS);
}
示例14: add
/**
* Adds a new node.
*
* @param mixed Array of field => value pairs which define the record.
* @param array Array of options for the content being created.
* Understands skipTransaction, skipFloodCheck, floodchecktime, skipDupCheck, skipNotification, nl2br, autoparselinks.
* - nl2br: if TRUE, all \n will be converted to <br /> so that it's not removed by the html parser (e.g. comments).
* - wysiwyg: if true convert html to bbcode. Defaults to true if not given.
*
* @return integer the new nodeid
*/
public function add($data, $options = array())
{
vB_Api::instanceInternal('hv')->verifyToken($data['hvinput'], 'post');
if (vB_Api::instanceInternal('node')->fetchAlbumChannel() == $data['parentid'] and !vB::getUserContext()->hasPermission('albumpermissions', 'picturefollowforummoderation')) {
$data['approved'] = 0;
$data['showapproved'] = 0;
}
return parent::add($data, $options);
}
示例15: fetch_online_status
/**
* Fetches the online states for the user, taking into account the browsing
* user's viewing permissions. Also modifies the user to include [buddymark]
* and [invisiblemark]
*
* @param array Array of userinfo to fetch online status for
* @param boolean True if you want to set $user[onlinestatus] with template results
*
* @return integer 0 = offline, 1 = online, 2 = online but invisible (if permissions allow)
*/
function fetch_online_status(&$user)
{
static $buddylist, $datecut;
$session = vB::getCurrentSession();
if (empty($session)) {
$currentUserId = 0;
} else {
$currentUserId = vB::getCurrentSession()->get('userid');
}
// get variables used by this function
if (!isset($buddylist) and !empty($currentUserId)) {
$buddylist = array();
//If we are asking for the current user's status we can skip the fetch
if ($currentUserId == $user['userid']) {
$currentUser =& $user;
} else {
$currentUser = vB_Api::instanceInternal('user')->fetchCurrentUserInfo();
}
if (isset($currentUser['buddylist']) and $currentUser['buddylist'] = trim($currentUser['buddylist'])) {
$buddylist = preg_split('/\\s+/', $currentUser['buddylist'], -1, PREG_SPLIT_NO_EMPTY);
}
}
if (!isset($datecut)) {
$datecut = vB::getRequest()->getTimeNow() - vB::getDatastore()->getOption('cookietimeout');
}
// is the user on bbuser's buddylist?
if (isset($buddylist) and is_array($buddylist) and in_array($user['userid'], $buddylist)) {
$user['buddymark'] = '+';
} else {
$user['buddymark'] = '';
}
// set the invisible mark to nothing by default
$user['invisiblemark'] = '';
$onlinestatus = 0;
$user['online'] = 'offline';
// now decide if we can see the user or not
if ($user['lastactivity'] > $datecut and $user['lastvisit'] != $user['lastactivity']) {
$bf_misc_useroptions = vB::getDatastore()->getValue('bf_misc_useroptions');
if ($user['options'] & $bf_misc_useroptions['invisible']) {
if (!isset($userContext)) {
$userContext = vB::getUserContext();
}
if ($currentUserId == $user['userid'] or $userContext and $userContext->hasPermission('genericpermissions', 'canseehidden')) {
// user is online and invisible BUT bbuser can see them
$user['invisiblemark'] = '*';
$user['online'] = 'invisible';
$onlinestatus = 2;
}
} else {
// user is online and visible
$onlinestatus = 1;
$user['online'] = 'online';
}
}
return $onlinestatus;
}