Esempio n. 1
0
 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new LiteralField("", "<p>" . _t('SecurityAdmin.ADVANCEDONLY', "This section is for advanced users only.\n\t\t\t\t\t\t\tSee <a href=\"http://doc.silverstripe.com/doku.php?id=permissions:codes\" target=\"_blank\">this page</a>\n\t\t\t\t\t\t\tfor more information.") . "</p>"), new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', HtmlEditorConfig::get_available_configs_map()), new TableField("Permissions", "Permission", array("Code" => _t('SecurityAdmin.CODE', 'Code'), "Arg" => _t('SecurityAdmin.OPTIONALID', 'Optional ID')), array("Code" => "PermissionDropdownField", "Arg" => "TextField"), "GroupID", $this->ID)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses.  It won't prevent\n\t\t\t\t\t\tpeople from logging in.  This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
         $fields->removeFieldFromTab('Root', 'IP Addresses');
     }
     $memberList->setController($this);
     $memberList->setPermissions(array('show', 'edit', 'delete', 'export', 'add'));
     $memberList->setParentClass('Group');
     $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Esempio n. 2
0
 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), $permissionsTab = new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses.  It won't prevent\n\t\t\t\t\t\tpeople from logging in.  This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
     // Only add a dropdown for HTML editor configurations if more than one is available.
     // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
     $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
     if (count($editorConfigMap) > 1) {
         $fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
     }
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
         $fields->removeFieldFromTab('Root', 'IP Addresses');
     }
     // Only show the "Roles" tab if permissions are granted to edit them,
     // and at least one role exists
     if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
         $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab") . "</p>"));
         // Add roles (and disable all checkboxes for inherited roles)
         $allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
         $groupRoles = $this->Roles();
         $inheritedRoles = new DataObjectSet();
         $ancestors = $this->getAncestors();
         foreach ($ancestors as $ancestor) {
             $ancestorRoles = $ancestor->Roles();
             if ($ancestorRoles) {
                 $inheritedRoles->merge($ancestorRoles);
             }
         }
         $fields->findOrMakeTab('Root.Roles', 'Root.' . _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', $rolesField = new CheckboxSetField('Roles', 'Roles', $allRoles));
         $rolesField->setDefaultItems($inheritedRoles->column('ID'));
         $rolesField->setDisabledItems($inheritedRoles->column('ID'));
     }
     $memberList->setController($this);
     $memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
     $memberList->setParentClass('Group');
     $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
     $memberList->setRelationAutoSetting(false);
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Esempio n. 3
0
 public function getEditForm($id)
 {
     $record = DataObject::get_by_id("Group", $id);
     if ($record) {
         $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", _t('SecurityAdmin.GROUPNAME', 'Group name')), $memberList = new MemberTableField($this, "Members", $record, null, false)), new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new LiteralField("", "<p>" . _t('SecurityAdmin.ADVANCEDONLY', "This section is for advanced users only.\n\t\t\t\t\t\t\tSee <a href=\"http://doc.silverstripe.com/doku.php?id=permissions:codes\" target=\"_blank\">this page</a>\n\t\t\t\t\t\t\tfor more information.") . "</p>"), new TableField("Permissions", "Permission", array("Code" => _t('SecurityAdmin.CODE', 'Code'), "Arg" => _t('SecurityAdmin.OPTIONALID', 'Optional ID')), array("Code" => "PermissionDropdownField", "Arg" => "TextField"), "GroupID", $id))));
         if (!Permission::check('EDIT_PERMISSIONS')) {
             $fields->removeFieldFromTab('Root', 'Permissions');
         }
         $memberList->setController($this);
         $memberList->setPermissions(array('show', 'edit', 'delete', 'export', 'add'));
         $memberList->setParentClass('Group');
         $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
         $fields->push($idField = new HiddenField("ID"));
         $idField->setValue($id);
         $actions = new FieldSet(new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member')));
         $actions->push(new FormAction('save', _t('SecurityAdmin.SAVE', 'Save')));
         $form = new Form($this, "EditForm", $fields, $actions);
         $form->loadDataFrom($record);
         return $form;
     }
 }
