Ejemplo n.º 1
0
 public function index($slug = null)
 {
     //No document requested, list documents
     if (null == $slug) {
         $docs = Doc::all();
         $data = array('docs' => $docs, 'page_id' => 'docs', 'page_title' => 'All Documents');
         return View::make('doc.index', $data);
     }
     try {
         //Retrieve requested document
         $doc = Doc::where('slug', $slug)->with('statuses')->with('userSponsor')->with('groupSponsor')->with('categories')->with('dates')->first();
         if (!isset($doc)) {
             App::abort('404');
         }
         $showAnnotationThanks = false;
         if (Auth::check()) {
             $userId = Auth::user()->id;
             $userMeta = UserMeta::where('user_id', '=', $userId)->where('meta_key', '=', UserMeta::TYPE_SEEN_ANNOTATION_THANKS)->take(1)->first();
             if ($userMeta instanceof UserMeta) {
                 $showAnnotationThanks = !$userMeta->meta_value;
             } else {
                 $showAnnotationThanks = true;
             }
         }
         //Set data array
         $data = array('doc' => $doc, 'page_id' => strtolower(str_replace(' ', '-', $doc->title)), 'page_title' => $doc->title, 'showAnnotationThanks' => $showAnnotationThanks);
         //Render view and return
         return View::make('doc.reader.index', $data);
     } catch (Exception $e) {
         return Redirect::to('/')->with('error', $e->getMessage());
     }
     App::abort('404');
 }
Ejemplo n.º 2
0
 public static function postProfile()
 {
     if (current_user_can('profile')) {
         $user_id = get_current_user_id();
         $usermeta = \UserMeta::where('user_id', $user_id)->first();
         $usermeta->updateMe(\Input::all());
         self::profile();
     }
 }
Ejemplo n.º 3
0
 public function getVerify()
 {
     $this->beforeFilter('admin');
     $userQuery = UserMeta::where('meta_key', 'verify');
     if (Input::get('status')) {
         $userQuery->where('meta_value', Input::get('status'));
     }
     $requests = $userQuery->with('user')->get();
     return Response::json($requests);
 }
Ejemplo n.º 4
0
 /**
  * 	Verification request view
  */
 public function getVerifications()
 {
     $user = Auth::user();
     if (!$user->can('admin_verify_users')) {
         return Redirect::to('/dashboard')->with('message', "You do not have permission");
     }
     $requests = UserMeta::where('meta_key', 'verify')->with('user')->get();
     $data = array('page_id' => 'verify_users', 'page_title' => 'Verify Users', 'requests' => $requests);
     return View::make('dashboard.verify-account', $data);
 }
Ejemplo n.º 5
0
 /**
  * sanitize the params .(if there was a problem in a occurred an exception will throw )
  *
  * @param array $wpNeeds
  * @return mixed returns user or errors
  */
 public function register(array $wpNeeds)
 {
     $user = new \stdClass();
     $user->user = null;
     $user->error = false;
     if ($error = $this->sanitize($wpNeeds) === true) {
         /**
          * making object from arrays for easier writability
          */
         $wpNeedsObj = $this->formatter->arrayToStdClass($wpNeeds);
         /**
          * doing the registration
          */
         $id = $this->insertUser($wpNeeds);
         /**
          * fetching registered user
          */
         if (is_integer($id)) {
             $user = new \WP_User($id);
             $user->add_cap("profile");
             $usermeta = new \UserMeta();
             $usermeta->user_id = $id;
             $usermeta->save();
             $usermeta = \UserMeta::where('user_id', $id)->first();
             $user = \WpUser::where("ID", $id)->first();
             $user->meta_id = $usermeta->id;
             $user->save();
             $user->user = $this->db->getRegisteredUser($id);
             unset($user->error);
             /**
              * user structure is
              * $user->user
              * $user->email
              */
             return $user;
         }
         return $user;
     }
     $user->error = $error;
     return $user;
 }
Ejemplo n.º 6
0
 /**
  * Get user by Facebook id.
  * 
  * @param  string  $token
  * @return \FIIP\Users\User|null
  */
 public function getByFacebook($id)
 {
     $meta = UserMeta::where('key', 'facebook')->where('value', $id)->first();
     return $meta ? $meta->user : null;
 }
Ejemplo n.º 7
0
 /**
  *	getValidSponsors.
  *
  *	@todo I'm not sure what exactly this does at first glance
  */
 public function getValidSponsors()
 {
     $collection = new Collection();
     $groups = GroupMember::where('user_id', '=', $this->id)->whereIn('role', array(Group::ROLE_EDITOR, Group::ROLE_OWNER))->get();
     foreach ($groups as $groupMember) {
         $collection->add($groupMember->group()->first());
     }
     $users = UserMeta::where('user_id', '=', $this->id)->where('meta_key', '=', UserMeta::TYPE_INDEPENDENT_SPONSOR)->where('meta_value', '=', '1')->get();
     foreach ($users as $userMeta) {
         $collection->add($userMeta->user()->first());
     }
     return $collection;
 }
Ejemplo n.º 8
0
 public function getVerify()
 {
     $this->beforeFilter('admin');
     $requests = UserMeta::where('meta_key', 'verify')->with('user')->get();
     return Response::json($requests);
 }
Ejemplo n.º 9
0
 public static function getAllValidSponsors()
 {
     $userMeta = UserMeta::where('meta_key', '=', UserMeta::TYPE_INDEPENDENT_SPONSOR)->where('meta_value', '=', 1)->get();
     $groups = Group::where('status', '=', Group::STATUS_ACTIVE)->get();
     $results = new Collection();
     $userIds = array();
     foreach ($userMeta as $m) {
         $userIds[] = $m->user_id;
     }
     if (!empty($userIds)) {
         $users = User::whereIn('id', $userIds)->get();
         foreach ($users as $user) {
             $row = array('display_name' => "{$user->fname} {$user->lname}", 'sponsor_type' => 'individual', 'id' => $user->id);
             $results->add($row);
         }
     }
     foreach ($groups as $group) {
         $row = array('display_name' => $group->display_name, 'sponsor_type' => 'group', 'id' => $group->id);
         $results->add($row);
     }
     return $results;
 }