/**
  * Gets the url which can be used to download the document.
  *
  * @param int $version Not implemented. The content version of the document
  */
 function get_download_url($version = null)
 {
     $session = $this->ktapi->get_session();
     // Create the url that can be used to download the document
     $download_manager = new KTDownloadManager();
     $download_manager->set_session($session->session);
     $download_manager->cleanup();
     $url = $download_manager->allow_download($this);
     // Log the transaction
     $this->download();
     return $url;
 }
示例#2
0
 *
 */
if (!array_key_exists('code', $_GET)) {
    $msg = urlencode('Code not specified.');
    print "status_code=1&msg={$msg}";
    exit;
}
$hash = $_GET['code'];
if (!array_key_exists('d', $_GET)) {
    $msg = urlencode('Document not specified.');
    print "status_code=2&msg={$msg}";
    exit;
}
$document_id = $_GET['d'];
if (!array_key_exists('u', $_GET)) {
    $msg = urlencode('Session not specified.');
    print "status_code=3&msg={$msg}";
    exit;
}
$session = $_GET['u'];
require_once '../config/dmsDefaults.php';
require_once '../ktapi/ktapi.inc.php';
require_once 'KTDownloadManager.inc.php';
$download_manager = new KTDownloadManager();
$download_manager->set_session($session);
$response = $download_manager->download($document_id, $hash);
if (PEAR::isError($response)) {
    $msg = urlencode($response->getMessage());
    print "status_code=4&msg={$msg}";
    exit;
}
示例#3
0
function sendExternalEmails($aEmailAddresses, $iDocumentID, $sDocumentName, $sComment, &$aEmailErrors)
{
    global $default;
    $oSendingUser = User::get($_SESSION['userID']);
    // Create email content
    /*
        $sMessage = '<font face="arial" size="2">';
    	$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><br>';
        $sMsgEnd = '<br><br>' . _kt('Comments') . ':<br>' . $sComment;
    	$sMsgEnd .= '</font>';
    
    	$sTitle = sprintf(_kt("Link (ID %s): %s from %s"), $iDocumentID, $sDocumentName, $oSendingUser->getName());
    */
    $sTitle = sprintf(_kt("%s wants to share a document using KnowledgeTree"), $oSendingUser->getName());
    $sMessage = '<br>
	               &#160;&#160;&#160;&#160;' . _kt('Hello') . ',
	               <br />
	               <br />
	               &#160;&#160;&#160;&#160;' . sprintf(_kt('A KnowledgeTree user, %s, wants to share a document with you entitled "%s".'), $oSendingUser->getName(), $sDocumentName) . '
	               <br />
	               <br />
	               &#160;&#160;&#160;&#160;<b>' . _kt('Message') . ':</b>
	               <br />
	               <br />
	               &#160;&#160;&#160;&#160;' . $sComment . '
	               <br />
	               <br />
	               &#160;&#160;&#160;&#160;' . _kt('<b>KnowledgeTree is easy to use open source document management software</b><br />&#160;&#160;&#160;&#160;that helps businesses collaborate, securely store all critical documents, address<br />&#160;&#160;&#160;&#160;compliance challenges, and improve business processes.') . '
	               <br />
	               <br />';
    $sEmail = null;
    $sEmailFrom = null;
    $oConfig =& KTConfig::getSingleton();
    if (!$oConfig->get('email/sendAsSystem')) {
        $sEmail = $oSendingUser->getEmail();
        $sEmailFrom = $oSendingUser->getName();
    }
    $oEmail = new Email($sEmail, $sEmailFrom);
    $iCounter = 0;
    foreach ($aEmailAddresses as $sAddress) {
        if (validateEmailAddress($sAddress)) {
            // Add to list of addresses
            $sDestEmails .= empty($sDestEmails) ? $sAddress : ', ' . $sAddress;
            // Create uniqueish temporary session id
            $session = 'ktext_' . $iDocumentID . time() . $iCounter++;
            // Create download link
            $oDownloadManager = new KTDownloadManager();
            $oDownloadManager->set_session($session);
            $link = $oDownloadManager->allow_download($iDocumentID);
            //            $link = "<a href=\"{$link}\">{$link}</a>";
            $links = '&#160;&#160;&#160;&#160;<a href="http://www.knowledgetree.com/products">' . _kt('Learn More') . '</a>';
            $links .= "&#160;|&#160;<a href=\"{$link}\">" . _kt('View Document') . "</a>";
            $links .= '&#160;|&#160;<a href="http://www.knowledgetree.com/node/39">' . _kt('Download Free Trial') . '</a><br /><br />';
            //            $sMsg = $sMessage.$link.$sMsgEnd;
            $sMsg = $sMessage . $links;
            $res = $oEmail->send(array($sAddress), $sTitle, $sMsg);
            if (PEAR::isError($res)) {
                $default->log->error($res->getMessage());
                $aEmailErrors[] = $res->getMessage();
            } else {
                if ($res === false) {
                    $default->log->error("Error sending email ({$sTitle}) to {$sAddress}");
                    $aEmailErrors[] = "Error sending email ({$sTitle}) to {$sAddress}";
                }
            }
        }
        $default->log->info("Send email ({$sTitle}) to external addresses {$sDestEmails}");
        // emailed link transaction
        // need a document to do this.
        $oDocument =& Document::get($iDocumentID);
        $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Document link emailed to external addresses %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}");
        }
    }
}
示例#4
0
 * the terms of the GNU General Public License version 3 as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, 
 * California 94120-7775, or email info@knowledgetree.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * KnowledgeTree" logo and retain the original copyright notice. If the display of the 
 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
 * must display the words "Powered by KnowledgeTree" and retain the original 
 * copyright notice.
 * Contributor( s): ______________________________________
 *
 */
