/**
  * Permission generic check
  *
  * @param integer $permType Type of permission : PERM_READ|PERM_EDIT|PERM_DENY
  *
  * @return boolean
  */
 function getPerm($permType)
 {
     return CPermObject::getPermObject($this, $permType);
 }
Exemple #2
0
 /**
  * @see parent::getPerm()
  */
 function getPerm($permType)
 {
     if (!$this->_ref_group) {
         $this->loadRefsFwd();
     }
     return CPermObject::getPermObject($this, $permType) && $this->_ref_group->getPerm($permType);
 }
    $_perm->_owner = "template";
    $_perm->loadRefDBModule();
    $permsModule[$_perm->mod_id]["profil"] = $_perm;
}
foreach ($permModule->loadList($whereUser, $order) as $_perm) {
    $permsModuleCount++;
    $_perm->_owner = "user";
    $module = $_perm->loadRefDBModule();
    if (!$module->_id) {
        $isAdminPermSet = true;
    }
    $permsModule[$module->_id]["user"] = $_perm;
    unset($modulesInstalled[$module->mod_name]);
}
// DROITS SUR LES OBJETS
$permObject = new CPermObject();
$permsObject = array();
$permsObjectCount = 0;
$order = "object_class, object_id";
// Droit sur le profil
foreach ($permObject->loadList($whereProfil, $order) as $_perm) {
    $permsObjectCount++;
    $_perm->_owner = "template";
    $object = $_perm->loadRefDBObject();
    $permsObject[$object->_class][$object->_id]["profil"] = $_perm;
}
// Droit sur l'utilisateur
foreach ($permObject->loadList($whereUser, $order) as $_perm) {
    $permsObjectCount++;
    $_perm->_owner = "user";
    $object = $_perm->loadRefDBObject();
 /**
  * Load user permissions
  *
  * @param int $user_id The user's ID
  *
  * @return void FIXME Everything is put into global $userPermsObjects
  */
 static function loadUserPerms($user_id = null)
 {
     global $userPermsObjects;
     // Déclaration du user
     $user = CUser::get($user_id);
     /** @var self[] $permsObjectFinal */
     $permsObjectFinal = array();
     /** @var self[] $tabObjectProfil */
     $tabObjectProfil = array();
     /** @var self[] $tabObjectSelf */
     $tabObjectSelf = array();
     // Chargement des droits
     $permsObjectSelf = CPermObject::loadExactPermsObject($user->user_id);
     // Creation du tableau de droits du user
     foreach ($permsObjectSelf as $value) {
         $tabObjectSelf["obj_{$value->object_id}{$value->object_class}"] = $value;
     }
     // Creation du tableau de droits du profil
     $permsObjectProfil = CPermObject::loadExactPermsObject($user->profile_id);
     foreach ($permsObjectProfil as $value) {
         $tabObjectProfil["obj_{$value->object_id}{$value->object_class}"] = $value;
     }
     // Fusion des deux tableaux de droits
     $tabObjectFinal = array_merge($tabObjectProfil, $tabObjectSelf);
     // Creation du tableau de fusion des droits
     foreach ($tabObjectFinal as $value) {
         $permsObjectFinal[$value->perm_object_id] = $value;
     }
     // Tri du tableau de droit final en fonction des cle (perm_module_id)
     ksort($permsObjectFinal);
     $userPermsObjects = array();
     foreach ($permsObjectFinal as $perm_obj) {
         if (!$perm_obj->object_id) {
             $userPermsObjects[$perm_obj->object_class][0] = $perm_obj;
         } else {
             $userPermsObjects[$perm_obj->object_class][$perm_obj->object_id] = $perm_obj;
         }
     }
 }
 /**
  * Ajout de la permission sur son établissement à un utilisateur
  *
  * @return void
  */
 function insGroupPermission()
 {
     $function = new CFunctions();
     $function->load($this->function_id);
     $where = array();
     $where["user_id"] = "= '{$this->user_id}'";
     $where["object_class"] = "= 'CGroups'";
     $where["object_id"] = "= '{$function->group_id}'";
     $perm = new CPermObject();
     if (!$perm->loadObject($where)) {
         $perm = new CPermObject();
         $perm->user_id = $this->user_id;
         $perm->object_class = "CGroups";
         $perm->object_id = $function->group_id;
         $perm->permission = PERM_EDIT;
         $perm->store();
     }
 }
Exemple #6
0
 function removePerms()
 {
     $this->completeField("user_id");
     $perm = new CPermModule();
     $perm->user_id = $this->user_id;
     $perms = $perm->loadMatchingList();
     foreach ($perms as $_perm) {
         $_perm->delete();
     }
     $perm = new CPermObject();
     $perm->user_id = $this->user_id;
     $perms = $perm->loadMatchingList();
     foreach ($perms as $_perm) {
         $_perm->delete();
     }
 }