public function DefaultRoles() { $this->Permission('Garden.Roles.Manage'); $this->AddSideMenu(''); $this->Title(T('Default Roles')); // Load roles for dropdowns. $RoleModel = new RoleModel(); $this->SetData('RoleData', $RoleModel->Get()); if ($this->Form->AuthenticatedPostBack() === FALSE) { // Get a list of default member roles from the config. $DefaultRoles = C('Garden.Registration.DefaultRoles'); $this->Form->SetValue('DefaultRoles', $DefaultRoles); // Get the guest roles. $GuestRolesData = $RoleModel->GetByUserID(0); $GuestRoles = ConsolidateArrayValuesByKey($GuestRolesData, 'RoleID'); $this->Form->SetValue('GuestRoles', $GuestRoles); // The applicant role. $ApplicantRoleID = C('Garden.Registration.ApplicantRoleID', ''); $this->Form->SetValue('ApplicantRoleID', $ApplicantRoleID); } else { $DefaultRoles = $this->Form->GetFormValue('DefaultRoles'); $ApplicantRoleID = $this->Form->GetFormValue('ApplicantRoleID'); SaveToConfig(array('Garden.Registration.DefaultRoles' => $DefaultRoles, 'Garden.Registration.ApplicantRoleID' => $ApplicantRoleID)); $GuestRoles = $this->Form->GetFormValue('GuestRoles'); $UserModel = new UserModel(); $UserModel->SaveRoles(0, $GuestRoles, FALSE); $this->StatusMessage = T("Saved"); } $this->Render(); }