require_once '../config/dmsDefaults.php';
require_once 'KTUploadManager.inc.php';
$download_manager = new KTDownloadManager();
$download_manager->cleanup();
示例#5
0
 /**
  * Checkout a Document
  * params contains:
  * 		document_id			the id of the document
  * 		reason				the checkout reason
  *
  * @param array $params
  *
  */
 function checkout_document($params)
 {
     $responseType = 'kt_response';
     $kt =& $this->KT;
     $document =& $kt->get_document_by_id($params['document_id']);
     if (PEAR::isError($document)) {
         $this->addError("checkout_document - cannot get documentid {$params['document_id']} - " . $document->getMessage());
         $this->setResponse(array('status_code' => 1, 'message' => $document->getMessage()));
         return;
     }
     $result = $document->checkout($params['reason']);
     if (PEAR::isError($result)) {
         $this->addError($result->getMessage());
         $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage()));
         return;
     }
     $url = '';
     if ($params['download']) {
         $download_manager = new KTDownloadManager();
         $download_manager->set_session($params['session_id']);
         $download_manager->cleanup();
         $url = $download_manager->allow_download($document);
     }
     $this->setResponse(array('status_code' => 0, 'message' => $url));
 }
示例#6
0
 /**
  * Returns a reference to a file to be downloaded.
  *
  * @param string $session_id
  * @param int $document_id
  * @return kt_response. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS
  */
 function download_document($session_id, $document_id, $version = null)
 {
     $this->debug("download_document('{$session_id}',{$document_id})");
     $kt =& $this->get_ktapi($session_id);
     if (is_array($kt)) {
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_response", $kt);
     }
     $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
     $document =& $kt->get_document_by_id($document_id);
     if (PEAR::isError($document)) {
         $response['message'] = $document->getMessage();
         $this->debug("download_document - cannot get {$document_id} - " . $document->getMessage(), $session_id);
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_response", $response);
     }
     $result = $document->download();
     if (PEAR::isError($result)) {
         $response['message'] = $result->getMessage();
         $this->debug("download_document - cannot download - " . $result->getMessage(), $session_id);
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_response", $response);
     }
     $session =& $kt->get_session();
     $download_manager = new KTDownloadManager();
     $download_manager->set_session($session->session);
     $download_manager->cleanup();
     $url = $download_manager->allow_download($document);
     $response['status_code'] = KTWS_SUCCESS;
     $response['message'] = $url;
     return new SOAP_Value('return', "{urn:{$this->namespace}}kt_response", $response);
 }
示例#7
0
 /**
  * Returns a reference to a file to be downloaded.
  *
  * @author KnowledgeTree Team
  * @access public
  * @param int $document_id
  * @return kt_response.
  */
 public function download_document($document_id, $version = null)
 {
     $document =& $this->get_document_by_id($document_id);
     if (PEAR::isError($document)) {
         $response['status_code'] = 1;
         $response['message'] = $document->getMessage();
         return $response;
     }
     $result = $document->download();
     if (PEAR::isError($result)) {
         $response['status_code'] = 1;
         $response['message'] = $result->getMessage();
         return $response;
     }
     $session =& $this->get_session();
     $download_manager = new KTDownloadManager();
     $download_manager->set_session($session->session);
     $download_manager->cleanup();
     $url = $download_manager->allow_download($document);
     $response['status_code'] = 0;
     $response['results'] = urlencode($url);
     return $response;
 }
示例#8
0
 */
if (!array_key_exists('code', $_GET)) {
    $msg = urlencode('Code not specified.');
    print "status_code=1&msg={$msg}";
    exit;
}
$hash = $_GET['code'];
if (!array_key_exists('d', $_GET)) {
    $msg = urlencode('Document not specified.');
    print "status_code=2&msg={$msg}";
    exit;
}
$document_id = $_GET['d'];
if (!array_key_exists('u', $_GET)) {
    $msg = urlencode('Session not specified.');
    print "status_code=3&msg={$msg}";
    exit;
}
$session = $_GET['u'];
$apptype = isset($_GET['apptype']) ? $_GET['apptype'] : 'ws';
require_once '../config/dmsDefaults.php';
require_once '../ktapi/ktapi.inc.php';
require_once 'KTDownloadManager.inc.php';
$download_manager = new KTDownloadManager();
$download_manager->set_session($session);
$response = $download_manager->download($document_id, $hash, null, $apptype);
if (PEAR::isError($response)) {
    $msg = urlencode($response->getMessage());
    print "status_code=4&msg={$msg}:" . $_GET["u"] . ":" . $_GET["d"] . ":" . $_GET["code"] . ":" . $_GET["apptype"] . ":";
    exit;
}