示例#1
0
function makeSchemaReplace($text)
{
    global $usr;
    $text = str_replace("%rr_member_name%", $usr['username'], $text);
    $text = str_replace("%cachename%", getCachename($_REQUEST['reportid']), $text);
    return $text;
}
示例#2
0
function notifyOwner($cacheid, $msgType)
{
    // msgType - 0 = cache accepted, 1 = cache declined (=archived)
    global $stylepath, $usr, $octeam_email, $site_name, $absolute_server_URI, $octeamEmailsSignature;
    $user_id = getCacheOwnerId($cacheid);
    $cachename = getCachename($cacheid);
    if ($msgType == 0) {
        $email_content = file_get_contents($stylepath . '/email/activated_cache.email');
    } else {
        $email_content = file_get_contents($stylepath . '/email/archived_cache.email');
    }
    $email_headers = "Content-Type: text/plain; charset=utf-8\r\n";
    $email_headers .= "From: {$site_name} <{$octeam_email}>\r\n";
    $email_headers .= "Reply-To: {$octeam_email}\r\n";
    $email_content = mb_ereg_replace('{server}', $absolute_server_URI, $email_content);
    $email_content = mb_ereg_replace('{cachename}', $cachename, $email_content);
    $email_content = mb_ereg_replace('{cacheid}', $cacheid, $email_content);
    $email_content = mb_ereg_replace('{octeamEmailsSignature}', $octeamEmailsSignature, $email_content);
    $email_content = mb_ereg_replace('{cacheArchived_01}', tr('cacheArchived_01'), $email_content);
    $email_content = mb_ereg_replace('{cacheArchived_02}', tr('cacheArchived_02'), $email_content);
    $email_content = mb_ereg_replace('{cacheArchived_03}', tr('cacheArchived_03'), $email_content);
    $email_content = mb_ereg_replace('{cacheArchived_04}', tr('cacheArchived_04'), $email_content);
    $email_content = mb_ereg_replace('{cacheArchived_05}', tr('cacheArchived_05'), $email_content);
    $email_content = mb_ereg_replace('{Cacheactivated_01}', tr('Cacheactivated_01'), $email_content);
    $email_content = mb_ereg_replace('{Cacheactivated_02}', tr('Cacheactivated_02'), $email_content);
    $email_content = mb_ereg_replace('{Cacheactivated_03}', tr('Cacheactivated_03'), $email_content);
    $email_content = mb_ereg_replace('{Cacheactivated_04}', tr('Cacheactivated_04'), $email_content);
    $email_content = mb_ereg_replace('{Cacheactivated_05}', tr('Cacheactivated_05'), $email_content);
    $owner_email = XDb::xMultiVariableQueryValue("SELECT `email` FROM `user` WHERE `user_id`= :1 LIMIT 1", '', $user_id);
    if ($msgType == 0) {
        //send email to owner
        mb_send_mail($owner_email['email'], tr('viewPending_01') . ": " . $cachename, $email_content, $email_headers);
        //send email to approver
        mb_send_mail($usr['email'], tr('viewPending_01') . ": " . $cachename, tr('viewPending_02') . ":\n" . $email_content, $email_headers);
        // generate automatic log about status cache
        $log_text = tr("viewPending_03");
        $log_uuid = create_uuid();
        XDb::xSql("INSERT INTO `cache_logs`\n                (`id`, `cache_id`, `user_id`, `type`, `date`, `text`, `text_html`, `text_htmledit`, `date_created`, `last_modified`, `uuid`, `node`,`encrypt`)\n            VALUES ('', ?, ?, '12', NOW(), ?, '0', '0', NOW(), NOW(), ?, '2', '0')", $cacheid, $usr['userid'], $log_text, $log_uuid);
    } else {
        //send email to owner
        mb_send_mail($owner_email['email'], tr('viewPending_04') . ": " . $cachename, $email_content, $email_headers);
        //send email to approver
        mb_send_mail($usr['email'], tr('viewPending_04') . ": " . $cachename, tr('viewPending_05') . ":\n" . $email_content, $email_headers);
        // generate automatic log about status cache
        $log_text = tr("viewPending_06");
        $log_uuid = create_uuid();
        XDb::xSql("INSERT INTO `cache_logs`\n                (`id`, `cache_id`, `user_id`, `type`, `date`, `text`, `text_html`, `text_htmledit`, `date_created`, `last_modified`, `uuid`, `node`,`encrypt`)\n            VALUES ('', ?, ?, ?, NOW(), ?, ?, ?, NOW(), NOW(), ?, ?, ?)", $cacheid, $usr['userid'], 12, $log_text, 0, 0, $log_uuid, 2, 0);
    }
}