diff --git a/code/AssetAdmin.php b/code/AssetAdmin.php index fe100ff4..4e6ea585 100755 --- a/code/AssetAdmin.php +++ b/code/AssetAdmin.php @@ -75,8 +75,6 @@ class AssetAdmin extends LeftAndMain { Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css"); Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin.js"); - Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin_left.js"); - Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin_right.js"); Requirements::javascript(CMS_DIR . "/javascript/CMSMain_upload.js"); Requirements::javascript(CMS_DIR . "/javascript/Upload.js"); @@ -518,25 +516,6 @@ JS; } } - /** - * Return the given tree item to the client. - * If called by ajax, this will be some javascript commands. - * Otherwise, it will redirect back. - */ - public function returnItemToUser($p) { - if($_REQUEST['ajax']) { - $parentID = (int) $p->ParentID; - return <<ID, "$p->Title", "$p->class"); - tree.getTreeNodeByIdx($parentID).appendTreeNode(newNode); - newNode.selectTreeNode(); -JS; - } else { - Director::redirectBack(); - } - } - /** * Delete a folder */ @@ -545,16 +524,13 @@ JS; $ids = split(' *, *', $_REQUEST['csvIDs']); $script = ''; foreach($ids as $id) { - if(is_numeric($id)) { $record = DataObject::get_by_id($this->stat('tree_class'), $id); - if(!$record) { - Debug::message( "Record appears to be null" ); + if($record) { + $script .= $this->deleteTreeNodeJS($record); + $record->delete(); + $record->destroy(); } - $record->delete(); - $record->destroy(); - - $script .= $this->deleteTreeNodeJS($record); } } diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 9db36166..d8d02d5d 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -496,7 +496,7 @@ class LeftAndMain extends Controller { public function returnItemToUser($p) { if(Director::is_ajax()) { // Prepare the object for insertion. - $parentID = (int)$p->ParentID; + $parentID = (int) $p->ParentID; $id = $p->ID ? $p->ID : "new-$p->class-$p->ParentID"; $treeTitle = Convert::raw2js($p->TreeTitle()); $hasChildren = (is_numeric($id) && $p->AllChildren() && $p->AllChildren()->Count()) ? ' unexpanded' : ''; @@ -506,7 +506,9 @@ class LeftAndMain extends Controller { var tree = $('sitetree'); var newNode = tree.createTreeNode("$id", "$treeTitle", "{$p->class}{$hasChildren}"); node = tree.getTreeNodeByIdx($parentID); - if(!node){ node = tree.getTreeNodeByIdx(0); } + if(!node) { + node = tree.getTreeNodeByIdx(0); + } node.open(); node.appendTreeNode(newNode); newNode.selectTreeNode(); @@ -515,12 +517,10 @@ JS; return FormResponse::respond(); } else { - Director::redirect("admin/show/" . $p->ID); + Director::redirect('admin/' . self::$url_segment . '/show/' . $p->ID); } - } - /** * Save and Publish page handler */ diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 302ee362..2f656fd9 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -42,16 +42,20 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css"); Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css"); - Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin.js"); - Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin_left.js"); - Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin_right.js"); - + Requirements::javascript(CMS_DIR . '/javascript/SecurityAdmin_left.js'); + Requirements::javascript(CMS_DIR . '/javascript/SecurityAdmin_right.js'); + Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js"); Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js"); } public function getEditForm($id) { - $record = DataObject::get_by_id($this->stat('tree_class'), $id); + $record = null; + + if($id && $id != 'root') { + $record = DataObject::get_by_id($this->stat('tree_class'), $id); + } + if(!$record) return false; $fields = $record->getCMSFields(); @@ -194,24 +198,32 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { } /** - * Return the entire site tree as a nested set of ULs + * Return the entire site tree as a nested set of ULs. + * @return string Unordered list