$ClassVersion = null; if (!is_numeric($ClassID)) { return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel'); } $class = eZContentClass::fetch($ClassID, true, eZContentClass::VERSION_STATUS_DEFINED); if (!$class) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } if (!$LanguageCode) { $LanguageCode = $class->attribute('top_priority_language_locale'); } if ($http->hasPostVariable('AddGroupButton') && $http->hasPostVariable('ContentClass_group')) { eZClassFunctions::addGroup($ClassID, $ClassVersion, $http->postVariable('ContentClass_group')); } if ($http->hasPostVariable('RemoveGroupButton') && $http->hasPostVariable('group_id_checked')) { if (!eZClassFunctions::removeGroup($ClassID, $ClassVersion, $http->postVariable('group_id_checked'))) { $validation['groups'][] = array('text' => ezpI18n::tr('kernel/class', 'You have to have at least one group that the class belongs to!')); $validation['processed'] = true; } } $attributes = $class->fetchAttributes(); $datatypes = eZDataType::registeredDataTypes(); $mainGroupID = false; $mainGroupName = false; $groupList = $class->fetchGroupList(); if (count($groupList) > 0) { $mainGroupID = $groupList[0]->attribute('group_id'); $mainGroupName = $groupList[0]->attribute('group_name'); } $Module->setTitle("Edit class " . $class->attribute("name")); $tpl = eZTemplate::factory();
$http = eZHTTPTool::instance(); $deleteIDArray = $http->hasSessionVariable('DeleteClassIDArray') ? $http->sessionVariable('DeleteClassIDArray') : array(); $DeleteResult = array(); $alreadyRemoved = array(); if (!$http->hasPostVariable('ConfirmButton') && !$http->hasPostVariable('CancelButton') && $GroupID != null) { // we will remove class - group relations rather than classes if they belongs to more than 1 group: $updateDeleteIDArray = true; foreach ($deleteIDArray as $key => $classID) { // for each classes tagged for deleting: $class = eZContentClass::fetch($classID); if ($class) { // find out to how many groups the class belongs: $classInGroups = $class->attribute('ingroup_list'); if (count($classInGroups) != 1) { // remove class - group relation: eZClassFunctions::removeGroup($classID, null, array($GroupID)); $alreadyRemoved[] = array('id' => $classID, 'name' => $class->attribute('name')); $updateDeleteIDArray = true; unset($deleteIDArray[$key]); } } } if ($updateDeleteIDArray) { // we aren't going to remove classes already processed: $http->setSessionVariable('DeleteClassIDArray', $deleteIDArray); } if (count($deleteIDArray) == 0) { // we don't need anything to confirm: return $Module->redirectTo('/class/classlist/' . $GroupID); } }