Example #1
0
 public function details($order_id = null)
 {
     $data['order'] = $this->order_model->get_order_by_id($order_id);
     if (user_is_customer() and $data['order']->user_email != get_user_email()) {
         redirect('user/login');
     }
     $this->load->view('templates/header', $data);
     $this->load->view('order/order_details', $data);
     $this->load->view('templates/footer', $data);
 }
Example #2
0
/**
 * Sends an email to a group.
 *
 * If the group doesn't have an email configured, the email is only sent
 * to the default user.
 *
 * @param int Group id.
 * @param string Email subject.
 * @param string Email body.
 */
function send_group_email($id_group, $subject, $body)
{
    $group = get_db_row("tgrupo", "id_grupo", $id_group);
    $name = $group['nombre'];
    $email = $group['email'];
    /* If the group has no email, use the email of the risponsable */
    if ($email == '') {
        $email = get_user_email($group['id_user_default']);
    }
    integria_sendmail($email, $subject, $body);
}
/**
 * Sends an email to a group.
 *
 * If the group doesn't have an email configured, the email is only sent
 * to the default user.
 *
 * @param int Group id.
 * @param string Email subject.
 * @param string Email body.
 */
function send_group_email($id_group, $subject, $body)
{
    $group = get_db_row("tgrupo", "id_grupo", $id_group);
    $name = $group['nombre'];
    $emails_group = $group['email_group'];
    $emails_forced_email = $group['forced_email'];
    /* If the group has no email, use the email of the risponsable */
    $email = get_user_email($group['id_user_default']);
    integria_sendmail($email, $subject, $body, false, "", $group['email_from']);
    if ($emails_group == '') {
        $email_group = explode(',', $emails_group);
        foreach ($email_group as $k) {
            integria_sendmail($k, $subject, $body, false, "", $group['email_from']);
        }
    }
}
Example #4
0
<?php

require_once '../lib/config.php';
require_once '../lib/func/comm.func.php';
require_once '../lib/func/admin.func.php';
require_once '../lib/class/node.class.php';
require_once '../lib/class/invite_code.class.php';
//检测是否登录,若没登录则转向登录界面
if (!isset($_COOKIE['admin_name']) || !isset($_COOKIE['admin_uid']) || !isset($_COOKIE['admin_pwd'])) {
    header("Location:login.php");
    exit;
} else {
    //co
    $uid = $_COOKIE['admin_uid'];
    $admin_name = $_COOKIE['admin_name'];
    $admin_pwd = $_COOKIE['admin_pwd'];
    $admin_email = get_user_email($uid);
    //验证cookie
    $pw = get_user_pass($uid);
    $pw = co_pw($pw);
    if ($pw != $admin_pwd) {
        header("Location:login.php");
    }
}
//admin config
$admin_title = "管理中心";
Example #5
0
function user_email()
{
    echo get_user_email();
}
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);
}
                <td>
                    <?php 
    echo $fellow->roll_number;
    ?>
                </td>
                <td class="text-right">
                    <a target="_blank" target="_blank" href="<?php 
    echo "http://www.formstack.com/forms/?1263698-rWnaydsUyH&staff_avanti_pin=" . get_user_email() . "&fellow_roll_number=" . $fellow->roll_number;
    ?>
">Submit a Goal</a>
                </td>
                <td class="text-right">
                    <a target="_blank" href="<?php 
    echo "http://www.formstack.com/forms/?1258004-7GdhAtYPy4&staff_avanti_pin=" . get_user_email() . "&fellow_roll_number=" . $fellow->roll_number;
    ?>
">Submit a Monthly Report</a></td>
                <td class="text-right">
                    <a target="_blank" href="<?php 
    echo "http://www.formstack.com/forms/?1255471-EGG2QhnkpU&staff_avanti_pin=" . get_user_email() . "&fellow_roll_number=" . $fellow->roll_number;
    ?>
