コード例 #1
0
 function do_cleanup()
 {
     $folder = KTUtil::arrayGet($_REQUEST, 'folder');
     if (is_null($folder)) {
         exit(redirect(generateControllerLink('dashboard')));
     }
     $oRegistry =& KTPluginRegistry::getSingleton();
     $oPlugin =& $oRegistry->getPlugin('ktcore.housekeeper.plugin');
     // we must avoid doing anything to the documents folder at all costs!
     $folder = HouseKeeper::getDirectory($folder);
     if (is_null($folder) || !$folder['canClean']) {
         exit(redirect(generateControllerLink('dashboard')));
     }
     HouseKeeper::cleanDirectory($folder['folder'], $folder['pattern']);
     HouseKeeper::getKTUsageStats();
     exit(redirect(generateControllerLink('dashboard')));
 }
コード例 #2
0
 function do_main()
 {
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $aOptions = array();
     $iVersion = KTUtil::arrayGet($_REQUEST, 'version');
     session_write_close();
     if ($iVersion) {
         $oVersion = KTDocumentContentVersion::get($iVersion);
         $aOptions['version'] = sprintf('%d.%d', $oVersion->getMajorVersionNumber(), $oVersion->getMinorVersionNumber());
         $res = $oStorage->downloadVersion($this->oDocument, $iVersion);
     } else {
         $res = $oStorage->download($this->oDocument);
     }
     if ($res === false) {
         $this->addErrorMessage(_kt('The file you requested is not available - please contact the system administrator if this is incorrect.'));
         redirect(generateControllerLink('viewDocument', sprintf(_kt('fDocumentId=%d'), $this->oDocument->getId())));
         exit(0);
     }
     $oDocumentTransaction =& new DocumentTransaction($this->oDocument, _kt('Document downloaded'), 'ktcore.transactions.download', $aOptions);
     $oDocumentTransaction->create();
     // fire subscription alerts for the downloaded document
     $oKTConfig =& KTConfig::getSingleton();
     $bNotifications = $oKTConfig->get('export/enablenotifications', 'on') == 'on' ? true : false;
     if ($bNotifications) {
         $oSubscriptionEvent = new SubscriptionEvent();
         $oFolder = Folder::get($this->oDocument->getFolderID());
         $oSubscriptionEvent->DownloadDocument($this->oDocument, $oFolder);
     }
     exit(0);
 }
コード例 #3
0
 function _actionhelper($aActionTuple)
 {
     $aTuple = array("label" => $aActionTuple["name"]);
     if ($aActionTuple["action"]) {
         $aTuple["url"] = generateControllerLink($aActionTuple["action"], $aActionTuple["query"]);
     } else {
         if ($aActionTuple["url"]) {
             $sUrl = $aActionTuple["url"];
             $sQuery = KTUtil::arrayGet($aActionTuple, 'query');
             if ($sQuery) {
                 $sUrl = KTUtil::addQueryString($sUrl, $sQuery);
             }
             $aTuple["url"] = $sUrl;
         } else {
             if ($aActionTuple["query"]) {
                 $aTuple['url'] = KTUtil::addQueryStringSelf($aActionTuple["query"]);
             } else {
                 $aTuple["url"] = false;
             }
         }
     }
     return $aTuple;
 }
コード例 #4
0
ファイル: notify.php プロジェクト: 5haman/knowledgetree
 function clearAll()
 {
     $this->startTransaction();
     $aNotifications = KTNotification::getList('user_id = ' . $this->oUser->getId());
     foreach ($aNotifications as $oNotification) {
         $res = $oNotification->delete();
         if (PEAR::isError($res)) {
             $this->rollbackTransaction();
             $this->addErrorMessage(_kt('Failed to clear notifications.'));
             exit(redirect(generateControllerLink('dashboard')));
         }
     }
     $this->commitTransaction();
     $this->addInfoMessage(_kt('Notifications cleared.'));
     exit(redirect(generateControllerLink('dashboard')));
 }
