Users::getUser PHP Method

getUser() private method

private getUser ( $cond )
    private function getUser($cond)
    {
        $res = Sql::select('uc_members.uid', 'pre_common_member_profile.realname as alias', 'pre_common_member_profile.avatar', 'pre_common_member_profile.level', 'pre_common_member_profile.ext')->from('uc_members')->leftJoin('pre_common_member_profile')->on('uc_members.uid=pre_common_member_profile.uid')->whereArgs($cond)->get($this->db);
        if (count($res)) {
            $ext = json_decode($res[0]['ext'], true);
            unset($res[0]['ext']);
            if (isset($ext['education'])) {
                $res[0]['education'] = $ext['education'];
            }
            if (isset($ext['company'])) {
                $res[0]['company'] = $ext['company'];
            }
            if (isset($ext['fields'])) {
                $res[0]['fields'] = $ext['fields'];
            }
        }
        return count($res) > 0 ? $res[0] : false;
    }

Usage Example

示例#1
0
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the user
     $users = new Users();
     $user = $users->getUser($widget['user_id']);
     // Get all sources configured for that user
     $properties = new Properties(array(Properties::KEY => $user->id));
     // Get the bio data
     // User profile
     $this->view->username = $user->username;
     $this->view->first_name = $properties->getProperty('first_name');
     $this->view->last_name = $properties->getProperty('last_name');
     $this->view->bio = $properties->getProperty('bio');
     $this->view->location = $properties->getProperty('location');
     $this->view->avatar = $properties->getProperty('avatar_image');
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "About {$user->username}";
 }
All Usage Examples Of Users::getUser