コード例 #1
0
ファイル: NameTest.php プロジェクト: jorgenils/zend-framework
    public function testNormalNameShouldHaveNoExtensionElements() {
        $this->name->givenName = "John";
        $this->name->familyName = "Doe";

        $this->assertEquals("John", $this->name->givenName);
        $this->assertEquals("Doe", $this->name->familyName);

        $this->assertEquals(0, count($this->name->extensionElements));
        $newName = new Zend_Gdata_Gapps_Extension_Name();
        $newName->transferFromXML($this->name->saveXML());
        $this->assertEquals(0, count($newName->extensionElements));
        $newName->extensionElements = array(
                new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
        $this->assertEquals(1, count($newName->extensionElements));
        $this->assertEquals("John", $newName->givenName);
        $this->assertEquals("Doe", $newName->familyName);

        /* try constructing using magic factory */
        $gdata = new Zend_Gdata_Gapps();
        $newName2 = $gdata->newName();
        $newName2->transferFromXML($newName->saveXML());
        $this->assertEquals(1, count($newName2->extensionElements));
        $this->assertEquals("John", $newName2->givenName);
        $this->assertEquals("Doe", $newName2->familyName);
    }
コード例 #2
0
 public function create_user_account($user_info)
 {
     $password = $this->createPassword();
     $client = Zend_Gdata_ClientLogin::getHttpClient($this->email, $this->password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
     $gdata = new Zend_Gdata_Gapps($client, $this->domain);
     $res[0] = $gdata->createUser($user_info['accountname'], $user_info['givenname'], $user_info['familyname'], $password, $passwordHashFunction = null, $quota = null);
     $res[1] = $password;
     return $res;
 }
コード例 #3
0
ファイル: QuotaTest.php プロジェクト: omusico/sugar_work
 public function testNormalQuotaShouldHaveNoExtensionElements()
 {
     $this->quota->limit = "123456789";
     $this->assertEquals("123456789", $this->quota->limit);
     $this->assertEquals(0, count($this->quota->extensionElements));
     $newQuota = new Zend_Gdata_Gapps_Extension_Quota();
     $newQuota->transferFromXML($this->quota->saveXML());
     $this->assertEquals(0, count($newQuota->extensionElements));
     $newQuota->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newQuota->extensionElements));
     $this->assertEquals("123456789", $newQuota->limit);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata_Gapps();
     $newQuota2 = $gdata->newQuota();
     $newQuota2->transferFromXML($newQuota->saveXML());
     $this->assertEquals(1, count($newQuota2->extensionElements));
     $this->assertEquals("123456789", $newQuota2->limit);
 }
コード例 #4
0
 public function testNormalEmailListShouldHaveNoExtensionElements()
 {
     $this->emailList->name = "test-name";
     $this->assertEquals("test-name", $this->emailList->name);
     $this->assertEquals(0, count($this->emailList->extensionElements));
     $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList();
     $newEmailList->transferFromXML($this->emailList->saveXML());
     $this->assertEquals(0, count($newEmailList->extensionElements));
     $newEmailList->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newEmailList->extensionElements));
     $this->assertEquals("test-name", $newEmailList->name);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata_Gapps();
     $newEmailList2 = $gdata->newEmailList();
     $newEmailList2->transferFromXML($newEmailList->saveXML());
     $this->assertEquals(1, count($newEmailList2->extensionElements));
     $this->assertEquals("test-name", $newEmailList2->name);
 }
