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


PHP User::by_id方法代码示例

本文整理汇总了PHP中User::by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP User::by_id方法的具体用法?PHP User::by_id怎么用?PHP User::by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


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

示例1: get_partner_club

 public function get_partner_club()
 {
     if (!$this->partner_club_id) {
         return NULL;
     }
     return User::by_id($this->partner_club_id);
 }
开发者ID:nishad,项目名称:bmtmgr,代码行数:7,代码来源:entry.php

示例2: display_pms

 public function display_pms(Page $page, $pms)
 {
     global $user;
     $html = "\n\t\t\t<script type='text/javascript'>\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$(\"#pms\").tablesorter();\n\t\t\t});\n\t\t\t</script>\n\t\t\t<table id='pms' class='zebra'>\n\t\t\t\t<thead><tr><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead>\n\t\t\t\t<tbody>";
     $n = 0;
     foreach ($pms as $pm) {
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $h_subject = html_escape($pm->subject);
         if (strlen(trim($h_subject)) == 0) {
             $h_subject = "(No subject)";
         }
         $from_name = User::by_id($pm->from_id)->name;
         $h_from = html_escape($from_name);
         $from_url = make_link("user/" . url_escape($from_name));
         $pm_url = make_link("pm/read/" . $pm->id);
         $del_url = make_link("pm/delete");
         $h_date = html_escape($pm->sent_date);
         if ($pm->is_read) {
             $h_subject = "<b>{$h_subject}</b>";
         }
         $html .= "<tr class='{$oe}'><td><a href='{$pm_url}'>{$h_subject}</a></td>\n\t\t\t<td><a href='{$from_url}'>{$h_from}</a></td><td>{$h_date}</td>\n\t\t\t<td><form action='{$del_url}' method='POST'>\n\t\t\t\t<input type='hidden' name='pm_id' value='{$pm->id}'>\n\t\t\t\t" . $user->get_auth_html() . "\n\t\t\t\t<input type='submit' value='Delete'>\n\t\t\t</form></td></tr>";
     }
     $html .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t";
     $page->add_block(new Block("Private Messages", $html, "main", 10));
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:25,代码来源:theme.php

示例3: get_owner

 public function get_owner()
 {
     if (empty($this->owner)) {
         $this->owner = User::by_id($this->owner_id);
     }
     return $this->owner;
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:7,代码来源:main.php

示例4: display_pms

 public function display_pms(Page $page, $pms)
 {
     global $user;
     $html = "\n\t\t\t<table id='pms' class='zebra sortable'>\n\t\t\t\t<thead><tr><th>R?</th><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead>\n\t\t\t\t<tbody>";
     foreach ($pms as $pm) {
         $h_subject = html_escape($pm->subject);
         if (strlen(trim($h_subject)) == 0) {
             $h_subject = "(No subject)";
         }
         $from = User::by_id($pm->from_id);
         $from_name = $from->name;
         $h_from = html_escape($from_name);
         $from_url = make_link("user/" . url_escape($from_name));
         $pm_url = make_link("pm/read/" . $pm->id);
         $del_url = make_link("pm/delete");
         $h_date = html_escape($pm->sent_date);
         $readYN = "Y";
         if (!$pm->is_read) {
             $h_subject = "<b>{$h_subject}</b>";
             $readYN = "N";
         }
         $hb = $from->can("hellbanned") ? "hb" : "";
         $html .= "<tr class='{$hb}'>\n\t\t\t<td>{$readYN}</td>\n\t\t\t<td><a href='{$pm_url}'>{$h_subject}</a></td>\n\t\t\t<td><a href='{$from_url}'>{$h_from}</a></td><td>{$h_date}</td>\n\t\t\t<td><form action='{$del_url}' method='POST'>\n\t\t\t\t<input type='hidden' name='pm_id' value='{$pm->id}'>\n\t\t\t\t" . $user->get_auth_html() . "\n\t\t\t\t<input type='submit' value='Delete'>\n\t\t\t</form></td>\n\t\t\t</tr>";
     }
     $html .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t";
     $page->add_block(new Block("Private Messages", $html, "main", 40, "private-messages"));
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:27,代码来源:theme.php

示例5: __construct

 function __construct()
 {
     Authentication::require_admin();
     $this->is_admin_page = true;
     // find active entity
     parent::__construct();
     // find user
     if (!isset($_REQUEST['userid'])) {
         throw new NotFoundException("Missing parameter: userid");
     }
     $this->user = User::by_id(intval($_REQUEST['userid']));
 }
开发者ID:jlsa,项目名称:justitia,代码行数:12,代码来源:admin_user_submission.php

示例6: current_user

 static function current_user()
 {
     static $current_user;
     if (isset($current_user)) {
         return $current_user;
     }
     Authentication::session_start();
     if (isset($_SESSION['userid'])) {
         $current_user = User::by_id($_SESSION['userid']);
     } else {
         $current_user = false;
     }
     return $current_user;
 }
开发者ID:jlsa,项目名称:justitia,代码行数:14,代码来源:Authentication.php

示例7: init

 private static function init()
 {
     // current user is always in group
     $user = Authentication::current_user();
     if (!$user) {
         UserGroup::$current = array();
     } else {
         UserGroup::$current = array($user);
     }
     // get from session
     UserGroup::start_session();
     foreach ($_SESSION['usergroup'] as $extra_userid) {
         UserGroup::$current[] = User::by_id($extra_userid);
     }
 }
开发者ID:jlsa,项目名称:justitia,代码行数:15,代码来源:UserGroup.php

示例8: test_save

 function test_save()
 {
     //just to check and get
     $user = new User();
     $rand = md5(rand());
     $user->username = 'user_' . $rand;
     $user->fullname = 'This is the name';
     $user->email = "{$rand}@email.com";
     $user->save();
     $user_g = User::by_id($user->get_id());
     $this->assertNotNull($user_g);
     $this->assertEqual($user_g->username, $user->username);
     $this->assertEqual($user_g->email, $user->email);
     $this->assertEqual($user_g->fullname, $user->fullname);
     $this->assertEqual($user_g->get_id(), $user->get_id());
 }
开发者ID:arunoda-susiripala,项目名称:Code51,代码行数:16,代码来源:user_helper.php

示例9: write_entries

 function write_entries($entries)
 {
     echo "<table>";
     echo "<tr><th>Time</th><th>Type</th><th>Entity</th><th>Message</th><th>Judge host</th><th>User</th><th>IP</th></tr>";
     foreach ($entries as $entry) {
         echo "<tr>";
         echo "<td>" . format_date_compact($entry->time);
         echo "<td>" . htmlspecialchars(LogLevel::toString($entry->level));
         echo "<td>" . ($entry->entity_path ? "<a href=\"index.php" . htmlspecialchars($entry->entity_path) . "\">" . $entry->entity_path . "</a>" : "-");
         echo "<td>" . nl2br(htmlspecialchars($entry->message));
         echo "<td>" . ($entry->judge_host ? htmlspecialchars($entry->judge_host) : '-');
         echo "<td>" . ($entry->userid ? htmlspecialchars(User::by_id($entry->userid, false)->name_and_login()) : '-');
         echo "<td>" . ($entry->ip ? htmlspecialchars($entry->ip) : '-');
         echo "</tr>";
     }
     echo "</table>";
 }
开发者ID:jlsa,项目名称:justitia,代码行数:17,代码来源:admin_view_log.php

示例10: change_class_wrapper

 /**
  * @param User $duser
  * @param string $class
  * @throws NullUserException
  */
 private function change_class_wrapper(User $duser, $class)
 {
     global $user;
     if ($user->class->name == "admin") {
         $duser = User::by_id($_POST['id']);
         if (!$duser instanceof User) {
             throw new NullUserException("Error: the user id does not exist!");
         }
         $duser->set_class($class);
         flash_message("Class changed");
         $this->redirect_to_user($duser);
     }
 }
开发者ID:JarJak,项目名称:shimmie2,代码行数:18,代码来源:main.php

示例11: _get_user

/**
 * @return User
 */
function _get_user()
{
    global $config;
    $user = null;
    if (get_prefixed_cookie("user") && get_prefixed_cookie("session")) {
        $tmp_user = User::by_session(get_prefixed_cookie("user"), get_prefixed_cookie("session"));
        if (!is_null($tmp_user)) {
            $user = $tmp_user;
        }
    }
    if (is_null($user)) {
        $user = User::by_id($config->get_int("anon_id", 0));
    }
    assert(!is_null($user));
    return $user;
}
开发者ID:JarJak,项目名称:shimmie2,代码行数:19,代码来源:util.inc.php

示例12: log_out

 protected function log_out()
 {
     global $user, $config;
     $user = User::by_id($config->get_int("anon_id", 0));
     $this->assertNotNull($user);
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:6,代码来源:bootstrap.php

示例13: log_email

 private static function log_email($loglevel, $message, $entity_path = null, $judge_host = null)
 {
     if ($loglevel >= LOG_EMAIL_LEVEL) {
         $body = "Justitia produced a log entry.\n\n";
         $body .= "Type entry: " . LogLevel::toString($loglevel) . "\n";
         $body .= "Date: " . format_date(time()) . "\n";
         if ($entity_path != null) {
             $body .= "Entity path: " . $entity_path . "\n";
         }
         if ($judge_host != null) {
             $body .= "Judge host: " . $judge_host . "\n";
         }
         if (self::userid() != null) {
             $body .= "User: " . User::by_id(self::userid())->name_and_login() . "\n";
         }
         if (self::ip() != null) {
             $body .= "IP address: " . self::ip() . "\n";
         }
         $body .= "Message: " . $message . "\n";
         mail(LOG_EMAIL_EMAIL_ADRESSES, "Justitia logging", $body);
     }
 }
开发者ID:jlsa,项目名称:justitia,代码行数:22,代码来源:Log.php

示例14: write_get_submission_results

 function write_get_submission_results($entities)
 {
     // find submissions
     $users = array();
     foreach ($entities as $e => $entity) {
         //			// *all* submissions
         //			$all_subms = $entity->all_submissions();
         //			// for each userid => subm
         //			$subms = $entity->all_final_submissions_from($all_subms);
         $subms = $entity->all_final_submissions_quick();
         foreach ($subms as $userid => $subm) {
             if (!isset($users[$userid])) {
                 $users[$userid]['user'] = User::by_id($userid);
             }
             $users[$userid]['subms'][$e] = $subm;
         }
     }
     Timer::after("find submissions");
     // sort users by name
     $users_sorted = array();
     foreach ($users as $user) {
         $users_sorted[$user['user']->name_for_sort()] = $user;
     }
     ksort($users_sorted);
     Timer::after("sort");
     // write table
     $this->write_submission_results($entities, $users_sorted);
     Timer::after("write");
 }
开发者ID:jlsa,项目名称:justitia,代码行数:29,代码来源:admin_results.php

示例15: tryAuth

 /**
  * Try to figure who is uploading
  *
  * Currently checks for either user & session in request or cookies
  * and initializes a global User
  * @param void
  * @return void
  */
 private function tryAuth()
 {
     global $config, $user;
     if (isset($_REQUEST['user']) && isset($_REQUEST['session'])) {
         //Auth by session data from query
         $name = $_REQUEST['user'];
         $session = $_REQUEST['session'];
         $duser = User::by_session($name, $session);
         if (!is_null($duser)) {
             $user = $duser;
         } else {
             $user = User::by_id($config->get_int("anon_id", 0));
         }
     } elseif (isset($_COOKIE[$config->get_string('cookie_prefix', 'shm') . '_' . 'session']) && isset($_COOKIE[$config->get_string('cookie_prefix', 'shm') . '_' . 'user'])) {
         //Auth by session data from cookies
         $session = $_COOKIE[$config->get_string('cookie_prefix', 'shm') . '_' . 'session'];
         $user = $_COOKIE[$config->get_string('cookie_prefix', 'shm') . '_' . 'user'];
         $duser = User::by_session($user, $session);
         if (!is_null($duser)) {
             $user = $duser;
         } else {
             $user = User::by_id($config->get_int("anon_id", 0));
         }
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:33,代码来源:main.php


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