diff --git a/code/CMSMain.php b/code/CMSMain.php index 4edceb63..2d98eb7b 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -255,7 +255,6 @@ JS; unset($classes[$mark]); } } - foreach($classes as $class) { $instance = singleton($class); if($instance instanceof HiddenClass) continue; @@ -271,7 +270,7 @@ JS; $addAction = preg_replace('/^a /','',$addAction); $addAction = ucfirst($addAction); } else { - $addAction = $class; + $addAction = $instance->singular_name(); } $result->push(new ArrayData(array( @@ -279,6 +278,8 @@ JS; "AddAction" => $addAction, ))); } + $result->sort('AddAction'); + return $result; } diff --git a/code/GenericDataAdmin.php b/code/GenericDataAdmin.php index ef0962c0..391f0b10 100755 --- a/code/GenericDataAdmin.php +++ b/code/GenericDataAdmin.php @@ -439,7 +439,7 @@ HTML; $fileData .= implode(",",$columnData); $fileData .= "\n"; } - + HTTP::sendFileToBrowser($fileData, $fileName); } else { user_error("No records found", E_USER_ERROR); diff --git a/code/MemberTableField.php b/code/MemberTableField.php index 27007b8b..beb7cf62 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -81,6 +81,8 @@ class MemberTableField extends ComplexTableField { $fieldList["Password"] = "Password"; } +// $detailFormFields = singleton(Object::getCustomClass($this->stat("data_class")))->getCMSFields(); + if(isset($_REQUEST['ctf']['childID']) && $memberID = $_REQUEST['ctf']['childID']) { $SNG_member = DataObject::get_by_id($this->stat("data_class"),$_REQUEST['ctf']['childID']); } else { @@ -98,7 +100,7 @@ class MemberTableField extends ComplexTableField { $this->hidePassword = $hidePassword; - parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields); + parent::__construct($controller, $name, $sourceClass, $fieldList); Requirements::javascript("cms/javascript/MemberTableField.js"); @@ -128,7 +130,6 @@ class MemberTableField extends ComplexTableField { } $this->sourceJoin = " INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`"; - $this->setFieldListCsv( $csvFieldList ); } @@ -146,40 +147,80 @@ class MemberTableField extends ComplexTableField { } function DetailForm() { + + // Get all the requests $ID = Convert::raw2xml(isset($_REQUEST['ctf']['ID']) ? $_REQUEST['ctf']['ID'] : ''); $childID = isset($_REQUEST['ctf']['childID']) ? Convert::raw2xml($_REQUEST['ctf']['childID']) : 0; $childClass = Convert::raw2xml($_REQUEST['fieldName']); - $methodName = isset($_REQUEST['methodName']) ? $_REQUEST['methodName'] : ''; + $this->methodName = $_REQUEST['methodName']; - if($methodName == "add") { - $parentIdName = $this->getParentIdName($childClass,$this->getParentClass()); + // used to discover fields if requested and for population of field + if(is_numeric($childID)) { + // we have to use the basedataclass, otherwise we might exclude other subclasses + $childData = DataObject::get_by_id(ClassInfo::baseDataClass($this->sourceClass), $childID); + } + + $parentIdName = $this->getParentIdName($this->sourceClass,$this->getParentClass()); + + if(!$parentIdName) { + user_error("ComplexTableField::DetailForm() DataObject does not seem to have an 'has-one'-relationship", E_USER_WARNING); + return; + } + // If the fieldset is passed, use it, else use the formfields returned + // from the object via a string method call. + if(is_a($this->detailFormFields,"Fieldset")){ + $detailFields = $this->detailFormFields; + } else if(is_string($this->detailFormFields)){ + $functioncall = $this->detailFormFields; + if($childData->hasMethod($functioncall)){ + $detailFields = $childData->$functioncall(); + } + } elseif(!$childData || $this->methodName == 'add') { + $SNG_sourceClass = singleton($this->sourceClass); + if(is_numeric($ID) && $this->getParentClass()) { + // make sure the relation-link is existing, even if we just add the sourceClass + // and didn't save it + $parentIDName = $this->getParentIdName($this->sourceClass,$this->getParentClass()); + $SNG_sourceClass->$parentIDName = $ID; + } + $detailFields = $SNG_sourceClass->getCMSFields(); + } else { + $detailFields = $childData->getCMSFields(); + } + + if($this->getParentClass()) { + $parentIdName = $this->getParentIdName($this->sourceClass,$this->getParentClass()); if(!$parentIdName) { - user_error("ComplexTableField::DetailForm() Dataobject does not seem to have an 'has-one'-relationship", E_USER_WARNING); + user_error("ComplexTableField::DetailForm() Cannot automatically + determine 'has-one'-relationship to parent, + please use setParentClass() to set it manually", + E_USER_WARNING); return; } - $this->detailFormFields->push(new HiddenField('parentClass'," ",$this->getParentClass())); - } + // add relational fields + $detailFields->push(new HiddenField("ctf[parentClass]"," ",$this->getParentClass())); + $detailFields->push(new HiddenField("$parentIdName"," ",$ID)); + } // the ID field confuses the Controller-logic in finding the right view for ReferencedField - $this->detailFormFields->removeByName('ID'); - - $this->detailFormFields->push(new HiddenField("ctf[ID]"," ",$ID)); - // add a namespaced ID instead thats "converted" by saveComplexTableField() - $this->detailFormFields->push(new HiddenField("ctf[childID]","",$childID)); - $this->detailFormFields->push(new HiddenField("ClassName","",$this->sourceClass)); + $detailFields->removeByName('ID'); - $form = new MemberTableField_Popup($this, "DetailForm", $this->detailFormFields, $this->sourceClass, $methodName == "show", $this->detailFormValidator); + // add a namespaced ID instead thats "converted" by saveComplexTableField() + $detailFields->push(new HiddenField("ctf[childID]","",$childID)); + $detailFields->push(new HiddenField("ctf[ClassName]","",$this->sourceClass)); + + $form = new MemberTableField_Popup($this, "DetailForm", $detailFields, $this->sourceClass, false, $this->detailFormValidator); if (is_numeric($childID)) { - if ($methodName == "show" || $methodName == "edit") { + if ($this->methodName == "show" || $this->methodName == "edit") { $childData = DataObject::get_by_id($this->sourceClass, $childID); $form->loadDataFrom($childData); } } - if ($methodName == "show") { + if ($this->methodName == "show") { $form->makeReadonly(); } diff --git a/code/Newsletter/BatchProcess.php b/code/Newsletter/BatchProcess.php index dab62a97..e694afc1 100755 --- a/code/Newsletter/BatchProcess.php +++ b/code/Newsletter/BatchProcess.php @@ -46,7 +46,7 @@ class BatchProcess extends Object { $this->id = self::generateID(); if( !$this->objects || count( $this->objects ) === 0 ) - return $this->complete(); + return $this->complete(); return $this->next(); } diff --git a/code/Newsletter/SubscribeForm.php b/code/Newsletter/SubscribeForm.php index e61d2284..6e26369d 100755 --- a/code/Newsletter/SubscribeForm.php +++ b/code/Newsletter/SubscribeForm.php @@ -18,9 +18,9 @@ class SubscribeForm extends UserDefinedForm { 'Subject' => 'Varchar' ); - static $defaults = array( - "OnCompleteMessage" => "
Thanks, you have been added to our mailing list.
", - ); + static $defaults = array( + "OnCompleteMessage" => "Thanks, you have been added to our mailing list.
", + ); static $has_many = array( 'Newsletters' => 'NewsletterType' diff --git a/code/NewsletterAdmin.php b/code/NewsletterAdmin.php index 5a024d8e..ecee7c52 100755 --- a/code/NewsletterAdmin.php +++ b/code/NewsletterAdmin.php @@ -223,8 +223,7 @@ class NewsletterAdmin extends LeftAndMain { if(isset($mailType) && is_object($mailType) && $mailType->GroupID) { $group = DataObject::get_one("Group", "ID = $mailType->GroupID"); } - - if(isset($mailType)) { + if(isset($mailType)&&$mailType) { $fields = new FieldSet( new TabSet("Root", new Tab("Newsletter Settings", diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 03636123..8f4c6d81 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -50,8 +50,16 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { new TableField( "Permissions", "Permission", - array("Code" => "Code", "Arg" => "Optional ID"), - array("Code" => "PermissionDropdownField", "Arg" => "TextField"), + array( + "Code" => "Code", + "Arg" => "Optional ID", + "Enabled" => "Enabled", + ), + array( + "Code" => "PermissionDropdownField", + "Arg" => "TextField", + "Enabled" => "CheckboxField", + ), "GroupID", $id ) ) diff --git a/javascript/GenericDataAdmin_right.js b/javascript/GenericDataAdmin_right.js index eb8746a8..cfd527cf 100755 --- a/javascript/GenericDataAdmin_right.js +++ b/javascript/GenericDataAdmin_right.js @@ -8,18 +8,13 @@ RightContent.prototype = { welcomeMessage: "Welcome to SilverStripe CMS! Please choose click on one of the items on the left pane.
", initialize : function() { - Behaviour.register({ - '#Form_EditForm_action_delete' : { - onclick: this.remove.bind(this) - } - }); }, updateCMSContent: function(el, currentTab, link, customCallBack) { if(!customCallBack) customCallBack = function(){}; if(el || link){ - var reqLink = (el.href) ? el.href : link; + var reqLink = (el && el.href) ? el.href : link; if(typeof(currentTab) != 'undefined') $('Form_EditForm').openTab = currentTab; @@ -59,7 +54,7 @@ RightContent.prototype = { remove: function(e) { if(window.confirm('Are you sure you want to delete?')){ var el = Event.element(e); - Ajax.SubmitForm(el.ownerForm, el.name, { + Ajax.SubmitForm($('Form_EditForm'),, el.name, { postBody : 'ajax=1', onSuccess: Ajax.Evaluator, onFailure: ajaxErrorHandler @@ -113,4 +108,8 @@ RightContent.prototype = { titleHolder[0].innerHTML = title; } } -} \ No newline at end of file +} + +var action_delete_right = function(e) { + $('Form_EditForm').remove(e); +} \ No newline at end of file diff --git a/silverstripe_version b/silverstripe_version index 03d27cc0..d58dc285 100644 --- a/silverstripe_version +++ b/silverstripe_version @@ -1 +1 @@ -$URL$ \ No newline at end of file +$URL:svn://svn.silverstripe.com/silverstripe/modules/cms/branches/2.0.1-inform/silverstripe_version $ \ No newline at end of file diff --git a/templates/Includes/GenericDataAdmin_left.ss b/templates/Includes/GenericDataAdmin_left.ss index 85e47600..63f33f0a 100755 --- a/templates/Includes/GenericDataAdmin_left.ss +++ b/templates/Includes/GenericDataAdmin_left.ss @@ -22,7 +22,7 @@