Beispiel #1
0
/**
 * Implements hook_process_form_content().
 */
function commons_beehive_process_form_content(&$variables, $hook)
{
    // Crunch down attribute arrays.
    template_process($variables, $hook);
}
Beispiel #2
0
 public function build_mk_cache()
 {
     //获取站点信息
     $this->site = $this->pub_config->get_site_first('*', $this->site_id);
     $css_js_filein_tem = true;
     //获取客户端详细信息
     $this->client = $this->pub_config->get_client_first($this->client_type);
     //设置文件生成方式
     $this->page_info['file_mktype'] = $this->site['produce_format'];
     $this->page_info['filename'] = $this->site['indexname'] ? $this->site['indexname'] : 'index';
     $this->page_info['weburl'] = $this->site['site_info']['url'];
     $this->page_info['dir'] = $this->site['site_dir'];
     $this->page_info['custom_content_dir'] = $this->site['custom_content_dir'];
     $this->page_info['custom_content_dir'] = $this->site['custom_content_dir'];
     $this->page_info['tem_material_dir'] = get_site_temdir($this->site);
     $this->page_info['tem_material_url'] = get_site_temurl($this->site);
     //如果有页面id
     if ($this->page_id) {
         $page_type = common::get_page_manage($this->site_id, $this->page_id, 'id');
         $page_type_detail = $page_type[$this->page_id];
         if ($page_type_detail['sign'] == 'special') {
             //查询专题的生成目录
         } else {
             if ($page_type_detail['sign']) {
                 //设置文件生成方式
                 $this->page_info['file_mktype'] = isset($page_type_detail['maketype']) ? $page_type_detail['maketype'] : 1;
                 $this->page_info['filename'] = isset($page_type_detail['colindex']) ? $page_type_detail['colindex'] : 'index';
                 $this->page_info['weburl'] = $page_type_detail['column_domain'];
                 $this->page_info['dir'] .= $page_type_detail['column_dir'];
             }
         }
         //如果有页面数据id,
         if ($this->page_data_id && $page_type_detail['sign'] != 'special') {
             $page_data = common::get_page_data($this->page_id, '', '', '', $page_type_detail, $this->page_data_id);
             $page_data_detail = $page_data['page_data'][0];
             if (!$page_data_detail) {
                 $this->set_error('未取得page_data_id:' . $this->page_id . '_' . $this->page_data_id . var_export($page_data, true) . '详细信息');
             }
             $this->column = $page_data_detail;
             //设置文件生成方式
             if (in_array($this->content_type, $this->content_type_true)) {
                 $this->page_info['file_mktype'] = $page_data_detail['maketype'];
             } else {
                 $this->page_info['file_mktype'] = $page_data_detail['col_con_maketype'];
                 //表示内容正文(目前生成分页正文全文链接有作用)
                 $this->page_info['page_content_type'] = 1;
             }
             //设置文件生成方式
             $this->page_info['filename'] = $page_data_detail['colindex'];
             $this->page_info['weburl'] = $page_data_detail['column_domain'];
             $this->page_info['dir'] .= $page_data_detail['column_dir'];
             $this->page_info['column_dir'] .= $page_data_detail['column_dir'];
             $this->page_info['relate_dir'] .= $page_data_detail['relate_dir'];
         }
     }
     $this->page_info['suffix'] = $this->page_info['file_mktype'] == 1 ? '.html' : '.php';
     //内容页计算出内容的url
     if (in_array($this->content_type, $this->content_type_true)) {
         $this->is_page_content = false;
     }
     //取单元,设有缓存
     if ($this->page_id_c && $this->page_data_id_c) {
         //专题模块查询出该专题详细信息
         include_once ROOT_PATH . 'lib/class/special.class.php';
         $special_obj = new special();
         $this->special_detail = $special_obj->get_special_by_id($this->page_data_id_c);
         //$cell_ret             = common::get_special_cell_list($this->page_data_id_c, $this->template_sign, 0, $this->page_info['tem_material_url'] . '/' . $this->settings['template_name']);
         $cell_ret = common::getTemplateAndCell(0, 0, $this->page_data_id_c, 0, $this->page_info['tem_material_url'] . '/' . $this->settings['template_name'], $this->template_sign);
         if (is_array($this->special_detail) && $this->special_detail) {
             //$this->page_info['column_dir'] .= $this->special_detail['column_dir'];
             $this->page_info['file_mktype'] = $this->special_detail['maketype'];
             $this->page_info['suffix'] = $this->page_info['file_mktype'] == 1 ? '.html' : '.php';
         }
         //表示内容正文(目前生成分页正文全文链接有作用)
         $this->page_info['page_content_type'] = 0;
     } else {
         if ($page_type_detail['sign'] == 'special') {
             //专题模块查询出该专题详细信息
             include_once ROOT_PATH . 'lib/class/special.class.php';
             $special_obj = new special();
             //根据专题子栏目查询出专题
             $this->special_detail = $special_obj->get_mkspecial('', $this->page_data_id);
             //查询出这个专题的发布目录
             if ($this->special_detail && is_array($this->special_detail)) {
                 $this->special_column = $this->special_detail['special_column'];
                 $this->page_info['column_dir'] .= $this->special_detail['column_dir'];
                 $this->page_info['relate_dir'] = $this->special_detail['relate_dir'];
                 $this->page_info['special_dir'] = $this->special_detail['special_dir'];
                 $this->page_info['file_mktype'] = $this->special_detail['maketype'];
                 $this->page_info['filename'] = $this->special_detail['colindex'];
                 $this->page_info['dir'] .= $this->special_detail['column_dir'];
                 $this->page_info['suffix'] = $this->page_info['file_mktype'] == 1 ? '.html' : '.php';
                 $this->page_info['page_type'] = 'special';
                 $this->template_sign = $this->special_detail['template_sign'];
                 $this->column['name'] = $this->special_detail['title'];
                 $this->column['keywords'] = $this->special_detail['keywords'];
                 $this->column['content'] = $this->special_detail['brief'];
                 $this->page_data_id_s = $this->special_detail['id'];
                 $this->content_type_s = $this->page_data_id . 's';
             } else {
                 $this->set_error('未取到专题信息,专题的栏目id:' . $this->page_data_id . ';专题返回数据(get_mkspecial):' . var_export($this->special_detail, true));
             }
             //$cell_ret = common::get_special_cell_list($this->special_detail['id'], $this->template_sign, $this->page_data_id, $this->page_info['tem_material_url'] . '/' . $this->settings['template_name']);
             $cell_ret = common::getTemplateAndCell(0, 0, $this->special_detail['id'], $this->page_data_id, $this->page_info['tem_material_url'] . '/' . $this->settings['template_name'], $this->template_sign);
         } else {
             //$cell_ret = common::get_cell_list($this->site_id, $this->page_id, $this->page_data_id, $this->content_type, $this->template_sign);
             $cell_ret = common::getTemplateAndCell($this->site_id, $this->page_id, $this->page_data_id, $this->content_type, $this->page_info['tem_material_url'] . '/' . $this->settings['template_name']);
         }
     }
     /**
             foreach($cell_ret['default_cell'] as $k=>$v)
             {
        if($v['layout_id'])
        {
            $cell_ret['default_cell'][$k]['id']=$v['id'].'_'.$v['layout_id'];
        }
             }
     */
     //当前使用中的套系标识
     $template_style = $cell_ret['curr_style'] ? $cell_ret['curr_style'] : 'default';
     //当前模板标识
     $template_sign = $cell_ret['template_sign'];
     //获取模板,设有缓存
     if ($this->page_id_c && $this->page_data_id_c || $page_type_detail['sign'] == 'special') {
         foreach ($cell_ret['default_cell'] as $k => $v) {
             if ($v['layout_id']) {
                 $cell_ret['default_cell'][$k]['id'] = $v['id'] . '_' . $v['layout_id'];
             }
         }
         $this->template_set = $cell_ret['template'];
         //$this->template_set = common::get_template_cache($template_sign, $template_style, $this->settings['special_template']['site_id'], $this->page_info['tem_material_url'] . '/' . $this->settings['template_name']);
     } else {
         $this->template_set = $cell_ret['template'];
         //$this->template_set = common::get_template_cache($template_sign, $template_style, $this->site_id, $this->page_info['tem_material_url'] . '/' . $this->settings['template_name']);
     }
     //页面标题关键字描述的插入到模板中
     if (!$this->is_page_content) {
         $this->template_set = template_process($this->template_set, $this->site, $this->column);
     } else {
         $this->template_set = template_process($this->template_set, $this->site, $this->column, true);
     }
     //取出单元用到的数据源,样式
     $this->cell_process($cell_ret);
     //js加入栏目信息到源码中
     $column_detail_codearr = array('id' => $page_data_detail['id'], 'title' => $page_data_detail['name'], 'keywords' => $page_data_detail['keywords']);
     $column_detail_codestr = "\n" . "<script type=\"text/javascript\">var m2o_column=" . json_encode($column_detail_codearr) . ";";
     $m2o_content_detail_codearr = '<?php 
                     $m2o_content_detail_codearr = array(
                     \'id\' => $__info[\'content\'][\'content_id\'],
                     \'title\' => $__info[\'content\'][\'title\'],
                     \'keywords\' => $__info[\'content\'][\'keywords\'],
                     \'bundle_id\' => $__info[\'content\'][\'bundle_id\'],
                     \'module_id\' => $__info[\'content\'][\'module_id\'],
                     \'content_id\' => $__info[\'content\'][\'content_id\'],
                     \'content_fromid\' => $__info[\'content\'][\'content_fromid\'],
                     \'rid\' => $__info[\'content\'][\'rid\'],
                 );
                 echo json_encode($m2o_content_detail_codearr);
                 ?>';
     $column_detail_codestr .= "var m2o_content = '" . $m2o_content_detail_codearr . "';";
     $column_detail_codestr .= "</script>" . "\n";
     $this->template_set = str_ireplace('</head>', $column_detail_codestr . '</head>', $this->template_set);
     //css加载到模板中
     if (!$this->is_page_content) {
         $this->template_set = str_ireplace('</head>', $this->css . "\n" . '</head>', $this->template_set);
         $this->css = '';
     } else {
         //计算js,css路径,外链到模板head中去
         //页面素材域名
         if ($this->page_id_c && $this->page_data_id_c) {
             $mar_dir = $this->page_id_c . '/' . $this->page_data_id_c . '/' . $this->content_type . '/';
             $css_filename = $this->page_id_c . '_' . $this->page_data_id_c . '_' . $this->content_type . '_' . $this->client_type . '.css';
         } else {
             $mar_dir = $this->page_id . '/' . $this->page_data_id . '/' . $this->content_type . '/';
             $css_filename = $this->page_id . '_' . $this->page_data_id . '_' . $this->content_type . '_' . $this->client_type . '.css';
         }
         //计算css路径
         $this->mar_css['mar_css_dir'] = $this->page_info['tem_material_dir'] . '/' . $this->settings['template_name'] . '/' . $mar_dir;
         $this->mar_css['mar_css_filename'] = $css_filename;
         $css_link = '<link  rel="stylesheet" type="text/css" href="' . $this->page_info['tem_material_url'] . '/' . $this->settings['template_name'] . '/' . $mar_dir . $css_filename . '" />';
         $this->template_set = str_ireplace('</head>', $css_link . "\n" . '</head>', $this->template_set);
     }
     //js添加到</body>之前
     if ($this->js) {
         $this->template_set = str_ireplace('</body>', $this->js . "\n" . '</body>', $this->template_set);
         $this->js = '';
     }
     //生成头部文件
     $this->include_head($cell_ret);
     //生成缓存文件
     $this->set_cache();
     //复制数据源缓存到lib/m2o/include
     if (is_dir(CUR_CONF_PATH . 'cache/datasource')) {
         if (!file_copy(CUR_CONF_PATH . 'cache/datasource', CUR_CONF_PATH . 'lib/m2o/include', array())) {
             $this->set_error('模板服务器:' . realpath(CUR_CONF_PATH . 'lib/m2o/include') . '目录不可写');
         }
     }
 }
