本文整理汇总了PHP中vB::get_registry方法的典型用法代码示例。如果您正苦于以下问题:PHP vB::get_registry方法的具体用法?PHP vB::get_registry怎么用?PHP vB::get_registry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB
的用法示例。
在下文中一共展示了vB::get_registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_logout
function do_logout()
{
$vbulletin = vB::get_registry();
$userinfo = vB_Api::instance('user')->fetchUserInfo();
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('fr_username' => vB_Cleaner::TYPE_STR));
if ($userinfo['userid'] < 1) {
return json_error(ERR_NO_PERMISSION);
}
$tableinfo = $vbulletin->db->query_first("\n\t\tSHOW TABLES LIKE '" . TABLE_PREFIX . "forumrunner_push_users'\n\t\t");
if ($tableinfo) {
$vbulletin->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "forumrunner_push_users\n\t\t\tWHERE fr_username = '" . $vbulletin->db->escape_string($cleaned['fr_username']) . "' AND vb_userid = {$userinfo['userid']}\n\t\t\t");
}
vB_User::processLogout();
//
// Properly set cookies on logout
//
$login = array();
$session = vB::getCurrentSession();
$login['sessionhash'] = $session->get('sessionhash');
$login['password'] = $session->get('password');
$login['cpsession'] = $session->get('cpsession');
$login['userid'] = $session->get('userid');
vB5_Cookie::set('cpsession', $login['cpsession'], 30);
vB5_Cookie::set('sessionhash', $login['sessionhash'], 30);
vB5_Cookie::set('password', $login['password'], 30);
vB5_Cookie::set('userid', $login['userid'], 30);
return array('success' => true, 'requires_authentication' => requires_authentication());
}
示例2: vB_UserChangeLog
/**
* Constructor
*
* @param vBulletin database Instance
*/
function vB_UserChangeLog(&$registry)
{
// the db object need for the execute and for the escape string
if (is_object($registry)) {
$this->registry =& $registry;
} else {
$this->registry =& vB::get_registry();
}
$this->assertor =& vB::getDbAssertor();
}
示例3: do_remove_fr_user
function do_remove_fr_user()
{
$vbulletin = vB::get_registry();
$userinfo = vB_Api::instance('user')->fetchUserInfo();
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('fr_username' => vB_Cleaner::TYPE_STR));
if (!$cleaned['fr_username'] || !$userinfo['userid']) {
return json_error(ERR_NO_PERMISSION);
}
$tableinfo = $vbulletin->db->query_first("\n\t\tSHOW TABLES LIKE '" . TABLE_PREFIX . "forumrunner_push_users'\n\t\t");
if ($tableinfo) {
$vbulletin->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "forumrunner_push_users\n\t\t\tWHERE fr_username = '" . $vbulletin->db->escape_string($cleaned['fr_username']) . "' AND vb_userid = {$userinfo['userid']}\n\t\t\t");
}
return true;
}
示例4: updateDisplayGroup
/**
* Update user's display group
*
* @param $userid User ID
* @param $usergroupid Usergroup ID to be used as display group
* @return void
*/
public function updateDisplayGroup($userid, $usergroupid)
{
$userinfo = vB_Api::instanceInternal('user')->fetchUserinfo($userid);
$membergroups = fetch_membergroupids_array($userinfo);
$permissions = $userinfo['permissions'];
$vbulletin = vB::get_registry();
$bf_ugp_genericpermissions = vB::getDatastore()->get_value('bf_ugp_genericpermissions');
if ($usergroupid == 0) {
throw new vB_Exception_Api('invalidid', array('usergroupid'));
}
if (!in_array($usergroupid, $membergroups)) {
throw new vB_Exception_Api('notmemberofdisplaygroup');
} else {
$display_usergroup = $vbulletin->usergroupcache["{$usergroupid}"];
//I'm not sure why we require canoverride to set the display group... this is *not* required
//by the the admincp user interface which uses a different method of saving.
if ($usergroupid == $userinfo['usergroupid'] or $display_usergroup['canoverride']) {
$userinfo['displaygroupid'] = $usergroupid;
// init user data manager
$userdata = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_ARRAY_UNPROCESSED);
$userdata->set_existing($userinfo);
$userdata->set('displaygroupid', $usergroupid);
if (!$userinfo['customtitle']) {
$userdata->set_usertitle($userinfo['customtitle'] ? $userinfo['usertitle'] : '', false, $display_usergroup, $permissions['genericpermissions'] & $bf_ugp_genericpermissions['canusecustomtitle'] ? true : false, $permissions['genericpermissions'] & $bf_ugp_genericpermissions['cancontrolpanel'] ? true : false);
}
$userdata->save();
} else {
throw new vB_Exception_Api('usergroup_invaliddisplaygroup');
}
}
}
示例5: getHVToken
function getHVToken()
{
require_once DIR . '/includes/class_humanverify.php';
$verify =& vB_HumanVerify::fetch_library(vB::get_registry());
$token = $verify->generate_token();
$ret = array('input' => $token['answer'], 'hash' => $token['hash']);
return $ret;
}
示例6: unset
}
$ids .= (!empty($ids) ? ',' : '') . $infractioninfo['orusergroupid'];
$groupids["{$usergroupid}"]["{$points}"]['ids'] = $ids;
$groupids["{$usergroupid}"]["{$points}"]['id'] = $infractiongroupid;
}
}
unset($infractiongroupid, $infractiongroupids, $ids);
}
foreach ($primaryupdates as $joinusergroupid => $ids) {
vB::getDbAssertor()->assertQuery('updateUserInfractions', array('joinusergroupid' => $joinusergroupid, 'pointlevel' => empty($groupids[$joinusergroupid]) ? array() : $groupids[$joinusergroupid], 'ids' => $ids));
$log = array($titles["{$joinusergroupid}"], '*', $primarynames["{$joinusergroupid}"]);
// the "1" indicates to use the second line of the phrase specified for this task
log_cron_action(serialize($log), $nextitem, 1);
}
unset($groupids);
$vbulletin =& vB::get_registry();
foreach ($userupdates as $userid => $info) {
$userdm = new vB_Datamanager_User($vbulletin, vB_DataManager_Constants::ERRTYPE_SILENT);
$user = array('userid' => $userid);
$userdm->set_existing($user);
if ($info['title']) {
$userdm->set('usertitle', $info['title']);
}
if ($info['rank']) {
$userdm->setr('rank', $info['rank']);
}
$userdm->save();
unset($userdm);
}
foreach ($secondaryupdates as $joinusergroupid => $ids) {
if ($ids) {
示例7: exec_digest
function exec_digest($type = 2)
{
// type = 2 : daily
// type = 3 : weekly
$lastdate = mktime(0, 0);
// midnight today
if ($type == 2) {
// daily
// yesterday midnight
$lastdate -= 24 * 60 * 60;
} else {
// weekly
// last week midnight
$lastdate -= 7 * 24 * 60 * 60;
}
if (trim(vB::getDatastore()->getOption('globalignore')) != '') {
$coventry = preg_split('#\\s+#s', vB::getDatastore()->getOption('globalignore'), -1, PREG_SPLIT_NO_EMPTY);
} else {
$coventry = array();
}
require_once DIR . '/includes/class_bbcode_alt.php';
$vbulletin =& vB::get_registry();
$plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list());
vB_Mail::vbmailStart();
$bf_misc_useroptions = vB::get_datastore()->get_value('bf_misc_useroptions');
$bf_ugp_genericoptions = vB::get_datastore()->get_value('bf_ugp_genericoptions');
$bf_ugp_forumpermissions = vB::get_datastore()->get_value('bf_ugp_forumpermissions');
// we want to fetch all language records at once and using cache if possible
$defaultLanguage = false;
$languageIds = array();
// get new threads (Topic Subscription)
$threads = vB::getDbAssertor()->getRows('getNewThreads', array('dstonoff' => $bf_misc_useroptions['dstonoff'], 'hasaccessmask' => $bf_misc_useroptions['hasaccessmask'], 'isnotbannedgroup' => $bf_ugp_genericoptions['isnotbannedgroup'], 'lastdate' => intval($lastdate)));
// grab all forums / subforums for given subscription (Channel Subscription)
$forums = vB::getDbAssertor()->assertQuery('getNewForums', array('dstonoff' => $bf_misc_useroptions['dstonoff'], 'hasaccessmask' => $bf_misc_useroptions['hasaccessmask'], 'type' => intval($type), 'lastdate' => intval($lastdate), 'channelcontenttype' => vB_Api::instanceInternal('contenttype')->fetchContentTypeIdFromClass('Channel'), 'isnotbannedgroup' => $bf_ugp_genericoptions['isnotbannedgroup']));
// Let's see which languageids we wanna fetch
foreach ($threads as $thread) {
if ($thread['languageid'] == 0) {
if (!$defaultLanguage) {
$defaultLanguage = intval(vB::getDatastore()->getOption('languageid'));
$languageIds[] = $defaultLanguage;
}
} else {
$languageIds[] = $thread['languageid'];
}
}
foreach ($forums as $forum) {
if ($forum['languageid'] == 0) {
if (!$defaultLanguage) {
$defaultLanguage = intval(vB::getDatastore()->getOption('languageid'));
$languageIds[] = $defaultLanguage;
}
} else {
$languageIds[] = $forum['languageid'];
}
}
// fetch languages
$languages = vB_Library::instance('language')->fetchLanguages($languageIds);
// process threads
foreach ($threads as $thread) {
$postbits = '';
// Make sure user have correct email notification settings.
if ($thread['emailnotification'] != $type) {
continue;
}
if ($thread['lastauthorid'] != $thread['userid'] and in_array($thread['lastauthorid'], $coventry)) {
continue;
}
$usercontext = vB::getUserContext($thread['userid']);
if (!$usercontext->getChannelPermission('forumpermissions', 'canview', $thread['nodeid']) or !$usercontext->getChannelPermission('forumpermissions', 'canviewthreads', $thread['nodeid']) or $thread['lastauthorid'] != $thread['userid'] and !$usercontext->getChannelPermission('forumpermissions', 'canviewothers', $thread['nodeid'])) {
continue;
}
$langInfo =& $languages[$thread['languageid']];
$userinfo = array('lang_locale' => $langInfo['locale'], 'dstonoff' => $thread['dstonoff'], 'timezoneoffset' => $thread['timezoneoffset']);
$thread['lastreplydate'] = vbdate($langInfo['dateoverride'] ? $langInfo['dateoverride'] : vB::getDatastore()->getOption('dateformat'), $thread['lastcontent'], false, true, true, false, $userinfo);
$thread['lastreplytime'] = vbdate($langInfo['timeoverride'] ? $langInfo['timeoverride'] : vB::getDatastore()->getOption('timeformat'), $thread['lastcontent'], false, true, true, false, $userinfo);
$thread['htmltitle'] = unhtmlspecialchars($thread['htmltitle']);
$thread['username'] = unhtmlspecialchars($thread['username']);
$thread['postusername'] = unhtmlspecialchars($thread['authorname']);
$thread['lastposter'] = unhtmlspecialchars($thread['lastcontentauthor']);
$thread['newposts'] = 0;
//not currently used and probably needs rethinking, but don't want to remove until this code gets rewritten
//$thread['auth'] = md5($thread['userid'] . $thread['subscribediscussionid'] . $thread['secret'] . vB_Request_Web::$COOKIE_SALT);
if ($thread['prefixid']) {
// need prefix in correct language
$phraseAux = vB_Api::instanceInternal('phrase')->fetch(array("prefix_{$thread['prefixid']}_title_plain"));
$thread['prefix_plain'] = $phraseAux["prefix_{$thread['prefixid']}_title_plain"] . ' ';
} else {
$thread['prefix_plain'] = '';
}
// Note: closure.depth = 1 on the where clause means getNewPosts only grabs replies, not comments.
// get posts
$posts = vB::getDbAssertor()->getRows('getNewPosts', array('threadid' => intval($thread['nodeid']), 'lastdate' => intval($lastdate)));
// compile
$haveothers = false;
foreach ($posts as $post) {
if ($post['userid'] != $thread['userid'] and in_array($post['userid'], $coventry)) {
continue;
}
if ($post['userid'] != $thread['userid']) {
$haveothers = true;
//.........这里部分代码省略.........
示例8: getDataForParse
/**
* Gets the data the presentation layer needs to have to parse the rawtext.
*
* @param mixed nodeId or array of nodeIds
*
* @return mixed array includes bbcodeoptions, attachments, and rawtext
*/
public function getDataForParse($nodeIds)
{
if (is_int($nodeIds)) {
$nodeIds = array($nodeIds);
} else {
if (!is_array($nodeIds)) {
throw new vB_Exception_Api('invalid_data');
}
}
$results = array();
$bfMiscForumoptions = vB::getDatastore()->getValue('bf_misc_forumoptions');
$pmType = vB_Types::instance()->getContentTypeID('vBForum_PrivateMessage');
$galleryTypeid = vB_Types::instance()->getContentTypeId('vBForum_Gallery');
$photoTypeid = vB_Types::instance()->getContentTypeId('vBForum_Photo');
$userContext = vB::getUserContext();
$channelTypes = vB::getDatastore()->getValue('vBChannelTypes');
if (!empty($nodeIds)) {
$nodes = $this->assertor->assertQuery('vBForum:getDataForParse', array('nodeid' => $nodeIds));
foreach ($nodes as $node) {
try {
if ($this->validate($node, self::ACTION_VIEW, $node['nodeid'], array($node))) {
$attachments = $this->nodeApi->getNodeAttachments($node['nodeid']);
// We don't need to show attachments for gallery. See VBV-6389.
// Or rather, we need to unset attachments that are part of a gallery, but want to show other attachments. See VBV-11058
if ($galleryTypeid == $node['contenttypeid']) {
foreach ($attachments as $key => &$attachment) {
// attachments have contenttype vBForum_Attach, while photos of a gallery have contenttype vBForum_Photo
if ($photoTypeid == $attachment['contenttypeid']) {
unset($attachments[$key]);
}
}
}
if ($node['contenttypeid'] == $pmType) {
$bbCodeOptions = vB_Api::instance('content_privatemessage')->getBbcodeOptions();
} else {
if ($userContext->getChannelPermission('forumpermissions', 'canviewthreads', $node['nodeid'], false, $node['parentid'])) {
$bbCodeOptions = array();
foreach ($bfMiscForumoptions as $optionName => $optionVal) {
$bbCodeOptions[$optionName] = (bool) ($node['options'] & $optionVal);
}
} else {
$bbCodeOptions = array();
}
}
$results[$node['nodeid']] = array('bbcodeoptions' => $bbCodeOptions, 'rawtext' => $node['rawtext'], 'previewtext' => $node['previewtext'], 'attachments' => $attachments, 'title' => $node['title'], 'channelid' => $node['channelid'], 'htmlstate' => $node['htmlstate'], 'disable_bbcode' => $node['nodeoptions'] & vB_Api_Node::OPTION_NODE_DISABLE_BBCODE);
} else {
if ($node['public_preview'] > 0) {
$results[$node['nodeid']] = array('bbcodeoptions' => array(), 'rawtext' => '', 'title' => $node['title'], 'channelid' => $node['channelid'], 'htmlstate' => 'off', 'preview_only' => 1, 'disable_bbcode' => $node['nodeoptions'] & vB_Api_Node::OPTION_NODE_DISABLE_BBCODE);
require_once DIR . '/includes/class_bbcode.php';
$tags = fetch_tag_list();
$registry = vB::get_registry();
$bbcode_parser = new vB_BbCodeParser($registry, $tags);
$previewBbcodeOptions = array('allowsmilies' => 1, 'allowbbcode', 'allowimagecode' => 1);
if ($node['htmlstate'] != 'off') {
$previewBbcodeOptions['allowhtml'] = 1;
}
if ($node['nodeid'] == $node['starter']) {
$channel = vB_Library::instance('node')->getNodeFullContent($node['parentid']);
} else {
$starter = $this->nodeApi->getNode($node['starter']);
$channel = vB_Library::instance('node')->getNodeFullContent($starter['parentid']);
}
$channel = array_pop($channel);
if ($channel['channeltype'] == 'article') {
$previewBbcodeOptions['allowPRBREAK'] = 1;
}
if (vB::getUserContext()->getChannelPermission('forumpermissions2', 'cangetimgattachment', $node['nodeid'])) {
$previewBbcodeOptions['allowimages'] = 1;
}
$results[$node['nodeid']]['previewtext'] = $bbcode_parser->getPreview($node['rawtext'], 0, FALSE, $node['htmlstate'] == 'on_nl2br', null, $previewBbcodeOptions);
} else {
$results[$node['nodeid']] = array('bbcodeoptions' => array(), 'rawtext' => '', 'previewtext' => '', 'title' => '', 'attachments' => array(), 'channelid' => $node['channelid'], 'htmlstate' => 'off', 'disable_bbcode' => $node['nodeoptions'] & vB_Api_Node::OPTION_NODE_DISABLE_BBCODE);
// not much point since there is no rawtext, but ensure that it's set.
}
}
//channeltype
if (isset($channelTypes[$node['channelid']])) {
$results[$node['nodeid']]['channeltype'] = $channelTypes[$node['channelid']];
if ($channelTypes[$node['channelid']] == 'article') {
$results[$node['nodeid']]['previewLength'] = vB::getDatastore()->getOption('def_cms_previewlength');
// VBV-12048 For articles, if preview break is present, use the length of the preview text instead of
// the global cms preview length
$prbreak = stripos($results[$node['nodeid']]['rawtext'], '[PRBREAK][/PRBREAK]');
if ($prbreak !== FALSE) {
$results[$node['nodeid']]['previewLength'] = $prbreak;
}
} else {
$results[$node['nodeid']]['previewLength'] = vB::getDatastore()->getOption('threadpreview');
}
} else {
$results[$node['nodeid']]['channeltype'] = '';
}
} catch (exception $e) {
//.........这里部分代码省略.........
示例9: doParseSignature
/**
* Used by getSignatureInfo and parseSignatures to parse a signature
*
* @param int User ID
* @param string|false (Optional) Signature text or false if unknown
* @param bool (Optional) Flag to control skipping the dupe check or not.
*
* @return array Array containing the parsed signature:
* <pre>
* array(
* signature => parsed signature
* allowed => array of bbcode tags the user is allowed to use in their signature
* disabled => array of bbcode tags the user is NOT allowed to use in their signature
* )
* </pre>
*/
protected function doParseSignature($userid, $signature = false, $skipdupcheck = false)
{
if (empty($signature)) {
$sigInfo = vB_Api::instanceInternal('user')->fetchSignature($userid);
if (empty($sigInfo) or empty($sigInfo['raw'])) {
$sigInfo['raw'] = '';
}
$signature = $sigInfo['raw'];
}
require_once DIR . '/includes/class_sigparser.php';
$sig_parser = new vB_SignatureParser(vB::get_registry(), $this->fetchTagList(), $userid);
$sig_parser->setSkipdupcheck($skipdupcheck);
// Parse the signature
$parsed = $sig_parser->parse($signature);
$perms = $sig_parser->getPerms();
//only cache the parsed signature if it came from the DB
if (isset($sigInfo)) {
$cacheKey = "vbSig_{$userid}";
$cachePermKey = "vbSigPerm_{$userid}";
$cache = vB_Cache::instance(vB_Cache::CACHE_STD);
$cache->write($cacheKey, $parsed, 1440, "userChg_{$userid}");
$cache->write($cachePermKey, $perms, 1440, "userChg_{$userid}");
}
return array('signature' => $parsed, 'allowed' => $perms['can'], 'disabled' => $perms['cant']);
}
示例10: switch
// insert the forumid of this item into an array for the update_forum_counters() function later
$update_forumids["{$feed['forumid']}"] = true;
$bbcodeApi = vB_Api::instanceInternal('bbcode');
switch ($feed['itemtype']) {
// insert item as announcement
case 'announcement':
// init announcement datamanager
if ($convertHtmlToBbcode) {
$pagetext = nl2br($feed['bodytemplate']);
$pagetext = $feed['xml']->parse_template($pagetext, $item);
$pagetext = vB_Api::instanceInternal('bbcode')->parseWysiwygHtmlToBbcode($pagetext, array('autoparselinks' => 1));
} else {
$pagetext = $feed['xml']->parse_template($feed['bodytemplate'], $item);
$pagetext = vB_Api::instanceInternal('bbcode')->convertUrlToBbcode($pagetext);
}
$itemdata =& datamanager_init('Announcement', vB::get_registry(), $error_type);
$itemdata->set_info('user', $feed);
$itemdata->set('userid', $feed['userid']);
$itemdata->set('nodeid', $feed['nodeid']);
$itemdata->set('title', strip_bbcode(convert_wysiwyg_html_to_bbcode($feed['xml']->parse_template($feed['titletemplate'], $item))));
$itemdata->set('pagetext', $pagetext);
$itemdata->set('startdate', vB::getRequest()->getTimeNow());
$itemdata->set('enddate', vB::getRequest()->getTimeNow() + 86400 * ($feed['endannouncement'] > 0 ? $feed['endannouncement'] : 7) - 1);
$itemdata->set_bitfield('announcementoptions', 'allowsmilies', $feed['rssoptions'] & $bf_misc_feedoptions['allowsmilies'] ? 1 : 0);
$itemdata->set_bitfield('announcementoptions', 'signature', 0);
$itemdata->set_bitfield('announcementoptions', 'allowhtml', $feed['rssoptions'] & $bf_misc_feedoptions['allowhtml'] ? 1 : 0);
$itemdata->set_bitfield('announcementoptions', 'allowbbcode', true);
$itemdata->set_bitfield('announcementoptions', 'parseurl', true);
if ($itemid = $itemdata->save()) {
$itemtitle = $itemdata->fetch_field('title');
$itemlink = vB_Api::instanceInternal('route')->getUrl('admincp', array('file' => 'announcement'), array('do' => 'edit', 'a' => $itemid));
示例11: update_registry
protected function update_registry($title, $data)
{
// todo: remove this when all references to vbulletin settings are replaced
$registry =& vB::get_registry();
if (!$registry) {
return;
}
if ($title == self::BITFIELDS_TITLE) {
foreach (array_keys($data) as $group) {
// todo: remove this when all references to vbulletin settings are replaced
$registry->{self::BITFIELDS_PREFIX . $group} =& $data["{$group}"];
$group_prefix = self::BITFIELDS_PREFIX . $group . '_';
$group_info =& $data["{$group}"];
foreach (array_keys($group_info) as $subgroup) {
// todo: remove this when all references to vbulletin settings are replaced
$registry->{$group_prefix . $subgroup} =& $group_info["{$subgroup}"];
}
}
} else {
if (!empty($title) and !empty($data)) {
// todo: remove this when all references to vbulletin settings are replaced
$registry->{$title} = (isset($registry->{$title}) and is_array($registry->{$title}) and is_array($data)) ? $data + $registry->{$title} : $data;
}
}
}
示例12: fr_parse_pm_bbcode
function fr_parse_pm_bbcode($bbcode, $smilies = true)
{
require_once DIR . '/includes/class_core.php';
require_once DIR . '/includes/class_bbcode.php';
$bbcode_parser = new vB_BbCodeParser(vB::get_registry(), fetch_tag_list());
return $bbcode_parser->parse($bbcode, 'privatemessage', $smilies);
}
示例13: fr_get_hvtoken
function fr_get_hvtoken()
{
// XXX: This is a hack, we basically turn off hv with this
require_once DIR . '/includes/class_humanverify.php';
$verify =& vB_HumanVerify::fetch_library(vB::get_registry());
$token = $verify->generate_token();
$ret = array('input' => $token['answer'], 'hash' => $token['hash']);
return $ret;
}
示例14: changeHistory
/**
* Return user change history
*
* @param integer $userid
* @return array |bool User change history array. False means no change history.
*/
public function changeHistory($userid)
{
$this->checkHasAdminPermission('canadminusers');
require_once DIR . '/includes/class_userchangelog.php';
require_once DIR . '/includes/functions_misc.php';
// initalize the $user storage
$users = false;
// create the vb_UserChangeLog instance and set the execute flag (we want to do the query, not just to build)
$userchangelog = new vb_UserChangeLog(vB::get_registry());
$userchangelog->set_execute(true);
// get the user change list
$userchange_list = $userchangelog->sql_select_by_userid($userid);
if (!$userchange_list) {
return false;
} else {
$usergroupcache = vB::getDatastore()->getValue('usergroupcache');
// fetch the rows
foreach ($userchange_list as $userchange) {
// get/find some names, depend on the field and the content
switch ($userchange['fieldname']) {
// get usergroup names from the cache
case 'usergroupid':
case 'membergroupids':
foreach (array('oldvalue', 'newvalue') as $fname) {
$str = '';
if ($ids = explode(',', $userchange[$fname])) {
foreach ($ids as $id) {
if ($usergroupcache["{$id}"]['title']) {
$str .= $usergroupcache["{$id}"]['title'] . '<br/>';
}
}
}
$userchange["{$fname}"] = $str ? $str : '-';
}
break;
}
$userchanges[] = $userchange;
}
return $userchanges;
}
}
示例15: applyAutomaticBan
/**
* Applies the automatic ban to the user
*
* @param array User Info for the user to ban
* @param array Data for the automatic ban to apply (returned from getAutomaticBanToApply)
* @param array Data for the infraction that's being given
*/
protected function applyAutomaticBan(array $userInfo, array $banToApply, array $data)
{
$currentBan = $this->assertor->getRow('userban', array('userid' => $userInfo['userid']));
$user = vB::getCurrentSession()->fetch_userinfo();
// Drop the ban hammer
if ($currentBan) {
if (($banToApply['liftdate'] == 0 or $currentBan['liftdate'] < $banToApply['liftdate']) and $currentBan['liftdate'] != 0) {
// there is already a record - just update this record
$this->assertor->update('userban', array('bandate' => vB::getRequest()->getTimeNow(), 'liftdate' => $banToApply['liftdate'], 'adminid' => $user['userid'], 'reason' => $data['banreason']), array('userid' => $userInfo['userid']));
}
} else {
// insert a record into the userban table
/*insert query*/
$this->assertor->insert('userban', array('userid' => $userInfo['userid'], 'usergroupid' => $userInfo['usergroupid'], 'displaygroupid' => $userInfo['displaygroupid'], 'customtitle' => $userInfo['customtitle'], 'usertitle' => $userInfo['usertitle'], 'bandate' => vB::getRequest()->getTimeNow(), 'liftdate' => $banToApply['liftdate'], 'adminid' => $user['userid'], 'reason' => $data['banreason']));
}
//$existingUserInfo = $this->assertor->getRow('user', array('userid' => $userInfo['userid']));
$existingUserInfo = vB_User::fetchUserinfo($userInfo['userid']);
// update the user record
$userdata = new vB_Datamanager_User(vB::get_registry(), vB_DataManager_Constants::ERRTYPE_SILENT);
$userdata->set_existing($existingUserInfo);
$userdata->set('usergroupid', $banToApply['banusergroupid']);
$userdata->set('displaygroupid', 0);
// update the user's title if they've specified a special user title for the banned group
$bannedUserGroups = vB_Api::instanceInternal('usergroup')->fetchBannedUsergroups();
if ($bannedUserGroups[$banToApply['banusergroupid']]['usertitle'] != '') {
$userdata->set('usertitle', $bannedUserGroups[$banToApply['banusergroupid']]['usertitle']);
$userdata->set('customtitle', 0);
}
$userdata->save();
unset($userdata);
}