section as $section){ if (strpos($section->sc,$country.'-') === 0) { //== whole sections =========================== //eg. CZ-USTI-ESN, CZ-LIBE-ESN, ... $casGroups[(string)$section->sc] = '/^('.$section->sc.'_Local\.[^"]+)$/'; //== Local roles ========================= //single local roles generation like CZ-USTI-ESN.president, CZ-USTI-ESN.alumnus,... foreach ($local_roles as $role) { $casGroups[$section->sc.'.'.$role] = '/^('.$section->sc.'_Local\.'.$role.')$/'; } } } //==== dynamic section loading END =========================================== /* //==== manual section names ================================================== $sections = array( // group name used by dokuwiki => name in galaxy 'CZ-ZLIN-ESN', 'CZ-CBUD-VST', 'CZ-PRAG-ICT', 'CZ-OSTR-VSB', 'CZ-HRKR-ESN', 'CZ-LIBE-ESN', 'CZ-PILS-UWB', 'CZ-OLOM-UPA', 'CZ-PRAG-VSE', 'CZ-PRAG-CUN', 'CZ-PRAG-CTU', 'CZ-BRNO-ISC', 'CZ-MZLU-ESN', 'CZ-OSTR-ISC', 'CZ-BRNO-VUT', 'CZ-USTI-ESN' ); foreach ($sections as $section) { //== whole sections =========================== //eg. ESN_Usti, ISC_VUT_Brno, ... $casGroups[$section] = '/^('.$section.'_Local\.[^"]+)$/'; //anyone (not by role list) //$casGroups[$key] = '/^('.$value.'_Local\.(' . implode("|", $local_roles) . '))$/'; //using just the list //== Local roles ========================= //single local roles generation like ESN_Usti.president, ESN_Usti.alumnus,... foreach ($local_roles as $role) { $casGroups[$section.'.'.$role] = '/^('.$section.'_Local\.'.$role.')$/'; } } //==== manual section names END ============================================== */ return $casGroups; } /* * The function plaincas_pattern_attributes has to return an array * with the CAS attributes which will be matched against the regular expressions * $attributes = phpCAS::getAttributes(); */ function plaincas_pattern_attributes( $attributes ){ $matchAttributes = array(); // in this example the attribute 'roles' is an array // and all of the elements will be prepended by the attribute 'sc' $roles = $attributes['roles']; $section = $attributes['sc']; if (!is_array($roles)) { $roles = array($roles); } foreach ($roles as $role) { $matchAttributes[] = $section . '_' . $role; } // finally the array is returned. return $matchAttributes; } /* * The function plaincas_user_attributes has to return an array * with keys 'name' and 'mail' representing the user. * $attributes = phpCAS::getAttributes(); */ function plaincas_user_attributes( $attributes ){ return array( 'name' => $attributes['first'] . ' ' . $attributes['last'], 'mail' => $attributes['mail'], ); } /* * The function plaincas_custom_groups has to return an array * with groupnames as keys and an array or usernames. * * Custom groups are independent of CAS attributes or groups but the group names can be the same. */ /* function plaincas_custom_groups(){ $customGroups = array( 'group1' => array('admin', 'userame2'), 'group2' => array('username3', 'userame4'), ); return $customGroups; } */