示例#1
0
 static function _getLatestUserData($type = 'userid', $params = null)
 {
     global $DATE_FORMAT, $TIME_FORMAT;
     static $user_id = null;
     if ($user_id === null) {
         $user = User::findLatestToRegister();
     } else {
         $user = User::find($user_id);
     }
     switch ($type) {
         default:
         case 'userid':
             return $user->getUserId();
         case 'username':
             return $user->getUserName();
         case 'fullname':
             return $user->getRealName();
         case 'regdate':
             if (is_array($params) && isset($params[0]) && $params[0] != '') {
                 $datestamp = $params[0];
             } else {
                 $datestamp = $DATE_FORMAT;
             }
             return timestamp_to_gedcom_date($user->getSetting('reg_timestamp'))->Display(false, $datestamp);
         case 'regtime':
             if (is_array($params) && isset($params[0]) && $params[0] != '') {
                 $datestamp = $params[0];
             } else {
                 $datestamp = str_replace('%', '', $TIME_FORMAT);
             }
             return date($datestamp, $user->getSetting('reg_timestamp'));
         case 'loggedin':
             if (is_array($params) && isset($params[0]) && $params[0] != '') {
                 $yes = $params[0];
             } else {
                 $yes = WT_I18N::translate('yes');
             }
             if (is_array($params) && isset($params[1]) && $params[1] != '') {
                 $no = $params[1];
             } else {
                 $no = WT_I18N::translate('no');
             }
             return WT_DB::prepare("SELECT SQL_NO_CACHE 1 FROM `##session` WHERE user_id=? LIMIT 1")->execute(array($user->getUserId()))->fetchOne() ? $yes : $no;
     }
 }