From a3f9d9b6d358220c038bef0b38ccde47f331eef5 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Fri, 23 Nov 2007 01:10:19 +0000 Subject: [PATCH] switch externals to trunk. Inform-merge: from the changeset: r32477: Merge 2.0-inform from trunk previously r32478: Merge 2.0-inform from trunk previously r32481: merge 2.0infom with lastes chunk r32483: merge 2.0infom with lastes chunk r33526: Final styling of all forms and combined communication form add/alter javascript for height adjustment of First / Second block r33580: styling for combined form communication in myinfom pages r33706: styling of combined form (communication) in Email r33881: made compatible to $extraClass r33885: added defaultVal r33887: fixed typo r34728: modified SmallFieldHolder?() r34729: added "validationError"-class r34914: WIP3866: Factfinder: Hide "self emplyed" block r34964: Change current plan upto TraumaInsurance? r35038: disabled friggin field focus r35230: #1032 Fixed hash-link insertion r35887: conditionally setting parameters in sourceID() - to avoid empty overrides r35892: Saving value in SQL-compatible format (YYYY-MM-DD instead of DD/MM/YYYY), with fallback for non-sql values (just passed through without conversion) r35928: Removed "create a" from PageType?-dropdown, sorting alphabetically, falling back to $singular_name r35990: branched off for membertablefield r35994: fix for membertablefield r36024: added array-condition needed for DMYDateField r36083: fix bug for compositeField -> dropDatalessField r36394: removed debug code r36826: change wrong indent format r36828: WIP 4262: Logging out of My Inform goes to blank page r36858: Fixed error caused in r12472 while merging to Session-class r37132: Merged partial changesets from branches/2.0-nzct, only adding childID to detailform when not in add-mode r40815: add an unsubscribe record when a member subscribe a newslettertype r41113: fix the bug described in http://support.silverstripe.com/info/ticket/31: CRM not showing search results r43226: fixed search (partial merge from trunk) r43268: merged createNewPassword() from trunk, was referencing a non-existinent global function randomString() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@45473 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 5 +- code/GenericDataAdmin.php | 2 +- code/MemberTableField.php | 75 ++++++++++++++++----- code/Newsletter/BatchProcess.php | 2 +- code/Newsletter/SubscribeForm.php | 6 +- code/NewsletterAdmin.php | 3 +- code/SecurityAdmin.php | 12 +++- javascript/GenericDataAdmin_right.js | 15 ++--- silverstripe_version | 2 +- templates/Includes/GenericDataAdmin_left.ss | 2 +- 10 files changed, 86 insertions(+), 38 deletions(-) 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: "

SilverStripe CMS

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 @@  

<% _t('SEARCHRESULTS','Search Results') %>

-
+
$Results
\ No newline at end of file