function testShowsAllMembersWithoutGroupParameter()
 {
     $member1 = $this->objFromFixture('Member', 'member1');
     $member2 = $this->objFromFixture('Member', 'member2');
     $member3 = $this->objFromFixture('Member', 'member3');
     $group1 = $this->objFromFixture('Group', 'group1');
     $tf = new MemberTableField($this, "Members");
     $members = $tf->sourceItems();
     $this->assertContains($member1->ID, $members->column('ID'), 'Members in the associated group are listed');
     $this->assertContains($member2->ID, $members->column('ID'), 'Members in children groups are listed as well');
     $this->assertContains($member3->ID, $members->column('ID'), 'Members in other groups are listed');
 }
Example #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)), 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;
 }
 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField(Controller::has_curr() ? Controller::curr() : new Controller(), "Members", $this, null, false)), $permissionsTab = new Tab('Permissions', _t('SecurityAdmin.PERMISSIONS', 'Permissions'), new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this)), new Tab('IPAddresses', _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->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;
 }
 /**
  * @return FieldSet
  */
 function RootForm()
 {
     $memberList = new MemberTableField($this, "Members");
     // unset 'inlineadd' permission, we don't want inline addition
     $memberList->setPermissions(array('edit', 'delete', 'add'));
     $memberList->setRelationAutoSetting(false);
     $fields = new FieldSet(new TabSet('Root', new Tab('Members', singleton('Member')->i18n_plural_name(), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the database')))), new Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>', $this->Link('groupimport'))))), new HiddenField('ID', false, 0));
     // Add roles editing interface
     if (Permission::check('APPLY_ROLES')) {
         $rolesCTF = new ComplexTableField($this, 'Roles', 'PermissionRole');
         $rolesCTF->setPermissions(array('add', 'edit', 'delete'));
         $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
         $rolesTab->push(new LiteralField('RolesDescription', ''));
         $rolesTab->push($rolesCTF);
     }
     $actions = new FieldSet(new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member')));
     $this->extend('updateRootFormFields', $fields, $actions);
     $form = new Form($this, 'EditForm', $fields, $actions);
     return $form;
 }
Example #5
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 static function addMembershipFields($addingFieldList, $addingCsvFieldList = null) {
		self::$addedFields = $addingFieldList;
		$addingCsvFieldList == null ? self::$addedCsvFields = $addingFieldList : self::$addedCsvFields = $addingCsvFieldList;
  	}
Example #7
0
 public function listmembers($baseGroup = null)
 {
     if (!$baseGroup) {
         $baseGroup = $this->urlParams['ID'];
     }
     // Debug::message( $_REQUEST['MemberListOrderByField'] );
     // construct the filter and sort
     if ($_REQUEST['MemberListOrderByField']) {
         $sort = "`" . $_REQUEST['MemberListOrderByField'] . "`" . addslashes($_REQUEST['MemberListOrderByOrder']);
     }
     $whereClauses = array();
     $search = addslashes($_REQUEST['MemberListSearch']);
     if ($_REQUEST['MemberListPage']) {
         $pageSize = 10;
         $limitClause = $_REQUEST['MemberListPage'] . ", {$pageSize}";
     }
     if (!empty($_REQUEST['MemberListSearch'])) {
         $whereClauses[] = "( `Email`='{$search}' OR `FirstName`='{$search}' OR `Surname`='{$search}' )";
     }
     if (is_numeric($_REQUEST['MemberListBaseGroup'])) {
         $whereClauses[] = "`GroupID`='" . $_REQUEST['MemberListBaseGroup'] . "'";
         $join = "INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`";
     }
     // $_REQUEST['showqueries'] = 1;
     $members = DataObject::get('Member', implode(' AND ', $whereClauses), $sort, $join, $limitClause);
     if (is_numeric($_REQUEST['MemberListGroup'])) {
         $baseMembers = new DataObjectSet();
         if ($members) {
             foreach ($members as $member) {
                 if ($member->inGroup($_REQUEST['MemberListGroup'])) {
                     $baseMembers->push($member);
                 }
             }
         }
     } else {
         $baseMembers = $members;
     }
     $baseMembers = null;
     // user_error( $_REQUEST['MemberListBaseGroup'], E_USER_ERROR );
     $memberListField = new MemberTableField($this, 'MemberList', $_REQUEST['MemberListBaseGroup'], $baseMembers, $_REQUEST['MemberListDontShowPassword']);
     return $memberListField->renderWith('MemberList_Table');
 }
 public function AddRecordForm()
 {
     $m = new MemberTableField($this, "Members", $this->currentPageID());
     return $m->AddRecordForm();
 }