Get the default role IDs for all types of roles.
public static getAllDefaultRoles ( ) : array | ||
return | array | Returns an array of arrays indexed by role type. |
// Try and find a system user. $SystemUserID = Gdn::sql()->getWhere('User', array('Name' => 'System', 'Admin' => 2))->value('UserID'); if ($SystemUserID) { saveToConfig('Garden.SystemUserID', $SystemUserID); } else { // Create a new one if we couldn't find one. Gdn::userModel()->getSystemUserID(); } } // UserRole Table $Construct->table('UserRole'); $UserRoleExists = $Construct->tableExists(); $Construct->column('UserID', 'int', false, 'primary')->column('RoleID', 'int', false, array('primary', 'index'))->set($Explicit, $Drop); // Fix old default roles that were stored in the config and user-role table. if ($RoleTableExists && $UserRoleExists && $RoleTypeExists) { $types = $RoleModel->getAllDefaultRoles(); if ($v = c('Garden.Registration.ApplicantRoleID')) { $SQL->update('Role')->set('Type', RoleModel::TYPE_APPLICANT)->where('RoleID', $types[RoleModel::TYPE_APPLICANT])->put(); // RemoveFromConfig('Garden.Registration.ApplicantRoleID'); } if ($v = c('Garden.Registration.DefaultRoles')) { $SQL->update('Role')->set('Type', RoleModel::TYPE_MEMBER)->where('RoleID', $types[RoleModel::TYPE_MEMBER])->put(); // RemoveFromConfig('Garden.Registration.DefaultRoles'); } if ($v = c('Garden.Registration.ConfirmEmailRole')) { $SQL->update('Role')->set('Type', RoleModel::TYPE_UNCONFIRMED)->where('RoleID', $types[RoleModel::TYPE_UNCONFIRMED])->put(); // RemoveFromConfig('Garden.Registration.ConfirmEmailRole'); } $guestRoleIDs = Gdn::sql()->getWhere('UserRole', array('UserID' => 0))->resultArray(); if (!empty($guestRoleIDs)) { $SQL->update('Role')->set('Type', RoleModel::TYPE_GUEST)->where('RoleID', $types[RoleModel::TYPE_GUEST])->put();