web/lib/Zend/Gdata/Gapps.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    14  * to license@zend.com so we can send you a copy immediately.
    14  * to license@zend.com so we can send you a copy immediately.
    15  *
    15  *
    16  * @category   Zend
    16  * @category   Zend
    17  * @package    Zend_Gdata
    17  * @package    Zend_Gdata
    18  * @subpackage Gapps
    18  * @subpackage Gapps
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  * @version    $Id: Gapps.php 22511 2010-07-01 01:41:46Z tjohns $
    21  * @version    $Id: Gapps.php 24593 2012-01-05 20:35:02Z matthew $
    22  */
    22  */
    23 
    23 
    24 /**
    24 /**
    25  * @see Zend_Gdata
    25  * @see Zend_Gdata
    26  */
    26  */
    74  * @link http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html
    74  * @link http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html
    75  *
    75  *
    76  * @category   Zend
    76  * @category   Zend
    77  * @package    Zend_Gdata
    77  * @package    Zend_Gdata
    78  * @subpackage Gapps
    78  * @subpackage Gapps
    79  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    79  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    80  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    80  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    81  */
    81  */
    82 class Zend_Gdata_Gapps extends Zend_Gdata
    82 class Zend_Gdata_Gapps extends Zend_Gdata
    83 {
    83 {
    84 
    84 
  1176      */
  1176      */
  1177     public function createGroup($groupId, $groupName, $description = null, $emailPermission = null)
  1177     public function createGroup($groupId, $groupName, $description = null, $emailPermission = null)
  1178     {
  1178     {
  1179         $i = 0;
  1179         $i = 0;
  1180         $group = $this->newGroupEntry();
  1180         $group = $this->newGroupEntry();
  1181         
  1181 
  1182         $properties[$i] = $this->newProperty();
  1182         $properties[$i] = $this->newProperty();
  1183         $properties[$i]->name = 'groupId';
  1183         $properties[$i]->name = 'groupId';
  1184         $properties[$i]->value = $groupId;
  1184         $properties[$i]->value = $groupId;
  1185         $i++;
  1185         $i++;
  1186         $properties[$i] = $this->newProperty();
  1186         $properties[$i] = $this->newProperty();
  1198         if($emailPermission != null) {
  1198         if($emailPermission != null) {
  1199             $properties[$i] = $this->newProperty();
  1199             $properties[$i] = $this->newProperty();
  1200             $properties[$i]->name = 'emailPermission';
  1200             $properties[$i]->name = 'emailPermission';
  1201             $properties[$i]->value = $emailPermission;
  1201             $properties[$i]->value = $emailPermission;
  1202             $i++;
  1202             $i++;
  1203         }        
  1203         }
  1204         
  1204 
  1205         $group->property = $properties;
  1205         $group->property = $properties;
  1206 
  1206 
  1207         return $this->insertGroup($group);
  1207         return $this->insertGroup($group);
  1208     }
  1208     }
  1209 
  1209 
  1238      * may cause execution to timeout without proper precautions in place.
  1238      * may cause execution to timeout without proper precautions in place.
  1239      *
  1239      *
  1240      * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry objects
  1240      * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry objects
  1241      *              representing all groups apart of the domain.
  1241      *              representing all groups apart of the domain.
  1242      */
  1242      */
  1243     public function retrieveAllGroups() 
  1243     public function retrieveAllGroups()
  1244     {
  1244     {
  1245         return $this->retrieveAllEntriesForFeed($this->retrievePageOfGroups());
  1245         return $this->retrieveAllEntriesForFeed($this->retrievePageOfGroups());
  1246     }
  1246     }
  1247 
  1247 
  1248     /**
  1248     /**
  1255         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1255         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1256         $uri .= $this->getDomain() . '/' . $groupId;
  1256         $uri .= $this->getDomain() . '/' . $groupId;
  1257 
  1257 
  1258         $this->delete($uri);
  1258         $this->delete($uri);
  1259     }
  1259     }
  1260     
  1260 
  1261     /**
  1261     /**
  1262      * Check to see if a member id or group id is a member of group
  1262      * Check to see if a member id or group id is a member of group
  1263      *
  1263      *
  1264      * @param string $memberId Member id or group group id
  1264      * @param string $memberId Member id or group group id
  1265      * @param string $groupId Group to be checked for
  1265      * @param string $groupId Group to be checked for
  1267      */
  1267      */
  1268     public function isMember($memberId, $groupId)
  1268     public function isMember($memberId, $groupId)
  1269     {
  1269     {
  1270         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1270         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1271         $uri .= $this->getDomain() . '/' . $groupId . '/member/' . $memberId;
  1271         $uri .= $this->getDomain() . '/' . $groupId . '/member/' . $memberId;
  1272         
  1272 
  1273         //if the enitiy is not a member, an exception is thrown
  1273         //if the enitiy is not a member, an exception is thrown
  1274         try {
  1274         try {
  1275             $results = $this->get($uri);
  1275             $results = $this->get($uri);
  1276         } catch (Exception $e) {
  1276         } catch (Exception $e) {
  1277             $results = false;
  1277             $results = false;
  1351 
  1351 
  1352         $owner->property = $properties;
  1352         $owner->property = $properties;
  1353 
  1353 
  1354         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1354         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1355         $uri .= $this->getDomain() . '/' . $groupId . '/owner';
  1355         $uri .= $this->getDomain() . '/' . $groupId . '/owner';
  1356         
  1356 
  1357         return $this->insertOwner($owner, $uri);
  1357         return $this->insertOwner($owner, $uri);
  1358     }
  1358     }
  1359 
  1359 
  1360     /**
  1360     /**
  1361      * Retrieves all the owners of a group
  1361      * Retrieves all the owners of a group
  1381      */
  1381      */
  1382     public function isOwner($email, $groupId)
  1382     public function isOwner($email, $groupId)
  1383     {
  1383     {
  1384         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1384         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1385         $uri .= $this->getDomain() . '/' . $groupId . '/owner/' . $email;
  1385         $uri .= $this->getDomain() . '/' . $groupId . '/owner/' . $email;
  1386         
  1386 
  1387         //if the enitiy is not an owner of the group, an exception is thrown
  1387         //if the enitiy is not an owner of the group, an exception is thrown
  1388         try {            
  1388         try {
  1389             $results = $this->get($uri);
  1389             $results = $this->get($uri);
  1390         } catch (Exception $e) {
  1390         } catch (Exception $e) {
  1391             $results = false;
  1391             $results = false;
  1392         }
  1392         }
  1393 
  1393 
  1425     public function updateGroup($groupId, $groupName = null, $description = null,
  1425     public function updateGroup($groupId, $groupName = null, $description = null,
  1426             $emailPermission = null)
  1426             $emailPermission = null)
  1427     {
  1427     {
  1428         $i = 0;
  1428         $i = 0;
  1429         $group = $this->newGroupEntry();
  1429         $group = $this->newGroupEntry();
  1430         
  1430 
  1431         $properties[$i] = $this->newProperty();
  1431         $properties[$i] = $this->newProperty();
  1432         $properties[$i]->name = 'groupId';
  1432         $properties[$i]->name = 'groupId';
  1433         $properties[$i]->value = $groupId;
  1433         $properties[$i]->value = $groupId;
  1434         $i++;
  1434         $i++;
  1435 
  1435 
  1451             $properties[$i] = $this->newProperty();
  1451             $properties[$i] = $this->newProperty();
  1452             $properties[$i]->name = 'emailPermission';
  1452             $properties[$i]->name = 'emailPermission';
  1453             $properties[$i]->value = $emailPermission;
  1453             $properties[$i]->value = $emailPermission;
  1454             $i++;
  1454             $i++;
  1455         }
  1455         }
  1456         
  1456 
  1457         $group->property = $properties;
  1457         $group->property = $properties;
  1458 
  1458 
  1459         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1459         $uri  = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/';
  1460         $uri .= $this->getDomain() . '/' . $groupId;
  1460         $uri .= $this->getDomain() . '/' . $groupId;
  1461 
  1461 
  1462         return $this->updateEntry($group, $uri, 'Zend_Gdata_Gapps_GroupEntry');        
  1462         return $this->updateEntry($group, $uri, 'Zend_Gdata_Gapps_GroupEntry');
  1463     }
  1463     }
  1464 
  1464 
  1465     /**
  1465     /**
  1466      * Retrieve all of the groups that a user is a member of
  1466      * Retrieve all of the groups that a user is a member of
  1467      *
  1467      *
  1468      * @param string $memberId Member username
  1468      * @param string $memberId Member username
  1469      * @param bool $directOnly (Optional) If true, members with direct association 
  1469      * @param bool $directOnly (Optional) If true, members with direct association
  1470      *             only will be considered
  1470      *             only will be considered
  1471      * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry
  1471      * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry
  1472      *              objects representing all groups member is apart of in the domain.
  1472      *              objects representing all groups member is apart of in the domain.
  1473      */
  1473      */
  1474     public function retrieveGroups($memberId, $directOnly = null)
  1474     public function retrieveGroups($memberId, $directOnly = null)