The table below describes the upgrades that have occurred to
@@ -294,18 +295,10 @@ class upgradeDatabase extends Step
$pre_res = $this->performPreUpgradeActions();
- if (PEAR::isError($pre_res)) {
- $errors = true;
- $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions failed.';
- }
- else {
- $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions succeeded.';
-
- }
-
$res = $this->performAllUpgrades();
- if (PEAR::isError($res) || PEAR::isError($pres)) {
+ if (!$res) {
$errors = true;
+ $this->error[] = 'An Error has occured';
// TODO instantiate error details hideable section?
$this->temp_variables['upgradeStatus'] = 'Database upgrade failed
@@ -319,13 +312,7 @@ class upgradeDatabase extends Step
}
$post_pres = $this->performPostUpgradeActions();
- if (PEAR::isError($post_res)) {
- $errors = true;
- $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions failed.';
- }
- else {
- $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions succeeded.';
- }
+
return !$errors;
}
@@ -334,40 +321,63 @@ class upgradeDatabase extends Step
// This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
// It should idealy work the same as the upgrades.
-
-// global $default;
-// print_r($this->paths);die;
// Lock the scheduler
- $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
- touch($lockFile);
+ $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
+ @touch($lockFile);
return true;
}
+ private function deleteDirectory($sPath) {
+ if (!WINDOWS_OS) {
+ if (file_exists('/bin/rm')) {
+ $this->util->pexec(array('/bin/rm', '-rf', $sPath));
+ return;
+ }
+ }
+ if (WINDOWS_OS) {
+ // Potentially kills off all the files in the path, speeding
+ // things up a bit
+ exec("del /q /s " . escapeshellarg($sPath));
+ }
+ $hPath = @opendir($sPath);
+ while (($sFilename = readdir($hPath)) !== false) {
+ if (in_array($sFilename, array('.', '..'))) {
+ continue;
+ }
+ $sFullFilename = sprintf("%s/%s", $sPath, $sFilename);
+ if (is_dir($sFullFilename)) {
+ $this->deleteDirectory($sFullFilename);
+ continue;
+ }
+ @chmod($sFullFilename, 0666);
+ @unlink($sFullFilename);
+ }
+ closedir($hPath);
+ @rmdir($sPath);
+ }
+
private function performPostUpgradeActions() {
// This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
// It should idealy work the same as the upgrades.
-// global $default;
-
// Ensure all plugins are re-registered.
$sql = "TRUNCATE plugin_helper";
- $res = DBUtil::runQuery($sql);
-
+ //$res = DBUtil::runQuery($sql);
+ $res = $this->util->dbUtilities->query($sql);
+
// Clear out all caches and proxies - they need to be regenerated with the new code
- $proxyDir = $default->proxyCacheDirectory;
- KTUtil::deleteDirectory($proxyDir);
-
- $oKTCache = new KTCache();
- $oKTCache->deleteAllCaches();
-
+ $this->deleteDirectory($this->proxyPath);
+// $oKTCache = new KTCache();
+// $oKTCache->deleteAllCaches();
+ $this->deleteDirectory($this->cachePath);
// Clear the configuration cache, it'll regenerate on next load
- $oKTConfig = new KTConfig();
- $oKTConfig->clearCache();
+// $oKTConfig = new KTConfig();
+// $oKTConfig->clearCache();
// Unlock the scheduler
- $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
+ $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
if(file_exists($lockFile)){
@unlink($lockFile);
}
@@ -377,18 +387,15 @@ class upgradeDatabase extends Step
}
private function performAllUpgrades () {
-// global $default;
-
$row = 1;
-
- $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);
- $lastVersion = DBUtil::getOneResultKey($query, 'value');
- $currentVersion = $default->systemVersion;
-
+ $table = 'system_settings';
+ $query = "SELECT value FROM $table WHERE name = 'databaseVersion'";
+ $result = $this->util->dbUtilities->query($query);
+ $assArr = $this->util->dbUtilities->fetchAssoc($result);
+ $lastVersion = $assArr[0]['value'];
+ $currentVersion = $this->sysVersion;
$upgrades = describeUpgrade($lastVersion, $currentVersion);
-
$this->temp_variables['upgradeTable'] = '';
-
foreach ($upgrades as $upgrade) {
if (($row % 2) == 1) {
$class = "odd";
@@ -402,15 +409,17 @@ class upgradeDatabase extends Step
$this->temp_variables['upgradeTable'] .= sprintf('
%s
', $this->showResult($res));
$this->temp_variables['upgradeTable'] .= ' ' . "\n";
$this->temp_variables['upgradeTable'] .= "\n";
- if (PEAR::isError($res)) {
- if (!is_a($res, 'Upgrade_Already_Applied')) {
- break;
- } else {
- $res = true;
- }
- }
+// if (!$res) {
+// if (!is_a($res, 'Upgrade_Already_Applied')) {
+// $res = false;
+// } else {
+// $res = true;
+// }
+// }
if ($res === false) {
- $res = PEAR::raiseError("Upgrade returned false");
+ die;
+ $this->error = $this->util->dbUtilities->getErrors();
+// print_r($this->error);
break;
}
}
@@ -419,11 +428,11 @@ class upgradeDatabase extends Step
}
private function showResult($res) {
- if (PEAR::isError($res)) {
+ if ($res) {
if (is_a($res, 'Upgrade_Already_Applied')) {
return 'Already applied';
}
- return sprintf('%s', htmlspecialchars($res->toString()));
+// return sprintf('%s', htmlspecialchars($res));
}
if ($res === true) {
return 'Success';
@@ -433,6 +442,5 @@ class upgradeDatabase extends Step
}
return $res;
}
-
}
?>
\ No newline at end of file
diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php
index 3e4d056..1c232df 100644
--- a/setup/upgrade/steps/upgradeWelcome.php
+++ b/setup/upgrade/steps/upgradeWelcome.php
@@ -45,7 +45,8 @@ class upgradeWelcome extends step {
protected $silent = true;
protected $temp_variables = array();
protected $error = array() ;
-
+ protected $storeInSession = true;
+
public function doStep() {
$this->temp_variables = array("step_name"=>"welcome");
if($this->next()) {
@@ -88,8 +89,6 @@ class upgradeWelcome extends step {
$configPath = $wizConfigHandler->readConfigPathIni();
$this->util->iniUtilities->load($configPath);
$dconf = $this->util->iniUtilities->getSection('db');
- if($dconf['dbPort'] == 'default')
- $dconf['dbPort'] = 3306;
$this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
$sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
$res = $this->util->dbUtilities->query($sQuery);
diff --git a/setup/upgrade/templates/complete.tpl b/setup/upgrade/templates/complete.tpl
index d32a3ce..9b35d08 100644
--- a/setup/upgrade/templates/complete.tpl
+++ b/setup/upgrade/templates/complete.tpl
@@ -6,8 +6,8 @@
- Your database has been upgraded to systemVersion; ?>
+ Your database has been upgraded to
- Goto Login
+ Goto Login
\ No newline at end of file
diff --git a/setup/upgrade/templates/database.tpl b/setup/upgrade/templates/database.tpl
index 46b3aec..4fb564b 100644
--- a/setup/upgrade/templates/database.tpl
+++ b/setup/upgrade/templates/database.tpl
@@ -3,6 +3,13 @@
This step performs the necessary Database Upgrades.
+ ";
+ foreach ($errors as $error) {
+ if($error != '')
+ echo "$error ";
+ }
+ ?>
diff --git a/setup/upgrade/upgradeSession.php b/setup/upgrade/upgradeSession.php
deleted file mode 100644
index 019fded..0000000
--- a/setup/upgrade/upgradeSession.php
+++ /dev/null
@@ -1,224 +0,0 @@
-.
-*
-* 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.
-*
-* @copyright 2008-2009, KnowledgeTree Inc.
-* @license GNU General Public License version 3
-* @author KnowledgeTree Team
-* @package Upgrader
-* @version Version 0.1
-*/
-class UpgradeSession
-{
- private $salt = 'upgrade';
- /**
- * Constructs session object
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- */
- public function __construct() {
- $this->startSession();
- }
-
- /**
- * Starts a session if one does not exist
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function startSession() {
- if(!isset($_SESSION[$this->salt]['ready'])) {
- session_start();
- $_SESSION[$this->salt] ['ready'] = TRUE;
- }
- }
-
- /**
- * Sets a value key pair in session
- *
- * @author KnowledgeTree Team
- * @param string $fld
- * @param string $val
- * @access public
- * @return void
- */
- public function set($fld, $val) {
- $this->startSession();
- $_SESSION[$this->salt] [$fld] = $val;
- }
-
- /**
- * Sets a value key pair in a class in session
- *
- * @author KnowledgeTree Team
- * @param string $class
- * @param string $fld
- * @param string $val
- * @access public
- * @return void
- */
- public function setClass($class , $k, $v) {
- $this->startSession();
- $classArray = $this->get($class);
- if(isset($classArray[$k])) {
- $classArray[$k] = $v;
- } else {
- $classArray[$k] = $v;
- }
- $_SESSION[$this->salt] [ $class] = $classArray;
- }
-
- /**
- * Sets a error value key pair in a class in session
- *
- * @author KnowledgeTree Team
- * @param string $class
- * @param string $fld
- * @param string $val
- * @access public
- * @return void
- */
- public function setClassError($class, $k, $v) {
- $this->startSession();
- $classArray = $this->get($class);
- if(isset($classArray[$k])) {
- $classArray[$k] = $v;
- } else {
- $classArray[$k] = $v;
- }
- $_SESSION[$this->salt] [ $class] = $classArray;
- }
-
- /**
- * Clear error values in a class session
- *
- * @author KnowledgeTree Team
- * @param string $class
- * @param string $fld
- * @param string $val
- * @access public
- * @return void
- */
- public function clearErrors($class) {
- $classArray = $this->get($class);
- unset($classArray['errors']);
- $_SESSION[$this->salt] [ $class] = $classArray;
- }
-
- /**
- * Unset a value in session
- *
- * @author KnowledgeTree Team
- * @param string $fld
- * @access public
- * @return void
- */
- public function un_set($fld) {
- $this->startSession();
- unset($_SESSION[$this->salt] [$fld]);
- }
-
- /**
- * Unset a class value in session
- *
- * @author KnowledgeTree Team
- * @param string $class
- * @access public
- * @return void
- */
- public function un_setClass($class) {
- $this->startSession();
- if(isset($_SESSION[$this->salt] [$class]))
- unset($_SESSION[$this->salt] [$class]);
- }
-
- /**
- * Destroy the session
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function destroy() {
- $this->startSession();
- unset($_SESSION[$this->salt]);
- session_destroy();
- }
-
- /**
- * Get a session value
- *
- * @author KnowledgeTree Team
- * @param string $fld
- * @access public
- * @return string
- */
- public function get($fld) {
- $this->startSession();
- if(isset($_SESSION[$this->salt] [$fld]))
- return $_SESSION[$this->salt] [$fld];
- return false;
- }
-
- /**
- * Check if a field exists in session
- *
- * @author KnowledgeTree Team
- * @param string $fld
- * @access public
- * @return string
- */
- public function is_set($fld) {
- $this->startSession();
- return isset($_SESSION[$this->salt] [$fld]);
- }
-
- /**
- * Return a class from session
- *
- * @author KnowledgeTree Team
- * @param string $fld
- * @access public
- * @return string
- */
- public function getClass($class) {
- return $_SESSION[$this->salt][$class];
- }
-}
-?>
\ No newline at end of file
diff --git a/setup/wizard/dbUtilities.php b/setup/wizard/dbUtilities.php
index 6206fe6..39f6876 100644
--- a/setup/wizard/dbUtilities.php
+++ b/setup/wizard/dbUtilities.php
@@ -267,5 +267,15 @@ class dbUtilities {
public function rollback() {
$this->query("ROLLBACK");
}
+
+ public function runQueries($aQueries) {
+ foreach ($aQueries as $sQuery) {
+ $res = $this->query($sQuery);
+ if (!$res) {
+ return $res;
+ }
+ }
+ return true;
+ }
}
?>
\ No newline at end of file
diff --git a/setup/wizard/iniUtilities.php b/setup/wizard/iniUtilities.php
index e47053a..366caf7 100644
--- a/setup/wizard/iniUtilities.php
+++ b/setup/wizard/iniUtilities.php
@@ -45,11 +45,11 @@ class iniUtilities {
function load($iniFile) {
- if($this->iniFile != $iniFile) {
- $this->cleanArray = array();
- $this->lineNum = 0;
- $this->exists = '';
- }
+// if($this->iniFile != $iniFile) {
+// $this->cleanArray = array();
+// $this->lineNum = 0;
+// $this->exists = '';
+// }
$this->iniFile = $iniFile;
$this->backupIni($iniFile);
$this->read($iniFile);
diff --git a/setup/wizard/lib/services/unixLucene.php b/setup/wizard/lib/services/unixLucene.php
index a87ca88..1520874 100644
--- a/setup/wizard/lib/services/unixLucene.php
+++ b/setup/wizard/lib/services/unixLucene.php
@@ -201,7 +201,7 @@ class unixLucene extends unixService {
public function start() {
$state = $this->status();
if($state != 'STARTED') {
- $logFile = $this->outputDir."log".DS."lucene.log";
+ $logFile = $this->outputDir.DS."lucene.log";
@unlink($logFile);
$cmd = "cd ".$this->getLuceneDir()."; ";
$cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!";
diff --git a/setup/wizard/lib/services/unixScheduler.php b/setup/wizard/lib/services/unixScheduler.php
index 6f8fada..9c5a4c0 100644
--- a/setup/wizard/lib/services/unixScheduler.php
+++ b/setup/wizard/lib/services/unixScheduler.php
@@ -180,7 +180,7 @@ class unixScheduler extends unixService {
// TODO : Write sh on the fly? Not sure the reasoning here
$source = $this->getSchedulerSourceLoc();
$this->writeSchedulerTask();
- $logFile = $this->outputDir."log".DS."scheduler.log";
+ $logFile = $this->outputDir.DS."scheduler.log";
@unlink($logFile);
if($source) { // Source
$cmd = "nohup ".$source." > ".$logFile." 2>&1 & echo $!";
diff --git a/setup/wizard/resources/graphics/greenit.jpg b/setup/wizard/resources/graphics/greenit.jpg
new file mode 100644
index 0000000..6498c37
--- /dev/null
+++ b/setup/wizard/resources/graphics/greenit.jpg
diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php
index 8df2aae..d32a648 100644
--- a/setup/wizard/steps/complete.php
+++ b/setup/wizard/steps/complete.php
@@ -96,6 +96,7 @@ class complete extends Step {
foreach ($paths as $path)
{
$output = '';
+ $path['path'] = $class = strtolower(substr($path['path'],0,1)).substr($path['path'],1); // Damn you windows
$result = $this->util->checkPermission($path['path']);
$output = sprintf($pathhtml, $result['class'], $path['path'],
(($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ),
diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php
index 7024af7..bdfca7d 100644
--- a/setup/wizard/steps/configuration.php
+++ b/setup/wizard/steps/configuration.php
@@ -450,7 +450,7 @@ class configuration extends Step
}
$dirs = $this->getFromConfigPath(); // Store contents
}
- $varDirectory = $fileSystemRoot . DS . 'var';
+
foreach ($dirs as $key => $dir){
$path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path'];
@@ -460,6 +460,7 @@ class configuration extends Step
if(WINDOWS_OS)
$path = preg_replace('/\//', '\\',$path);
$dirs[$key]['path'] = $path;
+ $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
if(isset($dir['file']))
$class = $this->util->checkPermission($path, $dir['create'], true);
else
diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php
index 6f5d309..153796d 100644
--- a/setup/wizard/steps/services.php
+++ b/setup/wizard/steps/services.php
@@ -219,7 +219,7 @@ class services extends Step
$srv = new $className();
$srv->load();
$status = $this->serviceInstalled($srv);
- if($status != 'STARTED') {
+ if($status != 'STARTED' || $status != 'STOPPED') {
if(!WINDOWS_OS) { $binary = $this->$class->getBinary(); } // Get binary, if it exists
$passed = $this->$class->binaryChecks(); // Run Binary Pre Checks
if ($passed) { // Install Service
diff --git a/setup/wizard/templates/install.tpl b/setup/wizard/templates/install.tpl
index 1e1a8f2..f25971f 100644
--- a/setup/wizard/templates/install.tpl
+++ b/setup/wizard/templates/install.tpl
@@ -5,10 +5,7 @@
We would greatly appreciate it if you would allow us to collect anonymous usage statistics to help us provide a better quality product. The information includes a unique identification number, number of users you have created, your operating system type and your IP address. Your privacy is protected by the KnowledgeTree Privacy and Data Protection Agreements.
-
- KnowledgeTree, in partnership with Food & Trees for Africa, and as a contributor to the National Tree Distribution Program, will also commit to planting one tree in Africa for every 1000 vertified installations of the product.
-
-
image('img_fatlogo.jpg'); ?>
+
image('greenit.jpg'); ?>
Help to improve KnowledgeTree by providing anonymous usage statistics
diff --git a/webservice/clienttools/ajaxhandler.php b/webservice/clienttools/ajaxhandler.php
index cc2109a..4e3e9a5 100644
--- a/webservice/clienttools/ajaxhandler.php
+++ b/webservice/clienttools/ajaxhandler.php
@@ -8,6 +8,7 @@ class ajaxHandler{
public $kt=NULL;
public $authenticator=NULL;
public $noAuthRequireList=array();
+ public $standardServices=array('system');
public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){
// set a local copy of the json request wrapper
@@ -30,6 +31,7 @@ class ajaxHandler{
}
$this->ret->setRequest($this->req->jsonArray);
$this->ret->setTitle($this->request['service'].'::'.$this->request['function']);
+ $this->ret->setDebug('Server Versions',$this->getServerVersions());
if(get_class($kt)=='KTAPI'){
$this->kt=&$kt;
@@ -38,20 +40,22 @@ class ajaxHandler{
return $this->render();
}
- // Prepar
- $this->loadService('auth');
- $this->authenticator=new auth($this->ret,$this->kt,$this->request,$this->auth);
-
-
- //Make sure a token exists before continuing
- if(!$this->verifyToken())return $this->render();
-
-
- if(!$this->verifySession()){
- $this->doLogin();
- $isAuthRequired=$this->isNoAuthRequiredRequest();
- $isAuthenticated=$this->isAuthenticated();
- if(!$isAuthRequired && !$isAuthenticated)return $this->render();
+ // Prepare
+ if(!$this->isStandardService()){
+ $this->loadService('auth');
+ $this->authenticator=new auth($this,$this->ret,$this->kt,$this->request,$this->auth);
+
+
+ //Make sure a token exists before continuing
+ if(!$this->verifyToken())return $this->render();
+
+
+ if(!$this->verifySession()){
+ $this->doLogin();
+ $isAuthRequired=$this->isNoAuthRequiredRequest();
+ $isAuthenticated=$this->isAuthenticated();
+ if(!$isAuthRequired && !$isAuthenticated)return $this->render();
+ }
}
$this->dispatch();
@@ -70,11 +74,15 @@ class ajaxHandler{
$service=$this->authenticator;
}else{
$this->loadService($request['service']);
- $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth);
+ if(class_exists($request['service'])){
+ $service=new $request['service']($this,$this->ret,$this->kt,$this->request,$this->auth);
+ }else{
+ $this->ret->setDebug('Service could not be loaded',$request['service']);
+ }
}
$this->ret->setdebug('dispatch_request','The service class loaded');
if(method_exists($service,$request['function'])){
- $this->ret->setdebug('dispatch_execution','The service method was found. Executing');
+ $this->ret->setDebug('dispatch_execution','The service method was found. Executing');
$service->$request['function']($request['parameters']);
}else{
$this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}");
@@ -82,16 +90,34 @@ class ajaxHandler{
}
}
+ public function isStandardService(){
+ return in_array($this->request['service'],$this->standardServices);
+ }
+
public function loadService($serviceName=NULL){
- $version=$this->getVersion();
- if(!class_exists($serviceName)){
- if(file_exists('services/'.$version.'/'.$serviceName.'.php')){
- require_once('services/'.$version.'/'.$serviceName.'.php');
- return true;
- }else{
- throw new Exception('Service could not be found: '.$serviceName);
- return false;
+ if(in_array($serviceName,$this->standardServices)){
+ $fileName=dirname(__FILE__).'/standardservices/'.$serviceName.'.php';
+ $this->ret->setDebug('standardService Found',$fileName);
+ if(!class_exists($serviceName)){
+ if(file_exists($fileName)){
+ require_once($fileName);
+ return true;
+ }else{
+ throw new Exception('Standard Service could not be found: '.$serviceName);
+ return false;
+ }
+ }
+ }else{
+ $version=$this->getVersion();
+ if(!class_exists($serviceName)){
+ if(file_exists('services/'.$version.'/'.$serviceName.'.php')){
+ require_once('services/'.$version.'/'.$serviceName.'.php');
+ return true;
+ }else{
+ throw new Exception('Service could not be found: '.$serviceName);
+ return false;
+ }
}
}
}
@@ -106,10 +132,22 @@ class ajaxHandler{
return true;
}
- protected function getVersion(){
+ public function getVersion(){
if(!$this->version)$this->version=$this->req->getVersion();
return $this->version;
}
+
+ public function getServerVersions(){
+ $folder='services/';
+ $contents=scandir($folder);
+ $dir=array();
+ foreach($contents as $item){
+ if(is_dir($folder.$item) && $item!='.' && $item!=='..'){
+ $dir[]=$item;
+ }
+ }
+ return $dir;
+ }
protected function verifySession(){
return $this->authenticator->pickup_session();
diff --git a/webservice/clienttools/client_service.php b/webservice/clienttools/client_service.php
index 971fc30..078dd5a 100644
--- a/webservice/clienttools/client_service.php
+++ b/webservice/clienttools/client_service.php
@@ -5,8 +5,9 @@ class client_service{
public $KT;
public $Request;
public $AuthInfo;
+ public $handler;
- public function __construct(&$ResponseObject,&$KT_Instance,&$Request,&$AuthInfo){
+ public function __construct(&$handler,&$ResponseObject,&$KT_Instance,&$Request,&$AuthInfo){
// set the response object
// if(get_class($ResponseObject)=='jsonResponseObject'){
// $this->Response=&$ResponseObject;
@@ -14,7 +15,7 @@ class client_service{
// $this->Response=new jsonResponseObject();
// }
-
+ $this->handler=$handler;
$this->Response=&$ResponseObject;
$this->KT=&$KT_Instance;
$this->AuthInfo=&$AuthInfo;
diff --git a/webservice/clienttools/jsonWrapper.php b/webservice/clienttools/jsonWrapper.php
index df4e092..c025f35 100644
--- a/webservice/clienttools/jsonWrapper.php
+++ b/webservice/clienttools/jsonWrapper.php
@@ -14,7 +14,7 @@ class jsonResponseObject{
public $additional=array();
public $isDataSource=false;
- public $includeDebug=false;
+ public $includeDebug=true;
public $response=array(
'requestName' =>'',
diff --git a/webservice/clienttools/services/0.1/auth.php b/webservice/clienttools/services/0.1/auth.php
index 67a62e7..e7cdc65 100644
--- a/webservice/clienttools/services/0.1/auth.php
+++ b/webservice/clienttools/services/0.1/auth.php
@@ -100,17 +100,25 @@ class auth extends client_service {
public function ping(){
global $default;
$user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
+ $versions=$this->handler->getServerVersions();
+ $bestVer=$versions[count($versions)-1];
+ $clientVer=$this->handler->getVersion();
$ret=array(
'response' =>'pong',
'loginLocation' => '/index.html',
- 'currentversion' =>$default->systemVersion,
- 'requiredversion' =>$default->systemVersion,
- 'versionok' =>true,
- 'fullName' =>PEAR::isError($user)?'':$user->getName()
+ 'versionok' =>in_array($clientVer,$versions),
+ 'fullName' =>PEAR::isError($user)?'':$user->getName(),
+ 'serverVersions' =>$versions,
+ 'serverBestVersion' =>$bestVer,
+ 'clientVersion' =>$clientVer,
+ 'canUpgradeClient' =>($clientVer<$bestVer?true:false),
+ 'canUpgradeServer' =>($clientVer>$bestVer?true:false)
+
);
$this->setResponse($ret);
return true;
}
+
function logout($params){
$params=$this->AuthInfo;
diff --git a/webservice/clienttools/services/0.2/auth.php b/webservice/clienttools/services/0.2/auth.php
index 67a62e7..5d7275f 100644
--- a/webservice/clienttools/services/0.2/auth.php
+++ b/webservice/clienttools/services/0.2/auth.php
@@ -100,13 +100,20 @@ class auth extends client_service {
public function ping(){
global $default;
$user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
+ $versions=$this->handler->getServerVersions();
+ $bestVer=$versions[count($versions)-1];
+ $clientVer=$this->handler->getVersion();
$ret=array(
'response' =>'pong',
'loginLocation' => '/index.html',
- 'currentversion' =>$default->systemVersion,
- 'requiredversion' =>$default->systemVersion,
- 'versionok' =>true,
- 'fullName' =>PEAR::isError($user)?'':$user->getName()
+ 'versionok' =>in_array($clientVer,$versions),
+ 'fullName' =>PEAR::isError($user)?'':$user->getName(),
+ 'serverVersions' =>$versions,
+ 'serverBestVersion' =>$bestVer,
+ 'clientVersion' =>$clientVer,
+ 'canUpgradeClient' =>($clientVer<$bestVer?true:false),
+ 'canUpgradeServer' =>($clientVer>$bestVer?true:false)
+
);
$this->setResponse($ret);
return true;
diff --git a/webservice/clienttools/services/0.2/kt.php b/webservice/clienttools/services/0.2/kt.php
index f267f1b..da76840 100644
--- a/webservice/clienttools/services/0.2/kt.php
+++ b/webservice/clienttools/services/0.2/kt.php
@@ -140,6 +140,7 @@ class kt extends client_service {
$folder=&$kt->get_folder_by_id($arr['node']);
if (PEAR::isError($folder)){
+ echo '
'.print_r($arr,true).'
';
$this->addError('Folder Not found');
return false;
}
@@ -430,6 +431,7 @@ class kt extends client_service {
}
}
$this->setResponse(array('items'=>$items, 'count'=>count($items)));
+ return true;
}
function update_document_type($params) {
@@ -599,9 +601,10 @@ class kt extends client_service {
$filename=$params['filename'];
$reason=$params['reason'];
$tempfilename=$params['tempfilename'];
+ $major_update=$params['major_update'];
$application=$this->AuthInfo['appType'];
- $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')");
+ $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application', $major_update)");
$kt=&$this->KT;
// we need to add some security to ensure that people don't frig the checkin process to access restricted files.
@@ -620,7 +623,7 @@ class kt extends client_service {
}
// checkin
- $result=$document->checkin($filename, $reason, $tempfilename, false);
+ $result=$document->checkin($filename, $reason, $tempfilename, $major_update);
if (PEAR::isError($result))
{
$this->setResponse(array('status_code'=>14));
@@ -676,7 +679,7 @@ class kt extends client_service {
$status_code=$update_result['status_code'];
if ($status_code != 0)
{
- $this->delete_document($arr['session_id'], $document_id, 'Rollback because metadata could not be added', $arr['application']);
+ $this->delete_document(array('session_id' => $arr['session_id'], 'document_id' => $document_id, 'reason' => 'Rollback because metadata could not be added', 'application' => $arr['application']));
$this->response= $update_result;
}
@@ -824,7 +827,12 @@ class kt extends client_service {
$this->setResponse($detail);
}
- function delete_document($session_id, $document_id, $reason, $application){
+ function delete_document($params){
+ $session_id = $params['session_id'];
+ $document_id = $params['document_id'];
+ $reason = $params['reason'];
+ $application = $params['application'];
+
$kt=&$this->KT;
$document=&$kt->get_document_by_id($document_id);
diff --git a/webservice/clienttools/standardservices/system.php b/webservice/clienttools/standardservices/system.php
new file mode 100644
index 0000000..17b4a01
--- /dev/null
+++ b/webservice/clienttools/standardservices/system.php
@@ -0,0 +1,26 @@
+KT->get_user_object_by_username($this->AuthInfo['user']);
+ $versions=$this->handler->getServerVersions();
+ $bestVer=$versions[count($versions)-1];
+ $clientVer=$this->handler->getVersion();
+ $ret=array(
+ 'response' =>'pong',
+ 'loginLocation' => '/index.html',
+ 'versionok' =>in_array($clientVer,$versions),
+ 'fullName' =>PEAR::isError($user)?'':$user->getName(),
+ 'serverVersions' =>$versions,
+ 'serverBestVersion' =>$bestVer,
+ 'clientVersion' =>$clientVer,
+ 'canUpgradeClient' =>($clientVer<$bestVer?true:false),
+ 'canUpgradeServer' =>($clientVer>$bestVer?true:false)
+
+ );
+ $this->setResponse($ret);
+ return true;
+ }
+}
+
+?>
\ No newline at end of file