Beispiel #1
0
 public function testGetName()
 {
     $this->User->setName('testuser');
     if ($this->User->getName() != 'testuser') {
         $this->fail();
     }
 }
 public function getHTML()
 {
     wfProfileIn(__METHOD__);
     if ($this->isVisible()) {
         $ownerName = $this->ownerUser->getName();
         $tmplData = array();
         $tmplData['ownerBadges'] = $this->getBadgesAnnotated();
         $tmplData['challengesBadges'] = $this->getChallengesAnnotated();
         $tmplData['title_no'] = wfMsg('achievements-profile-title-no', $ownerName);
         $tmplData['title'] = wfMsgExt('achievements-profile-title', array('parsemag'), $ownerName, $this->owner->getBadgesCount());
         $tmplData['title_challenges'] = wfMsg('achievements-profile-title-challenges', $ownerName);
         $tmplData['leaderboard_url'] = Skin::makeSpecialUrl("Leaderboard");
         if ($this->owner->getBadgesCount() > 0) {
             $rankingService = new AchRankingService();
             $tmplData['user_rank'] = $rankingService->getUserRankingPosition($this->ownerUser);
         }
         if ($this->viewerUser->isAllowed('editinterface')) {
             $tmplData['customize_url'] = Skin::makeSpecialUrl("AchievementsCustomize");
         }
         $template = new EasyTemplate(dirname(__FILE__) . '/../templates');
         $template->set_vars($tmplData);
         $out = $template->render('ProfileBox');
     } else {
         $out = '';
     }
     wfProfileOut(__METHOD__);
     return $out;
 }
