<?php

require_once __DIR__ . "/../class/EmailAlert.class.php";
if (isset($_GET)) {
    $EmailAlert = new EmailAlert();
    $EmailAlert->setEmail($_GET['email']);
    $EmailAlert->removeEmail();
    header("location:/alert.admin.php?event=deleted");
}
<?php

require_once __DIR__ . "/autoload/session.autoload.php";
require_once __DIR__ . "/autoload/checkconnected-admin.autoload.php";
require_once __DIR__ . "/class/Module.class.php";
require_once __DIR__ . "/class/EmailAlert.class.php";
$EmailAlert = new EmailAlert();
?>

<!DOCTYPE html>
<html>
<head>
  <?php 
require_once __DIR__ . "/template/headcode.template.php";
?>

  <script type="text/javascript" src="js/alert.admin.js"></script>
<body>

    <?php 
include __DIR__ . "/template/header.template.php";
?>

    <div class="container sub-body">
      <div class="controls text-align-center margin-top-1 big-text">

      	<?php 
if (isset($_GET['event'])) {
    if ($_GET['event'] == 'added') {
        echo '<div class="alert alert-success">Adresse ajoutée !</div>';
    } else {
 function sendNotification($aUsers, $eventType, $targetName, $objectId, $parentId)
 {
     $content = new SubscriptionContent();
     // needed for i18n
     //$aUsers = $this->_getSubscribers($oDocument->getId(), $this->subscriptionTypes["Document"]);
     $locationName = Folder::generateFullFolderPath($parentId);
     $userId = $_SESSION['userID'];
     foreach ($aUsers as $oSubscriber) {
         $emailAddress = $oSubscriber->getEmail();
         if ($oSubscriber->getEmailNotification() && !empty($emailAddress)) {
             // notification object first.
             $aNotificationOptions = array();
             $aNotificationOptions['target_user'] = $oSubscriber->getID();
             $aNotificationOptions['actor_id'] = $userId;
             $aNotificationOptions['target_name'] = $targetName;
             $aNotificationOptions['location_name'] = $locationName;
             $aNotificationOptions['object_id'] = $objectId;
             $aNotificationOptions['event_type'] = $eventType;
             $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
             // now the email content.
             $emailContent = $content->getEmailAlertContent($oNotification);
             $emailSubject = $content->getEmailAlertSubject($oNotification);
             $oEmail = new EmailAlert($emailAddress, $emailSubject, $emailContent);
             $oEmail->send();
         }
     }
 }
<?php

require_once __DIR__ . "/../class/EmailAlert.class.php";
if (isset($_POST)) {
    $EmailAlert = new EmailAlert();
    $EmailAlert->setEmail($_POST['email']);
    $EmailAlert->addEmail();
    header("location:/alert.admin.php?event=added");
}
Esempio n. 5
0
 function &newNotificationForDocument($oDocument, $oUser, $oState, $oActor, $sComments)
 {
     $aInfo = array();
     $aInfo['sData1'] = $oState->getName();
     $aInfo['sData2'] = $sComments;
     $aInfo['iData1'] = $oDocument->getId();
     $aInfo['iData2'] = $oActor->getId();
     $aInfo['sType'] = 'ktcore/workflow';
     $aInfo['dCreationDate'] = getCurrentDateTime();
     $aInfo['iUserId'] = $oUser->getId();
     $aInfo['sLabel'] = $oDocument->getName();
     $oNotification = KTNotification::createFromArray($aInfo);
     $handler = new KTWorkflowNotification();
     if ($oUser->getEmailNotification() && strlen($oUser->getEmail()) > 0) {
         $emailContent = $handler->handleNotification($oNotification);
         $emailSubject = sprintf(_kt('Workflow Notification: %s'), $oDocument->getName());
         $oEmail = new EmailAlert($oUser->getEmail(), $emailSubject, $emailContent);
         $oEmail->send();
     }
     return $oNotification;
 }
 function delete($oDocument, $sReason, $iDestFolderId = null)
 {
     // use the deleteSymbolicLink function is this is a symlink
     if ($oDocument->isSymbolicLink()) {
         return KTDocumentUtil::deleteSymbolicLink($oDocument);
     }
     $oDocument =& KTUtil::getObject('Document', $oDocument);
     if (is_null($iDestFolderId)) {
         $iDestFolderId = $oDocument->getFolderID();
     }
     $oStorageManager =& KTStorageManagerUtil::getSingleton();
     global $default;
     if (count(trim($sReason)) == 0) {
         return PEAR::raiseError(_kt('Deletion requires a reason'));
     }
     if (PEAR::isError($oDocument) || $oDocument == false) {
         return PEAR::raiseError(_kt('Invalid document object.'));
     }
     if ($oDocument->getIsCheckedOut() == true) {
         return PEAR::raiseError(sprintf(_kt('The document is checked out and cannot be deleted: %s'), $oDocument->getName()));
     }
     if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.delete')) {
         return PEAR::raiseError(_kt('Document cannot be deleted as it is restricted by the workflow.'));
     }
     // IF we're deleted ...
     if ($oDocument->getStatusID() == DELETED) {
         return true;
     }
     $oOrigFolder = Folder::get($oDocument->getFolderId());
     DBUtil::startTransaction();
     // flip the status id
     $oDocument->setStatusID(DELETED);
     // $iDestFolderId is DEPRECATED.
     $oDocument->setFolderID(null);
     $oDocument->setRestoreFolderId($oOrigFolder->getId());
     $oDocument->setRestoreFolderPath(Folder::generateFolderIDs($oOrigFolder->getId()));
     $res = $oDocument->update();
     if (PEAR::isError($res) || $res == false) {
         DBUtil::rollback();
         return PEAR::raiseError(_kt('There was a problem deleting the document from the database.'));
     }
     // now move the document to the delete folder
     $res = $oStorageManager->delete($oDocument);
     if (PEAR::isError($res) || $res == false) {
         //could not delete the document from the file system
         $default->log->error('Deletion: Filesystem error deleting document ' . $oDocument->getFileName() . ' from folder ' . Folder::getFolderPath($oDocument->getFolderID()) . ' id=' . $oDocument->getFolderID());
         // we use a _real_ transaction here ...
         DBUtil::rollback();
         /*
         //reverse the document deletion
         $oDocument->setStatusID(LIVE);
         $oDocument->update();
         */
         return PEAR::raiseError(_kt('There was a problem deleting the document from storage.'));
     }
     // get the user object
     $oUser = User::get($_SESSION['userID']);
     //delete all shortcuts linking to this document
     $aSymlinks = $oDocument->getSymbolicLinks();
     foreach ($aSymlinks as $aSymlink) {
         $oShortcutDocument = Document::get($aSymlink['id']);
         $oOwnerUser = User::get($oShortcutDocument->getOwnerID());
         KTDocumentUtil::deleteSymbolicLink($aSymlink['id']);
         //send an email to the owner of the shortcut
         if ($oOwnerUser->getEmail() != null && $oOwnerUser->getEmailNotification() == true) {
             $emailTemplate = new EmailTemplate("kt3/notifications/notification.SymbolicLinkDeleted", array('user_name' => $oUser->getName(), 'url' => KTUtil::ktLink(KTBrowseUtil::getUrlForDocument($oShortcutDocument)), 'title' => $oShortcutDocument->getName()));
             $email = new EmailAlert($oOwnerUser->getEmail(), _kt("KnowledgeTree Notification"), $emailTemplate->getBody());
             $email->send();
         }
     }
     $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document deleted: ') . $sReason, 'ktcore.transactions.delete');
     $oDocumentTransaction->create();
     $oDocument->setFolderID(1);
     DBUtil::commit();
     // we weren't doing notifications on this one
     $oSubscriptionEvent = new SubscriptionEvent();
     $oSubscriptionEvent->RemoveDocument($oDocument, $oOrigFolder);
     // document is now deleted:  triggers are best-effort.
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('delete', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array('document' => $oDocument);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
         if (PEAR::isError($ret)) {
             $oDocument->delete();
             // FIXME nbm: review that on-fail => delete is correct ?!
             return $ret;
         }
     }
 }
Esempio n. 7
0
 function &newNotificationForDocument($oDocument, $oUser, $oActor, $sSubject, $sDetails)
 {
     $aInfo = array();
     $aInfo['sData1'] = $sSubject;
     $aInfo['sText1'] = $sDetails;
     $aInfo['iData1'] = $oDocument->getId();
     $aInfo['iData2'] = $oActor->getId();
     $aInfo['sType'] = 'ktcore/assist';
     $aInfo['dCreationDate'] = getCurrentDateTime();
     $aInfo['iUserId'] = $oUser->getId();
     $aInfo['sLabel'] = $oDocument->getName();
     $oNotification = KTNotification::createFromArray($aInfo);
     $handler = new KTAssistNotification();
     if ($oUser->getEmailNotification() && strlen($oUser->getEmail()) > 0) {
         $emailContent = $handler->handleNotification($oNotification);
         $emailSubject = sprintf(_kt('Assistance request: %s'), $oDocument->getName());
         $oEmail = new EmailAlert($oUser->getEmail(), $emailSubject, $emailContent);
         $oEmail->send();
     }
     return $oNotification;
 }