">Submit an Interaction</a></td>
                <!--                http://www.formstack.com/forms/?1255471-EGG2QhnkpU&staff_avanti_pin=abhgupta@iitk.ac.in&fellow_roll_number=55555-->

            </tr>
                <?php 
}
?>
            </tbody>
        </table>
    </div>
</div>
Example #8
0
function resend_password($user)
{
    $user = sanitize($user);
    $password = randomPassword();
    $email = get_user_email($user);
    $id = get_user_id($user);
    $user = get_user_by_id($id);
    $to = $email;
    $toName = $user[0] . " " . $user[1];
    $subject = get_text('Title') . ': ' . get_text('New_password');
    $message = get_text('Dear') . ' ' . $user[0] . ",\n\t\t<p>\n\t\t\t" . get_text('New_user_credentials') . ":\n\t\t\t<br />\n\t\t\t" . get_text('Username') . ": " . $user[2] . "\n\t\t\t<br />\n\t\t\t" . get_text('Password') . ": " . $password . "\n\t\t</p>" . get_text('Mail_footer');
    mailFromProject($to, $toName, $subject, $message);
    $hashed_password = password_hash($password, PASSWORD_DEFAULT);
    mysql_query("UPDATE user SET Password = '******' WHERE ID = {$id}");
    return get_text('New_password_send');
}
Example #9
0
<?php

require_once '../lib/config.php';
require_once '../lib/func/comm.func.php';
require_once '../lib/func/user.func.php';
//检测是否登录,若没登录则转向登录界面
if (!isset($_COOKIE['user_name']) || !isset($_COOKIE['user_uid']) || !isset($_COOKIE['user_pwd'])) {
    header("Location:login.php");
    exit;
} else {
    //co
    $uid = $_COOKIE['user_uid'];
    $user_name = $_COOKIE['user_name'];
    $user_pwd = $_COOKIE['user_pwd'];
    $user_email = get_user_email($uid);
    //验证cookie
    $pw = get_user_pass($uid);
    $pw = co_pw($pw);
    if ($pw != $user_pwd) {
        header("Location:login.php");
    }
}
$oo = new Ss\User\Ss($uid);
Example #10
0
function mail_todo($mode, $id_todo)
{
    global $config;
    $todo = get_db_row("ttodo", "id", $id_todo);
    $tcreated = $todo["created_by_user"];
    $tassigned = $todo["assigned_user"];
    // Only send mails when creator is different than owner
    if ($tassigned == $tcreated) {
        return;
    }
    $tlastupdate = $todo["last_update"];
    $tdescription = wordwrap($todo["description"], 70, "\n");
    $tprogress = translate_wo_status($todo["progress"]);
    $tpriority = get_priority_name($todo["priority"]);
    $tname = $todo["name"];
    $url = $config["base_url"] . "/index.php?sec=todo&sec2=operation/todo/todo&operation=update&id={$id_todo}";
    switch ($mode) {
        case 0:
            // Add
            $text = "TO-DO '{$tname}' has been CREATED by user {$tcreated}. You could track this todo in the following URL (need to use your credentials): {$url}\n\n";
            $subject = "[" . $config["sitename"] . "] New TO-DO from '{$tcreated}' : {$tname}";
            break;
        case 1:
            // Update
            $text = "TO-DO '{$tname}' has been UPDATED by user {$tassigned}. This TO-DO was created by user {$tcreated}. You could track this todo in the following URL (need to use your credentials): {$url}\n\n";
            $subject = "[" . $config["sitename"] . "] Updated TO-DO from '{$tcreated}' : {$tname}";
            break;
        case 2:
            // Delete
            $text = "TO-DO '{$tname}' has been DELETED by user {$tassigned}. This TO-DO was created by user {$tcreated}. You could track this todo in the following URL (need to use your credentials): {$url}\n\n";
            $subject = "[" . $config["sitename"] . "] Deleted TO-DO from '{$tcreated}' : {$tname}";
    }
    $text .= "\n\t\t---------------------------------------------------------------------\n\t\tTO-DO NAME  : {$tname}\n\t\tDATE / TIME : {$tlastupdate}\n\t\tCREATED BY  : {$tcreated}\n\t\tASSIGNED TO : {$tassigned}\n\t\tPROGRESS    : {$tprogress}\n\t\tPRIORITY    : {$tpriority}\n\t\tDESCRIPTION\n\t\t---------------------------------------------------------------------\n\t\t{$tdescription}\n\n";
    $text = ascii_output($text);
    $subject = ascii_output($subject);
    // Send an email to both
    integria_sendmail(get_user_email($tcreated), $subject, $text);
    integria_sendmail(get_user_email($tassigned), $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");
                }
            }
        }
    }
}
Example #12
0
        alert_set('success', 'Настройки сохранены');
        header('Location:options.php');
        break;
    case 'save_team':
        save_user_team($_POST['team_id'], $_POST['new_team_name']);
        if ($_POST['team_id'] || $_POST['new_team_name']) {
            $am = new AchievementsManager((int) $_SESSION['user_id']);
            $am->emit(EventTypes::JOINED_TEAM);
        }
        alert_set('success', 'Настройки сохранены');
        header('Location:options.php');
        break;
    case 'readonly_on':
        set_readonly_on();
        header('Location:options.php');
        break;
    case 'readonly_off':
        set_readonly_off();
        header('Location:options.php');
        break;
    default:
        check_logged();
        $mgr = new UserOptionsManager();
        $smarty->assign('meta', $mgr->get_all_options(true));
        $smarty->assign('current_email', get_user_email($_SESSION['user_id']));
        $smarty->assign('current_name', get_user_shown_name($_SESSION['user_id']));
        $smarty->assign('teams', get_team_list());
        $smarty->assign('user_team', get_user_team($_SESSION['user_id']));
        $smarty->display('options.tpl');
}
log_timing();
Example #13
0
 * ============================================================================
