Ejemplo n.º 1
0
 function postValidate()
 {
     global $default;
     $oDocument =& $this->aInfo["document"];
     // fire subscription alerts for the checked in document
     $oSubscriptionEvent = new SubscriptionEvent();
     $oFolder = Folder::get($oDocument->getFolderID());
     $oSubscriptionEvent->ArchivedDocument($oDocument, $oFolder);
 }
Ejemplo n.º 2
0
 function archive($oDocument, $sReason)
 {
     if ($oDocument->isSymbolicLink()) {
         return PEAR::raiseError(_kt("It is not possible to archive a shortcut. Please archive the target document."));
     }
     // Ensure the action is not blocked
     if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.archive')) {
         return PEAR::raiseError(_kt('Document cannot be archived as it is restricted by the workflow.'));
     }
     $oDocument->setStatusID(ARCHIVED);
     $res = $oDocument->update();
     if (PEAR::isError($res) || $res === false) {
         return PEAR::raiseError(_kt('There was a database error while trying to archive this file'));
     }
     //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.SymbolicLinkArchived", array('user_name' => $this->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, sprintf(_kt('Document archived: %s'), $sReason), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('archive', '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();
             return $ret;
         }
     }
     // fire subscription alerts for the archived document
     $oSubscriptionEvent = new SubscriptionEvent();
     $oFolder = Folder::get($oDocument->getFolderID());
     $oSubscriptionEvent->ArchivedDocument($oDocument, $oFolder);
     return true;
 }