コード例 #5
0
ファイル: PropertyTest.php プロジェクト: vicfryzel/zf
 public function testNormalPropertyShouldHaveNoExtensionElements()
 {
     $this->property->name = "HairColor";
     $this->property->value = "Red";
     $this->assertEquals("HairColor", $this->property->name);
     $this->assertEquals("Red", $this->property->value);
     $this->assertEquals(0, count($this->property->extensionElements));
     $newProperty = new Zend_Gdata_Gapps_Extension_Property();
     $newProperty->transferFromXML($this->property->saveXML());
     $this->assertEquals(0, count($newProperty->extensionElements));
     $newProperty->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newProperty->extensionElements));
     $this->assertEquals("HairColor", $newProperty->name);
     $this->assertEquals("Red", $newProperty->value);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata_Gapps();
     $newProperty2 = $gdata->newProperty();
     $newProperty2->transferFromXML($newProperty->saveXML());
     $this->assertEquals(1, count($newProperty2->extensionElements));
     $this->assertEquals("HairColor", $newProperty2->name);
     $this->assertEquals("Red", $newProperty2->value);
 }
コード例 #6
0
/**
 * Remove an existing recipient from an email list.
 *
 * @param  Zend_Gdata_Gapps $gapps            The service object to use for communicating with the
 *                                            Google Apps server.
 * @param  boolean          $html             True if output should be formatted for display in a
 *                                            web browser.
 * @param  string           $recipientAddress The address of the recipient who should be removed.
 * @param  string           $emailList        The email list from which the recipient should be removed.
 * @return void
 */
function removeRecipientFromEmailList($gapps, $html, $recipientAddress, $emailList)
{
    if ($html) {
        echo "<h2>Unsubscribe Recipient</h2>\n";
    }
    $gapps->removeRecipientFromEmailList($recipientAddress, $emailList);
    if ($html) {
        echo "<p>Done.</p>\n";
    }
}
コード例 #7
0
ファイル: LoginTest.php プロジェクト: netvlies/zf
 public function testNormalLoginShouldHaveNoExtensionElements()
 {
     $this->login->username = "******";
     $this->login->password = "******";
     $this->login->hashFunctionName = "Foo";
     $this->login->suspended = true;
     $this->login->admin = true;
     $this->login->changePasswordAtNextLogin = true;
     $this->login->agreedToTerms = false;
     $this->assertEquals("johndoe", $this->login->username);
     $this->assertEquals("abcdefg1234567890", $this->login->password);
     $this->assertEquals("Foo", $this->login->hashFunctionName);
     $this->assertEquals(true, $this->login->suspended);
     $this->assertEquals(true, $this->login->admin);
     $this->assertEquals(true, $this->login->changePasswordAtNextLogin);
     $this->assertEquals(false, $this->login->agreedToTerms);
     $this->assertEquals(0, count($this->login->extensionElements));
     $newLogin = new Zend_Gdata_Gapps_Extension_Login();
     $newLogin->transferFromXML($this->login->saveXML());
     $this->assertEquals(0, count($newLogin->extensionElements));
     $newLogin->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newLogin->extensionElements));
     $this->assertEquals("johndoe", $newLogin->username);
     $this->assertEquals("abcdefg1234567890", $newLogin->password);
     $this->assertEquals("Foo", $newLogin->hashFunctionName);
     $this->assertEquals(true, $newLogin->suspended);
     $this->assertEquals(true, $newLogin->admin);
     $this->assertEquals(true, $newLogin->changePasswordAtNextLogin);
     $this->assertEquals(false, $newLogin->agreedToTerms);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata_Gapps();
     $newLogin2 = $gdata->newLogin();
     $newLogin2->transferFromXML($newLogin->saveXML());
     $this->assertEquals(1, count($newLogin2->extensionElements));
     $this->assertEquals("johndoe", $newLogin2->username);
     $this->assertEquals("abcdefg1234567890", $newLogin2->password);
     $this->assertEquals("Foo", $newLogin2->hashFunctionName);
     $this->assertEquals(true, $newLogin2->suspended);
     $this->assertEquals(true, $newLogin2->admin);
     $this->assertEquals(true, $newLogin2->changePasswordAtNextLogin);
     $this->assertEquals(false, $newLogin2->agreedToTerms);
 }
