function setDefaultPermissions($objectId, $perm, $force = false)
 {
     require_once 'www/project/admin/permissions.php';
     $res = permission_db_get_defaults($perm);
     while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
         permission_add_ugroup($this->groupId, $perm, $objectId, $row['ugroup_id'], $force);
     }
 }
 private function getDefaultGitAdminPermissions()
 {
     return permission_db_get_defaults(Git::PERM_ADMIN);
 }
 /**
  * Get the list of people to notify when Watermarking is disabled 
  * 
  * Notify the Docman admins.
  * Current code is not really clean, but as there is no clean interface
  * for ugroups & permission manangement...
  * 
  * @return Array
  */
 public function getPeopleToNotifyWhenWatermarkingIsDisabled($item)
 {
     $res = permission_db_authorized_ugroups('PLUGIN_DOCMAN_ADMIN', $item->getGroupId());
     if (db_numrows($res) == 0) {
         $res = permission_db_get_defaults('PLUGIN_DOCMAN_ADMIN');
     }
     $admins = array();
     $um = UserManager::instance();
     while ($row = db_fetch_array($res)) {
         if ($row['ugroup_id'] < 101) {
             $sql = ugroup_db_get_dynamic_members($row['ugroup_id'], 0, $item->getGroupId());
         } else {
             $sql = ugroup_db_get_members($row['ugroup_id']);
         }
         $res_members = db_query($sql);
         while ($row_members = db_fetch_array($res_members)) {
             $admins[] = $um->getUserById($row_members['user_id'])->getEmail();
         }
     }
     return $admins;
 }
 /**
  * Return true if the user has one of his ugroups with ADMIN permission on docman
  * @return boolean
  * @access protected
  */
 function _isUserDocmanAdmin($user)
 {
     require_once 'www/project/admin/permissions.php';
     $has_permission = false;
     $permission_type = 'PLUGIN_DOCMAN_ADMIN';
     $object_id = $this->groupId;
     // permissions set for this object.
     $res = permission_db_authorized_ugroups($permission_type, (int) $object_id);
     if (db_numrows($res) < 1 && $permission_type == 'PLUGIN_DOCMAN_ADMIN') {
         // No ugroup defined => no permissions set => get default permissions only for admin permission
         $res = permission_db_get_defaults($permission_type);
     }
     while (!$has_permission && ($row = db_fetch_array($res))) {
         // should work even for anonymous users
         $has_permission = ugroup_user_is_member($user->getId(), $row['ugroup_id'], $this->groupId);
     }
     return $has_permission;
 }
Esempio n. 5
0
/**
 * Return true if the permissions set for the given object are the same as the default values
 * Return false if they are different
 */
function permission_equals_to_default($permission_type, $object_id)
{
    $res1 = permission_db_authorized_ugroups($permission_type, $object_id);
    if (db_numrows($res1) == 0) {
        // No ugroup defined means default values
        return true;
    }
    $res2 = permission_db_get_defaults($permission_type);
    if (db_numrows($res1) != db_numrows($res2)) {
        return false;
    }
    while ($row1 = db_fetch_array($res1)) {
        $row2 = db_fetch_array($res2);
        if ($row1['ugroup_id'] != $row2['ugroup_id']) {
            return false;
        }
    }
    return true;
}