Commit 1a750644add54c03973f75f2548a0f44aa795a58
1 parent
48338aea
Updated session management to allow for additional webservice apptypes for compa…
…tibility with the Office Addin. Committed by: Megan Watson Reviewed by: Martin Kirsten
Showing
4 changed files
with
30 additions
and
27 deletions
ktapi/KTAPISession.inc.php
| @@ -282,7 +282,7 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -282,7 +282,7 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 282 | 282 | ||
| 283 | if ($validateSession) | 283 | if ($validateSession) |
| 284 | { | 284 | { |
| 285 | - $sql = "SELECT count(*) >= u.max_sessions as over_limit FROM active_sessions ass INNER JOIN users u ON ass.user_id=u.id WHERE ass.user_id = $user_id AND ass.apptype != 'ws'"; | 285 | + $sql = "SELECT count(*) >= u.max_sessions as over_limit FROM active_sessions ass INNER JOIN users u ON ass.user_id=u.id WHERE ass.user_id = $user_id AND ass.apptype = 'webapp'"; |
| 286 | $row = DBUtil::getOneResult($sql); | 286 | $row = DBUtil::getOneResult($sql); |
| 287 | 287 | ||
| 288 | if (PEAR::isError($row)) | 288 | if (PEAR::isError($row)) |
| @@ -301,9 +301,9 @@ class KTAPI_UserSession extends KTAPI_Session | @@ -301,9 +301,9 @@ class KTAPI_UserSession extends KTAPI_Session | ||
| 301 | 301 | ||
| 302 | $session = session_id(); | 302 | $session = session_id(); |
| 303 | $newSessionRequired = false; | 303 | $newSessionRequired = false; |
| 304 | - if ($app == 'ws') | 304 | + if ($app != 'webapp') |
| 305 | { | 305 | { |
| 306 | - $sql = "select id from active_sessions where user_id=$user_id AND apptype='ws' and ip='$ip'"; | 306 | + $sql = "select id from active_sessions where user_id=$user_id AND apptype='$app' and ip='$ip'"; |
| 307 | 307 | ||
| 308 | $row = DBUtil::getOneResult($sql); | 308 | $row = DBUtil::getOneResult($sql); |
| 309 | if (empty($row)) | 309 | if (empty($row)) |
ktwebservice/KTDownloadManager.inc.php
| @@ -132,7 +132,7 @@ class KTDownloadManager | @@ -132,7 +132,7 @@ class KTDownloadManager | ||
| 132 | * | 132 | * |
| 133 | * @access public | 133 | * @access public |
| 134 | */ | 134 | */ |
| 135 | - function download($document_id, $hash, $version = null) | 135 | + function download($document_id, $hash, $version = null, $apptype = 'ws') |
| 136 | { | 136 | { |
| 137 | $sql = "SELECT 1 FROM download_files WHERE hash=? AND session=? AND document_id=?"; | 137 | $sql = "SELECT 1 FROM download_files WHERE hash=? AND session=? AND document_id=?"; |
| 138 | $rows = DBUtil::getResultArray(array($sql, array($hash, $this->session, $document_id))); | 138 | $rows = DBUtil::getResultArray(array($sql, array($hash, $this->session, $document_id))); |
| @@ -156,7 +156,7 @@ class KTDownloadManager | @@ -156,7 +156,7 @@ class KTDownloadManager | ||
| 156 | $storage =& KTStorageManagerUtil::getSingleton(); | 156 | $storage =& KTStorageManagerUtil::getSingleton(); |
| 157 | 157 | ||
| 158 | $ktapi = &new KTAPI(); | 158 | $ktapi = &new KTAPI(); |
| 159 | - $res = $ktapi->get_active_session($this->session); | 159 | + $res = $ktapi->get_active_session($this->session, null, $apptype); |
| 160 | if (PEAR::isError($res)) | 160 | if (PEAR::isError($res)) |
| 161 | { | 161 | { |
| 162 | return $res; | 162 | return $res; |
ktwebservice/download.php
| @@ -8,31 +8,31 @@ | @@ -8,31 +8,31 @@ | ||
| 8 | * Document Management Made Simple | 8 | * Document Management Made Simple |
| 9 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. | 9 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. |
| 10 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 10 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 11 | - * | 11 | + * |
| 12 | * This program is free software; you can redistribute it and/or modify it under | 12 | * This program is free software; you can redistribute it and/or modify it under |
| 13 | * the terms of the GNU General Public License version 3 as published by the | 13 | * the terms of the GNU General Public License version 3 as published by the |
| 14 | * Free Software Foundation. | 14 | * Free Software Foundation. |
| 15 | - * | 15 | + * |
| 16 | * This program is distributed in the hope that it will be useful, but WITHOUT | 16 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 18 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 18 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 19 | * details. | 19 | * details. |
| 20 | - * | 20 | + * |
| 21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | - * | ||
| 24 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 23 | + * |
| 24 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 25 | * California 94120-7775, or email info@knowledgetree.com. | 25 | * California 94120-7775, or email info@knowledgetree.com. |
| 26 | - * | 26 | + * |
| 27 | * The interactive user interfaces in modified source and object code versions | 27 | * The interactive user interfaces in modified source and object code versions |
| 28 | * of this program must display Appropriate Legal Notices, as required under | 28 | * of this program must display Appropriate Legal Notices, as required under |
| 29 | * Section 5 of the GNU General Public License version 3. | 29 | * Section 5 of the GNU General Public License version 3. |
| 30 | - * | 30 | + * |
| 31 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 31 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 32 | * these Appropriate Legal Notices must retain the display of the "Powered by | 32 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 33 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 33 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 34 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 34 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 35 | - * must display the words "Powered by KnowledgeTree" and retain the original | 35 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 36 | * copyright notice. | 36 | * copyright notice. |
| 37 | * Contributor( s): ______________________________________ | 37 | * Contributor( s): ______________________________________ |
| 38 | * | 38 | * |
| @@ -64,6 +64,7 @@ if (!array_key_exists('u',$_GET)) | @@ -64,6 +64,7 @@ if (!array_key_exists('u',$_GET)) | ||
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | $session = $_GET['u']; | 66 | $session = $_GET['u']; |
| 67 | +$apptype = (isset($_GET['apptype'])) ? $_GET['apptype'] : 'ws'; | ||
| 67 | 68 | ||
| 68 | require_once('../config/dmsDefaults.php'); | 69 | require_once('../config/dmsDefaults.php'); |
| 69 | require_once('../ktapi/ktapi.inc.php'); | 70 | require_once('../ktapi/ktapi.inc.php'); |
| @@ -72,7 +73,7 @@ require_once('KTDownloadManager.inc.php'); | @@ -72,7 +73,7 @@ require_once('KTDownloadManager.inc.php'); | ||
| 72 | $download_manager = new KTDownloadManager(); | 73 | $download_manager = new KTDownloadManager(); |
| 73 | $download_manager->set_session($session); | 74 | $download_manager->set_session($session); |
| 74 | 75 | ||
| 75 | -$response = $download_manager->download($document_id, $hash); | 76 | +$response = $download_manager->download($document_id, $hash, null, $apptype); |
| 76 | if (PEAR::isError($response)) | 77 | if (PEAR::isError($response)) |
| 77 | { | 78 | { |
| 78 | $msg = urlencode($response->getMessage()); | 79 | $msg = urlencode($response->getMessage()); |
| @@ -80,4 +81,4 @@ if (PEAR::isError($response)) | @@ -80,4 +81,4 @@ if (PEAR::isError($response)) | ||
| 80 | exit; | 81 | exit; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | -?> | 84 | -?> |
| 85 | +?> | ||
| 84 | \ No newline at end of file | 86 | \ No newline at end of file |
ktwebservice/upload.php
| @@ -10,31 +10,31 @@ | @@ -10,31 +10,31 @@ | ||
| 10 | * Document Management Made Simple | 10 | * Document Management Made Simple |
| 11 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. | 11 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. |
| 12 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 12 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 13 | - * | 13 | + * |
| 14 | * This program is free software; you can redistribute it and/or modify it under | 14 | * This program is free software; you can redistribute it and/or modify it under |
| 15 | * the terms of the GNU General Public License version 3 as published by the | 15 | * the terms of the GNU General Public License version 3 as published by the |
| 16 | * Free Software Foundation. | 16 | * Free Software Foundation. |
| 17 | - * | 17 | + * |
| 18 | * This program is distributed in the hope that it will be useful, but WITHOUT | 18 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 20 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 20 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 21 | * details. | 21 | * details. |
| 22 | - * | 22 | + * |
| 23 | * You should have received a copy of the GNU General Public License | 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 | - * | ||
| 26 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 25 | + * |
| 26 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 27 | * California 94120-7775, or email info@knowledgetree.com. | 27 | * California 94120-7775, or email info@knowledgetree.com. |
| 28 | - * | 28 | + * |
| 29 | * The interactive user interfaces in modified source and object code versions | 29 | * The interactive user interfaces in modified source and object code versions |
| 30 | * of this program must display Appropriate Legal Notices, as required under | 30 | * of this program must display Appropriate Legal Notices, as required under |
| 31 | * Section 5 of the GNU General Public License version 3. | 31 | * Section 5 of the GNU General Public License version 3. |
| 32 | - * | 32 | + * |
| 33 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 33 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 34 | * these Appropriate Legal Notices must retain the display of the "Powered by | 34 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 35 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 35 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 36 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 36 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 37 | - * must display the words "Powered by KnowledgeTree" and retain the original | 37 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 38 | * copyright notice. | 38 | * copyright notice. |
| 39 | * Contributor( s): ______________________________________ | 39 | * Contributor( s): ______________________________________ |
| 40 | * | 40 | * |
| @@ -94,9 +94,11 @@ if ($action == 'C') | @@ -94,9 +94,11 @@ if ($action == 'C') | ||
| 94 | require_once('../ktapi/ktapi.inc.php'); | 94 | require_once('../ktapi/ktapi.inc.php'); |
| 95 | require_once('KTUploadManager.inc.php'); | 95 | require_once('KTUploadManager.inc.php'); |
| 96 | 96 | ||
| 97 | +$apptype = (isset($_POST['apptype'])) ? $_POST['apptype'] : 'ws'; | ||
| 97 | $session_id = $_POST['session_id']; | 98 | $session_id = $_POST['session_id']; |
| 99 | + | ||
| 98 | $ktapi = new KTAPI(); | 100 | $ktapi = new KTAPI(); |
| 99 | -$session = $ktapi->get_active_session($session_id); | 101 | +$session = $ktapi->get_active_session($session_id, null, $apptype); |
| 100 | if (PEAR::isError($session)) | 102 | if (PEAR::isError($session)) |
| 101 | { | 103 | { |
| 102 | respond(4, $session->getMessage()); | 104 | respond(4, $session->getMessage()); |
| @@ -204,4 +206,4 @@ function respond($code, $msg, $uploads=array()) | @@ -204,4 +206,4 @@ function respond($code, $msg, $uploads=array()) | ||
| 204 | } | 206 | } |
| 205 | 207 | ||
| 206 | 208 | ||
| 207 | -?> | 209 | -?> |
| 210 | +?> | ||
| 208 | \ No newline at end of file | 211 | \ No newline at end of file |