コード例 #8
0
function google_reset_password($password = "")
{
    global $db, $GOOGLE_APPS, $ENTRADA_USER;
    if (isset($GOOGLE_APPS) && is_array($GOOGLE_APPS) && isset($GOOGLE_APPS["active"]) && (bool) $GOOGLE_APPS["active"] && $password) {
        $query = "\tSELECT a.*, b.`group`, b.`role`\n\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\tON a.`id` = b.`user_id`\n\t\t\t\t\tWHERE a.`id` = " . $db->qstr($ENTRADA_USER->getID()) . "\n\t\t\t\t\tAND b.`app_id` = " . $db->qstr(AUTH_APP_ID);
        $result = $db->GetRow($query);
        if ($result) {
            if (!in_array($result["google_id"], array("", "opt-out", "opt-in"))) {
                try {
                    $client = Zend_Gdata_ClientLogin::getHttpClient($GOOGLE_APPS["admin_username"], $GOOGLE_APPS["admin_password"], Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
                    $service = new Zend_Gdata_Gapps($client, $GOOGLE_APPS["domain"]);
                    $account = $service->retrieveUser($result["google_id"]);
                    $account->login->password = $password;
                    $account->save();
                    application_log("success", "Successfully updated Google account password for google_id [" . $result["google_id"] . "] and proxy_id [" . $ENTRADA_USER->getID() . "].");
                    return true;
                } catch (Zend_Gdata_Gapps_ServiceException $e) {
                    application_log("error", "Unable to change password for google_id [" . $google_id . "] for proxy_id [" . $ENTRADA_USER->getID() . "]. Error details: [" . $error->getErrorCode() . "] " . $error->getReason() . ".");
                    if (is_array($e->getErrors())) {
                        foreach ($e->getErrors() as $error) {
                            application_log("error", "Unable to change password for google_id [" . $google_id . "] for proxy_id [" . $ENTRADA_USER->getID() . "]. Error details: [" . $error->getErrorCode() . "] " . $error->getReason() . ".");
                        }
                    }
                }
            }
        } else {
            application_log("error", "google_reset_password() failed because we were unable to fetch information on proxy_id [" . $ENTRADA_USER->getID() . "]. Database said: " . $db->ErrorMsg());
        }
    }
    return false;
}
コード例 #9
0
ファイル: gapps.php プロジェクト: name256/crm42
<?php

Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$domain = 'couleetechlink.com';
//CTLTODO make this a global setting
$email = $username . '@' . $domain;
ob_start();
try {
    $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, 'apps');
    $apps = new Zend_Gdata_Gapps($client, $domain);
    $gdClient = new Zend_Gdata($client);
    $user = $apps->retrieveUser($username);
    $logged_in = true;
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
    echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
    echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
    $logged_in = false;
    file_put_contents('/var/log/email_client.log', 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl(), FILE_APPEND);
} catch (Zend_Gdata_App_AuthException $ae) {
    echo 'Problem authenticating: ' . $ae->exception() . "\n";
    file_put_contents('/var/log/email_client.log', 'Problem authenticating: ' . $ae->exception() . "\n{$username} {$password}\n", FILE_APPEND);
    $logged_in = false;
}
ob_end_clean();
if ($logged_in == true) {
    $user_info = array();
    $user_info['user_name'] = $username;
コード例 #10
0
ファイル: getmembers.php プロジェクト: rolfnjorjensen/Buck
<?php

require_once 'init.php';
$email = '*****@*****.**';
$password = '******';
$domain = "domain.com";
require_once 'secret.php';
//here are the actual email/pw/domain values >D
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$service = new Zend_Gdata_Gapps($client, $domain);
$feed = $service->retrieveAllUsers();
foreach ($feed as $user) {
    echo "  * " . $user->login->username . ' (' . $user->name->givenName . ' ' . $user->name->familyName . ")\n";
    var_dump($es->add('member', $user->login->username, json_encode(array('handle' => $user->login->username, 'name' => $user->name->givenName . ' ' . $user->name->familyName, 'level' => 1))));
}