コード例 #5
0
ファイル: KTEmail.php プロジェクト: sfsergey/knowledgetree
function sendEmailHyperlink($aDestEmailAddress, $iDocumentID, $sDocumentName, $sComment, &$aEmailErrors)
{
    global $default;
    // Get the email list as a string for the logs
    $sDestEmails = implode(',', $aDestEmailAddress);
    $oSendingUser = User::get($_SESSION['userID']);
    $sMessage = '<font face="arial" size="2">';
    /*
    if ($sDestUserName) {
        $sMessage .= $sDestUserName . ',<br><br>';
    }
    */
    $sMessage .= sprintf(_kt("Your colleague, %s, wishes you to view the document entitled '%s'."), $oSendingUser->getName(), $sDocumentName);
    $sMessage .= " \n";
    $sMessage .= _kt('Click on the hyperlink below to view it.') . '<br>';
    // add the link to the document to the mail
    $sMessage .= '<br>' . generateControllerLink('viewDocument', "fDocumentID={$iDocumentID}", $sDocumentName, true);
    // add optional comment
    if (strlen($sComment) > 0) {
        $sMessage .= '<br><br>' . _kt('Comments') . ':<br>' . $sComment;
    }
    $sMessage .= '</font>';
    $sTitle = sprintf(_kt("Link (ID %s): %s from %s"), $iDocumentID, $sDocumentName, $oSendingUser->getName());
    //email the hyperlink
    //
    $sEmail = null;
    $sEmailFrom = null;
    $oConfig =& KTConfig::getSingleton();
    if (!$oConfig->get('email/sendAsSystem')) {
        $sEmail = $oSendingUser->getEmail();
        $sEmailFrom = $oSendingUser->getName();
    }
    $oEmail = new Email($sEmail, $sEmailFrom);
    $res = $oEmail->send($aDestEmailAddress, $sTitle, $sMessage);
    if (PEAR::isError($res)) {
        $default->log->error($res->getMessage());
        $aEmailErrors[] = $res->getMessage();
        return $res;
    } else {
        if ($res === false) {
            $default->log->error("Error sending email ({$sTitle}) to {$sDestEmails}");
            $aEmailErrors[] = "Error sending email ({$sTitle}) to {$sDestEmails}";
            return PEAR::raiseError(sprintf(_kt("Error sending email (%s) to %s"), $sTitle, $sDestEmails));
        } else {
            $default->log->info("Send email ({$sTitle}) to {$sDestEmails}");
        }
    }
    // emailed link transaction
    // need a document to do this.
    $oDocument =& Document::get($iDocumentID);
    $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Document link emailed to %s. "), $sDestEmails) . $sComment, 'ktcore.transactions.email_link');
    if ($oDocumentTransaction->create()) {
        $default->log->debug("emailBL.php created email link document transaction for document ID={$iDocumentID}");
    } else {
        $default->log->error("emailBL.php couldn't create email link document transaction for document ID={$iDocumentID}");
    }
}
コード例 #6
0
 /**
  * Method for downloading the document as a pdf.
  *
  * @deprecated
  * @return true on success else false
  */
 function do_pdfdownload_deprecated()
 {
     $oDocument = $this->oDocument;
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $oConfig =& KTConfig::getSingleton();
     $default = realpath(str_replace('\\', '/', KT_DIR . '/../openoffice/program'));
     putenv('ooProgramPath=' . $oConfig->get('openoffice/programPath', $default));
     $cmdpath = KTUtil::findCommand('externalBinary/python');
     // Check if openoffice and python are available
     if ($cmdpath == false || !file_exists($cmdpath) || empty($cmdpath)) {
         // Set the error messsage and redirect to view document
         $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. Python binary not found.'));
         redirect(generateControllerLink('viewDocument', sprintf('fDocumentId=%d', $oDocument->getId())));
         exit(0);
     }
     //get the actual path to the document on the server
     $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $oStorage->getPath($oDocument));
     if (file_exists($sPath)) {
         // Get a tmp file
         $sTempFilename = tempnam('/tmp', 'ktpdf');
         // We need to handle Windows differently - as usual ;)
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             $cmd = "\"" . $cmdpath . "\" \"" . KT_DIR . "/bin/openoffice/pdfgen.py\" \"" . $sPath . "\" \"" . $sTempFilename . "\"";
             $cmd = str_replace('/', '\\', $cmd);
             // TODO: Check for more errors here
             // SECURTIY: Ensure $sPath and $sTempFilename are safe or they could be used to excecute arbitrary commands!
             // Excecute the python script. TODO: Check this works with Windows
             $res = `"{$cmd}" 2>&1`;
             //print($res);
             //print($cmd);
             //exit;
         } else {
             // TODO: Check for more errors here
             // SECURTIY: Ensure $sPath and $sTempFilename are safe or they could be used to excecute arbitrary commands!
             // Excecute the python script.
             $cmd = $cmdpath . ' ' . KT_DIR . '/bin/openoffice/pdfgen.py ' . escapeshellcmd($sPath) . ' ' . escapeshellcmd($sTempFilename);
             $res = shell_exec($cmd . " 2>&1");
             //print($res);
             //print($cmd);
             //exit;
         }
         // Check the tempfile exists and the python script did not return anything (which would indicate an error)
         if (file_exists($sTempFilename) && $res == '') {
             $mimetype = 'application/pdf';
             $size = filesize($sTempFilename);
             $name = substr($oDocument->getFileName(), 0, strrpos($oDocument->getFileName(), '.')) . '.pdf';
             KTUtil::download($sTempFilename, $mimetype, $size, $name);
             // Remove the tempfile
             unlink($sTempFilename);
             // Create the document transaction
             $oDocumentTransaction =& new DocumentTransaction($oDocument, 'Document downloaded as PDF', 'ktcore.transactions.download', $aOptions);
             $oDocumentTransaction->create();
             // Just stop here - the content has already been sent.
             exit(0);
         } else {
             // Set the error messsage and redirect to view document
             $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. ' . $res));
             redirect(generateControllerLink('viewDocument', sprintf('fDocumentId=%d', $oDocument->getId())));
             exit(0);
         }
     } else {
         // Set the error messsage and redirect to view document
         $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. The path to the document did not exist.'));
         redirect(generateControllerLink('viewDocument', sprintf('fDocumentId=%d', $oDocument->getId())));
         exit(0);
     }
 }
コード例 #7
0
 function resolveNotification($oKTNotification)
 {
     $notify_action = KTUtil::arrayGet($_REQUEST, 'notify_action', null);
     if ($notify_action == 'clear') {
         $_SESSION['KTInfoMessage'][] = _kt('Workflow Notification cleared.');
         $oKTNotification->delete();
         exit(redirect(generateControllerLink('dashboard')));
     }
     $params = 'fDocumentId=' . $oKTNotification->getIntData1();
     $url = generateControllerLink('viewDocument', $params);
     //$oKTNotification->delete(); // clear the alert.
     exit(redirect($url));
 }
コード例 #8
0
ファイル: KTDashlets.php プロジェクト: 5haman/knowledgetree
 function getDocumentLink($oDocument)
 {
     return generateControllerLink('viewDocument', 'fDocumentId=' . $oDocument->getId());
 }
コード例 #9
0
ファイル: KTAssist.php プロジェクト: 5haman/knowledgetree
 function notify_view()
 {
     $params = 'fDocumentId=' . $this->oNotification->getIntData1();
     $url = generateControllerLink('viewDocument', $params);
     // $this->oNotification->delete(); // clear the alert.
     exit(redirect($url));
 }