/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $userLevel = UserLevel::model()->findAll();
     $preCheckedArray = array();
     if (isset($model->modulePrivilages)) {
         foreach ($model->modulePrivilages as $value) {
             $preCheckedArray[] = $value->user_level_id;
         }
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Module'])) {
         if (isset($_POST['privilages'])) {
             $preCheckedArray = Yii::app()->request->getPost('privilages');
         } else {
             $preCheckedArray = array();
         }
         $model->attributes = $_POST['Module'];
         $model->arrPrivilages = Yii::app()->request->getPost('privilages');
         if ($model->p_id == 0 || count($model->arrPrivilages)) {
             $model->hasPrivilage = true;
         }
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Module "' . $model->name . '" updated!');
             $model = $this->loadModel($model->id);
         }
     }
     $this->render('update', array('model' => $model, 'userLevel' => $userLevel, 'preCheckedArray' => $preCheckedArray));
 }
Example #2
0
 public function validationBeforeDelete()
 {
     $usedInModule = array();
     $this->onDeleteMessage = 'Cannot delete "' . $this->name . '", data already used in (';
     $criteria = new CDbCriteria();
     $criteria->compare('p_id', $this->id);
     $models = UserLevel::model()->findAll($criteria);
     if (isset($this->modulePrivilages) && count($this->modulePrivilages) > 0) {
         $usedInModule[] = 'Module';
     }
     if (isset($this->users) && count($this->users) > 0) {
         $usedInModule[] = 'User';
     }
     if (count($models) > 0) {
         $usedInModule[] = 'User Level';
     }
     if (count($usedInModule) > 0) {
         sort($usedInModule);
         foreach ($usedInModule as $value) {
             $this->onDeleteMessage .= $value . ', ';
         }
         $this->onDeleteMessage = substr($this->onDeleteMessage, 0, strlen($this->onDeleteMessage) - 2);
         $this->onDeleteMessage .= '). Please delete related data first before delete it!';
         return false;
     } else {
         return true;
     }
 }
