示例#1
0
		}
		$manufacturers = get_manufacturers ();
		$table_search->data[1][1] = print_select ($manufacturers, 'id_manufacturer',
		$params['id_manufacturer'], '', __('None'), 0, true, false, false, __('Manufacturer'), '','');

		//User Assoc
		if(!isset($params['associated_user'])){
			$params['associated_user'] = '';
		}
		$params_associated['input_id'] = 'text-associated_user';
		$params_associated['input_name'] = 'associated_user';
		$params_associated['input_value'] = $params['associated_user'];
		$params_associated['title'] = __('Associated user');
		$params_associated['return'] = true;
	
		$table_search->data[1][2] = user_print_autocomplete_input($params_associated);
		
		//status
		$all_inventory_status = inventories_get_inventory_status ();
		array_unshift($all_inventory_status, __("All"));
		if(!isset($params['inventory_status'])){
			$params['inventory_status'] = 'All';
		}
		$table_search->data[2][0] = print_select ($all_inventory_status, 'inventory_status', $params['inventory_status'], '', '', '', true, false, false, __('Status'));

		//Parent name
		if(!isset($params['parent_name'])){
			$params['parent_name'] = '';
		}
		$table_search->data[2][1] =  print_input_text_extended ("parent_name", $params['parent_name'], "text-parent_name", '', 20, 0, false, "", "class='inventory_obj_search' style='width:165px !important;'", true, false,  __('Parent object'), false, true);
		$table_search->data[2][1] .= "  " . print_image("images/add.png", true, array("onclick" => "show_inventory_search('','','','','','','','','','', '', '')", "style" => "cursor: pointer"));	
示例#2
0
if (!$create_incident) {
    $params_closed['input_id'] = 'text-closed_by';
    $params_closed['input_name'] = 'closed_by';
    $params_closed['input_value'] = $closed_by;
    $params_closed['title'] = __('Closed by');
    $params_closed['help_message'] = __("User assigned here is user that will be responsible to close the ticket.");
    $params_closed['return'] = true;
    $params_closed['return_help'] = true;
    $params_closed['disabled'] = $blocked_incident;
    //Only print closed by option when incident status is closed
    if ($incident["estado"] == STATUS_CLOSED) {
        $table->data[2][2] = "<div id='closed_by_wrapper'>";
    } else {
        $table->data[2][2] = "<div id='closed_by_wrapper' style='display: none'>";
    }
    $table->data[2][2] .= user_print_autocomplete_input($params_closed);
    $table->data[2][2] .= "</div>";
} else {
    if ($create_incident && $config["change_incident_datetime"]) {
        $date = date('Y-m-d');
        $time = date('H:i');
        $table->data[2][2] = print_input_text('creation_date', $date, '', 10, 100, true, __('Creation date'), $blocked_incident);
        $table->data[2][2] .= print_input_text('creation_time', $time, '', 10, 100, true, __('Creation time'), $blocked_incident) . print_help_tip(__("The format should be hh:mm"), true);
    }
}
$table->colspan[4][0] = 3;
//$table->data[4][0] = "<tr id='row_show_type_fields' colspan='4'></tr>";
$table->data[4][0] = "";
//////TABLA ADVANCED
$table_advanced->width = '98%';
$table_advanced->class = 'search-table';
示例#3
0
echo "<form id='form-report_annual' name='xx' method=post action='index.php?sec=users&sec2=operation/user_report/report_annual'>";
echo "<table cellpadding=4 cellspacing=4 style='margin: 0px auto;'>";
echo "<tr><td>";

if (give_acl($config["id_user"], 0, "PM") && $pdf_output == 0){		

	echo "<input type='hidden' name='year' value='$year'>";
	
	echo "<td>";
	// Show user
	$params['input_id'] = 'text-id_user';
	$params['input_name'] = 'id_user';
	$params['return'] = false;
	$params['return_help'] = false;
	$params['input_value'] = $id_user_show;
	user_print_autocomplete_input($params);
	
	echo "</td>";	
			
	echo "<td>";
	print_submit_button (__('Go'), 'sub_btn', false, 'class="upd sub"');
	echo "</td>";
}
echo "</table></form>";

echo "</td></tr>";
echo "<tr>";