*/
define('IN_QISHI', true);
require_once dirname(__FILE__) . '/../include/common.inc.php';
require_once QISHI_ROOT_PATH . 'include/mysql.class.php';
require_once QISHI_ROOT_PATH . 'include/fun_user.php';
$db = new mysql($dbhost, $dbuser, $dbpass, $dbname);
unset($dbhost, $dbuser, $dbpass, $dbname);
if ($_SESSION['input_token_subscribe'] != "" && $_SESSION['input_token_subscribe'] == $_POST['input_token_subscribe']) {
    $setsqlarr['email'] = trim($_POST['email']) ? trim($_POST['email']) : showmsg("请填写接收邮箱!", 1);
    $setsqlarr['search_name'] = trim($_POST['search_name']);
    $setsqlarr['district'] = trim($_POST['district_id']);
    $setsqlarr['district_cn'] = trim($_POST['district_cn']) ? trim($_POST['district_cn']) : showmsg("请填写意向地区!", 1);
    $setsqlarr['days'] = intval($_POST['days']) ? intval($_POST['days']) : showmsg("请选择发送周期!", 1);
    $setsqlarr['addtime'] = time();
    $ck_email = get_user_email(strtolower($_POST['email']));
    if ($ck_email) {
        $db->updatetable(table('jobs_subscribe'), $setsqlarr, " email='" . strtolower($_POST['email']) . "' ");
    } else {
        $insertid = $db->inserttable(table('jobs_subscribe'), $setsqlarr);
    }
    send_subscribe_jobs($setsqlarr);
    $link[0]['text'] = "返回";
    $link[0]['href'] = 'index.php';
    showmsg("恭喜您订阅成功!", 2, $link);
} else {
    showmsg("非法操作!", 1);
}
function get_user_email($email)
{
    global $db;
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);
                }
            }
        }
    }
}
echo $_POST['action'];
switch ($action) {
    case 'get_user_details':
        get_user_details();
        break;
    case 'get_permission':
        get_permission();
        break;
    case 'save_user_details':
        save_user_details();
        break;
    case 'logout_user':
        logout_user();
        break;
    case 'get_user_email':
        get_user_email();
        break;
    case 'getfd':
        get_full_details();
        break;
    case 'reset':
        clear_session();
        break;
    case 'chgpfl':
        update_profile_details();
        break;
    case 'get_files':
        get_files();
        break;
}
function save_user_details()
Example #16
0
 $stmt->close();
 $forum_title = stripslashes($forum_title);
 $f_cur_topic_title = $forum_title;
 echo "<hr>";
 //For Testing
 echo "List of users that have posted in this topic along with thier emails<br><br>";
 //Get User Ids based on forum topic id
 //Only sends one email per user except the user currently posting
 //Use Join to get the original posters email
 $query_get_uids = "\n\t\t\t\t\tSELECT * FROM (\n\t\t\t\t\t\t(\n\t\t\t\t\t\tSELECT fpr_user_id AS F_UID\n\t\t\t\t\t\tFROM " . $db_table_prefix . "forum_posts_replys \n\t\t\t\t\t\tWHERE fpr_post_id = '{$f_topic_id}' \n\t\t\t\t\t\tAND subcribe_email = 'YES'\n\t\t\t\t\t\tAND NOT fpr_user_id = '{$f_cur_usr_id}'\n\t\t\t\t\t\tGROUP BY fpr_user_id\n\t\t\t\t\t\tORDER BY fpr_timestamp DESC\n\t\t\t\t\t\t)\n\t\t\t\t\t\tUNION ALL\n\t\t\t\t\t\t(\n\t\t\t\t\t\tSELECT forum_user_id AS F_UID\n\t\t\t\t\t\tFROM " . $db_table_prefix . "forum_posts\n\t\t\t\t\t\tWHERE forum_post_id = '{$f_topic_id}'\n\t\t\t\t\t\tAND subcribe_email = 'YES'\n\t\t\t\t\t\tAND NOT forum_user_id = '{$f_cur_usr_id}'\n\t\t\t\t\t\tGROUP BY forum_user_id\n\t\t\t\t\t\tORDER BY forum_timestamp DESC\n\t\t\t\t\t\t) \n                    ) AS uniontable\n\t\t\t\t\tGROUP BY `F_UID`\n                    ORDER BY `F_UID` ASC\n\t\t\t\t";
 if ($result_get_uids = $mysqli->query($query_get_uids)) {
     $arr_get_uids = $result_get_uids->fetch_all(MYSQLI_BOTH);
     foreach ($arr_get_uids as $row_get_uids) {
         $f_topic_get_user_id = $row_get_uids['F_UID'];
         $f_topic_get_user_name = get_user_name_2($f_topic_get_user_id);
         $f_topic_get_email = get_user_email($f_topic_get_user_id);
         $f_cur_user_name = get_user_name_2($userIdme);
         //Format the content with bbcode
         require_once 'models/bbParser.php';
         $parser = new bbParser();
         $forum_content = $parser->getHtml($forum_content);
         echo "Username: {$f_topic_get_user_name} AND UserID: {$f_topic_get_user_id} AND UserEmail: OK";
         //Send user an email notification
         //Start of mail
         $adminmail = $f_topic_get_email;
         $usersub = "{$websiteName} - Forum - {$f_cur_user_name} replied to {$f_cur_topic_title}";
         $usermsg = "{$websiteName} - Forum Notification\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tCategory: {$f_cur_topic_cat}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTopic: {$f_cur_topic_title}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tReply by: {$f_cur_user_name}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tReply Content:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t************************<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$forum_content}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br>************************";
         $usermsg2 = " You may check the reply at <a href={$redir_link_url}>{$redir_link_url}</a>";
         $username = "******";
         //Mail file that setup the email and sends it based on input above
         require "models/mail.php";