当前位置: 首页>>代码示例>>PHP>>正文


PHP wfTimestampOrNull函数代码示例

本文整理汇总了PHP中wfTimestampOrNull函数的典型用法代码示例。如果您正苦于以下问题:PHP wfTimestampOrNull函数的具体用法?PHP wfTimestampOrNull怎么用?PHP wfTimestampOrNull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wfTimestampOrNull函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPasswordResetData

 protected function getPasswordResetData($username, $row)
 {
     $now = wfTimestamp();
     $expiration = wfTimestampOrNull(TS_UNIX, $row->user_password_expires);
     if ($expiration === null || $expiration >= $now) {
         return null;
     }
     $grace = $this->config->get('PasswordExpireGrace');
     if ($expiration + $grace < $now) {
         $data = ['hard' => true, 'msg' => \Status::newFatal('resetpass-expired')->getMessage()];
     } else {
         $data = ['hard' => false, 'msg' => \Status::newFatal('resetpass-expired-soft')->getMessage()];
     }
     return (object) $data;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:15,代码来源:LocalPasswordPrimaryAuthenticationProvider.php

示例2: LoginHistoryHook

 /**
  * LoginHistoryHook
  *
  * store information about when & where user logged in, for stats
  * purposes, called by Hook UserLoginComplete and UserLoadFromSessionInfo
  * Data is stored in external storage archive1
  *
  * @author Krzysztof Krzyżaniak (eloy) <eloy@wikia-inc.com>
  * @access public
  * @static
  *
  * @param Integer $from -- which hook call this
  * @param User    $user -- User class instance
  * @param String  $type -- UserLoadFromSessionInfo set this to 'cookie' or 'session'
  *
  * @return bool true		process other hooks
  */
 public static function LoginHistoryHook($from, $user, $type = false)
 {
     global $wgCityId;
     #--- private wikia identifier, you can use wgDBname
     global $wgEnableScribeReport, $wgStatsDB, $wgStatsDBEnabled;
     if (wfReadOnly()) {
         return true;
     }
     wfProfileIn(__METHOD__);
     /**
      * if user id is empty it means that user object is not loaded
      * store information only for registered users
      */
     if (!empty($user) && is_object($user)) {
         $id = $user->getId();
         if ($id) {
             if ($from == self::LOGIN_AUTO && $type == "session") {
                 # ignore
             } else {
                 $params = array("user_id" => $id, "city_id" => $wgCityId, "ulh_from" => $from, "ulh_rememberme" => $user->getOption('rememberpassword'));
                 if (!empty($wgEnableScribeReport)) {
                     # use scribe
                     try {
                         $message = array('method' => 'login', 'params' => $params);
                         $data = json_encode($message);
                         WScribeClient::singleton('trigger')->send($data);
                     } catch (TException $e) {
                         Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage());
                     }
                 } else {
                     # use database
                     if (!empty($wgStatsDBEnabled)) {
                         $dbw = wfGetDB(DB_MASTER, array(), $wgStatsDB);
                         $dbw->insert("user_login_history", $params, __METHOD__, array('IGNORE'));
                         $dbw->replace("user_login_history_summary", array('user_id'), array('ulh_timestamp' => wfTimestampOrNull(), 'user_id' => $id), __METHOD__);
                         if ($dbw->getFlag(DBO_TRX)) {
                             $dbw->commit(__METHOD__);
                         }
                     }
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:63,代码来源:UserChangesHistory.class.php

示例3: LoginHistoryHook

 /**
  * LoginHistoryHook
  *
  * store information about when & where user logged in, for stats
  * purposes, called by Hook UserLoginComplete and UserLoadFromSessionInfo
  * Data is stored in external storage archive1
  *
  * @author Krzysztof Krzyżaniak (eloy) <eloy@wikia-inc.com>
  * @access public
  * @static
  *
  * @param Integer $from -- which hook call this
  * @param User    $user -- User class instance
  * @param String  $type -- UserLoadFromSessionInfo set this to 'cookie' or 'session'
  *
  * @return bool true		process other hooks
  */
 public static function LoginHistoryHook($from, $user, $type = false)
 {
     global $wgCityId;
     #--- private wikia identifier, you can use wgDBname
     global $wgEnableScribeReport, $wgSpecialsDB;
     if (wfReadOnly()) {
         return true;
     }
     wfProfileIn(__METHOD__);
     /**
      * if user id is empty it means that user object is not loaded
      * store information only for registered users
      */
     if (!empty($user) && is_object($user)) {
         $id = $user->getId();
         if ($id) {
             if ($from == self::LOGIN_AUTO && $type == "session") {
                 # ignore
             } else {
                 $params = array("user_id" => $id, "city_id" => $wgCityId, "ulh_from" => $from, "ulh_rememberme" => $user->getGlobalPreference('rememberpassword'));
                 if (!empty($wgEnableScribeReport)) {
                     # use scribe
                     try {
                         $message = array('method' => 'login', 'params' => $params);
                         $data = json_encode($message);
                         WScribeClient::singleton('trigger')->send($data);
                     } catch (TException $e) {
                         Wikia\Logger\WikiaLogger::instance()->error(__METHOD__ . ' - scribeClient exception', ['exception' => $e]);
                     }
                 } else {
                     // user_login_history_summary is used in joins with specials.events_local_users table
                     // @see PLATFORM-1309
                     $dbw_specials = wfGetDB(DB_MASTER, array(), $wgSpecialsDB);
                     $dbw_specials->insert("user_login_history", $params, __METHOD__, array('IGNORE'));
                     $dbw_specials->replace("user_login_history_summary", array('user_id'), array('ulh_timestamp' => wfTimestampOrNull(), 'user_id' => $id), __METHOD__);
                     $dbw_specials->commit(__METHOD__);
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:yusufchang,项目名称:app,代码行数:60,代码来源:UserChangesHistory.class.php

示例4: getImageList

 /**
  * Get image list
  *
  * @param  integer $userId ID of the user to get the list for
  * @param  string  $from   Timestamp to get images before
  * @return array           List of images
  */
 public function getImageList($userId, $from = null)
 {
     wfProfileIn(__METHOD__);
     $imageList = [];
     $db = $this->getDatawareDB(DB_MASTER);
     $where = ['user_id' => $userId, 'state != ' . ImageReviewStatuses::STATE_DELETED . ' AND state != ' . ImageReviewStatuses::STATE_WIKI_DISABLED];
     $from = wfTimestampOrNull(TS_DB, $from);
     if (!empty($from)) {
         $where[] = 'last_edited < ' . $db->addQuotes($from);
     }
     $result = $db->select(['image_review'], ['wiki_id, page_id, state, flags, priority, last_edited'], $where, __METHOD__, ['ORDER BY' => 'last_edited desc', 'LIMIT' => self::LIMIT_IMAGES]);
     foreach ($result as $row) {
         $img = ImagesService::getImageSrc($row->wiki_id, $row->page_id);
         $wikiRow = WikiFactory::getWikiByID($row->wiki_id);
         $extension = pathinfo(strtolower($img['page']), PATHINFO_EXTENSION);
         $isThumb = true;
         if (empty($img['src'])) {
             // If we don't have a thumb by this point, we still need to display something, fall back to placeholder
             $globalTitle = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if (is_object($globalTitle)) {
                 $img['page'] = $globalTitle->getFullUrl();
                 // @TODO this should be taken from the code instead of being hardcoded
                 $img['src'] = '//images.wikia.com/central/images/8/8c/Wikia_image_placeholder.png';
             } else {
                 // This should never happen
                 continue;
             }
         }
         if (in_array($extension, ['gif', 'svg'])) {
             $img = ImagesService::getImageOriginalUrl($row->wiki_id, $row->page_id);
             $isThumb = false;
         }
         $imageList[] = ['wikiId' => $row->wiki_id, 'pageId' => $row->page_id, 'state' => $row->state, 'src' => $img['src'], 'priority' => $row->priority, 'url' => $img['page'], 'isthumb' => $isThumb, 'flags' => $row->flags, 'wiki_url' => isset($wikiRow->city_url) ? $wikiRow->city_url : '', 'user_page' => '', 'last_edited' => $row->last_edited];
     }
     $db->freeResult($result);
     wfProfileOut(__METHOD__);
     return $imageList;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:45,代码来源:CoppaImageReviewHelper.class.php

示例5: isTimestampValid

 /**
  * Check that a temporary password is still valid (hasn't expired).
  * @param string $timestamp A timestamp in MediaWiki (TS_MW) format
  * @return bool
  */
 protected function isTimestampValid($timestamp)
 {
     $time = wfTimestampOrNull(TS_MW, $timestamp);
     if ($time !== null) {
         $expiry = wfTimestamp(TS_UNIX, $time) + $this->newPasswordExpiry;
         if (time() >= $expiry) {
             return false;
         }
     }
     return true;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:16,代码来源:TemporaryPasswordPrimaryAuthenticationProvider.php

示例6: modifyFileLinks

 /**
  *  Called on BeforeParserFetchFileAndTitle hook
  *  Changes links and thumbnails of files to point to the approved revision in all cases except
  *  the primary file on file pages (e.g. the big image in the top left on File:My File.png). To
  *  modify that image see self::onImagePageFindFile()
  **/
 public static function modifyFileLinks($parser, Title $fileTitle, &$options, &$query)
 {
     if ($fileTitle->getNamespace() == NS_MEDIA) {
         $fileTitle = Title::makeTitle(NS_FILE, $fileTitle->getDBkey());
         $fileTitle->resetArticleId($fileTitle->getArticleID());
         // avoid extra queries
         // Media link redirects don't get caught by the normal redirect check, so this
         // extra check is required
         if ($temp = WikiPage::newFromID($fileTitle->getArticleID())->getRedirectTarget()) {
             $fileTitle = $temp;
             unset($temp);
         }
     }
     if ($fileTitle->isRedirect()) {
         $page = WikiPage::newFromID($fileTitle->getArticleID());
         $fileTitle = $page->getRedirectTarget();
         $fileTitle->resetArticleId($fileTitle->getArticleID());
         // avoid extra queries
     }
     # Tell Parser what file version to use
     list($approvedRevTimestamp, $approvedRevSha1) = ApprovedRevs::getApprovedFileInfo($fileTitle);
     // no valid approved timestamp or sha1, so don't modify image or image link
     if (!$approvedRevTimestamp || !$approvedRevSha1) {
         return true;
     }
     $options['time'] = wfTimestampOrNull(TS_MW, $approvedRevTimestamp);
     $options['sha1'] = $approvedRevSha1;
     // $options['broken'] = true; // breaks the link? was in FlaggedRevs...why would we want to do this?
     # Stabilize the file link
     if ($query != '') {
         $query .= '&';
     }
     $query .= "filetimestamp=" . urlencode(wfTimestamp(TS_MW, $approvedRevTimestamp));
     return true;
 }
开发者ID:emanspeaks,项目名称:ApprovedRevs,代码行数:41,代码来源:ApprovedRevs.hooks.php

示例7: localUserData

 /**
  * Fetch a row of user data needed for migration.
  *
  * @param $wikiID String
  * @throws Exception if local user not found
  * @return array
  */
 protected function localUserData($wikiID)
 {
     $lb = wfGetLB($wikiID);
     $db = $lb->getConnection(DB_SLAVE, array(), $wikiID);
     $fields = array('user_id', 'user_email', 'user_email_authenticated', 'user_password', 'user_editcount', 'user_registration');
     $conds = array('user_name' => $this->mName);
     $row = $db->selectRow('user', $fields, $conds, __METHOD__);
     if (!$row) {
         # Row missing from slave, try the master instead
         $lb->reuseConnection($db);
         $db = $lb->getConnection(DB_MASTER, array(), $wikiID);
         $row = $db->selectRow('user', $fields, $conds, __METHOD__);
     }
     if (!$row) {
         $lb->reuseConnection($db);
         throw new Exception("Could not find local user data for {$this->mName}@{$wikiID}");
     }
     /** @var $row object */
     $data = array('wiki' => $wikiID, 'id' => $row->user_id, 'email' => $row->user_email, 'emailAuthenticated' => wfTimestampOrNull(TS_MW, $row->user_email_authenticated), 'registration' => wfTimestampOrNull(TS_MW, $row->user_registration), 'password' => $row->user_password, 'editCount' => $row->user_editcount, 'groups' => array(), 'blocked' => false);
     // Edit count field may not be initialized...
     if (is_null($row->user_editcount)) {
         $data['editCount'] = $db->selectField('revision', 'COUNT(*)', array('rev_user' => $data['id']), __METHOD__);
     }
     // And we have to fetch groups separately, sigh...
     $result = $db->select('user_groups', array('ug_group'), array('ug_user' => $data['id']), __METHOD__);
     foreach ($result as $row) {
         $data['groups'][] = $row->ug_group;
     }
     $result->free();
     // And while we're in here, look for user blocks :D
     $result = $db->select('ipblocks', array('ipb_expiry', 'ipb_reason', 'ipb_block_email', 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', 'ipb_allow_usertalk'), array('ipb_user' => $data['id']), __METHOD__);
     global $wgLang;
     foreach ($result as $row) {
         if ($wgLang->formatExpiry($row->ipb_expiry, TS_MW) > wfTimestampNow()) {
             $data['block-expiry'] = $row->ipb_expiry;
             $data['block-reason'] = $row->ipb_reason;
             $data['block-anononly'] = (bool) $row->ipb_anon_only;
             $data['block-nocreate'] = (bool) $row->ipb_create_account;
             $data['block-noautoblock'] = !(bool) $row->ipb_enable_autoblock;
             $data['block-nousertalk'] = !(bool) $row->ipb_allow_usertalk;
             // Poorly named database column
             $data['block-noemail'] = (bool) $row->ipb_block_email;
             $data['blocked'] = true;
         }
     }
     $result->free();
     $lb->reuseConnection($db);
     return $data;
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:56,代码来源:CentralAuthUser.php

示例8: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     if (!is_null($params['prop'])) {
         $this->prop = array_flip($params['prop']);
     } else {
         $this->prop = [];
     }
     $users = (array) $params['users'];
     $goodNames = $done = [];
     $result = $this->getResult();
     // Canonicalize user names
     foreach ($users as $u) {
         $n = User::getCanonicalName($u);
         if ($n === false || $n === '') {
             $vals = ['name' => $u, 'invalid' => true];
             $fit = $result->addValue(['query', $this->getModuleName()], null, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done)));
                 $goodNames = [];
                 break;
             }
             $done[] = $u;
         } else {
             $goodNames[] = $n;
         }
     }
     $result = $this->getResult();
     if (count($goodNames)) {
         $this->addTables('user');
         $this->addFields(User::selectFields());
         $this->addWhereFld('user_name', $goodNames);
         $this->showHiddenUsersAddBlockInfo(isset($this->prop['blockinfo']));
         $data = [];
         $res = $this->select(__METHOD__);
         $this->resetQueryParams();
         // get user groups if needed
         if (isset($this->prop['groups']) || isset($this->prop['rights'])) {
             $userGroups = [];
             $this->addTables('user');
             $this->addWhereFld('user_name', $goodNames);
             $this->addTables('user_groups');
             $this->addJoinConds(['user_groups' => ['INNER JOIN', 'ug_user=user_id']]);
             $this->addFields(['user_name', 'ug_group']);
             $userGroupsRes = $this->select(__METHOD__);
             foreach ($userGroupsRes as $row) {
                 $userGroups[$row->user_name][] = $row->ug_group;
             }
         }
         foreach ($res as $row) {
             // create user object and pass along $userGroups if set
             // that reduces the number of database queries needed in User dramatically
             if (!isset($userGroups)) {
                 $user = User::newFromRow($row);
             } else {
                 if (!isset($userGroups[$row->user_name]) || !is_array($userGroups[$row->user_name])) {
                     $userGroups[$row->user_name] = [];
                 }
                 $user = User::newFromRow($row, ['user_groups' => $userGroups[$row->user_name]]);
             }
             $name = $user->getName();
             $data[$name]['userid'] = $user->getId();
             $data[$name]['name'] = $name;
             if (isset($this->prop['editcount'])) {
                 $data[$name]['editcount'] = $user->getEditCount();
             }
             if (isset($this->prop['registration'])) {
                 $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $user->getRegistration());
             }
             if (isset($this->prop['groups'])) {
                 $data[$name]['groups'] = $user->getEffectiveGroups();
             }
             if (isset($this->prop['implicitgroups'])) {
                 $data[$name]['implicitgroups'] = $user->getAutomaticGroups();
             }
             if (isset($this->prop['rights'])) {
                 $data[$name]['rights'] = $user->getRights();
             }
             if ($row->ipb_deleted) {
                 $data[$name]['hidden'] = true;
             }
             if (isset($this->prop['blockinfo']) && !is_null($row->ipb_by_text)) {
                 $data[$name]['blockid'] = (int) $row->ipb_id;
                 $data[$name]['blockedby'] = $row->ipb_by_text;
                 $data[$name]['blockedbyid'] = (int) $row->ipb_by;
                 $data[$name]['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $row->ipb_timestamp);
                 $data[$name]['blockreason'] = $row->ipb_reason;
                 $data[$name]['blockexpiry'] = $row->ipb_expiry;
             }
             if (isset($this->prop['emailable'])) {
                 $data[$name]['emailable'] = $user->canReceiveEmail();
             }
             if (isset($this->prop['gender'])) {
                 $gender = $user->getOption('gender');
                 if (strval($gender) === '') {
                     $gender = 'unknown';
                 }
                 $data[$name]['gender'] = $gender;
             }
             if (isset($this->prop['centralids'])) {
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryUsers.php

示例9: loadFromRow

 /**
  * Load the object from a database row
  *
  * @since 1.20
  * @param object|bool $data DB row containing fields returned by selectFields() or false
  * @param string|int $from One of the following:
  *        - "fromdb" or WikiPage::READ_NORMAL if the data comes from a replica DB
  *        - "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the master DB
  *        - "forupdate"  or WikiPage::READ_LOCKING if the data comes from
  *          the master DB using SELECT FOR UPDATE
  */
 public function loadFromRow($data, $from)
 {
     $lc = LinkCache::singleton();
     $lc->clearLink($this->mTitle);
     if ($data) {
         $lc->addGoodLinkObjFromRow($this->mTitle, $data);
         $this->mTitle->loadFromRow($data);
         // Old-fashioned restrictions
         $this->mTitle->loadRestrictions($data->page_restrictions);
         $this->mId = intval($data->page_id);
         $this->mTouched = wfTimestamp(TS_MW, $data->page_touched);
         $this->mLinksUpdated = wfTimestampOrNull(TS_MW, $data->page_links_updated);
         $this->mIsRedirect = intval($data->page_is_redirect);
         $this->mLatest = intval($data->page_latest);
         // Bug 37225: $latest may no longer match the cached latest Revision object.
         // Double-check the ID of any cached latest Revision object for consistency.
         if ($this->mLastRevision && $this->mLastRevision->getId() != $this->mLatest) {
             $this->mLastRevision = null;
             $this->mTimestamp = '';
         }
     } else {
         $lc->addBadLinkObj($this->mTitle);
         $this->mTitle->loadFromRow(false);
         $this->clearCacheFields();
         $this->mId = 0;
     }
     $this->mDataLoaded = true;
     $this->mDataLoadedFrom = self::convertSelectType($from);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:40,代码来源:WikiPage.php

示例10: loadFromRow

 /**
  * Initialize this object from a row from the user table.
  *
  * @param stdClass $row Row from the user table to load.
  * @param array $data Further user data to load into the object
  *
  *	user_groups		Array with groups out of the user_groups table
  *	user_properties		Array with properties out of the user_properties table
  */
 protected function loadFromRow($row, $data = null)
 {
     $all = true;
     $passwordFactory = self::getPasswordFactory();
     $this->mGroups = null;
     // deferred
     if (isset($row->user_name)) {
         $this->mName = $row->user_name;
         $this->mFrom = 'name';
         $this->setItemLoaded('name');
     } else {
         $all = false;
     }
     if (isset($row->user_real_name)) {
         $this->mRealName = $row->user_real_name;
         $this->setItemLoaded('realname');
     } else {
         $all = false;
     }
     if (isset($row->user_id)) {
         $this->mId = intval($row->user_id);
         $this->mFrom = 'id';
         $this->setItemLoaded('id');
     } else {
         $all = false;
     }
     if (isset($row->user_id) && isset($row->user_name)) {
         self::$idCacheByName[$row->user_name] = $row->user_id;
     }
     if (isset($row->user_editcount)) {
         $this->mEditCount = $row->user_editcount;
     } else {
         $all = false;
     }
     if (isset($row->user_password)) {
         // Check for *really* old password hashes that don't even have a type
         // The old hash format was just an md5 hex hash, with no type information
         if (preg_match('/^[0-9a-f]{32}$/', $row->user_password)) {
             $row->user_password = ":A:{$this->mId}:{$row->user_password}";
         }
         try {
             $this->mPassword = $passwordFactory->newFromCiphertext($row->user_password);
         } catch (PasswordError $e) {
             wfDebug('Invalid password hash found in database.');
             $this->mPassword = $passwordFactory->newFromCiphertext(null);
         }
         try {
             $this->mNewpassword = $passwordFactory->newFromCiphertext($row->user_newpassword);
         } catch (PasswordError $e) {
             wfDebug('Invalid password hash found in database.');
             $this->mNewpassword = $passwordFactory->newFromCiphertext(null);
         }
         $this->mNewpassTime = wfTimestampOrNull(TS_MW, $row->user_newpass_time);
         $this->mPasswordExpires = wfTimestampOrNull(TS_MW, $row->user_password_expires);
     }
     if (isset($row->user_email)) {
         $this->mEmail = $row->user_email;
         $this->mTouched = wfTimestamp(TS_MW, $row->user_touched);
         $this->mToken = $row->user_token;
         if ($this->mToken == '') {
             $this->mToken = null;
         }
         $this->mEmailAuthenticated = wfTimestampOrNull(TS_MW, $row->user_email_authenticated);
         $this->mEmailToken = $row->user_email_token;
         $this->mEmailTokenExpires = wfTimestampOrNull(TS_MW, $row->user_email_token_expires);
         $this->mRegistration = wfTimestampOrNull(TS_MW, $row->user_registration);
     } else {
         $all = false;
     }
     if ($all) {
         $this->mLoadedItems = true;
     }
     if (is_array($data)) {
         if (isset($data['user_groups']) && is_array($data['user_groups'])) {
             $this->mGroups = $data['user_groups'];
         }
         if (isset($data['user_properties']) && is_array($data['user_properties'])) {
             $this->loadOptions($data['user_properties']);
         }
     }
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:90,代码来源:User.php

示例11: loadFromDatabase

 /**
  * Load user and user_group data from the database
  * $this->mId must be set, this is how the user is identified.
  * 
  * @return true if the user exists, false if the user is anonymous
  * @private
  */
 function loadFromDatabase()
 {
     # Paranoia
     $this->mId = intval($this->mId);
     /** Anonymous user */
     if (!$this->mId) {
         $this->loadDefaults();
         return false;
     }
     $dbr = wfGetDB(DB_MASTER);
     $s = $dbr->selectRow('user', '*', array('user_id' => $this->mId), __METHOD__);
     if ($s !== false) {
         # Initialise user table data
         $this->mName = $s->user_name;
         $this->mRealName = $s->user_real_name;
         $this->mPassword = $s->user_password;
         $this->mNewpassword = $s->user_newpassword;
         $this->mNewpassTime = wfTimestampOrNull(TS_MW, $s->user_newpass_time);
         $this->mEmail = $s->user_email;
         $this->decodeOptions($s->user_options);
         $this->mTouched = wfTimestamp(TS_MW, $s->user_touched);
         $this->mToken = $s->user_token;
         $this->mEmailAuthenticated = wfTimestampOrNull(TS_MW, $s->user_email_authenticated);
         $this->mEmailToken = $s->user_email_token;
         $this->mEmailTokenExpires = wfTimestampOrNull(TS_MW, $s->user_email_token_expires);
         $this->mRegistration = wfTimestampOrNull(TS_MW, $s->user_registration);
         $this->mEditCount = $s->user_editcount;
         $this->getEditCount();
         // revalidation for nulls
         # Load group data
         $res = $dbr->select('user_groups', array('ug_group'), array('ug_user' => $this->mId), __METHOD__);
         $this->mGroups = array();
         while ($row = $dbr->fetchObject($res)) {
             $this->mGroups[] = $row->ug_group;
         }
         return true;
     } else {
         # Invalid user_id
         $this->mId = 0;
         $this->loadDefaults();
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:50,代码来源:User.php

示例12: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     if (!is_null($params['prop'])) {
         $this->prop = array_flip($params['prop']);
     } else {
         $this->prop = array();
     }
     $users = (array) $params['users'];
     $goodNames = $done = array();
     $result = $this->getResult();
     // Canonicalize user names
     foreach ($users as $u) {
         $n = User::getCanonicalName($u);
         if ($n === false || $n === '') {
             $vals = array('name' => $u, 'invalid' => '');
             $fit = $result->addValue(array('query', $this->getModuleName()), null, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done)));
                 $goodNames = array();
                 break;
             }
             $done[] = $u;
         } else {
             $goodNames[] = $n;
         }
     }
     if (count($goodNames)) {
         $this->addTables('user', 'u1');
         $this->addFields('u1.*');
         $this->addWhereFld('u1.user_name', $goodNames);
         if (isset($this->prop['groups'])) {
             $this->addTables('user_groups');
             $this->addJoinConds(array('user_groups' => array('LEFT JOIN', 'ug_user=u1.user_id')));
             $this->addFields('ug_group');
         }
         $this->showHiddenUsersAddBlockInfo(isset($this->prop['blockinfo']));
         $data = array();
         $res = $this->select(__METHOD__);
         foreach ($res as $row) {
             $user = User::newFromRow($row);
             $name = $user->getName();
             $data[$name]['name'] = $name;
             if (isset($this->prop['editcount'])) {
                 $data[$name]['editcount'] = intval($user->getEditCount());
             }
             if (isset($this->prop['registration'])) {
                 $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $user->getRegistration());
             }
             if (isset($this->prop['groups']) && !is_null($row->ug_group)) {
                 // This row contains only one group, others will be added from other rows
                 $data[$name]['groups'][] = $row->ug_group;
             }
             if (isset($this->prop['rights']) && !is_null($row->ug_group)) {
                 if (!isset($data[$name]['rights'])) {
                     $data[$name]['rights'] = User::getGroupPermissions(User::getImplicitGroups());
                 }
                 $data[$name]['rights'] = array_unique(array_merge($data[$name]['rights'], User::getGroupPermissions(array($row->ug_group))));
                 $result->setIndexedTagName($data[$name]['rights'], 'r');
             }
             if ($row->ipb_deleted) {
                 $data[$name]['hidden'] = '';
             }
             if (isset($this->prop['blockinfo']) && !is_null($row->ipb_by_text)) {
                 $data[$name]['blockedby'] = $row->ipb_by_text;
                 $data[$name]['blockreason'] = $row->ipb_reason;
                 $data[$name]['blockexpiry'] = $row->ipb_expiry;
             }
             if (isset($this->prop['emailable']) && $user->canReceiveEmail()) {
                 $data[$name]['emailable'] = '';
             }
             if (isset($this->prop['gender'])) {
                 $gender = $user->getOption('gender');
                 if (strval($gender) === '') {
                     $gender = 'unknown';
                 }
                 $data[$name]['gender'] = $gender;
             }
             if (!is_null($params['token'])) {
                 $tokenFunctions = $this->getTokenFunctions();
                 foreach ($params['token'] as $t) {
                     $val = call_user_func($tokenFunctions[$t], $user);
                     if ($val === false) {
                         $this->setWarning("Action '{$t}' is not allowed for the current user");
                     } else {
                         $data[$name][$t . 'token'] = $val;
                     }
                 }
             }
         }
     }
     // Second pass: add result data to $retval
     foreach ($goodNames as $u) {
         if (!isset($data[$u])) {
             $data[$u] = array('name' => $u);
             $urPage = new UserrightsPage();
             $iwUser = $urPage->fetchUser($u);
             if ($iwUser instanceof UserRightsProxy) {
                 $data[$u]['interwiki'] = '';
                 if (!is_null($params['token'])) {
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:ApiQueryUsers.php

示例13: getReleaseTimestamp

 /**
  * @return int|null UNIX timestamp to delay running this job until, otherwise null
  * @since 1.22
  */
 public function getReleaseTimestamp()
 {
     return isset($this->params['jobReleaseTimestamp']) ? wfTimestampOrNull(TS_UNIX, $this->params['jobReleaseTimestamp']) : null;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:8,代码来源:Job.php

示例14: findPendingFileChanges

 /**
  * Fetch pending file changes for this reviewed page version.
  * For each file, the "version used" (for stable parsing) is:
  *    (a) (the latest rev) if FR_INCLUDES_CURRENT. Might be non-existing.
  *    (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE
  *    (c) ( rev at time of review ) if FR_INCLUDES_FREEZE
  * Pending changes exist for a file iff the file is used in
  * the current rev of this page and one of the following holds:
  *    (a) Current file is newer than the "version used" above (updated)
  *    (b) Current file exists and the "version used" was non-existing (created)
  *    (c) Current file doesn't exist and the "version used" existed (deleted)
  *
  * @param bool|string $noForeign Using 'noForeign' skips foreign file updates (bug 15748)
  * @return array of (title, MW file timestamp in reviewed version, has stable rev) tuples
  */
 public function findPendingFileChanges($noForeign = false)
 {
     if (FlaggedRevs::inclusionSetting() == FR_INCLUDES_CURRENT) {
         return array();
         // short-circuit
     }
     $dbr = wfGetDB(DB_SLAVE);
     # Only get templates with stable or "review time" versions.
     # Note: fi_img_timestamp is nullable (for deadlinks), so use fi_name
     if (FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE) {
         $reviewed = "fi_name IS NOT NULL OR fr_img_timestamp IS NOT NULL";
     } else {
         $reviewed = "fi_name IS NOT NULL";
     }
     $ret = $dbr->select(array('imagelinks', 'flaggedimages', 'page', 'flaggedpages', 'flaggedrevs'), array('il_to', 'fi_img_timestamp', 'fr_img_timestamp'), array('il_from' => $this->getPage(), $reviewed), __METHOD__, array(), array('flaggedimages' => array('LEFT JOIN', array('fi_rev_id' => $this->getRevId(), 'fi_name = il_to')), 'page' => array('LEFT JOIN', 'page_namespace = ' . NS_FILE . ' AND page_title = il_to'), 'flaggedpages' => array('LEFT JOIN', 'fp_page_id = page_id'), 'flaggedrevs' => array('LEFT JOIN', 'fr_rev_id = fp_stable')));
     $fileChanges = array();
     foreach ($ret as $row) {
         // each file
         $reviewedTS = trim($row->fi_img_timestamp);
         // may have \0's
         $reviewedTS = $reviewedTS ? wfTimestamp(TS_MW, $reviewedTS) : null;
         $stableTS = wfTimestampOrNull(TS_MW, $row->fr_img_timestamp);
         # Get file timestamp used in this FlaggedRevision when parsed
         $usedTS = self::fileTimestampUsed($stableTS, $reviewedTS);
         # Check for edits/creations/deletions...
         $title = Title::makeTitleSafe(NS_FILE, $row->il_to);
         if (self::fileChanged($title, $usedTS, $noForeign)) {
             if (!$title->equals($this->getTitle())) {
                 // bug 42297
                 $fileChanges[] = array($title, $usedTS, (bool) $stableTS);
             }
         }
     }
     return $fileChanges;
 }
开发者ID:crippsy14,项目名称:orange-smorange,代码行数:50,代码来源:FlaggedRevision.php

示例15: loadFromRow

 /**
  * Initialize this object from a row from the user table.
  *
  * @param $row \type{\arrayof{\mixed}} Row from the user table to load.
  */
 function loadFromRow($row)
 {
     $this->mDataLoaded = true;
     if (isset($row->user_id)) {
         $this->mId = $row->user_id;
     }
     $this->mName = $row->user_name;
     $this->mRealName = $row->user_real_name;
     $this->mPassword = $row->user_password;
     $this->mNewpassword = $row->user_newpassword;
     $this->mNewpassTime = wfTimestampOrNull(TS_MW, $row->user_newpass_time);
     $this->mEmail = $row->user_email;
     $this->decodeOptions($row->user_options);
     $this->mTouched = wfTimestamp(TS_MW, $row->user_touched);
     $this->mToken = $row->user_token;
     $this->mEmailAuthenticated = wfTimestampOrNull(TS_MW, $row->user_email_authenticated);
     $this->mEmailToken = $row->user_email_token;
     $this->mEmailTokenExpires = wfTimestampOrNull(TS_MW, $row->user_email_token_expires);
     $this->mRegistration = wfTimestampOrNull(TS_MW, $row->user_registration);
     $this->mEditCount = $row->user_editcount;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:26,代码来源:User.php


注:本文中的wfTimestampOrNull函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。