/** * Deletes a region and all its media * @return */ function DeleteRegion() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $layoutid = Kit::GetParam('layoutid', _REQUEST, _INT, 0); $regionid = Kit::GetParam('regionid', _REQUEST, _STRING); if ($layoutid == 0 || $regionid == '') { $response->SetError(__("No layout/region information available, please refresh the page and try again.")); $response->Respond(); } Kit::ClassLoader('region'); $region = new region($db); $ownerId = $region->GetOwnerId($layoutid, $regionid); $regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutid, $regionid, true); if (!$regionAuth->del) { trigger_error(__('You do not have permissions to delete this region'), E_USER_ERROR); } // Remove the permissions Kit::ClassLoader('layoutregiongroupsecurity'); $security = new LayoutRegionGroupSecurity($db); $security->UnlinkAll($layoutid, $regionid); $db->query(sprintf("DELETE FROM lklayoutmediagroup WHERE layoutid = %d AND RegionID = '%s'", $layoutid, $regionid)); if (!$region->DeleteRegion($layoutid, $regionid)) { //there was an ERROR $response->SetError($region->GetErrorMessage()); $response->Respond(); } $response->SetFormSubmitResponse(__('Region Deleted.'), true, sprintf("index.php?p=layout&layoutid=%d&modify=true", $layoutid)); $response->Respond(); }