Пример #1
0
 public static function getBestUser()
 {
     if (self::$bestUserRun) {
         return self::$bestUser;
     }
     $user = null;
     $segments = URL::getItems();
     foreach ($segments as $uname) {
         if (!in_array($uname, self::$skipNames)) {
             if (is_numeric($uname)) {
                 $user = ORM::factory("user", $uname);
             } else {
                 $user = ORM::factory("user")->where('vanity_url', '=', $uname)->find();
             }
             if ($user && $user->loaded()) {
                 break;
             }
         }
     }
     if (empty($user) || !$user->loaded()) {
         $user = Auth::instance()->get_user();
     }
     if (empty($user) || !$user->loaded()) {
         $user = new stdClass();
         $user->loaded = function () {
             return false;
         };
     }
     self::$bestUserRun = true;
     self::$bestUser = $user;
     return $user;
 }
Пример #2
0
 public function __construct()
 {
     parent::__construct();
     $user = Helper_Widget::getBestUser();
     if ($user->loaded()) {
         $this->template->photos = $user->favorite_photos->limit(10)->order_by(DB::expr('RAND()'))->find_all();
         $this->template->user = $user;
     }
 }
Пример #3
0
 public function __construct()
 {
     parent::__construct();
     $user = Helper_Widget::getBestUser();
     $loggedInUser = Auth::instance()->get_user();
     if ($user->loaded()) {
         $gameUser = Helper_Game::getUser($user->id);
         $this->template->following = $gameUser->following;
         if ($user->id === $loggedInUser->id) {
             $this->template->matchingUsers = true;
             $this->template->loggedInUser = new stdClass();
             $this->template->loggedInUser->id = $loggedInUser->id;
         }
     }
 }
Пример #4
0
 public function __construct()
 {
     $user = Helper_Widget::getBestUser();
     $loggedInUser = false;
     if ($user->loaded()) {
         if (Auth::instance()->get_user()->id == $user->id) {
             $loggedInUser = true;
             $this->template = "widget/minute/myminute";
         }
         parent::__construct();
         if (!$loggedInUser) {
             $this->template->minutelink = null;
             $show = $user->slideshows->where("complete", "=", 1)->order_by("created", "DESC")->find();
             if ($show->loaded()) {
                 $this->template->minutelink = $show->getLink();
             }
         }
     } else {
         parent::__construct();
     }
 }