static function removeGroup( $classID, $classVersion, $selectedGroup )
    {
        $class = eZContentClass::fetch( $classID, true, eZContentClass::VERSION_STATUS_DEFINED );
        if ( !$class )
            return false;
        $groups = $class->attribute( 'ingroup_list' );
        foreach ( array_keys( $groups ) as $key )
        {
            if ( in_array( $groups[$key]->attribute( 'group_id' ), $selectedGroup ) )
            {
                unset( $groups[$key] );
            }
        }

        if ( count( $groups ) == 0 )
        {
            return false;
        }
        else
        {
            foreach(  $selectedGroup as $group_id )
            {
                eZContentClassClassGroup::removeGroup( $classID, $classVersion, $group_id );
            }
        }
        return true;
    }
Beispiel #2
0
 private function removeFromGroup($classIdentifier, $groupIdentifier)
 {
     $classObject = eZContentClass::fetchByIdentifier($classIdentifier);
     $groupObject = eZContentClassGroup::fetchByName($groupIdentifier);
     if (!$classObject) {
         throw new Exception("Invalid Class Identifier. [" . $classIdentifier . "]");
     }
     if (!$groupObject) {
         throw new Exception("Invalid Group Identifier. [" . $groupIdentifier . "]");
     }
     $db = eZDB::instance();
     $db->begin();
     eZContentClassClassGroup::removeGroup($classObject->ID, null, $groupObject->ID);
     $db->commit();
     echo "Successfully removed class [" . $classIdentifier . "] from group [" . $groupIdentifier . "]";
 }
 protected function syncGroups()
 {
     $remote = $this->getRemote();
     if ($remote === null) {
         throw new Exception("Classe remota non trovata");
     }
     $this->syncAllGroups($remote);
     $locale = $this->currentClass;
     /** @var eZContentClassClassGroup[] $localGroups */
     $localGroups = $locale->fetchGroupList();
     //$localGroupsNames = array();
     //$remoteGroupsNames = array();
     foreach ($localGroups as $group) {
         /** @var eZContentClassGroup $classGroup */
         $classGroup = eZContentClassGroup::fetchByName($group->attribute('group_name'));
         if ($classGroup) {
             eZContentClassClassGroup::removeGroup($this->currentClass->attribute('id'), $this->currentClass->attribute('version'), $classGroup->attribute('id'));
         }
     }
     foreach ($remote->InGroups as $group) {
         /** @var eZContentClassGroup $classGroup */
         $classGroup = eZContentClassGroup::fetchByName($group->GroupName);
         if ($classGroup) {
             $ingroup = eZContentClassClassGroup::create($this->currentClass->attribute('id'), $this->currentClass->attribute('version'), $classGroup->attribute('id'), $classGroup->attribute('name'));
             $ingroup->store();
         }
     }
     //$groups = $this->currentClass->attribute( 'ingroup_list' );
     //if ( count( $groups ) == 0 )
     //{
     //    //@todo
     //}
 }