Esempio n. 4
0
 /**
  * Get the fieldset to display in the administration section
  */
 function getCMSFields()
 {
     $group = null;
     if ($this->GroupID) {
         $group = DataObject::get_one("Group", "ID = {$this->GroupID}");
     }
     $fields = new FieldSet(new TextField("Title", _t('NewsletterType.NEWSLETTERTYPE', 'Newsletter Type')), new TextField("FromEmail", _t('NewsletterType.SENDFROM', 'Send newsletters from')), new TabSet("Root", new Tab(_t('NewsletterType.DRAFTS', 'Drafts'), $draftList = new NewsletterList("Draft", $this, _t('NewsletterType.DRAFT', 'Draft'))), new TabSet('Sent', new Tab(_t('NewsletterType.SENT', 'Sent'), $sendList = new NewsletterList("Send", $this, _t('NewsletterType.SEND', 'Send'))), new Tab(_t('NewsletterType.UNSUBSCRIBED', 'Unsubscribed'), $unsubscribedList = new UnsubscribedList("Unsubscribed", $this)), new Tab(_t('NewsletterType.BOUNCED', 'Bounced'), $bouncedList = new BouncedList("Bounced", $this)))));
     if ($this->GroupID) {
         $fields->addFieldToTab('Root', new TabSet("Recipients", new Tab(_t('NewsletterType.RECIPIENTS', 'Recipients'), $recipients = new MemberTableField($this, "Recipients", $group)), new Tab(_t('NewsletterType.IMPORT', 'Import'), $importField = new RecipientImportField("ImportFile", _t('NewsletterType.IMPORTFROM', 'Import from file'), $group))));
         $recipients->setController($this);
         $importField->setController($this);
         $importField->setTypeID($this->ID);
     }
     $fields->addFieldToTab('Root', new Tab(_t('NewsletterType.TEMPLATE', 'Template'), $templates = new TemplateList("Template", "Template", $this->Template, NewsletterAdmin::template_path())));
     $draftList->setController($this);
     $sendList->setController($this);
     $templates->setController($this);
     $unsubscribedList->setController($this);
     $bouncedList->setController($this);
     $fields->push($idField = new HiddenField("ID"));
     $fields->push(new HiddenField("executeForm", "", "TypeEditForm"));
     $idField->setValue($this->ID);
     return $fields;
 }
 public function getMailingListEditForm($id)
 {
     if (!is_numeric($id)) {
         $id = Session::get('currentPage');
     }
     if (is_a($id, 'NewsletterType')) {
         $mailType = $id;
         $id = $mailType->ID;
     } else {
         if ($id && is_numeric($id)) {
             $mailType = DataObject::get_by_id('NewsletterType', $id);
         }
     }
     $group = null;
     if (isset($mailType) && is_object($mailType) && $mailType->GroupID) {
         $group = DataObject::get_one("Group", "ID = {$mailType->GroupID}");
     }
     if (isset($mailType) && is_object($mailType)) {
         $fields = new FieldSet(new TabSet("Root", new Tab(_t('NewsletterAdmin.RECIPIENTS', 'Recipients'), $recipients = new MemberTableField($this, "Recipients", $group)), new Tab(_t('NewsletterAdmin.IMPORT', 'Import'), $importField = new RecipientImportField("ImportFile", _t('NewsletterAdmin.IMPORTFROM', 'Import from file'), $group)), new Tab(_t('NewsletterAdmin.UNSUBSCRIBERS', 'Unsubscribers'), $unsubscribedList = new UnsubscribedList("Unsubscribed", $mailType)), new Tab(_t('NewsletterAdmin.BOUNCED', 'Bounced'), $bouncedList = new BouncedList("Bounced", $mailType))));
         $recipients->setController($this);
         $importField->setController($this);
         $unsubscribedList->setController($this);
         $bouncedList->setController($this);
         $importField->setTypeID($id);
         $fields->push($idField = new HiddenField("ID"));
         $fields->push(new HiddenField("executeForm", "", "MailingListEditForm"));
         $idField->setValue($id);
         // Save button is not used in Mailing List section
         $actions = new FieldSet(new HiddenField("save"));
         $form = new Form($this, "MailingListEditForm", $fields, $actions);
         $form->loadDataFrom(array('Title' => $mailType->Title, 'FromEmail' => $mailType->FromEmail));
         // This saves us from having to change all the JS in response to renaming this form to MailingListEditForm
         $form->setHTMLID('Form_EditForm');
     } else {
         $form = false;
     }
     return $form;
 }