示例#1
0
 public static function getUserDetails($user_id)
 {
     $user_fields = \Config::get('webshoppack::user_fields');
     $user_id_field = \Config::get('webshoppack::user_id_field');
     $user_table = \Config::get('webshoppack::user_table');
     $user_details = array();
     $fields = '';
     foreach ($user_fields as $key => $field) {
         if ($fields != '') {
             $fields .= ', ';
         }
         $fields .= $field . ' AS ' . $key;
     }
     $user_info = \DB::select('SELECT ' . $fields . ' FROM ' . $user_table . ' WHERE ' . $user_id_field . ' = \'' . $user_id . '\'');
     if (count($user_info) > 0) {
         foreach ($user_info as $user_det) {
             $user_details['user_code'] = CUtil::setUserCode($user_id);
             if (isset($user_det->fname)) {
                 $user_details['first_name'] = $user_det->fname;
             }
             if (isset($user_det->lname)) {
                 $user_details['last_name'] = $user_det->lname;
             }
             if (isset($user_det->email)) {
                 $user_details['email'] = $user_det->email;
             }
             if (isset($user_det->fname) && isset($user_det->lname)) {
                 $user_details['display_name'] = ucfirst($user_det->fname) . ' ' . ucfirst(substr($user_det->lname, 0, 1));
             }
         }
     }
     $user_details['profile_url'] = \URL::to(\Config::get('webshopauthenticate::uri')) . "/" . $user_details['user_code'];
     //."-". strtolower(str_replace(" ","", $user_details['first_name']));
     return $user_details;
 }
 public function fetchUserDetails($ident, $type)
 {
     $search_cond = 'users.user_id = ' . $ident;
     if ($type == 'code') {
         $search_cond = 'users.user_code = ' . $ident;
     }
     $user_details = array();
     $user_details['err_msg'] = '';
     $user_details['own_profile'] = 'No';
     $udetails = User::whereRaw($search_cond)->first(array('users.first_name', 'users.id', 'users.last_name', 'users.email', 'users.activated', 'users.activated_at'));
     if (count($udetails) > 0) {
         $user_details['user_code'] = CUtil::setUserCode($udetails['id']);
         $user_details['email'] = $udetails['email'];
         $user_details['user_id'] = $user_id = $udetails['id'];
         $user_details['first_name'] = $udetails['first_name'];
         $user_details['last_name'] = $udetails['last_name'];
         $user_display_name = $udetails['first_name'] . ' ' . substr($udetails['last_name'], 0, 1);
         $user_details['display_name'] = ucwords($user_display_name);
         $user_details['activated_at'] = $udetails['activated_at'];
         $user_details['activated'] = $udetails['activated'];
     } else {
         $user_details['err_msg'] = 'No such user found';
     }
     return $user_details;
 }