$calendars = array();
for ($ax = 1; $ax < 13; $ax++){
	$calendars[] = generate_small_work_calendar ($year, $ax, $days_f, 3, $config["first_day_week"], "en", $id_user_show);
 $ticket_editor .= "<tr>";
 $ticket_editor .= "<td>";
 $ticket_editor .= print_select(get_priorities(true), 'priority_editor', $priority, "", '', '', true, false, false, __('Priority'), false, '');
 $ticket_editor .= "</td>";
 $ticket_editor .= "<td>";
 //If IW creator enabled flag is enabled, the user can change the creator
 if ($has_im || $has_iw && $config['iw_creator_enabled']) {
     $src_code = print_image('images/group.png', true, false, true);
     $params_assigned['input_id'] = 'text-owner_editor';
     $params_assigned['input_name'] = 'owner_editor';
     $params_assigned['input_value'] = $owner;
     $params_assigned['title'] = __('Owner');
     $params_assigned['help_message'] = __("User assigned here is user that will be responsible to manage tickets. If you are opening a ticket and want to be resolved by someone different than yourself, please assign to other user");
     $params_assigned['return'] = true;
     $params_assigned['return_help'] = true;
     $ticket_editor .= user_print_autocomplete_input($params_assigned);
 } else {
     $ticket_editor .= print_label(__('Owner'), 'id_user', '', true, '<div id="plain-id_user">' . dame_nombre_real($owner) . '</div>');
 }
 $ticket_editor .= "</td>";
 $ticket_editor .= "</tr>";
 $ticket_editor .= "<tr>";
 $ticket_editor .= "<td>";
 if ($has_im) {
     $ticket_editor .= combo_incident_resolution($resolution, false, true, false, "");
 } else {
     $ticket_editor .= print_label(__('Resolution'), '', '', true, render_resolution($resolution));
 }
 $ticket_editor .= "</td>";
 $ticket_editor .= "<td>";
 $ticket_editor .= combo_incident_status($status, false, 0, true, false, "");
示例#5
0
function form_search_incident($return = false, $filter = false)
{
    include_once "functions_user.php";
    global $config;
    $output = '';
    if (!$filter) {
        $search_string = (string) get_parameter('search_string');
        $status = (int) get_parameter('search_status', -10);
        $priority = (int) get_parameter('search_priority', -1);
        $resolution = (int) get_parameter('search_resolution', -1);
        $id_group = (int) get_parameter('search_id_group');
        $id_inventory = (int) get_parameter('search_id_inventory');
        $id_company = (int) get_parameter('search_id_company');
        $search_id_user = (string) get_parameter('search_id_user');
        $search_id_incident_type = (int) get_parameter('search_id_incident_type');
        $date_from = (int) get_parameter("search_from_date");
        $date_start = (string) get_parameter("search_first_date");
        $date_end = (string) get_parameter("search_last_date");
        $search_creator = (string) get_parameter('search_id_creator');
        $search_editor = (string) get_parameter('search_editor');
        $search_closed_by = (string) get_parameter('search_id_creator');
        $group_by_project = (bool) get_parameter('search_group_by_project');
        $sla_state = (int) get_parameter('search_sla_state', 0);
        $id_task = (int) get_parameter('search_id_task', 0);
        $left_sla = (int) get_parameter('search_left_sla', 0);
        $right_sla = (int) get_parameter('search_right_sla', 0);
        $show_hierarchy = (bool) get_parameter('show_hierarchy');
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        foreach ($type_fields as $key => $type_field) {
            $search_type_field[$type_field['id']] = (string) get_parameter('search_type_field_' . $type_field['id']);
        }
    } else {
        $search_string = (string) $filter['string'];
        $priority = (int) $filter['priority'];
        $id_group = (int) $filter['id_group'];
        $status = (int) $filter['status'];
        $resolution = (int) $filter['resolution'];
        $id_company = (int) $filter['id_company'];
        $id_inventory = (int) $filter['id_inventory'];
        $search_id_incident_type = (int) $filter['id_incident_type'];
        $search_id_user = (string) $filter['id_user'];
        $date_from = (int) $filter['from_date'];
        $date_start = (string) $filter['first_date'];
        $date_end = (string) $filter['last_date'];
        $search_creator = (string) $filter['id_creator'];
        $search_editor = (string) $filter['editor'];
        $search_closed_by = (string) $filter['closed_by'];
        $group_by_project = (bool) $filter['group_by_project'];
        $sla_state = (int) $filter['sla_state'];
        $id_task = (int) $filter['id_task'];
        $left_sla = (int) $filter['left_sla'];
        $right_sla = (int) $filter['right_sla'];
        $show_hierarchy = (bool) $filter['show_hierarchy'];
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        if ($type_fields) {
            foreach ($type_fields as $key => $type_field) {
                $search_type_field[$type_field['id']] = (string) $filter['type_field_' . $type_field['id']];
            }
        }
    }
    /* No action is set, so the form will be sent to the current page */
    $table = new stdclass();
    $table->width = "99%";
    $table->class = "search-table-button";
    $table->cellspacing = 2;
    $table->cellpadding = 2;
    $table->data = array();
    $table->size = array();
    $table->style = array();
    $table->style[0] = 'width: 25%';
    $table->style[1] = 'width: 25%';
    $table->style[2] = 'width: 25%; vertical-align:text-top;';
    $table->style[3] = 'width: 25%';
    $table->rowstyle = array();
    $table->rowstyle[1] = 'display: none';
    $table->rowstyle[2] = 'display: none';
    $table->rowstyle[3] = 'display: none';
    $table->rowstyle[4] = 'display: none';
    $table->rowstyle[5] = 'display: none';
    $table->rowstyle[6] = 'text-align: right';
    $table->colspan = array();
    $table->colspan[0][0] = 2;
    $table->colspan[6][0] = 4;
    $table->colspan[7][1] = 3;
    $table->rowspan = array();
    $table->rowspan[2][2] = 2;
    $table->data[0][0] = print_input_text('search_string', $search_string, '', 50, 100, true, __('Search string'));
    $available_status = get_indicent_status();
    $available_status[-10] = __("Not closed");
    $table->data[0][1] = print_select($available_status, 'search_status', $status, '', __('Any'), 0, true, false, true, __('Status'));
    $groups = users_get_groups_for_select($config['id_user'], "IW", true, true);
    $table->data[0][2] = print_select($groups, 'search_id_group', $id_group, '', '', '', true, false, false, __('Group'));
    $table->data[0][3] = print_checkbox_extended('search_show_hierarchy', 1, $show_hierarchy, false, '', '', true, __('Show hierarchy'));
    $params_owner = array();
    $params_owner['input_id'] = 'text-search_id_user';
    $params_owner['input_name'] = 'search_id_user';
    $params_owner['input_value'] = $search_id_user;
    $params_owner['title'] = __('Owner');
    $params_owner['return'] = true;
    $table->data[1][0] = user_print_autocomplete_input($params_owner);
    $params_editor = array();
    $params_editor['input_id'] = 'text-search_editor';
    $params_editor['input_name'] = 'search_editor';
    $params_editor['input_value'] = $search_editor;
    $params_editor['title'] = __('Editor');
    $params_editor['return'] = true;
    $table->data[1][1] = user_print_autocomplete_input($params_editor);
    $params_closed_by = array();
    $params_closed_by['input_id'] = 'text-search_closed_by';
    $params_closed_by['input_name'] = 'search_closed_by';
    $params_closed_by['input_value'] = $search_closed_by;
    $params_closed_by['title'] = __('Closed by');
    $params_closed_by['return'] = true;
    $table->data[1][2] = user_print_autocomplete_input($params_closed_by);
    $params_creator = array();
    $params_creator['input_id'] = 'text-search_id_creator';
    $params_creator['input_name'] = 'search_id_creator';
    $params_creator['input_value'] = $search_creator;
    $params_creator['title'] = __('Creator');
    $params_creator['return'] = true;
    $table->data[1][3] = user_print_autocomplete_input($params_creator);
    $table->data[2][0] = print_select(get_priorities(), 'search_priority', $priority, '', __('Any'), -1, true, false, false, __('Priority'), false);
    $table->data[2][1] = print_select(get_incident_resolutions(), 'search_resolution', $resolution, '', __('Any'), -1, true, false, false, __('Resolution'), false);
    $table->data[2][2] = get_last_date_control($date_from, 'search_from_date', __('Date'), $date_start, 'search_first_date', __('Created from'), $date_end, 'search_last_date', __('Created to'));
    $name = $id_inventory ? get_inventory_name($id_inventory) : '';
    $table->data[2][3] = print_input_text('inventory_name', $name, '', 7, 0, true, __('Inventory'), false);
    $table->data[2][3] .= "&nbsp;&nbsp;<a href='javascript: show_search_inventory(\"\",\"\",\"\",\"\",\"\",\"\");'>" . print_image('images/zoom.png', true, array('title' => __('Search inventory'))) . "</a>";
    $table->data[2][3] .= print_input_hidden('id_inventory', $id_inventory, true);
    if (!get_external_user($config["id_user"])) {
        $table->data[4][0] = print_select(get_companies(), 'search_id_company', $id_company, '', __('All'), 0, true, false, false, __('Company'));
    }
    $table->data[4][1] = print_select(get_incident_types(), 'search_id_incident_type', $search_id_incident_type, 'javascript:change_type_fields_table();', __('All'), 0, true, false, false, __('Ticket type'));
    $table->data[4][3] = print_checkbox_extended('search_group_by_project', 1, $group_by_project, false, '', '', true, __('Group by project/task'));
    $sla_states = array();
    $sla_states[1] = __('SLA is fired');
    $sla_states[2] = __('SLA is not fired');
    $table->data[5][0] = print_select($sla_states, 'search_sla_state', $sla_state, '', __('All'), 0, true, false, false, __('SLA'));
    $table->data[5][1] = combo_task_user_participant($config["id_user"], 0, $id_task, true, __("Task"), 'search_id_task');
    $table->data[5][2] = print_input_text('search_left_sla', $left_sla, '', 7, 0, true, __('SLA > (%)'), false);
    $table->data[5][3] = print_input_text('search_right_sla', $right_sla, '', 7, 0, true, __('SLA < (%)'), false);
    $table_type_fields = new stdclass();
    $table_type_fields->width = "100%";
    $table_type_fields->class = "search-table";
    $table_type_fields->data = array();
    //Print custom field data
    $column = 0;
    $row = 0;
    if ($type_fields) {
        foreach ($type_fields as $key => $type_field) {
            $data = $search_type_field[$type_field['id']];
            if ($type_field['type'] == "text" || $type_field['type'] == "textarea") {
                $input = print_input_text('search_type_field_' . $type_field['id'], $data, '', 30, 30, true, $type_field['label']);
            } else {
                if ($type_field['type'] == "combo") {
                    $combo_values = explode(",", $type_field['combo_value']);
                    $values = array();
                    foreach ($combo_values as $value) {
                        $values[$value] = $value;
                    }
                    $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, '', __('Any'), '', true, false, false, $type_field['label']);
                } else {
                    if ($type_field['type'] == "linked") {
                        $linked_values = explode(",", $type_field['linked_value']);
                        $values = array();
                        foreach ($linked_values as $value) {
                            $value_without_parent = preg_replace("/^.*\\|/", "", $value);
                            $values[$value_without_parent] = $value_without_parent;
                            $has_childs = get_db_all_rows_sql("SELECT * FROM tincident_type_field WHERE parent=" . $type_field['id']);
                            if ($has_childs) {
                                $i = 0;
                                foreach ($has_childs as $child) {
                                    if ($i == 0) {
                                        $childs = $child['id'];
                                    } else {
                                        $childs .= ',' . $child['id'];
                                    }
                                    $i++;
                                }
                                $childs = "'" . $childs . "'";
                                $script = 'javascript:change_linked_type_fields_table(' . $childs . ',' . $type_field['id'] . ');';
                            } else {
                                $script = '';
                            }
                        }
                        $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, $script, __('Any'), '', true, false, false, $type_field['label']);
                    }
                }
            }
            $table_type_fields->data[$row][$column] = $input;
            if ($column >= 3) {
                $column = 0;
                $row++;
            } else {
                $column++;
            }
        }
    }
    if ($table_type_fields->data) {
        $table_type_fields_html = print_table($table_type_fields, true);
    }
    $table->data[6][0] = "<div id='table_type_fields'>" . $table_type_fields_html . "</div>";
    $table->data[7][0] = '<div style="width: 100%; text-align: left; height: 20px;"><a class="show_advanced_search" id="show_advanced_search" href="javascript:show_ad_search();">' . __('Advanced search') . '></a></div>';
    //Store serialize filter
    serialize_in_temp($filter, $config["id_user"]);
    $table->data[7][2] = print_submit_button(__('Search'), 'search', false, 'class="sub search"', true);
    $table->data[7][2] .= print_button(__('Export to CSV'), '', false, 'window.open(\'' . 'include/export_csv.php?export_csv_tickets=1' . '\')', 'class="sub csv"', true);
    $table->colspan[7][2] = 4;
    $output .= '<form id="search_incident_form" method="post" action="index.php?sec=incidents&sec2=operation/incidents/incident_search">';
    $output .= print_table($table, true);
    $output .= '</form>';
    echo "<div class= 'dialog ui-dialog-content' id='search_inventory_window'></div>";
    if ($return) {
        return $output;
    }
    echo $output;
}
示例#6
0
function form_search_incident($return = false, $filter = false, $ajax = 0)
{
    include_once "functions_user.php";
    global $config;
    $output = '';
    if (!$filter) {
        $inverse_filter = (bool) get_parameter('search_inverse_filter');
        $search_string = (string) get_parameter('search_string');
        $status = (int) get_parameter('search_status', -10);
        $priority = (int) get_parameter('search_priority', -1);
        $resolution = (int) get_parameter('search_resolution', -1);
        $id_group = (int) get_parameter('search_id_group');
        $id_inventory = (int) get_parameter('search_id_inventory');
        $id_company = (int) get_parameter('search_id_company');
        $search_id_user = (string) get_parameter('search_id_user');
        $search_id_incident_type = (int) get_parameter('search_id_incident_type');
        $date_from = (int) get_parameter("search_from_date");
        $date_start = (string) get_parameter("search_first_date");
        $date_end = (string) get_parameter("search_last_date");
        $search_creator = (string) get_parameter('search_id_creator');
        $search_editor = (string) get_parameter('search_editor');
        $search_closed_by = (string) get_parameter('search_closed_by');
        $group_by_project = (bool) get_parameter('search_group_by_project');
        $sla_state = (int) get_parameter('search_sla_state', 0);
        $id_task = (int) get_parameter('search_id_task', 0);
        $left_sla = (int) get_parameter('search_left_sla', 0);
        $right_sla = (int) get_parameter('search_right_sla', 0);
        $show_hierarchy = (bool) get_parameter('search_show_hierarchy');
        $search_medal = get_parameter('search_medals');
        $name = get_parameter('parent_name');
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        foreach ($type_fields as $key => $type_field) {
            $search_type_field[$type_field['id']] = (string) get_parameter('search_type_field_' . $type_field['id']);
        }
    } else {
        $inverse_filter = (bool) $filter['inverse_filter'];
        $search_string = (string) $filter['string'];
        $priority = (int) $filter['priority'];
        $id_group = (int) $filter['id_group'];
        $status = (int) $filter['status'];
        $resolution = (int) $filter['resolution'];
        $id_company = (int) $filter['id_company'];
        $id_inventory = (int) $filter['id_inventory'];
        $search_id_incident_type = (int) $filter['id_incident_type'];
        $search_id_user = (string) $filter['id_user'];
        $date_from = (int) $filter['from_date'];
        $date_start = (string) $filter['first_date'];
        $date_end = (string) $filter['last_date'];
        $search_creator = (string) $filter['id_creator'];
        $search_editor = (string) $filter['editor'];
        $search_closed_by = (string) $filter['closed_by'];
        $group_by_project = (bool) $filter['group_by_project'];
        $sla_state = (int) $filter['sla_state'];
        $id_task = (int) $filter['id_task'];
        $left_sla = (int) $filter['left_sla'];
        $right_sla = (int) $filter['right_sla'];
        $show_hierarchy = (bool) $filter['show_hierarchy'];
        $search_medal = (int) $filter['medals'];
        $name = (string) $filter['parent_name'];
        //This is inventory obj name value !!!
        $type_fields = incidents_get_type_fields($search_id_incident_type);
        $search_type_field = array();
        if ($type_fields) {
            foreach ($type_fields as $key => $type_field) {
                $search_type_field[$type_field['id']] = (string) $filter['type_field_' . $type_field['id']];
            }
        }
    }
    /* No action is set, so the form will be sent to the current page */
    $table = new stdclass();
    $table->width = "100%";
    $table->class = "search-table-button";
    $table->data = array();
    // Filter text
    $table->data[0][0] = print_input_text('search_string', $search_string, '', 30, 100, true, __('Text filter'));
    // Status
    $available_status = get_indicent_status();
    $available_status[-10] = __("Not closed");
    $table->data[0][1] = print_select($available_status, 'search_status', $status, '', __('Any'), 0, true, false, true, __('Status'));
    // Groups
    $groups = users_get_groups_for_select($config['id_user'], "IW", true, true);
    $table->data[0][2] = print_select($groups, 'search_id_group', $id_group, '', '', '', true, false, false, __('Group'));
    // Check Box
    $table->data[0][3] = print_checkbox_extended('search_show_hierarchy', 1, $show_hierarchy, false, '', '', true, __('Show hierarchy'));
    $table_advanced = new stdclass();
    $table_advanced->width = "100%";
    $table_advanced->class = "search-table-button";
    $params_owner = array();
    $params_owner['input_id'] = 'text-search_id_user';
    $params_owner['input_name'] = 'search_id_user';
    $params_owner['input_value'] = $search_id_user;
    $params_owner['title'] = __('Owner');
    $params_owner['attributes'] = 'style="width: 210px;"';
    $params_owner['return'] = true;
    $table_advanced->data[1][0] = user_print_autocomplete_input($params_owner);
    $params_editor = array();
    $params_editor['input_id'] = 'text-search_editor';
    $params_editor['input_name'] = 'search_editor';
    $params_editor['input_value'] = $search_editor;
    $params_editor['title'] = __('Editor');
    $params_editor['attributes'] = 'style="width: 210px;"';
    $params_editor['return'] = true;
    $table_advanced->data[1][1] = user_print_autocomplete_input($params_editor);
    $params_closed_by = array();
    $params_closed_by['input_id'] = 'text-search_closed_by';
    $params_closed_by['input_name'] = 'search_closed_by';
    $params_closed_by['input_value'] = $search_closed_by;
    $params_closed_by['title'] = __('Closed by');
    $params_closed_by['attributes'] = 'style="width: 210px;"';
    $params_closed_by['return'] = true;
    $table_advanced->data[1][2] = user_print_autocomplete_input($params_closed_by);
    $params_creator = array();
    $params_creator['input_id'] = 'text-search_id_creator';
    $params_creator['input_name'] = 'search_id_creator';
    $params_creator['input_value'] = $search_creator;
    $params_creator['title'] = __('Creator');
    $params_creator['attributes'] = 'style="width: 210px;"';
    $params_creator['return'] = true;
    $table_advanced->data[1][3] = user_print_autocomplete_input($params_creator);
    $table_advanced->data[2][0] = print_select(get_priorities(), 'search_priority', $priority, '', __('Any'), -1, true, false, false, __('Priority'), false);
    $table_advanced->data[2][1] = print_select(get_incident_resolutions(), 'search_resolution', $resolution, '', __('Any'), -1, true, false, false, __('Resolution'), false);
    //$name = $id_inventory ? get_inventory_name ($id_inventory) : '';
    //Parent name
    $table_advanced->data[2][2] = print_input_text_extended("parent_name", $name, "text-parent_name", '', 20, 0, false, "", "class='inventory_obj_search' style='width:165px !important;'", true, false, __('Inventory object'), false, true);
    $table_advanced->data[2][2] .= "&nbsp;&nbsp;" . print_image("images/add.png", true, array("onclick" => "show_inventory_search('','','','','','','','','','', '', '')", "style" => "cursor: pointer"));
    $table_advanced->data[2][2] .= "&nbsp;&nbsp;" . print_image("images/cross.png", true, array("onclick" => "cleanParentInventory()", "style" => "cursor: pointer"));
    $table_advanced->data[2][2] .= print_input_hidden('id_parent', $id_inventory, true);
    $table_advanced->data[2][3] = get_last_date_control($date_from, 'search_from_date', __('Date'), $date_start, 'search_first_date', __('Created from'), $date_end, 'search_last_date', __('Created to'));
    $table_advanced->rowspan[2][3] = 2;
    $table_advanced->cellstyle[2][3] = "vertical-align:top;";
    if (!get_standalone_user($config["id_user"])) {
        $table_advanced->data[4][0] = print_select(get_companies(), 'search_id_company', $id_company, '', __('Any'), 0, true, false, false, __('Company'));
    }
    $table_advanced->data[4][1] = print_select(get_incident_types(), 'search_id_incident_type', $search_id_incident_type, 'javascript:change_type_fields_table(\'' . __('Custom field') . '\');', __('Any'), 0, true, false, false, __('Ticket type'));
    $table_advanced->data[4][3] = print_checkbox_extended('search_group_by_project', 1, $group_by_project, false, '', '', true, __('Group by project/task'));
    $sla_states = array();
    $sla_states[1] = __('SLA is fired');
    $sla_states[2] = __('SLA is not fired');
    $table_advanced->data[5][0] = print_select($sla_states, 'search_sla_state', $sla_state, '', __('Any'), 0, true, false, false, __('SLA'));
    $table_advanced->data[5][1] = combo_task_user_participant($config["id_user"], 0, $id_task, true, __("Task"), 'search_id_task');
    $table_advanced->data[5][2] = "<div>";
    $table_advanced->data[5][2] .= "<div style='display: inline-block;'>" . print_input_text('search_left_sla', $left_sla, '', 8, 0, true, __('SLA > (%)'), false) . "</div>";
    $table_advanced->data[5][2] .= "&nbsp;<div style='display: inline-block;'>" . print_input_text('search_right_sla', $right_sla, '', 8, 0, true, __('SLA < (%)'), false) . "</div>";
    $table_advanced->data[5][2] .= "</div>";
    $medals = array();
    $medals[1] = __('Gold medals');
    $medals[2] = __('Black medals');
    $table_advanced->data[5][3] = print_select($medals, 'search_medals', $search_medal, '', __('Any'), 0, true, false, false, __('Medals'));
    $table_type_fields = new StdClass();
    $table_type_fields->width = "100%";
    $table_type_fields->class = "search-table";
    $table_type_fields->data = array();
    $table_type_fields->align[0] = 'left';
    //Print custom field data
    $column = 0;
    $row = 0;
    if ($type_fields) {
        foreach ($type_fields as $key => $type_field) {
            $data = $search_type_field[$type_field['id']];
            switch ($type_field['type']) {
                case "text":
                    $input = print_input_text('search_type_field_' . $type_field['id'], $data, '', 30, 30, true, $type_field['label']);
                    break;
                case "combo":
                    $combo_values = explode(",", $type_field['combo_value']);
                    $values = array();
                    foreach ($combo_values as $value) {
                        $values[$value] = $value;
                    }
                    $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, '', __('Any'), '', true, false, false, $type_field['label']);
                    break;
                case "linked":
                    $linked_values = explode(",", $type_field['linked_value']);
                    $values = array();
                    foreach ($linked_values as $value) {
                        $value_without_parent = preg_replace("/^.*\\|/", "", $value);
                        $values[$value_without_parent] = $value_without_parent;
                        $has_childs = get_db_all_rows_sql("SELECT * FROM tincident_type_field WHERE parent=" . $type_field['id']);
                        if ($has_childs) {
                            $i = 0;
                            foreach ($has_childs as $child) {
                                if ($i == 0) {
                                    $childs = $child['id'];
                                } else {
                                    $childs .= ',' . $child['id'];
                                }
                                $i++;
                            }
                            $childs = "'" . $childs . "'";
                            $script = 'javascript:change_linked_type_fields_table(' . $childs . ',' . $type_field['id'] . ');';
                        } else {
                            $script = '';
                        }
                    }
                    $input = print_select($values, 'search_type_field_' . $type_field['id'], $data, $script, __('Any'), '', true, false, false, $type_field['label']);
                    break;
                case "numeric":
                    $input = print_input_number('search_type_field_' . $type_field['id'], $data, 1, 1000000, '', true, $type_field['label']);
                    break;
                case "date":
                    $input = print_input_date('search_type_field_' . $type_field['id'], $data, '', '', '', true, $type_field['label']);
                    break;
                case "textarea":
                    $input = print_input_text('search_type_field_' . $type_field['id'], $data, '', 30, 30, true, $type_field['label']);
                    break;
            }
            $table_type_fields->data[$row][$column] = $input;
            if ($column >= 3) {
                $column = 0;
                $row++;
            } else {
                $column++;
            }
        }
    }
    $table_advanced->colspan[6][0] = 4;
    if ($table_type_fields->data) {
        $table_type_fields_html = print_table($table_type_fields, true);
    }
    if (!isset($table_type_fields_html)) {
        $table_type_fields_html = '';
    }
    $table_advanced->data[6][0] = "<div id='table_type_fields'>" . $table_type_fields_html . "</div>";
    $table->colspan['row_advanced'][0] = 5;
    $table->data['row_advanced'][0] = print_container_div('advanced_parameters_incidents_search', __('Advanced filter'), print_table($table_advanced, true), 'closed', true, true);
    //Store serialize filter
    serialize_in_temp($filter, $config["id_user"]);
    $table->colspan['button'][0] = 2;
    $table->colspan['button'][2] = 2;
    $table->data['button'][0] = '</br>';
    $table->data['button'][2] = print_submit_button(__('Filter'), 'search', false, 'class="sub search"', true);
    $table->data['button'][2] .= print_input_hidden('search_inverse_filter', (int) $inverse_filter, true);
    $table->data['button'][2] .= print_submit_button(__('Inverse filter'), 'submit_inverse_filter', false, 'class="sub search"', true);
    $table->data['button'][2] .= print_button(__('Export to CSV'), '', false, 'window.open(\'' . 'include/export_csv.php?export_csv_tickets=1' . '\')', 'class="sub"', true);
    // Inverse filter info
    $output .= '<div id="inverse_filter_info" style="display: ' . ($inverse_filter ? 'block' : 'none') . ';">';
    $output .= ui_print_message(__('Inverse filter enabled'), 'suc', 'style="display:inline;padding-top: 15px;padding-bottom: 15px;"', true, 'h3', false);
    $output .= print_help_tip(__('The result will be the items which doesn\'t match the filters') . '. ' . __('The select controls with \'Any\' or \'All\' selected will be ignored'), true);
    $output .= '<br /><br />';
    $output .= '</div>';
    if ($ajax) {
        $output .= '<form id="search_incident_form" method="post">';
    } else {
        $output .= '<form id="search_incident_form" method="post" onsubmit="incidents_gift();return false">';
    }
    //~ $output .= '<form id="search_incident_form" method="post">';
    $output .= '<div class="divresult_incidents">' . print_table($table, true) . '</div>';
    $output .= '</form>';
    echo "<div class= 'dialog ui-dialog-content' id='search_inventory_window'></div>";
    // WARNING: Important for the inverse filter feature
    // Change the search_inverse_filter value when the form is submitted using the submit_inverse_filter or the search buttons
    // Show or hide the inverse filter info
    $output .= '<script type="text/javascript">';
    $output .= '$(document).ready(function () {';
    $output .= 'var inverseFilterInfo = document.getElementById("inverse_filter_info");';
    $output .= 'var filterForm = document.getElementById("search_incident_form");';
    $output .= 'var filterBtn = filterForm.elements["search"];';
    $output .= 'var inverseFilterBtn = filterForm.elements["submit_inverse_filter"];';
    $output .= 'var inverseFilter = filterForm.elements["search_inverse_filter"];';
    $output .= '$(filterBtn).click(function (e) {';
    $output .= 'inverseFilter.value = 0;';
    $output .= '$(inverseFilterInfo).hide();';
    $output .= '});';
    $output .= '$(inverseFilterBtn).click(function (e) {';
    $output .= 'inverseFilter.value = 1;';
    $output .= '$(inverseFilterInfo).show();';
    $output .= '});';
    $output .= '});';
    $output .= '</script>';
    if ($return) {
        return $output;
    }
    echo $output;
}
$table->data[2][0] = print_input_text ('duration', $duration, '', 7, 7,
	true, __('Time used'));

