コード例 #1
0
ファイル: update.php プロジェクト: Trideon/gigolo
$params = array_merge($params, $_REQUEST);
if ($ikey != NULL && $ikey != $params['ikey']) {
    header('HTTP/1.1 401 Unauthorized', true, 401);
    print json_encode(array('message' => "your iKey is invalid", 'ikey' => $ikey, 'param_ikey' => $params['ikey']));
    return;
}
foreach (array('rn', 'username') as $key) {
    if (!$params[$key]) {
        header('HTTP/1.1 406 Not Acceptable', true, 406);
        print json_encode(array('message' => "{$key} has to be set"));
        return;
    }
}
$rn = $params['rn'];
$userRepo = new UserRepository();
$user = $userRepo->LoadByUsername($params['username']);
if ($user instanceof NullUser) {
    header('HTTP/1.1 403 Forbidden', true, 403);
    print json_encode(array('message' => "invalid userId"));
    return;
}
$user_session = new UserSession($user->Id());
// load resource by contact_info or rid
$resourceRepository = new ResourceRepository();
$contact_info = trim($_REQUEST['contact_info']);
$rid = trim($_REQUEST['rid']);
if ($contact_info && $rid) {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "You must not set both contact_info and rid"));
    return;
}
コード例 #2
0
ファイル: Ldap.php プロジェクト: hugutux/booked
 public function Login($username, $loginContext)
 {
     $username = $this->CleanUsername($username);
     if ($this->LdapUserExists()) {
         $this->Synchronize($username);
     }
     $repo = new UserRepository();
     $user = $repo->LoadByUsername($username);
     $user->Deactivate();
     $user->Activate();
     $repo->Update($user);
     return $this->authToDecorate->Login($username, $loginContext);
 }
コード例 #3
0
ファイル: create.php プロジェクト: Trideon/gigolo
$ends_at = $_REQUEST['ends_at'];
#$recurrence   = $_REQUEST['recurrence'];
$title = $_REQUEST['summary'];
$description = $_REQUEST['description'];
$contact_info = trim($_REQUEST['contact_info']);
$rid = trim($_REQUEST['rid']);
##$regexp_email = firstname.lastname@aaa.bbb.com;
$regexp_email = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}\$/";
if (preg_match($regexp_email, $contact_info)) {
    $contact_info = strtolower($contact_info);
}
/*************************************************
 	user information
 *************************************************/
$userRepository = new UserRepository();
$user = $userRepository->LoadByUsername($username);
if ($user instanceof NullUser) {
    header('HTTP/1.1 403 Forbidden', true, 403);
    print json_encode(array('message' => "invalid userId"));
    return;
}
$user_session = new UserSession($user->Id());
$user_session->Timezone = 'UTC';
/*************************************************
 	resources
 *************************************************/
$resourceRepository = new ResourceRepository();
if ($contact_info && $rid) {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "You must not set both contact_info and rid"));
    return;
コード例 #4
0
 public function testCanLoadUserByUserName()
 {
     $userName = '******';
     $userId = 982;
     $loginCommand = new LoginCommand(strtolower($userName));
     $loadEmailPreferencesCommand = new GetUserEmailPreferencesCommand($userId);
     $loadPermissionsCommand = new GetUserPermissionsCommand($userId);
     $loadGroupsCommand = new GetUserGroupsCommand($userId, null);
     $loadOwnedGroups = new GetGroupsIManageCommand($userId);
     $loadPreferences = new GetUserPreferencesCommand($userId);
     $userRow = $this->GetUserRow($userId);
     $emailPrefRows = $this->GetEmailPrefRows();
     $permissionsRows = $this->GetPermissionsRows();
     $groupsRows = $this->GetGroupsRows();
     $attributeRows = $this->GetAttributeRows();
     $ownedGroupRows = $this->GetOwnedGroupRows();
     $preferenceRows = $this->GetPreferenceRows();
     $this->db->SetRow(0, array($userRow));
     $this->db->SetRow(1, $emailPrefRows);
     $this->db->SetRow(2, $permissionsRows);
     $this->db->SetRow(3, $groupsRows);
     $this->db->SetRow(4, $attributeRows);
     $this->db->SetRow(5, $ownedGroupRows);
     $this->db->SetRow(6, $preferenceRows);
     $userRepository = new UserRepository();
     $user = $userRepository->LoadByUsername($userName);
     $this->assertEquals(7, count($this->db->_Commands));
     $this->assertTrue($this->db->ContainsCommand($loginCommand));
     $this->assertTrue($this->db->ContainsCommand($loadEmailPreferencesCommand));
     $this->assertTrue($this->db->ContainsCommand($loadPermissionsCommand));
     $this->assertTrue($this->db->ContainsCommand($loadGroupsCommand));
     $this->assertTrue($this->db->ContainsCommand($loadOwnedGroups));
     $this->assertTrue($this->db->ContainsCommand($loadPreferences));
     $this->assertEquals($userId, $user->Id());
 }