Get the user type that matches the given config variables.
public static GetUserTypeFromConfig ( $p_configVars ) : mixed | ||
$p_configVars | An array of permissions variables | |
Результат | mixed | bool False The config passed does not match any user type object $userType The user type object matching |
/** * Updates the permissions for the user. * * @param array * $p_permissions The list of permissions * * @return bool */ public function updatePermissions($p_permissions) { global $LiveUserAdmin; if (!is_array($p_permissions) || sizeof($p_permissions) == 0) { return false; } $permissions = array(); // generate an array of granted permissions foreach ($p_permissions as $permission => $value) { if ($value) { $permissions[$permission] = $value; } } // find out whether the given config matches an specific user type $userType = UserType::GetUserTypeFromConfig($permissions); if ($userType) { $this->setUserType($userType->getId()); $this->setProperty('fk_user_type', $userType->getId()); } else { foreach ($p_permissions as $permission => $value) { $filter = array('filters' => array('right_define_name' => $permission)); $right = $LiveUserAdmin->perm->getRights($filter); if (!is_array($right) || sizeof($right) == 0) { continue; } $params = array('right_id' => $right[0]['right_id'], 'perm_user_id' => $this->getPermUserId()); // revoke or grant the given right if (isset($this->m_config[$permission])) { if (!$value) { $LiveUserAdmin->perm->revokeUserRight($params); unset($this->m_config[$permission]); } } if ($value) { $LiveUserAdmin->perm->grantUserRight($params); } } // remove this user from current user type if any $filter = array('group_id' => $this->getUserType(), 'perm_user_id' => $this->getPermUserId()); $LiveUserAdmin->perm->removeUserFromGroup($filter); $this->setProperty('fk_user_type', 'NULL', true, true); } } // fn updatePermissions