本文整理匯總了PHP中IPSMember::unpackMemberCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSMember::unpackMemberCache方法的具體用法?PHP IPSMember::unpackMemberCache怎麽用?PHP IPSMember::unpackMemberCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSMember
的用法示例。
在下文中一共展示了IPSMember::unpackMemberCache方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _viewModern
//.........這裏部分代碼省略.........
//-----------------------------------------
// Visitors
//-----------------------------------------
if ($member['pp_setting_count_visitors']) {
$_pp_last_visitors = unserialize($member['pp_last_visitors']);
$_visitor_info = array();
$_count = 1;
if (is_array($_pp_last_visitors)) {
krsort($_pp_last_visitors);
$_members = IPSMember::load(array_values($_pp_last_visitors), 'extendedProfile');
foreach ($_members as $_id => $_member) {
$_visitor_info[$_id] = IPSMember::buildDisplayData($_member, 0);
}
foreach ($_pp_last_visitors as $_time => $_id) {
if ($_count > $member['pp_setting_count_visitors']) {
break;
}
$_count++;
if (!$_visitor_info[$_id]['members_display_name_short']) {
$_visitor_info[$_id] = IPSMember::setUpGuest();
}
$_visitor_info[$_id]['_visited_date'] = ipsRegistry::getClass('class_localization')->getDate($_time, 'TINY');
$_visitor_info[$_id]['members_display_name_short'] = $_visitor_info[$_id]['members_display_name_short'] ? $_visitor_info[$_id]['members_display_name_short'] : $this->lang->words['global_guestname'];
$visitors[] = $_visitor_info[$_id];
}
}
}
//-----------------------------------------
// Friends
//-----------------------------------------
# Get random number from member's friend cache... grab 10 random. array_rand( array, no.)
# also fall back on last 10 if no cache
if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) {
$member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']);
if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) {
foreach ($member['_cache']['friends'] as $id => $approved) {
$id = intval($id);
if ($approved and $id) {
$_member_ids[] = $id;
}
}
$member['_total_approved_friends'] = count($_member_ids);
if (is_array($_member_ids) and count($_member_ids)) {
$_max = count($_member_ids) > 50 ? 50 : count($_member_ids);
$_rand = array_rand($_member_ids, $_max);
$_final = array();
# If viewing member is in list, let's show em
if (in_array($this->memberData['member_id'], $_member_ids)) {
$_final[] = $this->memberData['member_id'];
$new_mids = array();
foreach ($_member_ids as $mid) {
if ($mid == $this->memberData['member_id']) {
continue;
}
$new_mids[] = $mid;
}
$_member_ids = $new_mids;
unset($new_mids);
if (is_array($_rand)) {
if (count($_rand) >= 50) {
array_pop($_rand);
}
}
}
if (is_array($_rand) and count($_rand)) {
foreach ($_rand as $_id) {
示例2: setUpMember
/**
* Set up a member
*
* @return @e void
*/
protected static function setUpMember()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$cache = ipsRegistry::cache()->getCache('group_cache');
//-----------------------------------------
// Unpack cache
//-----------------------------------------
if (isset(self::$data_store['members_cache'])) {
self::$data_store['_cache'] = IPSMember::unpackMemberCache(self::$data_store['members_cache']);
} else {
self::$data_store['_cache'] = array();
}
if (!isset(self::$data_store['_cache']['friends']) or !is_array(self::$data_store['_cache']['friends'])) {
self::$data_store['_cache']['friends'] = array();
}
//-----------------------------------------
// Unpack ignored users
//-----------------------------------------
if (isset(self::$data_store['ignored_users'])) {
self::$data_store['_ignoredUsers'] = @unserialize(self::$data_store['ignored_users']);
} else {
self::$data_store['_ignoredUsers'] = array();
}
//-----------------------------------------
// Set up main 'display' group
//-----------------------------------------
if (is_array($cache[self::$data_store['member_group_id']])) {
self::$data_store = array_merge(self::$data_store, $cache[self::$data_store['member_group_id']]);
}
//-----------------------------------------
// Work out permissions
//-----------------------------------------
self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
/* Ensure we don't have a ,, string */
self::$data_store['org_perm_id'] = IPSText::cleanPermString(self::$data_store['org_perm_id']);
self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
//-----------------------------------------
// Synchronise the last visit and activity times if
// we have some in the member profile
//-----------------------------------------
if (!self::$data_store['last_activity']) {
self::$data_store['last_activity'] = IPS_UNIX_TIME_NOW;
}
//-----------------------------------------
// If there hasn't been a cookie update in 2 hours,
// we assume that they've gone and come back
//-----------------------------------------
if (!self::$data_store['last_visit']) {
//-----------------------------------------
// No last visit set, do so now!
//-----------------------------------------
ipsRegistry::DB()->update('members', array('last_visit' => self::$data_store['last_activity'], 'last_activity' => IPS_UNIX_TIME_NOW), "member_id=" . self::$data_store['member_id'], true);
self::$data_store['last_visit'] = self::$data_store['last_activity'];
} else {
if (IPS_UNIX_TIME_NOW - self::$data_store['last_activity'] > 300) {
//-----------------------------------------
// If the last click was longer than 5 mins ago and this is a member
// Update their profile.
//-----------------------------------------
$be_anon = IPSMember::isLoggedInAnon(self::$data_store);
ipsRegistry::DB()->update('members', array('login_anonymous' => "{$be_anon}&1", 'last_activity' => IPS_UNIX_TIME_NOW), 'member_id=' . self::$data_store['member_id'], true);
}
}
//-----------------------------------------
// Group promotion based on time since joining
//-----------------------------------------
/* Are we checking for auto promotion? */
if (self::$data_store['g_promotion'] != '-1&-1') {
/* Are we checking for post based auto incrementation? 0 is post based, 1 is date based, so... */
if (self::$data_store['gbw_promote_unit_type']) {
list($gid, $gdate) = explode('&', self::$data_store['g_promotion']);
if ($gid > 0 and $gdate > 0) {
if (self::$data_store['joined'] <= time() - $gdate * 86400) {
IPSMember::save(self::$data_store['member_id'], array('core' => array('member_group_id' => $gid)));
/* Now reset the members group stuff */
self::$data_store = array_merge(self::$data_store, $cache[$gid]);
self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
}
}
}
}
}
示例3: _getRandomFriends
/**
* Get 12 random friends
*
* @param array $member Member data
* @return @e array
*/
protected function _getRandomFriends($member)
{
# Get random number from member's friend cache... grab 10 random. array_rand( array, no.)
# also fall back on last 10 if no cache
$_member_ids = array();
$friends = array();
if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) {
$member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']);
if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) {
foreach ($member['_cache']['friends'] as $id => $approved) {
$id = intval($id);
if ($approved and $id) {
$_member_ids[] = $id;
}
}
$member['_total_approved_friends'] = count($_member_ids);
if (is_array($_member_ids) and $member['_total_approved_friends']) {
$_max = $member['_total_approved_friends'] > 12 ? 12 : $member['_total_approved_friends'];
$_rand = array_rand($_member_ids, $_max);
$_final = array();
# If viewing member is in list, let's show em
if (in_array($this->memberData['member_id'], $_member_ids)) {
$_final[] = $this->memberData['member_id'];
$new_mids = array();
foreach ($_member_ids as $mid) {
if ($mid == $this->memberData['member_id']) {
continue;
}
$new_mids[] = $mid;
}
$_member_ids = $new_mids;
unset($new_mids);
if (is_array($_rand)) {
if (count($_rand) >= 12) {
array_pop($_rand);
}
}
}
if (is_array($_rand) and count($_rand)) {
foreach ($_rand as $_id) {
$_final[] = $_member_ids[$_id];
}
}
if (count($_final)) {
$sql_extra = ' AND friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')';
}
}
}
/* Fetch friends */
$_memberIds = array();
$_members = array();
$_friends = array();
$this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id')), 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1' . ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')' . $sql_extra, 'limit' => array(0, 12), 'order' => 'friends_approved DESC'));
$this->DB->execute();
while ($row = $this->DB->fetch()) {
$_memberIds[] = $row['friends_friend_id'];
$_friends[] = $row;
}
/* Got members? */
$_members = IPSMember::load($_memberIds, 'core,extendedProfile');
foreach ($_friends as $row) {
if (!isset($_members[$row['friends_friend_id']])) {
continue;
}
$row = array_merge($row, $_members[$row['friends_friend_id']]);
$row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT');
$row = IPSMember::buildProfilePhoto($row);
$friends[] = $row;
}
}
return $friends;
}
示例4: doExecute
/**
* Main Execution Function
*
* @access public
* @param object Registry reference
* @return void [Outputs to screen/redirects]
*/
public function doExecute(ipsRegistry $registry)
{
//-----------------------------------------
// INIT
//-----------------------------------------
$post_data = array();
$poll_data = '';
$function = '';
//-----------------------------------------
// INIT module
//-----------------------------------------
$this->loadTopicAndForum();
//-----------------------------------------
// Topic rating: Rating
//-----------------------------------------
$this->can_rate = $this->memberData['member_id'] ? intval($this->memberData['g_topic_rate_setting']) : 0;
//-----------------------------------------
// Reputation Cache
//-----------------------------------------
if ($this->settings['reputation_enabled']) {
/* Load the class */
require_once IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php';
$this->registry->setClass('repCache', new classReputationCache());
/* Update the filter? */
if (isset($this->request['rep_filter']) && $this->request['rep_filter'] == 'update') {
$_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']);
if ($this->request['rep_filter_set'] == '*') {
$_mem_cache['rep_filter'] = '*';
} else {
$_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']);
}
IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache);
$this->memberData['_members_cache'] = $_mem_cache;
} else {
$this->memberData['_members_cache'] = IPSMember::unpackMemberCache($this->memberData['members_cache']);
}
}
//-----------------------------------------
// Process the topic
//-----------------------------------------
$this->topicSetUp();
//-----------------------------------------
// Which view are we using?
// If mode='show' we're viewing poll results, don't change view mode
//-----------------------------------------
$this->topic_view_mode = $this->_generateTopicViewMode();
//-----------------------------------------
// VIEWS
//-----------------------------------------
$this->_doViewCheck();
//-----------------------------------------
// UPDATE TOPIC?
//-----------------------------------------
$this->_doUpdateTopicCheck();
//-----------------------------------------
// Check PPD
//-----------------------------------------
$this->_ppd_ok = $this->registry->getClass('class_forums')->checkGroupPostPerDay($this->memberData, TRUE);
//-----------------------------------------
// Post ID stuff
//-----------------------------------------
$find_pid = $this->request['pid'] == "" ? isset($this->request['p']) ? $this->request['p'] : 0 : (isset($this->request['pid']) ? $this->request['pid'] : 0);
$threaded_pid = $find_pid ? '&pid=' . $find_pid : '';
$linear_pid = $find_pid ? '&view=findpost&p=' . $find_pid : '';
//-----------------------------------------
// Remove potential [attachmentid= tag in title
//-----------------------------------------
$this->topic['title'] = IPSText::stripAttachTag($this->topic['title']);
//-----------------------------------------
// Get posts
//-----------------------------------------
$_NOW = IPSDebug::getMemoryDebugFlag();
if ($this->topic_view_mode == 'threaded') {
require_once IPSLib::getAppDir('forums') . '/sources/classes/threaded.php';
$threaded = new threadedModeLibrary($this->registry, $this);
$post_data = $threaded->_getTopicDataThreaded();
} else {
$post_data = $this->_getTopicDataLinear();
}
unset($this->cached_members);
IPSDebug::setMemoryDebugFlag("TOPICS: Parsed Posts - Completed", $_NOW);
//-----------------------------------------
// Generate template
//-----------------------------------------
$this->topic['id'] = $this->topic['forum_id'];
/* Posting Allowed? */
$this->forum['_user_can_post'] = 1;
//( $this->_ppd_ok === TRUE ) ? 1 : 0;
if (!$this->registry->permissions->check('start', $this->forum)) {
$this->forum['_user_can_post'] = 0;
}
if (!$this->forum['sub_can_post']) {
$this->forum['_user_can_post'] = 0;
//.........這裏部分代碼省略.........
示例5: _unpackRepCache
/**
* Unpack the repuation cache, yo.
*
* @return @e void
*/
protected function _unpackRepCache()
{
if ($this->settings['reputation_enabled']) {
/* Load the class */
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
$this->registry->setClass('repCache', new $classToLoad());
/* Update the filter? */
if (isset($this->request['rep_filter']) && $this->request['rep_filter'] == 'update') {
$_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']);
if ($this->request['rep_filter_set'] == '*') {
$_mem_cache['rep_filter'] = '*';
} else {
$_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']);
}
IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache);
$this->memberData['_members_cache'] = $_mem_cache;
} else {
$this->memberData['_members_cache'] = IPSMember::unpackMemberCache($this->memberData['members_cache']);
}
$this->memberData['_members_cache']['rep_filter'] = isset($this->memberData['_members_cache']['rep_filter']) ? $this->memberData['_members_cache']['rep_filter'] : '*';
}
}
示例6: __construct
/**
* Constructor
*
* @param object Registry reference
* @return @e void
*/
public function __construct(ipsRegistry $registry)
{
/* Make objects */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set default member */
$this->setMemberData($this->memberData);
/* Check for class_forums */
if (!$this->registry->isClassLoaded('class_forums')) {
$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums');
$this->registry->setClass('class_forums', new $classToLoad($registry));
$this->registry->strip_invisible = 0;
$this->registry->class_forums->forumsInit();
}
/* Load tagging stuff */
if (!$this->registry->isClassLoaded('tags')) {
require_once IPS_ROOT_PATH . 'sources/classes/tags/bootstrap.php';
/*noLibHook*/
$this->registry->setClass('tags', classes_tags_bootstrap::run('forums', 'topics'));
}
/* Unpack reputation @todo this isn't ideal here but it'll do for now */
if ($this->settings['reputation_enabled']) {
/* Load the class */
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
$this->registry->setClass('repCache', new $classToLoad());
/* Update the filter? */
if (isset($this->request['rep_filter']) and $this->request['rep_filter'] == 'update') {
/**
* Check secure key
* @link http://community.invisionpower.com/tracker/issue-22078-i-can-edit-your-treshold
*/
if ($this->request['secure_key'] != $this->member->form_hash) {
$this->registry->output->showError('usercp_forums_bad_key', 1021522);
}
$_mem_cache = IPSMember::unpackMemberCache($this->memberData['members_cache']);
if ($this->request['rep_filter_set'] == '*') {
$_mem_cache['rep_filter'] = '*';
} else {
$_mem_cache['rep_filter'] = intval($this->request['rep_filter_set']);
}
IPSMember::packMemberCache($this->memberData['member_id'], $_mem_cache);
$this->memberData['_members_cache'] = $_mem_cache;
} else {
$this->memberData['_members_cache'] = isset($this->memberData['members_cache']) ? IPSMember::unpackMemberCache($this->memberData['members_cache']) : array();
}
}
}
示例7: getMemberNotificationConfig
/**
* Get the member's notification configuration
*
* @access public
* @param array Member data
* @return array
* @link http://community.invisionpower.com/tracker/issue-23529-notification-defaults-dont-apply/
* @link http://community.invisionpower.com/tracker/issue-23663-notification-issues/
*/
public function getMemberNotificationConfig($member)
{
$_cache = !empty($member['members_cache']) ? IPSMember::unpackMemberCache($member['members_cache']) : array();
if (!empty($_cache['notifications'])) {
$savedTypes = array_keys($_cache['notifications']);
$_default = $this->getDefaultNotificationConfig();
$defaultTypes = array_keys($_default);
$missingTypes = array_diff($defaultTypes, $savedTypes);
//-----------------------------------------
// Grab any missing types
//-----------------------------------------
foreach ($missingTypes as $_type) {
$_cache['notifications'][$_type] = $_default[$_type]['selected'];
}
//-----------------------------------------
// Make changes if admin has disallowed override
// since we saved our config
//-----------------------------------------
foreach ($_default as $k => $sub) {
if ($sub['disable_override']) {
$_cache['notifications'][$k]['selected'] = $sub['selected'];
} else {
if ($sub['disabled']) {
$_newSelection = array();
if (is_array($_cache['notifications'][$k]['selected']) and count($_cache['notifications'][$k]['selected'])) {
foreach ($_cache['notifications'][$k]['selected'] as $_thisType) {
if (!in_array($_thisType, $sub['disabled'])) {
$_newSelection[] = $_thisType;
}
}
}
$_cache['notifications'][$k]['selected'] = $_newSelection;
}
}
}
return $_cache['notifications'];
} else {
return $this->getDefaultNotificationConfig();
}
}