GalleryGroup * @g2 GalleryEntity * @g2 * @g2 1 * @g2 1 * @g2 * @g2 * * @package GalleryCore * @subpackage Classes * @author Bharat Mediratta * @version $Revision: 17580 $ */ class GalleryGroup extends GalleryEntity { /** * The group type * @var int * * @g2 * @g2 groupType * @g2 INTEGER * @g2 * @g2 */ var $groupType; /** * The group name * @var string * * @g2 * @g2 groupName * @g2 STRING * @g2 MEDIUM * @g2 * @g2 READ * @g2 */ var $groupName; /** * Create a new instance of this GalleryGroup in the persistent store * * @param string $groupName the name of the new group * @param int $groupType the type of group * @return GalleryStatus a status code */ function create($groupName, $groupType=GROUP_NORMAL) { global $gallery; /* Check to see if we have a collision */ $query = ' SELECT [GalleryGroup::id] FROM [GalleryGroup] WHERE [GalleryGroup::groupName] = ? '; list ($ret, $results) = $gallery->search($query, array($groupName), array('limit' => array('count' => 1))); if ($ret) { return $ret; } $result = $results->nextResult(); if ($result[0] > 0) { return GalleryCoreApi::error(ERROR_COLLISION); } $ret = parent::create(); if ($ret) { return $ret; } $this->setGroupName($groupName); $this->setGroupType($groupType); return null; } /** * Delete this GalleryGroup. * Do some bookkeeping, like removing any user/group mappings. * * @return GalleryStatus a status code */ function delete() { /* Don't allow to delete the special groups (admin, registered, everybody) */ if ($this->getGroupType() != GROUP_NORMAL) { return GalleryCoreApi::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__, 'Special groups cannot be deleted!'); } $ret = GalleryCoreApi::removeAllUsersFromGroup($this->getId()); if ($ret) { return $ret; } /* Delete all permissions from the permissions map table */ $ret = GalleryCoreApi::removeMapEntry( 'GalleryAccessMap', array('userOrGroupId' => $this->getId())); if ($ret) { return $ret; } $ret = parent::delete(); if ($ret) { return $ret; } return null; } /** * @see GalleryEntity::itemTypeName */ function itemTypeName($localized = true) { if ($localized) { list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core'); if (! $ret) { return array($core->translate('Group'), $core->translate('group')); } } return array('Group', 'group'); } /** * @see GalleryEntity::getClassName */ function getClassName() { return 'GalleryGroup'; } function getGroupType() { return $this->groupType; } function setGroupType($groupType) { $this->groupType = $groupType; } function getGroupName() { return $this->groupName; } function setGroupName($groupName) { $this->groupName = $groupName; } } ?>