예제 #1
0
파일: Group.php 프로젝트: raisanen/tlon
 /**
  * getGroupsInfo(): get information (including user-lists) for groups a
  *                  user belongs to (and has READ rights to).
  * @param string $authtoken Authentication token
  * @return TlonSoapResponse Result
  */
 public function getGroupsInfo($authtoken)
 {
     if (($user = TlonUser::getByAuthToken($authtoken)) && ($ugs = TlonUserGroup::getByUsername($user['username']))) {
         $info = array();
         foreach ($ugs as $ug) {
             $groupinfo = array('username' => $user['username'], 'groupname' => $ug['groupname'], 'rights' => $ug['rights'], 'info' => '', 'users' => array());
             if ($ug['rights'] & TlonRights::READ) {
                 if ($g = TlonGroup::getByGroupname($ug['groupname'])) {
                     $groupinfo['info'] = $g['info'];
                 }
                 if ($users = TlonUserGroup::getByGroupname($ug['groupname'])) {
                     foreach ($users as $u) {
                         $userinfo = TlonUser::getByUsername($u['username']);
                         array_push($groupinfo['users'], array('username' => $u['username'], 'realname' => $userinfo ? $userinfo['realname'] : $u['username'], 'rights' => $u['rights']));
                     }
                 }
                 // if($users...
             }
             // if($ug['rights']...
             array_push($info, $groupinfo);
         }
         // foreach(...
         return $this->returnSuccess($authtoken, $info);
     } else {
         return $this->returnFailure($authtoken);
     }
 }
예제 #2
0
파일: User.php 프로젝트: raisanen/tlon
 /**
  * modify(): Update user information.
  * @param  string $authtoken Authentication token.
  * @param  string $oldpass  Old Password.
  * @param  string $password New Password.
  * @param  string $realname Real name.
  * @return TlonSoapResponse Result.
  */
 public function modify($authtoken, $oldpass, $password, $realname)
 {
     $old_user = TlonUser::getByAuthToken($authtoken);
     if ($old_user && TlonUser::checkPassword($old_user, $oldpass) && TlonUser::modify($old_user['username'], $password, $realname)) {
         return $this->returnSuccess(TlonUser::getAuthToken($old_user['username']));
     } else {
         return $this->returnFailure($authtoken);
     }
 }
예제 #3
0
파일: Document.php 프로젝트: raisanen/tlon
 private function authUser($auth_token, $document_id, $auth_rights = TlonRights::READ)
 {
     if (($u = TlonUser::getByAuthToken($auth_token)) && ($groups = TlonUserGroup::getByUsername($u['username']))) {
         foreach ($groups as $grp) {
             $gi .= ', ' . $grp['groupname'];
             if (TlonGroupDocument::hasRights($grp['groupname'], $document_id, $auth_rights)) {
                 return true;
             }
         }
     } else {
         return "No groups gotten";
     }
     return "No groups matched ({$gi})";
 }