/**
 * Selects all profiles (array (id => name)) or profiles filtered
 *
 * @param mixed Array with filter conditions to retrieve profiles or false.  
 *
 * @return array List of all profiles
 */
function profile_get_profiles($filter = false)
{
    if ($filter === false) {
        $profiles = get_db_all_rows_in_table("tprofile", "name");
    } else {
        $profiles = get_db_all_rows_filter("tprofile", $filter);
    }
    $return = array();
    if ($profiles === false) {
        return $return;
    }
    foreach ($profiles as $profile) {
        $return[$profile["id"]] = $profile["name"];
    }
    return $return;
}
function um_db_load_settings()
{
    clean_cache_db();
    $result = get_db_all_rows_in_table(DB_PREFIX . 'tupdate_settings');
    if ($result === false) {
        echo '<strong>Error reading settings</strong><br />';
        return NULL;
    }
    $settings = new stdClass();
    $settings->proxy = '';
    $settings->proxy_port = '';
    $settings->proxy_user = '';
    $settings->proxy_pass = '';
    foreach ($result as $field) {
        $settings->{$field}['key'] = $field['value'];
    }
    return $settings;
}
Example #3
0
function lead_progress_array()
{
    $lprogress = get_db_all_rows_in_table("tlead_progress");
    $lead_progress = array();
    foreach ($lprogress as $l) {
        $lead_progress[$l["id"]] = $l["name"];
    }
    return $lead_progress;
}
Example #4
0
function load_config()
{
    global $config;
    require_once $config["homedir"] . '/include/functions_db.php';
    $configs = get_db_all_rows_in_table('tconfig');
    if ($configs === false) {
        include $config["homedir"] . "/general/error_invalidconfig.php";
        exit;
    }
    foreach ($configs as $c) {
        $config[$c["token"]] = $c["value"];
    }
    if (!isset($config["block_size"])) {
        $config["block_size"] = 25;
    }
    if (!isset($config["notification_period"])) {
        $config["notification_period"] = "86400";
    }
    if (!isset($config["autowu_completion"])) {
        $config["autowu_completion"] = "0";
    }
    if (!isset($config["no_wu_completion"])) {
        $config["no_wu_completion"] = "";
    }
    if (!isset($config["FOOTER_EMAIL"])) {
        $config["FOOTER_EMAIL"] = __('Please do NOT answer this email, it has been automatically created by Integria (http://integria.sourceforge.net).');
    }
    if (!isset($config["HEADER_EMAIL"])) {
        $config["HEADER_EMAIL"] = "Hello, \n\nThis is an automated message coming from Integria\n\n";
    }
    if (!isset($config["currency"])) {
        $config["currency"] = "€";
    }
    if (!isset($config["hours_perday"])) {
        $config["hours_perday"] = 8;
    }
    if (!isset($config["limit_size"])) {
        $config["limit_size"] = 1000;
    }
    if (!isset($config["sitename"])) {
        $config["sitename"] = "INTEGRIA";
    }
    if (!isset($config["fontsize"])) {
        $config['fontsize'] = 7;
    }
    if (!isset($config["incident_reporter"])) {
        $config['incident_reporter'] = 0;
    }
    if (!isset($config["show_owner_incident"])) {
        $config["show_owner_incident"] = 1;
    }
    if (!isset($config["show_creator_incident"])) {
        $config["show_creator_incident"] = 1;
    }
    if (!isset($config["smtp_host"])) {
        $config["smtp_host"] = "localhost";
    }
    if (!isset($config["wokring_weekends"])) {
        $config["wokring_weekends"] = 0;
    }
    if (!isset($config["smtp_user"])) {
        $config["smtp_user"] = "";
    }
    if (!isset($config["smtp_pass"])) {
        $config["smtp_pass"] = "";
    }
    if (!isset($config["smtp_port"])) {
        $config["smtp_port"] = 25;
    }
    if (!isset($config["pop_host"])) {
        $config["pop_host"] = "localhost";
    }
    if (!isset($config["pop_port"])) {
        $config["pop_port"] = 110;
    }
    if (!isset($config["pop_user"])) {
        $config["pop_user"] = "";
    }
    if (!isset($config["pop_pass"])) {
        $config["pop_pass"] = "";
    }
    if (!isset($config["audit_delete_days"])) {
        $config["audit_delete_days"] = 45;
    }
    if (!isset($config["iwu_defaultime"])) {
        $config["iwu_defaultime"] = "0.25";
    }
    if (!isset($config["pwu_defaultime"])) {
        $config["pwu_defaultime"] = "4";
    }
    if (!isset($config["timezone"])) {
        $config["timezone"] = "Europe/Madrid";
    }
    if (!isset($config["api_acl"])) {
        $config["api_acl"] = "127.0.0.1";
    }
    if (!isset($config["auto_incident_close"])) {
        $config["auto_incident_close"] = "72";
    }
    if (!isset($config["language_code"])) {
        $config["language_code"] = "en_GB";
    }
    if (!isset($config["flash_charts"])) {
        $config["flash_charts"] = true;
    }
    // Mail address used to send mails
    if (!isset($config["mail_from"])) {
        $config["mail_from"] = "integria@localhost";
    }
    if (!isset($config["site_logo"])) {
        $config["site_logo"] = "integria_logo.png";
    }
    if (!isset($config["header_logo"])) {
        $config["header_logo"] = "integria_logo_header.png";
    }
    if (!isset($config["email_on_incident_update"])) {
        $config["email_on_incident_update"] = 0;
    }
    if (!isset($config["error_log"])) {
        $config["error_log"] = 1;
    }
    if (!isset($config["sql_query_limit"])) {
        $config["sql_query_limit"] = 1500;
    }
    if (!isset($config["pdffont"])) {
        $config["pdffont"] = $config["homedir"] . "/include/fonts/FreeSans.ttf";
    }
    if (!isset($config["font"])) {
        $config["font"] = $config["homedir"] . "/include/fonts/smallfont.ttf";
    }
    if (!isset($config["audit_category_default"])) {
        $config["audit_category_default"] = 1;
    }
    if (!isset($config["max_file_size"])) {
        $config["max_file_size"] = "50M";
    }
    if (!isset($config["enable_newsletter"])) {
        $config["enable_newsletter"] = 0;
    }
    if (!isset($config["batch_newsletter"])) {
        $config["batch_newsletter"] = 15;
    }
    if (!isset($config["want_chat"])) {
        $config["want_chat"] = 0;
    }
    if (!isset($config["lead_warning_time"])) {
        $config["lead_warning_time"] = "7";
    }
    if (!isset($config["incident_creation_wu"])) {
        $config["incident_creation_wu"] = 0;
    }
    if (!isset($config["graphviz_win"])) {
        $config["graphviz_win"] = "C:\\Program Files\\Graphviz 2.28\\bin";
    }
    if (!isset($config["months_to_delete_incidents"])) {
        $config["months_to_delete_incidents"] = 12;
    }
    if (!isset($config["working_weekends"])) {
        $config["working_weekends"] = 0;
    }
    if (!isset($config["mask_emails"])) {
        $config["mask_emails"] = 0;
    }
    if (!isset($config['attachment_store'])) {
        $config['attachment_store'] = $config['homedir'] . 'attachment';
    }
    if (!isset($config['session_timeout'])) {
        $config['session_timeout'] = 9000;
    }
    if (!isset($config['update_manager_installed'])) {
        $config['update_manager_installed'] = 1;
    }
    if (!isset($config["inventory_path"])) {
        $config["inventory_path"] = $config["homedir"] . "attachment/inventory";
    }
    if (!isset($config["remote_inventory_type"])) {
        $config["remote_inventory_type"] = 0;
    }
    if (!isset($config["inventory_default_owner"])) {
        $config["inventory_default_owner"] = "";
    }
    if (!isset($config["smtp_queue_retries"])) {
        $config["smtp_queue_retries"] = 10;
    }
    if (!isset($config["access_protocol"])) {
        $config["access_protocol"] = false;
    }
    if (!isset($config["access_port"])) {
        $config["access_port"] = "";
    }
    if (!isset($config["access_public"])) {
        if (isset($_SERVER["SERVER_NAME"])) {
            $config["access_public"] = $_SERVER["SERVER_NAME"];
        } else {
            $config["access_public"] = "localhost";
        }
        update_config_token("access_public", $config["access_public"]);
    }
    if (!isset($config["license"])) {
        $config["license"] = "INTEGRIA-FREE";
        update_config_token("license", $config["license"]);
    }
    if (!isset($config["news_smtp_host"])) {
        $config["news_smtp_host"] = "";
    }
    if (!isset($config["news_smtp_user"])) {
        $config["news_smtp_user"] = "";
    }
    if (!isset($config["news_smtp_pass"])) {
        $config["news_smtp_pass"] = "";
    }
    if (!isset($config["news_smtp_port"])) {
        $config["news_smtp_port"] = "";
    }
    if (!isset($config["news_batch_newsletter"])) {
        $config["news_batch_newsletter"] = "";
    }
    if (!isset($config["enabled_ticket_editor"])) {
        $config["enabled_ticket_editor"] = 0;
    }
    if (!isset($config["email_ticket_on_creation_and_closing"])) {
        $config["email_ticket_on_creation_and_closing"] = 0;
    }
    if (!isset($config["batch_email_validation"])) {
        $config["batch_email_validation"] = 10;
    }
    if (!isset($config["active_validate"])) {
        $config["active_validate"] = 1;
    }
    if (!isset($config["enable_update_manager"])) {
        $config["enable_update_manager"] = true;
    }
    if (!isset($config["invoice_auto_id"])) {
        $config["invoice_auto_id"] = 0;
    }
    if (!isset($config["invoice_id_pattern"])) {
        $config["invoice_id_pattern"] = "15/[1000]";
    }
    if (!isset($config["change_creator_owner"])) {
        $config["change_creator_owner"] = 1;
    }
}
Example #5
0
function api_get_incidents_status($return_type, $user)
{
    $status = get_db_all_rows_in_table('tincident_status');
    $status = clean_numerics($status);
    $ret = '';
    if ($return_type == 'xml') {
        $ret = "<xml>\n";
    }
    foreach ($status as $index => $item) {
        switch ($return_type) {
            case "xml":
                $ret .= "<status>\n";
                foreach ($item as $key => $value) {
                    if (!is_numeric($key)) {
                        $ret .= "<" . $key . ">" . $value . "</" . $key . ">\n";
                    }
                }
                $ret .= "</status>\n";
                break;
            case "csv":
                $ret .= array_to_csv($item);
                break;
        }
    }
    if ($return_type == 'xml') {
        $ret .= "</xml>\n";
    }
    return $ret;
}
Example #6
0
    echo '<h3 class="suc">' . __('Updated successfuly') . '</h3>';
}
echo '<form method="post">';
$table->width = '99%';
$table->class = 'search-table';
$table->colspan = array();
$table->data = array();
$status = get_db_all_rows_in_table('tincident_status');
foreach ($status as $stat) {
    $data = array();
    $data[0] = print_input_text('status[' . $stat['id'] . ']', $stat['name'], '', 35, 255, true);
    array_push($table->data, $data);
}
$table_status = print_table($table, true);
$table->data = array();
$resolutions = get_db_all_rows_in_table('tincident_resolution');
foreach ($resolutions as $resolution) {
    $data = array();
    $data[0] = print_input_text('resolutions[' . $resolution['id'] . ']', $resolution['name'], '', 35, 255, true);
    array_push($table->data, $data);
}
$table_resolutions = print_table($table, true);
$table->width = '99%';
$table->class = 'search-table listing';
$table->colspan = array();
$table->data = array();
$date_table = "<table>";
$date_table .= "<tr>";
$date_table .= "<td>";
$date_table .= "<input id='new_day' type='text' name='new_day' width='15' size='15'>";
$date_table .= "</td>";
global $config;
check_login();
require_once 'include/functions_inventories.php';
echo '<h1>' . __('Inventory reports') . '</h1>';
$delete = (bool) get_parameter('delete_report');
if ($delete) {
    $id = (int) get_parameter('id');
    $result = process_sql_delete('tinventory_reports', array('id' => $id));
    if ($result !== false) {
        echo '<h3 class="suc">' . __('Successfully deleted') . '</h3>';
    } else {
        echo '<h3 class="error">' . __('Could not be deleted') . '</h3>';
    }
}
if (dame_admin($config['id_user'])) {
    $reports = get_db_all_rows_in_table('tinventory_reports');
} else {
    $all_groups_str = groups_get_user_groups($config['id_user']);
    $sql = "SELECT * FROM tinventory_reports WHERE id_group IN " . $all_groups_str;
    $reports = get_db_all_rows_sql($sql);
}
if ($reports === false) {
    echo '<h2 class="error">' . __('No reports were found') . '</h2>';
} else {
    $table->width = '99%';
    $table->class = 'listing';
    $table->data = array();
    $table->head = array();
    $table->head[0] = __('Name/Edit');
    $table->head[1] = __('View');
    $table->head[2] = __('PDF');
/**
 * Return a array of id_group of childrens (to branches down)
 *
 * @param integer $parent The id_group parent to search the childrens.
 * @param array $groups The groups, its for optimize the querys to DB.
 */
function groups_get_childrens($parent, $groups = null)
{
    if (empty($groups)) {
        $groups = get_db_all_rows_in_table('tgrupo');
    }
    $return = array();
    foreach ($groups as $key => $group) {
        if ($group['id_grupo'] == 0) {
            continue;
        }
        if ($group['parent'] == $parent) {
            $return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups);
        }
    }
    return $return;
}
Example #9
0
function get_object_types($only_names = true, $only_show = false)
{
    if ($only_show) {
        $sql = "SELECT * FROM tobject_type WHERE show_in_list = 1";
        $types = get_db_all_rows_sql($sql);
    } else {
        $types = get_db_all_rows_in_table('tobject_type');
    }
    if ($types == false) {
        return array();
    }
    if ($only_names) {
        $result = array();
        foreach ($types as $type) {
            $result[$type['id']] = $type['name'];
        }
        return $result;
    }
    return $types;
}
Example #10
0
 $fields = array();
 foreach ($desc_ext as $key => $ext) {
     if ($parent_reference_field == $ext['Field']) {
         continue;
     }
     $fields[$ext['Field']] = $ext['Field'];
 }
 if ($id_parent_value) {
     $id_parent = get_parameter("id_parent", 0);
     $table_name_parent = get_db_value_sql("SELECT parent_table_name FROM tobject_type_field WHERE id=" . $id_object_type_field);
     $id_reference_parent = get_db_value_sql("SELECT parent_reference_field FROM tobject_type_field WHERE id=" . $id_object_type_field);
     $parent_label = get_db_value_sql("SELECT external_label FROM tobject_type_field WHERE id=" . $id_parent);
     $id_parent_value = get_db_value_sql('SELECT ' . $id_parent_table . ' FROM ' . $table_name_parent . ' WHERE ' . $parent_label . '="' . $id_parent_value . '"');
     $external_data = get_db_all_rows_sql("SELECT * FROM {$table_name} WHERE " . $id_reference_parent . "=" . $id_parent_value);
 } else {
     $external_data = get_db_all_rows_in_table($table_name);
 }
 if ($external_data !== false) {
     $table->class = 'listing';
     $table->width = '98%';
     $table->data = array();
     $table->head = array();
     $keys = array_keys($fields);
     $i = 0;
     foreach ($keys as $k => $head) {
         $table->head[$i] = $head;
         if ($head == $id_table) {
             $pos_id = $i + 1;
         }
         $i++;
     }
function get_products($only_names = true)
{
    $products = get_db_all_rows_in_table('tkb_product');
    if ($products === false) {
        return array();
    }
    if ($only_names) {
        $retval = array();
        foreach ($products as $product) {
            $retval[$product['id']] = $product['name'];
        }
        return $retval;
    }
    return $products;
}
    if ($id) {
        $button = print_submit_button(__('Update'), "enviar", false, 'class="sub upd"', true);
        $button .= print_input_hidden('update_group', 1, true);
        $button .= print_input_hidden('id', $id, true);
    } else {
        $button .= print_submit_button(__('Create'), "enviar", false, 'class="sub create"', true);
        $button .= print_input_hidden('insert_group', 1, true);
    }
    $table->data[0][2] = $button;
    // $table->data['button'][0] = $button;
    // $table->colspan['button'][0] = 2;
    echo '<form id="form-project_group_detail" method="post">';
    print_table($table);
    echo "</form>";
} else {
    $groups = get_db_all_rows_in_table('tproject_group', 'name');
    $table->width = "99%";
    if ($groups !== false) {
        $table->class = "listing";
        $table->data = array();
        $table->style = array();
        $table->style[0] = 'font-weight: bold';
        $table->size = array();
        $table->size[1] = '40px';
        $table->align = array();
        $table->align[1] = 'center';
        $table->head = array();
        $table->head[0] = __('Name');
        $table->head[1] = __('Delete');
        foreach ($groups as $group) {
            $data = array();
Example #13
0
function crm_get_campaigns()
{
    $campaigns = get_db_all_rows_in_table("tcampaign");
    return $campaigns;
}
Example #14
0
    echo "</div>";
} else {
    // Main list view for Links editor
    $table = new StdClass();
    $table->width = '100%';
    $table->class = 'listing';
    $table->data = array();
    $table->style = array();
    $table->style[0] = 'font-weight: bold';
    $table->align = array();
    $table->align[2] = 'center';
    $table->head = array();
    $table->head[0] = __('Link name');
    $table->head[1] = __('URL');
    $table->head[2] = __('Delete');
    $links = get_db_all_rows_in_table('tlink', 'name');
    if ($links === false) {
        $links = array();
    }
    foreach ($links as $link) {
        $data = array();
        $data[0] = '<a href="index.php?sec=godmode&sec2=godmode/setup/links&edit=1&id_link=' . $link['id_link'] . '">' . $link['name'] . '</a>';
        $data[1] = '<a href="' . $link['link'] . '">' . $link['link'] . '</a>';
        $data[2] = '<a href="index.php?sec=godmode&sec2=godmode/setup/links&delete=1&id_link=' . $link["id_link"] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png"></a>';
        array_push($table->data, $data);
    }
    echo "<div class='divresult'>";
    print_table($table);
    echo "</div>";
    echo "<div class='divform'>";
    echo '<form method="post">';
function calendar_get_non_working_days($year = false)
{
    global $config;
    $holidays = get_db_all_rows_in_table("tholidays", "day");
    if (!$year || $config["working_weekends"]) {
        return $holidays;
    }
    $res = array();
    foreach ($holidays as $holiday) {
        $day = new DateTime($holiday["day"]);
        $res[] = $day->format("Y-m-d");
    }
    $start = new DateTime("{$year}-1-1");
    $end = new DateTime("{$year}-12-31");
    $endTimestamp = $end->getTimestamp();
    if ($start->format("w") == 6 || $start->format("w") == 0) {
        $d = $start;
    } else {
        $d = $start->modify("next saturday");
    }
    $oneday = new DateInterval("P1D");
    $sixdays = new DateInterval("P6D");
    while ($d->getTimestamp() <= $endTimestamp) {
        $res[] = $d->format("Y-m-d");
        $d = $d->add($oneday);
        if ($d->getTimestamp() <= $endTimestamp) {
            $res[] = $d->format("Y-m-d");
        }
        $d = $d->add($sixdays);
    }
    return $res;
}
Example #16
0
        $button .= print_input_hidden('insert_object', 1, true);
    } else {
        $button = print_submit_button(__('Update'), 'upd_btn', false, 'class="sub upd"', true);
        $button .= print_input_hidden('id', $id, true);
        $button .= print_input_hidden('update_object', 1, true);
    }
    $table->data[3][0] = $button;
    echo '<form id="form-manage_objects" method="post">';
    print_table($table);
    echo '</form>';
}
//**********************************************************************
// List objects
//**********************************************************************
if (!$id && !$create) {
    $objects = get_db_all_rows_in_table('tobject_type', 'name');
    $table->width = '99%';
    if ($objects !== false) {
        $table->class = 'listing';
        $table->data = array();
        $table->head = array();
        $table->head[0] = __('ID');
        $table->head[1] = __('Name');
        $table->head[2] = __('Description');
        $table->head[3] = __('Items');
        $table->head[4] = __('Actions');
        $table->style = array();
        $table->style[1] = 'font-weight: bold';
        $table->align = array();
        echo '<table width="90%" class="listing">';
        foreach ($objects as $object) {
Example #17
0
        $button = print_submit_button(__('Create'), 'crt_btn', false, 'class="sub create"', true);
        $button .= print_input_hidden('insert_product', 1, true);
    } else {
        $button = print_submit_button(__('Update'), 'upd_btn', false, 'class="sub upd"', true);
        $button .= print_input_hidden('id', $id, true);
        $button .= print_input_hidden('update_product', 1, true);
    }
    $table->data['button'][0] = $button;
    echo '<form id="form-product_type" method="post">';
    print_table($table);
    echo "</form>";
}
// Show list of product
// =======================
if (!$id && !$create) {
    $products = get_db_all_rows_in_table('tkb_product', 'name');
    $table->width = '99%';
    echo "<h1>" . __('Defined products') . "</h1>";
    if ($products !== false) {
        $table->class = 'listing';
        $table->data = array();
        $table->head = array();
        $table->head[0] = __('ID');
        $table->head[1] = __('Icon');
        $table->head[2] = __('Name');
        $table->head[3] = __('Description');
        $table->head[4] = __('Items');
        $table->head[5] = __('Delete');
        $table->style = array();
        $table->style[2] = 'font-weight: bold';
        $table->align = array();