function mail_workorder($id_wo, $mode, $id_note = false, $wo_info = false, $note_info = false)
{
    global $config;
    $wo = $wo_info;
    if (!$wo_info) {
        $wo = get_db_row("ttodo", "id", $id_wo);
    }
    // Only send mails when creator is different than owner
    if ($wo['assigned_user'] == $wo['created_by_user']) {
        return;
    }
    $MACROS["_sitename_"] = $config['sitename'];
    $MACROS["_wo_id_"] = $wo['id'];
    $MACROS["_wo_name_"] = $wo['name'];
    $MACROS["_wo_last_update_"] = $wo['last_update'];
    $MACROS["_wo_created_by_user_"] = $wo['created_by_user'];
    $MACROS["_wo_assigned_user_"] = $wo['assigned_user'];
    $MACROS["_wo_progress_"] = translate_wo_status($wo['progress']);
    $MACROS["_wo_priority_"] = get_priority_name($wo['priority']);
    $MACROS["_wo_description_"] = wordwrap($wo["description"], 70, "\n");
    $MACROS["_wo_url_"] = $config["base_url"] . "/index.php?sec=projects&sec2=operation/workorders/wo&operation=view&id={$id_wo}";
    $MACROS["_wo_title_"] = $wo['name'];
    $MACROS["_wo_delete_user_"] = $config["id_user"];
    //Replace note macros if needed
    if ($id_note) {
        if (!$note_info) {
            $note_info = get_db_row('ttodo_notes', 'id', $id_note);
        }
        $MACROS["_wo_note_created_by_user_"] = $note_info["written_by"];
        $MACROS["_wo_notes_url_"] = $config["base_url"] . "/index.php?sec=projects&sec2=operation/workorders/wo&operation=view&tab=notes&id={$id_wo}";
        $MACROS["_wo_note_info_"] = $note_info["description"];
        $MACROS["_wo_note_delete_user_"] = $config["id_user"];
    }
    // Send email for assigned and creator of this workorder
    $email_creator = get_user_email($wo['created_by_user']);
    $email_assigned = get_user_email($wo['assigned_user']);
    switch ($mode) {
        case 0:
            // WO update
            $text = template_process($config["homedir"] . "/include/mailtemplates/wo_update.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/wo_subject_update.tpl", $MACROS);
            break;
        case 1:
            // WO creation
            $text = template_process($config["homedir"] . "/include/mailtemplates/wo_create.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/wo_subject_create.tpl", $MACROS);
            break;
        case 3:
            // WO deleted
            $text = template_process($config["homedir"] . "/include/mailtemplates/wo_delete.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/wo_subject_delete.tpl", $MACROS);
            break;
        case 4:
            //New note
            $text = template_process($config["homedir"] . "/include/mailtemplates/wo_new_note.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/wo_subject_new_note.tpl", $MACROS);
            break;
        case 5:
            //Delete note
            $text = template_process($config["homedir"] . "/include/mailtemplates/wo_delete_note.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/wo_subject_delete_note.tpl", $MACROS);
            break;
    }
    $msg_code = "WO#{$id_wo}";
    $msg_code .= "/" . substr(md5($id_wo . $config["smtp_pass"] . $wo["assigned_user"]), 0, 5);
    $msg_code .= "/" . $wo["assigned_user"];
    integria_sendmail($email_assigned, $subject, $text, false, $msg_code);
    $msg_code = "WO#{$id_wo}";
    $msg_code .= "/" . substr(md5($id_wo . $config["smtp_pass"] . $wo["created_by_user"]), 0, 5);
    $msg_code .= "/" . $wo["created_by_user"];
    integria_sendmail($email_creator, $subject, $text, false, $msg_code);
}
Beispiel #4
0
/**
 * Check an SLA inactivity value on an incident and send email (to incident owner) if needed.
 *
 * @param array Incident to check
 */