if (dame_admin ($config['id_user'])) {
	$table->colspan[2][1] = 3;
	
	$params = array();
	$params['input_id'] = 'text-id_username';
	$params['input_name'] = 'id_username';
	$params['input_value'] = $wu_user;
	$params['title'] = 'Username';
	$params['return'] = true;
	$params['return_help'] = true;
	$params['attributes'] = "style='width:210px;'";
	
	$table->data[2][1] = user_print_autocomplete_input($params);
}

// Various checkboxes
$table->data[3][0] = print_checkbox ('have_cost', 1, $have_cost, true,
	__('Have cost'));
$table->data[3][1] = print_checkbox ('public', 1, $public, true, __('Public'));

if (! $id_workunit) {
	$table->data[4][0] = print_checkbox ('forward', 1, 
		false, true, __('Forward') . print_help_tip (__('If this checkbox is activated, propagation will be forward'), true));
	
	$table->data[4][1] = print_checkbox ('split', 1, false, true, 
		__('Backward')  . print_help_tip (__('If this checkbox is activated, propagation will be backward'),
		true));
}
示例#8
0
function lionwiki_show($conf = null, $execute_actions_param = true) {
	global $plugins;
	global $TITLE;
	global $page;
	global $PG_DIR;
	global $DATE_FORMAT;
	global $HIST_DIR;
	global $plugin_ret_diff;
	global $PASSWORD;
	global $sc;
	global $PROTECTED_READ;
	global $content;
	global $error;
	global $action;
	global $html;
	global $preview;
	global $HEAD;
	global $PLUGINS_DIR;
	global $VAR_DIR;
	global $self;
	global $self_form;
	global $CON;
	global $execute_actions;
	global $rightnow;
	global $config;

	$execute_actions = $execute_actions_param;
	
	$is_enterprise = false;
	if (file_exists ("enterprise/include/functions_wiki.php")) {
		require_once ("enterprise/include/functions_wiki.php");
		$is_enterprise = true;
	}
	
	//Default confs
	$wiki_title_conf = 'My new wiki';
	$password_conf = '';
	$template_conf = 'templates/dandelion.html';
	$protected_read_conf = false;
	$no_html_conf = false;
	$start_page_conf = 'Main page';
	$syntax_page_conf = 'http://lionwiki.0o.cz/?page=Syntax+reference';
	$date_format_conf = 'Y/m/d H:i';
	$local_hour_conf = 0;
	$var_dir_conf = 'var/';
	$plugin_dir_conf = 'plugins/';
	$lang_dir_conf = 'lang/';
	$self = basename($_SERVER['PHP_SELF']) . '?';
	$fallback_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
	<title>{PAGE_TITLE_HEAD  - }{WIKI_TITLE}</title>
	<style type="text/css">
*{margin:0;padding:0}
body{font-size:12px;line-height:16px;padding:10px 20px 20px 20px}
p{margin:5px}
a{color:#060;text-decoration:none;border-bottom:1px dotted #060}
a.pending{color:#900}
a.external:after{content:"\2197"}
pre{border:1px dotted #ccc;padding:4px;overflow:auto;margin:3px}
img,a img{border:0}
h1,h2,h3,h4,h5,h6{letter-spacing:2px;font-weight:normal;margin:15px 0 15px 0;color:#060}
h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{color:#060}
h1 a{border-bottom:0}
h2 .par-edit,h3 .par-edit,h4 .par-edit,h5 .par-edit,h6 .par-edit{visibility:hidden;font-size:x-small}
h2:hover .par-edit,h3:hover .par-edit,h4:hover .par-edit,h5:hover .par-edit,h6:hover .par-edit{visibility:visible}
hr{margin:10px 0 10px 0;height:1px;overflow:hidden;border:0;background:#060}
ul,ol{padding:5px 0px 5px 20px}
table{text-align:left}
input,select,textarea{border:1px solid #AAA;padding:2px;font-size:12px}
#toc{border:1px dashed #060;margin:5px 0 5px 10px;padding:6px 5px 7px 0;float:right;padding-right:2em;list-style:none}
#toc ul{list-style:none;padding:3px 0 3px 10px}
#toc li{font-size:11px;padding-left:10px}
#diff {padding:1em; white-space: pre-wrap; width: 97%;}
#diff ins{color:green;font-weight:bold}
#diff del{color:red;text-decoration:line-through}
#diff .orig{color:#666;font-size:90%}
/* Plugins */
.tagList{padding:0.2em 0.4em 0.2em 0.4em;margin-top:0.5em;border:1px dashed #060;clear:right}
.tagCloud{float:right;width:200px;padding:0.5em;margin:1em;border:1px dashed #060;clear:right}
.pageVersionsList{letter-spacing:0;font-variant:normal;font-size:12px}
.resizeTextarea a{border-bottom:none}

	</style>
	{HEAD}
</head>
<body>
<table width="100%" cellpadding="4">
<tr>
	<td colspan="2">{HOME} {RECENT_CHANGES}</td>
	<td style="text-align:right">{EDIT} {SYNTAX} {HISTORY}</td>
</tr>
<tr><th colspan="3"><hr/><h1 id="page-title">{PAGE_TITLE} {<span class="pageVersionsList">( plugin:VERSIONS_LIST )</span>}</h1></th></tr>
<tr>
	<td colspan="3">
		{<div style="color:#F25A5A;font-weight:bold;"> ERROR </div>}
		{CONTENT} {plugin:TAG_LIST}
		{CONTENT_FORM} {RENAME_TEXT} {RENAME_INPUT <br/><br/>} {CONTENT_TEXTAREA}
		<p style="float:right;margin:6px">{FORM_PASSWORD} {FORM_PASSWORD_INPUT} {plugin:CAPTCHA_QUESTION} {plugin:CAPTCHA_INPUT}
		{EDIT_SUMMARY_TEXT} {EDIT_SUMMARY_INPUT} {CONTENT_SUBMIT} {CONTENT_PREVIEW}</p>{/CONTENT_FORM}
	</td>
</tr>
<tr><td colspan="3"><hr/></td></tr>
<tr>
	<td><div>{SEARCH_FORM}{SEARCH_INPUT}{SEARCH_SUBMIT}{/SEARCH_FORM}</div></td>
	<td>{LAST_CHANGED_TEXT}: {LAST_CHANGED} {COOKIE}</td>
	<td style="text-align:right">{EDIT} {SYNTAX} {HISTORY}</td>
</tr>
</table>
</body>
</html>';
	
	if ($conf != null) {
		if (isset($conf['wiki_title'])) $wiki_title_conf = $conf['wiki_title'];
		if (isset($conf['password'])) $password_conf = $conf['password'];
		if (isset($conf['template'])) $template_conf = $conf['template'];
		if (isset($conf['protected_read'])) $protected_read_conf = $conf['protected_read'];
		if (isset($conf['no_html'])) $no_html_conf = $conf['no_html'];
		if (isset($conf['start_page'])) $start_page_conf = $conf['start_page'];
		if (isset($conf['syntax_page'])) $syntax_page_conf = $conf['syntax_page'];
		if (isset($conf['date_format'])) $date_format_conf = $conf['date_format'];
		if (isset($conf['local_hour'])) $local_hour_conf = $conf['local_hour'];
		if (isset($conf['var_dir'])) $var_dir_conf = $conf['var_dir'];
		if (isset($conf['plugin_dir'])) $plugin_dir_conf = $conf['plugin_dir'];
		if (isset($conf['lang_dir'])) $lang_dir_conf = $conf['lang_dir'];
		if (isset($conf['self'])) $self = $conf['self'];
		if (isset($conf['fallback_template'])) $fallback_template = $conf['fallback_template'];
	}
	else {
		loadConfig();
	}
	
	//Delete the last character, it is ? or & normality.
	$self_form = substr_replace($self, '', -1);
	
	/*
	 * Disabled for avoid lost the var $action or $page for example
	foreach ($_REQUEST as $k => $v)
		unset($$k); // register_globals = off
	*/ 
	
	// SETTINGS - default settings, can be overridden in config.php
	$WIKI_TITLE = $wiki_title_conf; // name of the site
	$PASSWORD = $password_conf; // SHA1 hash
	
	$TEMPLATE = $template_conf; // presentation template
	$PROTECTED_READ = $protected_read_conf; // if true, you need to fill password for reading pages too
	$NO_HTML = 0; //$no_html_conf; // XSS protection
	
	$START_PAGE = $start_page_conf; // Which page should be default (start page)?
	$SYNTAX_PAGE = $syntax_page_conf;
	
	$DATE_FORMAT = $date_format_conf;
	$LOCAL_HOUR = $local_hour_conf;
	
	@error_reporting(E_ERROR | E_WARNING | E_PARSE);
	@ini_set('default_charset', 'UTF-8');
	set_magic_quotes_runtime(0);
	umask(0);
	
	if (get_magic_quotes_gpc()) // magic_quotes_gpc can't be turned off
		for ($i = 0, $_SG = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST), $c = count($_SG); $i < $c; ++$i)
			$_SG[$i] = array_map('stripslashes', $_SG[$i]);
	
	$REAL_PATH = realpath(dirname(__FILE__)) . '/';
	$VAR_DIR = $var_dir_conf;
	$PG_DIR = $VAR_DIR . 'pages/';
	$HIST_DIR = $VAR_DIR . 'history/';
	$PLUGINS_DIR = $plugin_dir_conf;
	$PLUGINS_DATA_DIR = $VAR_DIR.'plugins/';
	$LANG_DIR = $lang_dir_conf;
	
	
	// default translation
	$T_HOME = 'Main page';
	$T_SYNTAX = 'Syntax';
	$T_DONE = 'Save changes';
	$T_DISCARD_CHANGES = 'Discard changes';
	$T_PREVIEW = 'Preview';
	$T_SEARCH = 'Search';
	$T_SEARCH_RESULTS = 'Wiki search results';
	$T_LIST_OF_ALL_PAGES = 'List of all pages';
	$T_RECENT_CHANGES = 'Recent changes';
	$T_LAST_CHANGED = 'Last changed';
	$T_HISTORY = 'History';
	$T_RESTORE = 'Restore';
	$T_REV_DIFF = '<b>Difference between revisions from {REVISION1} and {REVISION2}.</b>';
	$T_REVISION = "'''This revision is from {TIME}. You can {RESTORE} it.'''\n\n";
	$T_PASSWORD = '******';
	$T_EDIT = 'Edit';
	$T_EDIT_SUMMARY = 'Summary of changes';
	$T_EDIT_CONFLICT = 'Edit conflict: somebody saved this page after you started editing. See last {DIFF} before saving your changes.';
	$T_SHOW_SOURCE = 'Show source';
	$T_SHOW_PAGE = 'Show page';
	$T_ERASE_COOKIE = 'Erase cookies';
	$T_MOVE_TEXT = 'New name';
	$T_DIFF = 'diff';
	$T_CREATE_PAGE = 'Create page';
	$T_PROTECTED_READ = 'You need to enter password to view content of site: ';
	$T_WRONG_PASSWORD = '******';
	
	if ($_GET['lang']) {
		$LANG = clear_path($_GET['lang']);
		setcookie('LW_LANG', $LANG, time() + 365 * 86400);
	}
	elseif ($_COOKIE['LW_LANG'])
		$LANG = clear_path($_COOKIE['LW_LANG']);
	else
		list($LANG) = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
	
	if ((@include("$LANG_DIR$LANG.php")) === false && (@include($LANG_DIR . substr($LANG, 0, 2) . '.php')) === false)
		$LANG = 'en';
	
	
	// Creating essential directories if they don't exist
	if (!file_exists($VAR_DIR) && !mkdir(rtrim($VAR_DIR, "/")))
		die("Can't create directory $VAR_DIR. Please create $VAR_DIR with 0777 rights.");
	else
		foreach (array($PG_DIR, $HIST_DIR, $PLUGINS_DATA_DIR) as $DIR)
			if (@mkdir(rtrim($DIR, '/'), 0777)) {
				$f = fopen($DIR . ".htaccess", "w"); fwrite($f, "deny from all"); fclose($f);
			}
	
	
	if ($_GET['erasecookie']) // remove cookie without reloading
		foreach ($_COOKIE as $k => $v)
			if (substr($k, 0, 3) == 'LW_') {
				setcookie($k);
				unset($_COOKIE[$k]);
			}
	
	//Load Plugins
	for ($plugins = array(), $dir = @opendir($PLUGINS_DIR); $dir && $f = readdir($dir);) // load plugins
		if (preg_match('/wkp_(.+)\.php$/', $f, $m) > 0) {
			require_once $PLUGINS_DIR . $f;
			$plugins[$m[1]] = new $m[1]();
			
			if (isset($$m[1]))
				foreach ($$m[1] as $name => $value)
					$plugins[$m[1]]->$name = $value;
		}
	
	plugin('pluginsLoaded');
	
	foreach (array('action', 'content', 'error', 'esum', 'f1', 'f2',
		'last_changed', 'moveto', 'page', 'par', 'preview', 'query', 'restore',
		'sc', 'showsource', 'time') as $req)
		$$req = $_REQUEST[$req]; // export request variables to global namespace
	
	if (empty($page)) {
		$page = $start_page_conf;
	}
	
	$TITLE = $page = clear_path($page);
	$moveto = clear_path($moveto);
	$f1 = clear_path($f1);
	$f2 = clear_path($f2);
	$CON = $content;
	
	plugin('actionBegin');
	
	if (!$action) {

		if (!$page) {

			error_show_lionwiki("Location:$self" . "page=" . u($START_PAGE));
		}
		elseif (file_exists("$PG_DIR$page.$LANG.txt")) { // language variant

			error_show_lionwiki("Location:$self" . "page=" . u("$page.$LANG"));
		} elseif (!file_exists("$PG_DIR$page.txt")) {

			$action = 'edit'; // create page if it doesn't exist
			
			if (check_no_new_page()) {
				if (!plugin('check_no_new_page')) {
					$action = 'view-html';
				}
				else {
					$action = 'view-html';
				}
			}
		}
	}
	
	//Disable the action
	if (!$execute_actions) {
		$action = '';
	}

	//Check the create new page
	if ($action == 'edit') {
		if (!file_exists("$PG_DIR$page.txt")) {
			if (check_no_new_page()) {
				if (!plugin('show_message_no_new_page')) {
					$action = 'view-html';
				}
				else {
					$action = 'view-html';
				}
			}
		}
	}
	
	if (check_no_read()) {
		if (!plugin('show_message_no_read')) {
			$CON = "<form action=\"$self_form" . "page=".u($page)."\" method=\"post\"><p>$T_PROTECTED_READ <input type=\"password\" name=\"sc\"/> <input class=\"submit\" type=\"submit\"/></p></form>";
			$action = 'view-html';
		}
		else {
			$action = 'view-html';
		}
	}
	else {
		if ($restore || $action == 'rev') { // Show old revision
			$CON = @file_get_contents("$HIST_DIR$page/$f1");
			
			if ($action == 'rev') {
				$rev_restore = "[$T_RESTORE|./$self" . "page=".u($page)."&amp;action=edit&amp;f1=$f1&amp;restore=1]";
				$CON = strtr($T_REVISION, array('{TIME}' => rev_time($f1), '{RESTORE}' => $rev_restore)) . $CON;
				$action = '';
			}
		}
		else if ($page) { // Load the page
			$last_changed_ts = @filemtime("$PG_DIR$page.txt");
			
			if (!$action || $action == 'edit') {
				$CON = @file_get_contents("$PG_DIR$page.txt");
				$CON = $par ? get_paragraph($CON, $par) : $CON;
				
				if (!$action && substr($CON, 0, 10) == '{redirect:' && $_REQUEST['redirect'] != 'no')
					error_show_lionwiki("Location:$self" . "page=".u(substr($CON, 10, strpos($CON, '}') - 10)));
			}
		}
	}
	
	if ($action == 'save' && check_no_save()) {
		if (!plugin('show_message_no_save')) {
			$action = 'view-html';
		}
		else {
			$action = 'view-html';
		}
	}
	else {
		$rightnow = date('Ymd-Hi-s', time() + $LOCAL_HOUR * 3600);
		
		if ($action == 'save' && !$preview && authentified()) { // do we have page to save?
			if (!trim($content) && !$par) // delete empty page
				@unlink("$PG_DIR$page.txt");
			elseif ($last_changed < @filemtime("$PG_DIR$page.txt")) {
				$action = 'edit';
				$error = str_replace('{DIFF}', "<a href=\"$self" . "page=".u($page)."&amp;action=diff\">$T_DIFF</a>", $T_EDIT_CONFLICT);
			}
			elseif (!plugin('writingPage')) { // are plugins OK with page? (e.g. checking for spam)
				if ($par) {
					$c = @file_get_contents("$PG_DIR$page.txt");
					$content = str_replace(get_paragraph($c, $par), $content, $c);
				}
				
				if (!$file = @fopen("$PG_DIR$page.txt", 'w'))
					die("Could not write page $PG_DIR$page.txt!");
				
				fwrite($file, $content); fclose($file);
				
				// Backup old revision
				@mkdir($HIST_DIR.$page, 0777); // Create directory if does not exist
				
				if (!$bak = @fopen("$HIST_DIR$page/$rightnow.bak", 'w'))
					die("Could not write to $HIST_DIR$page!");
				
				fwrite($bak, $content); fclose($bak);
				
				$es = fopen("$HIST_DIR$page/meta.dat", 'ab');
				
				fwrite($es, '!' . $rightnow .
					str_pad($_SERVER['REMOTE_ADDR'], 16, ' ', STR_PAD_LEFT) .
					str_pad(filesize("$PG_DIR$page.txt"), 11, ' ', STR_PAD_LEFT) . ' ' .
					str_pad(substr($esum, 0, 128), 128 + 2)) . "\n";
				
				fclose($es);
				
				if ($moveto != $page && $moveto)
					if (file_exists("$PG_DIR$moveto.txt"))
						die('Error: target filename already exists. Page was not moved.');
					elseif (!rename("$PG_DIR$page.txt", "$PG_DIR$moveto.txt"))
						die('Unknown error! Page was not moved.');
					elseif (!rename($HIST_DIR.$page, $HIST_DIR.$moveto)) {
						rename("$PG_DIR$moveto.txt", "$PG_DIR$page.txt"); // revert previous change
						die('Unknown error2! Page was not moved.');
					}
					else
						$page = $moveto;
				
				if (!plugin('pageWritten')) {
					error_show_lionwiki("Location:$self" . 
						"page=" . u($page) . '&redirect=no' . 
						($par ? "&par=$par" : '') . ($_REQUEST['ajax'] ? '&ajax=1' : ''));
				}
				else {
					$action = ''; // display content ...
				}
				
				$par = 1; //reset counter
				
				//Show all page not only the section.
				$CON = $content;
			}
			else {// there's some problem with page, give user a chance to fix it
				$action = 'edit';
			}
		}
		elseif ($action == 'save' && !$preview) { // wrong password, give user another chance
			$error = $T_WRONG_PASSWORD;
			$action = 'edit';
		}
	}
	
	if ($action == 'edit' || $preview) {

		$has_permission = true;
		if ($is_enterprise) {
			$has_permission = wiki_get_write_acl($config['id_user'], $page);

		}
		if ($has_permission) {
			$CON_FORM_BEGIN = "<form action=\"$self_form\" method=\"post\"><input type=\"hidden\" name=\"action\" value=\"save\"/><input type=\"hidden\" name=\"last_changed\" value=\"$last_changed_ts\"/><input type=\"hidden\" name=\"showsource\" value=\"$showsource\"/><input type=\"hidden\" name=\"par\" value=\"".h($par)."\"/><input type=\"hidden\" name=\"page\" value=\"".h($page)."\"/>";
			$CON_FORM_END = '</form>';
			$CON_TEXTAREA = '<textarea class="contentTextarea" name="content" rows="27">'.h($CON).'</textarea>';
			$CON_PREVIEW = '<input class="submit" type="submit" name="preview" value="'.$T_PREVIEW.'"/>';
			
			if (!$showsource) {
				$CON_SUBMIT = '<input class="submit" type="submit" value="'.$T_DONE.'"/>';
				$EDIT_SUMMARY_TEXT = $T_EDIT_SUMMARY;
				$EDIT_SUMMARY = '<input type="text" name="esum" value="'.h($esum).'"/>';
				
				if (!authentified()) { // if not logged on, require password
					$FORM_PASSWORD = $T_PASSWORD;
					$FORM_PASSWORD_INPUT = '<input type="password" name="sc"/>';
				}
				
				if (!$par) {
					$RENAME_TEXT = $T_MOVE_TEXT;
					$RENAME_INPUT = '<input type="text" name="moveto" value="'.h($page).'"/>';
				}
			}
			
			if ($preview)
				$TITLE = "$T_PREVIEW: $page";
		} else {
			include "general/noaccess.php";
			exit;
		}
	}
	elseif ($action == 'history') { // show whole history of page
		for ($files = array(), $dir = @opendir("$HIST_DIR$page/"); $f = @readdir($dir);)
			if (substr($f, -4) == '.bak')
				$files[] = $f;
		
		rsort($files);
		$CON = '<form action="'.$self_form.'" method="post"><input type="hidden" name="action" value="diff"/><input type="hidden" name="page" value="'.h($page).'"/><input type="submit" class="submit" value="'.$T_DIFF.'"/><br/>';
		$meta = @fopen("$HIST_DIR$page/meta.dat", "rb");
	
		for ($i = 0, $mi = 1, $c = count($files); $i < $c; $i++) {
			if (($m = meta_getline($meta, $mi)) && !strcmp(basename($files[$i], ".bak"), $m[0]))
				$mi++;
			
			global $return_loadMetadata;
			$return_loadMetadata = '';
			plugin('loadMetadata',$page, $m);
			
			//Replace IP for the return of loadMetaData
			if (!empty($return_loadMetadata)) {
				$m[1] = $return_loadMetadata;
			}
			
			$CON .= '<input type="radio" name="f1" value="'.h($files[$i]).'"/><input type="radio" name="f2" value="'.h($files[$i]).'"/>';
			$CON .= "<a href=\"$self" . "page=".u($page)."&amp;action=rev&amp;f1=".$files[$i]."\">".rev_time($files[$i])."</a> - ($m[2] B) $m[1] <i>".h($m[3])."</i><br/>";
		}
		
		$CON .= '</form>';
	}
	elseif ($action == 'diff') {
		if (!$f1 && $dir = @opendir("$HIST_DIR$page/")) { // diff is made on two last revisions
			while ($f = @readdir($dir))
				if (substr($f, -4) == '.bak')
					$files[] = $f;
			
			$i = count($files);
			rsort($files);
			$f1=$files[$i - 1];
			$f2=$files[$i - 2];
			error_show_lionwiki("Location:$self" . "action=diff&page=".u($page)."&f1=$files[0]&f2=$files[1]");
		}
		
		$r1 = "<a href=\"$self" . "page=".u($page)."&amp;action=rev&amp;f1=$f1\">".rev_time($f1)."</a>";
		$r2 = "<a href=\"$self" . "page=".u($page)."&amp;action=rev&amp;f1=$f2\">".rev_time($f2)."</a>";
		
		$CON = str_replace(array("{REVISION1}", "{REVISION2}"), array($r1, $r2), $T_REV_DIFF);
		$CON .= diff($f1, $f2);
	}
	elseif ($action == 'search') {
		for ($files = array(), $dir = opendir($PG_DIR); $f = readdir($dir);) {
			if (substr($f, -4) == '.txt' && ($c = @file_get_contents($PG_DIR . $f)) !== false) {
				if (!$query || stristr($f . $c, $query) !== false)
					$files[] = substr($f, 0, -4);
			}
		}
		
		sort($files);
		
		foreach ($files as $f)
			$list .= "<li><a href=\"$self" . "page=".u($f).'&amp;redirect=no">'.h($f)."</a></li>";
		
		$CON = "<ul>$list</ul>";
		
		if ($query && !file_exists("$PG_DIR$query.txt")) // offer to create the page
			$CON = "<p><i><a href=\"$self" . "action=edit&amp;page=".u($query)."\">$T_CREATE_PAGE ".h($query)."</a>.</i></p>".$CON;
		
		$TITLE = (!$query ? $T_LIST_OF_ALL_PAGES : "$T_SEARCH_RESULTS $query") . " (".count($files).")";
	}
	elseif ($action == 'recent') { // recent changes
		for ($files = array(), $dir = opendir($PG_DIR); $f = readdir($dir);)
			if (substr($f, -4) == '.txt')
				$files[substr($f, 0, -4)] = filemtime($PG_DIR . $f);
		
		arsort($files);
		
		foreach (array_slice($files, 0, 100) as $f => $ts) { // just first 100 files
			$dir_name = basename($f, '.txt');
			if ($meta = @fopen($HIST_DIR . $dir_name . '/meta.dat', 'r')) {
				$m = meta_getline($meta, 1);
				fclose($meta);
			}
			global $return_loadMetadata;
			$return_loadMetadata = '';
			plugin('loadMetadata',$dir_name, $m);
			
			//Replace IP for the return of loadMetaData
			if (!empty($return_loadMetadata)) {
				$m[1] = $return_loadMetadata;
			}
			
			$recent .= "<tr><td class=\"rc-diff\"><a href=\"$self" . "page=".u($f)."&amp;action=diff\">$T_DIFF</a></td><td class=\"rc-date\" nowrap>".date($DATE_FORMAT, $ts + $LOCAL_HOUR * 3600)."</td><td class=\"rc-ip\">$m[1]</td><td class=\"rc-page\"><a href=\"$self" . "page=".u($f)."&amp;redirect=no\">".h($f)."</a> <span class=\"rc-size\">($m[2] B)</span><i class=\"rc-esum\"> ".h($m[3])."</i></td></tr>";
		}
		
		$CON = "<table>$recent</table>";
		$TITLE = $T_RECENT_CHANGES;
	}
	
	elseif ($action == 'read_acl') { 

		$page_acl = get_parameter('page');

		$delete_acl_read = get_parameter('delete_acl_read', 0);
		$add_acl_read = get_parameter('add_acl_read', 0);
		
		$acl = '';
		
		if ($add_acl_read) {

			$new_user = get_parameter('new_user');
			
			$values = array();
			
			$exists = wiki_exists_page($page_acl);
		
			if ($exists) {

				$update = wiki_update_wiki($page_acl, $new_user, 'read');
				if ($update === false) {
					$acl .= "<h4>Error updating user</h4>";
				} else {
					$acl .= "<h4>User succesfully added</h4>";
				}
			} else {

				$insert = wiki_insert_wiki($page_acl, $new_user, 'read');
				if ($insert === false) {
					$acl .= "<h4>Error adding user</h4>";
				} else {
					$acl .= "<h4>User succesfully created</h4>";
				}
			}
		}
		
		if ($delete_acl_read) {
			
			$id_user = get_parameter('id_user');
	
			$result = wiki_delete_acl($id_user, $page_acl, 'read');
			
			if ($result === false) {
				$acl .= "<h4>Error deleting user</h4>";
			} else {
				$acl .= "<h4>User succesfully deleted</h4>";
			}
		}	
		
		$acl .= "<h3>$page_acl".print_help_tip (__("If a content has any users in its reading list, it will be accessible to all people. When we add an user to the access lists, only those users will have reading or writing permissions."), true)."</h3>";
		include_once('include/functions_db.php');
		include_once('include/functions_html.php');
		include_once('include/functions_user.php');
		
		$acls = wiki_get_acls ($page_acl);
		
		$table->id = 'acl_list';
		$table->class = 'listing';
		$table->width = '98%';
		$table->data = array ();
		$table->head = array ();
		
		$table->size[1] = '80px';
		
		$table->head[0] = __('Read');
		$table->head[1] = __('Operation');
			
		if ($acls === false) {
			$acl .= "<h4>No acls</h4>";
		} 
			
		$read = $acls['read_page'];
		
		if (!empty($read)) {
			$users_read = explode(',', $read);
			
			foreach ($users_read as $key=>$user) {
				$data = array();
				$data[0] = $user;
				$data[1] = '<a href="index.php?sec=wiki&
							sec2=operation/wiki/wiki&action=read_acl&
							delete_acl_read=1&page='.$page_acl.'&id_user='******'"
							onClick="if (!confirm(\''.__('Are you sure?').'\'))
							return false;">
							<img src="images/cross.png" /></a>';
				array_push ($table->data, $data);
			}
		}
		
		$data = array();
		
		$params_assigned['input_id'] = 'text-new_user';
		$params_assigned['input_name'] = 'new_user';
		$params_assigned['input_value'] = '';
		$params_assigned['title'] = 'New user';
		$params_assigned['return'] = true;

		$url = "index.php?sec=wiki&sec2=operation/wiki/wiki&action=read_acl&add_acl_read=1&page=$page_acl";

		$data[0] = "<form name=adduser method=post action='" . $url . "'>";
		$data[0] .= user_print_autocomplete_input($params_assigned);
		$data[1] = print_input_image("add_user", "images/add.png", 1, '', true);
		$data[1] .= "</form>";
						
		array_push ($table->data, $data);
		
		$acl .= print_table($table, true);
			

		$CON = "<table>$acl</table>";
		$TITLE = "READ ACL";
	}
	elseif ($action == 'write_acl') { 

		$page_acl = get_parameter('page');

		$delete_acl_write = get_parameter('delete_acl_write', 0);
		$add_acl_write = get_parameter('add_acl_write', 0);

		$new_user = get_parameter('new_user', '');
		
		$acl = '';
		
		if ($add_acl_write) {

			$new_user = get_parameter('new_user');
			
			$values = array();
			
			$exists = wiki_exists_page($page_acl);
		
			if ($exists) {

				$update = wiki_update_wiki($page_acl, $new_user, 'write');
				
				if ($update === false) {
					$acl .= "<h4>Error updating user</h4>";
				} else {
					$acl .= "<h4>User succesfully added</h4>";
				}
			} else {

				$insert = wiki_insert_wiki($page_acl, $new_user, 'write');
				
				if ($insert === false) {
					$acl .= "<h4>Error adding user</h4>";
				} else {
					$acl .= "<h4>User succesfully created</h4>";
				}
			}
		}
		
		if ($delete_acl_write) {
			
			$id_user = get_parameter('id_user');

			$result = wiki_delete_acl($id_user, $page_acl, 'write');
			
			if ($result === false) {
				$acl .= "<h4>Error deleting user</h4>";
			} else {
				$acl .= "<h4>User succesfully deleted</h4>";
			}
		}	
		
		$acl .= "<h3>$page_acl".print_help_tip (__("If a content has any users in its writing list, it will be accessible to all people. When we add an user to the access lists, only those users will have reading or writing permissions."), true)."</h3>";
		include_once('include/functions_db.php');
		include_once('include/functions_html.php');
		include_once('include/functions_user.php');
		
		$acls = wiki_get_acls ($page_acl);
		
		$table->id = 'acl_list';
		$table->class = 'listing';
		$table->width = '98%';
		$table->data = array ();
		$table->head = array ();
		
		$table->size[1] = '80px';
		
		$table->head[0] = __('Write');
		$table->head[1] = __('Operation');
			
		if ($acls === false) {
			$acl .= "<h4>No acls</h4>";
		} 
			
		$read = $acls['write_page'];
		
		if (!empty($read)) {
			$users_read = explode(',', $read);
			
			foreach ($users_read as $key=>$user) {
				$data = array();
				$data[0] = $user;
				$data[1] = '<a href="index.php?sec=wiki&
							sec2=operation/wiki/wiki&action=write_acl&
							delete_acl_write=1&page='.$page_acl.'&id_user='******'"
							onClick="if (!confirm(\''.__('Are you sure?').'\'))
							return false;">
							<img src="images/cross.png" /></a>';
				array_push ($table->data, $data);
			}
		}

		$data = array();
		$params_assigned['input_id'] = 'text-new_user';
		$params_assigned['input_name'] = 'new_user';
		$params_assigned['input_value'] = '';
		$params_assigned['title'] = 'New user';
		$params_assigned['return'] = true;

		$url = "index.php?sec=wiki&sec2=operation/wiki/wiki&action=write_acl&add_acl_write=1&page=$page_acl";

		$data[0] = "<form id='form-adduser' name=adduser method=post action='" . $url . "'>";
		$data[0] .= user_print_autocomplete_input($params_assigned);
		$data[1] = print_input_image("add_user", "images/add.png", 1, '', true);
		$data[1] .= "</form>";
						
		array_push ($table->data, $data);
		
		$acl .= print_table($table, true);
			

		$CON = "<table>$acl</table>";
		$TITLE = "WRITE ACL";
	}
	else {
		if (!plugin('check_no_action', $action)) { //Check to block or not a action
			plugin('action', $action);
		}
		else {
			if (!plugin('show_message_no_save')) {
				$action = 'view-html';
			}
			else {
				$action = 'view-html';
			}
		}
	}
	
	if (!$action || $action == 'save' || $preview) { // page parsing
		if (preg_match("/(?<!\^)\{title:([^}\n]*)\}/U", $CON, $m)) { // Change page title
			$TITLE = $m[1];
			$CON = str_replace($m[0], "", $CON);
		}
		
		// subpages
		while (preg_match('/(?<!\^){include:([^}]+)}/Um', $CON, $m))
			if (!strcmp($m[1], $page)) // limited recursion protection
				$CON = str_replace($m[0], "'''Warning: subpage recursion!'''", $CON);
			elseif (file_exists("$PG_DIR$m[1].txt"))
				$CON = str_replace($m[0], file_get_contents("$PG_DIR$m[1].txt"), $CON);
			else
				$CON = str_replace($m[0], "'''Warning: subpage $m[1] was not found!'''", $CON);
		
		plugin('subPagesLoaded');
		
		// save content not intended for substitutions ({html} tag)
		if (!$NO_HTML) { // XSS protection
			preg_match_all("/(?<!\^)\{html\}(.+)\{\/html\}/Ums", $CON, $htmlcodes, PREG_PATTERN_ORDER);
			$CON = preg_replace("/(?<!\^)\{html\}.+\{\/html\}/Ums", "{HTML}", $CON);
		}
		
		$CON = preg_replace("/(?<!\^)<!--.*-->/U", "", $CON); // internal comments
		$CON = preg_replace("/\^(.)/e", "'&#'.ord('$1').';'", $CON);
		$CON = str_replace(array("<", "&"), array("&lt;", "&amp;"), $CON);
		$CON = preg_replace("/&amp;([a-z]+;|\#[0-9]+;)/U", "&$1", $CON); // keep HTML entities
		$CON = preg_replace("/(\r\n|\r)/", "\n", $CON); // unifying newlines to Unix ones
		
		preg_match_all("/{{(.+)}}/Ums", $CON, $codes, PREG_PATTERN_ORDER);
		$CON = preg_replace("/{{(.+)}}/Ums", "<pre>{CODE}</pre>", $CON);
		
		// spans
		preg_match_all("/\{([\.#][^\s\"\}]*)(\s([^\}\"]*))?\}/m", $CON, $spans, PREG_SET_ORDER);
		
		foreach ($spans as $m) {
			$class = $id = '';
			$parts = preg_split('/([\.#])/', $m[1], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
			
			for ($i = 0, $c = count($parts); $c > 1 && $i < $c; $i += 2)
				if ($parts[$i] == '.')
					$class .= $parts[$i + 1] . ' ';
				else
					$id = $parts[$i + 1];
			
			$CON = str_replace($m[0], '<span'.($id ? " id=\"$id\"" : '').($class ? " class=\"$class\"" : '').($m[3] ? " style=\"$m[3]\"" : '').'>', $CON);
		}
		
		$CON = str_replace('{/}', '</span>', $CON);
		
		plugin('formatBegin');
		
		$CON = strtr($CON, array('&lt;-->' => '&harr;', '-->' => '&rarr;', '&lt;--' => '&larr;', "(c)" => '&copy;', "(r)" => '&reg;'));
		$CON = preg_replace("/\{small\}(.*)\{\/small\}/U", "<small>$1</small>", $CON); // small
		$CON = preg_replace("/\{su([bp])\}(.*)\{\/su([bp])\}/U", "<su$1>$2</su$3>", $CON); // sup and sub
		
		$CON = preg_replace("/^([^!\*#\n][^\n]+)$/Um", '<p>$1</p>', $CON); // paragraphs
		
		// images
		preg_match_all("#\[((https?://|\./)[^|\]]+\.(jpeg|jpg|gif|png))(\|[^\]]+)?\]#", $CON, $imgs, PREG_SET_ORDER);
		
		foreach ($imgs as $img) {
			$link = $i_attr = $a_attr = $center = $tag = "";
			
			preg_match_all("/\|([^\]\|=]+)(=([^\]\|\"]+))?(?=[\]\|])/", $img[0], $options, PREG_SET_ORDER);
			
			foreach ($options as $o)
				if ($o[1] == 'center') $center = true;
				elseif ($o[1] == 'right' || $o[1] == 'left') $i_attr .= " style=\"float:$o[1]\"";
				elseif ($o[1] == 'link') $link = (substr($o[3], 0, 4) == "http" || substr($o[3], 0, 2) == "./") ? $o[3] : $self . "page=" . u($o[3]);
				elseif ($o[1] == 'alt') $i_attr .= " alt=\"$o[3]\"";
				elseif ($o[1] == 'title') $a_attr .= " title=\"$o[3]\"";
			
			$tag = "<img src=\"$img[1]\"$i_attr/>";
			
			if ($link) $tag = "<a href=\"$link\"$a_attr>$tag</a>";
			if ($center) $tag = "<div style=\"text-align:center\">$tag</div>";
			
			$CON = str_replace($img[0], $tag, $CON);
		}
		
		$CON = preg_replace('#([0-9a-zA-Z\./~\-_]+@[0-9a-z/~\-_]+\.[0-9a-z\./~\-_]+)#i', '<a href="mailto:$0">$0</a>', $CON); // mail recognition
		
		// links
		$CON = preg_replace("#\[([^\]\|]+)\|(\./([^\]]+)|(https?://[^\]]+))\]#U", '<a href="$2" class="external">$1</a>', $CON);
		$CON = preg_replace("#(?<!\")https?://[0-9a-zA-Z\.\#/~\-_%=\?\&,\+\:@;!\(\)\*\$']*#i", '<a href="$0" class="external">$0</a>', $CON);
		
		preg_match_all("/\[(?:([^|\]]+)\|)?([^\]#]+)(?:#([^\]]+))?\]/", $CON, $matches, PREG_SET_ORDER); // matching Wiki links
		
		foreach ($matches as $m) {
			$m[1] = $m[1] ? $m[1] : $m[2]; // is page label same as its name?
			$m[3] = $m[3] ? '#'.u(preg_replace('/[^\da-z]/i', '_', $m[3])) : ''; // anchor
			
			$attr = file_exists("$PG_DIR$m[2].txt") ? $m[3] : '&amp;action=edit" class="pending';
			$CON = str_replace($m[0], '<a href="'.$self.'page='.u($m[2]).$attr.'">'.$m[1].'</a>', $CON);
		}
		
		for ($i = 10; $i >= 1; $i--) { // Lists, ordered, unordered
			$CON = preg_replace('/^'.str_repeat('\*', $i)."(.*)(\n?)/m", str_repeat('<ul>', $i).'<li>$1</li>'.str_repeat('</ul>', $i).'$2', $CON);
			$CON = preg_replace('/^'.str_repeat('\#', $i)."(.*)(\n?)/m", str_repeat('<ol>', $i).'<li>$1</li>'.str_repeat('</ol>', $i).'$2', $CON);
			$CON = preg_replace("#(</ol>\n?<ol>|</ul>\n?<ul>)#", '', $CON);
		}
		
		// headings
		preg_match_all('/^(!+)(.*)$/m', $CON, $matches, PREG_SET_ORDER);
		$stack = array();
		
		for ($h_id = max($par, 1), $i = 0, $c = count($matches); $i < $c && $m = $matches[$i]; $i++, $h_id++) {
			$excl = strlen($m[1]) + 1;
			$hash = preg_replace('/[^\da-z]/i', '_', $m[2]);
			
			for ($ret = ''; end($stack) >= $excl; $ret .= '</div>', array_pop($stack));
			
			$stack[] = $excl;
			
			$ret .= "<div class=\"par-div\" id=\"par-$h_id\"><h$excl id=\"$hash\">$m[2]";

			if ($is_enterprise) {
				if (!get_standalone_user($config['id_user'])) {
					if (wiki_get_write_acl ($config['id_user'], $page)) { 
						$ret .= "<span class=\"par-edit\">(<a href=\"$self" . "action=edit&amp;page=".u($page)."&amp;par=$h_id\">$T_EDIT</a>)</span>";
					}
				}
			} else {
				if (!get_standalone_user($config['id_user'])) {
					if (is_writable($PG_DIR . $page . '.txt')) {
						$ret .= "<span class=\"par-edit\">(<a href=\"$self" . "action=edit&amp;page=".u($page)."&amp;par=$h_id\">$T_EDIT</a>)</span>";
					}
				}
			}
	
			$CON = preg_replace('/' . preg_quote($m[0], '/') . '/', "$ret</h$excl>", $CON, 1);
			$TOC .= str_repeat("<ul>", $excl - 2).'<li><a href="'.$self.'page='.u($page).'#'.u($hash).'">'.$m[2].'</a></li>'.str_repeat("</ul>", $excl - 2);
		}

	
		$CON .= str_repeat('</div>', count($stack));
		
		$TOC = '<ul id="toc">' . preg_replace(array_fill(0, 5, "#</ul>\n*<ul>#"), array_fill(0, 5, ''), $TOC) . '</ul>';
		$TOC = str_replace(array('</li><ul>', '</ul><li>', '</ul></ul>', '<ul><ul>'), array('<ul>', '</ul></li><li>', '</ul></li></ul>', '<ul><li><ul>'), $TOC);
		
		$CON = preg_replace("/'--(.*)--'/Um", '<del>$1</del>', $CON); // strikethrough
		$CON = preg_replace("/'__(.*)__'/Um", '<u>$1</u>', $CON); // underlining
		$CON = preg_replace("/'''(.*)'''/Um", '<strong>$1</strong>', $CON); // bold
		$CON = preg_replace("/''(.*)''/Um", '<em>$1</em>', $CON); // italic
		$CON = str_replace('{br}', '<br style="clear:both"/>', $CON); // new line
		$CON = preg_replace('/-----*/', '<hr/>', $CON); // horizontal line
		$CON = str_replace('--', '&mdash;', $CON); // --
		
		$CON = preg_replace(array_fill(0, count($codes[1]) + 1, '/{CODE}/'), $codes[1], $CON, 1); // put HTML and "normal" codes back
		$CON = preg_replace(array_fill(0, count($htmlcodes[1]) + 1, '/{HTML}/'), $htmlcodes[1], $CON, 1);
		
		plugin('formatEnd');
	}
	
	plugin('formatFinished');
	
	// Loading template. If does not exist, use built-in default
	$html = file_exists($TEMPLATE) ?
		file_get_contents(clear_path($TEMPLATE)) : $fallback_template;
	
	// including pages in pure HTML
	while (preg_match('/{include:([^}]+)}/U', $html, $m)) {
		$inc = str_replace(array('{html}', '{/html}'), '', @file_get_contents("$PG_DIR$m[1].txt"));
		$html = str_replace($m[0], $inc, $html);
	}
	
	plugin('template'); // plugin templating
	
	
	$html = preg_replace('/\{([^}]* )?plugin:.+( [^}]*)?\}/U', '', $html); // get rid of absent plugin tags
	
	$has_perm = true;
	if ($is_enterprise) {
		$has_perm = wiki_get_write_acl($config['id_user'], $page); //if user has write permissions, he can read
		if (!$has_perm) {
			$has_perm = wiki_get_read_acl($config['id_user'], $page);
		}
	}
	
	if (!$has_perm) {
		$CON = __("You can't access this page");
	}
	
	$tpl_subs = array(
		'HEAD' => $HEAD . ($action ? '<meta name="robots" content="noindex, nofollow"/>' : ''),
		'SEARCH_FORM' => '<form action="'.$self_form.'" method="post"><span><input type="hidden" name="action" value="search"/><input type="submit" style="display:none;"/>',
		'\/SEARCH_FORM' => "</span></form>",
		'SEARCH_INPUT' => '<input type="text" name="query" value="'.h($query).'"/>',
		'SEARCH_SUBMIT' => "<input class=\"submit\" type=\"submit\" value=\"$T_SEARCH\"/>",
		'HOME' => "<a href=\"$self" . "page=".u($START_PAGE)."\">$T_HOME</a>",
		'RECENT_CHANGES' => "<a href=\"$self" . "action=recent\">$T_RECENT_CHANGES</a>",
		'READ' => "<a href=\"$self" . "page=".u($page). "&amp;action=read_acl\">Read ACL</a>",
		'WRITE' => "<a href=\"$self" . "page=".u($page). "&amp;action=write_acl\">Write ACL</a>",
		'ERROR' => $error,
		'HISTORY' => $page ? "<a href=\"$self" . "page=".u($page)."&amp;action=history\">$T_HISTORY</a>" : "",
		'PAGE_TITLE' => h($page == $START_PAGE && $page == $TITLE ? $WIKI_TITLE : $TITLE),
		'PAGE_TITLE_HEAD' => h($TITLE),
		'PAGE_URL' => u($page),
		'EDIT' => !$action?
			("<a href=\"$self" . "page=".u($page)."&amp;action=edit" . 
				(is_writable("$PG_DIR$page.txt") ? "\">$T_EDIT</a>" : "&amp;showsource=1\">$T_SHOW_SOURCE</a>"))
			: "",
		'WIKI_TITLE' => h($WIKI_TITLE),
		'LAST_CHANGED_TEXT' => $last_changed_ts ? $T_LAST_CHANGED : "",
		'LAST_CHANGED' => $last_changed_ts ? date($DATE_FORMAT, $last_changed_ts + $LOCAL_HOUR * 3600) : "",
		'CONTENT' => $action != "edit" ? $CON : "",
		'TOC' => $TOC,
		'SYNTAX' => $action == "edit" || $preview ? "<a href=\"$SYNTAX_PAGE\">$T_SYNTAX</a>" : "",
		'SHOW_PAGE' => $action == "edit" || $preview ? "<a href=\"$self" . "page=".u($page)."\">$T_SHOW_PAGE</a>" : "",
		'COOKIE' => '<a href="'.$self.'page='.u($page).'&amp;action='.u($action).'&amp;erasecookie=1">'.$T_ERASE_COOKIE.'</a>',
		'CONTENT_FORM' => $CON_FORM_BEGIN,
		'\/CONTENT_FORM' => $CON_FORM_END,
		'CONTENT_TEXTAREA' => $CON_TEXTAREA,
		'CONTENT_SUBMIT' => $CON_SUBMIT,
		'CONTENT_PREVIEW' => $CON_PREVIEW,
		'RENAME_TEXT' => $RENAME_TEXT,
		'RENAME_INPUT' => $RENAME_INPUT,
		'EDIT_SUMMARY_TEXT' => $EDIT_SUMMARY_TEXT,
		'EDIT_SUMMARY_INPUT' => $EDIT_SUMMARY,
		'FORM_PASSWORD' => $FORM_PASSWORD,
		'FORM_PASSWORD_INPUT' => $FORM_PASSWORD_INPUT
	);
	
	if ($action == '') {
		$tpl_subs['SYNTAX'] = "<a href=\"$SYNTAX_PAGE\">$T_SYNTAX</a>";
	}
	
	
	foreach ($tpl_subs as $tpl => $rpl) // substituting values

		$html = template_replace($tpl, $rpl, $html);
	
	header_lionwiki('Content-type: text/html; charset=UTF-8');
	
	echo($html);

}
function create_new_table_multiworkunit($number = false, $date = false)
{
    global $config;
    //If not number return empty
    if (!$number) {
        return;
    }
    //Set several global variables
    if ($date) {
        $now = $date;
    } else {
        $now = (string) get_parameter("givendate", date("Y-m-d H:i:s"));
    }
    $start_date = substr($now, 0, 10);
    $wu_user = $config["id_user"];
    echo "<table id='wu_" . $number . "' class='search-table' width='99%'>";
    echo "<tr>";
    echo "<td colspan=4>";
    echo "<strong>" . sprintf(__("Workunit  #%d"), $number) . "</strong>";
    echo "</td>";
    //If number greater than 1 display a cross to delete workunit
    echo "<td id='del_wu_" . $number . "' style='text-align:right; padding-right: 10px'>";
    if ($number > 1) {
        echo "<a id='del_wu_" . $number . "' href='#'><img src='images/cross.png'></a>";
    } else {
        echo "&nbsp;";
    }
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    // Show task combo if none was given.
    echo "<td>";
    echo print_input_text('start_date_' . $number, $start_date, '', 10, 20, true, __("Date"));
    echo "</td>";
    echo "<td colspan='2'>";
    echo combo_task_user_participant($wu_user, true, 0, true, __("Task"), 'id_task_' . $number, true, false, 'check_multiplewu_task();');
    echo "</td>";
    echo "<td>";
    if (dame_admin($config['id_user'])) {
        echo combo_roles(true, 'id_profile_' . $number, __('Role'), true);
    } else {
        echo combo_user_task_profile($id_task, 'id_profile_' . $number, 0, false, true);
    }
    echo "</td>";
    echo "<td>";
    if (dame_admin($config['id_user'])) {
        $params = array();
        $params['input_id'] = 'text-id_username_' . $number;
        $params['input_name'] = 'id_username';
        $params['input_value'] = $wu_user;
        $params['title'] = 'Username';
        $params['return'] = true;
        $params['return_help'] = true;
        echo user_print_autocomplete_input($params);
    }
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>";
    echo print_input_text('duration_' . $number, 4, false, 7, 7, true, __('Time used'));
    echo "</td>";
    echo "<td>";
    echo print_checkbox('have_cost_' . $number, 1, false, true, __('Have cost'));
    echo "</td>";
    echo "<td>";
    echo print_checkbox('public_' . $number, 1, true, true, __('Public'));
    echo "</td>";
    echo "<td>";
    echo print_checkbox('forward_' . $number, 1, false, true, __('Forward')) . print_help_tip(__('If this checkbox is activated, propagation will be forward instead backward'), true);
    echo "</td>";
    echo "<td>";
    echo print_checkbox('split_' . $number, 1, false, true, __('Split > 1day'));
    echo print_help_tip(__('If workunit added is superior to 8 hours, it will be propagated to previous workday and deduced from the total, until deplete total hours assigned'), true);
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>";
    echo print_checkbox('work_home_' . $number, 1, false, true, __('Work from home'));
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td colspan=5>";
    echo print_textarea('description_' . $number, 4, 30, false, '', true, __('Description'));
    echo "</td>";
    echo "</tr>";
    echo "</table>";
}
示例#10
0
    echo '<div style="width:' . $table_company->width . '" class="action-buttons button">';
    echo "<a href='javascript: loadCompany();'>" . __('Add') . "<img src='images/go.png' /></a>";
    echo '</div>';
    return;
}
if ($get_user_associated) {
    $inventory_user = get_parameter('inventory_user', '');
    $table_user->class = 'databox';
    $table_user->width = '98%';
    $table_user->data = array();
    $params_user['input_id'] = 'text-inventory_user';
    $params_user['input_name'] = 'inventory_user';
    $params_user['input_value'] = $inventory_user;
    $params_user['return'] = true;
    $table_user->data[0][0] = print_label(__('User'), '', '', true);
    $table_user->data[0][1] = user_print_autocomplete_input($params_user);
    print_table($table_user);
    echo '<div style="width:' . $table_user->width . '" class="action-buttons button">';
    echo "<a href='javascript: loadUser();'>" . __('Add') . "<img src='images/go.png' /></a>";
    echo '</div>';
    return;
}
if ($printTableMoreInfo) {
    $id_inventory = get_parameter('id_inventory');
    $id_object_type = get_db_value_sql('SELECT id_object_type FROM tinventory WHERE id=' . $id_inventory);
    if ($id_object_type) {
        $object_fields = get_db_all_rows_sql("SELECT * FROM tobject_type_field WHERE id_object_type=" . $id_object_type);
        if ($object_fields == false) {
            $object_fields = array();
        }
        $table_info->class = 'list';
示例#11
0
 $table->colspan[4][1] = 2;
 $table->colspan[5][0] = 3;
 $table->colspan[7][0] = 3;
 /* First row */
 if ($write_permission || !$id) {
     $table->data[0][0] = print_input_text('name', $name, '', 40, 128, true, __('Name'));
 } else {
     $table->data[0][0] = print_label(__('Name'), '', '', true, $name);
 }
 $params_assigned['input_id'] = 'text-owner';
 $params_assigned['input_name'] = 'owner';
 $params_assigned['input_value'] = $owner;
 $params_assigned['title'] = 'Owner';
 $params_assigned['return'] = true;
 if ($write_permission || !$id) {
     $table->data[0][1] = user_print_autocomplete_input($params_assigned);
 } else {
     $table->data[0][1] = print_label(__('Owner'), '', '', true, $owner);
 }
 if ($write_permission || !$id) {
     $table->data[0][2] = print_checkbox_extended('public', 1, $public, false, '', '', true, __('Public'));
 } else {
     $table->data[0][2] = print_checkbox_extended('public', 1, $public, true, '', '', true, __('Public'));
 }
 if ($write_permission || !$id) {
     $parent_name = $id_parent ? get_inventory_name($id_parent) : __("None");
     $table->data[1][0] = print_input_text_extended("parent_name", $parent_name, "text-parent_name", '', 20, 0, false, "show_inventory_search('','','','','','','','','','', '', '')", "class='inventory_obj_search'", true, false, __('Parent object'));
     $table->data[1][0] .= print_image("images/cross.png", true, array("onclick" => "cleanParentInventory()", "style" => "cursor: pointer"));
     $table->data[1][0] .= print_input_hidden('id_parent', $id_parent, true);
 } else {
     $parent_name = $id_parent ? get_inventory_name($id_parent) : __('Not set');
示例#12
0
		$params_creator["title"] = __("Ticket creator");
		$params_creator['return'] = false;
		$params_creator['return_help'] = true;
		
		user_print_autocomplete_input($params_creator);

	    echo "<td>";
	    
	    $params_editor['input_id'] = 'text-user_id3';
		$params_editor['input_name'] = 'editor';
		$params_editor["input_value"] = $editor;
		$params_editor["title"] = __("Ticket editor");
		$params_editor['return'] = false;
		$params_editor['return_help'] = true;
		
		user_print_autocomplete_input($params_editor);

	    echo "<td>";
	    $available_status = get_indicent_status();
	    $available_status[-10] = __("Not closed");

	    echo print_select ($available_status,
	        'search_status', $status,
	        '', __('Any'), 0, true, false, true,
	        __('Status'));

	    // TODO: Meter aqui inventario, con un control nuevo, tipo AJAX similar al de los usuarios.

	    echo "</table>";
	    
	    echo "<div class='button-form'>";