/** * Only create a Member object on the Frontend of the site. * There is no need to create this in the Administration context * as authenticated users are Authors and are handled by Symphony, * not this extension. */ public function __construct() { if (!extension_Members::$initialised) { // Find all possible member sections $config_sections = preg_split('~,~', extension_Members::getSetting('section'), -1, PREG_SPLIT_NO_EMPTY); extension_Members::initialiseMemberSections($config_sections); if (class_exists('Symphony') && Symphony::Engine() instanceof Frontend) { /** * This delegate fires as soon as possible to allow other extensions * the chance to overwrite the default Member class. This allows * for other types of Member objects to be used with the Members * extension. If the given `$member` is left as null, then * the default `SymphonyMember` will be initialised. * * @delegate InitialiseMember * @param string $context * '/frontend/' * @param object $member * Excepted to be a instance of a class that implements the `Member` * interface. Defaults to null. */ Symphony::ExtensionManager()->notifyMembers('InitialiseMember', '/frontend/', array('member' => &$this->Member)); // Set $this->Member to be an instance of SymphonyMember if an // extension hasn't already populated this variable if (is_null($this->Member)) { $this->Member = new SymphonyMember(); } $members_section_id = $this->getMemberDriver()->getMemberSectionID(); // If there is only one section... this just got easy if (count($config_sections) === 1) { $this->setMembersSection(current($config_sections)); } else { if (isset($_REQUEST['members-section-id']) && in_array((int) $_REQUEST['members-section-id'], $config_sections)) { $this->setMembersSection($_REQUEST['members-section-id']); } else { if (isset($members_section_id) && in_array((int) $members_section_id, $config_sections)) { $this->setMembersSection($members_section_id); } } } } extension_Members::$initialised = true; } }
/** * Loops over the configuration to detect the capabilities of this * Members setup. Populates two array's, one for Field objects, and * one for Field handles. */ public static function initialise() { extension_Members::$initialised = true; $sectionManager = extension_Members::$entryManager->sectionManager; $membersSectionSchema = array(); if (!is_null(extension_Members::getMembersSection()) && is_numeric(extension_Members::getMembersSection())) { $memberSection = $sectionManager->fetch(extension_Members::getMembersSection()); if ($memberSection instanceof Section) { $membersSectionSchema = $memberSection->fetchFieldsSchema(); } else { Symphony::$Log->pushToLog(__("The Member's section, %d, saved in the configuration could not be found.", array(extension_Members::getMembersSection())), E_ERROR, true); } } foreach ($membersSectionSchema as $field) { if ($field['type'] == 'membertimezone') { extension_Members::initialiseField($field, 'timezone'); continue; } if ($field['type'] == 'memberrole') { extension_Members::initialiseField($field, 'role'); continue; } if ($field['type'] == 'memberactivation') { extension_Members::initialiseField($field, 'activation'); continue; } if ($field['type'] == 'memberusername') { extension_Members::initialiseField($field, 'identity'); continue; } if ($field['type'] == 'memberemail') { extension_Members::initialiseField($field, 'email'); continue; } if ($field['type'] == 'memberpassword') { extension_Members::initialiseField($field, 'authentication'); continue; } } }