static function remove($classID)
 {
     $contentClass = eZContentClass::fetch($classID);
     if ($contentClass == null or !$contentClass->isRemovable()) {
         return false;
     }
     // Remove all objects
     $contentObjects = eZContentObject::fetchSameClassList($classID);
     foreach ($contentObjects as $contentObject) {
         eZContentObjectOperations::remove($contentObject->attribute('id'));
     }
     if (count($contentObjects) == 0) {
         eZContentObject::expireAllViewCache();
     }
     eZContentClassClassGroup::removeClassMembers($classID, 0);
     eZContentClassClassGroup::removeClassMembers($classID, 1);
     // Fetch real version and remove it
     $contentClass->remove(true);
     // Fetch temp version and remove it
     $tempDeleteClass = eZContentClass::fetch($classID, true, 1);
     if ($tempDeleteClass != null) {
         $tempDeleteClass->remove(true, 1);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Stores the current class as a modified version, updates the contentobject_name
  * attribute and recreates the class group entries.
  *
  * @note It will remove classes in the previous and specified version before storing.
  *
  * @param array $attributes array of attributes
  * @param int $version version status
  * @since Version 4.3
  */
 public function storeVersioned($attributes, $version)
 {
     $previousVersion = $this->attribute('version');
     $db = eZDB::instance();
     $db->begin();
     // Before removing anything from the attributes, load attribute information
     // which might otherwise not accessible when recreating them below.
     // See issue #18164
     foreach ($attributes as $attribute) {
         $attribute->content();
     }
     $this->removeAttributes(false, $version);
     $this->removeAttributes(false, $previousVersion);
     $this->remove(false);
     $this->setVersion($version, $attributes);
     $this->setAttribute("modifier_id", eZUser::currentUser()->attribute("contentobject_id"));
     $this->setAttribute("modified", time());
     $this->adjustAttributePlacements($attributes);
     foreach ($attributes as $attribute) {
         $attribute->storeVersioned($version);
     }
     // Set contentobject_name to something sensible if it is missing
     if (count($attributes) > 0 && trim($this->attribute('contentobject_name')) == '') {
         $this->setAttribute('contentobject_name', '<' . $attributes[0]->attribute('identifier') . '>');
     }
     // Recreate class member entries
     eZContentClassClassGroup::removeClassMembers($this->ID, $version);
     foreach (eZContentClassClassGroup::fetchGroupList($this->ID, $previousVersion) as $classgroup) {
         $classgroup->setAttribute('contentclass_version', $version);
         $classgroup->store();
     }
     eZContentClassClassGroup::removeClassMembers($this->ID, $previousVersion);
     eZExpiryHandler::registerShutdownFunction();
     $handler = eZExpiryHandler::instance();
     $time = time();
     $handler->setTimestamp('user-class-cache', $time);
     $handler->setTimestamp('class-identifier-cache', $time);
     $handler->setTimestamp('sort-key-cache', $time);
     $handler->store();
     eZContentCacheManager::clearAllContentCache();
     $this->setAttribute('serialized_name_list', $this->NameList->serializeNames());
     $this->setAttribute('serialized_description_list', $this->DescriptionList->serializeNames());
     eZPersistentObject::store();
     $this->NameList->store($this);
     $db->commit();
 }
Exemplo n.º 3
0
if (isset($Params["GroupID"])) {
    $GroupID = $Params["GroupID"];
}
$class = eZContentClass::fetch($ClassID);
$ClassName = $class->attribute('name');
$classObjects = eZContentObject::fetchSameClassList($ClassID);
$ClassObjectsCount = count($classObjects);
if ($ClassObjectsCount == 0) {
    $ClassObjectsCount .= " object";
} else {
    $ClassObjectsCount .= " objects";
}
$http = eZHTTPTool::instance();
if ($http->hasPostVariable("ConfirmButton")) {
    $class->remove(true);
    eZContentClassClassGroup::removeClassMembers($ClassID, 0);
    ezpEvent::getInstance()->notify('content/class/cache', array($ClassID));
    $Module->redirectTo('/class/classlist/' . $GroupID);
}
if ($http->hasPostVariable("CancelButton")) {
    $Module->redirectTo('/class/classlist/' . $GroupID);
}
$Module->setTitle("Deletion of class " . $ClassID);
$tpl = eZTemplate::factory();
$tpl->setVariable("module", $Module);
$tpl->setVariable("GroupID", $GroupID);
$tpl->setVariable("ClassID", $ClassID);
$tpl->setVariable("ClassName", $ClassName);
$tpl->setVariable("ClassObjectsCount", $ClassObjectsCount);
$Result = array();
$Result['content'] = $tpl->fetch("design:class/delete.tpl");
Exemplo n.º 4
0
}
// Find out the group where class is created or edited from.
if ($http->hasSessionVariable('FromGroupID')) {
    $fromGroupID = $http->sessionVariable('FromGroupID');
} else {
    $fromGroupID = false;
}
$ClassID = $class->attribute('id');
$ClassVersion = $class->attribute('version');
$validation = array('processed' => false, 'groups' => array(), 'attributes' => array(), 'class_errors' => array());
$unvalidatedAttributes = array();
if ($http->hasPostVariable('DiscardButton')) {
    $http->removeSessionVariable('ClassCanStoreTicket');
    $class->setVersion(eZContentClass::VERSION_STATUS_TEMPORARY);
    $class->remove(true, eZContentClass::VERSION_STATUS_TEMPORARY);
    eZContentClassClassGroup::removeClassMembers($ClassID, eZContentClass::VERSION_STATUS_TEMPORARY);
    if ($fromGroupID === false) {
        $Module->redirectToView('grouplist');
    } else {
        $Module->redirectTo($Module->functionURI('classlist') . '/' . $fromGroupID . '/');
    }
    return;
}
if ($http->hasPostVariable('AddGroupButton') && $http->hasPostVariable('ContentClass_group')) {
    eZClassFunctions::addGroup($ClassID, $ClassVersion, $http->postVariable('ContentClass_group'));
    $lastChangedID = '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;
Exemplo n.º 5
0
Arquivo: index.php Projeto: truffo/eep
 private function deleteClass($classIdentifier)
 {
     $chunkSize = 1000;
     $classId = eZContentClass::classIDByIdentifier($classIdentifier);
     $contentClass = eZContentClass::fetch($classId);
     if (!$contentClass) {
         throw new Exception("Failed to instantiate content class. [" . $classIdentifier . "]");
     }
     $totalObjectCount = eZContentObject::fetchSameClassListCount($classId);
     echo "Deleting " . $totalObjectCount . " objects.\n";
     $moreToDelete = 0 < $totalObjectCount;
     $totalDeleted = 0;
     // need to operate in a privileged account - use doug@mugo.ca
     $adminUserObject = eZUser::fetch(eepSetting::PrivilegedAccountId);
     $adminUserObject->loginCurrent();
     while ($moreToDelete) {
         $params["IgnoreVisibility"] = true;
         $params['Limitation'] = array();
         $params['Limit'] = $chunkSize;
         $params['ClassFilterType'] = "include";
         $params['ClassFilterArray'] = array($classIdentifier);
         $children = eZContentObjectTreeNode::subTreeByNodeID($params, 2);
         foreach ($children as $child) {
             $info = eZContentObjectTreeNode::subtreeRemovalInformation(array($child->NodeID));
             if (!$info["can_remove_all"]) {
                 $msg = " permission is denied for nodeid=" . $child->NodeID;
                 // todo, this can yield an infinite loop if some objects are
                 // not deleteable, but you don't take that number into account
                 // at the bottom of the loop - where there will always be
                 // some >0 number of undeleteable objects left
                 echo $msg . "\n";
                 continue;
             }
             $removeResult = eZContentObjectTreeNode::removeSubtrees(array($child->NodeID), false, false);
             if (true === $removeResult) {
                 $totalDeleted += 1;
             } else {
                 $msg = " failed to delete nodeid=" . $child->NodeID;
                 echo $msg . "\n";
             }
             echo "Percent complete: " . sprintf("% 3.3f", $totalDeleted / $totalObjectCount * 100.0) . "%\r";
             unset($GLOBALS['eZContentObjectContentObjectCache']);
             unset($GLOBALS['eZContentObjectDataMapCache']);
             unset($GLOBALS['eZContentObjectVersionCache']);
         }
         $moreToDelete = 0 < eZContentObject::fetchSameClassListCount($classId);
     }
     echo "\nDone deleting objects.\n";
     $adminUserObject->logoutCurrent();
     eZContentClassClassGroup::removeClassMembers($classId, 0);
     eZContentClassClassGroup::removeClassMembers($classId, 1);
     // Fetch real version and remove it
     $contentClass->remove(true);
     // this seems to mainly cause an exception, might be an idea to simply skip it
     // Fetch temp version and remove it
     $tempDeleteClass = eZContentClass::fetch($classId, true, 1);
     if ($tempDeleteClass != null) {
         $tempDeleteClass->remove(true, 1);
     }
 }