Beispiel #3
0
 public function changeSubscription(User $user, array $addLists, array $deleteLists)
 {
     $email = $user->get($this->getConfig('email_field', 'email'));
     if (empty($email)) {
         return true;
     }
     // add custom fields info
     $fields = array();
     foreach ($this->getConfig('fields', array()) as $fn) {
         $fields['custom_' . $fn] = $user->get($fn);
     }
     foreach ($addLists as $listId) {
         $ret = $this->doRequest(array('id' => $listId, 'full_name' => $user->getName(), 'split_name' => $user->getName(), 'email' => $email, 'subscription_type' => 'E') + $fields);
         if (!$ret) {
             return false;
         }
     }
     foreach ($deleteLists as $listId) {
         $ret = $this->doRequest(array('id' => $listId, 'full_name' => $user->getName(), 'split_name' => $user->getName(), 'email' => $email, 'subscription_type' => 'E', 'arp_action' => 'UNS'));
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
Beispiel #4
0
 /**
  * @return bool|int|null
  */
 protected function saveContent()
 {
     global $wgLogRestrictions;
     $dbw = wfGetDB(DB_MASTER);
     $log_id = $dbw->nextSequenceValue('logging_log_id_seq');
     $this->timestamp = $now = wfTimestampNow();
     $data = array('log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $this->doer->getId(), 'log_user_text' => $this->doer->getName(), 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_page' => $this->target->getArticleId(), 'log_comment' => $this->comment, 'log_params' => $this->params);
     $dbw->insert('logging', $data, __METHOD__);
     $newId = !is_null($log_id) ? $log_id : $dbw->insertId();
     # And update recentchanges
     if ($this->updateRecentChanges) {
         $titleObj = SpecialPage::getTitleFor('Log', $this->type);
         RecentChange::notifyLog($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
     } elseif ($this->sendToUDP) {
         # Don't send private logs to UDP
         if (isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] != '*') {
             return true;
         }
         # Notify external application via UDP.
         # We send this to IRC but do not want to add it the RC table.
         $titleObj = SpecialPage::getTitleFor('Log', $this->type);
         $rc = RecentChange::newLogEntry($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
         $rc->notifyRC2UDP();
     }
     return $newId;
 }
Beispiel #5
0
 /**
  * Adds this new notification object to the backend storage.
  */
 protected function insert()
 {
     global $wgEchoBackend, $wgEchoNotifications;
     $row = array('notification_event' => $this->event->getId(), 'notification_user' => $this->user->getId(), 'notification_anon_ip' => $this->user->isAnon() ? $this->user->getName() : $this->user->getId(), 'notification_timestamp' => $this->timestamp, 'notification_read_timestamp' => $this->readTimestamp, 'notification_bundle_hash' => '', 'notification_bundle_display_hash' => '');
     // Get the bundle key for this event if web bundling is enabled
     $bundleKey = '';
     if (!empty($wgEchoNotifications[$this->event->getType()]['bundle']['web'])) {
         wfRunHooks('EchoGetBundleRules', array($this->event, &$bundleKey));
     }
     if ($bundleKey) {
         $hash = md5($bundleKey);
         $row['notification_bundle_hash'] = $hash;
         $lastStat = $wgEchoBackend->getLastBundleStat($this->user, $hash);
         // Use a new display hash if:
         // 1. there was no last bundle notification
         // 2. last bundle notification with the same hash was read
         if ($lastStat && !$lastStat->notification_read_timestamp) {
             $row['notification_bundle_display_hash'] = $lastStat->notification_bundle_display_hash;
         } else {
             $row['notification_bundle_display_hash'] = md5($bundleKey . '-display-hash-' . wfTimestampNow());
         }
     }
     $wgEchoBackend->createNotification($row);
     wfRunHooks('EchoCreateNotificationComplete', array($this));
 }
Beispiel #6
0
 public function profile()
 {
     $this->assertLoggedIn();
     try {
         //how do we find them?
         if ($this->args('id')) {
             $user = new User($this->args('id'));
         } else {
             if ($this->args('username')) {
                 $user = User::byUsername($this->args('username'));
             } else {
                 $user = new User();
             }
         }
         //did we really get someone?
         if (!$user->isHydrated()) {
             throw new Exception("Could not find that user.");
         }
         //set our title.
         if ($user->isMe()) {
             $this->setTitle("Welcome, " . $user->getName());
         } else {
             $this->setTitle("About " . $user->getName());
         }
         $this->set('user', $user);
         //$this->set('photo', $user->getProfileImage());
         //figure out our info.
         /** @var Collection $collection */
         $collection = $user->getActivityStream()->getPage(1, 25);
         $this->set('activities', $collection);
     } catch (Exception $e) {
         $this->setTitle('View User - Error');
         $this->set('megaerror', $e->getMessage());
     }
 }
Beispiel #7
0
 public function login(User $user)
 {
     $user->setChatroom($this);
     if (!array_key_exists($user->getName(), $this->users)) {
         $this->users[$user->getName()] = $user;
         printf('<font color="#0000dd">%sさんが入室しました</font><hr>', $user->getName());
     }
 }
 /**
  * @param  User $user
  * @return void
  **/
 public function login(User $user)
 {
     $user->setChatRoom($this);
     if (!array_key_exists($user->getName(), $this->users)) {
         $this->users[$user->getName()] = $user;
         echo sprintf('%sさんが入室しました', $user->getName());
     }
 }
Beispiel #9
0
 /**
  * @covers User::getName
  * @covers User::SetName
  */
 public function testSetName()
 {
     $name = "McGill";
     $actual = $this->user->getName();
     $this->assertNotEquals($name, $actual);
     $this->user->setName($name);
     $actual = $this->user->getName();
     $this->assertEquals($name, $actual);
 }
Beispiel #10
0
 public static function generateCode(User $user)
 {
     $rand = rand(100, 999);
     $date = date('mdy');
     $name = strtoupper($user->getName()[0] . $user->getName()[1]);
     $abbrev = '';
     foreach (explode(' ', $user->getAdmin()->getAdminRank()) as $word) {
         $abbrev .= strtoupper($word[0]);
     }
     return $date . $name . $abbrev . $rand;
 }
Beispiel #11
0
 /**
  * Creates user.
  *
  * @param User $user   The user object.
  *
  * @return string   The created user id.
  *
  * @throws UserExistsException
  */
 public function create(User $user)
 {
     if (!$this->isUniqueUserName($user->getName())) {
         throw new UserExistsException();
     }
     $sql = "\n\t\t\tINSERT INTO users\n\t\t\t\t(username, password_hash)\n\t\t\tVALUES\n\t\t\t\t(:_userName, :_passwordHash)\n\t\t\t";
     $sth = $this->pdo->prepare($sql);
     $params = array(':_userName' => $user->getName(), ':_passwordHash' => $user->getHashedPassword());
     $sth->execute($params);
     return $user->getName();
 }
Beispiel #12
0
 public function toJSON()
 {
     $json = array();
     $json['fields'] = array();
     $json['fields']['project'] = array("id" => $this->project->getId());
     $json['fields']['summary'] = $this->summary;
     $json['fields']['issuetype'] = array("id" => $this->issueType->getId());
     $json['fields']['assignee'] = array("name" => $this->assignee->getName());
     $json['fields']['reporter'] = array("name" => $this->reporter->getName());
     $json['fields']['labels'] = $this->labels;
     $json['fields']['description'] = $this->description;
     return $json;
 }
	protected function getFormFields() {
		return array(
			'From' => array(
				'type' => 'info',
				'raw' => 1,
				'default' => Linker::link(
					$this->getUser()->getUserPage(),
					htmlspecialchars( $this->getUser()->getName() )
				),
				'label-message' => 'emailfrom',
				'id' => 'mw-emailuser-sender',
			),
			'To' => array(
				'type' => 'info',
				'raw' => 1,
				'default' => Linker::link(
					$this->mTargetObj->getUserPage(),
					htmlspecialchars( $this->mTargetObj->getName() )
				),
				'label-message' => 'emailto',
				'id' => 'mw-emailuser-recipient',
			),
			'Target' => array(
				'type' => 'hidden',
				'default' => $this->mTargetObj->getName(),
			),
			'Subject' => array(
				'type' => 'text',
				'default' => $this->msg( 'defemailsubject',
					$this->getUser()->getName() )->inContentLanguage()->text(),
				'label-message' => 'emailsubject',
				'maxlength' => 200,
				'size' => 60,
				'required' => true,
			),
			'Text' => array(
				'type' => 'textarea',
				'rows' => 20,
				'cols' => 80,
				'label-message' => 'emailmessage',
				'required' => true,
			),
			'CCMe' => array(
				'type' => 'check',
				'label-message' => 'emailccme',
				'default' => $this->getUser()->getBoolOption( 'ccmeonemails' ),
			),
		);
	}
Beispiel #14
0
/**
 * Creates the profile image with border
 *
 * @param User $user
 * @return string
 */
function user_link(User $user)
{
    $str = sprintf('<div class="profile-image"><img src="%s" alt="%s" /></div>', url_for('@avatar?user_id=' . $user->getId()), $user->getName());
    $str .= '<div class="link">' . link_to($user->getName(), '/profile/' . $user->getUsername()) . '</div>';
    if ($user->getCountUserAward() > 0) {
        $str .= '<div class="award_img_main">';
    }
    for ($i = 0; $i < $user->getCountUserAward(); $i++) {
        $str .= '<div class="award_img"><img src="/images/award.gif"/></div>';
    }
    if ($user->getCountUserAward() > 0) {
        $str .= '</div>';
    }
    return $str;
}
Beispiel #15
0
 function createArticle()
 {
     $user = new User($this->mySQL);
     $news_item = $this->mySQL['r']->query("SELECT * FROM `news_articles` WHERE `ID`='" . $this->articleID . "'");
     $news = array();
     if ($news_item !== false && $news_item->num_rows != 0) {
         while ($item = $news_item->fetch_array()) {
             $article['author'] = $user->create($item['pub_a']);
             $article['author'] = $user->getName();
             $article['editer'] = $user->create($item['edit_a']);
             $article['editer'] = $user->getName();
             $article['title'] = $item['title'];
             if ($this->publish) {
                 $article['pub'] = "<small>Published: " . date("H:i:s, D d/m/Y", strtotime($item['t_p'])) . "</small>";
                 $article['edit'] = "<small>Edited: " . date("H:i:s, D d/m/Y", strtotime($item['t_e'])) . "</small>";
                 if ($item['t_p'] != $item['t_e']) {
                     $this->editPub = true;
                 } else {
                     $this->editPub = false;
                 }
             } else {
                 $article['edit'] = $article['pub'] = "";
             }
             if ($item['long'] == "") {
                 $this->long = false;
             } else {
                 $this->long = true;
             }
             if ($this->preview) {
                 $article['content'] = $item['short'];
             } else {
                 if ($item['long'] != "") {
                     $article['content'] = "<b>" . $item['short'] . "</b><br />" . "\n" . $item['long'];
                 } else {
                     $article['content'] = $item['short'];
                 }
             }
         }
     } else {
         $article = false;
     }
     $this->article = $article;
     if ($article === false) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Render the page
  * @param string $par The username of the user to display
  */
 public function executeWhenAvailable($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $out->addJsConfigVars(array('wgMFMaxDescriptionChars' => self::MAX_DESCRIPTION_CHARS));
     if ($par) {
         $this->targetUser = User::newFromName($par);
         $pageTitle = $this->targetUser ? $this->targetUser->getName() : $par;
         $out->setPageTitle($pageTitle);
         // Make sure this is a valid registered user and not an invalid username (e.g. ip see bug 56822)
         if ($this->targetUser && $this->targetUser->getId()) {
             $context = MobileContext::singleton();
             // if in beta redirect to the user page, i.e. User:Username
             if ($context->isBetaGroupMember()) {
                 $redirectTitle = Title::makeTitle(NS_USER, $this->targetUser->getName());
                 $out->redirect($redirectTitle->getLocalURL());
             } else {
                 // Prepare content
                 $templateParser = new TemplateParser(__DIR__);
                 $this->userInfo = new MobileUserInfo($this->targetUser);
                 $html = $templateParser->processTemplate('userprofile', $this->getTemplateData($templateParser));
                 $out->addHtml($html);
             }
         } else {
             $this->displayNoUserError('mobile-frontend-profile-nouser');
         }
     } else {
         $out->setPageTitle($this->msg('mobile-frontend-profile-title'));
         $this->displayNoUserError('mobile-frontend-profile-noargs');
     }
 }
 /**
  * Abort user creation if the username is that of the autocreation username.
  * @param $user User
  * @param $errorText
  * @return bool
  */
 public static function onAbortNewAccount(User $user, &$errorText)
 {
     $url = wfMessage('babel-url')->text();
     $errorText = wfMessage('babel-autocreate-abort', $url)->parse();
     $autoCreateUser = wfMessage('babel-autocreate-user')->inContentLanguage()->plain();
     return $user->getName() !== $autoCreateUser;
 }
Beispiel #18
0
 function login()
 {
     //登录
     if (isset($_POST['name'])) {
         $model = new User();
         if ($model->check()) {
             //检查用户输入的用户名和密码是否有效
             setcookie('user', $_POST['name']);
             //有效则将用户信息存入cookie和session中
             $_SESSION['name'] = $model->getName();
             $_SESSION['id'] = $model->getID();
             $_SESSION['role'] = $model->getRole();
             header('location:http://' . $_SERVER['HTTP_HOST'] . '/WeiXianPin/index.php');
             //重定向到主页
             exit;
         } else {
             $error = '用户名或密码错误,请重新登录';
         }
     } else {
         $error = '';
     }
     //没有提交登录表单,自然没错
     include 'login.html.php';
     //进入登录页面并显示错误信息(如果没有则不显示)
 }
    /**
     * Generate the generic "this page has been changed" e-mail text.
     */
    protected function composeCommonMailtext()
    {
        global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress;
        global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
        global $wgEnotifUseRealName, $wgRequest;
        $this->composed_common = true;
        if ($this->editor->isAnon()) {
            $pageEditor = wfMsgForContent('enotif_anon_editor', $this->editor->getName());
        } else {
            $pageEditor = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
        }
        // build the subject
        $this->subject = wfMessage('moodbar-enotif-subject')->params($pageEditor)->escaped();
        // build the body
        $targetUserName = $this->targetUser->getName();
        $links = $this->buildEmailLink();
        //text version, no need to escape since client will interpret it as plain text
        $textBody = wfMessage('moodbar-enotif-body')->params($targetUserName, $links['feedbackPageUrl'], $links['editorTalkPageUrl'], $this->response, $links['targetUserTalkPageUrl'], $pageEditor)->text();
        //html version, this is a little bit ugly as we have to make wiki link clickable in emails
        $action = $wgRequest->getVal('action');
        $wgRequest->setVal('action', 'render');
        $htmlBody = wfMsgExt('moodbar-enotif-body', array('parse'), $targetUserName, $links['feedbackPageUrl'], $links['editorTalkPageUrl'], '<div style="margin-left:20px; margin-right:20px;">"' . $this->response . '"</div>', $links['targetUserTalkPageUrl'], $pageEditor);
        $wgRequest->setVal('action', $action);
        // assemble the email body
        $this->body = <<<HTML
--{$this->mime_boundary}
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

{$textBody}

--{$this->mime_boundary}
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
\t<body>
\t\t{$htmlBody}
\t</body>
</html>

--{$this->mime_boundary}--
HTML;
        # Reveal the page editor's address as REPLY-TO address only if
        # the user has not opted-out and the option is enabled at the
        # global configuration level.
        $adminAddress = new MailAddress($wgPasswordSender, $wgPasswordSenderName);
        if ($wgEnotifRevealEditorAddress && $this->editor->getEmail() != '' && $this->editor->getOption('enotifrevealaddr')) {
            $editorAddress = new MailAddress($this->editor);
            if ($wgEnotifFromEditor) {
                $this->from = $editorAddress;
            } else {
                $this->from = $adminAddress;
                $this->replyto = $editorAddress;
            }
        } else {
            $this->from = $adminAddress;
            $this->replyto = new MailAddress($wgNoReplyAddress);
        }
    }
Beispiel #20
0
 /**
  *@depends testShouldExistsGetterForName             
  */
 public function testShouldDefineAndRetrieveTheName()
 {
     $name = 'diego';
     $instance = new User();
     $instance->setName($name);
     $this->assertEquals($name, $instance->getName());
 }
 public function add($word)
 {
     $words = $this->get();
     //        if word already is in list, remove it.
     if ($this->wordIsOnBlacklist($word)) {
         $this->removeWord($word);
     } else {
         if ($words) {
             $new_words = $words . " " . $word;
         } else {
             $new_words = $word;
         }
         global $link;
         if ($words) {
             $sql = "UPDATE blacklists " . "SET words = :newwords " . "WHERE username = :username;";
         } else {
             //                die("Tried to do an insert."); //TESTING
             $sql = "INSERT INTO blacklists(words, username) " . "VALUES(:newwords, :username);";
         }
         $stmt = $link->prepare($sql);
         $stmt->bindParam(":newwords", $new_words, PDO::PARAM_STR);
         $stmt->bindParam(":username", User::getName(), PDO::PARAM_STR);
         //OOPify this
         $stmt->execute();
         $stmt->closeCursor();
     }
 }
 /**
  * Create a CentralAuthUser object corresponding to the supplied User, and
  * cache it in the User object.
  * @param User $user
  *
  * @return CentralAuthUser
  */
 static function getInstance(User $user)
 {
     if (!isset($user->centralAuthObj)) {
         $user->centralAuthObj = new self($user->getName());
     }
     return $user->centralAuthObj;
 }
 /**
  * @param array $options
  *
  * @return Job
  */
 private function getJob(array $options)
 {
     $params = array('from' => $this->oldUser->getName(), 'to' => $this->newUser->getName(), 'renamer' => $this->performingUser->getName(), 'movepages' => $options['movepages'], 'suppressredirects' => $options['suppressredirects'], 'promotetoglobal' => false, 'reason' => $options['reason'], 'session' => $this->session, 'force' => isset($options['force']) && $options['force']);
     $title = Title::newFromText('Global rename job');
     // This isn't used anywhere!
     return new LocalRenameUserJob($title, $params);
 }
 /**
  * Render the page
  * @param string $par The username of the user to display
  */
 public function executeWhenAvailable($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $out->addJsConfigVars(array('wgMFMaxDescriptionChars' => self::MAX_DESCRIPTION_CHARS));
     if ($par) {
         $this->targetUser = User::newFromName($par);
         $pageTitle = $this->targetUser ? $this->targetUser->getName() : $par;
         $out->setPageTitle($pageTitle);
         // Make sure this is a valid registered user and not an invalid username (e.g. ip see bug 56822)
         if ($this->targetUser && $this->targetUser->getId()) {
             // Prepare content
             $this->userInfo = new MobileUserInfo($this->targetUser);
             $activityHtml = $this->getLastEditHtml() . $this->getLastThanksHtml();
             $html = Html::openElement('div', array('class' => 'profile content'));
             if ($activityHtml) {
                 $html .= Html::openElement('div', array('class' => 'card-container')) . Html::openElement('h2') . $this->msg('mobile-frontend-profile-activity-heading') . Html::closeElement('h2') . $activityHtml . Html::closeElement('div');
             }
             $html .= $this->getUserFooterHtml() . Html::closeElement('div');
             $out->addHtml($html);
         } else {
             $this->displayNoUserError('mobile-frontend-profile-nouser');
         }
     } else {
         $out->setPageTitle($this->msg('mobile-frontend-profile-title'));
         $this->displayNoUserError('mobile-frontend-profile-noargs');
     }
 }
Beispiel #25
0
 public function present(User $user)
 {
     $name = $this->presentName($user->getName());
     $email = $this->presentEmail($user->getEmail());
     $password = $this->presentPassword($user->getPassword());
     return join('', ['Your name is: ', $name, PHP_EOL, 'Your email is: ', $email, PHP_EOL, 'Your password is: ', $password, PHP_EOL]);
 }
 /**
  * Check that we can perform the rename
  *
  * @param User $oldUser
  * @param User $newUser
  *
  * @return Status
  */
 public function validate(User $oldUser, User $newUser)
 {
     $status = new Status();
     if (!User::isCreatableName($newUser->getName())) {
         $status->fatal('centralauth-rename-badusername');
     }
     $caOldUser = CentralAuthUser::getInstance($oldUser);
     if (!$caOldUser->exists()) {
         $status->fatal('centralauth-rename-doesnotexist');
     }
     $caNewUser = CentralAuthUser::getInstance($newUser);
     if ($caNewUser->exists()) {
         $status->fatal('centralauth-rename-alreadyexists');
     }
     $unattached = $caNewUser->listUnattached();
     if ($unattached) {
         $status->fatal('centralauth-rename-unattached-intheway');
     }
     // Check we're not currently renaming the user
     $renameState = $caOldUser->renameInProgress();
     if ($renameState) {
         $status->fatal('centralauth-rename-alreadyinprogress', $renameState[1]);
     }
     return $status;
 }
 /**
  * Generates HTML for the uploads page for the passed user.
  *
  * @param User $user
  * @return string
  */
 public function getUserUploadsPageHtml(User $user)
 {
     $uploadCount = $this->getUserUploadCount($user->getName());
     $mobileContext = MobileContext::singleton();
     $html = '';
     $attrs = array();
     if ($uploadCount !== false) {
         $threshold = $this->getUploadCountThreshold();
         // FIXME: Use Html class?
         $html .= '<div class="content">';
         if ($mobileContext->userCanUpload()) {
             $html .= '<div class="ctaUploadPhoto"></div>';
         }
         if ($uploadCount > $threshold) {
             $msg = $this->msg('mobile-frontend-photo-upload-user-count-over-limit')->text();
         } else {
             $msg = $this->msg('mobile-frontend-photo-upload-user-count')->numParams($uploadCount)->parse();
             if ($uploadCount === 0) {
                 $attrs = array('style' => 'display:none');
             }
         }
         $html .= Html::openElement('h2', $attrs) . $msg . Html::closeElement('h2');
         $html .= '</div>';
     }
     return $html;
 }
Beispiel #28
0
 /**
  * @deprecated since 1.24
  * @param User $user
  * @return string
  */
 public static function getUserrightsToken($user)
 {
     global $wgUser;
     // Since the permissions check for userrights is non-trivial,
     // don't bother with it here
     return $wgUser->getEditToken($user->getName());
 }
Beispiel #29
0
function printMobileEntryListView($entries, $listid, $title, $paging, $count = 0, $header = true)
{
    $context = Model_Context::getInstance();
    $itemsView = '<ul data-role="listview" class="posts" id="' . $listid . '" title="' . $title . '" selected="false" data-inset="true">' . CRLF;
    if ($header) {
        $itemsView .= '<li class="group ui-bar ui-bar-e">' . CRLF;
        $itemsView .= '	<h3>' . $title . '</h3>' . CRLF;
        $itemsView .= '	<span class="ui-li-count">' . $count . '</span>' . CRLF;
        $itemsView .= '	<span class="ui-li-aside">' . _text('페이지') . ' ' . $paging['page'] . ' / ' . $paging['pages'] . '</span>' . CRLF;
        $itemsView .= '</li>' . CRLF;
    }
    foreach ($entries as $item) {
        $author = User::getName($item['userid']);
        if ($imageName = printMobileAttachmentExtract($item['content'])) {
            $imageSrc = printMobileImageResizer($context->getProperty('blog.id'), $imageName, 80);
        } else {
            $imageSrc = $context->getProperty('service.path') . '/resources/style/iphone/images/noPostThumb.png';
        }
        $itemsView .= '<li data-role="list-divider" role="heading" class="ui-li ui-li-divider ui-bar-b ui-btn-up-c" style="font-size:8pt;font-weight:normal">';
        $itemsView .= '	' . Timestamp::format5($item['published']) . '</li>' . CRLF;
        $itemsView .= '<li class="post_item">' . CRLF;
        $itemsView .= '	<a href="' . $context->getProperty('uri.blog') . '/entry/' . $item['id'] . '" class="link">' . CRLF;
        $itemsView .= '	<img src="' . $imageSrc . '"  />' . CRLF;
        $itemsView .= '	<h3>' . fireEvent('ViewListTitle', htmlspecialchars($item['title'])) . '</h3>' . CRLF;
        $itemsView .= '	<p class="ui-li-count"> ' . _textf('댓글 %1개', $item['comments'] > 0 ? $item['comments'] : 0) . '</p>' . CRLF;
        if (!empty($item['content'])) {
            $itemsView .= '	<p>' . htmlspecialchars(Utils_Unicode::lessenAsEm(removeAllTags(stripHTML($item['content'])), 150)) . '</p>' . CRLF;
        }
        $itemsView .= '	</a>' . CRLF;
        $itemsView .= '</li>' . CRLF;
    }
    $itemsView .= '</ul>' . CRLF;
    return $itemsView;
}
 public static function ArticleSaveComplete($article, User $user)
 {
     global $wgDBname, $wgMemc, $wgSharedDB, $wgUser;
     /* unset the key for this user on this database */
     $username = $user->getName();
     $wgMemc->delete("{$wgSharedDB}:LookupContribs:normal:{$username}:{$wgDBname}");
     $wgMemc->delete("{$wgSharedDB}:LookupContribs:final:{$username}:{$wgDBname}");
     return true;
 }