Example #1
0
function exchangesync_syncItems($cal, $user, $user_id, $entries_sync)
{
    global $alert_admin, $alerts;
    global $systemurl;
    global $entryObj;
    global $created_items, $deleted_items;
    // "Returns"
    global $area;
    // Build where statement for query and add items that needs to be created
    $entries_new = array();
    $delete_where = array();
    foreach ($entries_sync as $entry_id => $entry) {
        // Only create new if the user is still assigned to entry
        if (isset($entry['user_assigned'][$user_id])) {
            //$entry = getEntry($entry['entry_id']); // Need more information
            templateAssignEntry('entryObj', $entry);
            $rooms = $entryObj->room . ' (' . $area[$entry['area_id']] . ')';
            // Add the entry to list of items
            $i = $cal->createCalendarItems_addItem(utf8_encode($entryObj->entry_name), exchangesync_getEntryCalendarDescription($systemurl, $entryObj), date('c', $entryObj->time_start), date('c', $entryObj->time_end), array('ReminderIsSet' => false, 'Location' => utf8_encode($rooms)), $user['user_ews_sync_email']);
            $entries_new[$i] = $entry['entry_id'];
        }
        // Delete this entry for this user
        $delete_where[] = '(`entry_id` = \'' . $entry_id . '\' && `user_id` = \'' . $user_id . '\')';
    }
    // Delete in Exchange
    $Q_sync = mysql_query("select * from `entry_exchangesync`\n\t\tWHERE " . implode(' || ', $delete_where));
    $deleted_items = array();
    while ($R_sync = mysql_fetch_assoc($Q_sync)) {
        try {
            $deleted_item = $cal->deleteItem($R_sync['exchange_id']);
            $deleted_items[$R_sync['entry_id']] = $deleted_item;
            printout($R_sync['entry_id'] . ' deleted');
        } catch (Exception $e) {
            printout('Exception - deleteItem - ' . $R_sync['entry_id'] . ': ' . $e->getMessage());
            $alert_admin = true;
            $alerts[] = 'deleteItem exception';
        }
    }
    // Delete all the exchangesync data
    $Q_sync = mysql_query("delete from `entry_exchangesync`\n\t\tWHERE " . implode(' || ', $delete_where));
    printout_mysqlerror();
    // Create the new items
    $created_items = array();
    try {
        if (count($entries_new)) {
            $created_items = $cal->createCalendarItems();
        } else {
            printout('No calendar items to be created');
        }
    } catch (Exception $e) {
        printout('Exception - createCalendarItems: ' . $e->getMessage() . '<br />');
        $alert_admin = true;
        $alerts[] = 'createCalendarItems exception: ' . $e->getMessage();
    }
    foreach ($created_items as $i => $ids) {
        if (!is_null($ids['Id'])) {
            $entry = $entries_sync[$entries_new[$i]];
            printout($entries_new[$i] . ' created.');
            // Inserting in sync
            mysql_query("INSERT INTO `entry_exchangesync` (\n\t\t\t\t`entry_id` ,\n\t\t\t\t`exchange_id` ,\n\t\t\t\t`exchange_changekey`,\n\t\t\t\t`user_id`,\n\t\t\t\t`entry_rev`,\n\t\t\t\t`sync_from`,\n\t\t\t\t`sync_to`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . $entry['entry_id'] . "' , \n\t\t\t\t'" . $ids['Id'] . "', \n\t\t\t\t'" . $ids['ChangeKey'] . "',\n\t\t\t\t'" . $user_id . "',\n\t\t\t\t'" . $entry['rev_num'] . "',\n\t\t\t\t'" . $entry['time_start'] . "',\n\t\t\t\t'" . $entry['time_end'] . "'\n\t\t\t);");
            printout_mysqlerror();
        } else {
            if ($ids['ResponseMessage']->ResponseCode == 'ErrorCreateItemAccessDenied') {
                // Alert admin, alert user and disable sync
                emailSend($user_id, 'Ikke tilgang til kalender', exchangesync_getUsermsgAccessDenied($systemurl));
                mysql_query("UPDATE `users` SET `user_ews_sync` = '0' WHERE `user_id` =" . $user_id);
                printout($entries_new[$i] . ' not created. User ' . $user_id . ' has access denied error when creating items. Has disabled the sync of this user. Message from Exchange: ' . $ids['ResponseMessage']->MessageText);
                $alert_admin = true;
                $alerts[] = $entries_new[$i] . ' not created. User ' . $user_id . ' has access denied error when creating items. Has disabled the sync of this user. Message from Exchange: ' . $ids['ResponseMessage']->MessageText;
            } else {
                // Unknown error, alert admin
                printout($entries_new[$i] . ' not created: ' . print_r($ids['ResponseMessage'], true));
                $alert_admin = true;
                $alerts[] = $entries_new[$i] . ' not created. Message from Exchange: ' . $ids['ResponseMessage']->MessageText;
            }
        }
    }
}
Example #2
0
<?php

require_once "email-send/email-send.php";
$to = array();
$to[] = array("email" => $_POST['inputEmail'], "nome" => "Usuário");
$subject = "Relação de condomínios";
$title = "Relação de condomínios";
$message = "Veja a relação de condomínios que recebem o nosso jornal.<br /><br />";
$message = "<strong>Segue em anexo</strong>";
$response = emailSend($to, $subject, $title, $message, "../../arquivos/gypa-news-2015.xls");
if (!isset($response["erro"])) {
    exit(false);
}
exit(!$response["erro"]);
Example #3
0
                 }
             }
         } else {
             // Generate key and valid_to
             $key = sha1(microtime(true) . mt_rand(10000, 90000));
             $valid_to = time() + 60 * 15;
             // 15 min
             mysql_query("\n\t\t\t\t\tupdate `users`\n\t\t\t\t\tset \n\t\t\t\t\t\tuser_newpassword_key = '{$key}',\n\t\t\t\t\t\tuser_newpassword_validto = '{$valid_to}'\n\t\t\t\t\twhere\n\t\t\t\t\t\tuser_id = '{$user_id}'");
             $smarty = new Smarty();
             templateAssignSystemvars('smarty');
             $smarty->assign('forgot_pw_user', $user);
             $smarty->assign('key', $key);
             $smarty->assign('valid_to', $valid_to);
             $message = $smarty->fetch('file:mail-forgot_pw.tpl');
             $subject = 'Glemt passord - J&aerligmuseets bookingsystem';
             emailSend($user_id, $subject, $message);
         }
     } else {
         $forgot_pw_failed = true;
     }
 }
 echo '<html>' . chr(10) . '<head>' . chr(10) . '	<title>' . __('JM-booking') . ' - ' . __('Log in') . '</title>' . chr(10) . '	<link rel="stylesheet" href="css/jm-booking.css" type="text/css">' . chr(10) . '	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' . chr(10) . '	<script type="text/javascript" src="js/browser_detection.js"></script>' . chr(10) . '</head>' . chr(10) . '<body>' . chr(10);
 echo '<br><br><br><br>' . chr(10) . chr(10);
 echo $testSystem['msgLogin'];
 echo '<table ' . 'style="border:0px solid #0000ff; border-collapse:collapse;" ' . 'align="center" ' . 'cellspacing="0" ' . 'cellpadding="0">' . chr(10);
 '	<tr>' . chr(10);
 if ($forgot_pw_keyfound) {
     echo '		<td align="center" style="border:1px solid #0000ff; padding: 30px; width: 600px;" colspan="2">' . chr(10);
 } else {
     echo '		<td align="center" style="border:1px solid #0000ff; padding: 30px; width: 300px;">' . chr(10);
 }
