static function addGroup( $classID, $classVersion, $selectedGroup )
 {
     list ( $groupID, $groupName ) = explode( '/', $selectedGroup );
     $ingroup = eZContentClassClassGroup::create( $classID, $classVersion, $groupID, $groupName );
     $ingroup->store();
     return true;
 }
    /**
     * Test that saving a content class in DEFINED version status
     * correctly manipulate associated class groups
     *
     * @link http://issues.ez.no/16197
     */
    public function testContentClassStillInGroupAfterEdition()
    {
        $class = eZContentClass::fetch( $this->class->id );
        // This is logic contained in kernel/class/edit.php
        foreach ( eZContentClassClassGroup::fetchGroupList( $class->attribute( 'id' ),
                                                            eZContentClass::VERSION_STATUS_DEFINED )  as $classGroup )
        {
            eZContentClassClassGroup::create( $class->attribute( 'id' ),
                                              eZContentClass::VERSION_STATUS_TEMPORARY,
                                              $classGroup->attribute( 'group_id' ),
                                              $classGroup->attribute( 'group_name' ) )
                ->store();
        }

        $attributes = $class->fetchAttributes();
        $class->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY );
        $class->NameList->setHasDirtyData();

        foreach ( $attributes as $attribute )
        {
            $attribute->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY );
            if ( $dataType = $attribute->dataType() )
                $dataType->initializeClassAttribute( $attribute );
        }

        $class->store( $attributes );
        $db = eZDB::instance();
        $db->begin();
        $class->storeVersioned( $attributes, eZContentClass::VERSION_STATUS_DEFINED );
        $db->commit();

        $this->assertTrue( eZContentClassClassGroup::classInGroup( $class->attribute( 'id' ),
                                                                   eZContentClass::VERSION_STATUS_DEFINED,
                                                                   1 ) );
    }
Exemplo n.º 3
0
 /**
  * Initialize ezpClass object
  *
  * @param string $name
  * @param string $identifier
  * @param string $contentObjectName
  * @param int $creatorID
  * @param string $language
  * @param int $groupID
  * @param string $groupName
  */
 public function __construct($name = 'Test class', $identifier = 'test_class', $contentObjectName = '<test_attribute>', $creatorID = 14, $language = 'eng-GB', $groupID = 1, $groupName = 'Content')
 {
     if (eZContentLanguage::fetchByLocale($language) === false) {
         $topPriorityLanguage = eZContentLanguage::topPriorityLanguage();
         if ($topPriorityLanguage) {
             $language = $topPriorityLanguage->attribute('locale');
         }
     }
     $this->language = $language;
     $this->class = eZContentClass::create($creatorID, array(), $this->language);
     $this->class->setName($name, $this->language);
     $this->class->setAttribute('contentobject_name', $contentObjectName);
     $this->class->setAttribute('identifier', $identifier);
     $this->class->store();
     $languageID = eZContentLanguage::idByLocale($this->language);
     $this->class->setAlwaysAvailableLanguageID($languageID);
     $this->classGroup = eZContentClassClassGroup::create($this->id, $this->version, $groupID, $groupName);
     $this->classGroup->store();
 }
Exemplo n.º 4
0
 function appendClass($class, $version = false)
 {
     if ($class instanceof eZContentClass) {
         $classID = $class->attribute('id');
         $version = $class->attribute('version');
     } else {
         $classID = $class;
     }
     $classGroupLink = eZContentClassClassGroup::create($classID, $version, $this->attribute('id'), $this->attribute('name'));
     $classGroupLink->store();
     return $classGroupLink;
 }
Exemplo n.º 5
0
            eZDebug::writeError('Undefined default language', 'class/edit.php');
            $Module->setExitStatus(eZModule::STATUS_FAILED);
            return;
        }
    }
    if (is_numeric($GroupID) and is_string($GroupName) and $GroupName != '') {
        $user = eZUser::currentUser();
        $user_id = $user->attribute('contentobject_id');
        $class = eZContentClass::create($user_id, array(), $EditLanguage);
        $class->setName(ezpI18n::tr('kernel/class/edit', 'New Class'), $EditLanguage);
        $class->store();
        $editLanguageID = eZContentLanguage::idByLocale($EditLanguage);
        $class->setAlwaysAvailableLanguageID($editLanguageID);
        $ClassID = $class->attribute('id');
        $ClassVersion = $class->attribute('version');
        $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $GroupID, $GroupName);
        $ingroup->store();
        $Module->redirectTo($Module->functionURI('edit') . '/' . $ClassID . '/(language)/' . $EditLanguage);
        return;
    } else {
        $errorResponseGroupName = $GroupName == '' ? '<Empty name>' : $GroupName;
        $errorResponseGroupID = !is_numeric($GroupID) ? '<Empty ID>' : $GroupID;
        eZDebug::writeError("Unknown class group: {$errorResponseGroupName} (ID: {$errorResponseGroupID})", 'Kernel - Class - Edit');
        $Module->setExitStatus(eZModule::STATUS_FAILED);
        return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
}
$contentClassHasInput = true;
if ($http->hasPostVariable('ContentClassHasInput')) {
    $contentClassHasInput = $http->postVariable('ContentClassHasInput');
}
Exemplo n.º 6
0
Arquivo: index.php Projeto: truffo/eep
 private function createClass($displayName, $classIdentifier, $groupIdentifier, $groupId)
 {
     $adminUserObject = eZUser::fetchByName("admin");
     $adminUserObject->loginCurrent();
     $adminUserId = $adminUserObject->attribute('contentobject_id');
     $language = eZContentLanguage::topPriorityLanguage();
     $editLanguage = $language->attribute('locale');
     $class = eZContentClass::create($adminUserId, array(), $editLanguage);
     // this is the display name, ez automatically creates the content-class-identifier from it
     $class->setName($displayName, $editLanguage);
     $class->setAttribute("identifier", $classIdentifier);
     // default naming for objects - content classes should update this value once they have attributes added
     $class->setAttribute('contentobject_name', 'eep-created-content-class');
     $class->store();
     $editLanguageID = eZContentLanguage::idByLocale($editLanguage);
     $class->setAlwaysAvailableLanguageID($editLanguageID);
     $ClassID = $class->attribute('id');
     $ClassVersion = $class->attribute('version');
     $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $groupId, $groupIdentifier);
     $ingroup->store();
     // clean up the content class status
     $class->storeDefined(array());
     $adminUserObject->logoutCurrent();
 }
 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
     //}
 }