Example #3
0
function getWelcome()
{
    global $wgUser, $wgOut, $wgLang;
    // Add CSS
    $wgOut->addModuleStyles('ext.socialprofile.userwelcome.css');
    // Get stats and user level
    $stats = new UserStats($wgUser->getID(), $wgUser->getName());
    $stats_data = $stats->getUserStats();
    $user_level = new UserLevel($stats_data['points']);
    // Safe links
    $level_link = Title::makeTitle(NS_HELP, wfMessage('mp-userlevels-link')->inContentLanguage()->plain());
    $avatar_link = SpecialPage::getTitleFor('UploadAvatar');
    // Make an avatar
    $avatar = new wAvatar($wgUser->getID(), 'l');
    // Profile top images/points
    $output = '<div class="mp-welcome-logged-in">
	<h2>' . wfMessage('mp-welcome-logged-in', $wgUser->getName())->parse() . '</h2>
	<div class="mp-welcome-image">
	<a href="' . htmlspecialchars($wgUser->getUserPage()->getFullURL()) . '" rel="nofollow">' . $avatar->getAvatarURL() . '</a>';
    if (strpos($avatar->getAvatarImage(), 'default_') !== false) {
        $uploadOrEditMsg = 'mp-welcome-upload';
    } else {
        $uploadOrEditMsg = 'mp-welcome-edit';
    }
    $output .= '<div><a href="' . htmlspecialchars($avatar_link->getFullURL()) . '" rel="nofollow">' . wfMessage($uploadOrEditMsg)->plain() . '</a></div>';
    $output .= '</div>';
    global $wgUserLevels;
    if ($wgUserLevels) {
        $output .= '<div class="mp-welcome-points">
			<div class="points-and-level">
				<div class="total-points">' . wfMessage('mp-welcome-points', $wgLang->formatNum($stats_data['points']))->parse() . '</div>
				<div class="honorific-level"><a href="' . htmlspecialchars($level_link->getFullURL()) . '">(' . $user_level->getLevelName() . ')</a></div>
			</div>
			<div class="cleared"></div>
			<div class="needed-points">
				<br />' . wfMessage('mp-welcome-needed-points', htmlspecialchars($level_link->getFullURL()), $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance())->text() . '</div>
		</div>';
    }
    $output .= '<div class="cleared"></div>';
    $output .= getRequests();
    $output .= '</div>';
    return $output;
}
function getWelcome()
{
    global $wgUser, $wgOut, $wgScriptPath, $wgUploadPath;
    // Add CSS
    $wgOut->addExtensionStyle($wgScriptPath . '/extensions/SocialProfile/UserWelcome/UserWelcome.css');
    // Get stats and user level
    $stats = new UserStats($wgUser->getID(), $wgUser->getName());
    $stats_data = $stats->getUserStats();
    $user_level = new UserLevel($stats_data['points']);
    // Safe links
    $level_link = Title::makeTitle(NS_HELP, wfMsgForContent('mp-userlevels-link'));
    $avatar_link = SpecialPage::getTitleFor('UploadAvatar');
    // Make an avatar
    $avatar = new wAvatar($wgUser->getID(), 'l');
    // Profile top images/points
    $output = '<div class="mp-welcome-logged-in">
	<h2>' . wfMsg('mp-welcome-logged-in', $wgUser->getName()) . '</h2>
	<div class="mp-welcome-image">
	<a href="' . $wgUser->getUserPage()->escapeFullURL() . '" rel="nofollow"><img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0"/></a>';
    if (strpos($avatar->getAvatarImage(), 'default_') !== false) {
        $output .= '<div><a href="' . $avatar_link->escapeFullURL() . '" rel="nofollow">' . wfMsg('mp-welcome-upload') . '</a></div>';
    } else {
        $output .= '<div><a href="' . $avatar_link->escapeFullURL() . '" rel="nofollow">' . wfMsg('mp-welcome-edit') . '</a></div>';
    }
    $output .= '</div>';
    global $wgUserLevels;
    if ($wgUserLevels) {
        $output .= '<div class="mp-welcome-points">
			<div class="points-and-level">
				<div class="total-points">' . wfMsgExt('mp-welcome-points', 'parsemag', $stats_data['points']) . '</div>
				<div class="honorific-level"><a href="' . $level_link->escapeFullURL() . '">(' . $user_level->getLevelName() . ')</a></div>
			</div>
			<div class="cleared"></div>
			<div class="needed-points">
				<br />' . wfMsgExt('mp-welcome-needed-points', 'parsemag', $level_link->escapeFullURL(), $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance()) . '</div>
		</div>';
    }
    $output .= '<div class="cleared"></div>';
    $output .= getRequests();
    $output .= '</div>';
    return $output;
}
Example #5
0
    /**
     * Get the header for the social profile page, which includes the user's
     * points and user level (if enabled in the site configuration) and lots
     * more.
     *
     * @param $user_id Integer: user ID
     * @param $user_name String: user name
     */
    function getProfileTop($user_id, $user_name)
    {
        global $wgOut, $wgUser, $wgLang;
        global $wgUserLevels;
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $user_level = new UserLevel($stats_data['points']);
        $level_link = Title::makeTitle(NS_HELP, wfMessage('user-profile-userlevels-link')->inContentLanguage()->text());
        $this->initializeProfileData($user_name);
        $profile_data = $this->profile_data;
        // Variables and other crap
        $page_title = $this->getTitle()->getText();
        $title_parts = explode('/', $page_title);
        $user = $title_parts[0];
        $id = User::idFromName($user);
        $user_safe = urlencode($user);
        // Safe urls
        $add_relationship = SpecialPage::getTitleFor('AddRelationship');
        $remove_relationship = SpecialPage::getTitleFor('RemoveRelationship');
        $give_gift = SpecialPage::getTitleFor('GiveGift');
        $send_board_blast = SpecialPage::getTitleFor('SendBoardBlast');
        $update_profile = SpecialPage::getTitleFor('UpdateProfile');
        $watchlist = SpecialPage::getTitleFor('Watchlist');
        $contributions = SpecialPage::getTitleFor('Contributions', $user);
        $send_message = SpecialPage::getTitleFor('UserBoard');
        $upload_avatar = SpecialPage::getTitleFor('UploadAvatar');
        $user_page = Title::makeTitle(NS_USER, $user);
        $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user);
        $user_wiki = Title::makeTitle(NS_USER_WIKI, $user);
        $us = new UserStatus($this->user);
        $city = $us->getCity();
        $city = Sanitizer::escapeHtmlAllowEntities($city);
        $birthday = $us->getBirthday();
        $status = $us->getStatus();
        $status = Sanitizer::escapeHtmlAllowEntities($status);
        $gender = $us->getGender();
        if ($gender == 'male') {
            $genderIcon = '♂';
            $gendertext = '他';
        } elseif ($gender == 'female') {
            $genderIcon = '♀';
            $gendertext = '她';
        } else {
            $genderIcon = '♂/♀';
            $gendertext = 'TA';
        }
        if ($this->isOwner()) {
            $gendertext = '你';
        }
        if ($id != 0) {
            $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
        }
        $avatar = new wAvatar($this->user_id, 'l');
        wfDebug('profile type: ' . $profile_data['user_page_type'] . "\n");
        $output = '';
        //get more
        $target = SpecialPage::getTitleFor('ShowFollowedSites');
        $query = array('user_id' => $wgUser->getId(), 'target_user_id' => $this->user_id);
        $mailVerify = $wgUser->getEmailAuthenticationTimestamp();
        if ($mailVerify == NULL) {
            $href = "/wiki/Special:ConfirmEmail";
        } else {
            $href = "/wiki/Special:UploadAvatar";
        }
        $output .= '<div id="profile-right" class="col-md-6 col-sm-12 col-xs-12">';
        $output .= '<div id="profile-title-container">
				<h1 id="profile-title">
				<div id="profile-image">' . ($this->isOwner() ? '<div class="profile-image-container crop-headimg" id="crop-avatar"><div class="avatar-view upload-tool" title="上传头像">' . $avatar->getOwnerAvatarURL() . '</div>' . $this->cropModal() . '</div>' : $avatar->getAvatarURL()) . '</div>' . $user_name . '</h1></div>';
        $output .= '<div class="modal fade watch-url" tabindex="-1" role="dialog" aria-labelledby="mySmModalLabel" aria-hidden="true">
                      <div class="modal-dialog modal-sm">
                        <div class="modal-content">
                          <div class="modal-header">
                              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                              <h4 class="modal-title" id="gridSystemModalLabel">' . $gendertext . '关注的wiki</h4>
                          </div>
                            <div class="modal-body">
	                            <div class="list-group">
								</div>
								' . Linker::LinkKnown($target, '<i class="fa fa-arrows-alt"></i> 全部', array('type' => 'button', 'class' => 'btn btn-default'), $query) . '
							</div>
                        </div>
                      </div>
                    </div>';
        // Show the user's level and the amount of points they have if
        // UserLevels has been configured contributions
        $notice = SpecialPage::getTitleFor('ViewFollows');
        $contributions = SpecialPage::getTitleFor('Contributions');
        $output .= '<div>
					    <ul class="user-follow-msg">
					        <li><h5>编辑</h5>' . Linker::link($contributions, $stats_data['edits'], array(), array('target' => $user, 'contribs' => 'user')) . '</li>
					        <li><h4>|</h4></li>
					        <li><h5>关注</h5>' . Linker::link($notice, UserUserFollow::getFollowingCount(User::newFromName($user)), array('id' => 'user-following-count'), array('user' => $user, 'rel_type' => 1)) . '</li>
					        <li><h4>|</h4></li>
					        <li><h5>被关注</h5>' . Linker::link($notice, UserUserFollow::getFollowerCount(User::newFromName($user)), array('id' => 'user-follower-count'), array('user' => $user, 'rel_type' => 2)) . '</li>
                        </ul>
                        <div class="cleared"></div>
                    </div>
                    <!--<span id="user-site-count">' . '</span>个站点。-->';
        if ($wgUserLevels) {
            $progress = $user_level->getLevelProgress() * 100;
            $output .= '<div id="honorific-level" class="label">
						<a href="' . htmlspecialchars($level_link->getFullURL()) . '" rel="nofollow">' . $user_level->getLevelName() . '</a>
					</div>
					<div id="points-level" class="progress">
						<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="' . $progress . '" aria-valuemin="0" aria-valuemax="100" style="width: ' . $progress . '%">
							<span class="sr-only">' . wfMessage('user-profile-points', $wgLang->formatNum($stats_data['points']))->escaped() . '</span>
						</div>

					</div>';
        }
        $output .= '<div class="profile-actions">';
        $output .= '<div class="form-container ' . ($this->isOwner() ? 'owner' : '') . '"><div class="form-msg"><a class="form-location ' . ($this->isOwner() ? 'edit' : '') . '">' . ($city == '' ? $this->isOwner() ? '填写居住地' : '居住地未公开' : $city) . '</a>
                    <span class="span-color">|</span><a class="form-date ' . ($this->isOwner() ? 'edit' : '') . '" data-birthday="' . ($birthday == '' || $birthday == '0000-00-00' ? '' : $birthday) . '">' . ($birthday == '' || $birthday == '0000-00-00' ? $this->isOwner() ? '填写生日' : '生日未公开' : '') . '</a>
                    <span class="span-color">|</span><a class="form-sex ' . ($this->isOwner() ? 'edit' : '') . '" data-sex="' . $gender . '">' . $genderIcon . '</a></div>';
        $output .= '<div class="user-autograph"><a class="form-autograph ' . ($this->isOwner() ? 'edit' : '') . '">' . ($status == '' ? $this->isOwner() ? '填写个人状态' : '这个人很懒,什么都没有写...' : $status) . '</a></div></div>';
        // Links to User:user_name from User_profile:
        // if ( $this->getTitle()->getNamespace() == NS_USER_PROFILE && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ) {
        // 	$output .= '| <a href="' . htmlspecialchars( $user_page->getFullURL() ) . '" rel="nofollow">' .
        // 		wfMessage( 'user-page-link' )->escaped() . '</a> ';
        // }
        // // Links to User:user_name from User_profile:
        // if ( $this->getTitle()->getNamespace() == NS_USER && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ) {
        // 	$output .= '| <a href="' . htmlspecialchars( $user_social_profile->getFullURL() ) . '" rel="nofollow">' .
        // 		wfMessage( 'user-social-profile-link' )->escaped() . '</a> ';
        // }
        // if ( $this->getTitle()->getNamespace() == NS_USER && ( !$this->profile_data['user_id'] || $this->profile_data['user_page_type'] == 1 ) ) {
        // 	$output .= '| <a href="' . htmlspecialchars( $user_wiki->getFullURL() ) . '" rel="nofollow">' .
        // 		wfMessage( 'user-wiki-link' )->escaped() . '</a>';
        // }
        $output .= '</div></div>';
        return $output;
    }
    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgOut, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
        // Load CSS
        $wgOut->addExtensionStyle($wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css');
        $wgOut->setPageTitle(wfMsg('user-stats-alltime-title'));
        $count = 100;
        $realcount = 50;
        $user_list = array();
        // Try cache
        $key = wfMemcKey('user_stats', 'top', 'points', $realcount);
        $data = $wgMemc->get($key);
        if ($data != '') {
            wfDebug("Got top users by points ({$count}) from cache\n");
            $user_list = $data;
        } else {
            wfDebug("Got top users by points ({$count}) from DB\n");
            $params['ORDER BY'] = 'stats_total_points DESC';
            $params['LIMIT'] = $count;
            $dbr = wfGetDB(DB_SLAVE);
            $res = $dbr->select('user_stats', array('stats_user_id', 'stats_user_name', 'stats_total_points'), array('stats_user_id <> 0'), __METHOD__, $params);
            $loop = 0;
            foreach ($res as $row) {
                $user = User::newFromId($row->stats_user_id);
                if (!$user->isBlocked()) {
                    $user_list[] = array('user_id' => $row->stats_user_id, 'user_name' => $row->stats_user_name, 'points' => $row->stats_total_points);
                    $loop++;
                }
                if ($loop >= 50) {
                    break;
                }
            }
            $wgMemc->set($key, $user_list, 60 * 5);
        }
        $recent_title = SpecialPage::getTitleFor('TopUsersRecent');
        $out = '<div class="top-fan-nav">
			<h1>' . wfMsg('top-fans-by-points-nav-header') . '</h1>
			<p><b>' . wfMsg('top-fans-total-points-link') . '</b></p>';
        if ($wgUserStatsTrackWeekly) {
            $out .= '<p><a href="' . $recent_title->escapeFullURL('period=monthly') . '">' . wfMsg('top-fans-monthly-points-link') . '</a></p>';
        }
        if ($wgUserStatsTrackMonthly) {
            $out .= '<p><a href="' . $recent_title->escapeFullURL('period=weekly') . '">' . wfMsg('top-fans-weekly-points-link') . '</a></p>';
        }
        // Build nav of stats by category based on MediaWiki:Topfans-by-category
        $by_category_title = SpecialPage::getTitleFor('TopFansByStatistic');
        $byCategoryMessage = wfMsgForContent('topfans-by-category');
        $lines = explode("\n", $byCategoryMessage);
        if (count($lines) > 0 && !wfEmptyMsg('topfans-by-category', $byCategoryMessage)) {
            $out .= '<h1 style="margin-top:15px !important;">' . wfMsg('top-fans-by-category-nav-header') . '</h1>';
        }
        foreach ($lines as $line) {
            if (strpos($line, '*') !== 0) {
                continue;
            } else {
                $line = explode('|', trim($line, '* '), 2);
                $stat = $line[0];
                $link_text = $line[1];
                $out .= '<p> <a href="' . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
            }
        }
        $out .= '</div>';
        $x = 1;
        $out .= '<div class="top-users">';
        $last_level = '';
        foreach ($user_list as $user) {
            $user_title = Title::makeTitle(NS_USER, $user['user_name']);
            $avatar = new wAvatar($user['user_id'], 'm');
            $commentIcon = $avatar->getAvatarImage();
            // Break list into sections based on User Level if it's defined for this site
            if (is_array($wgUserLevels)) {
                $user_level = new UserLevel(number_format($user['points']));
                if ($user_level->getLevelName() != $last_level) {
                    $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\">\r\n\t\t\t\t\t\t{$user_level->getLevelName()}\r\n\t\t\t\t\t\t</div></div>";
                }
                $last_level = $user_level->getLevelName();
            }
            $out .= "<div class=\"top-fan-row\">\r\n\t\t\t\t<span class=\"top-fan-num\">{$x}.</span>\r\n\t\t\t\t<span class=\"top-fan\">\r\n\t\t\t\t\t<img src='{$wgUploadPath}/avatars/" . $commentIcon . "' alt='' border='' /> <a href='" . $user_title->escapeFullURL() . "'>" . $user['user_name'] . '</a>
				</span>';
            $out .= '<span class="top-fan-points"><b>' . number_format($user['points']) . '</b> ' . wfMsg('top-fans-points') . '</span>';
            $out .= '<div class="cleared"></div>';
            $out .= '</div>';
            $x++;
        }
        $out .= '</div><div class="cleared"></div>';
        $wgOut->addHTML($out);
    }
 /**
  * Get site followed users 
  *
  * @param $user:current username; $site_name:servername
  * @return array
  */
 public static function getSiteFollowersWithDetails($user, $site_name)
 {
     // return '';
     $dbr = wfGetDB(DB_SLAVE);
     $request = array();
     // $follower = UserUserFollow::getFollowedByUser( $user->getName() );
     $res = self::getSiteFollowers($user, $site_name);
     foreach ($res as $value) {
         $u_name = $value['user_name'];
         $temp['user'] = $u_name;
         // $temp['user'] = User::getEffectiveGroups($user);
         $userPage = Title::makeTitle(NS_USER, $u_name);
         $userPageURL = htmlspecialchars($userPage->getFullURL());
         $temp['userUrl'] = $userPageURL;
         $user_id = User::idFromName($u_name);
         $stats = new UserStats($user_id, $u_name);
         $stats_data = $stats->getUserStats();
         $user_level = new UserLevel($stats_data['points']);
         $temp['level'] = $user_level->getLevelName();
         $avatar = new wAvatar($user_id, 'm');
         $temp['url'] = $avatar->getAvatarURL();
         $tuser = User::newFromName($u_name);
         $temp['count'] = UserStats::getSiteEditsCount($tuser, $site_name);
         // if(in_array($u_name, $follower)){
         // 	$is_follow = 'Y';
         // }else{
         // 	$is_follow = 'N';
         // }
         // $temp['is_follow'] = $is_follow;
         $request[] = $temp;
     }
     foreach ($request as $key => $value) {
         $count[$key] = $value['count'];
     }
     array_multisort($count, SORT_DESC, $request);
     return $request;
 }
