Exemplo n.º 1
0
 /** Tries to return the correct profile from a given hrpid.
  */
 private function findProfile($hrpid = null)
 {
     if (is_null($hrpid)) {
         $user = S::user();
         if (!$user->hasProfile()) {
             return PL_NOT_FOUND;
         } else {
             $profile = $user->profile(false, 0, Visibility::get(Visibility::VIEW_ADMIN));
         }
     } else {
         $profile = Profile::get($hrpid, 0, Visibility::get(Visibility::VIEW_ADMIN));
     }
     if (!$profile) {
         return PL_NOT_FOUND;
     } else {
         if (!S::user()->canEdit($profile) && Platal::notAllowed()) {
             return PL_FORBIDDEN;
         }
     }
     return $profile;
 }