diff --git a/ktwebservice/1-20090903194035 b/ktwebservice/1-20090903194035
new file mode 100644
index 0000000..fc36c0f
--- /dev/null
+++ b/ktwebservice/1-20090903194035
@@ -0,0 +1,68 @@
+
+Acorn Layout1247050268296_43541024768false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ktwebservice/KTDownloadManager.inc.php b/ktwebservice/KTDownloadManager.inc.php
index c1032e7..1779615 100644
--- a/ktwebservice/KTDownloadManager.inc.php
+++ b/ktwebservice/KTDownloadManager.inc.php
@@ -60,10 +60,8 @@ class KTDownloadManager
$this->age = $config->get('webservice/downloadExpiry',5);
$protocol = $config->get('KnowledgeTree/sslEnabled')?'https':'http';
- $server = KTUtil::getServerName(TRUE);
- $url = $config->get('webservice/downloadUrl');
- $this->download_url = $protocol . '://' . $server . $url;
+ $this->download_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $config->get('webservice/downloadUrl');
$this->random=$config->get('webservice/randomKeyText','jhsdf8q1jkjpoiudfs7sd3ds1');
}
diff --git a/ktwebservice/KTUploadManager.inc.php b/ktwebservice/KTUploadManager.inc.php
index be50f93..57dc38f 100644
--- a/ktwebservice/KTUploadManager.inc.php
+++ b/ktwebservice/KTUploadManager.inc.php
@@ -110,7 +110,6 @@ class KTUploadManager
return ($tempdir == $this->temp_dir);
*/
}
-
function store_base64_file($base64, $prefix= 'sa_')
{
$tempfilename = $this->get_temp_filename($prefix);
@@ -134,36 +133,6 @@ class KTUploadManager
return $tempfilename;
}
-
- /**
- *
- * @param string $content file content NOT base64 encoded (may be string, may be binary)
- * @param string $prefix [optional]
- * @return $tempfilename the name of the temporary file created
- */
- function store_file($content, $prefix= 'sa_')
- {
- $tempfilename = $this->get_temp_filename($prefix);
- if (!is_writable($tempfilename))
- {
- return new PEAR_Error("Cannot write to file: $tempfilename");
- }
-
- if (!$this->is_valid_temporary_file($tempfilename))
- {
- return new PEAR_Error("Invalid temporary file: $tempfilename. There is a problem with the temporary storage path: $this->temp_dir.");
- }
-
- $fp=fopen($tempfilename, 'wb');
- if ($fp === false)
- {
- return new PEAR_Error("Cannot write content to temporary file: $tempfilename.");
- }
- fwrite($fp, $content);
- fclose($fp);
-
- return $tempfilename;
- }
/**
* This tells the manager to manage a file that has been uploaded.
diff --git a/ktwebservice/download.php b/ktwebservice/download.php
index 9adb4a0..f3170c4 100644
--- a/ktwebservice/download.php
+++ b/ktwebservice/download.php
@@ -77,7 +77,7 @@ $response = $download_manager->download($document_id, $hash, null, $apptype);
if (PEAR::isError($response))
{
$msg = urlencode($response->getMessage());
- print "status_code=4&msg=$msg";
+ print "status_code=4&msg=$msg:".$_GET["u"].":".$_GET["d"].":".$_GET["code"].":".$_GET["apptype"].":";
exit;
}
diff --git a/ktwebservice/upload.php b/ktwebservice/upload.php
index 67f4ffc..35f96aa 100644
--- a/ktwebservice/upload.php
+++ b/ktwebservice/upload.php
@@ -117,6 +117,7 @@ foreach($_FILES as $key =>$file)
$tempfile=$file['tmp_name'];
$error=$file['error'];
+ $extra = $filename.'-'.$tempfile.'-'.$error;
if ($error == UPLOAD_ERR_OK)
{
$result = $upload_manager->uploaded($filename, $tempfile, $action);
@@ -145,7 +146,7 @@ if ($failed)
}
else
{
- respond(0, '', $added);
+ respond(0, 'It worked'.$extra, $added);
}
function respond($code, $msg, $uploads=array())
diff --git a/webservice/clienttools/ajaxhandler.php b/webservice/clienttools/ajaxhandler.php
index d0596a4..cc2109a 100644
--- a/webservice/clienttools/ajaxhandler.php
+++ b/webservice/clienttools/ajaxhandler.php
@@ -7,12 +7,19 @@ class ajaxHandler{
public $request=NULL;
public $kt=NULL;
public $authenticator=NULL;
+ public $noAuthRequireList=array();
- public function __construct(&$ret=NULL,&$kt){
+ public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){
// set a local copy of the json request wrapper
+ $noAuthRequests=is_array($noAuthRequests)?$noAuthRequests:split(',',(string)$noAuthRequests);
+ $this->registerNoAuthRequest($noAuthRequests);
$this->req=new jsonWrapper(isset($_GET['request'])?$_GET['request']:(isset($_POST['request'])?$_POST['request']:''));
- $this->auth=$this->req->jsonArray['auth'];
- $this->request=$this->req->jsonArray['request'];
+ $this->auth=$this->structArray('user,pass,passhash,appType,session,token,version',$this->req->jsonArray['auth']);
+ $this->request=$this->structArray('service,function,parameters',$this->req->jsonArray['request']);
+
+ $add_params=array_merge($_GET,$_POST);
+ unset($add_params['request'],$add_params['datasource']);
+ $this->request['parameters']=array_merge($this->request['parameters'],$add_params);
// set the response object
@@ -22,6 +29,7 @@ class ajaxHandler{
$this->ret=new jsonResponseObject();
}
$this->ret->setRequest($this->req->jsonArray);
+ $this->ret->setTitle($this->request['service'].'::'.$this->request['function']);
if(get_class($kt)=='KTAPI'){
$this->kt=&$kt;
@@ -41,21 +49,32 @@ class ajaxHandler{
if(!$this->verifySession()){
$this->doLogin();
- if(!$this->isAuthenticated())return $this->render();
+ $isAuthRequired=$this->isNoAuthRequiredRequest();
+ $isAuthenticated=$this->isAuthenticated();
+ if(!$isAuthRequired && !$isAuthenticated)return $this->render();
}
$this->dispatch();
return $this->render();
}
+
+ private function structArray($structString=NULL,$arr=NULL){
+ $struct=array_flip(split(',',(string)$structString));
+ return array_merge($struct,is_array($arr)?$arr:array());
+ }
public function dispatch(){
$request=$this->request;
- $this->loadService($request['service']);
- $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth);
- $this->ret->setTitle($request['service'].'::'.$request['function']);
+ if($request['auth']){
+ $service=$this->authenticator;
+ }else{
+ $this->loadService($request['service']);
+ $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth);
+ }
+ $this->ret->setdebug('dispatch_request','The service class loaded');
if(method_exists($service,$request['function'])){
- //$this->ret->setDebug('got here');
+ $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']}");
@@ -97,7 +116,7 @@ class ajaxHandler{
}
protected function isAuthenticated(){
- return true;
+ return $this->authenticator->pickup_session();
}
protected function doLogin(){
@@ -113,6 +132,26 @@ class ajaxHandler{
echo $this->ret->getJson();
return true;
}
+
+ public function registerNoAuthRequest($requestString=''){
+ if($requestString){
+ if(is_array($requestString)){
+ foreach ($requestString as $rString){
+ $rString=strtolower((string)$rString);
+ $this->noAuthRequireList[$rString]=$rString;
+ }
+ }else{
+ $requestString=strtolower((string)$requestString);
+ $this->noAuthRequireList[$requestString]=(string)$requestString;
+ }
+ }
+ }
+
+ public function isNoAuthRequiredRequest(){
+ $req=$this->request;
+ $reqString=strtolower("{$req['service']}.{$req['function']}");
+ return in_array($reqString,$this->noAuthRequireList);
+ }
}
?>
\ No newline at end of file
diff --git a/webservice/clienttools/client_service.php b/webservice/clienttools/client_service.php
index a5c8412..971fc30 100644
--- a/webservice/clienttools/client_service.php
+++ b/webservice/clienttools/client_service.php
@@ -41,6 +41,17 @@ class client_service{
return $var;
}
+ protected function checkPearError($obj,$errMsg,$debug=NULL,$response=NULL){
+ if (PEAR::isError($obj)){
+ if($response===NULL)$response=array('status_code' => 1);
+ $this->addError($errMsg);
+ if((isset($debug) || $debug==NULL) && $debug!=='')$this->addDebug('',$debug!==NULL?$debug:$obj);
+ $this->setResponse($response);
+ return false;
+ }
+ return true;
+ }
+
}
?>
\ No newline at end of file
diff --git a/webservice/clienttools/comms.php b/webservice/clienttools/comms.php
index 2a39488..cdb6c78 100644
--- a/webservice/clienttools/comms.php
+++ b/webservice/clienttools/comms.php
@@ -38,12 +38,23 @@ $old_error_handler=set_error_handler('error_handler',E_ERROR);
//Interpret the Json Object that was passed
include_once('jsonWrapper.php');
include_once('ajaxhandler.php');
+include_once('serviceHelper.php');
include_once('client_service.php');
//Instantiate base classes
$KT = new KTAPI();
$RET=new jsonResponseObject();
-$handler=new ajaxHandler($RET,$KT);
+if($_GET['datasource'])$RET->isDataSource=true;
+
+$noAuthRequests=array(
+ 'auth.ping',
+ 'auth.japiLogin',
+ 'kt.get_all_client_policies',
+ 'kt.get_languages',
+ 'kt.switchlang'
+);
+
+$handler=new ajaxHandler($RET,$KT,$noAuthRequests);
diff --git a/webservice/clienttools/jsonWrapper.php b/webservice/clienttools/jsonWrapper.php
index b48d0f2..1da332e 100644
--- a/webservice/clienttools/jsonWrapper.php
+++ b/webservice/clienttools/jsonWrapper.php
@@ -12,6 +12,7 @@ class jsonResponseObject{
protected $request=array();
protected $debug=array();
public $additional=array();
+ public $isDataSource=false;
public $response=array(
'requestName' =>'',
@@ -60,7 +61,7 @@ class jsonResponseObject{
public function getJson(){
$response=array_merge(array(
- 'title' =>$this->title,
+ 'requestName' =>$this->title,
'errors' =>array(
'hadErrors' =>(count($this->errors)>0?1:0),
'errors' =>$this->errors
@@ -71,7 +72,11 @@ class jsonResponseObject{
'debug' =>$this->debug,
),$this->additional);
- $response=json_encode($response);
+ if($this->isDataSource){
+ $response=json_encode($response['data']);
+ }else{
+ $response=json_encode($response);
+ }
return $response;
}
}
diff --git a/webservice/clienttools/serviceHelper.php b/webservice/clienttools/serviceHelper.php
new file mode 100644
index 0000000..dc2d146
--- /dev/null
+++ b/webservice/clienttools/serviceHelper.php
@@ -0,0 +1,75 @@
+1) {
+ $size=$size/1024;
+ $i++;
+ }
+ return substr($size,0,strpos($size,'.')+3).$iec[$i];
+ }
+
+
+ /**
+ * Display byte sizes in human readable representations
+ *
+ * @param integer $size Size to represent
+ * @param string $max Maximum representational unit (eg B,KB,MB)
+ * @param string $system Selecting the system of representation (si,bi&c1 defined)
+ * @param string $retstring Format for the return string.
+ * @return String
+ */
+ function size_readable($size, $max = null, $system = 'c1', $retstring = '%01.1f %s'){
+ // Pick units
+ $systems['si']['prefix'] = array('B', 'K', 'MB', 'GB', 'TB', 'PB');
+ $systems['si']['size'] = 1000;
+ $systems['bi']['prefix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
+ $systems['bi']['size'] = 1024;
+ $systems['c1']['prefix'] = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
+ $systems['c1']['size'] = 1024;
+ $sys = isset($systems[$system]) ? $systems[$system] : $systems['si'];
+
+ // Max unit to display
+ $depth = count($sys['prefix']) - 1;
+ if ($max && false !== $d = array_search($max, $sys['prefix'])) {
+ $depth = $d;
+ }
+
+ // Loop
+ $i = 0;
+ while ($size >= $sys['size'] && $i < $depth) {
+ $size /= $sys['size'];
+ $i++;
+ }
+
+ return sprintf(($sys['prefix'][$i]=='B'?'%01d %s':$retstring), $size, $sys['prefix'][$i]);
+ }
+}
+?>
\ No newline at end of file
diff --git a/webservice/clienttools/services/3.6.1/auth.php b/webservice/clienttools/services/3.6.1/auth.php
index d490458..15c8582 100644
--- a/webservice/clienttools/services/3.6.1/auth.php
+++ b/webservice/clienttools/services/3.6.1/auth.php
@@ -23,7 +23,9 @@ class auth extends client_service {
require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
if (!BaobabKeyUtil::checkIfLicensed(true)) {
- return array('authenticated'=> false, 'message'=> 'license_expired');
+ $this->setResponse(array('authenticated'=> false, 'message'=> 'license_expired'));
+ $this->addError('Licence Expired');
+ return false;
}
}
@@ -38,21 +40,34 @@ class auth extends client_service {
if(!PEAR::isError($session)){
$this->Response->setStatus('session_id',$session->get_session());
}else{
- $this->Response->setDebug('failed login',print_r($session,true));
- throw new Exception('Unknown Login Error');
+ $this->setResponse(array('authenticated'=> false, 'message'=> 'Invalid username and/or password.'));
+ $this->addDebug('failed login',print_r($session,true));
+ $this->addError('Unknown Login Error');
return false;
}
}else{
- throw new Exception('Incorrect Credentials');
+ $this->addError('Incorrect Credentials');
+ //throw new Exception('Incorrect Credentials');
return false;
}
}else{
- throw new Exception('Unrecognized User');
+ $this->addError('Incorrect Credentials');
+ //throw new Exception('Unrecognized User');
return false;
}
return true;
}
+ public function japiLogin(){
+ global $default;
+ $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
+ $ret=array(
+ 'fullName' =>PEAR::isError($user)?'':$user->getName()
+ );
+ $this->setResponse($ret);
+ return true;
+ }
+
public function pickup_session(){
$params=$this->AuthInfo;
$app_type=$params['appType'];
@@ -67,6 +82,40 @@ class auth extends client_service {
$this->Response->setStatus('session_id',$session->get_session());
return true;
}
+
+
+ public function ping(){
+ global $default;
+ $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
+ $ret=array(
+ 'response' =>'pong',
+ 'loginLocation' => '/index.html',
+ 'currentversion' =>$default->systemVersion,
+ 'requiredversion' =>$default->systemVersion,
+ 'versionok' =>true,
+ 'fullName' =>PEAR::isError($user)?'':$user->getName()
+ );
+ $this->setResponse($ret);
+ return true;
+ }
+
+ function logout($params){
+ $params=$this->AuthInfo;
+ $app_type=$params['appType'];
+ $session_id=$params['session'];
+ $ip=$_SERVER['REMOTE_ADDR'];
+
+ $session = $this->KT->get_active_session($session_id, $ip, $app_type);
+
+ if (PEAR::isError($session)){
+ return false;
+ }
+
+ $session->logout();
+ $this->setResponse(array('logout'=>true));
+ return true;
+ }
+
}
?>
\ No newline at end of file
diff --git a/webservice/clienttools/services/3.6.1/kt.php b/webservice/clienttools/services/3.6.1/kt.php
index 97afde1..92bdeaf 100644
--- a/webservice/clienttools/services/3.6.1/kt.php
+++ b/webservice/clienttools/services/3.6.1/kt.php
@@ -1,74 +1,77 @@
geti18nLanguages('knowledgeTree');
- $aLanguageNames = $oReg->getLanguages('knowledgeTree');
- $languages = array();
+ $aRegisteredLangs=$oReg->geti18nLanguages('knowledgeTree');
+ $aLanguageNames=$oReg->getLanguages('knowledgeTree');
+ $languages=array();
if(!empty($aRegisteredLangs)){
foreach (array_keys($aRegisteredLangs) as $sLang){
- $languages[] = array(
- 'isoCode' => $sLang,
- 'language' => $aLanguageNames[$sLang]
+ $languages[]=array(
+ 'isoCode'=>$sLang,
+ 'language'=>$aLanguageNames[$sLang]
);
}
}
-
- $this->setResponse(array('languages' => $languages, 'count' => count($languages), 'defaultLanguage' => $default->defaultLanguage));
+ $response=array('languages'=>$languages, 'count'=>count($languages), 'defaultLanguage'=>$default->defaultLanguage);
+ if(is_bool($passthru))if($passthru)return $response;
+ $this->setResponse($response);
}
function get_rootfolder_detail($params){
- $params['folderId'] = '1';
+ $params['folderId']='1';
$this->get_folder_detail($params);
}
function get_folder_detail($params) {
- $kt = &$this->KT;
+ if(isset($params['node'])&&!isset($params['folderId'])){
+ $params['node']=split('_',$params['node']);
+ $params['folderId']=$params['node'][1];
+ }
+ $kt=&$this->KT;
- $folder = &$kt->get_folder_by_id($params['folderId']);
+ $folder=&$kt->get_folder_by_id($params['folderId']);
if (PEAR::isError($folder))
{
$this->setError("Could not get folder by Id: {$params['folderId']}");
$this->setDebug('FolderError',array('kt'=>$kt,'folder'=>$folder));
- return;
+ return false;
}
- $detail = $folder->get_detail();
- if (PEAR::isError($detail))
- {
- $this->response= "detail error {$params['node']}";
+ $detail=$folder->get_detail();
+ if (PEAR::isError($detail)){
+ $this->setResponse("detail error {$params['node']}");
+ return false;
}
- if(strtolower($detail['folder_name']) == 'root folder') {
- $detail['folder_name'] = 'KnowledgeTree';
+ if(strtolower($detail['folder_name'])=='root folder'){
+ $detail['folder_name']='KnowledgeTree';
}
$qtip .= $this->xlate('Folder name').": {$detail['folder_name']}
";
- $class = 'folder';
+ $class='folder';
- $permissions = $detail['permissions'];
- $perms = '';
- //default write permissions to false
- $canWrite = false;
+ $permissions=$detail['permissions'];
+ $perms='';
+ $canWrite=false;
- //iterate through the permissions and convert to human-readable
- for ($j = 0; $j < strlen($permissions); $j++)
- {
- switch (strtoupper($permissions{$j}))
- {
+ for ($j=0; $j < strlen($permissions); $j++){
+ switch (strtoupper($permissions{$j})){
case 'W':
- $canWrite = true;
+ $canWrite=true;
$perms .= $this->xlate('write, ');
break;
case 'R':
@@ -80,227 +83,195 @@ class kt extends client_service {
}
}
- //now chop off trailing ', ' if any
- if (strlen($perms) > 2)
- {
- $perms = substr($perms, 0, strlen($perms)-2);
+ if (strlen($perms) > 2){
+ $perms=substr($perms, 0, strlen($perms)-2);
}
- //permissions
$qtip .= $this->xlate('Permissions:') . " {$perms}
";
-
- //comment
$qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder');
- $result[] = array
- (
- 'text' => $detail['folder_name'],
- 'id' => $params['control'] . $params['node'],
- 'filename' => $detail['folder_name'],
- 'cls' => 'folder',
- 'leaf' => false,
- 'document_type' => '',
- 'item_type' => 'F',
- 'permissions' => $permissions,
+ $result[]=array(
+ 'text'=>$detail['folder_name'],
+ 'id'=>'F_'. $params['folderId'],
+ 'filename'=>$detail['folder_name'],
+ 'cls'=>'folder',
+ 'leaf'=>false,
+ 'document_type'=>'',
+ 'item_type'=>'F',
+ 'permissions'=>$permissions,
'qtip'=> $qtip
);
$this->setResponse($result);
+ return true;
}
function get_folder_contents($params){
$kt=&$this->KT;
- $params['control'] = 'F_';
- $params['node'] = substr($params['node'], strlen($params['control']));
+ $params['control']='F_';
+ $params['node']=substr($params['node'], strlen($params['control']));
- $folder = &$kt->get_folder_by_id($params['node']);
- if (PEAR::isError($folder)){
- $this->addError("[error 1] Folder Not Found: {$params['control']}{$params['node']}");
- return false;
- }
+ $folder=&$kt->get_folder_by_id($params['node']);
+ if(!$this->checkPearError($folder,"[error 1] Folder Not Found: {$params['control']}{$params['node']}",'',array()))return false;
- $types = (isset($params['types']) ? $params['types'] : 'DF');
+ $types=(isset($params['types']) ? $params['types'] : 'DF');
+ $listing=$folder->get_listing(1, $types);
+ $result=$this->_processListing($listing, 'folderContents', $params);
- $listing = $folder->get_listing(1, $types);
+ $this->setResponse($result);
+ return true;
+ }
- $result = $this->_processListing($listing, 'folderContents', $params);
- $this->setResponse($result);
+ /**
+ * Returns the contents of a folder formatted for a grid view.
+ *
+ * @param array $arr
+ * @return array
+ */
+ function get_folder_contents_for_grid($arr)
+ {
+ $kt=&$this->KT;
+
+ $arr['control']='F_';
+ $arr['node']=substr($arr['node'], strlen($arr['control']));
+
+ $folder=&$kt->get_folder_by_id($arr['node']);
+ if (PEAR::isError($folder)){
+ $this->addError('Folder Not found');
+ return false;
+ }
+
+ $types=(isset($arr['types']) ? $arr['types'] : 'DF');
+
+ $listing=$folder->get_listing(1, $types);
+
+ $result=$this->_processListing($listing, 'grid', $arr);
+
+ $this->setResponse(array('totalCount'=>count($listing), 'items'=>$result));
+
+ return true;
}
-
+
+
private function _processListing($listing, $type, $arr){
- $result = array();
- $methodToIncludeItem = '_processItemInclusion_'.$type;
-
- foreach ($listing as $item)
- {
- $filename = $item['filename'];
- $itemType = $item['item_type'];
-
- $includeMe = true;
-
- //build up tooltip
- $qtip = '';
-
- //default write permissions to false
- $canWrite = false;
- //default immutable to false
- $immutable = false;
-
- //first do permissions since they are applicable to both folders and docs
- $permissions = $item['permissions'];
- $perms = '';
-
- //iterate through the permissions and convert to human-readable
- for ($j = 0; $j < strlen($permissions); $j++)
- {
- switch (strtoupper($permissions{$j}))
- {
+ $result=array();
+ $methodToIncludeItem='_processItemInclusion_'.$type;
+
+ foreach($listing as $item){
+ /* Trying to fix folder sizes */
+ if($item['filesize']<=0){
+ $item['filesize']='';
+ }else{
+ $item['filesize']=serviceHelper::size_readable($item['filesize']);
+ }
+
+ $filename=$item['filename'];
+ $itemType=$item['item_type'];
+
+ $includeMe=true;
+ $qtip='';
+ $canWrite=false;
+ $immutable=false;
+ $permissions=$item['permissions'];
+ $perms='';
+
+ for ($j=0; $j < strlen($permissions); $j++){
+ switch (strtoupper($permissions{$j})){
case 'W':
- $canWrite = true;
+ $canWrite=true;
$perms .= $this->xlate('write, ');
- break;
+ break;
case 'R':
$perms .= $this->xlate('read, ');
- break;
+ break;
case 'A':
$perms .= $this->xlate('add folder, ');
- break;
- // default:
- // $perms .= strtoupper($permissions{$j});
- // break;
+ break;
}
}
- //now chop off trailing ', ' if any
- if (strlen($perms) > 2)
- {
- $perms = substr($perms, 0, strlen($perms)-2);
+ if(strlen($perms) > 2){
+ $perms=substr($perms, 0, strlen($perms)-2);
}
- //folders
- if ($itemType == 'F')
- {
+ if($itemType=='F'){
$qtip .= $this->xlate('Folder name').": {$filename}
";
- $class = 'folder';
-
- //permissions
+ $class='folder';
$qtip .= $this->xlate('Permissions:') . " {$perms}
";
-
- //comment
$qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder');
}
//documents
- else
- {
- $qtip = '';
-
- //get file extension so can determine mimetype
- $extpos = strrpos($filename, '.') ;
-
- if ($extpos === false)
- {
- $class = 'file-unknown';
+ else{
+ $qtip='';
+ $extpos=strrpos($filename, '.') ;
+
+ if($extpos === false){
+ $class='file-unknown';
+ }else{
+ $ext=substr($filename, $extpos); // Get Extension including the dot
+ $class='file-' . substr($filename, $extpos +1); // Get Extension without the dot
}
- else
- {
- $ext = substr($filename, $extpos); // Get Extension including the dot
- $class = 'file-' . substr($filename, $extpos +1); // Get Extension without the dot
- }
-
- // Convert list to array
- $extensions = explode(',', $arr['extensions']);
-
- //don't include results which don't have the correct file extensions
- if(!in_array(strtolower($ext), $extensions))
- {
- $includeMe = false;
- }
- else
- {
- //filename
+
+ $extensions=explode(',', $arr['extensions']);
+ if(!in_array(strtolower($ext), $extensions)){
+ $includeMe=false;
+ }else{
$qtip .= $this->xlate('Filename') . ": {$filename}
";
-
- //size
- $qtip .= $this->xlate('File Size') . ": " . fsize_desc($item['filesize']) . "
";
-
- //last modified
+ $qtip .= $this->xlate('File Size') . ": " . serviceHelper::fsize_desc($item['filesize']) . "
";
$qtip .= $this->xlate('Modified') . ": {$item['modified_date']}
";
-
- //owner
$qtip .= $this->xlate('Owner') . ": {$item['created_by']}
";
-
- //version
$qtip .= $this->xlate('Version') . ": {$item['version']}
";
-
- //immutability
- if (bool2str(strtolower($item['is_immutable'])) == 'true')
- {
- $canWrite = false;
- $immutable = true;
+ if (serviceHelper::bool2str(strtolower($item['is_immutable']))=='true'){
+ $canWrite=false;
+ $immutable=true;
}
-
- //status, i.e. checked out or not, or immutable
- if ($immutable)
- {
+
+ if($immutable){
$qtip .= $this->xlate('Status: Immutable') . '
';
- }
- else if (strtolower($item['checked_out_by']) != 'n/a' && ($item['checked_out_by'] != ''))
- {
+ }else if (strtolower($item['checked_out_by']) != 'n/a' && ($item['checked_out_by'] != '')){
$qtip .= $this->xlate('Status: Checked out by') . " {$item['checked_out_by']}
";
- }
- else
- {
+ }else{
$qtip .= $this->xlate('Status: Available') . '
';
}
-
- //permissions
$qtip .= $this->xlate('Permissions:') . " {$perms}
";
- //immutable
- if($immutable)
- {
+ if($immutable){
$qtip .= $this->xlate('This document is not editable');
- }
- else if ($canWrite)
- {
+ }else if ($canWrite){
$qtip .= $this->xlate('You may edit this document');
- }
- else
- {
+ }else{
$qtip .= $this->xlate('This document is not editable');
}
}
}//end of if for files
- if($includeMe)
- {
- $result[] = $this->$methodToIncludeItem($item, $class, $qtip);
+ if($includeMe){
+ $result[]=$this->$methodToIncludeItem($item, $class, $qtip);
}
}
-
return $result;
}
- private function _processItemInclusion_folderContents($item, $class, $qtip)
- {
+ private function _processItemInclusion_folderContents($item, $class, $qtip){
return array (
- 'text' => htmlspecialchars($item['title']),
- 'originaltext' => $item['title'],
- 'id' => ($item['item_type'] == 'F' ? $item['item_type']."_" : "").$item['id'],
- 'filename' => $item['filename'],
- 'cls' => $class,
- 'leaf' => ($item['item_type'] == 'D'),
- 'document_type' => $item['document_type'],
- 'item_type' => $item['item_type'],
- 'permissions' => $item['permissions'],
- 'content_id' => $item['content_id'],
+ 'text'=>htmlspecialchars($item['title']),
+ 'originaltext'=>$item['title'],
+ 'id'=>($item['item_type']=='F' ? $item['item_type']."_" : "").$item['id'],
+ 'filename'=>$item['filename'],
+ 'cls'=>$class,
+ 'leaf'=>($item['item_type']=='D'),
+ 'document_type'=>$item['document_type'],
+ 'item_type'=>$item['item_type'],
+ 'permissions'=>$item['permissions'],
+ 'content_id'=>$item['content_id'],
+ 'checked_out_by'=>$item['checked_out_by'],
'qtip'=> $qtip
);
}
@@ -309,128 +280,155 @@ class kt extends client_service {
private function _processItemInclusion_search($item, $class, $qtip)
{
return array (
- 'text' => htmlspecialchars($item['title']),
- 'originaltext' => $item['title'],
- 'id' => $item['document_id'],
- 'filename' => $item['filename'],
- 'cls' => $class,
- 'leaf' => true,
- 'document_type' => $item['document_type'],
- 'item_type' => 'D',
- 'permissions' => $item['permissions'],
- 'content_id' => $item['content_id'],
- 'relevance' => $item['relevance'],
+ 'text'=>htmlspecialchars($item['title']),
+ 'originaltext'=>$item['title'],
+ 'id'=>$item['document_id'],
+ 'filename'=>$item['filename'],
+ 'cls'=>$class,
+ 'leaf'=>true,
+ 'document_type'=>$item['document_type'],
+ 'item_type'=>'D',
+ 'permissions'=>$item['permissions'],
+ 'content_id'=>$item['content_id'],
+ 'relevance'=>$item['relevance'],
'qtip'=> $qtip
);
}
+ private function _processItemInclusion_grid($item, $class, $qtip)
+ {
+ //var_dump($item);
+
+ if ($item['filesize']=='n/a') {
+ $item['filesize']=-1;
+ }
+
+ return array (
+ 'text'=>htmlspecialchars($item['title']),
+ 'originaltext'=>$item['title'],
+ 'id'=>$item['id'],
+ 'filename'=>$item['filename'],
+ 'cls'=>$class,
+ 'owner'=>$item['created_by'],
+ 'document_type'=>$item['document_type'],
+ 'item_type'=>$item['item_type'],
+ 'permissions'=>$item['permissions'],
+ 'content_id'=>$item['content_id'],
+ 'filesize'=>$item['filesize'],
+ 'modified'=>$item['modified_date'],
+ 'checked_out_by'=>$item['checked_out_by']
+ );
+ }
+
-
public function get_metadata($params) {
+ $kt=&$this->KT;
- $kt = &$this->KT;
+ if (substr($params['document_id'], 0, 2)=='D_') {
+ $params['document_id']=substr($params['document_id'], 2);
+ }
- $document_id = (int)$params['document_id'];
+ $document_id=(int)$params['document_id'];
if($document_id > 0) {
- $document = $kt->get_document_by_id($params['document_id']);
- $detail = $document->get_metadata();
- $document_detail = $document->get_detail();
- $title = $document_detail['title'];
- $document_type = $document_detail['document_type'];
+ $document=$kt->get_document_by_id($params['document_id']);
+ $detail=$document->get_metadata();
+ $document_detail=$document->get_detail();
+ $title=$document_detail['title'];
+ $document_type=$document_detail['document_type'];
- } else {
+ }else{
if(isset($params['document_type'])) {
- $document_type = $params['document_type'];
- } else {
- $document_type = 'Default';
+ $document_type=$params['document_type'];
+ }else{
+ $document_type='Default';
}
- $detail = $kt->get_document_type_metadata($document_type);
- $title = "";
+ $detail=$kt->get_document_type_metadata($document_type);
+ $title="";
}
- $result = array();
- $items = array();
- $index = 0;
- $items[] = array("name" => "__title", "index" => 0, "value" => $title, "control_type" => "string");
+ $result=array();
+ $items=array();
+ $index=0;
+ $items[]=array("name"=>"__title", "index"=>0, "value"=>$title, "control_type"=>"string");
// Commented out for timebeing - will be used by 'Save in Format'
if (isset($params['extensions'])) {
- $fileParts = pathinfo($document_detail['filename']);
+ $fileParts=pathinfo($document_detail['filename']);
- $items[] = array("name" => "__document_extension", "index" => 0, "value" => strtolower($fileParts['extension']), "control_type" => "lookup", "selection" => explode(',', str_replace('.', '', $params['extensions'])));
+ $items[]=array("name"=>"__document_extension", "index"=>0, "value"=>strtolower($fileParts['extension']), "control_type"=>"lookup", "selection"=>explode(',', str_replace('.', '', $params['extensions'])));
}
- $document_types = $this->get_documenttypes($params);
- $json_document_types = array();
+ $document_types=$this->get_documenttypes($params);
+ $json_document_types=array();
foreach($document_types['items'] as $val) {
- $json_document_types[] = $val['name'];
+ $json_document_types[]=$val['name'];
}
- $items[] = array("name" => "__document_type", "index" => 0, "value" => $document_type, "control_type" => "lookup", "selection" => $json_document_types);
+ $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$json_document_types);
for($i=0;$i $detail[$i]['fieldset'],
- 'name' => $detail[$i]['fields'][$j]['name'],
+ $items[]=array(
+ 'fieldset'=>$detail[$i]['fieldset'],
+ 'name'=>$detail[$i]['fields'][$j]['name'],
// Change for value. If blank value is set to 1, change value to ''
// Overcomes issue of n/a
- 'value' => ($document_id > 0 ? ($detail[$i]['fields'][$j]['blankvalue'] == '1' ? '' : $detail[$i]['fields'][$j]['value']) : ''),
-
- 'description' => $detail[$i]['fields'][$j]['description'],
- 'control_type' => $detail[$i]['fields'][$j]['control_type'],
- 'selection' => $detail[$i]['fields'][$j]['selection'],
- 'required' => $detail[$i]['fields'][$j]['required'],
- 'blankvalue' => $detail[$i]['fields'][$j]['blankvalue'],
- 'index' => $index
+ 'value'=>($document_id > 0 ? ($detail[$i]['fields'][$j]['blankvalue']=='1' ? '' : $detail[$i]['fields'][$j]['value']) : ''),
+
+ 'description'=>$detail[$i]['fields'][$j]['description'],
+ 'control_type'=>$detail[$i]['fields'][$j]['control_type'],
+ 'selection'=>$detail[$i]['fields'][$j]['selection'],
+ 'required'=>$detail[$i]['fields'][$j]['required'],
+ 'blankvalue'=>$detail[$i]['fields'][$j]['blankvalue'],
+ 'index'=>$index
);
$index++;
}
}
- $this->setResponse(array('id' => $title, 'items' => $items, 'count' => count($items)));
-
+ $this->setResponse(array('id'=>$title, 'items'=>$items, 'count'=>count($items)));
+ return true;
}
public function get_documenttypes($params) {
- $kt = &$this->KT;
+ $kt=&$this->KT;
- $detail = $kt->get_documenttypes();
- $result = array();
- $items = array();
+ $detail=$kt->get_documenttypes();
+ $result=array();
+ $items=array();
for($i=0;$i $detail[$i]
+ $items[]=array(
+ 'name'=>$detail[$i]
);
}
}
- $this->setResponse(array('items' => $items, 'count' => count($items)));
+ $this->setResponse(array('items'=>$items, 'count'=>count($items)));
}
function update_document_type($params) {
- $kt = &$this->KT;
- $document_id = (int)$params['document_id'];
+ $kt=&$this->KT;
+ $document_id=(int)$params['document_id'];
if($document_id > 0) {
- $document = $kt->get_document_by_id($document_id);
+ $document=$kt->get_document_by_id($document_id);
$document->change_document_type($params['document_type']);
- $this->setResponse(array('status_code' => 0));
+ $this->setResponse(array('status_code'=>0));
return true;
}else{
$this->addError("Invalid document Id : {$document_id}");
- $this->setResponse(array('status_code' => 1));
+ $this->setResponse(array('status_code'=>1));
return false;
}
@@ -447,35 +445,38 @@ class kt extends client_service {
$session_id=$params['session_id'];
- $document = &$kt->get_document_by_id($params['document_id']);
- $docname = $document->document->getFileName();
+ $document=&$kt->get_document_by_id($params['document_id']);
// $docname='test.txt';
if (PEAR::isError($document))
{
- $response['message'] = $document->getMessage();
- $this->debug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id);
+ $response['message']=$document->getMessage();
+ $this->addDebug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id);
- $this->setResponse(new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response));
+// $this->setResponse(new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response));
+ $this->setResponse($response);
return;
}
-
- $result = $document->download();
+ $docname=$document->document->getFileName();
+ $result=$document->download();
if (PEAR::isError($result))
{
- $response['message'] = $result->getMessage();
- $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage()));
+ $response['message']=$result->getMessage();
+ $this->setResponse(array('status_code'=>1, 'message'=>$result->getMessage()));
return;
}
- $session = &$kt->get_session();
- $download_manager = new KTDownloadManager();
+ $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'] = 0;
- $response['message'] = $url;
- $response['filename'] = $docname;
+ $url=$download_manager->allow_download($document);
+ //http://ktair.dev?code=750f7a09d40a3d855f2897f417baf0bbb9a1f615&d=16&u=evm2pdkkhfagon47eh2b9slqj6
+ $url=split('\?',$url);
+ $url=$url[0].'/ktwebservice/download.php?'.$url[1];
+
+ $response['status_code']=0;
+ $response['message']=$url;
+ $response['filename']=$docname;
$this->setResponse($response);
}
@@ -490,35 +491,35 @@ class kt extends client_service {
*
*/
function checkout_document($params){
- $responseType = 'kt_response';
+ $responseType='kt_response';
$kt=&$this->KT;
- $document = &$kt->get_document_by_id($params['document_id']);
+ $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()));
+ $this->setResponse(array('status_code'=>1, 'message'=>$document->getMessage()));
return;
}
- $result = $document->checkout($params['reason']);
+ $result=$document->checkout($params['reason']);
if (PEAR::isError($result))
{
$this->addError($result->getMessage());
- $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage()));
+ $this->setResponse(array('status_code'=>1, 'message'=>$result->getMessage()));
return;
}
- $url = '';
+ $url='';
if ($params['download'])
{
- $download_manager = new KTDownloadManager();
+ $download_manager=new KTDownloadManager();
$download_manager->set_session($params['session_id']);
$download_manager->cleanup();
- $url = $download_manager->allow_download($document);
+ $url=$download_manager->allow_download($document);
}
- $this->setResponse(array('status_code' => 0, 'message' => $url));
+ $this->setResponse(array('status_code'=>0, 'message'=>$url));
}
@@ -533,43 +534,43 @@ class kt extends client_service {
* @param array $params
*/
function checkin_document($params){
- $session_id = $this->AuthInfo['session'];
- $document_id = $params['document_id'];
- $filename = $params['filename'];
- $reason = $params['reason'];
- $tempfilename = $params['tempfilename'];
- $application = $this->AuthInfo['appType'];
+ $session_id=$this->AuthInfo['session'];
+ $document_id=$params['document_id'];
+ $filename=$params['filename'];
+ $reason=$params['reason'];
+ $tempfilename=$params['tempfilename'];
+ $application=$this->AuthInfo['appType'];
$this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')");
- $kt = &$this->KT;
+ $kt=&$this->KT;
// we need to add some security to ensure that people don't frig the checkin process to access restricted files.
// possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
- $upload_manager = new KTUploadManager();
+ $upload_manager=new KTUploadManager();
if (!$upload_manager->is_valid_temporary_file($tempfilename))
{
- $this->setResponse(array('status_code' => 12));
+ $this->setResponse(array('status_code'=>12));
return;
}
- $document = &$kt->get_document_by_id($document_id);
+ $document=&$kt->get_document_by_id($document_id);
if (PEAR::isError($document))
{
- $this->setResponse(array('status_code' => 13));
+ $this->setResponse(array('status_code'=>13));
}
// checkin
- $result = $document->checkin($filename, $reason, $tempfilename, false);
+ $result=$document->checkin($filename, $reason, $tempfilename, false);
if (PEAR::isError($result))
{
- $this->setResponse(array('status_code' => 14));
+ $this->setResponse(array('status_code'=>14));
}
// get status after checkin
//$this->response= $this->get_document_detail($session_id, $document_id);
- $detail = $document->get_detail();
- $detail['status_code'] = 0;
- $detail['message'] = '';
+ $detail=$document->get_detail();
+ $detail['status_code']=0;
+ $detail['message']='';
$this->setResponse($detail);
}
@@ -581,686 +582,540 @@ class kt extends client_service {
* @param unknown_type $arr
*/
function add_document_with_metadata($arr){
- $session_id = $arr['session_id'];
+ $session_id=$arr['session_id'];
//error_reporting(E_ALL);
- $metadata = array();
- $packed = @json_decode($arr['metadata']);
+ $metadata=array();
+ $packed=@json_decode($arr['metadata']);
$this->debug('Entered add_document_with_metadata');
- foreach($packed as $key => $val) {
+ foreach($packed as $key=>$val) {
if(!is_array($metadata[$val->fieldset])) {
- $metadata[$val->fieldset]['fieldset'] = $val->fieldset;
- $metadata[$val->fieldset]['fields'] = array();
+ $metadata[$val->fieldset]['fieldset']=$val->fieldset;
+ $metadata[$val->fieldset]['fields']=array();
}
- $metadata[$val->fieldset]['fields'][] = array(
- 'name' => $val->name,
- 'value' => $val->value
+ $metadata[$val->fieldset]['fields'][]=array(
+ 'name'=>$val->name,
+ 'value'=>$val->value
);
}
- $add_result = $this->add_document($arr['session_id'], $arr['folder_id'], $arr['title'], $arr['filename'], $arr['documenttype'], $arr['tempfilename'], $arr['application']);
+ $add_result=$this->add_document($arr['session_id'], $arr['folder_id'], $arr['title'], $arr['filename'], $arr['documenttype'], $arr['tempfilename'], $arr['application']);
$this->debug('$this->response= from add_document');
- $status_code = $add_result['status_code'];
+ $status_code=$add_result['status_code'];
if ($status_code != 0)
{
$this->response= $add_result;
}
- $document_id = $add_result['document_id'];
- $content_id = $add_result['content_id'];
+ $document_id=$add_result['document_id'];
+ $content_id=$add_result['content_id'];
- $update_result = $this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
+ $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
$this->debug('$this->response= from update_document_metadata');
- $status_code = $update_result['status_code'];
+ $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->response= $update_result;
}
- $kt = &$this->KT;
+ $kt=&$this->KT;
if (is_array($kt))
{
- $this->response= array('status_code' => 1);
+ $this->response= array('status_code'=>1);
}
- $document = $kt->get_document_by_id($document_id);
- $result = $document->removeUpdateNotification();
+ $document=$kt->get_document_by_id($document_id);
+ $result=$document->removeUpdateNotification();
if (PEAR::isError($result))
{
// not much we can do, maybe just log!
}
- $result = $document->mergeWithLastMetadataVersion();
+ $result=$document->mergeWithLastMetadataVersion();
if (PEAR::isError($result))
{
// not much we can do, maybe just log!
}
- $this->response= array('status_code' => 0, 'document_id' => $document_id, 'content_id' => $content_id);
+ $this->response= array('status_code'=>0, 'document_id'=>$document_id, 'content_id'=>$content_id);
}
-}
-
-
-/*
-
-
-
-
-
-
-
-
-
-
-
- function debug($str) {
- $this->response= true;
- if(!is_resource($this->dfp)) {
- $this->dfp = fopen("./debug.log", "a+");
+ function get_all_client_policies(){
+ $config=KTConfig::getSingleton();
+ $this->addDebug('KTConfig Singleton',$config);
+
+ $policies=array('allowRememberPassword', 'captureReasonsCheckin', 'captureReasonsCheckout');
+
+ $returnPolicies=array();
+
+ foreach ($policies as $policy_name)
+ {
+ $policyInfo=array(
+ 'name'=>$policy_name,
+ 'value'=>serviceHelper::bool2str($config->get('addInPolicies/'.$policy_name)),
+ 'type'=>'boolean'
+ );
+
+ $returnPolicies[$policy_name] =$policyInfo;
}
- fwrite($this->dfp, strftime("[DEBUG %Y-%m-%d %H:%M:%S] ").$str."\r\n");
+
+ $languages=$this->get_languages(true);
+
+ $metadata=array('totalProperty'=>'resultsCounter', 'root'=>'languages', 'fields'=>array('isoCode', 'language'));
+
+ $finalArray=array();
+ $finalArray['metaData']=$metadata;
+ $finalArray['policies']=$returnPolicies;
+ $finalArray['languages']=$languages['languages'];
+ $finalArray['defaultLanguage']=$languages['defaultLanguage'];
+ $finalArray['resultsCounter']=$languages['count'];
+
+
+ $this->setResponse($finalArray);
+ return true;
+ }
+
+ public function switchlang($params){
+ setcookie("kt_language", $params['lang'], 2147483647, '/');
}
+ function add_document_params($params){
+ $folder_id=$params['folder_id'];
+ $title=$params['title'];
+ $filename=$params['filename'];
+ $documenttype=$params['documenttype'];
+ $tempfilename=$params['tempfilename'];
+ $application=$params['application'];
+ $this->addDebug('','Entered add_document');
+ $kt=&$this->KT;
- function add_document_params($params)
- {
- $session_id = $params['session_id'];
- $folder_id = $params['folder_id'];
- $title = $params['title'];
- $filename = $params['filename'];
- $documenttype = $params['documenttype'];
- $tempfilename = $params['tempfilename'];
- $application = $params['application'];
-
- $this->debug('Entered add_document');
- $kt = &$this->get$this->xlateapi($session_id, $application);
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
- $this->debug("Got \$kt");
-
- $upload_manager = new KTUploadManager();
- if (!$upload_manager->is_valid_temporary_file($tempfilename))
- {
- $this->response= array('status_code' => 1);
+ $upload_manager=new KTUploadManager();
+ if (!$upload_manager->is_valid_temporary_file($tempfilename)) {
+ $this->addError('Temporary File Not Valid');
+ $this->setResponse(array('status_code'=>1));
+ return false;
}
- $this->debug('Exited is_valid_temporary file');
+ $this->addDebug('','Exited is_valid_temporary file');
- $folder = &$kt->get_folder_by_id($folder_id);
- if (PEAR::isError($folder))
- {
- $this->response= array('status_code' => 1);
+ $folder=&$kt->get_folder_by_id($folder_id);
+ if (PEAR::isError($folder)){
+ $this->addError('Could not find Folder '.$folder_id);
+ $this->setResponse(array('status_code'=>1));
+ return false;
}
- $this->debug('Exited get_folder_by_id');
+ $this->addDebug('','Exited get_folder_by_id');
- $document = &$folder->add_document($title, $filename, $documenttype, $tempfilename);
- if (PEAR::isError($document))
- {
- $this->response= array('status_code' => 1);
+ $document=&$folder->add_document($title, $filename, $documenttype, $tempfilename);
+ if (PEAR::isError($document)){
+ $this->addError("Could add Document [title:{$title},filename:{$filename},documenttype:{$documenttype},tempfilename:{$tempfilename}]");
+ $this->setResponse(array('status_code'=>1));
+ return false;
}
- $this->debug('Exited folder add_document');
+ $this->addDebug('','Exited folder add_document');
- $detail = $document->get_detail();
- $detail['status_code'] = 0;
- $detail['message'] = '';
-
- $this->response= $detail;
+ $detail=$document->get_detail();
+ $detail['status_code']=0;
+ $detail['message']='';
+ $this->setResponse($detail);
}
+
+ function delete_document($session_id, $document_id, $reason, $application){
+ $kt=&$this->KT;
-
- function add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $application)
- {
- $this->debug('Entered add_document');
- $kt = &$this->get$this->xlateapi($session_id, $application);
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
+ $document=&$kt->get_document_by_id($document_id);
+ if (PEAR::isError($document)){
+ $this->addError("Invalid document {$document_id}");
+ $this->setResponse(array('status_code'=>1));
+ return false;
}
- $this->debug("Got \$kt");
- $upload_manager = new KTUploadManager();
- if (!$upload_manager->is_valid_temporary_file($tempfilename))
- {
- $this->response= array('status_code' => 1);
+ $result=$document->delete($reason);
+ if (PEAR::isError($result)) {
+ $this->addError("Could not delete document {$document_id}");
+ $this->setResponse(array('status_code'=>1));
+ return false;
}
- $this->debug('Exited is_valid_temporary file');
-
- $folder = &$kt->get_folder_by_id($folder_id);
- if (PEAR::isError($folder))
- {
- $this->response= array('status_code' => 1);
- }
-
- $this->debug('Exited get_folder_by_id');
-
- $document = &$folder->add_document($title, $filename, $documenttype, $tempfilename);
- if (PEAR::isError($document))
- {
- $this->response= array('status_code' => 1);
- }
-
- $this->debug('Exited folder add_document');
-
- $detail = $document->get_detail();
- $detail['status_code'] = 0;
- $detail['message'] = '';
-
- $this->response= $detail;
+ $this->setResponse(array('status_code'=>0));
+ return true;
}
- function delete_document($session_id, $document_id, $reason, $application)
- {
- $kt = &$this->get$this->xlateapi($session_id, $application );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
-
-
- $document = &$kt->get_document_by_id($document_id);
- if (PEAR::isError($document))
- {
- $this->response= array('status_code' => 1);
- }
-
- $result = $document->delete($reason);
- if (PEAR::isError($result))
- {
- $this->response= array('status_code' => 1);
- }
- $response['status_code'] = 0;
-
- $this->response= $response;
-
- }
-
- function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null)
- {
- $this->debug('entered update_document_metadata');
- $kt = &$this->get$this->xlateapi($session_id, $application );
- $responseType = 'kt_response';
- if ($this->version >= 2)
- {
- $responseType = 'kt_document_detail';
- }
+ private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){
+ $this->addDebug('','entered update_document_metadata');
+ $kt=&$this->KT;
+ $responseType='kt_document_detail';
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1, 'kterror'=>$kt);
+ $document=&$kt->get_document_by_id($document_id);
+ if (PEAR::isError($document)){
+ return array('status_code'=>1, 'error'=>'Error getting document');
}
- $document = &$kt->get_document_by_id($document_id);
- if (PEAR::isError($document))
- {
- $this->response= array('status_code' => 1, 'error'=>'Error getting document');
- }
-
- $result = $document->update_metadata($metadata);
- if (PEAR::isError($result))
- {
- $this->response= array('status_code' => 1, 'error'=>'Error updating metadata');
+ $result=$document->update_metadata($metadata);
+ if (PEAR::isError($result)){
+ return array('status_code'=>1, 'error'=>'Error updating metadata');
}
- if ($this->version >= 2)
- {
- $result = $document->update_sysdata($sysdata);
- if (PEAR::isError($result))
- {
- $this->response= array('status_code' => 1, 'error'=>'Error update_sysdata');
- }
- }
- $response['status_code'] = 0;
-
- $this->response= array('status_code' => 0);
- }
-
-
- function get_client_policy($arr)
- {
- $policy_name = $arr['policy_name'];
-
- $config = KTConfig::getSingleton();
-
- $policy = array(
- 'name' => $policy_name,
- 'value' => bool2str($config->get($policy_name)),
- 'type' => 'boolean'
- );
-
- $response['policy'] = $policy;
- $response['message'] = 'Knowledgetree client policies retrieval succeeded.';
- $response['status_code'] = 0;
+ $result=$document->update_sysdata($sysdata);
+ if (PEAR::isError($result)){
+ return array('status_code'=>1, 'error'=>'Error update_sysdata');
+ }
- $this->response= $response;
+ return array('status_code'=>0);
}
- function get_all_client_policies()
- {
- $config = KTConfig::getSingleton();
-
- $policies = array('allowRememberPassword', 'captureReasonsCheckin', 'captureReasonsCheckout');
+ function get_client_policy($arr){
+ $policy_name=$arr['policy_name'];
- $$this->response=Policies = array();
+ $config=KTConfig::getSingleton();
- foreach ($policies as $policy_name)
- {
- $policyInfo = array(
- 'name' => $policy_name,
- 'value' => bool2str($config->get('addInPolicies/'.$policy_name)),
- 'type' => 'boolean'
+ $policy=array(
+ 'name'=>$policy_name,
+ 'value'=>serviceHelper::bool2str($config->get($policy_name)),
+ 'type'=>'boolean'
);
- $this->response=Policies[$policy_name] = $policyInfo;
- }
-
- $languages = $this->get_languages();
-
- $metadata = array('totalProperty'=>'resultsCounter', 'root'=>'languages', 'fields'=>array('isoCode', 'language'));
-
- $finalArray = array();
- $finalArray['metaData'] = $metadata;
- $finalArray['policies'] = $$this->response=Policies;
- $finalArray['languages'] = $languages['languages'];
- $finalArray['defaultLanguage'] = $languages['defaultLanguage'];
- $finalArray['resultsCounter'] = $languages['count'];
+ $response['policy']=$policy;
+ $response['message']='Knowledgetree client policies retrieval succeeded.';
+ $response['status_code']=0;
-
- $this->response= $finalArray;
+ $this->setResponse($response);
+ return true;
}
- function search($arr)
- {
- $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application']);
- if (is_array($kt))
- {
- $this->response= $kt;
- }
+ function search($arr){
+ $kt=&$this->KT;
- $listing = processSearchExpression("(GeneralText contains \"".$arr['query']."\")");
+ $listing=processSearchExpression("(GeneralText contains \"".$arr['query']."\")");
- $result = ListController::_processListing($listing, 'search', $arr);
+ $result=ListController::_processListing($listing, 'search', $arr);
if(!count($result)) {
-
- $result[] = array
- (
- 'text' => $this->xlate("No results found"),
- 'id' => ($listing[$i]['item_type'] == 'F' ? $listing[$i]['item_type']."_" : "").$listing[$i]['id'],
- 'leaf' => true,
- 'relevance' => 0,
+ $result[]=array(
+ 'text'=>$this->xlate("No results found"),
+ 'id'=>($listing[$i]['item_type']=='F' ? $listing[$i]['item_type']."_" : "").$listing[$i]['id'],
+ 'leaf'=>true,
+ 'relevance'=>0,
'qtip'=> $this->xlate("Please retry your search")
);
- } else {
- $result = array_slice($result, 0, 200);
+ }else{
+ $result=array_slice($result, 0, 200);
}
- $this->response= $result;
+ $this->setResponse($result);
+ return true;
}
- public function update_metadata($arr)
- {
- $session_id = $arr['session_id'];
- $metadata = array();
- $packed = @json_decode($arr['metadata']);
- $this->debug('Entered add_document_with_metadata');
+ public function update_metadata($arr){
+ $metadata=array();
+ $packed=@json_decode($arr['metadata']);
- $special = array();
+ $this->addDebug('','Entered add_document_with_metadata');
- foreach($packed as $key => $val) {
- if(substr($val->name,0,2) != '__') {
+ $special=array();
+ foreach($packed as $key=>$val) {
+ if(substr($val->name,0,2) != '__') {
if(!is_array($metadata[$val->fieldset])) {
- $metadata[$val->fieldset]['fieldset'] = $val->fieldset;
- $metadata[$val->fieldset]['fields'] = array();
+ $metadata[$val->fieldset]['fieldset']=$val->fieldset;
+ $metadata[$val->fieldset]['fields']=array();
}
- $metadata[$val->fieldset]['fields'][] = array(
- 'name' => $val->name,
- 'value' => $val->value
+ $metadata[$val->fieldset]['fields'][]=array(
+ 'name'=>$val->name,
+ 'value'=>$val->value
);
- } else {
- $special[$val->name] = $val->value;
+ }else{
+ $special[$val->name]=$val->value;
}
}
- $document_id = $arr['document_id'];
+ $document_id=$arr['document_id'];
- $update_result = $this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
- $this->debug('$this->response= from update_document_metadata');
- $status_code = $update_result['status_code'];
- if ($status_code != 0)
- {
- $this->response= $update_result;
+ $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
+ $this->addDebug('','$this->response= from update_document_metadata');
+
+ $status_code=$update_result['status_code'];
+ if ($status_code != 0){
+ $this->setResponse($update_result);
}
- $kt = &$this->get$this->xlateapi($arr['session_id']);
- if (is_array($kt))
- {
- $this->response= $kt;
- }
+ $kt=&$this->KT;
if(!empty($special)) {
-
if($document_id > 0) {
- $document = $kt->get_document_by_id($document_id);
+ $document=$kt->get_document_by_id($document_id);
if(isset($special['__title'])) {
$this->debug("Renaming to {$special['__title']}");
- $res = $document->rename($special['__title']);
+ $res=$document->rename($special['__title']);
}
}
}
- $this->response= array('status_code' => 0, 'document_id' => $document_id);
+ $this->setResponse(array('status_code'=>0, 'document_id'=>$document_id));
}
- function check_document_title($arr)
- {
-
- $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application'] );
-
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
- $folder = $kt->get_folder_by_id($arr['folder_id']);
+ function check_document_title($arr){
+ $kt=&$this->KT;
+ $folder=$kt->get_folder_by_id($arr['folder_id']);
if(PEAR::isError($folder)) {
- $this->response= array('status_code' => 1, 'reason' => 'No such folder');
+ $this->setResponse(array('status_code'=>1, 'reason'=>'No such folder'));
+ return false;
}
- $doc = $folder->get_document_by_name($arr['title']);
-
+ $doc=$folder->get_document_by_name($arr['title']);
if(PEAR::isError($doc)) {
- $this->response= array('status_code' => 1, 'reason' => 'No document with that title '.$arr['title']);
+ $this->setResponse(array('status_code'=>1, 'reason'=>'No document with that title '.$arr['title']));
+ return false;
}
- $this->response= array('status_code' => 0);
+ $this->setResponse(array('status_code'=>0));
+ return true;
}
- //$session_id, $document_id, $reason
- function cancel_checkout($params)
- {
- //$this->debug("undo_document_checkout({$params['session_id']}, {$params['document_id']}, {$params['reason']})");
-
- $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
+ function cancel_checkout($params){
+ $kt=&$this->KT;
- $document = &$kt->get_document_by_id($params['document_id']);
- if (PEAR::isError($document))
- {
- $this->response= array('status_code' => 1, 'message' => $document->getMessage());
+ $document=&$kt->get_document_by_id($params['document_id']);
+ if (PEAR::isError($document)){
+ $this->setResponse(array('status_code'=>1, 'message'=>$document->getMessage()));
+ return false;
}
- $result = $document->undo_checkout($params['reason']);
- if (PEAR::isError($result))
- {
- $this->response= array('status_code' => 1, 'message' => $result->getMessage());
+ $result=$document->undo_checkout($params['reason']);
+ if (PEAR::isError($result)){
+ $this->setResponse(array('status_code'=>1, 'message'=>$result->getMessage()));
+ return false;
}
-
- $response['status_code'] = 0;
-
- $this->response= $response;
+ $response['status_code']=0;
+ $this->setResponse($response);
}
- function get_users_groups($params)
- {
- $kt = &$this->get$this->xlateapi($params['session_id'],$params['application'] );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
-
- $query = $params['query'];
- //$start = $params['start'];
- //$page = $params['page'];
- $results = KTAPI_User::getList('name LIKE "%'.$query.'%" AND id>0');
-
- $$this->response=Array = array();
-
- if (count($results) > 0) {
- foreach ($results as $user)
- {
- $$this->response=Array[] = array('emailid'=>'u_'.$user->getId(), 'name'=> $user->getName(), 'to'=>preg_replace('/('.$query.')/i', '${0}', $user->getName()));
+ public function get_users_groups($params){
+ $kt=&$this->KT;
+ $query=$params['query'];
+ //$start=$params['start'];
+ //$page=$params['page'];
+
+ $results=KTAPI_User::getList('name LIKE "%'.$query.'%" AND id>0');
+ $returnArray=array();
+ if (count($results) > 0){
+ foreach ($results as $user){
+ $returnArray[]=array('emailid'=>'u_'.$user->getId(), 'name'=> $user->getName(), 'to'=>preg_replace('/('.$query.')/i', '${0}', $user->getName()));
}
}
-
- $groups = KTAPI_Group::getList('name LIKE "%'.$query.'%"');
-
- if (count($groups) > 0) {
- foreach ($groups as $group)
- {
- $$this->response=Array[] = array('emailid'=>'g_'.$group->getId(), 'name'=> $group->getName(), 'to'=>preg_replace('/('.$query.')/i', '${0}', $group->getName()));
+
+ $groups=KTAPI_Group::getList('name LIKE "%'.$query.'%"');
+ if (count($groups) > 0){
+ foreach ($groups as $group){
+ $returnArray[]=array('emailid'=>'g_'.$group->getId(), 'name'=> $group->getName(), 'to'=>preg_replace('/('.$query.')/i', '${0}', $group->getName()));
}
}
-
-
- $sendArray = array ('emails'=>$$this->response=Array, 'metaData'=>array('count'=>count($finalArray), 'root'=>'emails', fields=>array('name', 'to', 'emailid')));
-
- $this->response= $sendArray;
-
-
-
+
+ $sendArray=array ('emails'=>$returnArray, 'metaData'=>array('count'=>count($finalArray), 'root'=>'emails', fields=>array('name', 'to', 'emailid')));
+ $this->setResponse($sendArray);
+ return true;
}
-
- function send_email($params)
- {
- $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
-
-
- $message = $params['message'];
- $list = $params['users'];
-
-
- $recipientsList = array();
-
- $list = explode(',', $list);
-
- foreach ($list as $recipient)
- {
- if (trim($recipient) != '') { // check that value is present
-
+
+
+ function send_email($params){
+ $kt=&$this->KT;
+
+ $message=$params['message'];
+ $list=$params['users'];
+ $list=explode(',', $list);
+
+ $recipientsList=array();
+
+ foreach ($list as $recipient){
+ if (trim($recipient) != ''){ // check that value is present
// if @ sign is present, signifies email address
- if(strpos($recipient, '@') === false) {
- // Not email
- $recipient = trim($recipient);
-
- switch (substr($recipient, 0, 2))
- {
+ if(strpos($recipient, '@') === false) {
+ $recipient=trim($recipient);
+ switch (substr($recipient, 0, 2)){
case 'u_':
- $id = substr($recipient, 2);
- $user = KTAPI_User::getById($id);
-
- if ($user != null) {
- $recipientsList[] = $user;
+ $id=substr($recipient, 2);
+ $user=KTAPI_User::getById($id);
+ if ($user != null){
+ $recipientsList[]=$user;
}
-
break;
case 'g_':
- $id = substr($recipient, 2);
- $group = KTAPI_Group::getById($id);
-
+ $id=substr($recipient, 2);
+ $group=KTAPI_Group::getById($id);
if ($group != null) {
- $recipientsList[] = $group;
+ $recipientsList[]=$group;
}
break;
}
-
- } else { // Email - just add to list
- $recipientsList[] = trim($recipient);
+ }else{ // Email - just add to list
+ $recipientsList[]=trim($recipient);
}
}
}
-
- $document = $kt->get_document_by_id($params['document']);
-
-
- if (count($recipientsList) == 0) {
- $this->response= array('status'=>'norecipients');
- } else {
+
+ $document=$kt->get_document_by_id($params['document']);
+ if (count($recipientsList)==0) {
+ $this->setResponse(array('status'=>'norecipients'));
+ return false;
+ }else{
$document->email($recipientsList, $message, TRUE); // true to attach document
- $this->response= array('status'=>'documentemailed');
+ $this->setResponse(array('status'=>'documentemailed'));
}
-
-
+ return true;
}
- function is_latest_version($params)
- {
+ function is_latest_version($params){
$kt=&$this->KT;
-
-
- if (is_array($kt))
- {
- $this->response= $kt;
- }
-
- $documentId = $params['document_id'];
- $contentId = $params['content_id'];
-
- $result = $kt->is_latest_version($documentId, $contentId);
-
- $this->response= $result;
-
+
+ $documentId=$params['document_id'];
+ $contentId=$params['content_id'];
+
+ $result=$kt->is_latest_version($documentId, $contentId);
+
+ $this->setResponse($result);
+ return true;
}
-
- function check_permission($params)
- {
+
+ function check_permission($params){
$kt=&$this->KT;
-
-
- if (is_array($kt))
- {
- $this->response= $kt;
- }
-
- $user = $kt->get_user();
-
- $document = $kt->get_document_by_id($params['document_id']);
-
- $folder = &$kt->get_folder_by_id($document->ktapi_folder->folderid);
-
- $folderDetail = $folder->get_detail();
-
- $permissions = $folderDetail['permissions'];
-
- if ($user->getId() == $document->document->getCheckedOutUserID()) {
+
+ $user=$kt->get_user();
+ $document=$kt->get_document_by_id($params['document_id']);
+ $folder=&$kt->get_folder_by_id($document->ktapi_folder->folderid);
+ $folderDetail=$folder->get_detail();
+ $permissions=$folderDetail['permissions'];
+ if ($user->getId()==$document->document->getCheckedOutUserID()){
$permissions .= 'E';
}
-
- $this->response= array('status_code'=>0, 'permissions'=>$permissions);
- //$this->response= $permissions;
+
+ $this->setResponse(array('status_code'=>0, 'permissions'=>$permissions));
+ return true;
}
+ function copydocument($params){
+ $kt=&$this->KT;
- function renamefolder($params)
- {
- $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
-
- $response = $kt->rename_folder($params['currentfolderid'], $params['newname']);
-
- if ($response['status_code'] == 0) {
- $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Renamed'), 'message'=>$this->xlate('Folder has been successfully renamed'));
- } else {
- $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to rename folder'), 'message'=>$this->xlate('Unable to rename folder')); //$response['message']
+ $response=$kt->copy_document($params['documentid'], $params['destfolderid']);
+ if ($response['status_code']==0) {
+ $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Document Copied'), 'message'=>$this->xlate('Document has been successfully copied')));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to copy document'), 'message'=>$this->xlate('Unable to copy document')));
+ return false;
}
-
}
- function addfolder($params)
- {
- $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
- }
-
-
- $response = $kt->create_folder($params['currentfolderid'], $params['newname']);
+ function movedocument($params){
+ $kt=$this->KT;
- if ($response['status_code'] == 0) {
- $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Created'), 'message'=>$this->xlate('Folder has been successfully created'), 'id' =>$response['results']['id']); //$params['newname']);//
- } else {
- $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to create folder'), 'message'=>$this->xlate('Unable to create folder')); //$response['message']
+ $response=$kt->move_document($params['documentid'], $params['destfolderid']);
+ if ($response['status_code']==0) {
+ $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Document Moved'), 'message'=>$this->xlate('Document has been successfully moved')));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to move document'), 'message'=>$this->xlate('Unable to move document')));
+ return false;
}
-
+
}
-
- function deletefolder($params)
- {
- $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );
- if (is_array($kt))
- {
- $this->response= array('status_code' => 1);
+
+ function copyfolder($params){
+ $kt=&$this->KT;
+
+ $response=$kt->copy_folder($params['sourcefolderid'], $params['destfolderid']);
+ if ($response['status_code']==0) {
+ $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Copied'), 'message'=>$this->xlate('Folder has been successfully copied')));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to copy folder'), 'message'=>$this->xlate('Unable to copy folder')));
+ return false;
}
+
+ }
- $response = $kt->delete_folder($params['folderid'], 'Deleted from office addin');
+ function movefolder($params){
+ $kt=&$this->KT;
- if ($response['status_code'] == 0) {
- $this->response= array('status_code' => 0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>$this->xlate('Folder Deleted'), 'message'=>$this->xlate('Folder has been successfully deleted'));
- } else {
- $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to delete folder'), 'message'=>$this->xlate('Unable to delete folder')); //$response['message']
+ $response=$kt->move_folder($params['sourcefolderid'], $params['destfolderid']);
+ if ($response['status_code']==0) {
+ $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Moved'), 'message'=>$this->xlate('Folder has been successfully moved')));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to move folder'), 'message'=>$this->xlate('Unable to move folder')));
+ return false;
}
-
}
- function candeletefolder($arr)
- {
- $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application']);
-
- if (is_array($kt))
- {
- $this->response= $kt;
+
+ function renamefolder($params){
+ $kt=&$this->KT;
+
+ $response=$kt->rename_folder($params['currentfolderid'], $params['newname']);
+ if ($response['status_code']==0) {
+ $this->setResponse(array('status_code'=>0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Renamed'), 'message'=>$this->xlate('Folder has been successfully renamed')));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to rename folder'), 'message'=>$this->xlate('Unable to rename folder')));
+ return false;
}
+ }
-
- $folder = &$kt->get_folder_by_id($arr['folderid']);
- if (PEAR::isError($folder))
- {
- $response = 'error';
-
- $this->response= 'error 1';
+ function addfolder($params) {
+ $kt=&$this->KT;
+ $this->addDebug('parameters',$params);
+ $response=$kt->create_folder($params['currentfolderid'], $params['newname']);
+ $this->setResponse($response);
+ return true;
+ }
+
+ function deletefolder($params){
+ $kt=&$this->KT;
+
+ $response=$kt->delete_folder($params['folderid'], 'Deleted from office addin');
+ if ($response['status_code']==0) {
+ $this->setResponse(array('status_code'=>0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>$this->xlate('Folder Deleted'), 'message'=>$this->xlate('Folder has been successfully deleted')));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to delete folder'), 'message'=>$this->xlate('Unable to delete folder')));
+ return false;
}
-
-
- $listing = $folder->get_listing(1, 'DF');
-
- if (count($listing) == 0) {
- $this->response= array('status_code' => 0, 'candelete'=>TRUE);
- } else {
- $this->response= array('status_code' => 0, 'candelete'=>FALSE);
+ }
+
+ function candeletefolder($arr){
+ $kt=&$this->KT;
+
+ $folder=&$kt->get_folder_by_id($arr['folderid']);
+ if (PEAR::isError($folder)){
+ $this->setResponse('error 1');
+ return false;
+ }
+
+ $listing=$folder->get_listing(1, 'DF');
+ if (count($listing)==0) {
+ $this->setResponse(array('status_code'=>0, 'candelete'=>TRUE));
+ return true;
+ }else{
+ $this->setResponse(array('status_code'=>0, 'candelete'=>FALSE));
+ return true;
}
}
-
-*/
+}
?>
\ No newline at end of file
diff --git a/webservice/clienttools/services/3.6.1/server.php b/webservice/clienttools/services/3.6.1/server.php
index 160e565..0ccb49c 100644
--- a/webservice/clienttools/services/3.6.1/server.php
+++ b/webservice/clienttools/services/3.6.1/server.php
@@ -1,7 +1,7 @@
setResponse(array('online'=>true));
}
public function ping(){