Example #8
0
	<div class="row">
		<?php 
echo $form->label($model, 'email');
?>
		<?php 
echo $form->textField($model, 'email', array('size' => 50, 'maxlength' => 50));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'user_level_id');
?>
		<?php 
echo $form->dropDownList($model, 'user_level_id', CHtml::listData(UserLevel::model()->findAll(), 'id', 'name'), array('empty' => ""));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'last_ip_address');
?>
		<?php 
echo $form->textField($model, 'last_ip_address', array('size' => 60, 'maxlength' => 255));
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton('Search');
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = UserLevel::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #10
0
 /**
  * GET USER DETAIL INFO
  * @param user UserName
  * 
  * @return result array
  */
 public function getUserAllInfo()
 {
     global $wgUser;
     $dbr = wfGetDB(DB_SLAVE);
     $result = array();
     $result['username'] = $this->username;
     $user_id = $this->userid;
     $avatar = new wAvatar($user_id, 'ml');
     $result['url'] = $avatar->getAvatarURL();
     $gender = $this->getGender();
     $status = $this->getStatus();
     $result['gender'] = $gender;
     $result['status'] = $status;
     //¹Ø×¢Êý
     $usercount = UserUserFollow::getFollowingCount($this->user);
     $result['usercounts'] = $usercount;
     //±»¹Ø×¢Êý
     $usercounted = UserUserFollow::getFollowerCount($this->user);
     $result['usercounted'] = $usercounted;
     //±à¼­Êý
     $stats = new UserStats($this->userid, $this->username);
     $stats_data = $stats->getUserStats();
     $result['editcount'] = $stats_data['edits'];
     //µÈ¼¶
     $user_level = new UserLevel($stats_data['points']);
     $result['level'] = $user_level->getLevelName();
     //ÊÇ·ñ¹Ø×¢
     if ($wgUser->isLoggedIn()) {
         $current_user = $wgUser->getName();
         // return $current_user;
         $follower = UserUserFollow::getFollowedByUser($current_user);
         if (in_array($this->username, $follower)) {
             $result['is_follow'] = 'Y';
         } else {
             $result['is_follow'] = 'N';
         }
         //¹²Í¬¹Ø×¢
         $cfollow = array();
         $t_user = $this->username;
         $ufollower = UserUserFollow::getFollowedByUser($t_user);
         if ($ufollower != null) {
             foreach ($follower as $valuea) {
                 if (in_array($valuea, $ufollower)) {
                     $cfollow[] = $valuea;
                 }
             }
         } else {
             $cfollow = array();
         }
         $result['commonfollow'] = $cfollow;
         //ÎÒ¹Ø×¢µÄË­Ò²¹Ø×¢Ëû
         $result['minefollowerhim'] = self::getFollowingFollowsUser($t_user, $current_user);
     } else {
         $result['is_follow'] = '';
         $result['commonfollow'] = '';
         $result['minefollowerhim'] = '';
     }
     // $wgMemc->set( $key, $result );
     return $result;
 }
 public function actionDelete($id)
 {
     UserLevel::model()->deleteByPk($id);
     Yii::app()->user->setFlash('success', "Data deleted.");
     $this->redirect(array('index'));
 }