function check_sla_inactivity($incident)
{
    global $compare_timestamp;
    global $config;
    $id_sla = check_incident_sla_max_inactivity($incident['id_incidencia']);
    if (!$id_sla) {
        return false;
    }
    $sla = get_db_row("tsla", "id", $id_sla);
    /* Check if it was already notified in a specified time interval */
    $sql = sprintf('SELECT COUNT(id) FROM tevent
		WHERE type = "SLA_MAX_INACTIVITY_NOTIFY"
		AND id_item = %d
		AND timestamp > "%s"', $incident['id_incidencia'], $compare_timestamp);
    $notified = get_db_sql($sql);
    if ($notified > 0) {
        return true;
    }
    /* We need to notify via email to the owner user */
    $user = get_user($incident['id_usuario']);
    $MACROS["_sitename_"] = $config["sitename"];
    $MACROS["_username_"] = $incident['id_usuario'];
    $MACROS["_fullname_"] = dame_nombre_real($incident['id_usuario']);
    $MACROS["_group_"] = dame_nombre_grupo($incident['id_grupo']);
    $MACROS["_incident_id_"] = $incident["id_incidencia"];
    $MACROS["_incident_title_"] = $incident['titulo'];
    $MACROS["_data1_"] = give_human_time($sla['max_inactivity'] * 3600);
    $access_dir = empty($config['access_public']) ? $config["base_url"] : $config['public_url'];
    $MACROS["_access_url_"] = $access_dir . "/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=" . $incident['id_incidencia'];
    $text = template_process($config["homedir"] . "/include/mailtemplates/incident_sla_max_inactivity_time.tpl", $MACROS);
    $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_sla_max_inactivity_time_subject.tpl", $MACROS);
    if ($sla['enforced'] == 1) {
        integria_sendmail($user['direccion'], $subject, $text);
        insert_event('SLA_MAX_INACTIVITY_NOTIFY', $incident['id_incidencia']);
    } else {
        insert_event('SLA_MAX_INACTIVITY_NOTIFY', $incident['id_incidencia']);
    }
}
Beispiel #5
0
function mail_project($mode, $id_user, $id_workunit, $id_task, $additional_msg = "")
{
    global $config;
    $workunit = get_db_row("tworkunit", "id", $id_workunit);
    $task = get_db_row("ttask", "id", $id_task);
    $project = get_db_row("tproject", "id", $task["id_project"]);
    $id_project = $task["id_project"];
    $id_manager = $project["id_owner"];
    $cc_project = $project["cc"];
    $cc_task = $task["cc"];
    $MACROS["_time_used_"] = $workunit["duration"];
    $access_dir = empty($config['access_public']) ? $config["base_url"] : $config['public_url'];
    $MACROS["_access_url_"] = $access_dir . "/index.php?sec=projects&sec2=operation/projects/task_workunit&id_project={$id_project}&id_task={$id_task}";
    if ($workunit["have_cost"] == 1) {
        $MACROS["_havecost_"] = __('Yes');
    } else {
        $MACROS["_havecost_"] = __('No');
    }
    if ($workunit["public"] == 1) {
        $MACROS["_public_"] = __('Yes');
    } else {
        $MACROS["_public_"] = __('No');
    }
    $MACROS["_sitename_"] = $config["sitename"];
    $MACROS["_taskname_"] = $task["name"];
    $MACROS["_projectname_"] = $project["name"];
    $MACROS["_fullname_"] = dame_nombre_real($project["id_owner"]);
    $MACROS["_update_timestamp_"] = $workunit["timestamp"];
    $MACROS["_owner_"] = $project["id_owner"];
    $MACROS["_wu_text_"] = $workunit["description"];
    $MACROS["_wu_user_"] = dame_nombre_real($id_user);
    $MACROS["_additional_message_"] = $additional_msg;
    $description = $workunit["description"];
    switch ($mode) {
        case 0:
            // Workunit add
            $text = template_process($config["homedir"] . "/include/mailtemplates/project_wu_create.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/project_subject_wucreate.tpl", $MACROS);
            break;
        case 1:
            // Workunit updated
            $text = template_process($config["homedir"] . "/include/mailtemplates/project_wu_update.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/project_subject_wuupdate.tpl", $MACROS);
            break;
    }
    if (!user_is_disabled($id_manager)) {
        // Send an email to project manager
        integria_sendmail(get_user_email($id_manager), $subject, $text);
    }
    if ($cc_project != "") {
        integria_sendmail($cc_project, $subject, $text);
    }
    if ($cc_task != "") {
        integria_sendmail($cc_task, $subject, $text);
    }
}
function mail_incident($id_inc, $id_usuario, $nota, $timeused, $mode, $public = 1)
{
    global $config;
    include_once $config["homedir"] . '/include/functions_user.php';
    clean_cache_db();
    $row = get_db_row("tincidencia", "id_incidencia", $id_inc);
    $group_name = get_db_sql("SELECT nombre FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $email_from = get_db_sql("SELECT email_from FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $titulo = $row["titulo"];
    $description = wordwrap(ascii_output($row["descripcion"]), 70, "\n");
    $prioridad = get_priority_name($row["prioridad"]);
    $nota = wordwrap($nota, 75, "\n");
    $estado = render_status($row["estado"]);
    $resolution = render_resolution($row["resolution"]);
    $create_timestamp = $row["inicio"];
    $update_timestamp = $row["actualizacion"];
    $usuario = $row["id_usuario"];
    $creator = $row["id_creator"];
    $email_copy = $row["email_copy"];
    // Send email for owner and creator of this incident
    $email_creator = get_user_email($creator);
    $company_creator = get_user_company($creator, true);
    if (empty($company_creator)) {
        $company_creator = "";
    } else {
        $company_creator = " (" . reset($company_creator) . ")";
    }
    $email_owner = get_user_email($usuario);
    $company_owner = get_user_company($usuario, true);
    if (empty($company_owner)) {
        $company_owner = "";
    } else {
        $company_owner = " (" . reset($company_owner) . ")";
    }
    //check if user is disabled
    $owner_disabled = user_is_disabled($usuario);
    $creator_disabled = user_is_disabled($creator);
    $ticket_score = '';
    if ($row["estado"] == 7 and $row['score'] == 0) {
        $ticket_score = $config["base_url"] . "/index.php?sec=incidents&sec2=operation/incidents/incident_detail&id={$id_inc}";
        //$ticket_score =  '<a href="'.$config["base_url"].'"/index.php?sec=incidents&sec2=operation/incidents/incident_detail&id="'.$id_inc.'">'."Click hear to scoring".'</a>';
    }
    $MACROS["_sitename_"] = $config["sitename"];
    $MACROS["_fullname_"] = dame_nombre_real($usuario);
    $MACROS["_username_"] = $usuario;
    $MACROS["_incident_id_"] = $id_inc;
    $MACROS["_incident_title_"] = $titulo;
    $MACROS["_creation_timestamp_"] = $create_timestamp;
    $MACROS["_update_timestamp_"] = $update_timestamp;
    $MACROS["_group_"] = $group_name;
    $MACROS["_author_"] = dame_nombre_real($creator) . $company_creator;
    $MACROS["_owner_"] = dame_nombre_real($usuario) . $company_owner;
    $MACROS["_priority_"] = $prioridad;
    $MACROS["_status_"] = $estado;
    $MACROS["_resolution_"] = $resolution;
    $MACROS["_time_used_"] = $timeused;
    $MACROS["_incident_main_text_"] = $description;
    $access_dir = empty($config['access_public']) ? $config["base_url"] : $config['public_url'];
    $MACROS["_access_url_"] = $access_dir . "/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id={$id_inc}";
    $MACROS["_incident_epilog_"] = $row["epilog"];
    $MACROS["_incident_closed_by_"] = $row["closed_by"];
    // Resolve code for its name
    switch ($mode) {
        case 10:
            // Add Workunit
            //$subject = "[".$config["sitename"]."] Incident #$id_inc ($titulo) has a new workunit from [$id_usuario]";
            $company_wu = get_user_company($id_usuario, true);
            if (empty($company_wu)) {
                $company_wu = "";
            } else {
                $company_wu = " (" . reset($company_wu) . ")";
            }
            $MACROS["_wu_user_"] = dame_nombre_real($id_usuario) . $company_wu;
            $MACROS["_wu_text_"] = $nota;
            $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update_wu.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_new_wu.tpl", $MACROS);
            break;
        case 0:
            // Incident update
            $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_update.tpl", $MACROS);
            break;
        case 1:
            // Incident creation
            $text = template_process($config["homedir"] . "/include/mailtemplates/incident_create.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_create.tpl", $MACROS);
            break;
        case 2:
            // New attach
            $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_attach.tpl", $MACROS);
            break;
        case 3:
            // Incident deleted
            $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_delete.tpl", $MACROS);
            break;
        case 5:
            // Incident closed
            $MACROS["_ticket_score_"] = $ticket_score;
            $text = template_process($config["homedir"] . "/include/mailtemplates/incident_close.tpl", $MACROS);
            $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_close.tpl", $MACROS);
            break;
    }
    // Create the TicketID for have a secure reference to incident hidden
    // in the message. Will be used for POP automatic processing to add workunits
    // to the incident automatically.
    $msg_code = "TicketID#{$id_inc}";
    $msg_code .= "/" . substr(md5($id_inc . $config["smtp_pass"] . $row["id_usuario"]), 0, 5);
    $msg_code .= "/" . $row["id_usuario"];
    if ((!$config['email_ticket_on_creation_and_closing'] || $mode == 5 || $mode == 1) && !$owner_disabled) {
        integria_sendmail($email_owner, $subject, $text, false, $msg_code, $email_from, 0, "", "X-Integria: no_process");
    }
    // Send a copy to each address in "email_copy"
    //if ($email_copy != ""){
    if ($email_copy != "" && !$config['email_ticket_on_creation_and_closing']) {
        $emails = explode(",", $email_copy);
        foreach ($emails as $em) {
            integria_sendmail($em, $subject, $text, false, "", $email_from, 0, "", "X-Integria: no_process");
        }
    }
    // Incident owner
    if ($email_owner != $email_creator and !$config['email_ticket_on_creation_and_closing'] and !$creator_disabled) {
        $msg_code = "TicketID#{$id_inc}";
        $msg_code .= "/" . substr(md5($id_inc . $config["smtp_pass"] . $row["id_creator"]), 0, 5);
        $msg_code .= "/" . $row["id_creator"];
        integria_sendmail($email_creator, $subject, $text, false, $msg_code, $email_from, "", 0, "", "X-Integria: no_process");
    }
    //if ($public == 1){
    if ($public == 1 and !$config['email_ticket_on_creation_and_closing']) {
        // Send email for all users with workunits for this incident
        $sql1 = "SELECT DISTINCT(tusuario.direccion), tusuario.id_usuario FROM tusuario, tworkunit, tworkunit_incident WHERE tworkunit_incident.id_incident = {$id_inc} AND tworkunit_incident.id_workunit = tworkunit.id AND tworkunit.id_user = tusuario.id_usuario AND tusuario.disabled=0";
        if ($result = mysql_query($sql1)) {
            while ($row = mysql_fetch_array($result)) {
                if ($row[0] != $email_owner and $row[0] != $email_creator) {
                    $msg_code = "TicketID#{$id_inc}";
                    $msg_code .= "/" . substr(md5($id_inc . $config["smtp_pass"] . $row[1]), 0, 5);
                    $msg_code .= "/" . $row[1];
                    integria_sendmail($row[0], $subject, $text, false, $msg_code, $email_from, "", 0, "", "X-Integria: no_process");
                }
            }
        }
        // Send email to incident reporters associated to this incident
        if ($config['incident_reporter'] == 1) {
            $contacts = get_incident_contact_reporters($id_inc, true);
            if ($contats) {
                foreach ($contacts as $contact) {
                    $contact_email = get_db_sql("SELECT email FROM tcompany_contact WHERE fullname = '{$contact}'");
                    integria_sendmail($contact_email, $subject, $text, false, $msg_code, $email_from, "", 0, "", "X-Integria: no_process");
                }
            }
        }
    }
}
Beispiel #7
0
				} else {
					$mail_description = template_process ($config["homedir"]."/include/mailtemplates/".$templa_new.".tpl", $MACROS);
					integria_sendmail($email['email'], "[".$config["sitename"]."] ".__("New calendar event"), $mail_description,  $attachments);
				}
			} else {
				if($email['id_group']){
					$sql_update    = "SELECT name FROM temail_template WHERE template_action = 17 AND id_group =".$email['id_group'].";";
					$templa_update = get_db_sql($sql_update);
				} else {
					$templa_update = '';
				}
				if ((!$templa_update) || ($templa_update == '')) {
					$mail_description = template_process ($config["homedir"]."/include/mailtemplates/update_entry_calendar.tpl", $MACROS);
					integria_sendmail($email['email'], "[".$config["sitename"]."] ".__("Updated calendar event"), $mail_description,  $attachments);
				} else {
					$mail_description = template_process ($config["homedir"]."/include/mailtemplates/".$templa_update.".tpl", $MACROS);
					integria_sendmail($email['email'], "[".$config["sitename"]."] ".__("Updated calendar event"), $mail_description,  $attachments);
				}
			}
		}
		
		// unlink ($full_filename);
		
		if (empty($id)) {
			echo ui_print_success_message (__('The event was added to calendar'), '', true, 'h3', true);
		} else {
			echo ui_print_success_message (__('The event was updated'), '', true, 'h3', true);
		}
		echo "<br>";
		print_button (__('OK'), 'OK', false, '', 'class="sub blank"');
	} else {
Beispiel #8
0
 public function show($plan, $content_data = array(), $is_from_sys = false)
 {
     $html = '';
     $this->setPlan($plan);
     if (!in_array($plan['content_type'], $this->content_type_true) && !$is_from_sys) {
         if ($plan['count'] === 0) {
             echo "所取内容条数为0条,不生成";
             exit;
         } else {
             if ($plan['count']) {
                 $count = $plan['count'] <= $this->settings['content_num_time'] ? $plan['count'] : $this->settings['content_num_time'];
                 $this->setTimecount($count);
                 $nextcount = $plan['count'] - $count;
                 $is_copy_plan = $nextcount > 0 ? true : false;
                 $offset = $plan['offset'] + $count;
             } else {
                 $offset = $plan['offset'] + $this->settings['content_num_time'];
                 //表示全部生成
                 $this->setTimecount($this->settings['content_num_time']);
                 $is_copy_plan = true;
             }
         }
     }
     //获取站点信息
     $site = $this->pub_config->get_site_first('*', $plan['site_id']);
     $this->setSite($site);
     if (!$site['tem_material_url']) {
         $site['tem_material_url'] = rtrim($site['sub_weburl'], '/') . '.' . $site['weburl'];
     }
     $this->setPagedir($site['site_dir']);
     $this->setMktype($site['produce_format']);
     $this->setFilename($site['indexname']);
     /**页面生成方式  1为静态生成 2为动态生成   
     			$page_mk_type页面生成方式  $page_content_mk_type内容生成方式
     			$dir 该页面生成的目录
     		*/
     if ($plan['page_id']) {
         $page_type = common::get_page_manage($plan['site_id'], $plan['page_id'], 'id');
         $page_type_detail = $page_type[$plan['page_id']];
         if ($page_type_detail['sign'] != 'column') {
             $this->setPagedir($page_type_detail['sign']);
         }
     }
     if ($plan['page_data_id']) {
         $page_data = common::get_page_data($plan['page_id'], '', '', '', $page_type_detail, $plan['page_data_id']);
         $page_data_detail = $page_data['page_data'][0];
         $this->setFilename($page_data_detail['colindex']);
         $this->setPagedir($page_data_detail['column_dir']);
         $this->setColumn($page_data_detail);
         if (in_array($plan['content_type'], $this->content_type_true)) {
             $this->setMktype($page_data_detail['maketype']);
         } else {
             $this->setMktype($page_data_detail['col_con_maketype']);
         }
     }
     $this->setWeburl();
     //获取对应模板,单元
     $cell_ret = common::merge_cell($plan['site_id'], $plan['page_id'], $plan['page_data_id'], $plan['content_type'], $site);
     if (MK_DEBUG) {
         file_in('../cache/log/', '处理前所有单元.txt', var_export($cell_ret, 1), true, true);
     }
     $template_style = $cell_ret['curr_style'];
     //当前使用中的套系标识
     $template_sign = $cell_ret['template_sign'];
     //当前模板标识
     //获取模板
     //		$site['tem_material_url'] = $site['tem_material_url']?$site['tem_material_url']:(rtrim($site['sub_weburl'],'/').'/'.rtrim($site['weburl'],'/').'/'.'templates');
     $template = common::get_template_cache($template_sign, $template_style, $plan['site_id'], $site['tem_material_url'] . '/t');
     if (MK_DEBUG) {
         file_in('../cache/log/', '处理前的模板.txt', $template, true, true);
     }
     //页面标题关键字描述的插入到模板中
     $template = template_process($template, $this->site, $this->column);
     if (MK_DEBUG) {
         file_in('../cache/log/', '处理head后模板.txt', $template, true, true);
     }
     if (empty($template)) {
         echo "没有部署模板";
         exit;
     }
     if (is_array($cell_ret['default_cell'])) {
         //			print_r($cell_ret['default_cell']);exit;
         //获取所有样式
         foreach ($cell_ret['default_cell'] as $k => $v) {
             if ($v['cell_mode']) {
                 $mode_idarr[$v['cell_mode']] = $v['cell_mode'];
             }
             if ($v['data_source']) {
                 $datasourceid[$v['data_source']] = $v['data_source'];
             }
         }
         //取样式的详细信息
         if ($mode_idarr) {
             $mode_id_str = implode(',', $mode_idarr);
             $mode_data = common::get_mode_infos($mode_id_str, '', 'id');
             //获取样式参数
             $mode_variables = common::get_mode_variable($mode_id_str);
             //加载css
             $cssstr = '<style type="text/css">';
             foreach ($mode_data as $k => $v) {
                 $cssstr .= $v['css'] . ' ';
             }
             $cssstr .= '</style>';
             $template = str_ireplace('</head>', $cssstr . '</head>', $template);
         }
         if (MK_DEBUG) {
             file_in('../cache/log/', '处理过样式后模板.txt', $template, true, true);
         }
         /**
          * 首页,列表的单元处理
          * */
         if (in_array($plan['content_type'], $this->content_type_true)) {
             $index_cell = $this->index_cell($cell_ret, $mode_data, $datasourceid, $mode_variables);
             $tem_cell = $index_cell['tem_cell'];
         } else {
             //取正文
             if ($is_from_sys) {
                 $content_list[0] = $content_data;
             } else {
                 //找到能取列表的数据源
                 $content_list_ds = common::get_datasource_by_sign(0, $page_type_detail['sign']);
                 $datasource_param = array();
                 if ($content_list_ds) {
                     $content_list_ds['argument'] = unserialize($content_list_ds['argument']);
                     $datasource_param = datasource_param($content_list_ds['argument']);
                 }
                 $plan['content_param']['site_id'] = $plan['site_id'];
                 $plan['content_param']['column_id'] = $plan['page_data_id'];
                 $plan['content_param']['count'] = $this->timecount;
                 $plan['content_param']['offset'] = $plan['offset'];
                 if ($content_list_ds) {
                     $content_list = common::get_content_by_datasource($content_list_ds['id'], $plan['content_param'] + $datasource_param);
                     //						print_r($content_list);
                 }
                 $new_plan = $plan;
                 unset($new_plan['id']);
                 $new_plan['offset'] = $offset;
                 $new_plan['count'] = $nextcount;
                 $new_plan['content_param'] = serialize($plan['content_param']);
                 if (empty($content_list)) {
                     $content_list = array(0 => array());
                     echo "没有可生成的内容";
                     exit;
                 } else {
                     if ($is_copy_plan) {
                         if (count($content_list) >= $this->settings['content_num_time']) {
                             $this->obj->insert('mkpublish_plan', $new_plan);
                         }
                     }
                 }
             }
             $index_cell = $this->content_cell($cell_ret, $mode_data, $content_list, $datasourceid, $page_type_detail);
             $tem_cell = $index_cell['tem_cell'];
             $tem_cell_file = $index_cell['tem_cell_file'];
             //				print_r($tem_cell);exit;
         }
     }
     //		$this->pagedir = '../cache/www/aaa/bbb/';
     foreach ($tem_cell as $kk => $vv) {
         $this->html = '';
         if ($this->mktype == 2) {
             //动态生成页面
             if (in_array($plan['content_type'], $this->content_type_true)) {
                 $this->include_conf($datasourceid, $site['site_dir'], $this->pagedir);
             } else {
                 $this->include_conf($datasourceid, $site['site_dir'], $tem_cell_file[$kk]['file_dir']);
             }
         } else {
             //静态生成页面
             $this->include_head($datasourceid, $site['site_dir']);
         }
         $parse_tem_cell_find = $parse_tem_cell_replace = array();
         if ($vv) {
             foreach ($vv as $k => $v) {
                 $parse_tem_cell_find[] = '/<span[\\s]+(?:id|class)="livcms_cell".+?>liv_' . $v['name'] . '<\\/span>/';
                 $parse_tem_cell_replace[] = $v['program'];
             }
             $new_template = preg_replace($parse_tem_cell_find, $parse_tem_cell_replace, $template);
         }
         $this->setHtml($new_template);
         //表示首页或者列表页
         if ($this->mktype == 2) {
             //动态生成页面
             if (in_array($plan['content_type'], $this->content_type_true)) {
                 file_in($this->pagedir, $this->filename . ".php", $this->html, true, true, $this->filename . ".html");
             } else {
                 file_in($tem_cell_file[$kk]['file_dir'], rtrim($tem_cell_file[$kk]['file_name'], '.html') . '.php', $this->html, true, true, rtrim($tem_cell_file[$kk]['file_name'], '.html') . '.html');
             }
         } else {
             //静态生成页面
             $cache_filename = md5(uniqid()) . '.php';
             file_put_contents(CUR_CONF_PATH . "cache/{$cache_filename}", $this->html);
             $result = $this->include_file(CUR_CONF_PATH . "cache/{$cache_filename}");
             chmod(CUR_CONF_PATH . "cache/{$cache_filename}", 0777);
             unlink(CUR_CONF_PATH . "cache/{$cache_filename}");
             if (in_array($plan['content_type'], $this->content_type_true)) {
                 if ($this->is_need_page) {
                     if ($this->plan['page_num']) {
                         $this->filename .= '_' . $this->plan['page_num'];
                     }
                 }
                 file_in($this->pagedir, $this->filename . ".html", $result, true, true, $this->filename . ".php");
             } else {
                 file_in($tem_cell_file[$kk]['file_dir'], $tem_cell_file[$kk]['file_name'], $result, true, true, rtrim($tem_cell_file[$kk]['file_name'], '.html') . '.php');
             }
         }
         echo "已生成" . $this->pagedir . $this->filename . ".html";
     }
 }
function mail_incident($id_inc, $id_usuario, $nota, $timeused, $mode, $public = 1)
{
    global $config;
    include_once $config["homedir"] . '/include/functions_user.php';
    include_once $config["homedir"] . '/include/functions_db.php';
    include_once $config["homedir"] . '/include/functions_db.mysql.php';
    clean_cache_db();
    $row = get_db_row("tincidencia", "id_incidencia", $id_inc);
    $group_name = get_db_sql("SELECT nombre FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $email_group = get_db_sql("SELECT email_group FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $forced_email = get_db_sql("SELECT forced_email FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $user_defect_group = get_db_sql("SELECT id_user_default FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $email_from = get_db_sql("SELECT email_from FROM tgrupo WHERE id_grupo = " . $row["id_grupo"]);
    $type_ticket = get_db_sql("SELECT name FROM tincident_type WHERE id = " . $row["id_incident_type"]);
    $titulo = $row["titulo"];
    $description = $row["descripcion"];
    $prioridad = get_priority_name($row["prioridad"]);
    $estado = render_status($row["estado"]);
    $resolution = render_resolution($row["resolution"]);
    $create_timestamp = $row["inicio"];
    $update_timestamp = $row["actualizacion"];
    $usuario = $row["id_usuario"];
    $creator = $row["id_creator"];
    $email_copy = $row["email_copy"];
    // Send email for owner and creator of this incident
    $email_creator = get_user_email($creator);
    $company_creator = get_user_company($creator, true);
    if (empty($company_creator)) {
        $company_creator = "";
    } else {
        $company_creator = " (" . reset($company_creator) . ")";
    }
    $email_owner = get_user_email($usuario);
    $company_owner = get_user_company($usuario, true);
    if (empty($company_owner)) {
        $company_owner = "";
    } else {
        $company_owner = " (" . reset($company_owner) . ")";
    }
    //check if user is disabled
    $owner_disabled = user_is_disabled($usuario);
    $creator_disabled = user_is_disabled($creator);
    $ticket_score = '';
    if ($row["estado"] == 7 and $row['score'] == 0) {
        $ticket_score = $config["base_url"] . "/index.php?sec=incidents&sec2=operation/incidents/incident_detail&id={$id_inc}";
        //$ticket_score =  '<a href="'.$config["base_url"].'"/index.php?sec=incidents&sec2=operation/incidents/incident_detail&id="'.$id_inc.'">'."Click hear to scoring".'</a>';
    }
    //name for fields
    $sql_name_custom = 'select ttf.label from tincident_field_data tfd, tincident_type_field ttf 
						where tfd.id_incident_field = ttf.id and tfd.id_incident=' . $id_inc . ';';
    $name_custom = get_db_all_rows_sql($sql_name_custom);
    if ($name_custom === false) {
        $name_custom = array();
    }
    foreach ($name_custom as $p) {
        //value according to the name of the custom fields
        $sql_value_custom = "select tfd.data from tincident_field_data tfd, tincident_type_field ttf \n\t\t\t\t\t\t\t where tfd.id_incident_field = ttf.id and tfd.id_incident=" . $id_inc . " and ttf.label='" . $p['label'] . "';";
        $value_custom = get_db_sql($sql_value_custom);
        $MACROS['_' . $p['label'] . '_'] = $value_custom;
    }
    $MACROS["_sitename_"] = $config["sitename"];
    $MACROS["_fullname_"] = dame_nombre_real($usuario);
    $MACROS["_username_"] = $usuario;
    $MACROS["_incident_id_"] = $id_inc;
    $MACROS["_incident_title_"] = $titulo;
    $MACROS["_creation_timestamp_"] = $create_timestamp;
    $MACROS["_update_timestamp_"] = $update_timestamp;
    $MACROS["_group_"] = $group_name;
    $MACROS["_author_"] = dame_nombre_real($creator) . $company_creator;
    $MACROS["_owner_"] = dame_nombre_real($usuario) . $company_owner;
    $MACROS["_priority_"] = $prioridad;
    $MACROS["_status_"] = $estado;
    $MACROS["_resolution_"] = $resolution;
    $MACROS["_time_used_"] = $timeused;
    $MACROS["_incident_main_text_"] = $description;
    $access_dir = empty($config['access_public']) ? $config["base_url"] : $config['public_url'];
    $MACROS["_access_url_"] = $access_dir . "/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id={$id_inc}";
    $MACROS["_incident_epilog_"] = $row["epilog"];
    $MACROS["_incident_closed_by_"] = $row["closed_by"];
    $MACROS["_type_tickets_"] = $type_ticket;
    // Resolve code for its name
    switch ($mode) {
        case 10:
            // Add Workunit
            //$subject = "[".$config["sitename"]."] Incident #$id_inc ($titulo) has a new workunit from [$id_usuario]";
            $company_wu = get_user_company($id_usuario, true);
            if (empty($company_wu)) {
                $company_wu = "";
            } else {
                $company_wu = " (" . reset($company_wu) . ")";
            }
            $MACROS["_wu_user_"] = dame_nombre_real($id_usuario) . $company_wu;
            $MACROS["_wu_text_"] = $nota;
            // Do not pass to safe_output. $nota is already HTML Safe in this point
            $temp_group = get_db_value('id_grupo', 'tgrupo', 'nombre', $group_name);
            $sql_body = "SELECT name FROM temail_template WHERE template_action = 7 AND id_group =" . $temp_group . ";";
            $sql_subject = "SELECT name FROM temail_template WHERE template_action = 6 AND id_group =" . $temp_group . ";";
            $templa_body = get_db_sql($sql_body);
            $templa_subj = get_db_sql($sql_subject);
            if (!$templa_body) {
                $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update_wu.tpl", $MACROS);
            } else {
                $text = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_body . ".tpl", $MACROS);
            }
            if (!$templa_subj) {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_new_wu.tpl", $MACROS);
            } else {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_subj . ".tpl", $MACROS);
            }
            break;
        case 0:
            // Incident update
            $attachments = "";
            $images = "";
            $temp_group = get_db_value('id_grupo', 'tgrupo', 'nombre', $group_name);
            $sql_body = "SELECT name FROM temail_template WHERE template_action = 9 AND id_group =" . $temp_group . ";";
            $sql_subject = "SELECT name FROM temail_template WHERE template_action = 8 AND id_group =" . $temp_group . ";";
            $templa_body = get_db_sql($sql_body);
            $templa_subj = get_db_sql($sql_subject);
            if (!$templa_body) {
                $text .= template_process($config["homedir"] . "/include/mailtemplates/incident_update.tpl", $MACROS);
            } else {
                $text .= template_process($config["homedir"] . "/include/mailtemplates/" . $templa_body . ".tpl", $MACROS);
            }
            if (!$templa_subj) {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_update.tpl", $MACROS);
            } else {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_subj . ".tpl", $MACROS);
            }
            $attached_files = get_db_all_rows_sql("SELECT * FROM tattachment WHERE id_incidencia=" . $id_inc);
            if ($attached_files === false) {
                $attached_files = array();
            }
            $i = 0;
            $j = 0;
            foreach ($attached_files as $file) {
                $file_name = $file['id_attachment'] . '_' . $file['filename'];
                $access_public = get_db_value("value", "tconfig", "token", "access_public");
                $access_protocol = get_db_value("value", "tconfig", "token", "access_protocol");
                if ($access_protocol) {
                    $protocol = "https://";
                } else {
                    $protocol = "http://";
                }
                $ext = strtolower(substr($file['filename'], -3, 3));
                if ($ext == "jpg" || $ext == "png" || $ext == "gif") {
                    $path_file = $protocol . $access_public . '/' . $config['baseurl'] . '/attachment/' . $file_name;
                    if ($j == 0) {
                        $images = $path_file;
                    } else {
                        $images .= ',' . $path_file;
                    }
                    $j++;
                } else {
                    $path_file = $config['homedir'] . "attachment/" . $file_name;
                    if ($i == 0) {
                        $attachments = $path_file;
                    } else {
                        $attachments .= ',' . $path_file;
                    }
                    $i++;
                }
            }
            break;
        case 1:
            // Incident creation
            $attachments = "";
            $images = "";
            $temp_group = get_db_value('id_grupo', 'tgrupo', 'nombre', $group_name);
            $sql_body = "SELECT name FROM temail_template WHERE template_action = 0 AND id_group =" . $temp_group . ";";
            $sql_subject = "SELECT name FROM temail_template WHERE template_action = 1 AND id_group =" . $temp_group . ";";
            $templa_body = get_db_sql($sql_body);
            $templa_subj = get_db_sql($sql_subject);
            if (!$templa_body) {
                $text .= template_process($config["homedir"] . "/include/mailtemplates/incident_create.tpl", $MACROS);
            } else {
                $text .= template_process($config["homedir"] . "/include/mailtemplates/" . $templa_body . ".tpl", $MACROS);
            }
            if (!$templa_subj) {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_create.tpl", $MACROS);
            } else {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_subj . ".tpl", $MACROS);
            }
            $attached_files = get_db_all_rows_sql("SELECT * FROM tattachment WHERE id_incidencia=" . $id_inc);
            if ($attached_files === false) {
                $attached_files = array();
            }
            $i = 0;
            $j = 0;
            foreach ($attached_files as $file) {
                $file_name = $file['id_attachment'] . '_' . $file['filename'];
                $access_public = get_db_value("value", "tconfig", "token", "access_public");
                $access_protocol = get_db_value("value", "tconfig", "token", "access_protocol");
                if ($access_protocol) {
                    $protocol = "https://";
                } else {
                    $protocol = "http://";
                }
                $ext = strtolower(substr($file['filename'], -3, 3));
                if ($ext == "jpg" || $ext == "png" || $ext == "gif") {
                    $path_file = $protocol . $access_public . '/' . $config['baseurl'] . '/attachment/' . $file_name;
                    if ($j == 0) {
                        $images = $path_file;
                    } else {
                        $images .= ',' . $path_file;
                    }
                    $j++;
                } else {
                    $path_file = $config['homedir'] . "attachment/" . $file_name;
                    if ($i == 0) {
                        $attachments = $path_file;
                    } else {
                        $attachments .= ',' . $path_file;
                    }
                    $i++;
                }
            }
            break;
        case 2:
            // New attach
            $attachments = "";
            $images = "";
            $temp_group = get_db_value('id_grupo', 'tgrupo', 'nombre', $group_name);
            $sql_body = "SELECT name FROM temail_template WHERE template_action = 9 AND id_group =" . $temp_group . ";";
            $sql_subject = "SELECT name FROM temail_template WHERE template_action = 4 AND id_group =" . $temp_group . ";";
            $templa_body = get_db_sql($sql_body);
            $templa_subj = get_db_sql($sql_subject);
            if (!$templa_body) {
                $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update.tpl", $MACROS);
            } else {
                $text = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_body . ".tpl", $MACROS);
            }
            if (!$templa_subj) {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_attach.tpl", $MACROS);
            } else {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_subj . ".tpl", $MACROS);
            }
            $attached_files = get_db_all_rows_sql("SELECT * FROM tattachment WHERE id_incidencia=" . $id_inc);
            if ($attached_files === false) {
                $attached_files = array();
            }
            $i = 0;
            $j = 0;
            foreach ($attached_files as $file) {
                $file_name = $file['id_attachment'] . '_' . $file['filename'];
                $access_public = get_db_value("value", "tconfig", "token", "access_public");
                $access_protocol = get_db_value("value", "tconfig", "token", "access_protocol");
                if ($access_protocol) {
                    $protocol = "https://";
                } else {
                    $protocol = "http://";
                }
                $ext = strtolower(substr($file['filename'], -3, 3));
                if ($ext == "jpg" || $ext == "png" || $ext == "gif") {
                    $path_file = $protocol . $access_public . '/' . $config['baseurl'] . '/attachment/' . $file_name;
                    if ($j == 0) {
                        $images = $path_file;
                    } else {
                        $images .= ',' . $path_file;
                    }
                    $j++;
                } else {
                    $path_file = $config['homedir'] . "attachment/" . $file_name;
                    if ($i == 0) {
                        $attachments = $path_file;
                    } else {
                        $attachments .= ',' . $path_file;
                    }
                    $i++;
                }
            }
            break;
        case 3:
            // Incident deleted
            $temp_group = get_db_value('id_grupo', 'tgrupo', 'nombre', $group_name);
            $sql_body = "SELECT name FROM temail_template WHERE template_action = 9 AND id_group =" . $temp_group . ";";
            $sql_subject = "SELECT name FROM temail_template WHERE template_action = 5 AND id_group =" . $temp_group . ";";
            $templa_body = get_db_sql($sql_body);
            $templa_subj = get_db_sql($sql_subject);
            if (!$templa_body) {
                $text = template_process($config["homedir"] . "/include/mailtemplates/incident_update.tpl", $MACROS);
            } else {
                $text = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_body . ".tpl", $MACROS);
            }
            if (!$templa_subj) {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_delete.tpl", $MACROS);
            } else {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_subj . ".tpl", $MACROS);
            }
            break;
        case 5:
            // Incident closed
            $MACROS["_ticket_score_"] = $ticket_score;
            $temp_group = get_db_value('id_grupo', 'tgrupo', 'nombre', $group_name);
            $sql_body = "SELECT name FROM temail_template WHERE template_action = 2 AND id_group =" . $temp_group . ";";
            $sql_subject = "SELECT name FROM temail_template WHERE template_action = 3 AND id_group =" . $temp_group . ";";
            $templa_body = get_db_sql($sql_body);
            $templa_subj = get_db_sql($sql_subject);
            if (!$templa_body) {
                $text = template_process($config["homedir"] . "/include/mailtemplates/incident_close.tpl", $MACROS);
            } else {
                $text = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_body . ".tpl", $MACROS);
            }
            if (!$templa_subj) {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/incident_subject_close.tpl", $MACROS);
            } else {
                $subject = template_process($config["homedir"] . "/include/mailtemplates/" . $templa_subj . ".tpl", $MACROS);
            }
            break;
    }
    // Create the TicketID for have a secure reference to incident hidden
    // in the message. Will be used for POP automatic processing to add workunits
    // to the incident automatically.
    if ($public != 7) {
        //owner
        $msg_code = "TicketID#{$id_inc}";
        $msg_code .= "/" . substr(md5($id_inc . $config["smtp_pass"] . $row["id_usuario"]), 0, 5);
        $msg_code .= "/" . $row["id_usuario"];
        integria_sendmail($email_owner, $subject, $text, $attachments, $msg_code, $email_from, 0, "", "X-Integria: no_process", $images);
        //creator
        if ($email_owner != $email_creator) {
            $msg_code = "TicketID#{$id_inc}";
            $msg_code .= "/" . substr(md5($id_inc . $config["smtp_pass"] . $row["id_creator"]), 0, 5);
            $msg_code .= "/" . $row["id_creator"];
            integria_sendmail($email_creator, $subject, $text, $attachments, $msg_code, $email_from, 0, "", "X-Integria: no_process", $images);
        }
        // Send emails to the people in the group added
        if ($forced_email != 0) {
            $email_default = get_user_email($user_defect_group);
            integria_sendmail($email_default, $subject, $text, $attachments, $msg_code, $email_from, 0, "", "X-Integria: no_process", $images);
            if ($email_group) {
                $email_g = explode(',', $email_group);
                foreach ($email_g as $k) {
                    integria_sendmail($k, $subject, $text, $attachments, $msg_code, $email_from, 0, "", "X-Integria: no_process", $images);
                }
            }
        }
    }
    if ($public == 7) {
        // Send a copy to each address in "email_copy"
        if ($email_copy != "") {
            $emails = explode(",", $email_copy);
            foreach ($emails as $em) {
                integria_sendmail($em, $subject, $text, $attachments, "", $email_from, 0, "", "X-Integria: no_process", $images);
            }
        }
    }
    if ($public == 1) {
        // Send email for all users with workunits for this incident
        $sql1 = "SELECT DISTINCT(tusuario.direccion), tusuario.id_usuario FROM tusuario, tworkunit, tworkunit_incident WHERE tworkunit_incident.id_incident = {$id_inc} AND tworkunit_incident.id_workunit = tworkunit.id AND tworkunit.id_user = tusuario.id_usuario AND tusuario.disabled=0";
        if ($result = mysql_query($sql1)) {
            while ($row = mysql_fetch_array($result)) {
                if ($row[0] != $email_owner and $row[0] != $email_creator) {
                    $msg_code = "TicketID#{$id_inc}";
                    $msg_code .= "/" . substr(md5($id_inc . $config["smtp_pass"] . $row[1]), 0, 5);
                    $msg_code .= "/" . $row[1];
                    integria_sendmail($row[0], $subject, $text, false, $msg_code, $email_from, 0, "", "X-Integria: no_process", $images);
                }
            }
        }
        // Send email to incident reporters associated to this incident
        if ($config['incident_reporter'] == 1) {
            $contacts = get_incident_contact_reporters($id_inc, true);
            if ($contats) {
                foreach ($contacts as $contact) {
                    $contact_email = get_db_sql("SELECT email FROM tcompany_contact WHERE fullname = '{$contact}'");
                    integria_sendmail($contact_email, $subject, $text, false, $msg_code, $email_from, 0, "", "X-Integria: no_process", $images);
                }
            }
        }
    }
}
<!DOCTYPE html>
<?php 
// In case then we show maintenance page in demo view
if (!isset($site_name)) {
    template_preprocess_maintenance_page($variables);
    extract($variables);
}
nikadevs_cms_preprocess_html($variables);
template_process_maintenance_page($variables);
template_process($variables, '');
extract($variables);
?>
<head>

  <?php 
print $head;
?>

  <title><?php 
print $head_title;
?>
</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <!-- Mobile Specific Metas
  ================================================== -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <?php 
print $styles;
?>