gapps.php

来自「Bug tracker, and reporter.」· PHP 代码 · 共 1,074 行 · 第 1/3 页

PHP
1,074
字号
     *          or Query.     * @return Zend_Gdata_Gapps_EmailListFeed     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function getEmailListFeed($location = null)    {        if ($location === null) {            $uri = $this->getBaseUrl() . self::APPS_NICKNAME_PATH;        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_Gapps_EmailListFeed');    }    /**     * Retreive EmailListRecipientFeed object containing multiple      * EmailListRecipientEntry objects.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Gapps_EmailListRecipientFeed     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function getEmailListRecipientFeed($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_Gapps_EmailListRecipientFeed');    }    /**     * Retreive a single UserEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Gapps_UserEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function getUserEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_Gapps_UserEntry');    }    /**     * Retreive a single NicknameEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Gapps_NicknameEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function getNicknameEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_Gapps_NicknameEntry');    }    /**     * Retreive a single EmailListEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Gapps_EmailListEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function getEmailListEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_Gapps_EmailListEntry');    }    /**     * Retreive a single EmailListRecipientEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Gapps_EmailListRecipientEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function getEmailListRecipientEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_Gapps_EmailListRecipientEntry');    }    /**     * Create a new user from a UserEntry.     *      * @param Zend_Gdata_Gapps_UserEntry $user The user entry to insert.     * @param string $uri (optional) The URI where the user should be      *          uploaded to. If null, the default user creation URI for      *          this domain will be used.     * @return Zend_Gdata_Gapps_UserEntry The inserted user entry as      *          returned by the server.     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function insertUser($user, $uri = null)    {        if ($uri === null) {            $uri = $this->getBaseUrl() . self::APPS_USER_PATH;        }        $newEntry = $this->insertEntry($user, $uri, 'Zend_Gdata_Gapps_UserEntry');        return $newEntry;    }    /**     * Create a new nickname from a NicknameEntry.     *      * @param Zend_Gdata_Gapps_NicknameEntry $nickname The nickname entry to      *          insert.     * @param string $uri (optional) The URI where the nickname should be      *          uploaded to. If null, the default nickname creation URI for      *          this domain will be used.     * @return Zend_Gdata_Gapps_NicknameEntry The inserted nickname entry as      *          returned by the server.     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function insertNickname($nickname, $uri = null)    {        if ($uri === null) {            $uri = $this->getBaseUrl() . self::APPS_NICKNAME_PATH;        }        $newEntry = $this->insertEntry($nickname, $uri, 'Zend_Gdata_Gapps_NicknameEntry');        return $newEntry;    }    /**     * Create a new email list from an EmailListEntry.     *      * @param Zend_Gdata_Gapps_EmailListEntry $emailList The email list entry     *          to insert.     * @param string $uri (optional) The URI where the email list should be      *          uploaded to. If null, the default email list creation URI for      *          this domain will be used.     * @return Zend_Gdata_Gapps_EmailListEntry The inserted email list entry      *          as returned by the server.     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function insertEmailList($emailList, $uri = null)    {        if ($uri === null) {            $uri = $this->getBaseUrl() . self::APPS_EMAIL_LIST_PATH;        }        $newEntry = $this->insertEntry($emailList, $uri, 'Zend_Gdata_Gapps_EmailListEntry');        return $newEntry;    }        /**     * Create a new email list recipient from an EmailListRecipientEntry.     *      * @param Zend_Gdata_Gapps_EmailListRecipientEntry $recipient The recipient      *          entry to insert.     * @param string $uri (optional) The URI where the recipient should be      *          uploaded to. If null, the default recipient creation URI for      *          this domain will be used.     * @return Zend_Gdata_Gapps_EmailListRecipientEntry The inserted      *          recipient entry as returned by the server.     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function insertEmailListRecipient($recipient, $uri = null)    {        if ($uri === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'URI must not be null');        } elseif ($uri instanceof Zend_Gdata_Gapps_EmailListEntry) {            $uri = $uri->getLink('edit')->href;        }        $newEntry = $this->insertEntry($recipient, $uri, 'Zend_Gdata_Gapps_EmailListRecipientEntry');        return $newEntry;    }        /**     * Provides a magic factory method to instantiate new objects with     * shorter syntax than would otherwise be required by the Zend Framework     * naming conventions. For more information, see Zend_Gdata_App::__call().     *     * This overrides the default behavior of __call() so that query classes      * do not need to have their domain manually set when created with      * a magic factory method.     *     * @see Zend_Gdata_App::__call()     * @param string $method The method name being called     * @param array $args The arguments passed to the call     * @throws Zend_Gdata_App_Exception     */    public function __call($method, $args) {        if (preg_match('/^new(\w+Query)/', $method, $matches)) {            $class = $matches[1];            $foundClassName = null;            foreach ($this->_registeredPackages as $name) {                 try {                     require_once 'Zend/Loader.php';                     @Zend_Loader::loadClass("${name}_${class}");                     $foundClassName = "${name}_${class}";                     break;                 } catch (Zend_Exception $e) {                     // package wasn't here- continue searching                 }            }            if ($foundClassName != null) {                $reflectionObj = new ReflectionClass($foundClassName);                // Prepend the domain to the query                $args = array_merge(array($this->getDomain()), $args);                return $reflectionObj->newInstanceArgs($args);            } else {                require_once 'Zend/Gdata/App/Exception.php';                throw new Zend_Gdata_App_Exception(                        "Unable to find '${class}' in registered packages");            }        } else {            return parent::__call($method, $args);        }            }        // Convenience methods    // Specified at http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_e        /**     * Create a new user entry and send it to the Google Apps servers.     *      * @param string $username The username for the new user.     * @param string $givenName The given name for the new user.     * @param string $familyName The family name for the new user.     * @param string $password The password for the new user as a plaintext string     *                 (if $passwordHashFunction is null) or a SHA-1 hashed      *                 value (if $passwordHashFunction = 'SHA-1').     * @param string $quotaLimitInMB (optional) The quota limit for the new user in MB.     * @return Zend_Gdata_Gapps_UserEntry (optional) The new user entry as returned by      *                 server.     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function createUser ($username, $givenName, $familyName, $password,             $passwordHashFunction = null, $quotaLimitInMB = null) {        $user = $this->newUserEntry();        $user->login = $this->newLogin();        $user->login->username = $username;        $user->login->password = $password;        $user->login->hashFunctionName = $passwordHashFunction;        $user->name = $this->newName();        $user->name->givenName = $givenName;        $user->name->familyName = $familyName;        if ($quotaLimitInMB !== null) {            $user->quota = $this->newQuota();            $user->quota->limit = $quotaLimitInMB;        }        return $this->insertUser($user);    }        /**     * Retrieve a user based on their username.     *      * @param string $username The username to search for.     * @return Zend_Gdata_Gapps_UserEntry The username to search for, or null      *              if no match found.     * @throws Zend_Gdata_App_InvalidArgumentException     * @throws Zend_Gdata_App_HttpException     */    public function retrieveUser ($username) {        $query = $this->newUserQuery($username);        try {            $user = $this->getUserEntry($query);        } catch (Zend_Gdata_Gapps_ServiceException $e) {            // Set the user to null if not found            if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) {                $user = null;            } else {                throw $e;            }        }        return $user;    }        /**     * Retrieve a page of users in alphabetical order, starting with the     * provided username.     *     * @param string $startUsername (optional) The first username to retrieve.      *          If null or not declared, the page will begin with the first      *          user in the domain.     * @return Zend_Gdata_Gapps_UserFeed Collection of Zend_Gdata_UserEntry      *              objects representing all users in the domain.     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     * @throws Zend_Gdata_Gapps_ServiceException     */    public function retrievePageOfUsers ($startUsername = null) {        $query = $this->newUserQuery();        $query->setStartUsername($startUsername);        return $this->getUserFeed($query);    }        /**     * Retrieve all users in the current domain. Be aware that      * calling this function on a domain with many users will take a      * signifigant amount of time to complete. On larger domains this may      * may cause execution to timeout without proper precautions in place.     *

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?