public function setRoleToUsers( core_kernel_classes_Resource $role, $users = array())
    {
        $returnValue = (bool) false;
        $userService = tao_models_classes_UserService::singleton();

        $rolesProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_ROLES);
    	foreach ($users as $u){
    		$u = ($u instanceof core_kernel_classes_Resource) ? $u : new core_kernel_classes_Resource($u);

    		// just in case of ...
    		$userService->unnatachRole($u, $role);

    		// assign the new role.
    		$u->setPropertyValue($rolesProperty, $role);

    		if (common_session_SessionManager::getSession()->getUserUri() == $u->getUri()) {
    		    common_session_SessionManager::getSession()->refresh();
    		}
    	}

    	$returnValue = true;

        return (bool) $returnValue;
    }
public function setRoleToUsers( core_kernel_classes_Resource $role, $users = array())
    {
        $returnValue = (bool) false;
        $userService = tao_models_classes_UserService::singleton();

        $rolesProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_ROLES);
    	foreach ($users as $u){
    		$u = ($u instanceof core_kernel_classes_Resource) ? $u : new core_kernel_classes_Resource($u);

    		// just in case of ...
    		$userService->unnatachRole($u, $role);

    		// assign the new role.
    		$u->setPropertyValue($rolesProperty, $role);

    		if (common_session_SessionManager::getSession()->getUserUri() == $u->getUri()) {
    		    common_session_SessionManager::getSession()->refresh();
    		}
    	}

    	$returnValue = true;

        return (bool) $returnValue;
    }
public function setRoleToUsers ( core_kernel_classes_Resource $ role , $ users = array ( ) ) { $ returnValue = ( bool ) false ; $ userService = tao_models_classes_UserService :: singleton ( ) ; $ rolesProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_USER_ROLES ) ; foreach ( $ users as $ u ) { $ u = ( $ u instanceof core_kernel_classes_Resource ) ? $ u : new core_kernel_classes_Resource ( $ u ) ; // just in case of ... $ userService -> unnatachRole ( $ u , $ role ) ; // assign the new role. $ u -> setPropertyValue ( $ rolesProperty , $ role ) ; if ( common_session_SessionManager :: getSession ( ) -> getUserUri ( ) == $ u -> getUri ( ) ) { common_session_SessionManager :: getSession ( ) -> refresh ( ) ; } } $ returnValue = true ; return ( bool ) $ returnValue ; }
assign a role to a set of users

@access public
@author Joel Bout, <joel@taotesting.com>
@param  Resource role
@param  array users
@return boolean
assign a role to a set of users