Пример #1
0
function users_can_manage_group_all($id_group = 1, $access = "IR")
{
    global $config;
    if ($id_group != 1) {
        return true;
    }
    $is_admin = get_admin_user($config['id_user']);
    if (give_acl($config['id_user'], 1, $access) || $is_admin) {
        return true;
    }
    return false;
}
Пример #2
0
function check_user_incident($id_user, $id_incident)
{
    $users = get_incident_users($id_incident);
    return in_array($id_user, $users['owner']) || in_array($id_user, $users['creator']) || get_admin_user($id_user);
}
Пример #3
0
/** 
 * Get all the groups a user has reading privileges.
 * 
 * @param id_user User id
 * @param permission Permission to have in the group (IR by default)
 * 
 * @return A list of the groups the user has reading privileges.
 */
function get_user_groups($id_user = 0, $permission = 'IR', $all = true, $returnAllColumns = false)
{
    if ($id_user === 0) {
        global $config;
        $id_user = $config['id_user'];
    }
    $user_groups = array();
    $groups = get_groups();
    // Admin have access to everything, so this loop is DIFFERENT from
    // loop below.
    if (get_admin_user($id_user)) {
        foreach ($groups as $group) {
            if (!$all && $group["id_grupo"] == 1) {
                continue;
            }
            if ($returnAllColumns) {
                $user_groups[$group['id_grupo']] = $group;
            } else {
                $user_groups[$group['id_grupo']] = $group['nombre'];
            }
        }
        return $user_groups;
    }
    if (!$groups) {
        return $user_groups;
    }
    foreach ($groups as $group) {
        if (!$all && $group["id_grupo"] == 1) {
            continue;
        }
        if (!give_acl($id_user, $group["id_grupo"], $permission)) {
            continue;
        }
        if ($returnAllColumns) {
            $user_groups[$group['id_grupo']] = $group;
        } else {
            $user_groups[$group['id_grupo']] = $group['nombre'];
        }
    }
    return $user_groups;
}
Пример #4
0
        echo "</div>";
        // SLA Management
        echo "<div class='portlet'>";
        echo "<h3 class='admin'>" . __('SLA') . "</h3>";
        echo "<ul class='sidemenu'>";
        if ($sec2 == "operation/slas/sla_detail") {
            echo "<li id='sidesel'>";
        } else {
            echo "<li>";
        }
        echo "<a href='index.php?sec=incidents&sec2=operation/slas/sla_detail'>" . __('SLA Management') . "</a></li>";
        echo "</ul>";
        echo "</div>";
    }
    //Workflow rules
    if (get_admin_user($config['id_user'])) {
        enterprise_include("operation/sidemenu_workflow_rules.php");
    }
    echo "</div></div>";
}
// INVENTORY
if ($sec == "inventory" && give_acl($config['id_user'], 0, "VR") && $show_inventory != MENU_HIDDEN) {
    $id_inventory = (int) get_parameter('id');
    echo "<div class='portlet'>";
    echo "<h3>" . __('Inventory') . "</h3>";
    echo "<ul class='sidemenu'>";
    // Incident overview
    if ($sec2 == "operation/inventories/inventory") {
        echo "<li id='sidesel'>";
    } else {
        echo "<li>";
Пример #5
0
function get_contracts($only_names = true, $filter = false)
{
    global $config;
    $contracts = get_db_all_rows_filter('tcontract', $filter);
    if ($contracts === false) {
        return array();
    }
    $names = array();
    foreach ($contracts as $k => $contract) {
        if (!give_acl($config["id_user"], $contract['id_group'], "VR") && !get_admin_user($config["id_user"])) {
            continue;
        }
        $names[$contract['id']] = $contract['name'];
    }
    asort($names);
    if ($only_names) {
        return $names;
    }
    $retval = array();
    $contract_keys = array_keys($names);
    foreach ($contracts as $contract) {
        if (in_array($contract['id'], $contract_keys)) {
            $retval[] = $contract;
        }
    }
    return $retval;
}
Пример #6
0
		$config["id_user"] = $loginhash_user;
	}
	else {
			echo '<body class="login">';
			require ('general/login_page.php');
			exit;
	}
} elseif (! isset ($_SESSION['id_usuario']) && $login) {

	$nick = get_parameter ("nick");
	$pass = get_parameter ("pass");

	$config["auth_error"] = "";

	$nick_in_db = process_user_login ($nick, $pass);
	$is_admin = get_admin_user($nick_in_db);

	if (($nick_in_db !== false) && ($is_admin != 1) && ($is_enterprise) && ($config['enable_pass_policy'])) {

		$blocked = login_check_blocked($nick);

		if ($blocked) {
			echo '<body class="login">';
			require ('general/login_page.php');
			exit;
		}
		//Checks if password has expired
		$check_status = check_pass_status($nick, $pass);

		switch ($check_status) {
			case 1: //first change
 /**
  * Create a zip package with the /tmp files in the user folder on tattachment/file_sharing
  * and delete the original files.
  * Fill the files with FileSharingFile objects is required. This objects should have filled
  * the params 'fullpath' and 'basename'.
  * 
  * @return array The index 'status' shows the result of the operation, the index 'message'
  * returns a message and the index 'bad_files' returns an array with the not created files.
  */
 public function save()
 {
     global $config;
     $result = array('status' => false, 'message' => '', 'badFiles' => array());
     if (isset($this->files) && !empty($this->files) && is_array($this->files)) {
         if (isset($this->id)) {
             // Do nothing. At this moment the package edition is not supported
             $result['message'] = __('At this moment the package edition is not supported');
         } else {
             // Package creation
             if (class_exists("ZipArchive")) {
                 // The admin can manage the file uploads as any user
                 $user_is_admin = (bool) dame_admin($config['id_user']);
                 if ($user_is_admin) {
                     $id_user = get_parameter("id_user", $config['id_user']);
                     // If the user doesn't exist get the current user
                     $user_data = get_user($id_user);
                     if (empty($user_data)) {
                         $id_user = $config['id_user'];
                     }
                     $this->uploader = $id_user;
                 } else {
                     $this->uploader = $config['id_user'];
                 }
                 if (!isset($this->filename) || empty($this->filename)) {
                     $this->filename = 'IntegriaIMS-SharedFile';
                 }
                 if (!isset($this->description)) {
                     $this->description = '';
                 }
                 if (!isset($this->created)) {
                     $this->created = time();
                 }
                 $this->filename .= ".zip";
                 // Insert the package info into the tattachment table
                 $values = array();
                 $values['id_usuario'] = safe_input($this->uploader);
                 $values['filename'] = safe_input($this->filename);
                 $values['timestamp'] = date("Y-m-d", $this->created);
                 $values['public_key'] = hash("sha256", $id . $this->uploader . $this->filename . $this->created);
                 $values['file_sharing'] = 1;
                 $id = process_sql_insert(FileSharingFile::$dbTable, $values);
                 if (!empty($id)) {
                     $this->id = $id;
                     if (!file_exists(self::$fileSharingDir) && !is_dir(self::$fileSharingDir)) {
                         mkdir(self::$fileSharingDir);
                     }
                     $userDir = self::$fileSharingDir . "/" . $this->uploader;
                     if (!file_exists($userDir) && !is_dir($userDir)) {
                         mkdir($userDir);
                     }
                     $this->fullpath = $userDir . "/" . $this->id . "_" . $this->filename;
                     // Zip creation
                     $zip = new ZipArchive();
                     $res = $zip->open($this->fullpath, ZipArchive::CREATE);
                     if ($res === true) {
                         foreach ($this->files as $file) {
                             if (is_array($file)) {
                                 $file = new FileSharingFile($file);
                             }
                             $fullpath = $file->getFullpath();
                             $basename = $file->getBasename();
                             if ($file->isReadable() && !empty($fullpath) && !empty($basename)) {
                                 // Add the file to the package
                                 if (!$zip->addFile($fullpath, $basename)) {
                                     $result['badFiles'][] = $file;
                                 }
                             } else {
                                 $result['badFiles'][] = $file;
                             }
                         }
                         $zip->close();
                         $filesCount = count($this->files);
                         $badFilesCount = count($result['badFiles']);
                         if ($badFilesCount == 0) {
                             $result['status'] = true;
                         } else {
                             if ($badFilesCount < $filesCount) {
                                 $result['status'] = true;
                                 $result['message'] = __('Not all the files where added to the package');
                             } else {
                                 $result['message'] = __('An error occurred while building the package');
                             }
                         }
                         // Remove the original files
                         foreach ($this->files as $file) {
                             if (is_array($file)) {
                                 $file = new FileSharingFile($file);
                             }
                             $file->deleteFromDisk();
                         }
                         // Reload the data and recheck the package
                         if ($result['status']) {
                             $this->loadWithID($this->id);
                             if (!$this->exists || !$this->readable) {
                                 $result['status'] = false;
                                 $result['message'] = __('An error occurred while building the package');
                                 $result['badFiles'] = array();
                                 $this->delete();
                             } else {
                                 // The file was created successsfully
                                 $this->trackingCreation();
                             }
                         }
                     }
                 } else {
                     $result['message'] = __('An error occurred while creating the package');
                     foreach ($this->files as $file) {
                         if (is_array($file)) {
                             $file = new FileSharingFile($file);
                         }
                         $file->deleteFromDisk();
                     }
                 }
             } else {
                 if (get_admin_user($config['id_user'])) {
                     $result['message'] = __("Impossible to handle the package. You have to install the PHP's Zip extension");
                 } else {
                     $result['message'] = __('An error occurred while building the package');
                 }
             }
         }
     } else {
         $result['message'] = __('This package has no files');
     }
     return $result;
 }