예제 #1
0
function deletecontent($contentid)
{
    $userid = get_userid();
    $mypages = author_pages($userid);
    $access = check_permission($userid, 'Remove Pages') && (check_ownership($userid, $contentid) || quick_check_authorship($contentid, $mypages)) || check_permission($userid, 'Manage All Content');
    $gCms = cmsms();
    $hierManager = $gCms->GetHierarchyManager();
    if ($access) {
        $node = $hierManager->getNodeById($contentid);
        if ($node) {
            $contentobj = $node->getContent(true, false, true);
            $childcount = 0;
            $parentid = -1;
            $parent = $node->getParent();
            if ($parent) {
                $parentContent = $parent->getContent(true, false, true);
                if (is_object($parentContent)) {
                    $parentid = $parentContent->Id();
                    $childcount = $parent->getChildrenCount();
                }
            }
            if ($contentobj) {
                $title = $contentobj->Name();
                #Check for children
                if ($contentobj->HasChildren()) {
                    $_GET['error'] = 'errorchildcontent';
                }
                #Check for default
                if ($contentobj->DefaultContent()) {
                    $_GET['error'] = 'errordefaultpage';
                }
                $title = $contentobj->Name();
                $contentobj->Delete();
                $contentops = $gCms->GetContentOperations();
                $contentops->SetAllHierarchyPositions();
                #See if this is the last child... if so, remove
                #the expand for it
                if ($childcount == 1 && $parentid > -1) {
                    toggleexpand($parentid, true);
                }
                #Do the same with this page as well
                toggleexpand($contentid, true);
                // put mention into the admin log
                audit($contentid, 'Core', 'Content Item: ' . $title, 'Deleted');
                $contentops->ClearCache();
                $_GET['message'] = 'contentdeleted';
            }
        }
    }
}
예제 #2
0
                 $result->MoveNext();
             }
             $query = 'SELECT count(*) as thecount FROM ' . cms_db_prefix() . 'content WHERE parent_id = ' . $db->qstr($parentid);
             $result =& $db->Execute($query);
             while ($result && !$result->EOF) {
                 $childcount = $result->fields['thecount'];
                 $result->MoveNext();
             }
             $node->Delete();
             #See if this is the last child... if so, remove
             #the expand for it
             if ($childcount == 1 && $parentid > -1) {
                 toggleexpand($parentid, true);
             }
             #Do the same with this page as well
             toggleexpand($id, true);
             audit($id, $title, 'Deleted Content');
         }
         ContentManager::SetAllHierarchyPositions();
         $bulk = true;
     }
     //include_once("footer.php");
     if (!$bulk) {
         redirect("listcontent.php" . $urlext . '&message=no_bulk_performed');
     }
     redirect("listcontent.php" . $urlext . '&message=bulk_success');
 } else {
     if ($action == 'inactive') {
         $userid = get_userid();
         $modifyall = check_permission($userid, 'Modify Any Page');
         foreach ($nodelist as $node) {