Example #12
0
 static function showPage()
 {
     global $wgUser, $wgParser;
     $templateParser = new TemplateParser(__DIR__ . '/View');
     $output = '';
     // Prevent E_NOTICE
     //user login
     if ($wgUser->isLoggedIn()) {
         $login = true;
     } else {
         $login = false;
         $register = Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), '注册', array(), array('type' => 'signup'));
         $active = 'active';
         $inactive = 'in active';
     }
     // check mobile device
     $mobile = mobiledetect();
     $mobileUser = $mobile && $login;
     if (!$mobileUser) {
         //right data
         $fileCount = AllSitesInfo::getAllUploadFileCount();
         $siteCount = AllSitesInfo::getSiteCountNum();
         $userCount = AllSitesInfo::getUsreCountNum();
         $editCount = AllSitesInfo::getAllSiteEditCount();
         $pageCount = AllSitesInfo::getAllPageCount();
         $userName = $wgUser->getName();
         $usreId = $wgUser->getId();
         $avatar = new wAvatar($usreId, 'l');
         $userAvatar = $avatar->getAvatarURL();
         //level
         $stats = new UserStats($usreId, $userName);
         $stats_data = $stats->getUserStats();
         $user_level = new UserLevel($stats_data['points']);
         $level_link = Title::makeTitle(NS_HELP, wfMessage('user-profile-userlevels-link')->inContentLanguage()->text());
         $levelUrl = htmlspecialchars($level_link->getFullURL());
         $userLevel = $user_level->getLevelName();
         //user info
         $notice = SpecialPage::getTitleFor('ViewFollows');
         $contributions = SpecialPage::getTitleFor('Contributions');
         $userEdit = Linker::link($contributions, $stats_data['edits'], array(), array('target' => $userName, 'contribs' => 'user'));
         $follower = Linker::link($notice, UserUserFollow::getFollowingCount($wgUser), array('id' => 'user-following-count'), array('user' => $userName, 'rel_type' => 1));
         $followee = Linker::link($notice, UserUserFollow::getFollowerCount($wgUser), array('id' => 'user-follower-count'), array('user' => $userName, 'rel_type' => 2));
         //siterank
         $yesterday = date('Y-m-d', strtotime('-1 days'));
         $allSiteRank = AllSitesInfo::getAllSitesRankData('', $yesterday);
         $siteRank = array_slice($allSiteRank, 0, 10);
         $siteInfo = array();
         foreach ($siteRank as $key => $value) {
             $siteRank[$key]['site_prefix'] = HuijiPrefix::prefixToSiteName($value['site_prefix']);
             $siteRank[$key]['site_url'] = HuijiPrefix::prefixToUrl($value['site_prefix']);
             $siteInfo = AllSitesInfo::getPageInfoByPrefix($value['site_prefix']);
             $siteRank[$key]['totalEdits'] = $siteInfo['totalEdits'];
             $siteRank[$key]['totalArticles'] = $siteInfo['totalArticles'];
             $siteRank[$key]['totalPages'] = $siteInfo['totalPages'];
             $siteRank[$key]['totalUsers'] = $siteInfo['totalUsers'];
         }
         //userrank
         $weekRank = UserStats::getUserRank(10, 'week');
         $monthRank = UserStats::getUserRank(20, 'month');
         $totalRank = UserStats::getUserRank(20, 'total');
         //小蓝格
         $ueb = new UserEditBox();
         $editBox = $editData = array();
         $userEditInfo = $ueb->getUserEditInfo($usreId);
         $maxlen = $currentMaxlen = 0;
         //init variables.
         foreach ($userEditInfo as $value) {
             if (is_object($value) && !empty($value->_id) && $value->value > 0) {
                 $editBox[$value->_id] = $value->value;
                 $editData[] = $value->_id;
             }
         }
         $today = date("Y-m-d");
         $yesterday = date("Y-m-d", strtotime("-1 day"));
         $editBox[$today] = UserEditBox::getTodayEdit($usreId);
         if (!empty($editBox[$today])) {
             $editData[] = $today;
         }
         $totalEdit = count($editData);
         if ($totalEdit > 0) {
             $resArr[] = strtotime($editData[0]);
             $maxlen = 1;
         }
         for ($k = 1; $k < count($editData); $k++) {
             if (in_array(strtotime($editData[$k]) - 86400, $resArr)) {
                 $resArr[] = strtotime($editData[$k]);
                 if (count($resArr) > $maxlen) {
                     $maxlen = count($resArr);
                 }
             } else {
                 $resArr = array();
                 $resArr[] = strtotime($editData[$k]);
             }
             if ($resArr[count($resArr) - 1] == strtotime($today) || $resArr[count($resArr) - 1] == strtotime($yesterday)) {
                 $currentMaxlen = count($resArr);
             } else {
                 $currentMaxlen = 0;
             }
         }
         $lange = '<svg width="710" height="110" class=" ">
                  <g transform="translate(20, 20)">';
         $n = 676 / 13;
         $dateArr = array();
         for ($k = 0; $k < 365; $k++) {
             $dateArr[] = date('Y-m-d', strtotime("-{$k} day"));
         }
         $desdateArr = array_reverse($dateArr);
         $translate = array();
         for ($i = 0; $i <= $n; $i++) {
             $trani = $i * 13;
             $lange .= '<g transform="translate(' . $trani . ', 0)">';
             $dayofweek = date('w', strtotime($desdateArr[0]));
             if ($i == 0) {
                 $j = $dayofweek;
                 $start = 0;
                 $m = 7 - $dayofweek;
             } else {
                 $j = 0;
                 $m = 7;
                 $start = $i * 7 - $dayofweek;
             }
             $zoneDate = array_slice($desdateArr, $start, $m);
             foreach ($zoneDate as $val) {
                 $arrDate[$j] = $val;
                 $y = $j * 13;
                 $dataCount = isset($editBox[$val]) ? $editBox[$val] : 0;
                 if ($dataCount == 0) {
                     $color = '#eee';
                 } elseif ($dataCount > 0 && $dataCount <= 8) {
                     $color = '#86beee';
                 } elseif ($dataCount > 8 && $dataCount <= 21) {
                     $color = '#5ea2de';
                 } elseif ($dataCount > 21 && $dataCount <= 55) {
                     $color = '#256fb1';
                 } else {
                     $color = '#0d5493';
                 }
                 $lange .= '<rect class="day" width="11" height="11" y="' . $y . '" fill="' . $color . '" data-count="' . $dataCount . '" data-date="' . $val . '" title="' . $val . ' 编辑' . $dataCount . '次"></rect>';
                 $j = $j >= 7 ? 0 : $j + 1;
             }
             if (!empty($arrDate[0])) {
                 $translate[$arrDate[0]] = $trani;
             }
             $lange .= '</g>';
         }
         $moninit = 1;
         for ($p = 0; $p < 12; $p++) {
             $year = date('Y') - 1;
             $mon = date('m') + $p + 1;
             if ($mon > 12) {
                 $mon = $moninit++;
                 $year = date('Y');
             }
             $sunDay = UserEditBox::getSunday($mon, $year);
             $Stime = strtotime($sunDay);
             $sunDay = date('Y-m-d', $Stime);
             if (!isset($translate[$sunDay])) {
                 $Suntime = strtotime($sunDay);
                 $Sundate = date('Y', $Suntime) - 1;
                 $sunDay = UserEditBox::getSunday($mon, $Sundate);
             }
             foreach ($translate as $key => $value) {
                 if (strtotime($key) == strtotime($sunDay)) {
                     $x = $value;
                 }
             }
             $lange .= '<text x="' . $x . '" y="-5" class="' . $year . '">' . $mon . '月</text>';
         }
         $lange .= ' <text text-anchor="middle" class="wday" dx="-10" dy="9" style="display: none;">S</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="22">M</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="35" style="display: none;">T</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="48">W</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="61" style="display: none;">T</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="74">F</text>
                  <text text-anchor="middle" class="wday" dx="-10" dy="87" style="display: none;">S</text>
                </g>
              </svg>';
         //url helpManual huijitramac
         $helpManual = 'http://www.huiji.wiki/wiki/%E5%B8%AE%E5%8A%A9:%E7%BC%96%E8%BE%91%E6%89%8B%E5%86%8C';
         $tarmac = 'http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BAwiki:%E7%81%B0%E6%9C%BA%E5%81%9C%E6%9C%BA%E5%9D%AA';
         $contact = 'http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BAwiki:%E8%81%94%E7%B3%BB%E6%88%91%E4%BB%AC';
     }
     if ($login) {
         // follow
         $followUserCount = UserUserFollow::getFollowingCount($wgUser);
         if ($followUserCount >= 5) {
             $userHidden = true;
         } else {
             $userHidden = false;
         }
         $followSiteCount = UserSiteFollow::getFollowingCount($wgUser);
         if ($followSiteCount >= 5) {
             $siteHidden = true;
         } else {
             $siteHidden = false;
         }
         //recommend user $weekRank $monthRank  $totalRank
         $uuf = new UserUserFollow();
         if (count($weekRank) >= 8) {
             $recommend = UserStats::getUserRank(10, 'week');
         } elseif (count($monthRank) >= 8) {
             $recommend = UserStats::getUserRank(20, 'month');
         } else {
             $recommend = UserStats::getUserRank(20, 'total');
         }
         $recommendRes = array();
         $flres = array();
         foreach ($recommend as $value) {
             $tuser = User::newFromName($value['user_name']);
             $isFollow = $uuf->checkUserUserFollow($wgUser, $tuser);
             if (!$isFollow && $value['user_name'] != $userName) {
                 $flres['avatar'] = $value['avatarImage'];
                 $flres['username'] = $value['user_name'];
                 $flres['userurl'] = $value['user_url'];
                 $recommendRes[] = $flres;
             }
         }
         $recommendRes = array_slice($recommendRes, 0, 5);
         //recommend site
         $usf = new UserSiteFollow();
         // $recSite = array_slice($allSiteRank,0 ,5);
         $recommendSite = array();
         foreach ($allSiteRank as $value) {
             $isFollowSite = $usf->checkUserSiteFollow($wgUser, $value['site_prefix']);
             if ($isFollowSite == false) {
                 $fsres['s_name'] = HuijiPrefix::prefixToSiteName($value['site_prefix']);
                 $fsres['s_url'] = HuijiPrefix::prefixToUrl($value['site_prefix']);
                 $fsres['s_prefix'] = $value['site_prefix'];
                 $fsres['s_avatar'] = (new wSiteAvatar($value['site_prefix'], 'l'))->getAvatarHtml();
                 $recommendSite[] = $fsres;
             }
         }
         $recommendSite = array_slice($recommendSite, 0, 5);
         if ($login && !$mobile) {
             $infoHeader = wfMessage('info-header-user')->parseAsBlock();
         } elseif (!$login) {
             $infoHeader = wfMessage('info-header-anon')->parseAsBlock();
         } else {
             $infoHeader = '';
         }
     }
     $output .= $templateParser->processTemplate('frontpage', array('mobileUser' => $mobileUser, 'infoHeader' => $infoHeader, 'fileCount' => $fileCount, 'siteCount' => $siteCount, 'userCount' => $userCount, 'editCount' => $editCount, 'pageCount' => $pageCount, 'userName' => $userName, 'userAvatar' => $userAvatar, 'levelUrl' => $levelUrl, 'userLevel' => $userLevel, 'userEdit' => $userEdit, 'follower' => $follower, 'followee' => $followee, 'siteRank' => $siteRank, 'weekRank' => $weekRank, 'monthRank' => $monthRank, 'totalRank' => $totalRank, 'lange' => $lange, 'login' => $login, 'register' => $register, 'userHidden' => $userHidden, 'siteHidden' => $siteHidden, 'active' => $active, 'inactive' => $inactive, 'recommendSite' => $recommendSite, 'recContent' => $recContent, 'followUserCount' => $followUserCount, 'followSiteCount' => $followSiteCount, 'helpManual' => $helpManual, 'tarmac' => $tarmac, 'contact' => $contact));
     return $output;
 }
 /**
  * get site followers
  * @param  boolean $expanded if true return user detail info,eles return simple info
  * @return array
  */
 public function getFollowers($expanded = false)
 {
     if (!$this->mFollowers) {
         // return $this->mFollowers;
         $usf = new UserSiteFollow();
         $this->mFollowers = $usf->getSiteFollowers($this->mPrefix);
         $siteCache = self::getSiteCache();
         $siteCache->set($this->mPrefix, $this);
         //return $this->mFollowers;
     }
     if (!$expanded) {
         return $this->mFollowers;
     } else {
         $request = array();
         foreach ($this->mFollowers as $value) {
             $u_name = $value['user_name'];
             $temp['user'] = $u_name;
             // $temp['user'] = User::getEffectiveGroups($user);
             $userPage = Title::makeTitle(NS_USER, $u_name);
             $userPageURL = htmlspecialchars($userPage->getFullURL());
             $temp['userUrl'] = $userPageURL;
             $user_id = User::idFromName($u_name);
             $temp['userId'] = $user_id;
             $stats = new UserStats($user_id, $u_name);
             $stats_data = $stats->getUserStats();
             $user_level = new UserLevel($stats_data['points']);
             $temp['level'] = $user_level->getLevelName();
             $avatar = new wAvatar($user_id, 'm');
             $temp['url'] = $avatar->getAvatarURL();
             $tuser = User::newFromName($u_name);
             $temp['count'] = UserStats::getSiteEditsCount($tuser, $this->mPrefix);
             // if(in_array($u_name, $follower)){
             // 	$is_follow = 'Y';
             // }else{
             // 	$is_follow = 'N';
             // }
             // $temp['is_follow'] = $is_follow;
             $request[] = $temp;
         }
         foreach ($request as $key => $value) {
             $count[$key] = $value['count'];
         }
         array_multisort($count, SORT_DESC, $request);
         return $request;
     }
 }
    /**
     * Get the header for the social profile page, which includes the user's
     * points and user level (if enabled in the site configuration) and lots
     * more.
     *
     * @param $user_id Integer: user ID
     * @param $user_name String: user name
     */
    function getProfileTop($user_id, $user_name)
    {
        global $wgTitle, $wgUser, $wgUploadPath, $wgLang;
        global $wgUserLevels;
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $user_level = new UserLevel($stats_data['points']);
        $level_link = Title::makeTitle(NS_HELP, wfMsgForContent('user-profile-userlevels-link'));
        if (!$this->profile_data) {
            $profile = new UserProfile($user_name);
            $this->profile_data = $profile->getProfile();
        }
        $profile_data = $this->profile_data;
        // Variables and other crap
        $page_title = $wgTitle->getText();
        $title_parts = explode('/', $page_title);
        $user = $title_parts[0];
        $id = User::idFromName($user);
        $user_safe = urlencode($user);
        // Safe urls
        $add_relationship = SpecialPage::getTitleFor('AddRelationship');
        $remove_relationship = SpecialPage::getTitleFor('RemoveRelationship');
        $give_gift = SpecialPage::getTitleFor('GiveGift');
        $send_board_blast = SpecialPage::getTitleFor('SendBoardBlast');
        $update_profile = SpecialPage::getTitleFor('UpdateProfile');
        $watchlist = SpecialPage::getTitleFor('Watchlist');
        $contributions = SpecialPage::getTitleFor('Contributions', $user);
        $send_message = SpecialPage::getTitleFor('UserBoard');
        $upload_avatar = SpecialPage::getTitleFor('UploadAvatar');
        $user_page = Title::makeTitle(NS_USER, $user);
        $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user);
        $user_wiki = Title::makeTitle(NS_USER_WIKI, $user);
        if ($id != 0) {
            $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
        }
        $avatar = new wAvatar($this->user_id, 'l');
        wfDebug('profile type: ' . $profile_data['user_page_type'] . "\n");
        $output = '';
        if ($this->isOwner()) {
            $toggle_title = SpecialPage::getTitleFor('ToggleUserPage');
            if ($this->profile_data['user_page_type'] == 1) {
                $toggleMessage = wfMsg('user-type-toggle-old');
            } else {
                $toggleMessage = wfMsg('user-type-toggle-new');
            }
            $output .= '<div id="profile-toggle-button">
				<a href="' . $toggle_title->escapeFullURL() . '" rel="nofollow">' . $toggleMessage . '</a>
			</div>';
        }
        $output .= '<div id="profile-image">
			<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />
		</div>';
        $output .= '<div id="profile-right">';
        $output .= '<div id="profile-title-container">
				<div id="profile-title">' . $user_name . '</div>';
        if ($wgUserLevels) {
            $output .= '<div id="points-level">
					<a href="' . $level_link->escapeFullURL() . '">' . wfMsgExt('user-profile-points', 'parsemag', $stats_data['points']) . '</a>
					</div>
					<div id="honorific-level">
						<a href="' . $level_link->escapeFullURL() . '" rel="nofollow">(' . $user_level->getLevelName() . ')</a>
					</div>';
        }
        $output .= '<div class="cleared"></div>
			</div>
			<div class="profile-actions">';
        if ($this->isOwner()) {
            $output .= $wgLang->pipeList(array('<a href="' . $update_profile->escapeFullURL() . '">' . wfMsg('user-edit-profile') . '</a>', '<a href="' . $upload_avatar->escapeFullURL() . '">' . wfMsg('user-upload-avatar') . '</a>', '<a href="' . $watchlist->escapeFullURL() . '">' . wfMsg('user-watchlist') . '</a>', ''));
        } elseif ($wgUser->isLoggedIn()) {
            if ($relationship == false) {
                $output .= $wgLang->pipeList(array('<a href="' . $add_relationship->escapeFullURL('user='******'&rel_type=1') . '" rel="nofollow">' . wfMsg('user-add-friend') . '</a>', '<a href="' . $add_relationship->escapeFullURL('user='******'&rel_type=2') . '" rel="nofollow">' . wfMsg('user-add-foe') . '</a>', ''));
            } else {
                if ($relationship == 1) {
                    $output .= $wgLang->pipeList(array('<a href="' . $remove_relationship->escapeFullURL('user='******'">' . wfMsg('user-remove-friend') . '</a>', ''));
                }
                if ($relationship == 2) {
                    $output .= $wgLang->pipeList(array('<a href="' . $remove_relationship->escapeFullURL('user='******'">' . wfMsg('user-remove-foe') . '</a>', ''));
                }
            }
            global $wgUserBoard;
            if ($wgUserBoard) {
                $output .= '<a href="' . $send_message->escapeFullURL('user='******'&conv=' . $user_safe) . '" rel="nofollow">' . wfMsg('user-send-message') . '</a>';
                $output .= wfMsgExt('pipe-separator', 'escapenoentities');
            }
            $output .= '<a href="' . $give_gift->escapeFullURL('user='******'" rel="nofollow">' . wfMsg('user-send-gift') . '</a>';
            $output .= wfMsgExt('pipe-separator', 'escapenoentities');
        }
        $output .= '<a href="' . $contributions->escapeFullURL() . '" rel="nofollow">' . wfMsg('user-contributions') . '</a> ';
        // Links to User:user_name from User_profile:
        if ($wgTitle->getNamespace() == NS_USER_PROFILE && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0) {
            $output .= '| <a href="' . $user_page->escapeFullURL() . '" rel="nofollow">' . wfMsg('user-page-link') . '</a> ';
        }
        // Links to User:user_name from User_profile:
        if ($wgTitle->getNamespace() == NS_USER && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0) {
            $output .= '| <a href="' . $user_social_profile->escapeFullURL() . '" rel="nofollow">' . wfMsg('user-social-profile-link') . '</a> ';
        }
        if ($wgTitle->getNamespace() == NS_USER && (!$this->profile_data['user_id'] || $this->profile_data['user_page_type'] == 1)) {
            $output .= '| <a href="' . $user_wiki->escapeFullURL() . '" rel="nofollow">' . wfMsg('user-wiki-link') . '</a>';
        }
        $output .= '</div>

		</div>';
        return $output;
    }
Example #15
0
echo $form->labelEx($model, 'description');
?>
		<?php 
echo $form->textField($model, 'description', array('size' => 50, 'maxlength' => 50));
?>
		<?php 
echo $form->error($model, 'description');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'p_id');
?>
		<?php 
echo $form->dropDownList($model, 'p_id', array('0' => 'Parent') + CHtml::listData(UserLevel::model()->findAll(), 'id', 'name'), NULL);
?>
		<?php 
echo $form->error($model, 'p_id');
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
?>
	</div>

<?php 
$this->endWidget();
?>
Example #16
0
 /**
  * Display all the comments for the current page.
  * CSS and JS is loaded in Comment.php, function displayComments.
  */
 function display()
 {
     global $wgUser, $wgOut, $wgScriptPath, $wgMemc, $wgUserLevels;
     $output = '';
     // Try cache
     $key = wfMemcKey('comment', 'list', $this->PageID);
     $data = $wgMemc->get($key);
     if (!$data) {
         wfDebug("Loading comments for page {$this->PageID} from DB\n");
         $comments = $this->getCommentList();
         $wgMemc->set($key, $comments);
     } else {
         wfDebug("Loading comments for page {$this->PageID} from cache\n");
         $comments = $data;
     }
     // Try cache for voted list for this user
     $voted = array();
     if ($wgUser->isLoggedIn()) {
         $key = wfMemcKey('comment', 'voted', $this->PageID, 'user_id', $wgUser->getID());
         $data = $wgMemc->get($key);
         if (!$data) {
             $voted = $this->getCommentVotedList();
             $wgMemc->set($key, $voted);
         } else {
             wfDebug("Loading comment voted for page {$this->PageID} for user {$wgUser->getID()} from cache\n");
             $voted = $data;
         }
     }
     // Load complete blocked list for logged in user so they don't see their comments
     $block_list = array();
     if ($wgUser->getID() != 0) {
         $block_list = $this->getBlockList($wgUser->getId());
     }
     $AFCounter = 1;
     $AFBucket = array();
     if ($comments) {
         foreach ($comments as $comment) {
             $CommentScore = $comment['Comment_Score'];
             $CommentPosterLevel = '';
             if ($comment['Comment_user_id'] != 0) {
                 $title = Title::makeTitle(NS_USER, $comment['Comment_Username']);
                 $CommentPoster = '<a href="' . $title->escapeFullURL() . '" rel="nofollow">' . $comment['Comment_Username'] . '</a>';
                 $CommentReplyTo = $comment['Comment_Username'];
                 if ($wgUserLevels && class_exists('UserLevel')) {
                     $user_level = new UserLevel($comment['Comment_user_points']);
                     $CommentPosterLevel = "{$user_level->getLevelName()}";
                 }
             } else {
                 if (!array_key_exists($comment['Comment_Username'], $AFBucket)) {
                     $AFBucket[$comment['Comment_Username']] = $AFCounter;
                     $AFCounter++;
                 }
                 $CommentPoster = wfMsgForContent('comment-anon-name') . ' #' . $AFBucket[$comment['Comment_Username']];
                 $CommentReplyTo = wfMsgForContent('comment-anon-name');
             }
             // Comment delete button for privileged users
             $dlt = '';
             if ($wgUser->isAllowed('commentadmin')) {
                 $dlt = " | <span class=\"c-delete\"><a href=\"javascript:document.commentform.commentid.value={$comment['CommentID']};document.commentform.submit();\">" . wfMsg('comment-delete-link') . '</a></span>';
             }
             // Reply Link (does not appear on child comments)
             $replyRow = '';
             if ($wgUser->isAllowed('comment')) {
                 if ($comment['Comment_Parent_ID'] == 0) {
                     if ($replyRow) {
                         $replyRow .= ' | ';
                     }
                     $replyRow .= " | <a href=\"#end\" rel=\"nofollow\" class=\"comments-reply-to\" data-comment-id=\"{$comment['CommentID']}\" data-comments-safe-username=\"" . htmlspecialchars($CommentReplyTo, ENT_QUOTES) . '">' . wfMsg('comment-reply') . '</a>';
                 }
             }
             if ($comment['Comment_Parent_ID'] == 0) {
                 $container_class = 'full';
                 $comment_class = 'f-message';
             } else {
                 $container_class = 'reply';
                 $comment_class = 'r-message';
             }
             // Display Block icon for logged in users for comments of users
             // that are already not in your block list
             $block_link = '';
             if ($wgUser->getID() != 0 && $wgUser->getID() != $comment['Comment_user_id'] && !in_array($comment['Comment_Username'], $block_list)) {
                 $block_link = '<a href="javascript:void(0);" rel="nofollow" class="comments-block-user" data-comments-safe-username="******" data-comments-comment-id="' . $comment['CommentID'] . '" data-comments-user-id="' . $comment['Comment_user_id'] . "\">\n\t\t\t\t\t<img src=\"{$wgScriptPath}/extensions/Comments/images/block.png\" border=\"0\" alt=\"\"/>\n\t\t\t\t</a>";
             }
             // If you are ignoring the author of the comment, display message in comment box,
             // along with a link to show the individual comment
             $hide_comment_style = '';
             if (in_array($comment['Comment_Username'], $block_list)) {
                 $hide_comment_style = 'display:none;';
                 $blockListTitle = SpecialPage::getTitleFor('CommentIgnoreList');
                 $output .= "<div id=\"ignore-{$comment['CommentID']}\" class=\"c-ignored {$container_class}\">\n";
                 $output .= wfMsgExt('comment-ignore-message', 'parsemag');
                 $output .= '<div class="c-ignored-links">' . "\n";
                 $output .= "<a href=\"javascript:void(0);\" data-comment-id=\"{$comment['CommentID']}\">" . wfMsg('comment-show-comment-link') . '</a> | ';
                 $output .= "<a href=\"{$blockListTitle->escapeFullURL()}\">" . wfMsg('comment-manage-blocklist-link') . '</a>';
                 $output .= '</div>' . "\n";
                 $output .= '</div>' . "\n";
             }
             // Default avatar image, if SocialProfile extension isn't
             // enabled
             global $wgCommentsDefaultAvatar;
             $avatar_img = '<img src="' . $wgCommentsDefaultAvatar . '" alt="" border="0" />';
             // If SocialProfile *is* enabled, then use its wAvatar class
             // to get the avatars for each commenter
             if (class_exists('wAvatar')) {
                 $avatar = new wAvatar($comment['Comment_user_id'], 'ml');
                 $avatar_img = $avatar->getAvatarURL() . "\n";
             }
             $output .= "<div id=\"comment-{$comment['CommentID']}\" class=\"c-item {$container_class}\" style=\"{$hide_comment_style}\">" . "\n";
             $output .= "<div class=\"c-avatar\">{$avatar_img}</div>" . "\n";
             $output .= '<div class="c-container">' . "\n";
             $output .= '<div class="c-user">' . "\n";
             $output .= "{$CommentPoster}";
             $output .= "<span class=\"c-user-level\">{$CommentPosterLevel}</span> {$block_link}" . "\n";
             wfSuppressWarnings();
             // E_STRICT bitches about strtotime()
             $output .= '<div class="c-time">' . wfMsg('comments-time-ago', self::getTimeAgo(strtotime($comment['Comment_Date']))) . '</div>' . "\n";
             wfRestoreWarnings();
             $output .= '<div class="c-score">' . "\n";
             if ($this->AllowMinus == true || $this->AllowPlus == true) {
                 $output .= '<span class="c-score-title">' . wfMsg('comment-score-text') . " <span id=\"Comment{$comment['CommentID']}\">{$CommentScore}</span></span>";
                 // Voting is possible only when database is unlocked
                 if (!wfReadOnly()) {
                     if (!in_array($comment['CommentID'], $voted)) {
                         // You can only vote for other people's comments,
                         // not for your own
                         if ($wgUser->getName() != $comment['Comment_Username']) {
                             $output .= "<span id=\"CommentBtn{$comment['CommentID']}\">";
                             if ($this->AllowPlus == true) {
                                 $output .= $this->getVoteLink($comment['CommentID'], 1);
                             }
                             if ($this->AllowMinus == true) {
                                 $output .= $this->getVoteLink($comment['CommentID'], -1);
                             }
                             $output .= '</span>';
                         } else {
                             $output .= wfMsg('comment-you');
                         }
                     } else {
                         // Already voted?
                         $output .= '<img src="' . $wgScriptPath . '/extensions/Comments/images/voted.gif" border="0" alt="" />' . wfMsg('comment-voted-label');
                     }
                 }
             }
             $output .= '</div>' . "\n";
             // $wgTitle points to Special:CommentListGet...and that special
             // page shouldn't even exist, so we certainly don't want to
             // advertise it...let's point the permalink to the current page
             // instead :)
             $title = Title::newFromID($this->PageID);
             $output .= '</div>' . "\n";
             $output .= "<div class=\"c-comment {$comment_class}\">" . "\n";
             $output .= $this->getCommentText($comment['Comment_Text']);
             $output .= '</div>' . "\n";
             $output .= '<div class="c-actions">' . "\n";
             $output .= '<a href="' . $title->escapeFullURL() . "#comment-{$comment['CommentID']}\" rel=\"nofollow\">" . wfMsg('comment-permalink') . '</a> ';
             if ($replyRow || $dlt) {
                 $output .= "{$replyRow} {$dlt}" . "\n";
             }
             $output .= '</div>' . "\n";
             $output .= '</div>' . "\n";
             $output .= '<div class="cleared"></div>' . "\n";
             $output .= '</div>' . "\n";
         }
     }
     $output .= '<a id="end" name="end" rel="nofollow"></a>';
     return $output;
 }
 /**
  * before validate attributes
  */
 protected function beforeValidate()
 {
     $controller = strtolower(Yii::app()->controller->id);
     $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
     if (parent::beforeValidate()) {
         if ($this->isNewRecord) {
             $setting = OmmuSettings::model()->findByPk(1, array('select' => 'site_type, signup_username, signup_approve, signup_verifyemail, signup_random, signup_inviteonly, signup_checkemail'));
             $this->profile_id = 1;
             $this->salt = self::getUniqueCode();
             if (in_array($controller, array('o/admin', 'o/member'))) {
                 // Auto Approve Users
                 if ($setting->signup_approve == 1) {
                     $this->enabled = 1;
                 }
                 // Auto Verified Email User
                 if ($setting->signup_verifyemail == 1) {
                     $this->verified = 0;
                 }
                 // Generate user by admin
                 $this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : 0;
             } else {
                 $this->level_id = UserLevel::getDefault();
                 $this->enabled = $setting->signup_approve == 1 ? 1 : 0;
                 $this->verified = $setting->signup_verifyemail == 1 ? 0 : 1;
                 // Signup by Invite (Admin or User)
                 if ($setting->site_type == 1 && $setting->signup_inviteonly != 0) {
                     if ($setting->signup_checkemail == 1 && $this->inviteCode == '') {
                         $this->addError('inviteCode', 'Invite Code tidak boleh kosong.');
                     }
                     if ($this->email != '') {
                         $invite = UserInvites::getInvite(strtolower($this->email));
                         if ($invite != null) {
                             if ($invite->queue->member_id != 0) {
                                 $this->addError('email', 'Email anda sudah terdaftar sebagai user, silahkan login.');
                             } else {
                                 if ($setting->signup_inviteonly == 1 && $invite->queue->invite == 0) {
                                     $this->addError('email', 'Maaf invite hanya bisa dilakukan oleh admin');
                                 } else {
                                     if ($setting->signup_checkemail == 1) {
                                         $code = UserInvites::model()->findByAttributes(array('code' => $this->inviteCode), array('select' => 'queue_id, user_id, code'));
                                         if ($code == null) {
                                             $this->addError('inviteCode', 'Invite Code yang and masukan salah.');
                                         } else {
                                             $this->referenceId = $code->user_id;
                                         }
                                     }
                                 }
                             }
                         } else {
                             $this->addError('email', 'Email anda belum ada dalam daftar invite.');
                         }
                     } else {
                         if ($setting->signup_checkemail == 1) {
                             $this->addError('inviteCode', 'Invite Code yang and masukan salah, silahkan lengkapi input email');
                         }
                     }
                 }
             }
             // Username required
             if ($setting->signup_username == 1) {
                 if ($this->username != '') {
                     $user = self::model()->findByAttributes(array('username' => $this->username));
                     if ($user != null) {
                         $this->addError('username', 'Username already in use');
                     }
                 } else {
                     $this->addError('username', 'Username cannot be blank.');
                 }
             }
             // Random password
             if ($setting->signup_random == 1) {
                 $this->confirmPassword = $this->newPassword = self::getGeneratePassword();
                 $this->verified = 1;
             }
             $this->creation_ip = $_SERVER['REMOTE_ADDR'];
         } else {
             /**
              * Modify Mamber
              * = Admin modify member
              * = User modify
              */
             // Admin modify member
             if (in_array($currentAction, array('o/admin/edit', 'o/member/edit'))) {
                 $this->modified_date = date('Y-m-d H:i:s');
                 $this->modified_id = Yii::app()->user->id;
             } else {
                 if (!in_array($controller, array('password'))) {
                     $this->update_date = date('Y-m-d H:i:s');
                 }
                 $this->update_ip = $_SERVER['REMOTE_ADDR'];
             }
         }
     }
     return true;
 }
Example #18
0
 /**
  * Updates the total amount of points the user has.
  *
  * @return Array
  */
 public function updateTotalPoints()
 {
     global $wgEnableFacebook, $wgUserLevels;
     if ($this->user_id == 0) {
         return array();
     }
     $stats_data = array();
     if (is_array($wgUserLevels)) {
         // Load points before update
         $stats = new UserStats($this->user_id, $this->user_name);
         $stats_data = $stats->getUserStats();
         $points_before = $stats_data['points'];
         // Load Honorific Level before update
         $user_level = new UserLevel($points_before);
         $level_number_before = $user_level->getLevelNumber();
     }
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->select('user_stats', '*', array("stats_user_id = {$this->user_id}"), __METHOD__);
     $row = $dbw->fetchObject($res);
     if ($row) {
         // recaculate point total
         $new_total_points = 1000;
         if ($this->point_values) {
             foreach ($this->point_values as $point_field => $point_value) {
                 if ($this->stats_fields[$point_field]) {
                     $field = $this->stats_fields[$point_field];
                     $new_total_points += $point_value * $row->{$field};
                 }
             }
         }
         if ($wgEnableFacebook) {
             $s = $dbw->selectRow('fb_link_view_opinions', array('fb_user_id', 'fb_user_session_key'), array('fb_user_id_wikia' => $this->user_id), __METHOD__);
             if ($s !== false) {
                 $new_total_points += $this->point_values['facebook'];
             }
         }
         $dbw->update('user_stats', array('stats_total_points' => $new_total_points), array('stats_user_id' => $this->user_id), __METHOD__);
         // If user levels is in settings, check to see if user advanced with update
         if (is_array($wgUserLevels)) {
             // Get New Honorific Level
             $user_level = new UserLevel($new_total_points);
             $level_number_after = $user_level->getLevelNumber();
             // Check if the user advanced to a new level on this update
             if ($level_number_after > $level_number_before) {
                 $m = new UserSystemMessage();
                 $m->addMessage($this->user_name, 2, wfMessage('level-advanced-to', $user_level->getLevelName())->inContentLanguage()->parse());
                 $m->sendAdvancementNotificationEmail($this->user_id, $user_level->getLevelName());
             }
         }
         $this->clearCache();
     }
     return $stats_data;
 }
Example #19
0
echo $form->labelEx($model, 'email');
?>
		<?php 
echo $form->textField($model, 'email', array('size' => 50, 'maxlength' => 50));
?>
		<?php 
echo $form->error($model, 'email');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'user_level_id');
?>
		<?php 
echo $form->dropDownList($model, 'user_level_id', CHtml::listData(UserLevel::model()->findAll(), 'id', 'name'), NULL);
?>
        
		<?php 
echo $form->error($model, 'user_level_id');
?>
	</div>
    
    
    <?php 
if (!$model->isNewRecord) {
    ?>
        </br>
        <div class="row">
            <p class="note">Optional</p>
        </div>