コード例 #1
0
ファイル: content.roles.php プロジェクト: bauhouse/members
 public function view()
 {
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 9126341);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/members/assets/scripts.js', 9126342);
     $create_button = Widget::Anchor(__('Create a new role'), extension_members::baseURL() . 'roles_new/', __('Create a new role'), 'create button');
     $this->setPageType('table');
     $this->appendSubheading(__('Member Roles ') . $create_button->generate(false));
     $aTableHead = array(array(__('Name'), 'col'), array(__('Members'), 'col'));
     $roles = $this->_driver->fetchRoles();
     $aTableBody = array();
     if (!is_array($roles) || empty($roles)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
     } elseif (is_null(extension_members::memberSectionID())) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('No Member section has been specified in <a href="' . URL . '/symphony/extension/members/setup/">Member Setup</a>. Please do this first.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($this->_driver->memberSectionID());
         $bEven = true;
         $role_field_name = Symphony::Database()->fetchVar('element_name', 0, "SELECT `element_name` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->roleField() . "' LIMIT 1");
         $with_selected_roles = array();
         foreach ($roles as $role) {
             $member_count = Symphony::Database()->fetchVar('count', 0, "SELECT COUNT(*) AS `count` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = '" . $role->id() . "'");
             ## Setup each cell
             $td1 = Widget::TableData(Widget::Anchor($role->name(), extension_members::baseURL() . 'roles_edit/' . $role->id() . '/', NULL, 'content'));
             if (extension_Members::GUEST_ROLE_ID == $role->id()) {
                 $td2 = Widget::TableData(__('N/A'), 'inactive');
             } else {
                 $td2 = Widget::TableData(Widget::Anchor("{$member_count}", URL . '/symphony/publish/' . $section->get('handle') . '/?filter=' . $role_field_name . ':' . $role->id()));
             }
             if (!in_array($role->id(), array(extension_Members::GUEST_ROLE_ID, extension_Members::INACTIVE_ROLE_ID))) {
                 $td2->appendChild(Widget::Input("items[" . $role->id() . "]", null, 'checkbox'));
             }
             ## Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2), $bEven ? 'odd' : NULL);
             if ($role->id() != extension_Members::GUEST_ROLE_ID) {
                 $with_selected_roles[] = array("move::" . $role->id(), false, $role->name());
             }
             $bEven = !$bEven;
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), 2 => array('delete-members', false, __('Delete Members')), array('delete', false, __('Delete')));
     if (count($with_selected_roles) > 0) {
         $options[1] = array('label' => __('Move Members To'), 'options' => $with_selected_roles);
     }
     ksort($options);
     $tableActions->appendChild(Widget::Select('with-selected', $options, array('id' => 'with-selected')));
     $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($tableActions);
 }
コード例 #2
0
ファイル: content.setup.php プロジェクト: ErisDS/Bugaroo
 public function view()
 {
     $sectionManager = new SectionManager(Administration::instance());
     $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70);
     $this->appendSubheading('Setup');
     $bIsWritable = true;
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if (!is_writable(CONFIG)) {
         $this->pageAlert('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.', AdministrationPage::PAGE_ALERT_ERROR);
         $bIsWritable = false;
     } elseif ($formHasErrors) {
         $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR);
     }
     if (!is_null(extension_members::memberSectionID())) {
         $member_section = $sectionManager->fetch(extension_members::memberSectionID());
     }
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', 'Instructions'));
     $p = new XMLElement('p', 'A section is required for storing member details. Use the button below to automatically create a compatible section (you can always edit or add fields later), or use the dropdowns to link to an existing section containing the required fields.');
     $group->appendChild($p);
     $this->Form->appendChild($group);
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', 'Smart Setup'));
     $attr = array('name' => 'action[smart-setup]', 'type' => 'submit');
     if ($member_section instanceof Section) {
         $attr['disabled'] = 'disabled';
     }
     $div = new XMLElement('div', NULL, array('id' => 'file-actions', 'class' => 'label'));
     $span = new XMLElement('span');
     $span->appendChild(new XMLElement('button', 'Create', $attr));
     $div->appendChild($span);
     $div->appendChild(new XMLElement('p', 'Automatically creates a new section, called Members, containing Username/Password, Role, Email Address, and Timezone Offset fields.', array('class' => 'help')));
     $group->appendChild($div);
     $this->Form->appendChild($group);
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', 'Essentials'));
     $p = new XMLElement('p', 'Must contain a <code>Member</code> type field. Will be used to validate login details.');
     $p->setAttribute('class', 'help');
     $group->appendChild($p);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $section_list = Symphony::Database()->fetchCol('parent_section', "SELECT `parent_section` FROM `tbl_fields` WHERE `type` = 'member'");
     $label = Widget::Label('Member Section');
     $options = array();
     foreach ($section_list as $section_id) {
         $section = $sectionManager->fetch($section_id);
         $options[] = array($section_id, extension_members::memberSectionID('member_section', 'members') == $section_id, $section->get('name'));
     }
     $label->appendChild(Widget::Select('fields[member_section]', $options));
     $div->appendChild($label);
     $label = Widget::Label('Email Address Field');
     if ($member_section instanceof Section) {
         $options = array(array('', false, ''));
         foreach ($member_section->fetchFields() as $f) {
             $options[] = array($f->get('id'), Symphony::Configuration()->get('email_address_field_id', 'members') == $f->get('id'), $f->get('label'));
         }
     } else {
         $options = array(array('', false, 'Must set Member section first'));
     }
     $label->appendChild(Widget::Select('fields[email_address_field_id]', $options, $member_section instanceof Section ? NULL : array('disabled' => 'disabled')));
     $div->appendChild($label);
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $label = Widget::Label('Timezone Offset Field');
     if ($member_section instanceof Section) {
         $options = array(array('', false, ''));
         foreach ($member_section->fetchFields() as $f) {
             $options[] = array($f->get('id'), Symphony::Configuration()->get('timezone_offset_field_id', 'members') == $f->get('id'), $f->get('label'));
         }
     } else {
         $options = array(array('', false, 'Must set Member section first'));
     }
     $label->appendChild(Widget::Select('fields[timezone_offset_field_id]', $options, $member_section instanceof Section ? NULL : array('disabled' => 'disabled')));
     $div->appendChild($label);
     $group->appendChild($div);
     $group->appendChild(new XMLElement('p', 'Stores member timezones. Used to dynamically adjust date displays. Defaults to Symphony configuration offset.', array('class' => 'help')));
     $this->Form->appendChild($group);
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', 'Registration'));
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $label = Widget::Label('New Member Default Role');
     $options = array(array(NULL, false, NULL));
     foreach ($this->_driver->fetchRoles() as $r) {
         if (in_array($r->id(), array(extension_Members::GUEST_ROLE_ID, extension_Members::INACTIVE_ROLE_ID))) {
             continue;
         }
         $options[] = array($r->id(), Symphony::Configuration()->get('new_member_default_role', 'members') == $r->id(), $r->name());
     }
     $label->appendChild(Widget::Select('fields[new_member_default_role]', $options));
     $div->appendChild($label);
     $group->appendChild($div);
     $label = Widget::Label();
     $input = Widget::Input('fields[require_activation]', 'yes', 'checkbox');
     if (Symphony::Configuration()->get('require_activation', 'members') == 'yes') {
         $input->setAttribute('checked', 'checked');
     }
     $label->setValue($input->generate() . ' ' . __('New members require activation'));
     $group->appendChild($label);
     $group->appendChild(new XMLElement('p', __('If activation is required, new members will be added to the \'Inactive\' role until they reply to the \'Activate Account\' email. Activated members will be added to the role selected above.'), array('class' => 'help')));
     $this->Form->appendChild($group);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $attr = array('accesskey' => 's');
     if (!$bIsWritable) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', $attr));
     $this->Form->appendChild($div);
 }