Example #4
0
                exchangesync_analyzeSync($entries, $cal_ids, $cal, $user, $user_id);
                // Sync any entries removed from this user that has been synced earlier
                foreach ($sync as $entry_id => $R_sync) {
                    // => Sync
                    $entries_sync[$entry_id] = getEntry($entry_id);
                }
                // Sync items
                printout(count($entries_sync) . ' items to be synced to Exchange');
                if (count($entries_sync)) {
                    exchangesync_syncItems($cal, $user, $user_id, $entries_sync);
                }
            }
        } catch (Exception $e) {
            if ($e->getMessage() == 'getCalendarItems failed. ResponseClass: Error. ResponseCode: ErrorFolderNotFound. Message: The specified folder could not be found in the store.') {
                // Alert admin, alert user and disable sync
                emailSend($user_id, 'Ikke tilgang til kalender', exchangesync_getUsermsgAccessDenied($systemurl));
                mysql_query("UPDATE `users` SET `user_ews_sync` = '0' WHERE `user_id` =" . $user_id);
                $msg = 'User ' . $user_id . ' has access denied error when getting calendar items. Has disabled the sync of this user. Message from Exchange: ' . $e->getMessage();
                printout($msg);
                $alert_admin = true;
                $alerts[] = $msg;
            } else {
                // Unknown error, alert admin
                printout('Exception during user ' . $user_id . ': ' . $e->getMessage());
                $alert_admin = true;
                $alerts[] = 'Exception during user ' . $user_id . ': ' . $e->getMessage();
            }
        }
    }
} catch (Exception $e) {
    printout('Exception: ' . $e->getMessage());
Example #5
0
function emailSendEntryUndeleted($entry, $user_id)
{
    global $smarty;
    if (!isUserDeactivated($user_id)) {
        $smarty = new Smarty();
        templateAssignEntry('smarty', $entry);
        templateAssignSystemvars('smarty');
        $message = $smarty->fetch('file:mail-entry-undeleted.tpl');
        $subject = "[booking]" . $entry['entry_id'] . ' ' . date('d.m.Y', $entry['time_start']) . ' Gjenopprettet - ' . $entry['entry_name'];
        emailSend($user_id, $subject, $message);
    }
}
Example #6
0
function emailSendEntryUserDeleted($entry, $rev_num, $user_id)
{
    global $smarty;
    $smarty = new Smarty();
    templateAssignEntry('smarty', $entry);
    templateAssignSystemvars('smarty');
    templateAssignEntryChanges('smarty', $entry, $rev_num);
    $message = $smarty->fetch('file:mail-entry-userdeleted.tpl');
    $subject = "[booking]" . $entry['entry_id'] . ' ' . date('d.m.Y', $entry['time_start']) . ' Ikke lenger vert';
    emailSend($user_id, $subject, $message);
}
Example #7
0
<?php

require_once "email-send/email-send.php";
$to = array();
$to[] = array("email" => "*****@*****.**", "nome" => "Kayo Almeida");
$subject = "Contato via site";
$title = "Contato via site";
$message = "<strong>Nome: </strong>" . $_POST["inputName"];
$message = "<strong>E-mail: </strong>" . $_POST["inputEmail"];
$message = "<strong>Mensagem<br /> </strong>" . $_POST["textArea"];
$response = emailSend($to, $subject, $title, $message);
var_dump($response);
if (!isset($response["erro"])) {
    exit(false);
}
exit(!$response["erro"]);
Example #8
0
/**
 * Send an email with selected template
 */
function email_tpl_send($template = "generic/email", $to, $subject, $body, $from = null, $from_name = null, $attachment = null)
{
    $tpl = new TPL();
    $tpl->assign("body", $body);
    $body = $tpl->draw($template, true);
    return emailSend($to, $subject, $body, $from, $from_name, $attachment);
}