public static function mapLTIRole2TaoRole($role)
    {
        $taoRole = null;
        if (filter_var($role, FILTER_VALIDATE_URL)) {
            // url found
            $taoRole = new core_kernel_classes_Resource($role);
        } else {
            // if not fully qualified prepend LIS context role NS
            if (strtolower(substr($role, 0, 4)) !== 'urn:') {
                $role = self::LIS_CONTEXT_ROLE_NAMESPACE . $role;
            }
            list ($prefix, $nid, $nss) = explode(':', $role, 3);
            if ($nid != 'lti') {
                common_Logger::w('Non LTI URN ' . $role . ' passed via LTI');
            }
            $urn = 'urn:' . strtolower($nid) . ':' . $nss;

            // search for fitting role
            $class = new core_kernel_classes_Class(LtiRoles::CLASS_URI);
            $cand = $class->searchInstances(array(
                LtiRoles::PROPERTY_URN => $urn
            ));
            if (count($cand) > 1) {
                throw new common_exception_Error('Multiple instances share the URN ' . $urn);
            }
            if (count($cand) == 1) {
                $taoRole = current($cand);
            } else {
                common_Logger::w('Unknown LTI role with urn: ' . $urn);
            }
        }
        if (!is_null($taoRole) && $taoRole->exists()) {
            return $taoRole->getUri();
        } else {
            return null;
        }
    }
public static function mapLTIRole2TaoRole($role)
    {
        $taoRole = null;
        if (filter_var($role, FILTER_VALIDATE_URL)) {
            // url found
            $taoRole = new core_kernel_classes_Resource($role);
        } else {
            // if not fully qualified prepend LIS context role NS
            if (strtolower(substr($role, 0, 4)) !== 'urn:') {
                $role = self::LIS_CONTEXT_ROLE_NAMESPACE . $role;
            }
            list ($prefix, $nid, $nss) = explode(':', $role, 3);
            if ($nid != 'lti') {
                common_Logger::w('Non LTI URN ' . $role . ' passed via LTI');
            }
            $urn = 'urn:' . strtolower($nid) . ':' . $nss;

            // search for fitting role
            $class = new core_kernel_classes_Class(LtiRoles::CLASS_URI);
            $cand = $class->searchInstances(array(
                LtiRoles::PROPERTY_URN => $urn
            ));
            if (count($cand) > 1) {
                throw new common_exception_Error('Multiple instances share the URN ' . $urn);
            }
            if (count($cand) == 1) {
                $taoRole = current($cand);
            } else {
                common_Logger::w('Unknown LTI role with urn: ' . $urn);
            }
        }
        if (!is_null($taoRole) && $taoRole->exists()) {
            return $taoRole->getUri();
        } else {
            return null;
        }
    }
public static function mapLTIRole2TaoRole ( $ role ) { $ taoRole = null ; if ( filter_var ( $ role , FILTER_VALIDATE_URL ) ) { // url found $ taoRole = new core_kernel_classes_Resource ( $ role ) ; } else { // if not fully qualified prepend LIS context role NS if ( strtolower ( substr ( $ role , 0 , 4 ) ) !== 'urn:' ) { $ role = self :: LIS_CONTEXT_ROLE_NAMESPACE . $ role ; } list ( $ prefix , $ nid , $ nss ) = explode ( ':' , $ role , 3 ) ; if ( $ nid != 'lti' ) { common_Logger :: w ( 'Non LTI URN ' . $ role . ' passed via LTI' ) ; } $ urn = 'urn:' . strtolower ( $ nid ) . ':' . $ nss ; // search for fitting role $ class = new core_kernel_classes_Class ( LtiRoles :: CLASS_URI ) ; $ cand = $ class -> searchInstances ( array ( LtiRoles :: PROPERTY_URN => $ urn ) ) ; if ( count ( $ cand ) > 1 ) { throw new common_exception_Error ( 'Multiple instances share the URN ' . $ urn ) ; } if ( count ( $ cand ) == 1 ) { $ taoRole = current ( $ cand ) ; } else { common_Logger :: w ( 'Unknown LTI role with urn: ' . $ urn ) ; } } if ( ! is_null ( $ taoRole ) && $ taoRole -> exists ( ) ) { return $ taoRole -> getUri ( ) ; } else { return null ; } }
Maps a fuly qualified or abbreviated lti role
to an existing tao role

@param string $role
@throws common_Exception
@throws common_exception_Error
@return core_kernel_classes_Resource the tao role or null
Maps a fuly qualified or abbreviated lti role to an existing tao role