コード例 #3
0
 function view()
 {
     $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70);
     $this->appendSubheading('Preferences');
     $bIsWritable = true;
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if (!is_writable(CONFIG)) {
         $this->pageAlert('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.', AdministrationPage::PAGE_ALERT_ERROR);
         $bIsWritable = false;
     } elseif ($formHasErrors) {
         $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR);
     }
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', 'Essentials'));
     $p = new XMLElement('p', 'Must contain a <code>Member</code> type field. Will be used to validate login details.');
     $p->setAttribute('class', 'help');
     $group->appendChild($p);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $section_list = $this->_Parent->Database->fetchCol('parent_section', "SELECT `parent_section` FROM `tbl_fields` WHERE `type` = 'member'");
     $sectionManager = new SectionManager($this->_Parent);
     $label = Widget::Label('Member Section');
     $options = array();
     foreach ($section_list as $section_id) {
         $section = $sectionManager->fetch($section_id);
         $options[] = array($section_id, extension_members::memberSectionID('member_section', 'members') == $section_id, $section->get('name'));
     }
     $label->appendChild(Widget::Select('fields[member_section]', $options));
     $div->appendChild($label);
     $label = Widget::Label('Email Address');
     $member_section_id = extension_members::memberSectionID();
     if (!empty($member_section_id)) {
         $options = array(array('', false, ''));
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($member_section_id);
         foreach ($section->fetchFields() as $f) {
             $options[] = array($f->get('id'), ConfigurationAccessor::get('email_address_field_id', 'members') == $f->get('id'), $f->get('label'));
         }
     } else {
         $options = array(array('', false, 'Must set Member section first'));
     }
     $label->appendChild(Widget::Select('fields[email_address_field_id]', $options, empty($member_section_id) ? array('disabled' => 'disabled') : NULL));
     $div->appendChild($label);
     $group->appendChild($div);
     $this->Form->appendChild($group);
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings type-file');
     $fieldset->appendChild(new XMLElement('legend', 'Forgotten Password Email Template'));
     $fieldset->appendChild(new XMLElement('p', 'When a member triggers the forgotten password event, this is the email template used when providing them a login link.', array('class' => 'help')));
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $label = Widget::Label('Subject');
     $label->appendChild(Widget::Input('fields[forgotten_pass_email_subject]', General::sanitize(stripslashes(ConfigurationAccessor::get('forgotten_pass_email_subject', 'members')))));
     if (isset($this->_errors['forgotten_pass_email_subject'])) {
         $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['forgotten_pass_email_subject']));
     } else {
         $fieldset->appendChild($label);
     }
     $label = Widget::Label('Body');
     $label->appendChild(Widget::Textarea('fields[forgotten_pass_email_body]', '25', '50', General::sanitize(stripslashes(ConfigurationAccessor::get('forgotten_pass_email_body', 'members')))));
     $fieldset->appendChild(isset($this->_errors['forgotten_pass_email_body']) ? $this->wrapFormElementWithError($label, $this->_errors['forgotten_pass_email_body']) : $label);
     $fieldset->appendChild(new XMLElement('p', 'You can add dynamic elements to the email by using <code>{$field-name}</code> syntax, where <code>field-name</code> corresponds to the fields of the member, and <code>{$member-token}</code> which is the unique token allowing them to login E.G. <code>' . URL . '/login/{$member-token}/</code>. The page must have a param called <code>member-token</code>.', array('class' => 'help')));
     $this->Form->appendChild($fieldset);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $attr = array('accesskey' => 's');
     if (!$bIsWritable) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', $attr));
     $this->Form->appendChild($div);
 }