本文整理汇总了PHP中vB::getUserContext方法的典型用法代码示例。如果您正苦于以下问题:PHP vB::getUserContext方法的具体用法?PHP vB::getUserContext怎么用?PHP vB::getUserContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB
的用法示例。
在下文中一共展示了vB::getUserContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(&$routeInfo, &$matches, &$queryString = '')
{
if (isset($matches['params']) and !empty($matches['params'])) {
$paramString = strpos($matches['params'], '/') === 0 ? substr($matches['params'], 1) : $matches['params'];
$params = explode('/', $paramString);
if (count($params) >= 2) {
$this->pagenum = $params[1];
$this->folderid = $params[0];
} else {
if (!empty($params)) {
$this->pagenum = $params[1];
}
}
}
if (!empty($matches['pagenum']) and intval($matches['pagenum'])) {
$this->pagenum = $matches['pagenum'];
}
if (!empty($matches['folderid']) and intval($matches['folderid'])) {
$this->folderid = $matches['folderid'];
}
$routeInfo['arguments']['subtemplate'] = $this->subtemplate;
$userid = vB::getCurrentSession()->get('userid');
$pmquota = vB::getUserContext($userid)->getLimit('pmquota');
$vboptions = vB::getDatastore($userid)->getValue('options');
$canUsePmSystem = ($vboptions['enablepms'] and $pmquota);
if (!$canUsePmSystem and !$this->overrideDisable) {
throw new vB_Exception_NodePermission('privatemessage');
}
}
示例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: __call
public function __call($method, $arguments)
{
try {
$logger = vB::getLogger('api.' . $this->controller . '.' . $method);
//check so that we don't var_export large variables when we don't have to
if ($logger->isInfoEnabled()) {
if (!($ip = vB::getRequest()->getAltIp())) {
$ip = vB::getRequest()->getIpAddress();
}
$message = str_repeat('=', 80) . "\ncalled {$method} on {$this->controller} from ip {$ip} \n\$arguments = " . var_export($arguments, true) . "\n" . str_repeat('=', 80) . "\n";
$logger->info($message);
$logger->info("time: " . microtime(true));
}
if ($logger->isTraceEnabled()) {
$message = str_repeat('=', 80) . "\n " . $this->getTrace() . str_repeat('=', 80) . "\n";
$logger->trace($message);
}
$c = $this->api;
// This is a hack to prevent method parameter reference error. See VBV-5546
$hackedarguments = array();
foreach ($arguments as $k => &$arg) {
$hackedarguments[$k] =& $arg;
}
$return = call_user_func_array(array(&$c, $method), $hackedarguments);
//check so that we don't var_export large variables when we don't have to
if ($logger->isDebugEnabled()) {
$message = str_repeat('=', 80) . "\ncalled {$method} on {$this->controller}\n\$return = " . var_export($return, true) . "\n" . str_repeat('=', 80) . "\n";
$logger->debug($message);
}
return $return;
} catch (vB_Exception_Api $e) {
$errors = $e->get_errors();
$config = vB::getConfig();
if (!empty($config['Misc']['debug'])) {
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
}
return array('errors' => $errors);
} catch (vB_Exception_Database $e) {
$config = vB::getConfig();
if (!empty($config['Misc']['debug']) or vB::getUserContext()->hasAdminPermission('cancontrolpanel')) {
$errors = array('Error ' . $e->getMessage());
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
return array('errors' => $errors);
} else {
// This text is purposely hard-coded since we don't have
// access to the database to get a phrase
return array('errors' => array(array('There has been a database error, and the current page cannot be displayed. Site staff have been notified.')));
}
} catch (Exception $e) {
$errors = array(array('unexpected_error', $e->getMessage()));
$config = vB::getConfig();
if (!empty($config['Misc']['debug'])) {
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
}
return array('errors' => $errors);
}
}
示例4: 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'];
}
示例5: checkRoutePermissions
protected function checkRoutePermissions()
{
$currentUser = vB::getUserContext();
if (!$currentUser->hasPermission('genericpermissions', 'canviewmembers') and $this->arguments['userid'] != vB::getCurrentSession()->get('userid')) {
throw new vB_Exception_NodePermission('profile');
}
}
示例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: canDeleteLink
/**
* Checks if user can delete a given link
*
* @param int User Id
*
* @param int Link Id
*
* @return boolean value to indicate whether user can or not delete link
*/
protected function canDeleteLink($userId, $nodeid, $fileDataRecord)
{
/** moderators can delete links */
if (vB::getUserContext()->getChannelPermission("moderatorpermissions", "canmoderateattachments", $nodeid)) {
return true;
}
return false;
}
示例8: 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;
}
示例9: 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);
}
示例10: fetchNotificationsForCurrentUser
/**
* Return current user's notifications from DB.
*
* @param Array $data @see vB_Library_Notification::fetchNotificationsForCurrentUser()
*
* @return Array @see vB_Library_Notification::fetchNotificationsForCurrentUser()
*
* @throws vB_Exception_Api('not_logged_no_permission') If user is not logged in
*/
public function fetchNotificationsForCurrentUser($data = array())
{
$userid = vB::getCurrentSession()->get('userid');
if (!intval($userid)) {
throw new vB_Exception_Api('not_logged_no_permission');
}
$data['showdetail'] = vB::getUserContext()->hasPermission('genericpermissions', 'canseewholiked');
$notifications = vB_Library::instance('notification')->fetchNotificationsForCurrentUser($data);
return $notifications;
}
示例11: __construct
public function __construct(&$routeInfo, &$matches, &$queryString = '')
{
$userid = vB::getCurrentSession()->get('userid');
$pmquota = vB::getUserContext($userid)->getLimit('pmquota');
$vboptions = vB::getDatastore($userid)->getValue('options');
$canUsePmSystem = ($vboptions['enablepms'] and $pmquota);
if (!$canUsePmSystem) {
throw new vB_Exception_NodePermission('privatemessage');
}
parent::__construct($routeInfo, $matches, $queryString);
}
示例12: checkExternalForChannels
/**
* Check if the external data provider type is available and it actually produces a valid output for given channels.
*
* @param Array List of channel ids to check external status from.
* @param String External type.
* Supported: vB_Api_External::TYPE_JS, vB_Api_External::TYPE_XML,
* vB_Api_External::TYPE_RSS, vB_Api_External::TYPE_RSS1, vB_Api_External::TYPE_RSS2
*
* @return Array Associative array with external status information for each given channel.
* Status will be added to each array element as '$type_enabled' key.
*/
public function checkExternalForChannels($channelids, $type)
{
$check = $this->validateExternalType($type);
$enabled = true;
if ($check['valid'] === false) {
$enabled = false;
}
$result = array();
$gcontext = vB::getUserContext(0);
foreach ($channelids as $channel) {
$result[$channel][$type . '_enabled'] = ($enabled and $gcontext->getChannelPermission('forumpermissions', 'canview', $channel)) ? 1 : 0;
}
return $result;
}
示例13: send
/** sends a batch of emails
*
* @param mixed array of recipients, or a semicolon-delimited string
* @param string subject of the message
* @param string content of message
*
* @return mixed either success => true, or array of sent, failed, errors, and message- the last is suitable for display to user.
*/
public function send($to, $subject, $message)
{
//This should only be used by admins
if (!vB::getUserContext()->hasAdminPermission('canadminusers')) {
throw new vB_Exception_Api('no_permission');
}
if (!is_array($to)) {
if (strpos($to, ';')) {
$to = explode(';', $to);
} else {
$to = array($to);
}
}
$errors = '';
$sent = array();
$failed = array();
foreach ($to as $toemail) {
//The next function returns either true, false or an error string.
$result = vB_Mail::vbmail($toemail, $subject, $message, false, '', '', '', true);
if (is_string($result)) {
$errors .= $result;
} else {
if ($result) {
$sent[] = $toemail;
} else {
$failed[] = $toemail;
}
}
}
if (empty($failed) and empty($errors)) {
return array('success' => true);
}
$message = '';
if (!empty($errors)) {
$message = vB_Phrase::fetchSinglePhrase('error_x', $errors) . '. ';
}
if (!empty($sent)) {
$message .= vB_Phrase::fetchSinglePhrase('sent_to_x', implode(',', $sent));
}
if (!empty($failed)) {
$message .= vB_Phrase::fetchSinglePhrase('send_failed_to_x', implode(',', $failed));
}
return array('sent' => $sent, 'failed' => $failed, 'errors' => $errors, 'message' => $message);
}
示例14: isViglinkEnabled
public function isViglinkEnabled($prev, $feature = self::VIGLINK_FEATURE_ALL)
{
$utils = new Viglink_Utils();
$is_enabled = (bool) vB::getDatastore()->getOption('viglink_enabled');
$has_key = (bool) vB_Api::instance('site')->getViglinkKey();
$args = func_get_args();
$enabled = $is_enabled && $has_key;
switch ($feature) {
case self::VIGLINK_FEATURE_ALL:
return $enabled;
case self::VIGLINK_FEATURE_LII:
// disabled for one of this user's groups?
$disabled_group_ids = json_decode($utils->getOption('lii_excluded_usergroups', '[]'));
$user_disabled_group_ids = array_intersect($disabled_group_ids, vB::getUserContext()->fetchUserGroups());
$lii_enabled_for_groups = empty($user_disabled_group_ids);
$lii_enabled = $lii_enabled_for_groups;
return $enabled && $lii_enabled;
}
}
示例15: __construct
public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
{
parent::__construct($routeInfo, $matches, $queryString);
if (isset($this->arguments['channelid'])) {
if (!vB::getUserContext()->getChannelPermission('forumpermissions', 'canview', $this->arguments['channelid'])) {
throw new vB_Exception_NodePermission($this->arguments['channelid']);
}
// check if we need to force a styleid
$channel = vB_Library::instance('Content_Channel')->getBareContent($this->arguments['channelid']);
if (is_array($channel)) {
$channel = array_pop($channel);
}
if (!empty($channel['styleid'])) {
$forumOptions = vB::getDatastore()->getValue('bf_misc_forumoptions');
if ($channel['options']['styleoverride']) {
// the channel must force the style
$this->arguments['forceStyleId'] = $channel['styleid'];
} else {
// the channel suggests to use this style
$this->arguments['routeStyleId'] = $channel['styleid'];
}
}
if (!empty($this->queryParameters)) {
$this->arguments['noindex'] = 1;
}
if (!empty($channel['description'])) {
$this->arguments['nodedescription'] = $channel['description'];
}
// rss info
$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'] = $channel['rss_enabled'];
// styleid for channels are not final at this point, so let's not include them in the key
$this->setPageKey('pageid', 'channelid');
// set user action
$this->setUserAction('viewing_forum_x', $channel['title'], $this->getFullUrl('fullurl'));
// remove link from last crumb
$this->breadcrumbs[count($this->breadcrumbs) - 1]['url'] = '';
}
}