<?php

$alertEmailAddress = new AlertEmailAddress();
$alertDaysInAdvance = new AlertDaysInAdvance();
$emailAddressArray = $alertEmailAddress->allAsArray();
$daysInAdvanceArray = $alertDaysInAdvance->allAsArray();
echo "<div class='adminRightHeader'>" . _("Alert Settings") . "</div>";
if (count($emailAddressArray) > 0) {
    ?>
			<table class='linedDataTable'>
				<tr>
				<th style='width:100%;'><?php 
    echo _("Email Address");
    ?>
</th>
				<th style='width:20px;'>&nbsp;</th>
				<th style='width:20px;'>&nbsp;</th>
				</tr>
				<?php 
    foreach ($emailAddressArray as $emailAddress) {
        echo "<tr>";
        echo "<td>" . $emailAddress['emailAddress'] . "</td>";
        echo "<td><a href='ajax_forms.php?action=getAdminAlertEmailForm&alertEmailAddressID=" . $emailAddress['alertEmailAddressID'] . "&height=128&width=260&modal=true' class='thickbox'><img src='images/edit.gif' alt='" . _("edit") . "' title='" . _("edit") . "'></a></td>";
        echo "<td><a href='javascript:deleteAlert(\"AlertEmailAddress\", " . $emailAddress['alertEmailAddressID'] . ");'><img src='images/cross.gif' alt='" . _("remove") . "' title='" . _("remove") . "'></a></td>";
        echo "</tr>";
    }
    ?>
			</table>
			<?php 
} else {
    echo _("(none found)") . "<br />";
Esempio n. 2
0
        //get resources that fit this criteria
        if (is_numeric($alertDays->daysInAdvanceNumber)) {
            foreach ($alertDays->getResourcesToAlert() as $resource) {
                $resourceIDArray[] = $resource->resourceID;
            }
        }
    }
    if (count($resourceIDArray) > 0) {
        //now get unique resource IDs out
        $resourceIDArray = array_unique($resourceIDArray);
        //now loop through each resource and send the email alert
        foreach ($resourceIDArray as $resourceID) {
            $resource = new Resource(new NamedArguments(array('primaryKey' => $resourceID)));
            $sendToArray = array();
            //determine who to send the email to
            $alertEmailAddress = new AlertEmailAddress();
            foreach ($alertEmailAddress->allAsArray() as $alertEmail) {
                $sendToArray[] = $alertEmail['emailAddress'];
            }
            //formulate email to be sent
            $email = new Email();
            $email->to = implode(", ", $sendToArray);
            $email->message = $util->createMessageFromTemplate('Alert', $resourceID, $resource->titleText, '', '', '');
            $email->subject = "CORAL Alert: " . $resource->titleText;
            $email->send();
        }
    } else {
        echo "No Resources found fitting alert day criteria";
    }
} else {
    echo "Alerts not enabled in configuration.ini file";
<?php

$alertEmailAddressID = $_POST['alertEmailAddressID'];
$emailAddress = $_POST['emailAddress'];
if ($alertEmailAddressID != '') {
    $instance = new AlertEmailAddress(new NamedArguments(array('primaryKey' => $alertEmailAddressID)));
} else {
    $instance = new AlertEmailAddress();
}
$instance->emailAddress = $emailAddress;
try {
    $instance->save();
} catch (Exception $e) {
    echo $e->getMessage();
}