function getSiteActivity( $input, $args, $parser ) {
	global $wgMemc, $wgScriptPath;

	$parser->disableCache();

	$limit = ( isset( $args['limit'] ) && is_numeric( $args['limit'] ) ) ? $args['limit'] : 10;

	// so that <siteactivity limit=5 /> will return 5 items instead of 4...
	$fixedLimit = $limit + 1;

	$key = wfMemcKey( 'site_activity', 'all', $fixedLimit );
	$data = $wgMemc->get( $key );
	if ( !$data ) {
		wfDebug( "Got site activity from DB\n" );
		$rel = new UserActivity( '', 'ALL', $fixedLimit );

		$rel->setActivityToggle( 'show_votes', 0 );
		$activity = $rel->getActivityListGrouped();
		$wgMemc->set( $key, $activity, 60 * 2 );
	} else {
		wfDebug( "Got site activity from cache\n" );
		$activity = $data;
	}

	$output = '';
	if ( $activity ) {
		$output .= '<div class="mp-site-activity">
			<h2>' . wfMsg( 'useractivity-siteactivity' ) . '</h2>';

		$x = 1;
		foreach ( $activity as $item ) {
			if ( $x < $fixedLimit ) {
				$typeIcon = UserActivity::getTypeIcon( $item['type'] );
				$output .= '<div class="mp-activity' . ( ( $x == $fixedLimit ) ? ' mp-activity-border-fix' : '' ) . '">
				<img src="' . $wgScriptPath . '/extensions/SocialProfile/images/' . $typeIcon . '" alt="' . $typeIcon . '" border="0" />'
				. $item['data'] .
				'</div>';
				$x++;
			}
		}

		$output .= '</div>';
	}

	return $output;
}
function getSiteActivity($input, $args, $parser)
{
    global $wgMemc, $wgExtensionAssetsPath, $wgUser;
    $parser->getOutput()->addModules('ext.socialprofile.siteactivity.css');
    $parser->disableCache();
    $limit = isset($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : 10;
    // so that <siteactivity limit=5 /> will return 5 items instead of 4...
    $fixedLimit = $limit + 1;
    $key = wfMemcKey('site_activity', 'THIS_SITE', $fixedLimit, $wgUser->getName());
    $data = $wgMemc->get($key);
    if (!$data) {
        wfDebug("Got site activity from DB\n");
        $rel = new UserActivity($wgUser->getName(), 'THIS_SITE', $fixedLimit);
        $rel->setActivityToggle('show_votes', 0);
        $rel->setActivityToggle('show_comments', 0);
        $activity = $rel->getActivityListGrouped();
        $wgMemc->set($key, $activity, 60 * 2);
    } else {
        wfDebug("Got site activity from cache\n");
        $activity = $data;
    }
    $output = '';
    if ($activity) {
        $output .= '<div class="mp-site-activity">';
        $x = 1;
        foreach ($activity as $item) {
            if ($x < $fixedLimit) {
                $typeIcon = UserActivity::getTypeIcon($item['type']);
                $output .= '<div class="mp-activity' . ($x == $fixedLimit ? ' mp-activity-border-fix' : '') . '">' . $item['data'] . '</div>';
                $x++;
            }
        }
        $output .= '</div>';
    }
    return $output;
}
Example #3
0
 protected function completeLogin($dept_id = NULL)
 {
     $this->errorCode = self::ERROR_NONE;
     $this->_id = $this->user->id;
     $this->username = $this->user->username;
     $this->setState(self::STATE_AUDIT_TRAIL, $this->auditTrail);
     $this->setState(self::STATE_USER_LEVEL, $this->user->user_level);
     $this->setState(self::STATE_DEPT_ID, $dept_id);
     $this->setState('client', $this->user->client_id);
     $base_module = null;
     if ($this->user->user_level !== UserLevels::LEVEL_MEMBER) {
         $base_module = 'admin';
     }
     $this->setState(self::STATE_HOME_MODULE, $base_module);
     if (!empty($this->user->timezone)) {
         Yii::app()->localtime->setTimezone($this->user->timezone);
     }
     //update last login
     Users::model()->updateLastLogin($this->user->id);
     //add activity log
     UserActivity::model()->addActivity($this->user->id, UserActivity::TYPE_LOGIN, Lang::t("{name} signed in successfully", array('{name}' => $this->user->username)));
 }
    /**
     * Gets the recent social activity for a given user.
     *
     * @param $user_name String: name of the user whose activity we want to fetch
     */
    function getActivity($user_name)
    {
        global $wgUser, $wgUserProfileDisplay, $wgScriptPath, $wgUploadPath;
        // If not enabled in site settings, don't display
        if ($wgUserProfileDisplay['activity'] == false) {
            return '';
        }
        $output = '';
        $limit = 8;
        $rel = new UserActivity($user_name, 'user', $limit);
        $rel->setActivityToggle('show_votes', 0);
        $rel->setActivityToggle('show_gifts_sent', 1);
        /**
         * Get all relationship activity
         */
        $activity = $rel->getActivityList();
        if ($activity) {
            $output .= '<div class="user-section-heading">
				<div class="user-section-title">' . wfMsg('user-recent-activity-title') . '</div>
				<div class="user-section-actions">
					<div class="action-right">
					</div>
					<div class="cleared"></div>
				</div>
			</div>
			<div class="cleared"></div>';
            $x = 1;
            if (count($activity) < $limit) {
                $style_limit = count($activity);
            } else {
                $style_limit = $limit;
            }
            foreach ($activity as $item) {
                $item_html = '';
                $title = Title::makeTitle($item['namespace'], $item['pagetitle']);
                $user_title = Title::makeTitle(NS_USER, $item['username']);
                $user_title_2 = Title::makeTitle(NS_USER, $item['comment']);
                if ($user_title_2) {
                    $user_link_2 = '<a href="' . $user_title_2->escapeFullURL() . '" rel="nofollow">' . $item['comment'] . '</a>';
                }
                $comment_url = '';
                if ($item['type'] == 'comment') {
                    $comment_url = "#comment-{$item['id']}";
                }
                $page_link = '<b><a href="' . $title->escapeFullURL() . "{$comment_url}\">" . $title->getPrefixedText() . '</a></b> ';
                $b = new UserBoard();
                // Easier than porting the time-related functions here
                $item_time = '<span class="item-small">' . wfMsg('user-time-ago', $b->getTimeAgo($item['timestamp'])) . '</span>';
                if ($x < $style_limit) {
                    $item_html .= '<div class="activity-item">
						<img src="' . $wgScriptPath . '/extensions/SocialProfile/images/' . UserActivity::getTypeIcon($item['type']) . '" alt="" border="0" />';
                } else {
                    $item_html .= '<div class="activity-item-bottom">
						<img src="' . $wgScriptPath . '/extensions/SocialProfile/images/' . UserActivity::getTypeIcon($item['type']) . '" alt="" border="0" />';
                }
                switch ($item['type']) {
                    case 'edit':
                        $item_html .= wfMsg('user-recent-activity-edit') . " {$page_link} {$item_time}\r\n\t\t\t\t\t\t\t<div class=\"item\">";
                        if ($item['comment']) {
                            $item_html .= "\"{$item['comment']}\"";
                        }
                        $item_html .= '</div>';
                        break;
                    case 'vote':
                        $item_html .= wfMsg('user-recent-activity-vote') . " {$page_link} {$item_time}";
                        break;
                    case 'comment':
                        $item_html .= wfMsg('user-recent-activity-comment') . " {$page_link} {$item_time}\r\n\t\t\t\t\t\t\t<div class=\"item\">\r\n\t\t\t\t\t\t\t\t\"{$item['comment']}\"\r\n\t\t\t\t\t\t\t</div>";
                        break;
                    case 'gift-sent':
                        $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($item['namespace'], 'm') . '" border="0" alt="" />';
                        $item_html .= wfMsg('user-recent-activity-gift-sent') . " {$user_link_2} {$item_time}\r\n\t\t\t\t\t\t<div class=\"item\">\r\n\t\t\t\t\t\t\t<a href=\"" . $wgScriptPath . "/index.php?title=Special:ViewGift&gift_id={$item['id']}\" rel=\"nofollow\">\r\n\t\t\t\t\t\t\t\t{$gift_image}\r\n\t\t\t\t\t\t\t\t{$item['pagetitle']}\r\n\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t</div>";
                        break;
                    case 'gift-rec':
                        $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($item['namespace'], 'm') . '" border="0" alt="" />';
                        $item_html .= wfMsg('user-recent-activity-gift-rec') . " {$user_link_2} {$item_time}</span>\r\n\t\t\t\t\t\t\t\t<div class=\"item\">\r\n\t\t\t\t\t\t\t\t\t<a href=\"" . $wgScriptPath . "/index.php?title=Special:ViewGift&gift_id={$item['id']}\" rel=\"nofollow\">\r\n\t\t\t\t\t\t\t\t\t\t{$gift_image}\r\n\t\t\t\t\t\t\t\t\t\t{$item["pagetitle"]}\r\n\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t</div>";
                        break;
                    case 'system_gift':
                        $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($item['namespace'], 'm') . '" border="0" alt="" />';
                        $item_html .= wfMsg('user-recent-system-gift') . " {$item_time}\r\n\t\t\t\t\t\t\t\t<div class=\"user-home-item-gift\">\r\n\t\t\t\t\t\t\t\t\t<a href=\"" . $wgScriptPath . "/index.php?title=Special:ViewSystemGift&gift_id={$item['id']}\" rel=\"nofollow\">\r\n\t\t\t\t\t\t\t\t\t\t{$gift_image}\r\n\t\t\t\t\t\t\t\t\t\t{$item['pagetitle']}\r\n\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t</div>";
                        break;
                    case 'friend':
                        $item_html .= wfMsg('user-recent-activity-friend') . " <b>{$user_link_2}</b> {$item_time}";
                        break;
                    case 'foe':
                        $item_html .= wfMsg('user-recent-activity-foe') . " <b>{$user_link_2}</b> {$item_time}";
                        break;
                    case 'system_message':
                        $item_html .= "{$item['comment']} {$item_time}";
                        break;
                    case 'user_message':
                        $item_html .= wfMsg('user-recent-activity-user-message') . " <b><a href=\"" . UserBoard::getUserBoardURL($user_title_2->getText()) . "\" rel=\"nofollow\">{$item['comment']}</a></b>  {$item_time}\r\n\t\t\t\t\t\t\t\t<div class=\"item\">\r\n\t\t\t\t\t\t\t\t\"{$item['namespace']}\"\r\n\t\t\t\t\t\t\t\t</div>";
                        break;
                }
                $item_html .= '</div>';
                if ($x <= $limit) {
                    $items_html_type['all'][] = $item_html;
                }
                $items_html_type[$item['type']][] = $item_html;
                $x++;
            }
            $by_type = '';
            foreach ($items_html_type['all'] as $item) {
                $by_type .= $item;
            }
            $output .= "<div id=\"recent-all\">{$by_type}</div>";
            $by_type = '';
            if (isset($items_html_type['edit']) && is_array($items_html_type['edit'])) {
                foreach ($items_html_type['edit'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['comment']) && is_array($items_html_type['comment'])) {
                foreach ($items_html_type['comment'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['gift-sent']) && is_array($items_html_type['gift-sent'])) {
                foreach ($items_html_type['gift-sent'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['gift-rec']) && is_array($items_html_type['gift-rec'])) {
                foreach ($items_html_type['gift-rec'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['system_gift']) && is_array($items_html_type['system_gift'])) {
                foreach ($items_html_type['system_gift'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['friend']) && is_array($items_html_type['friend'])) {
                foreach ($items_html_type['friend'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['foe']) && is_array($items_html_type['foe'])) {
                foreach ($items_html_type['foe'] as $item) {
                    $by_type .= $item;
                }
            }
            $by_type = '';
            if (isset($items_html_type['system_message']) && is_array($items_html_type['system_message'])) {
                foreach ($items_html_type['system_message'] as $item) {
                    $by_type .= $item;
                }
            }
        }
        return $output;
    }
Example #5
0
    /**
     * Gets the recent social activity for a given user.
     *
     * @param $user_name String: name of the user whose activity we want to fetch
     */
    function getEditingActivity($user_name)
    {
        global $wgUser, $wgUserProfileDisplay, $wgExtensionAssetsPath, $wgUploadPath;
        // If not enabled in site settings, don't display
        if ($wgUserProfileDisplay['activity'] == false) {
            return '';
        }
        $output = '';
        $limit = 8;
        $rel = new UserActivity($user_name, 'user', $limit);
        $rel->setActivityToggle('show_votes', 0);
        $rel->setActivityToggle('show_edits', 1);
        $rel->setActivityToggle('show_comments', 1);
        $rel->setActivityToggle('show_relationships', 0);
        $rel->setActivityToggle('show_system_gifts', 0);
        $rel->setActivityToggle('show_system_messages', 0);
        $rel->setActivityToggle('show_messages_sent', 0);
        $rel->setActivityToggle('show_user_user_follows', 0);
        $rel->setActivityToggle('show_user_site_follows', 0);
        $rel->setActivityToggle('show_user_update_status', 0);
        $rel->setActivityToggle('show_gifts_sent', 0);
        $rel->setActivityToggle('show_gifts_rec', 0);
        $rel->setActivityToggle('show_domain_creations', 1);
        $rel->setActivityToggle('show_image_uploads', 0);
        /**
         * Get all relationship activity
         */
        $activity = $rel->getActivityList();
        if ($activity) {
            $output .= '<div class="panel panel-default"><div class="user-section-heading panel-heading">
				<div class="user-section-title">' . wfMessage('user-recent-local-activity-title')->escaped() . '</div>
				<div class="user-section-actions">
					<div class="action-right">
					</div>
					<div class="cleared"></div>
				</div>
			</div>
			<div class="cleared"></div>
			<div class="panel-body">';
            $x = 1;
            if (count($activity) < $limit) {
                $style_limit = count($activity);
            } else {
                $style_limit = $limit;
            }
            foreach ($activity as $item) {
                $item_html = '';
                $title = Title::makeTitle($item['namespace'], $item['pagetitle'], '', $item['prefix']);
                $user_title = Title::makeTitle(NS_USER, $item['username']);
                $user_title_2 = Title::makeTitle(NS_USER, $item['comment']);
                if ($user_title_2) {
                    $user_link_2 = '<a href="' . htmlspecialchars($user_title_2->getFullURL()) . '" rel="nofollow">' . $item['comment'] . '</a>';
                }
                $comment_url = '';
                if ($item['type'] == 'comment') {
                    $comment_url = "#comment-{$item['id']}";
                }
                $page_link = '<b><a href="' . htmlspecialchars($title->getFullURL()) . "{$comment_url}\">" . $title->getText() . '</a></b> ';
                $b = new UserBoard();
                // Easier than porting the time-related functions here
                $item_time = '<span class="item-small">' . wfMessage('user-time-ago', $b->getTimeAgo($item['timestamp']))->escaped() . '</span>';
                if ($x < $style_limit) {
                    $item_html .= '<div class="activity-item">' . UserActivity::getTypeIcon($item['type']);
                } else {
                    $item_html .= '<div class="activity-item-bottom">' . UserActivity::getTypeIcon($item['type']);
                }
                $viewGift = SpecialPage::getTitleFor('ViewGift');
                switch ($item['type']) {
                    case 'edit':
                        $item_html .= wfMessage('user-recent-activity-edit')->escaped() . " {$page_link} {$item_time}\n\t\t\t\t\t\t\t<div class=\"item\">";
                        if ($item['comment']) {
                            $item_html .= "\"{$item['comment']}\"";
                        }
                        $item_html .= '</div>';
                        break;
                    case 'vote':
                        $item_html .= wfMessage('user-recent-activity-vote')->escaped() . " {$page_link} {$item_time}";
                        break;
                    case 'comment':
                        $item_html .= wfMessage('user-recent-activity-comment')->escaped() . " {$page_link} {$item_time}\n\t\t\t\t\t\t\t<div class=\"item\">\n\t\t\t\t\t\t\t\t\"{$item['comment']}\"\n\t\t\t\t\t\t\t</div>";
                        break;
                    case 'gift-sent':
                        $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($item['namespace'], 'm') . '" border="0" alt="" />';
                        $item_html .= wfMessage('user-recent-activity-gift-sent')->escaped() . " {$user_link_2} {$item_time}\n\t\t\t\t\t\t<div class=\"item\">\n\t\t\t\t\t\t\t<a href=\"" . htmlspecialchars($viewGift->getFullURL("gift_id={$item['id']}")) . "\" rel=\"nofollow\">\n\t\t\t\t\t\t\t\t{$gift_image}\n\t\t\t\t\t\t\t\t{$item['pagetitle']}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</div>";
                        break;
                    case 'gift-rec':
                        $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($item['namespace'], 'm') . '" border="0" alt="" />';
                        $item_html .= wfMessage('user-recent-activity-gift-rec')->escaped() . " {$user_link_2} {$item_time}</span>\n\t\t\t\t\t\t\t\t<div class=\"item\">\n\t\t\t\t\t\t\t\t\t<a href=\"" . htmlspecialchars($viewGift->getFullURL("gift_id={$item['id']}")) . "\" rel=\"nofollow\">\n\t\t\t\t\t\t\t\t\t\t{$gift_image}\n\t\t\t\t\t\t\t\t\t\t{$item['pagetitle']}\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</div>";
                        break;
                    case 'system_gift':
                        $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($item['namespace'], 'm') . '" border="0" alt="" />';
                        $viewSystemGift = SpecialPage::getTitleFor('ViewSystemGift');
                        $item_html .= wfMessage('user-recent-system-gift')->escaped() . " {$item_time}\n\t\t\t\t\t\t\t\t<div class=\"user-home-item-gift\">\n\t\t\t\t\t\t\t\t\t<a href=\"" . htmlspecialchars($viewSystemGift->getFullURL("gift_id={$item['id']}")) . "\" rel=\"nofollow\">\n\t\t\t\t\t\t\t\t\t\t{$gift_image}\n\t\t\t\t\t\t\t\t\t\t{$item['pagetitle']}\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</div>";
                        break;
                    case 'friend':
                        $item_html .= wfMessage('user-recent-activity-friend')->escaped() . " <b>{$user_link_2}</b> {$item_time}";
                        break;
                    case 'foe':
                        $item_html .= wfMessage('user-recent-activity-foe')->escaped() . " <b>{$user_link_2}</b> {$item_time}";
                        break;
                    case 'system_message':
                        $item_html .= "{$item['comment']} {$item_time}";
                        break;
                    case 'user_message':
                        $item_html .= wfMessage('user-recent-activity-user-message')->escaped() . " <b><a href=\"" . UserBoard::getUserBoardURL($user_title_2->getText()) . "\" rel=\"nofollow\">{$item['comment']}</a></b>  {$item_time}\n\t\t\t\t\t\t\t\t<div class=\"item\">\n\t\t\t\t\t\t\t\t\"{$item['namespace']}\"\n\t\t\t\t\t\t\t\t</div>";
                        break;
                    case 'network_update':
                        $network_image = SportsTeams::getLogo($item['sport_id'], $item['team_id'], 's');
                        $item_html .= wfMessage('user-recent-activity-network-update')->escaped() . '<div class="item">
									<a href="' . SportsTeams::getNetworkURL($item['sport_id'], $item['team_id']) . "\" rel=\"nofollow\">{$network_image} \"{$item['comment']}\"</a>\n\t\t\t\t\t\t\t\t</div>";
                        break;
                    case 'domain_creation':
                        $domainLink = '<b><a href="' . htmlspecialchars($title->getFullURL()) . "\">" . $item['domainname'] . '</a></b> ';
                        $item_html .= wfMessage('user-recent-activity-domain-creation')->escaped() . "{$domainLink} {$item_time}" . '<div class="item">
									<p>' . $item['comment'] . "</p>\n\t\t\t\t\t\t\t\t</div>";
                        break;
                }
                $item_html .= '</div>';
                if ($x <= $limit) {
                    $items_html_type['all'][] = $item_html;
                }
                $items_html_type[$item['type']][] = $item_html;
                $x++;
            }
            $by_type = '';
            foreach ($items_html_type['all'] as $item) {
                $by_type .= $item;
            }
            $output .= "<div id=\"recent-all\">{$by_type}</div></div></div>";
        }
        return $output;
    }
    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgExtensionAssetsPath, $wgMemc;
        $out = $this->getOutput();
        $request = $this->getRequest();
        $user = $this->getUser();
        // Add CSS
        $out->addModuleStyles('ext.socialprofile.useractivity.css');
        // Add Javascript
        $out->addModuleScripts('ext.socialprofile.useractivity.js');
        // Set the page title, robot policies, etc.
        $this->setHeaders();
        $out->setPageTitle($this->msg('useractivity-title')->plain());
        // Initialize all of these or otherwise we get a lot of E_NOTICEs about
        // undefined variables when the filtering feature (described below) is
        // active and we're viewing a filtered-down feed
        $edits = $votes = $comments = $comments = $gifts = $relationships = $messages = $system_gifts = $messages_sent = $network_updates = $domain_creations = $user_user_follows = $user_site_follows = $user_update_status = $image_uploads = 0;
        $filter = $request->getVal('filter');
        $item_type = $request->getVal('item_type');
        if (!$filter) {
            $filter = "FOLLOWING";
        }
        if (!$item_type) {
            $item_type = 'default';
        }
        $output = '
		<!-- Nav tabs -->
		<ul class="nav nav-tabs" role="tablist">
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=FOLLOWING_SITES" aria-controls="following_sites" role="tab" >我关注的站点</a></li>
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=FOLLOWING" aria-controls="following" role="tab" >我关注的用户</a></li>
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=USER" aria-controls="user" role="tab" >我自己</a></li>
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=ALL" aria-controls="all" role="tab" >精彩推荐</a></li>
		</ul>';
        // Filtering feature, if enabled
        // The filter message's format is:
        // *filter name (item_type URL parameter)|Displayed text (can be the name of a MediaWiki: message, too)|Type icon name (*not* the image name; see UserActivity::getTypeIcon())
        // For example:
        // *messages|Board Messages|user_message
        // This would add a link that allows filtering non-board messages
        // related events from the filter, only showing board message activity
        $filterMsg = $this->msg('useractivity-friendsactivity-filter');
        if (!$filterMsg->isDisabled()) {
            $output .= '<div class="user-home-links-container">
			<h2>' . $this->msg('useractivity-filter')->plain() . '</h2>
			<div class="user-home-links">';
            $lines = explode("\n", $filterMsg->inContentLanguage()->text());
            foreach ($lines as $line) {
                if (strpos($line, '*') !== 0) {
                    continue;
                } else {
                    $line = explode('|', trim($line, '* '), 3);
                    $type = $line[0];
                    $link_text = $line[1];
                    // Maybe it's the name of a MediaWiki: message? I18n is
                    // always nice, so at least try it and see what happens...
                    $linkMsgObj = wfMessage($link_text);
                    if (!$linkMsgObj->isDisabled()) {
                        $link_text = $linkMsgObj->parse();
                    }
                    $link_image = $line[2];
                    $output .= '<a href="' . htmlspecialchars($this->getPageTitle()->getFullURL("item_type={$type}")) . "\">" . UserActivity::getTypeIcon($type) . "&nbsp;{$link_text}</a>";
                }
            }
            $output .= Linker::link($this->getPageTitle(), $this->msg('useractivity-all')->plain());
            $output .= '</div>
			</div>';
        }
        $fixedLimit = 30;
        $output .= '<div class="user-home-feed" data-filter="' . $filter . '" data-limit="' . $fixedLimit . '" data-item_type="' . $item_type . '">';
        $output .= '</div>
		<div class="cleared"></div><button id="user-activity-more">More</button>';
        $out->addHTML($output);
    }
function wfUserActivityResponse($username, $filter, $item_type, $limit, $earlierThan)
{
    global $wgMemc;
    $output = '';
    $edits = $votes = $comments = $comments = $gifts = $relationships = $messages = $system_gifts = $messages_sent = $network_updates = $domain_creations = $user_user_follows = $user_site_follows = $user_update_status = $image_uploads = 0;
    if (!$filter) {
        $filter = "FOLLOWING";
    }
    if (!$item_type) {
        $item_type = 'default';
    }
    // If not otherwise specified, display everything but *votes* in the feed
    if ($item_type == 'edit' || $item_type == 'all') {
        $edits = 1;
    }
    if ($item_type == 'vote' || $item_type == 'all') {
        $votes = 1;
    }
    if ($item_type == 'comment' || $item_type == 'all') {
        $comments = 1;
    }
    if ($item_type == 'gift-rec' || $item_type == 'all') {
        $gifts = 1;
    }
    if ($item_type == 'friend' || $item_type == 'all') {
        $relationships = 1;
    }
    if ($item_type == 'system_message' || $item_type == 'all') {
        $messages = 1;
    }
    if ($item_type == 'system_gift' || $item_type == 'all') {
        $system_gifts = 1;
    }
    if ($item_type == 'user_message' || $item_type == 'all') {
        $messages_sent = 1;
    }
    if ($item_type == 'network_update' || $item_type == 'all') {
        $network_updates = 1;
    }
    if ($item_type == 'user_update_status' || $item_type == 'all') {
        $user_update_status = 1;
    }
    if ($item_type == 'user_user_follow' || $item_type == 'all') {
        $user_user_follows = 1;
    }
    if ($item_type == 'user_site_follow' || $item_type == 'all') {
        $user_site_follows = 1;
    }
    if ($item_type == 'domain_creation' || $item_type == 'all') {
        $domain_creations = 1;
    }
    if ($item_type == 'image_upload' || $item_type == 'all') {
        $image_uploads = 1;
    }
    // $output .= '<div class="user-home-feed">';
    // $rel = new UserActivity( $user->getName(), ( ( $rel_type == 1 ) ? ' friends' : 'foes' ), 50 );
    $fixedLimit = $limit;
    $rel = new UserActivity($username, $filter, $fixedLimit, $earlierThan);
    if ($item_type != 'default') {
        $rel->setActivityToggle('show_edits', $edits);
        $rel->setActivityToggle('show_votes', $votes);
        $rel->setActivityToggle('show_comments', $comments);
        $rel->setActivityToggle('show_gifts_rec', $gifts);
        $rel->setActivityToggle('show_relationships', $relationships);
        $rel->setActivityToggle('show_system_messages', $messages);
        $rel->setActivityToggle('show_system_gifts', $system_gifts);
        $rel->setActivityToggle('show_messages_sent', $messages_sent);
        $rel->setActivityToggle('show_network_updates', $network_updates);
        $rel->setActivityToggle('show_domain_creations', $domain_creations);
        $rel->setActivityToggle('show_user_user_follows', $user_user_follows);
        $rel->setActivityToggle('show_user_site_follows', $user_site_follows);
        $rel->setActivityToggle('show_user_update_status', $user_update_status);
        $rel->setActivityToggle('show_image_uploads', $image_uploads);
    }
    // $output .= '<div class="user-home-feed">';
    /**
     * Get all relationship activity
     */
    $key = wfForeignMemcKey('huiji', ' ', 'site_activity', $filter, $item_type, $fixedLimit, $username, $earlierThan);
    $data = $wgMemc->get($key);
    if ($data != '') {
        $activity = $data;
    } else {
        $activity = $rel->getActivityListGrouped();
        $wgMemc->set($key, $activity, 60 * 1);
    }
    $border_fix = '';
    $last = '';
    if ($activity) {
        $x = 1;
        $numberOfItems = $limit;
        foreach ($activity as $item) {
            if ($x < $numberOfItems) {
                if (count($activity) > $numberOfItems && $x == $numberOfItems - 1 || count($activity) < $numberOfItems && $x == count($activity)) {
                    $border_fix = ' border-fix';
                    $last = $item['timestamp'];
                }
                /* There can be a very weird bug that leads to $item['data'] == 1 */
                /* This is a temprary fix. */
                if ($item['data'] == 1) {
                    wfDebug("feed error: type:" . $item_type['type'] . "time:" . $item['timestamp']);
                    continue;
                }
                // $typeIcon = UserActivity::getTypeIcon( $item['type'] );
                // $output .= "<div class=\"user-home-activity{$border_fix}\">
                // 	<img src=\"{$wgExtensionAssetsPath}/SocialProfile/images/" . $typeIcon . "\" alt=\"\" border=\"0\" />
                // 	{$item['data']}
                // </div>";
                $output .= "<div class=\"user-home-activity{$border_fix}\">\n\t\t\t\t\t{$item['data']}\n\t\t\t\t</div>";
                // $last = $item['timestamp'];
                $x++;
            }
        }
        $end = false;
    } else {
        $end = true;
    }
    $out = array("success" => true, "continuation" => $last, "output" => $output, "earlierThan" => $earlierThan, "end" => $end);
    return json_encode($out);
}
    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgUser, $wgOut, $wgRequest, $wgScriptPath;
        $wgOut->addExtensionStyle($wgScriptPath . '/extensions/SocialProfile/UserActivity/UserActivity.css');
        $wgOut->setPageTitle(wfMsg('useractivity-title'));
        $output = '';
        $rel_type = $wgRequest->getVal('rel_type');
        $item_type = $wgRequest->getVal('item_type');
        if (!$rel_type) {
            $rel_type = 1;
        }
        if (!$item_type) {
            $item_type = 'all';
        }
        // If not otherwise specified, display everything but votes in the feed
        if ($item_type == 'edits' || $item_type == 'all') {
            $edits = 1;
        }
        if ($item_type == 'votes' || $item_type == 'all') {
            $votes = 0;
        }
        if ($item_type == 'comments' || $item_type == 'all') {
            $comments = 1;
        }
        if ($item_type == 'gifts' || $item_type == 'all') {
            $gifts = 1;
        }
        if ($item_type == 'relationships' || $item_type == 'all') {
            $relationships = 1;
        }
        if ($item_type == 'advancements' || $item_type == 'all') {
            $messages = 1;
        }
        if ($item_type == 'awards' || $item_type == 'all') {
            $system_gifts = 1;
        }
        if ($item_type == 'messages' || $item_type == 'all') {
            $messages_sent = 1;
        }
        $output .= '<div class="user-home-feed">';
        $rel = new UserActivity($wgUser->getName(), $rel_type == 1 ? ' friends' : 'foes', 50);
        $rel->setActivityToggle('show_edits', $edits);
        $rel->setActivityToggle('show_votes', $votes);
        $rel->setActivityToggle('show_comments', $comments);
        $rel->setActivityToggle('show_gifts_rec', $gifts);
        $rel->setActivityToggle('show_relationships', $relationships);
        $rel->setActivityToggle('show_system_messages', $messages);
        $rel->setActivityToggle('show_system_gifts', $system_gifts);
        $rel->setActivityToggle('show_messages_sent', $messages_sent);
        /**
         * Get all relationship activity
         */
        $activity = $rel->getActivityListGrouped();
        $border_fix = '';
        if ($activity) {
            $x = 1;
            foreach ($activity as $item) {
                if ($x < 40) {
                    if (count($activity) > 40 && $x == 39 || count($activity) < 40 && $x == count($activity) - 1) {
                        $border_fix = ' border-fix';
                    }
                    $typeIcon = UserActivity::getTypeIcon($item['type']);
                    $output .= "<div class=\"user-home-activity{$border_fix}\">\r\n\t\t\t\t\t\t<img src=\"{$wgScriptPath}/extensions/SocialProfile/images/" . $typeIcon . "\" alt=\"\" border=\"0\" />\r\n\t\t\t\t\t\t{$item['data']}\r\n\t\t\t\t\t</div>";
                    $x++;
                }
            }
        }
        $output .= '</div>
		<div class="cleared"></div>';
        $wgOut->addHTML($output);
    }
 /**
  * Used to delete activity after logout
  *
  * @access public
  * @return void
  */
 public function deleteActivity($user_id)
 {
     if (!empty($user_id)) {
         App::import("Model", "Users.UserActivity");
         $activityModel = new UserActivity();
         $activityModel->deleteAll(array('UserActivity.user_id' => $user_id), false);
     }
 }
Example #10
0
 /**
  * Remove activity
  *
  * @param array $args e.g. array('userid'=>4, 'key'=>'post', 'value'=>'6408')
  */
 public function removeActivity($args = array())
 {
     $activity = UserActivity::instance();
     return $activity->removeActivity($this, $args);
 }
    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgExtensionAssetsPath, $wgMemc;
        $out = $this->getOutput();
        $request = $this->getRequest();
        $user = $this->getUser();
        // Add CSS
        $out->addModuleStyles('ext.socialprofile.useractivity.css');
        // Set the page title, robot policies, etc.
        $this->setHeaders();
        $out->setPageTitle($this->msg('useractivity-title')->plain());
        // Initialize all of these or otherwise we get a lot of E_NOTICEs about
        // undefined variables when the filtering feature (described below) is
        // active and we're viewing a filtered-down feed
        $edits = $votes = $comments = $comments = $gifts = $relationships = $messages = $system_gifts = $messages_sent = $network_updates = $domain_creations = $user_user_follows = $user_site_follows = $user_update_status = $image_uploads = 0;
        $filter = $request->getVal('filter');
        $item_type = $request->getVal('item_type');
        if (!$filter) {
            $filter = "FOLLOWING";
        }
        if (!$item_type) {
            $item_type = 'default';
        }
        $output = '
		<!-- Nav tabs -->
		<ul class="nav nav-tabs" role="tablist">
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=FOLLOWING_SITES" aria-controls="following_sites" role="tab" >我关注的站点</a></li>
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=FOLLOWING" aria-controls="following" role="tab" >我关注的用户</a></li>
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=USER" aria-controls="user" role="tab" >我自己</a></li>
			<li role="presentation"><a href="/wiki/Special:UserActivity?filter=ALL" aria-controls="all" role="tab" >精彩推荐</a></li>
		</ul>';
        // If not otherwise specified, display everything but *votes* in the feed
        if ($item_type == 'edit' || $item_type == 'all') {
            $edits = 1;
        }
        if ($item_type == 'vote' || $item_type == 'all') {
            $votes = 1;
        }
        if ($item_type == 'comment' || $item_type == 'all') {
            $comments = 1;
        }
        if ($item_type == 'gift-rec' || $item_type == 'all') {
            $gifts = 1;
        }
        if ($item_type == 'friend' || $item_type == 'all') {
            $relationships = 1;
        }
        if ($item_type == 'system_message' || $item_type == 'all') {
            $messages = 1;
        }
        if ($item_type == 'system_gift' || $item_type == 'all') {
            $system_gifts = 1;
        }
        if ($item_type == 'user_message' || $item_type == 'all') {
            $messages_sent = 1;
        }
        if ($item_type == 'network_update' || $item_type == 'all') {
            $network_updates = 1;
        }
        if ($item_type == 'user_update_status' || $item_type == 'all') {
            $user_update_status = 1;
        }
        if ($item_type == 'user_user_follow' || $item_type == 'all') {
            $user_user_follows = 1;
        }
        if ($item_type == 'user_site_follow' || $item_type == 'all') {
            $user_site_follows = 1;
        }
        if ($item_type == 'domain_creation' || $item_type == 'all') {
            $domain_creations = 1;
        }
        if ($item_type == 'image_upload' || $item_type == 'all') {
            $image_uploads = 1;
        }
        // Filtering feature, if enabled
        // The filter message's format is:
        // *filter name (item_type URL parameter)|Displayed text (can be the name of a MediaWiki: message, too)|Type icon name (*not* the image name; see UserActivity::getTypeIcon())
        // For example:
        // *messages|Board Messages|user_message
        // This would add a link that allows filtering non-board messages
        // related events from the filter, only showing board message activity
        $filterMsg = $this->msg('useractivity-friendsactivity-filter');
        if (!$filterMsg->isDisabled()) {
            $output .= '<div class="user-home-links-container">
			<h2>' . $this->msg('useractivity-filter')->plain() . '</h2>
			<div class="user-home-links">';
            $lines = explode("\n", $filterMsg->inContentLanguage()->text());
            foreach ($lines as $line) {
                if (strpos($line, '*') !== 0) {
                    continue;
                } else {
                    $line = explode('|', trim($line, '* '), 3);
                    $type = $line[0];
                    $link_text = $line[1];
                    // Maybe it's the name of a MediaWiki: message? I18n is
                    // always nice, so at least try it and see what happens...
                    $linkMsgObj = wfMessage($link_text);
                    if (!$linkMsgObj->isDisabled()) {
                        $link_text = $linkMsgObj->parse();
                    }
                    $link_image = $line[2];
                    $output .= '<a href="' . htmlspecialchars($this->getPageTitle()->getFullURL("item_type={$type}")) . "\">" . UserActivity::getTypeIcon($type) . "&nbsp;{$link_text}</a>";
                }
            }
            $output .= Linker::link($this->getPageTitle(), $this->msg('useractivity-all')->plain());
            $output .= '</div>
			</div>';
        }
        $output .= '<div class="user-home-feed">';
        // $rel = new UserActivity( $user->getName(), ( ( $rel_type == 1 ) ? ' friends' : 'foes' ), 50 );
        $fixedLimit = 50;
        $rel = new UserActivity($user->getName(), $filter, $fixedLimit);
        if ($item_type != 'default') {
            $rel->setActivityToggle('show_edits', $edits);
            $rel->setActivityToggle('show_votes', $votes);
            $rel->setActivityToggle('show_comments', $comments);
            $rel->setActivityToggle('show_gifts_rec', $gifts);
            $rel->setActivityToggle('show_relationships', $relationships);
            $rel->setActivityToggle('show_system_messages', $messages);
            $rel->setActivityToggle('show_system_gifts', $system_gifts);
            $rel->setActivityToggle('show_messages_sent', $messages_sent);
            $rel->setActivityToggle('show_network_updates', $network_updates);
            $rel->setActivityToggle('show_domain_creations', $domain_creations);
            $rel->setActivityToggle('show_user_user_follows', $user_user_follows);
            $rel->setActivityToggle('show_user_site_follows', $user_site_follows);
            $rel->setActivityToggle('show_user_update_status', $user_update_status);
            $rel->setActivityToggle('show_image_uploads', $image_uploads);
        }
        /**
         * Get all relationship activity
         */
        $key = wfForeignMemcKey('huiji', ' ', 'site_activity', $filter, $item_type, $fixedLimit, $user->getName());
        $data = $wgMemc->get($key);
        if ($data != '') {
            $activity = $data;
        } else {
            $activity = $rel->getActivityListGrouped();
            $wgMemc->set($key, $activity, 60 * 2);
        }
        $border_fix = '';
        if ($activity) {
            $x = 1;
            foreach ($activity as $item) {
                if ($x < 40) {
                    if (count($activity) > 40 && $x == 39 || count($activity) < 40 && $x == count($activity)) {
                        $border_fix = ' border-fix';
                    }
                    $typeIcon = UserActivity::getTypeIcon($item['type']);
                    // $output .= "<div class=\"user-home-activity{$border_fix}\">
                    // 	<img src=\"{$wgExtensionAssetsPath}/SocialProfile/images/" . $typeIcon . "\" alt=\"\" border=\"0\" />
                    // 	{$item['data']}
                    // </div>";
                    $output .= "<div class=\"user-home-activity{$border_fix}\">\n\t\t\t\t\t\t{$item['data']}\n\t\t\t\t\t</div>";
                    $x++;
                }
            }
        }
        $output .= '</div>
		<div class="cleared"></div>';
        $out->addHTML($output);
    }
Example #12
0
 /**
  * Remove activity
  *
  * @param array $args e.g. array('userid'=>4, 'key'=>'post', 'value'=>'6408')
  */
 public function removeActivity($args = array())
 {
     require_once LIBS . 'UserActivity.php';
     $activity = new UserActivity();
     return $activity->removeActivity($this, $args);
 }