Commit 4b8cd0112a919fae87a5af45cc50a731c5399c60

Authored by Kevin G Fourie
2 parents d72bc3ae 7bbaa40a

Merge branch 'edge' of github.com:ktgit/knowledgetree into edge

.gitignore
@@ -8,3 +8,6 @@ bin/luceneserver/lucene.pid @@ -8,3 +8,6 @@ bin/luceneserver/lucene.pid
8 dummy.php 8 dummy.php
9 var/* 9 var/*
10 plugins/commercial 10 plugins/commercial
  11 +clienttools/Karoo
  12 +clienttools/Office
  13 +.gitmodules
11 \ No newline at end of file 14 \ No newline at end of file
bin/diagtools/ReportTemplate.html 0 โ†’ 100644
  1 +<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #000066; background-color:#DADADE"><tr><td style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; padding:10px; border-bottom: 1px solid #666666">[heading]</td></tr><tr><td style="font-size:12px; background-color:#FFFFFF; padding:10px 5px 20px 5px;"><pre>[content]</pre></td></tr></table>
0 \ No newline at end of file 2 \ No newline at end of file
bin/diagtools/winDiag.php 0 โ†’ 100644
  1 +<?php
  2 +/*
  3 + $template=file_get_contents('ReportTemplate.html');
  4 +
  5 + $rep=array();
  6 + $rep['running processes']=shell_exec('tasklist');
  7 + $rep['services']=shell_exec('sc query');
  8 + $rep['system path']=shell_exec('path');
  9 + $rep['environment variables']=shell_exec('set');
  10 +
  11 + $report=array();
  12 +
  13 + foreach ($rep as $test=>$results){
  14 + $test=ucwords($test);
  15 + $report[]=str_replace(array('[heading]','[content]'),array($test,$results),$template);
  16 + }
  17 +
  18 + $report=join('',$report);
  19 +
  20 + echo $report;
  21 +*/
  22 +?>
0 \ No newline at end of file 23 \ No newline at end of file
ktwebservice/1-20090903194035 0 โ†’ 100644
  1 +<?xml version="1.0"?>
  2 +<Document xmlns="http://www.evolus.vn/Namespace/Pencil"><Properties/><Pages><Page><Properties><Property name="name">Acorn Layout</Property><Property name="id">1247050268296_4354</Property><Property name="width">1024</Property><Property name="height">768</Property><Property name="dimBackground">false</Property></Properties><Content><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.Common:RoundedRect" transform="matrix(1, 0, 0, 1, 0, 0)" p:locked="true"><p:metadata><p:property name="box"><![CDATA[1030,770]]></p:property><p:property name="withBlur"><![CDATA[false]]></p:property><p:property name="radius"><![CDATA[7,0]]></p:property><p:property name="textPadding"><![CDATA[0,10]]></p:property><p:property name="fillColor"><![CDATA[#336699FF]]></p:property><p:property name="strokeColor"><![CDATA[#000000FF]]></p:property><p:property name="strokeStyle"><![CDATA[0|]]></p:property><p:property name="textContent"><![CDATA[]]></p:property><p:property name="textFont"><![CDATA[Arial|normal|normal|12px|none]]></p:property><p:property name="textColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="textAlign"><![CDATA[1,1]]></p:property></p:metadata>
  3 +
  4 + <defs>
  5 + <rect width="1030" height="770" rx="7" ry="7" x="0" y="0" style="stroke-width: 0pt; fill: rgb(51, 102, 153); fill-opacity: 1; stroke: rgb(0, 0, 0); stroke-opacity: 1;" p:name="rrRect" id="rrRect11247050298197" transform="translate(0)"/>
  6 + <filter height="1.2558399" y="-0.12792" width="1.06396" x="-0.03198" p:name="shadingFilter" id="shadingFilter11247050298197">
  7 + <feGaussianBlur stdDeviation="1" in="SourceAlpha"/>
  8 + </filter>
  9 + </defs>
  10 + <use xlink:href="#rrRect11247050298197" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(2, 2)" p:filter="url(#shadingFilter11247050298197)" style="opacity: 0.5; visibility: hidden;" p:heavy="true" p:name="bgCopy" id="bgCopy11247050298197"/>
  11 + <use xlink:href="#rrRect11247050298197" xmlns:xlink="http://www.w3.org/1999/xlink"/>
  12 + <foreignObject x="10" y="385" width="1010" height="0" p:name="text" id="text11247050298197" style="font-family: Arial; font-size: 12px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(255, 255, 255); fill-opacity: 1; color: rgb(255, 255, 255); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"/></foreignObject><path id="text11247050298197_underline" style="fill: none; stroke-width: 1px; visibility: hidden;"/>
  13 + </g><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.Common:RoundedRect" transform="matrix(1, 0, 0, 1, 13, 92)"><p:metadata><p:property name="box"><![CDATA[210,550]]></p:property><p:property name="withBlur"><![CDATA[false]]></p:property><p:property name="radius"><![CDATA[7,0]]></p:property><p:property name="textPadding"><![CDATA[0,10]]></p:property><p:property name="fillColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="strokeColor"><![CDATA[#000000FF]]></p:property><p:property name="strokeStyle"><![CDATA[0|]]></p:property><p:property name="textContent"><![CDATA[]]></p:property><p:property name="textFont"><![CDATA[Arial|normal|normal|12px|none]]></p:property><p:property name="textColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="textAlign"><![CDATA[1,1]]></p:property></p:metadata>
  14 +
  15 + <defs>
  16 + <rect width="210" height="550" rx="7" ry="7" x="0" y="0" style="stroke-width: 0pt; fill: rgb(255, 255, 255); fill-opacity: 1; stroke: rgb(0, 0, 0); stroke-opacity: 1;" p:name="rrRect" id="rrRect21247050338773" transform="translate(0)"/>
  17 + <filter height="1.2558399" y="-0.12792" width="1.06396" x="-0.03198" p:name="shadingFilter" id="shadingFilter21247050338773">
  18 + <feGaussianBlur stdDeviation="1" in="SourceAlpha"/>
  19 + </filter>
  20 + </defs>
  21 + <use xlink:href="#rrRect21247050338773" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(2, 2)" p:filter="url(#shadingFilter21247050338773)" style="opacity: 0.5; visibility: hidden;" p:heavy="true" p:name="bgCopy" id="bgCopy21247050338773"/>
  22 + <use xlink:href="#rrRect21247050338773" xmlns:xlink="http://www.w3.org/1999/xlink"/>
  23 + <foreignObject x="10" y="275" width="190" height="0" p:name="text" id="text21247050338773" style="font-family: Arial; font-size: 12px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(255, 255, 255); fill-opacity: 1; color: rgb(255, 255, 255); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"/></foreignObject><path id="text21247050338773_underline" style="fill: none; stroke-width: 1px; visibility: hidden;"/>
  24 + </g><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.Common:RoundedRect" transform="matrix(1, 0, 0, 1, 235, 90)"><p:metadata><p:property name="box"><![CDATA[560,550]]></p:property><p:property name="withBlur"><![CDATA[false]]></p:property><p:property name="radius"><![CDATA[7,0]]></p:property><p:property name="textPadding"><![CDATA[0,10]]></p:property><p:property name="fillColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="strokeColor"><![CDATA[#000000FF]]></p:property><p:property name="strokeStyle"><![CDATA[0|]]></p:property><p:property name="textContent"><![CDATA[]]></p:property><p:property name="textFont"><![CDATA[Arial|normal|normal|12px|none]]></p:property><p:property name="textColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="textAlign"><![CDATA[1,1]]></p:property></p:metadata>
  25 +
  26 + <defs>
  27 + <rect width="560" height="550" rx="7" ry="7" x="0" y="0" style="stroke-width: 0pt; fill: rgb(255, 255, 255); fill-opacity: 1; stroke: rgb(0, 0, 0); stroke-opacity: 1;" p:name="rrRect" id="rrRect31247050400981" transform="translate(0)"/>
  28 + <filter height="1.2558399" y="-0.12792" width="1.06396" x="-0.03198" p:name="shadingFilter" id="shadingFilter31247050400981">
  29 + <feGaussianBlur stdDeviation="1" in="SourceAlpha"/>
  30 + </filter>
  31 + </defs>
  32 + <use xlink:href="#rrRect31247050400981" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(2, 2)" p:filter="url(#shadingFilter31247050400981)" style="opacity: 0.5; visibility: hidden;" p:heavy="true" p:name="bgCopy" id="bgCopy31247050400981"/>
  33 + <use xlink:href="#rrRect31247050400981" xmlns:xlink="http://www.w3.org/1999/xlink"/>
  34 + <foreignObject x="10" y="275" width="540" height="0" p:name="text" id="text31247050400981" style="font-family: Arial; font-size: 12px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(255, 255, 255); fill-opacity: 1; color: rgb(255, 255, 255); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"/></foreignObject><path id="text31247050400981_underline" style="fill: none; stroke-width: 1px; visibility: hidden;"/>
  35 + </g><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.Common:RoundedRect" transform="matrix(1, 0, 0, 1, 803, 92)"><p:metadata><p:property name="box"><![CDATA[210,550]]></p:property><p:property name="withBlur"><![CDATA[false]]></p:property><p:property name="radius"><![CDATA[7,0]]></p:property><p:property name="textPadding"><![CDATA[0,10]]></p:property><p:property name="fillColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="strokeColor"><![CDATA[#000000FF]]></p:property><p:property name="strokeStyle"><![CDATA[0|]]></p:property><p:property name="textContent"><![CDATA[]]></p:property><p:property name="textFont"><![CDATA[Arial|normal|normal|12px|none]]></p:property><p:property name="textColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="textAlign"><![CDATA[1,1]]></p:property></p:metadata>
  36 +
  37 + <defs>
  38 + <rect width="210" height="550" rx="7" ry="7" x="0" y="0" style="stroke-width: 0pt; fill: rgb(255, 255, 255); fill-opacity: 1; stroke: rgb(0, 0, 0); stroke-opacity: 1;" p:name="rrRect" id="rrRect21247050338773133" transform="translate(0)"/>
  39 + <filter height="1.2558399" y="-0.12792" width="1.06396" x="-0.03198" p:name="shadingFilter" id="shadingFilter21247050338773133">
  40 + <feGaussianBlur stdDeviation="1" in="SourceAlpha"/>
  41 + </filter>
  42 + </defs>
  43 + <use xlink:href="#rrRect21247050338773133" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(2, 2)" p:filter="url(#shadingFilter21247050338773133)" style="opacity: 0.5; visibility: hidden;" p:heavy="true" p:name="bgCopy" id="bgCopy21247050338773133"/>
  44 + <use xlink:href="#rrRect21247050338773133" xmlns:xlink="http://www.w3.org/1999/xlink"/>
  45 + <foreignObject x="10" y="275" width="190" height="0" p:name="text" id="text21247050338773133" style="font-family: Arial; font-size: 12px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(255, 255, 255); fill-opacity: 1; color: rgb(255, 255, 255); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"/></foreignObject><path id="text21247050338773_underline133" style="fill: none; stroke-width: 1px; visibility: hidden;"/>
  46 + </g><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.Common:RoundedRect" transform="matrix(1, 0, 0, 1, 15, 8)"><p:metadata><p:property name="box"><![CDATA[995,72]]></p:property><p:property name="withBlur"><![CDATA[false]]></p:property><p:property name="radius"><![CDATA[7,0]]></p:property><p:property name="textPadding"><![CDATA[0,10]]></p:property><p:property name="fillColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="strokeColor"><![CDATA[#000000FF]]></p:property><p:property name="strokeStyle"><![CDATA[0|]]></p:property><p:property name="textContent"><![CDATA[]]></p:property><p:property name="textFont"><![CDATA[Arial|normal|normal|12px|none]]></p:property><p:property name="textColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="textAlign"><![CDATA[1,1]]></p:property></p:metadata>
  47 +
  48 + <defs>
  49 + <rect width="995" height="72" rx="7" ry="7" x="0" y="0" style="stroke-width: 0pt; fill: rgb(255, 255, 255); fill-opacity: 1; stroke: rgb(0, 0, 0); stroke-opacity: 1;" p:name="rrRect" id="rrRect21247050338773112" transform="translate(0)"/>
  50 + <filter height="1.2558399" y="-0.12792" width="1.06396" x="-0.03198" p:name="shadingFilter" id="shadingFilter21247050338773112">
  51 + <feGaussianBlur stdDeviation="1" in="SourceAlpha"/>
  52 + </filter>
  53 + </defs>
  54 + <use xlink:href="#rrRect21247050338773112" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(2, 2)" p:filter="url(#shadingFilter21247050338773112)" style="opacity: 0.5; visibility: hidden;" p:heavy="true" p:name="bgCopy" id="bgCopy21247050338773112"/>
  55 + <use xlink:href="#rrRect21247050338773112" xmlns:xlink="http://www.w3.org/1999/xlink"/>
  56 + <foreignObject x="10" y="36" width="975" height="0" p:name="text" id="text21247050338773112" style="font-family: Arial; font-size: 12px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(255, 255, 255); fill-opacity: 1; color: rgb(255, 255, 255); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"/></foreignObject><path id="text21247050338773112_underline" style="fill: none; stroke-width: 1px; visibility: hidden;"/><path id="text21247050338773_underline112" style="fill: none; stroke-width: 1px; visibility: hidden;"/>
  57 + </g><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.Common:RoundedRect" transform="matrix(1, 0, 0, 1, 15, 655)"><p:metadata><p:property name="box"><![CDATA[995,72]]></p:property><p:property name="withBlur"><![CDATA[false]]></p:property><p:property name="radius"><![CDATA[7,0]]></p:property><p:property name="textPadding"><![CDATA[0,10]]></p:property><p:property name="fillColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="strokeColor"><![CDATA[#000000FF]]></p:property><p:property name="strokeStyle"><![CDATA[0|]]></p:property><p:property name="textContent"><![CDATA[]]></p:property><p:property name="textFont"><![CDATA[Arial|normal|normal|12px|none]]></p:property><p:property name="textColor"><![CDATA[#FFFFFFFF]]></p:property><p:property name="textAlign"><![CDATA[1,1]]></p:property></p:metadata>
  58 +
  59 + <defs>
  60 + <rect width="995" height="72" rx="7" ry="7" x="0" y="0" style="stroke-width: 0pt; fill: rgb(255, 255, 255); fill-opacity: 1; stroke: rgb(0, 0, 0); stroke-opacity: 1;" p:name="rrRect" id="rrRect2124705033877311249" transform="translate(0)"/>
  61 + <filter height="1.2558399" y="-0.12792" width="1.06396" x="-0.03198" p:name="shadingFilter" id="shadingFilter2124705033877311249">
  62 + <feGaussianBlur stdDeviation="1" in="SourceAlpha"/>
  63 + </filter>
  64 + </defs>
  65 + <use xlink:href="#rrRect2124705033877311249" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(2, 2)" p:filter="url(#shadingFilter2124705033877311249)" style="opacity: 0.5; visibility: hidden;" p:heavy="true" p:name="bgCopy" id="bgCopy2124705033877311249"/>
  66 + <use xlink:href="#rrRect2124705033877311249" xmlns:xlink="http://www.w3.org/1999/xlink"/>
  67 + <foreignObject x="10" y="36" width="975" height="0" p:name="text" id="text2124705033877311249" style="font-family: Arial; font-size: 12px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(255, 255, 255); fill-opacity: 1; color: rgb(255, 255, 255); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"/></foreignObject><path id="text21247050338773112_underline49" style="fill: none; stroke-width: 1px; visibility: hidden;"/><path id="text21247050338773_underline11249" style="fill: none; stroke-width: 1px; visibility: hidden;"/>
  68 + </g></Content></Page></Pages></Document>
0 \ No newline at end of file 69 \ No newline at end of file
ktwebservice/KTDownloadManager.inc.php
@@ -60,10 +60,8 @@ class KTDownloadManager @@ -60,10 +60,8 @@ class KTDownloadManager
60 $this->age = $config->get('webservice/downloadExpiry',5); 60 $this->age = $config->get('webservice/downloadExpiry',5);
61 61
62 $protocol = $config->get('KnowledgeTree/sslEnabled')?'https':'http'; 62 $protocol = $config->get('KnowledgeTree/sslEnabled')?'https':'http';
63 - $server = KTUtil::getServerName(TRUE);  
64 - $url = $config->get('webservice/downloadUrl');  
65 63
66 - $this->download_url = $protocol . '://' . $server . $url; 64 + $this->download_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $config->get('webservice/downloadUrl');
67 $this->random=$config->get('webservice/randomKeyText','jhsdf8q1jkjpoiudfs7sd3ds1'); 65 $this->random=$config->get('webservice/randomKeyText','jhsdf8q1jkjpoiudfs7sd3ds1');
68 } 66 }
69 67
ktwebservice/KTUploadManager.inc.php
@@ -110,7 +110,6 @@ class KTUploadManager @@ -110,7 +110,6 @@ class KTUploadManager
110 return ($tempdir == $this->temp_dir); 110 return ($tempdir == $this->temp_dir);
111 */ 111 */
112 } 112 }
113 -  
114 function store_base64_file($base64, $prefix= 'sa_') 113 function store_base64_file($base64, $prefix= 'sa_')
115 { 114 {
116 $tempfilename = $this->get_temp_filename($prefix); 115 $tempfilename = $this->get_temp_filename($prefix);
@@ -134,36 +133,6 @@ class KTUploadManager @@ -134,36 +133,6 @@ class KTUploadManager
134 133
135 return $tempfilename; 134 return $tempfilename;
136 } 135 }
137 -  
138 - /**  
139 - *  
140 - * @param string $content file content NOT base64 encoded (may be string, may be binary)  
141 - * @param string $prefix [optional]  
142 - * @return $tempfilename the name of the temporary file created  
143 - */  
144 - function store_file($content, $prefix= 'sa_')  
145 - {  
146 - $tempfilename = $this->get_temp_filename($prefix);  
147 - if (!is_writable($tempfilename))  
148 - {  
149 - return new PEAR_Error("Cannot write to file: $tempfilename");  
150 - }  
151 -  
152 - if (!$this->is_valid_temporary_file($tempfilename))  
153 - {  
154 - return new PEAR_Error("Invalid temporary file: $tempfilename. There is a problem with the temporary storage path: $this->temp_dir.");  
155 - }  
156 -  
157 - $fp=fopen($tempfilename, 'wb');  
158 - if ($fp === false)  
159 - {  
160 - return new PEAR_Error("Cannot write content to temporary file: $tempfilename.");  
161 - }  
162 - fwrite($fp, $content);  
163 - fclose($fp);  
164 -  
165 - return $tempfilename;  
166 - }  
167 136
168 /** 137 /**
169 * This tells the manager to manage a file that has been uploaded. 138 * This tells the manager to manage a file that has been uploaded.
ktwebservice/download.php
@@ -77,7 +77,7 @@ $response = $download_manager-&gt;download($document_id, $hash, null, $apptype); @@ -77,7 +77,7 @@ $response = $download_manager-&gt;download($document_id, $hash, null, $apptype);
77 if (PEAR::isError($response)) 77 if (PEAR::isError($response))
78 { 78 {
79 $msg = urlencode($response->getMessage()); 79 $msg = urlencode($response->getMessage());
80 - print "status_code=4&msg=$msg"; 80 + print "status_code=4&msg=$msg:".$_GET["u"].":".$_GET["d"].":".$_GET["code"].":".$_GET["apptype"].":";
81 exit; 81 exit;
82 } 82 }
83 83
ktwebservice/upload.php
@@ -117,6 +117,7 @@ foreach($_FILES as $key =&gt;$file) @@ -117,6 +117,7 @@ foreach($_FILES as $key =&gt;$file)
117 $tempfile=$file['tmp_name']; 117 $tempfile=$file['tmp_name'];
118 118
119 $error=$file['error']; 119 $error=$file['error'];
  120 + $extra = $filename.'-'.$tempfile.'-'.$error;
120 if ($error == UPLOAD_ERR_OK) 121 if ($error == UPLOAD_ERR_OK)
121 { 122 {
122 $result = $upload_manager->uploaded($filename, $tempfile, $action); 123 $result = $upload_manager->uploaded($filename, $tempfile, $action);
@@ -145,7 +146,7 @@ if ($failed) @@ -145,7 +146,7 @@ if ($failed)
145 } 146 }
146 else 147 else
147 { 148 {
148 - respond(0, '', $added); 149 + respond(0, 'It worked'.$extra, $added);
149 } 150 }
150 151
151 function respond($code, $msg, $uploads=array()) 152 function respond($code, $msg, $uploads=array())
setup/wizard/installUtil.php
@@ -280,6 +280,7 @@ class InstallUtil { @@ -280,6 +280,7 @@ class InstallUtil {
280 280
281 if(is_writable($dir)){ 281 if(is_writable($dir)){
282 $ret['class'] = 'tick'; 282 $ret['class'] = 'tick';
  283 +
283 return $ret; 284 return $ret;
284 } 285 }
285 286
@@ -357,6 +358,14 @@ class InstallUtil { @@ -357,6 +358,14 @@ class InstallUtil {
357 return true; 358 return true;
358 } 359 }
359 360
  361 + /**
  362 + * Attempt using the php-java bridge
  363 + *
  364 + * @author KnowledgeTree Team
  365 + * @access public
  366 + * @param none
  367 + * @return boolean
  368 + */
360 public function javaBridge() { 369 public function javaBridge() {
361 try { 370 try {
362 $javaSystem = new Java('java.lang.System'); 371 $javaSystem = new Java('java.lang.System');
@@ -365,8 +374,16 @@ class InstallUtil { @@ -365,8 +374,16 @@ class InstallUtil {
365 } 374 }
366 return true; 375 return true;
367 } 376 }
368 -  
369 - function tryJava1() { 377 +
  378 + /**
  379 + * Attempt java detection
  380 + *
  381 + * @author KnowledgeTree Team
  382 + * @access public
  383 + * @param none
  384 + * @return boolean
  385 + */
  386 + public function tryJava1() {
370 $response = $this->pexec("java -version"); // Java Runtime Check 387 $response = $this->pexec("java -version"); // Java Runtime Check
371 if(empty($response['out'])) { 388 if(empty($response['out'])) {
372 return false; 389 return false;
@@ -375,7 +392,15 @@ class InstallUtil { @@ -375,7 +392,15 @@ class InstallUtil {
375 return 'java'; 392 return 'java';
376 } 393 }
377 394
378 - function tryJava2() { 395 + /**
  396 + * Attempt java detection
  397 + *
  398 + * @author KnowledgeTree Team
  399 + * @access public
  400 + * @param none
  401 + * @return boolean
  402 + */
  403 + public function tryJava2() {
379 $response = $this->pexec("java"); // Java Runtime Check 404 $response = $this->pexec("java"); // Java Runtime Check
380 if(empty($response['out'])) { 405 if(empty($response['out'])) {
381 return false; 406 return false;
@@ -384,7 +409,15 @@ class InstallUtil { @@ -384,7 +409,15 @@ class InstallUtil {
384 return 'java'; 409 return 'java';
385 } 410 }
386 411
387 - function tryJava3() { 412 + /**
  413 + * Attempt java detection
  414 + *
  415 + * @author KnowledgeTree Team
  416 + * @access public
  417 + * @param none
  418 + * @return boolean
  419 + */
  420 + public function tryJava3() {
388 $response = $this->pexec("whereis java"); // Java Runtime Check 421 $response = $this->pexec("whereis java"); // Java Runtime Check
389 if(empty($response['out'])) { 422 if(empty($response['out'])) {
390 return false; 423 return false;
@@ -454,7 +487,7 @@ class InstallUtil { @@ -454,7 +487,7 @@ class InstallUtil {
454 $response = $this->tryJava3(); 487 $response = $this->tryJava3();
455 } 488 }
456 } 489 }
457 - 490 +// return false;
458 return $response; 491 return $response;
459 } 492 }
460 493
@@ -468,7 +501,16 @@ class InstallUtil { @@ -468,7 +501,16 @@ class InstallUtil {
468 */ 501 */
469 function getPhp() { 502 function getPhp() {
470 $cmd = "whereis php"; 503 $cmd = "whereis php";
471 - $response = $this->pexec($cmd); 504 + $res = $this->getPhpHelper($cmd);
  505 + if($res != '') {
  506 + return $res;
  507 + }
  508 + $cmd = "which php";
  509 + return $this->getPhpHelper($cmd);
  510 + }
  511 +
  512 + function getPhpHelper($cmd) {
  513 + $response = $this->pexec($cmd);
472 if(is_array($response['out'])) { 514 if(is_array($response['out'])) {
473 if (isset($response['out'][0])) { 515 if (isset($response['out'][0])) {
474 $broke = explode(' ', $response['out'][0]); 516 $broke = explode(' ', $response['out'][0]);
@@ -481,7 +523,7 @@ class InstallUtil { @@ -481,7 +523,7 @@ class InstallUtil {
481 } 523 }
482 } 524 }
483 525
484 - return ''; 526 + return '';
485 } 527 }
486 528
487 function getOpenOffice() { 529 function getOpenOffice() {
setup/wizard/lib/services/unixLucene.php
@@ -180,6 +180,7 @@ class unixLucene extends unixService { @@ -180,6 +180,7 @@ class unixLucene extends unixService {
180 180
181 public function start() { 181 public function start() {
182 $state = $this->status(); 182 $state = $this->status();
  183 + return ;
183 if($state != 'STARTED') { 184 if($state != 'STARTED') {
184 $cmd = "cd ".$this->getLuceneDir()."; "; 185 $cmd = "cd ".$this->getLuceneDir()."; ";
185 $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!"; 186 $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!";
setup/wizard/lib/services/unixOpenOffice.php
@@ -125,6 +125,7 @@ class unixOpenOffice extends unixService { @@ -125,6 +125,7 @@ class unixOpenOffice extends unixService {
125 125
126 public function start() { 126 public function start() {
127 $state = $this->status(); 127 $state = $this->status();
  128 + return ;
128 if($state != 'STARTED') { 129 if($state != 'STARTED') {
129 $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; 130 $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!";
130 $response = $this->util->pexec($cmd); 131 $response = $this->util->pexec($cmd);
setup/wizard/lib/services/unixScheduler.php
@@ -150,6 +150,7 @@ class unixScheduler extends unixService { @@ -150,6 +150,7 @@ class unixScheduler extends unixService {
150 function start() { 150 function start() {
151 // TODO : Write sh on the fly? Not sure the reasoning here 151 // TODO : Write sh on the fly? Not sure the reasoning here
152 $source = $this->getSchedulerSourceLoc(); 152 $source = $this->getSchedulerSourceLoc();
  153 + return ;
153 if($source) { // Source 154 if($source) { // Source
154 $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; 155 $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!";
155 $response = $this->util->pexec($cmd); 156 $response = $this->util->pexec($cmd);
setup/wizard/output/outJV deleted
1 -java version "1.6.0_14"  
2 -Java(TM) SE Runtime Environment (build 1.6.0_14-b08)  
3 -Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)  
setup/wizard/resources/wizard.css
@@ -299,6 +299,11 @@ select { @@ -299,6 +299,11 @@ select {
299 margin-top:10px; 299 margin-top:10px;
300 } 300 }
301 301
  302 +.textinput {
  303 + margin-top:0px;
  304 + float:left;
  305 +}
  306 +
302 .step input { 307 .step input {
303 background-image: url("graphics/dame/kt_gradient.jpg"); 308 background-image: url("graphics/dame/kt_gradient.jpg");
304 background-repeat:repeat-x; 309 background-repeat:repeat-x;
@@ -326,11 +331,6 @@ select { @@ -326,11 +331,6 @@ select {
326 margin-top:10px; 331 margin-top:10px;
327 } 332 }
328 333
329 -.textinput {  
330 - margin-top:0px;  
331 - float:left;  
332 -}  
333 -  
334 .buttons a { 334 .buttons a {
335 background: #DDDDDD; 335 background: #DDDDDD;
336 border: solid 1px #888; 336 border: solid 1px #888;
@@ -528,4 +528,12 @@ td.dir_description { @@ -528,4 +528,12 @@ td.dir_description {
528 .description_click { 528 .description_click {
529 line-height:150%; 529 line-height:150%;
530 font-size:90%; 530 font-size:90%;
  531 +}
  532 +
  533 +.specify {
  534 + background: #DDDDDD;
  535 + border: solid 1px #888;
  536 + padding: 2px 8px 2px 5px;
  537 + text-decoration: none;
  538 + color: #EC7725;
531 } 539 }
532 \ No newline at end of file 540 \ No newline at end of file
setup/wizard/resources/wizard.js
@@ -5,18 +5,20 @@ function wizard() { @@ -5,18 +5,20 @@ function wizard() {
5 // Does a form check on every new page load 5 // Does a form check on every new page load
6 wizard.prototype.doFormCheck = function() { 6 wizard.prototype.doFormCheck = function() {
7 w.addReadOnly(); 7 w.addReadOnly();
8 - w.load(); 8 + w.preload();
9 } 9 }
10 10
11 // Toggle Advance Database options 11 // Toggle Advance Database options
12 -wizard.prototype.toggleClass = function(el, option) {  
13 - var el = document.getElementsByClassName(el); //adv_options|php_details|php_ext_details|php_con_details 12 +wizard.prototype.toggleClass = function(ele, option) {
  13 + var el = document.getElementsByClassName(ele); //adv_options|php_details|php_ext_details|php_con_details
14 if(el[0].style.display == 'none') { 14 if(el[0].style.display == 'none') {
15 el[0].style.display = 'block'; 15 el[0].style.display = 'block';
16 - document.getElementById(option).innerHTML = "Hide Details"; 16 + if(document.getElementById(option).innerHTML != '&nbsp;&nbsp;Advanced Options')
  17 + document.getElementById(option).innerHTML = "Hide Details";
17 } else { 18 } else {
18 el[0].style.display = 'none'; 19 el[0].style.display = 'none';
19 - document.getElementById(option).innerHTML = "Show Details"; 20 + if(document.getElementById(option).innerHTML != '&nbsp;&nbsp;Advanced Options')
  21 + document.getElementById(option).innerHTML = "Show Details";
20 } 22 }
21 } 23 }
22 24
@@ -51,8 +53,9 @@ wizard.prototype.toggleElement = function(el) { @@ -51,8 +53,9 @@ wizard.prototype.toggleElement = function(el) {
51 j = p-1; 53 j = p-1;
52 } 54 }
53 el = document.getElementsByClassName("step"+j); 55 el = document.getElementsByClassName("step"+j);
54 - el[0].style.display = 'block';  
55 - 56 + if(el != 'undefined') {
  57 + el[0].style.display = 'block';
  58 + }
56 return true; 59 return true;
57 } 60 }
58 61
@@ -170,17 +173,26 @@ wizard.prototype.valRegHelper = function() { @@ -170,17 +173,26 @@ wizard.prototype.valRegHelper = function() {
170 var first = document.getElementById('first'); 173 var first = document.getElementById('first');
171 var last = document.getElementById('last'); 174 var last = document.getElementById('last');
172 var email = document.getElementById('email'); 175 var email = document.getElementById('email');
173 -  
174 - if(first.value.length < 2) { 176 + if(first.value.length < 1) {
175 document.getElementById("reg_error").innerHTML = "Please enter a First Name"; 177 document.getElementById("reg_error").innerHTML = "Please enter a First Name";
176 w.focusElement(first); 178 w.focusElement(first);
177 return false; 179 return false;
178 } 180 }
179 - if(last.value.length < 2) { 181 + if(!w.nameCheck(first.value)) {
  182 + document.getElementById("reg_error").innerHTML = "Please enter a valid First Name";
  183 + w.focusElement(first);
  184 + return false;
  185 + }
  186 + if(last.value.length < 1) {
180 document.getElementById("reg_error").innerHTML = "Please enter a Last Name"; 187 document.getElementById("reg_error").innerHTML = "Please enter a Last Name";
181 w.focusElement(last); 188 w.focusElement(last);
182 return false; 189 return false;
183 } 190 }
  191 + if(!w.nameCheck(last.value)) {
  192 + document.getElementById("reg_error").innerHTML = "Please enter a valid Last Name";
  193 + w.focusElement(last);
  194 + return false;
  195 + }
184 if(!w.emailCheck(email.value)) { 196 if(!w.emailCheck(email.value)) {
185 document.getElementById("reg_error").innerHTML = "Please enter a valid email address"; 197 document.getElementById("reg_error").innerHTML = "Please enter a valid email address";
186 w.focusElement(email); 198 w.focusElement(email);
@@ -190,8 +202,18 @@ wizard.prototype.valRegHelper = function() { @@ -190,8 +202,18 @@ wizard.prototype.valRegHelper = function() {
190 return true; 202 return true;
191 } 203 }
192 204
  205 +wizard.prototype.nameCheck = function(str) {
  206 + var nameRegxp = /^([a-zA-Z]+)$/;
  207 + if(str.match(nameRegxp)) {
  208 + return true;
  209 + } else {
  210 + return false;
  211 + }
  212 +}
  213 +
193 // Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) 214 // Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
194 wizard.prototype.emailCheck = function(str) { 215 wizard.prototype.emailCheck = function(str) {
  216 + str = w.trim(str);
195 var at="@"; 217 var at="@";
196 var dot="."; 218 var dot=".";
197 var lat=str.indexOf(at); 219 var lat=str.indexOf(at);
@@ -221,6 +243,20 @@ wizard.prototype.emailCheck = function(str) { @@ -221,6 +243,20 @@ wizard.prototype.emailCheck = function(str) {
221 return true; 243 return true;
222 } 244 }
223 245
  246 +wizard.prototype.trim = function (str, chars) {
  247 + return w.ltrim(w.rtrim(str, chars), chars);
  248 +}
  249 +
  250 +wizard.prototype.ltrim = function (str, chars) {
  251 + chars = chars || "\\s";
  252 + return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
  253 +}
  254 +
  255 +wizard.prototype.rtrim = function (str, chars) {
  256 + chars = chars || "\\s";
  257 + return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
  258 +}
  259 +
224 // Disable DnD on element 260 // Disable DnD on element
225 // Element has to have a readOnly status set to readonly 261 // Element has to have a readOnly status set to readonly
226 wizard.prototype.disableDnd = function(el_id) { 262 wizard.prototype.disableDnd = function(el_id) {
@@ -243,6 +279,6 @@ wizard.prototype.addReadOnly = function() { @@ -243,6 +279,6 @@ wizard.prototype.addReadOnly = function() {
243 } 279 }
244 280
245 /* */ 281 /* */
246 -wizard.prototype.load = function() { 282 +wizard.prototype.preload = function() {
247 // $('#tooltips').tooltip(); 283 // $('#tooltips').tooltip();
248 } 284 }
249 \ No newline at end of file 285 \ No newline at end of file
setup/wizard/step.php
@@ -168,7 +168,7 @@ class Step @@ -168,7 +168,7 @@ class Step
168 * @return void 168 * @return void
169 */ 169 */
170 public function loadDefaults() { 170 public function loadDefaults() {
171 -// return ''; 171 +
172 } 172 }
173 173
174 /** 174 /**
setup/wizard/steps/configuration.php
@@ -47,17 +47,73 @@ class configuration extends Step @@ -47,17 +47,73 @@ class configuration extends Step
47 * 47 *
48 * @author KnowledgeTree Team 48 * @author KnowledgeTree Team
49 * @access private 49 * @access private
50 - * @var array  
51 - */ 50 + * @var object
  51 + */
52 private $_dbhandler = null; 52 private $_dbhandler = null;
  53 +
  54 + /**
  55 + * Database host
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access private
  59 + * @var string
  60 + */
53 private $host; 61 private $host;
  62 +
  63 + /**
  64 + * Database port
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access private
  68 + * @var string
  69 + */
54 private $port; 70 private $port;
  71 +
  72 + /**
  73 + * Relative path to knowledge tree directory
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access private
  77 + * @var string
  78 + */
55 private $root_url; 79 private $root_url;
  80 +
  81 + /**
  82 + * Absolute path to knowledge tree directory
  83 + *
  84 + * @author KnowledgeTree Team
  85 + * @access private
  86 + * @var string
  87 + */
56 private $file_system_root; 88 private $file_system_root;
  89 +
  90 + /**
  91 + * Whether or not ssl is enabled
  92 + *
  93 + * @author KnowledgeTree Team
  94 + * @access private
  95 + * @var string
  96 + */
57 private $ssl_enabled; 97 private $ssl_enabled;
  98 +
  99 + /**
  100 + * Whether or not the step is complete
  101 + *
  102 + * @author KnowledgeTree Team
  103 + * @access private
  104 + * @var string
  105 + */
58 private $done; 106 private $done;
59 - public $temp_variables = array("step_name"=>"configuration"); 107 +
  108 + /**
  109 + * Flag to store class information in session
  110 + *
  111 + * @author KnowledgeTree Team
  112 + * @access public
  113 + * @var array
  114 + */
60 public $displayFirst = true; 115 public $displayFirst = true;
  116 +
61 /** 117 /**
62 * Flag to store class information in session 118 * Flag to store class information in session
63 * 119 *
@@ -66,6 +122,7 @@ class configuration extends Step @@ -66,6 +122,7 @@ class configuration extends Step
66 * @var array 122 * @var array
67 */ 123 */
68 protected $storeInSession = true; 124 protected $storeInSession = true;
  125 +
69 /** 126 /**
70 * Flag if step needs to be installed 127 * Flag if step needs to be installed
71 * 128 *
@@ -84,7 +141,26 @@ class configuration extends Step @@ -84,7 +141,26 @@ class configuration extends Step
84 */ 141 */
85 protected $silent = false; 142 protected $silent = false;
86 143
  144 + /**
  145 + * Flag if step needs to run silently
  146 + *
  147 + * @author KnowledgeTree Team
  148 + * @access public
  149 + * @var array
  150 + */
  151 + protected $error = array();
  152 +
  153 + /**
  154 + * List of paths
  155 + *
  156 + * @author KnowledgeTree Team
  157 + * @access public
  158 + * @var array
  159 + */
  160 + protected $paths = array();
  161 +
87 protected $util = null; 162 protected $util = null;
  163 +
88 /** 164 /**
89 * Class constructor 165 * Class constructor
90 * 166 *
@@ -99,21 +175,6 @@ class configuration extends Step @@ -99,21 +175,6 @@ class configuration extends Step
99 $this->done = true; 175 $this->done = true;
100 } 176 }
101 177
102 - /**  
103 - * Set the variables from those stored in the session.  
104 - * Used for stepping back to the step from a future step.  
105 - *  
106 - * @author KnowledgeTree Team  
107 - * @access private  
108 - */  
109 - private function setDetails() {  
110 - $conf = $this->getDataFromSession("configuration");  
111 - if($conf) {  
112 - $this->temp_variables['server'] = $conf['server'];  
113 - $this->temp_variables['paths'] = $conf['paths'];  
114 - }  
115 - }  
116 -  
117 /** 178 /**
118 * Control function for position within the step 179 * Control function for position within the step
119 * 180 *
@@ -123,6 +184,7 @@ class configuration extends Step @@ -123,6 +184,7 @@ class configuration extends Step
123 */ 184 */
124 public function doStep() { 185 public function doStep() {
125 if(!$this->inStep("configuration")) { 186 if(!$this->inStep("configuration")) {
  187 + $this->setDetails();
126 $this->doRun(); 188 $this->doRun();
127 return 'landing'; 189 return 'landing';
128 } 190 }
@@ -133,26 +195,51 @@ class configuration extends Step @@ -133,26 +195,51 @@ class configuration extends Step
133 } 195 }
134 return 'error'; 196 return 'error';
135 } else if($this->previous()) { 197 } else if($this->previous()) {
136 -// $this->setDetails();  
137 return 'previous'; 198 return 'previous';
138 } else if($this->confirm()) { 199 } else if($this->confirm()) {
  200 + $this->setDetails();
139 if($this->doRun()) { 201 if($this->doRun()) {
140 return 'next'; 202 return 'next';
141 } 203 }
142 return 'error'; 204 return 'error';
143 } else if($this->edit()) { 205 } else if($this->edit()) {
144 - //$this->setDetails();  
145 - if($this->doRun()) {  
146 - 206 + $this->setDetails();
  207 + if($this->doRun(true)) {
  208 + return 'landing';
  209 + } else {
  210 + return 'error';
147 } 211 }
148 -// die;  
149 - return 'landing';  
150 } 212 }
151 213
152 $this->doRun(); 214 $this->doRun();
153 return 'landing'; 215 return 'landing';
154 } 216 }
155 - 217 +#/var/www/installers/knowledgetree/config/config.ini
  218 + /**
  219 + * Set the variables from those stored in the session.
  220 + * Used for stepping back to the step from a future step.
  221 + *
  222 + * @author KnowledgeTree Team
  223 + * @access private
  224 + * @param none
  225 + * @return void
  226 + */
  227 + private function setDetails() {
  228 + $conf = $this->getDataFromSession("configuration");
  229 + if($conf) {
  230 + $this->temp_variables['server'] = $conf['server'];
  231 + $this->temp_variables['paths'] = $conf['paths'];
  232 + }
  233 + }
  234 +
  235 + /**
  236 + * Default Template settings
  237 + *
  238 + * @author KnowledgeTree Team
  239 + * @access public
  240 + * @param none
  241 + * @return void
  242 + */
156 public function loadTemplateDefaults() { 243 public function loadTemplateDefaults() {
157 $this->temp_variables['paths_perms'] = 'tick'; 244 $this->temp_variables['paths_perms'] = 'tick';
158 } 245 }
@@ -164,13 +251,13 @@ class configuration extends Step @@ -164,13 +251,13 @@ class configuration extends Step
164 * @access public 251 * @access public
165 * @return boolean True to continue | False if errors occurred 252 * @return boolean True to continue | False if errors occurred
166 */ 253 */
167 - public function doRun() 254 + public function doRun($edit = false)
168 { 255 {
169 $server = $this->getServerInfo(); 256 $server = $this->getServerInfo();
170 - $this->temp_variables['server'] = $server; 257 + if(!$edit) $this->temp_variables['server'] = $server;
171 258
172 $paths = $this->getPathInfo($server['file_system_root']['value']); 259 $paths = $this->getPathInfo($server['file_system_root']['value']);
173 - $this->temp_variables['paths'] = $paths; 260 + if(!$edit) $this->temp_variables['paths'] = $paths;
174 261
175 // Running user 262 // Running user
176 // Logging 263 // Logging
@@ -338,7 +425,11 @@ class configuration extends Step @@ -338,7 +425,11 @@ class configuration extends Step
338 */ 425 */
339 private function getPathInfo($fileSystemRoot) 426 private function getPathInfo($fileSystemRoot)
340 { 427 {
341 - $dirs = $this->getDirectories(); 428 + if(isset($this->temp_variables['paths'])) {
  429 + $dirs = $this->temp_variables['paths']; // Pull from temp
  430 + } else {
  431 + $dirs = $this->getDirectories(); // Get detected
  432 + }
342 $varDirectory = $fileSystemRoot . DS . 'var'; 433 $varDirectory = $fileSystemRoot . DS . 'var';
343 foreach ($dirs as $key => $dir){ 434 foreach ($dirs as $key => $dir){
344 $path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path']; 435 $path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path'];
@@ -348,14 +439,16 @@ class configuration extends Step @@ -348,14 +439,16 @@ class configuration extends Step
348 } 439 }
349 if(WINDOWS_OS) 440 if(WINDOWS_OS)
350 $path = preg_replace('/\//', '\\',$path); 441 $path = preg_replace('/\//', '\\',$path);
351 -  
352 $dirs[$key]['path'] = $path; 442 $dirs[$key]['path'] = $path;
353 $class = $this->util->checkPermission($path, $dir['create']); 443 $class = $this->util->checkPermission($path, $dir['create']);
354 -  
355 if($class['class'] != 'tick') { 444 if($class['class'] != 'tick') {
356 $this->temp_variables['paths_perms'] = $class['class']; 445 $this->temp_variables['paths_perms'] = $class['class'];
357 $this->done = false; 446 $this->done = false;
358 - $this->error[] = "path error"; 447 + $this->error[] = "Path error";
  448 + }
  449 + if(isset($class['msg'])) {
  450 + $this->done = false;
  451 + $this->error[] = $class['msg'];
359 } 452 }
360 $dirs[$key] = array_merge($dirs[$key], $class); 453 $dirs[$key] = array_merge($dirs[$key], $class);
361 } 454 }
@@ -381,8 +474,24 @@ class configuration extends Step @@ -381,8 +474,24 @@ class configuration extends Step
381 array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true), 474 array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true),
382 array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true), 475 array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true),
383 array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${fileSystemRoot}/bin', 'create' => false), 476 array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${fileSystemRoot}/bin', 'create' => false),
384 - array('name' => 'Configuration File', 'setting' => '', 'path' => '${fileSystemRoot}/config/config.ini', 'create' => false), 477 + array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => '${fileSystemRoot}/config/config.ini', 'create' => false),
385 ); 478 );
386 } 479 }
  480 +
  481 + private function setFromPost() {
  482 + $this->paths = array(
  483 + array('name' => 'Var Directory', 'setting' => 'varDirectory', 'path' => $_POST['varDirectory'], 'create' => false),
  484 + array('name' => 'Document Directory', 'setting' => 'documentRoot', 'path' => $_POST['documentRoot'], 'create' => true),
  485 + array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $_POST['logDirectory'], 'create' => true),
  486 + array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $_POST['tmpDirectory'], 'create' => true),
  487 + array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $_POST['uploadDirectory'], 'create' => true),
  488 + array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => $_POST['binDirectory'], 'create' => false),
  489 + array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $_POST['configFile'], 'create' => false),
  490 + );
  491 + }
  492 +
  493 + public function getFromPost() {
  494 + return $this->paths;
  495 + }
387 } 496 }
388 ?> 497 ?>
389 \ No newline at end of file 498 \ No newline at end of file
setup/wizard/steps/database.php
@@ -196,15 +196,6 @@ class database extends Step @@ -196,15 +196,6 @@ class database extends Step
196 private $ddrop = false; 196 private $ddrop = false;
197 197
198 /** 198 /**
199 - * List of variables needed  
200 - *  
201 - * @author KnowledgeTree Team  
202 - * @access public  
203 - * @var array  
204 - */  
205 - public $temp_variables = array("step_name"=>"database");  
206 -  
207 - /**  
208 * List of errors encountered 199 * List of errors encountered
209 * 200 *
210 * @author KnowledgeTree Team 201 * @author KnowledgeTree Team
@@ -315,6 +306,8 @@ class database extends Step @@ -315,6 +306,8 @@ class database extends Step
315 return 'next'; 306 return 'next';
316 } else if($this->edit()) { 307 } else if($this->edit()) {
317 $this->setDataFromSession("database"); // Set Session Information, since its an edit 308 $this->setDataFromSession("database"); // Set Session Information, since its an edit
  309 + $this->temp_variables['state'] = 'edit';
  310 +
318 return 'landing'; 311 return 'landing';
319 } 312 }
320 } 313 }
@@ -469,6 +462,11 @@ class database extends Step @@ -469,6 +462,11 @@ class database extends Step
469 * @return void 462 * @return void
470 */ 463 */
471 private function setDetails() { 464 private function setDetails() {
  465 + if($this->edit()) {
  466 + $this->temp_variables['state'] = 'edit';
  467 + } else {
  468 + $this->temp_variables['state'] = '';
  469 + }
472 $this->temp_variables['dtype'] = $this->getPostSafe('dtype'); 470 $this->temp_variables['dtype'] = $this->getPostSafe('dtype');
473 $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases; 471 $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases;
474 $this->temp_variables['dhost'] = $this->getPostSafe('dhost'); 472 $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
setup/wizard/steps/registration.php
@@ -42,6 +42,15 @@ @@ -42,6 +42,15 @@
42 42
43 class registration extends Step 43 class registration extends Step
44 { 44 {
  45 + /**
  46 + * Flag to store class information in session
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access public
  50 + * @var array
  51 + */
  52 + public $storeInSession = true;
  53 +
45 /** 54 /**
46 * Initialise the registration step 55 * Initialise the registration step
47 * 56 *
@@ -63,7 +72,9 @@ class registration extends Step @@ -63,7 +72,9 @@ class registration extends Step
63 public function doStep() 72 public function doStep()
64 { 73 {
65 $this->setFormInfo(); 74 $this->setFormInfo();
  75 + $this->loadFromSession();
66 if(!$this->inStep("registration")) { 76 if(!$this->inStep("registration")) {
  77 + $this->loadFromSession();
67 return 'landing'; 78 return 'landing';
68 } 79 }
69 if($this->next()) { 80 if($this->next()) {
@@ -71,14 +82,48 @@ class registration extends Step @@ -71,14 +82,48 @@ class registration extends Step
71 return 'confirm'; 82 return 'confirm';
72 return 'error'; 83 return 'error';
73 } else if($this->previous()) { 84 } else if($this->previous()) {
  85 +
74 return 'previous'; 86 return 'previous';
75 }else if($this->confirm()) { 87 }else if($this->confirm()) {
76 88
77 return 'next'; 89 return 'next';
78 } 90 }
  91 +
79 return 'landing'; 92 return 'landing';
80 } 93 }
81 94
  95 + public function loadFromSession() {
  96 + $reg = $this->getDataFromSession('registration');
  97 + $this->temp_variables['first_name'] = $this->getPostSafe($reg['first_name']);
  98 + $this->temp_variables['last_name'] = $this->getPostSafe($reg['last_name']);
  99 + $this->temp_variables['email_address'] = $this->getPostSafe($reg['email_address']);
  100 + $this->temp_variables['sel_country'] = $this->getPostSafe($reg['sel_country']);
  101 + $this->temp_variables['sel_industry'] = $this->getPostSafe($reg['sel_industry']);
  102 + $this->temp_variables['sel_organization_size'] = $this->getPostSafe($reg['sel_organization_size']);
  103 + }
  104 +
  105 + /**
  106 + * Safer way to return post data
  107 + *
  108 + * @author KnowledgeTree Team
  109 + * @params SimpleXmlObject $simplexml
  110 + * @access public
  111 + * @return void
  112 + */
  113 + public function getPostSafe($key) {
  114 + $value = isset($key) ? $key : "";
  115 + return $value;
  116 + }
  117 +
  118 + public function setInSession() {
  119 + $this->temp_variables['first_name'] = $_POST['submitted']['first_name'];
  120 + $this->temp_variables['last_name'] = $_POST['submitted']['last_name'];
  121 + $this->temp_variables['email_address'] = $_POST['submitted']['email_address'];
  122 + $this->temp_variables['sel_country'] = $_POST['submitted']['country'];
  123 + $this->temp_variables['sel_industry'] = $_POST['submitted']['industry'];
  124 + $this->temp_variables['sel_organization_size'] = $_POST['submitted']['organization_size'];
  125 + }
  126 +
82 /** 127 /**
83 * Execute the step action to register the user. If the user has already registered then the step will return. 128 * Execute the step action to register the user. If the user has already registered then the step will return.
84 * 129 *
@@ -91,13 +136,14 @@ class registration extends Step @@ -91,13 +136,14 @@ class registration extends Step
91 if(isset($_POST['registered']) && $_POST['registered'] == 'yes'){ 136 if(isset($_POST['registered']) && $_POST['registered'] == 'yes'){
92 return true; 137 return true;
93 } 138 }
94 -return true; 139 + $this->setInSession();
  140 + return true;
95 //$this->postForm($_POST); 141 //$this->postForm($_POST);
96 //$this->sendToHost($_POST); 142 //$this->sendToHost($_POST);
97 143
98 // Post the form using curl 144 // Post the form using curl
99 $this->curlForm($_POST); 145 $this->curlForm($_POST);
100 - 146 +
101 // Prevent the form being reposted. 147 // Prevent the form being reposted.
102 $_POST['registered'] = 'yes'; 148 $_POST['registered'] = 'yes';
103 return true; 149 return true;
@@ -500,5 +546,17 @@ return true; @@ -500,5 +546,17 @@ return true;
500 $this->temp_variables['industries'] = $industries; 546 $this->temp_variables['industries'] = $industries;
501 $this->temp_variables['org_size'] = $sizes; 547 $this->temp_variables['org_size'] = $sizes;
502 } 548 }
  549 +
  550 + /**
  551 + * Return whether or not to store a step information in session
  552 + *
  553 + * @author KnowledgeTree Team
  554 + * @param none
  555 + * @access public
  556 + * @return boolean
  557 + */
  558 + public function storeInSession() {
  559 + return $this->storeInSession;
  560 + }
503 } 561 }
504 ?> 562 ?>
505 \ No newline at end of file 563 \ No newline at end of file
setup/wizard/steps/services.php
@@ -123,6 +123,9 @@ class services extends Step @@ -123,6 +123,9 @@ class services extends Step
123 * @var mixed 123 * @var mixed
124 */ 124 */
125 private $javaCheck = 'cross'; 125 private $javaCheck = 'cross';
  126 +
  127 +
  128 + public $providedJava = false;
126 129
127 /** 130 /**
128 * Flag if services are already Installed 131 * Flag if services are already Installed
@@ -215,7 +218,7 @@ class services extends Step @@ -215,7 +218,7 @@ class services extends Step
215 private $disableExtension = false; 218 private $disableExtension = false;
216 219
217 /** 220 /**
218 - * Holds path error, if java is specified 221 + * Flag, if java is specified and an error has been encountered
219 * 222 *
220 * @author KnowledgeTree Team 223 * @author KnowledgeTree Team
221 * @access public 224 * @access public
@@ -224,6 +227,15 @@ class services extends Step @@ -224,6 +227,15 @@ class services extends Step
224 private $javaExeError = ''; 227 private $javaExeError = '';
225 228
226 /** 229 /**
  230 + * Holds path error, if java is specified
  231 + *
  232 + * @author KnowledgeTree Team
  233 + * @access public
  234 + * @var mixed
  235 + */
  236 + private $javaExeMessage = '';
  237 +
  238 + /**
227 * Holds path error, if php is specified 239 * Holds path error, if php is specified
228 * 240 *
229 * @author KnowledgeTree Team 241 * @author KnowledgeTree Team
@@ -257,16 +269,21 @@ class services extends Step @@ -257,16 +269,21 @@ class services extends Step
257 $this->doRun(); 269 $this->doRun();
258 return 'landing'; 270 return 'landing';
259 } 271 }
260 - // Check dependencies  
261 - $passed = $this->doRun();  
262 if($this->next()) { 272 if($this->next()) {
263 - if($passed) 273 + // Check dependencies
  274 + $passed = $this->doRun();
  275 + $serv = $this->getDataFromSession("services");
  276 +// var_dump($conf);
  277 +// die;
  278 + if($passed || $serv['providedJava'])
264 return 'next'; 279 return 'next';
265 else 280 else
266 return 'error'; 281 return 'error';
267 } else if($this->previous()) { 282 } else if($this->previous()) {
268 return 'previous'; 283 return 'previous';
269 } 284 }
  285 +
  286 + $passed = $this->doRun();
270 return 'landing'; 287 return 'landing';
271 } 288 }
272 289
@@ -406,14 +423,17 @@ class services extends Step @@ -406,14 +423,17 @@ class services extends Step
406 $this->setJava(); // Check if java has been auto detected 423 $this->setJava(); // Check if java has been auto detected
407 if($this->util->javaSpecified()) { 424 if($this->util->javaSpecified()) {
408 $this->disableExtension = true; // Disable the use of the php bridge extension 425 $this->disableExtension = true; // Disable the use of the php bridge extension
409 - return $this->detSettings(); // AutoDetect java settings 426 + if($this->detSettings(true)) { // AutoDetect java settings
  427 + return true;
  428 + } else {
  429 + $this->specifyJava(); // Ask for settings
  430 + }
410 } else { 431 } else {
411 $auto = $this->useBridge(); // Use Bridge to get java settings 432 $auto = $this->useBridge(); // Use Bridge to get java settings
412 if($auto) { 433 if($auto) {
413 return $auto; 434 return $auto;
414 } else { 435 } else {
415 - // Check if auto detected java works  
416 - $auto = $this->useDetected(); 436 + $auto = $this->useDetected(); // Check if auto detected java works
417 if($auto) { 437 if($auto) {
418 $this->disableExtension = true; // Disable the use of the php bridge extension 438 $this->disableExtension = true; // Disable the use of the php bridge extension
419 return $auto; 439 return $auto;
@@ -434,7 +454,7 @@ class services extends Step @@ -434,7 +454,7 @@ class services extends Step
434 * @return boolean 454 * @return boolean
435 */ 455 */
436 private function useDetected() { 456 private function useDetected() {
437 - return $this->detSettings(true); 457 + return $this->detSettings();
438 } 458 }
439 459
440 private function specifyJava() { 460 private function specifyJava() {
@@ -480,24 +500,34 @@ class services extends Step @@ -480,24 +500,34 @@ class services extends Step
480 if($matches[1] < $this->javaVersion) { // Check Version of java 500 if($matches[1] < $this->javaVersion) { // Check Version of java
481 $this->javaVersionInCorrect(); 501 $this->javaVersionInCorrect();
482 $this->javaCheck = 'cross'; 502 $this->javaCheck = 'cross';
483 - if(!$attempt) $this->error[] = "Requires Java 1.5+ to be installed"; 503 + $this->error[] = "Requires Java 1.5+ to be installed";
  504 +
484 return false; 505 return false;
485 } else { 506 } else {
486 $this->javaVersionCorrect(); 507 $this->javaVersionCorrect();
487 $this->javaInstalled(); 508 $this->javaInstalled();
488 $this->javaCheck = 'tick'; 509 $this->javaCheck = 'tick';
  510 + $this->providedJava = true;
489 511
490 return true; 512 return true;
491 } 513 }
492 } else { 514 } else {
493 $this->javaVersionWarning(); 515 $this->javaVersionWarning();
494 $this->javaCheck = 'cross_orange'; 516 $this->javaCheck = 'cross_orange';
495 - $this->javaExeError = "Java : Incorrect path specified";  
496 - if(!$attempt) $this->error[] = "Requires Java 1.5+ to be installed"; 517 + if($attempt) {
  518 + $this->javaExeMessage = "Incorrect java path specified";
  519 + $this->javaExeError = true;
  520 + $this->error[] = "Requires Java 1.5+ to be installed";
  521 + }
  522 +
  523 +
497 return false; 524 return false;
498 } 525 }
499 } 526 }
500 527
  528 + $this->javaVersionInCorrect();
  529 + $this->javaCheck = 'cross';
  530 + $this->error[] = "Requires Java 1.5+ to be installed";
501 return false; 531 return false;
502 } 532 }
503 533
@@ -875,6 +905,7 @@ class services extends Step @@ -875,6 +905,7 @@ class services extends Step
875 $this->temp_variables['luceneInstalled'] = $this->luceneInstalled; 905 $this->temp_variables['luceneInstalled'] = $this->luceneInstalled;
876 $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled; 906 $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled;
877 $this->temp_variables['javaExeError'] = $this->javaExeError; 907 $this->temp_variables['javaExeError'] = $this->javaExeError;
  908 + $this->temp_variables['javaExeMessage'] = $this->javaExeMessage;
878 $this->temp_variables['javaCheck'] = $this->javaCheck; 909 $this->temp_variables['javaCheck'] = $this->javaCheck;
879 $this->temp_variables['javaExtCheck'] = $this->javaExtCheck; 910 $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;
880 // TODO : PHP detection 911 // TODO : PHP detection
@@ -882,6 +913,8 @@ class services extends Step @@ -882,6 +913,8 @@ class services extends Step
882 $this->temp_variables['phpExeError'] = '';//$this->phpExeError; 913 $this->temp_variables['phpExeError'] = '';//$this->phpExeError;
883 $this->temp_variables['serviceCheck'] = $this->serviceCheck; 914 $this->temp_variables['serviceCheck'] = $this->serviceCheck;
884 $this->temp_variables['disableExtension'] = $this->disableExtension; 915 $this->temp_variables['disableExtension'] = $this->disableExtension;
  916 + // TODO: Java checks are gettign intense
  917 + $this->temp_variables['providedJava'] = $this->providedJava;
885 } 918 }
886 919
887 private function setPhp() { 920 private function setPhp() {
setup/wizard/templates/configuration.tpl
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 <!--Warning and Error Messages--> 17 <!--Warning and Error Messages-->
18 <?php if($errors) { ?> 18 <?php if($errors) { ?>
19 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 19 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
20 - <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. Once you&rsquo;ve fixed these items, return to this wizard and try again.</span> 20 + <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. </span>
21 <br/> 21 <br/>
22 <?php } elseif ($warnings) { 22 <?php } elseif ($warnings) {
23 ?> 23 ?>
@@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
84 </p> 84 </p>
85 <table> 85 <table>
86 <?php 86 <?php
87 - if($errors && $warnings) { 87 + if($errors || $warnings) {
88 $width = "290px"; 88 $width = "290px";
89 } else { 89 } else {
90 $width = "520px"; 90 $width = "520px";
@@ -98,7 +98,7 @@ @@ -98,7 +98,7 @@
98 <?php if(isset($path['msg'])) { 98 <?php if(isset($path['msg'])) {
99 ?> 99 ?>
100 <td class="error"> <?php echo $path['msg']; ?> </td> 100 <td class="error"> <?php echo $path['msg']; ?> </td>
101 - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> 101 +<!-- <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td>-->
102 <?php 102 <?php
103 } else { 103 } else {
104 ?> 104 ?>
setup/wizard/templates/configuration_confirm.tpl
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <!--Warning and Error Messages--> 11 <!--Warning and Error Messages-->
12 <?php if($errors) { ?> 12 <?php if($errors) { ?>
13 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 13 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
14 - <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. Once you&rsquo;ve fixed these items, return to this wizard and try again.</span> 14 + <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address.</span>
15 <br/> 15 <br/>
16 <?php } elseif ($warnings) { 16 <?php } elseif ($warnings) {
17 ?> 17 ?>
setup/wizard/templates/database.tpl
@@ -12,37 +12,44 @@ @@ -12,37 +12,44 @@
12 user on the database server are required in order to be able to configure and install the installation database. 12 user on the database server are required in order to be able to configure and install the installation database.
13 </div> 13 </div>
14 <div id="step_content_database" class="step"> 14 <div id="step_content_database" class="step">
  15 +
15 <table class="dbconf"> 16 <table class="dbconf">
  17 + <?php
  18 + $input_size = '45';
  19 + $align = 'left';
  20 + ?>
16 <!-- TODO: Different Databases--> 21 <!-- TODO: Different Databases-->
  22 +<?php if($state != 'edit') { ?>
17 <tr><td>Your current database type is: </td> 23 <tr><td>Your current database type is: </td>
18 <?php if($dtypes) { 24 <?php if($dtypes) {
19 foreach($dtypes as $k=>$v) { 25 foreach($dtypes as $k=>$v) {
20 ?><td> 26 ?><td>
21 &nbsp; 27 &nbsp;
22 - <?php echo ucwords($v);?> 28 + <?php echo ucwords($v)." (Currently the only supported database.)";?>
23 <input type="hidden" name="dtype" value="<?php echo $v; ?>" <?php if(!$k)echo 'checked="checked"'; ?>/> 29 <input type="hidden" name="dtype" value="<?php echo $v; ?>" <?php if(!$k)echo 'checked="checked"'; ?>/>
24 </td> 30 </td>
25 <?php } 31 <?php }
26 } 32 }
27 ?> 33 ?>
28 </tr> 34 </tr>
  35 +<?php } ?>
29 <tr> 36 <tr>
30 <td><label for='dname'>Enter a name for the database: </label></td> 37 <td><label for='dname'>Enter a name for the database: </label></td>
31 - <td><input type='text' value="<?php echo $dname?>" id='dname' name='dname' size='45'/></td> 38 + <td><input type='text' value="<?php echo $dname?>" id='dname' name='dname' size='<?php echo $input_size; ?>' style="float:left"/></td>
32 <td id="error" class="error"><?php if($errors['dname']) echo $errors['dname']; ?></td> 39 <td id="error" class="error"><?php if($errors['dname']) echo $errors['dname']; ?></td>
33 </tr> 40 </tr>
34 <tr> 41 <tr>
35 <td><label for='duname'>Enter Database Administrative username: </label></td> 42 <td><label for='duname'>Enter Database Administrative username: </label></td>
36 - <td><input type='text' value="<?php echo $duname?>" id='duname' name='duname' size='45' /></td> 43 + <td><input type='text' value="<?php echo $duname?>" id='duname' name='duname' size='<?php echo $input_size; ?>' style="float:left"/></td>
37 <td id="error" class="error"><?php if($errors['duname']) echo $errors['duname']; ?></td> 44 <td id="error" class="error"><?php if($errors['duname']) echo $errors['duname']; ?></td>
38 </tr> 45 </tr>
39 <tr> 46 <tr>
40 <td><label for='dpassword'>Enter the password for the user: </label></td> 47 <td><label for='dpassword'>Enter the password for the user: </label></td>
41 - <td><input type='password' value="<?php echo $dpassword?>" id='dpassword' name='dpassword' size='45' /></td> 48 + <td><input type='password' value="<?php echo $dpassword?>" id='dpassword' name='dpassword' size='<?php echo $input_size; ?>' style="float:left"/></td>
42 <td id="error" class="error"><?php if($errors['dpassword']) echo $errors['dpassword']; ?></td> 49 <td id="error" class="error"><?php if($errors['dpassword']) echo $errors['dpassword']; ?></td>
43 </tr> 50 </tr>
44 </table> 51 </table>
45 - 52 +<br/><br/>
46 <div id="option3" class="onclick" onclick="javascript:{w.toggleClass('adv_options', 'option3');}">&nbsp;&nbsp;Advanced Options</div> 53 <div id="option3" class="onclick" onclick="javascript:{w.toggleClass('adv_options', 'option3');}">&nbsp;&nbsp;Advanced Options</div>
47 <div id="database" class="adv_options" style="display:none;"> 54 <div id="database" class="adv_options" style="display:none;">
48 <div class="description"> 55 <div class="description">
@@ -52,7 +59,7 @@ @@ -52,7 +59,7 @@
52 <tr> 59 <tr>
53 <td width="10px"> <label for='dhost'>Host: </label> </td> 60 <td width="10px"> <label for='dhost'>Host: </label> </td>
54 <td width="205px"> <div id="tooltips" title="The address of the server where the database is located, if different to the current server">&nbsp;</div> </td> 61 <td width="205px"> <div id="tooltips" title="The address of the server where the database is located, if different to the current server">&nbsp;</div> </td>
55 - <td width="10px"> <input type="text" value="<?php echo $dhost?>" id="dhost" name="dhost" size='45' class="textinput"/> </td> 62 + <td width="10px"> <input type="text" value="<?php echo $dhost?>" id="dhost" name="dhost" size='<?php echo $input_size; ?>' class="textinput"/> </td>
56 </tr> 63 </tr>
57 <tr> 64 <tr>
58 <td> <label for='dport'>Port: </label> </td> 65 <td> <label for='dport'>Port: </label> </td>
@@ -62,7 +69,7 @@ @@ -62,7 +69,7 @@
62 <tr> 69 <tr>
63 <td> <label for='dbbinary'>Socket: </label> </td> 70 <td> <label for='dbbinary'>Socket: </label> </td>
64 <td> <div id="tooltips" title="The path to the database binary. If it is not on your system path then please enter it here">&nbsp;</div> </td> 71 <td> <div id="tooltips" title="The path to the database binary. If it is not on your system path then please enter it here">&nbsp;</div> </td>
65 - <td> <input type="text" value="<?php echo $dbbinary?>" id="dbbinary" name="dbbinary" size='45' class="textinput"/> </td> 72 + <td> <input type="text" value="<?php echo $dbbinary?>" id="dbbinary" name="dbbinary" size='<?php echo $input_size; ?>' class="textinput"/> </td>
66 </tr> 73 </tr>
67 </table> 74 </table>
68 </div> 75 </div>
setup/wizard/templates/database_confirm.tpl
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <p class="title">Confirming Database Configurations</p> 2 <p class="title">Confirming Database Configurations</p>
3 3
4 <div class="description"> 4 <div class="description">
5 - Please confirm whether KnowledgeTree has correctly determined your database settings before proceeding. 5 + Please confirm whether KnowledgeTree has correctly determined your database settings before proceeding. Print this page for future use. <a href="javascript:window.print()">Click to Print This Page</a>
6 </div> 6 </div>
7 <div id="step_content_database_confirm" class="step"> 7 <div id="step_content_database_confirm" class="step">
8 <h3><b>Database Settings</b></h3> 8 <h3><b>Database Settings</b></h3>
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 <tr> 17 <tr>
18 <td width="153px">Database Type: </td> 18 <td width="153px">Database Type: </td>
19 <td width="15px"> <div id="tooltips" title="Type of database being used.">&nbsp;</div> </td> 19 <td width="15px"> <div id="tooltips" title="Type of database being used.">&nbsp;</div> </td>
20 - <td><?php echo $type; ?></td> 20 + <td><?php echo $type." (Currently the only supported database.)"; ?></td>
21 </tr> 21 </tr>
22 <?php } ?> 22 <?php } ?>
23 <tr> 23 <tr>
@@ -69,7 +69,7 @@ @@ -69,7 +69,7 @@
69 <?php } ?> 69 <?php } ?>
70 </table> 70 </table>
71 71
72 - <h3><b>Database Users</b></h3> 72 + <h3><b>Database Users (System Generated)</b></h3>
73 73
74 <table class="dbconf"> 74 <table class="dbconf">
75 <?php //if (!$silent) { ?> 75 <?php //if (!$silent) { ?>
setup/wizard/templates/dependencies.tpl
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 <!--Warning and Error Messages--> 17 <!--Warning and Error Messages-->
18 <?php if($errors) { ?> 18 <?php if($errors) { ?>
19 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 19 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
20 - <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. Once you&rsquo;ve fixed these items, return to this wizard and try again.</span> 20 + <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. </span>
21 <br/> 21 <br/>
22 <?php } elseif ($warnings) { ?> 22 <?php } elseif ($warnings) { ?>
23 <span class='cross_orange'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 23 <span class='cross_orange'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
setup/wizard/templates/registration.tpl
1 <form id="registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post" onsubmit="w.validateRegistration();return false;"> 1 <form id="registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post" onsubmit="w.validateRegistration();return false;">
2 <p class="title">Registering KnowledgeTree</p> 2 <p class="title">Registering KnowledgeTree</p>
3 - 3 + <?php
  4 + //echo $sel_country;
  5 + ?>
4 <p class="description"> 6 <p class="description">
5 - Register with KnowledgeTree to receive important product updates. <b>We respect your privacy and will not share your information with third parties. For more information, please refer to our Privacy and Data Retention Policies.</b> 7 + Register with KnowledgeTree to receive important product updates.
6 <a href="index.php?step_name=install">Skip Registration</a> 8 <a href="index.php?step_name=install">Skip Registration</a>
7 </p> 9 </p>
8 <!-- Hidden Fields --> 10 <!-- Hidden Fields -->
@@ -20,18 +22,18 @@ @@ -20,18 +22,18 @@
20 <tr> 22 <tr>
21 <td><label for='first'>First Name</label></td> 23 <td><label for='first'>First Name</label></td>
22 <td rowspan='6' width='5%'>&nbsp;</td> 24 <td rowspan='6' width='5%'>&nbsp;</td>
23 - <td><input name='submitted[first_name]' id='first' size='<?php echo $input_width; ?>' style="float:left;"/></td> 25 + <td><input value="<?php echo $first_name; ?>" name='submitted[first_name]' id='first' size='<?php echo $input_width; ?>' style="float:left;"/></td>
24 <td rowspan='6' width='5%'>&nbsp;</td> 26 <td rowspan='6' width='5%'>&nbsp;</td>
25 <td rowspan='6'> <img src='resources/graphics/dropbox.png' /> </td> 27 <td rowspan='6'> <img src='resources/graphics/dropbox.png' /> </td>
26 </tr> 28 </tr>
27 29
28 <tr> 30 <tr>
29 <td><label for='last'>Last Name</label></td> 31 <td><label for='last'>Last Name</label></td>
30 - <td><input name='submitted[last_name]' id='last' size='<?php echo $input_width; ?>' style="float:left;"/></td> 32 + <td><input value="<?php echo $last_name; ?>" name='submitted[last_name]' id='last' size='<?php echo $input_width; ?>' style="float:left;"/></td>
31 </tr> 33 </tr>
32 <tr> 34 <tr>
33 <td><label for='email'>Email Address</label></td> 35 <td><label for='email'>Email Address</label></td>
34 - <td><input name='submitted[email_address]' id='email' size='<?php echo $input_width; ?>' style="float:left;"/></td> 36 + <td><input value="<?php echo $email_address; ?>" name='submitted[email_address]' id='email' size='<?php echo $input_width; ?>' style="float:left;"/></td>
35 </tr> 37 </tr>
36 <tr> 38 <tr>
37 <td><label for='country'>Country</label></td> 39 <td><label for='country'>Country</label></td>
@@ -40,7 +42,12 @@ @@ -40,7 +42,12 @@
40 <?php 42 <?php
41 $str = ''; 43 $str = '';
42 foreach ($countries as $code => $country) { 44 foreach ($countries as $code => $country) {
43 - $str .= "<option name='{$code}' value='{$country}'>{$country}</option>"; 45 + if ($sel_country == $country) {
  46 + $str .= "<option name='{$code}' value='{$country}' selected='selected'>{$country}</option>";
  47 + } else {
  48 + $str .= "<option name='{$code}' value='{$country}'>{$country}</option>";
  49 + }
  50 +
44 } 51 }
45 52
46 echo $str; 53 echo $str;
@@ -55,7 +62,11 @@ @@ -55,7 +62,11 @@
55 <?php 62 <?php
56 $str = ''; 63 $str = '';
57 foreach ($industries as $code => $industry) { 64 foreach ($industries as $code => $industry) {
58 - $str .= "<option name='{$code}' value='{$industry}'>{$industry}</option>"; 65 + if ($sel_industry == $industry) {
  66 + $str .= "<option name='{$code}' value='{$industry}' selected='selected'>{$industry}</option>";
  67 + } else {
  68 + $str .= "<option name='{$code}' value='{$industry}'>{$industry}</option>";
  69 + }
59 } 70 }
60 71
61 echo $str; 72 echo $str;
@@ -70,7 +81,11 @@ @@ -70,7 +81,11 @@
70 <?php 81 <?php
71 $str = ''; 82 $str = '';
72 foreach ($org_size as $code => $size) { 83 foreach ($org_size as $code => $size) {
73 - $str .= "<option name='{$code}' value='{$size}'>{$size}</option>"; 84 + if ($sel_organization_size == $size) {
  85 + $str .= "<option name='{$code}' value='{$size}' selected='selected'>{$size}</option>";
  86 + } else {
  87 + $str .= "<option name='{$code}' value='{$size}'>{$size}</option>";
  88 + }
74 } 89 }
75 90
76 echo $str; 91 echo $str;
setup/wizard/templates/services.tpl
1 -<form action="index.php?step_name=services" method="post"> 1 +<form action="index.php?step_name=services" method="post" id="services">
  2 + <?php //if($javaExeError != '' || $phpExeError != '') {
  3 + //var_dump($javaExeError);
  4 + //if($errors) $top = "185px"; elseif ($warnings) $top = "185px"; else $top = "168px";
  5 + ?>
  6 +<!-- <input type="submit" name="Next" value="Submit" id="inner_button" style="top:<?php //echo $top; ?>"/>-->
  7 + <?php //} ?>
2 <p class="title">Checking Service Dependencies</p> 8 <p class="title">Checking Service Dependencies</p>
3 9
4 <p class="description"> 10 <p class="description">
@@ -17,7 +23,7 @@ @@ -17,7 +23,7 @@
17 <!--Warning and Error Messages--> 23 <!--Warning and Error Messages-->
18 <?php if($errors) { ?> 24 <?php if($errors) { ?>
19 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 25 <span class='cross'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
20 - <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. Once you&rsquo;ve fixed these items, return to this wizard and try again.</span> 26 + <span class='error_message'>Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address.</span>
21 <br/> 27 <br/>
22 <?php } elseif ($warnings) { 28 <?php } elseif ($warnings) {
23 ?> 29 ?>
@@ -28,18 +34,22 @@ @@ -28,18 +34,22 @@
28 }?> 34 }?>
29 <?php 35 <?php
30 if($errors || $warnings) { 36 if($errors || $warnings) {
  37 +// var_dump($errors);
31 ?> 38 ?>
32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://wiki.knowledgetree.com/Web_Based_Installer#Service_Dependencies" target="_blank">Click here for help on overcoming service issues</a> 39 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://wiki.knowledgetree.com/Web_Based_Installer#Service_Dependencies" target="_blank">Click here for help on overcoming service issues</a>
33 <?php } ?> 40 <?php } ?>
34 <!--Content--> 41 <!--Content-->
35 <div id="step_content_configuration" style="width:755px;" class="step"> 42 <div id="step_content_configuration" style="width:755px;" class="step">
36 <?php if(!$alreadyInstalled) { ?> 43 <?php if(!$alreadyInstalled) { ?>
37 - <?php if($javaExeError != '') { ?> 44 + <?php //var_dump($javaExeError); ?>
  45 + <?php if($javaExeError) { ?>
38 Specify the location of your Java executable 46 Specify the location of your Java executable
39 &nbsp;&nbsp;&nbsp; 47 &nbsp;&nbsp;&nbsp;
40 <input name='java' id='port' size='25' value='<?php echo $java['location']; ?>' style="float:none;"/> 48 <input name='java' id='port' size='25' value='<?php echo $java['location']; ?>' style="float:none;"/>
41 &nbsp;&nbsp;&nbsp; 49 &nbsp;&nbsp;&nbsp;
42 - <?php if($javaExeError != true) { ?><span class="error"><?php echo $javaExeError; ?></span><?php } ?> 50 + <a href="javascript:{document.getElementById('services').submit();}" class="specify">Submit</a>
  51 + <br/>
  52 + <?php if($javaExeError != '') { ?><span class="error"><?php echo $javaExeMessage; ?></span><?php } ?>
43 <?php } ?> 53 <?php } ?>
44 <?php if($phpExeError != '') { ?> 54 <?php if($phpExeError != '') { ?>
45 <br /> 55 <br />
@@ -53,9 +63,6 @@ @@ -53,9 +63,6 @@
53 &nbsp;&nbsp;&nbsp; 63 &nbsp;&nbsp;&nbsp;
54 <?php if($phpExeError != true) { ?><span class="error"><?php echo $phpExeError; ?></span><?php } ?> 64 <?php if($phpExeError != true) { ?><span class="error"><?php echo $phpExeError; ?></span><?php } ?>
55 <?php } ?> 65 <?php } ?>
56 - <?php if($javaExeError != '' || $phpExeError != '') { ?>  
57 -<!-- <input type="submit" name="Refresh" value="Submit" style="float:none;background-image:url('a');font-size:10pt;font-weight:normal;border:none;"/>-->  
58 - <?php } ?>  
59 <h3><?php echo "<span class='{$javaCheck}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Java Check</h3> 66 <h3><?php echo "<span class='{$javaCheck}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Java Check</h3>
60 <?php if($silent) { ?> 67 <?php if($silent) { ?>
61 <div id="option4" class="onclick" onclick="javascript:{w.toggleClass('java_details', 'option4');}">Show Details</div> 68 <div id="option4" class="onclick" onclick="javascript:{w.toggleClass('java_details', 'option4');}">Show Details</div>
webservice/clienttools/ajaxhandler.php
@@ -7,12 +7,19 @@ class ajaxHandler{ @@ -7,12 +7,19 @@ class ajaxHandler{
7 public $request=NULL; 7 public $request=NULL;
8 public $kt=NULL; 8 public $kt=NULL;
9 public $authenticator=NULL; 9 public $authenticator=NULL;
  10 + public $noAuthRequireList=array();
10 11
11 - public function __construct(&$ret=NULL,&$kt){ 12 + public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){
12 // set a local copy of the json request wrapper 13 // set a local copy of the json request wrapper
  14 + $noAuthRequests=is_array($noAuthRequests)?$noAuthRequests:split(',',(string)$noAuthRequests);
  15 + $this->registerNoAuthRequest($noAuthRequests);
13 $this->req=new jsonWrapper(isset($_GET['request'])?$_GET['request']:(isset($_POST['request'])?$_POST['request']:'')); 16 $this->req=new jsonWrapper(isset($_GET['request'])?$_GET['request']:(isset($_POST['request'])?$_POST['request']:''));
14 - $this->auth=$this->req->jsonArray['auth'];  
15 - $this->request=$this->req->jsonArray['request']; 17 + $this->auth=$this->structArray('user,pass,passhash,appType,session,token,version',$this->req->jsonArray['auth']);
  18 + $this->request=$this->structArray('service,function,parameters',$this->req->jsonArray['request']);
  19 +
  20 + $add_params=array_merge($_GET,$_POST);
  21 + unset($add_params['request'],$add_params['datasource']);
  22 + $this->request['parameters']=array_merge($this->request['parameters'],$add_params);
16 23
17 24
18 // set the response object 25 // set the response object
@@ -22,6 +29,7 @@ class ajaxHandler{ @@ -22,6 +29,7 @@ class ajaxHandler{
22 $this->ret=new jsonResponseObject(); 29 $this->ret=new jsonResponseObject();
23 } 30 }
24 $this->ret->setRequest($this->req->jsonArray); 31 $this->ret->setRequest($this->req->jsonArray);
  32 + $this->ret->setTitle($this->request['service'].'::'.$this->request['function']);
25 33
26 if(get_class($kt)=='KTAPI'){ 34 if(get_class($kt)=='KTAPI'){
27 $this->kt=&$kt; 35 $this->kt=&$kt;
@@ -41,21 +49,32 @@ class ajaxHandler{ @@ -41,21 +49,32 @@ class ajaxHandler{
41 49
42 if(!$this->verifySession()){ 50 if(!$this->verifySession()){
43 $this->doLogin(); 51 $this->doLogin();
44 - if(!$this->isAuthenticated())return $this->render(); 52 + $isAuthRequired=$this->isNoAuthRequiredRequest();
  53 + $isAuthenticated=$this->isAuthenticated();
  54 + if(!$isAuthRequired && !$isAuthenticated)return $this->render();
45 } 55 }
46 56
47 $this->dispatch(); 57 $this->dispatch();
48 58
49 return $this->render(); 59 return $this->render();
50 } 60 }
  61 +
  62 + private function structArray($structString=NULL,$arr=NULL){
  63 + $struct=array_flip(split(',',(string)$structString));
  64 + return array_merge($struct,is_array($arr)?$arr:array());
  65 + }
51 66
52 public function dispatch(){ 67 public function dispatch(){
53 $request=$this->request; 68 $request=$this->request;
54 - $this->loadService($request['service']);  
55 - $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth);  
56 - $this->ret->setTitle($request['service'].'::'.$request['function']); 69 + if($request['auth']){
  70 + $service=$this->authenticator;
  71 + }else{
  72 + $this->loadService($request['service']);
  73 + $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth);
  74 + }
  75 + $this->ret->setdebug('dispatch_request','The service class loaded');
57 if(method_exists($service,$request['function'])){ 76 if(method_exists($service,$request['function'])){
58 - //$this->ret->setDebug('got here'); 77 + $this->ret->setdebug('dispatch_execution','The service method was found. Executing');
59 $service->$request['function']($request['parameters']); 78 $service->$request['function']($request['parameters']);
60 }else{ 79 }else{
61 $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}"); 80 $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}");
@@ -97,7 +116,7 @@ class ajaxHandler{ @@ -97,7 +116,7 @@ class ajaxHandler{
97 } 116 }
98 117
99 protected function isAuthenticated(){ 118 protected function isAuthenticated(){
100 - return true; 119 + return $this->authenticator->pickup_session();
101 } 120 }
102 121
103 protected function doLogin(){ 122 protected function doLogin(){
@@ -113,6 +132,26 @@ class ajaxHandler{ @@ -113,6 +132,26 @@ class ajaxHandler{
113 echo $this->ret->getJson(); 132 echo $this->ret->getJson();
114 return true; 133 return true;
115 } 134 }
  135 +
  136 + public function registerNoAuthRequest($requestString=''){
  137 + if($requestString){
  138 + if(is_array($requestString)){
  139 + foreach ($requestString as $rString){
  140 + $rString=strtolower((string)$rString);
  141 + $this->noAuthRequireList[$rString]=$rString;
  142 + }
  143 + }else{
  144 + $requestString=strtolower((string)$requestString);
  145 + $this->noAuthRequireList[$requestString]=(string)$requestString;
  146 + }
  147 + }
  148 + }
  149 +
  150 + public function isNoAuthRequiredRequest(){
  151 + $req=$this->request;
  152 + $reqString=strtolower("{$req['service']}.{$req['function']}");
  153 + return in_array($reqString,$this->noAuthRequireList);
  154 + }
116 155
117 } 156 }
118 ?> 157 ?>
119 \ No newline at end of file 158 \ No newline at end of file
webservice/clienttools/client_service.php
@@ -41,6 +41,17 @@ class client_service{ @@ -41,6 +41,17 @@ class client_service{
41 return $var; 41 return $var;
42 } 42 }
43 43
  44 + protected function checkPearError($obj,$errMsg,$debug=NULL,$response=NULL){
  45 + if (PEAR::isError($obj)){
  46 + if($response===NULL)$response=array('status_code' => 1);
  47 + $this->addError($errMsg);
  48 + if((isset($debug) || $debug==NULL) && $debug!=='')$this->addDebug('',$debug!==NULL?$debug:$obj);
  49 + $this->setResponse($response);
  50 + return false;
  51 + }
  52 + return true;
  53 + }
  54 +
44 } 55 }
45 56
46 ?> 57 ?>
47 \ No newline at end of file 58 \ No newline at end of file
webservice/clienttools/comms.php
@@ -38,12 +38,23 @@ $old_error_handler=set_error_handler(&#39;error_handler&#39;,E_ERROR); @@ -38,12 +38,23 @@ $old_error_handler=set_error_handler(&#39;error_handler&#39;,E_ERROR);
38 //Interpret the Json Object that was passed 38 //Interpret the Json Object that was passed
39 include_once('jsonWrapper.php'); 39 include_once('jsonWrapper.php');
40 include_once('ajaxhandler.php'); 40 include_once('ajaxhandler.php');
  41 +include_once('serviceHelper.php');
41 include_once('client_service.php'); 42 include_once('client_service.php');
42 43
43 //Instantiate base classes 44 //Instantiate base classes
44 $KT = new KTAPI(); 45 $KT = new KTAPI();
45 $RET=new jsonResponseObject(); 46 $RET=new jsonResponseObject();
46 -$handler=new ajaxHandler($RET,$KT); 47 +if($_GET['datasource'])$RET->isDataSource=true;
  48 +
  49 +$noAuthRequests=array(
  50 + 'auth.ping',
  51 + 'auth.japiLogin',
  52 + 'kt.get_all_client_policies',
  53 + 'kt.get_languages',
  54 + 'kt.switchlang'
  55 +);
  56 +
  57 +$handler=new ajaxHandler($RET,$KT,$noAuthRequests);
47 58
48 59
49 60
webservice/clienttools/jsonWrapper.php
@@ -12,6 +12,7 @@ class jsonResponseObject{ @@ -12,6 +12,7 @@ class jsonResponseObject{
12 protected $request=array(); 12 protected $request=array();
13 protected $debug=array(); 13 protected $debug=array();
14 public $additional=array(); 14 public $additional=array();
  15 + public $isDataSource=false;
15 16
16 public $response=array( 17 public $response=array(
17 'requestName' =>'', 18 'requestName' =>'',
@@ -60,7 +61,7 @@ class jsonResponseObject{ @@ -60,7 +61,7 @@ class jsonResponseObject{
60 61
61 public function getJson(){ 62 public function getJson(){
62 $response=array_merge(array( 63 $response=array_merge(array(
63 - 'title' =>$this->title, 64 + 'requestName' =>$this->title,
64 'errors' =>array( 65 'errors' =>array(
65 'hadErrors' =>(count($this->errors)>0?1:0), 66 'hadErrors' =>(count($this->errors)>0?1:0),
66 'errors' =>$this->errors 67 'errors' =>$this->errors
@@ -71,7 +72,11 @@ class jsonResponseObject{ @@ -71,7 +72,11 @@ class jsonResponseObject{
71 'debug' =>$this->debug, 72 'debug' =>$this->debug,
72 ),$this->additional); 73 ),$this->additional);
73 74
74 - $response=json_encode($response); 75 + if($this->isDataSource){
  76 + $response=json_encode($response['data']);
  77 + }else{
  78 + $response=json_encode($response);
  79 + }
75 return $response; 80 return $response;
76 } 81 }
77 } 82 }
webservice/clienttools/serviceHelper.php 0 โ†’ 100644
  1 +<?php
  2 +class serviceHelper{
  3 + public function __construct(){
  4 + throw new Exception('ServiceHelper is only to be used statically');
  5 + }
  6 +
  7 + function bool2str($bool){
  8 + //TODO: Test this sometime.. a lot shorter - doesn't cater for string though.. but if string then result already correct
  9 + //return ((bool)$bool)?'true':false;
  10 +
  11 + if (is_bool($bool))
  12 + {
  13 + return $bool ? 'true' : 'false';
  14 + }
  15 + if (is_numeric($bool))
  16 + {
  17 + return ($bool+0) ? 'true' : 'false';
  18 + }
  19 + // assume str
  20 + return (strtolower($bool) == 'true') ? 'true' : 'false';
  21 + }
  22 +
  23 + /**
  24 + * Return human readable sizes
  25 + *
  26 + * @param integer $size The size you want to convert to human readable
  27 + * @return string
  28 + */
  29 + function fsize_desc($size){
  30 + $i=0;
  31 + $iec = array("B", "Kb", "Mb", "Gb", "Tb");
  32 + while (($size/1024)>1) {
  33 + $size=$size/1024;
  34 + $i++;
  35 + }
  36 + return substr($size,0,strpos($size,'.')+3).$iec[$i];
  37 + }
  38 +
  39 +
  40 + /**
  41 + * Display byte sizes in human readable representations
  42 + *
  43 + * @param integer $size Size to represent
  44 + * @param string $max Maximum representational unit (eg B,KB,MB)
  45 + * @param string $system Selecting the system of representation (si,bi&c1 defined)
  46 + * @param string $retstring Format for the return string.
  47 + * @return String
  48 + */
  49 + function size_readable($size, $max = null, $system = 'c1', $retstring = '%01.1f %s'){
  50 + // Pick units
  51 + $systems['si']['prefix'] = array('B', 'K', 'MB', 'GB', 'TB', 'PB');
  52 + $systems['si']['size'] = 1000;
  53 + $systems['bi']['prefix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
  54 + $systems['bi']['size'] = 1024;
  55 + $systems['c1']['prefix'] = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
  56 + $systems['c1']['size'] = 1024;
  57 + $sys = isset($systems[$system]) ? $systems[$system] : $systems['si'];
  58 +
  59 + // Max unit to display
  60 + $depth = count($sys['prefix']) - 1;
  61 + if ($max && false !== $d = array_search($max, $sys['prefix'])) {
  62 + $depth = $d;
  63 + }
  64 +
  65 + // Loop
  66 + $i = 0;
  67 + while ($size >= $sys['size'] && $i < $depth) {
  68 + $size /= $sys['size'];
  69 + $i++;
  70 + }
  71 +
  72 + return sprintf(($sys['prefix'][$i]=='B'?'%01d %s':$retstring), $size, $sys['prefix'][$i]);
  73 + }
  74 +}
  75 +?>
0 \ No newline at end of file 76 \ No newline at end of file
webservice/clienttools/services/3.6.1/auth.php
@@ -23,7 +23,9 @@ class auth extends client_service { @@ -23,7 +23,9 @@ class auth extends client_service {
23 require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 23 require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
24 24
25 if (!BaobabKeyUtil::checkIfLicensed(true)) { 25 if (!BaobabKeyUtil::checkIfLicensed(true)) {
26 - return array('authenticated'=> false, 'message'=> 'license_expired'); 26 + $this->setResponse(array('authenticated'=> false, 'message'=> 'license_expired'));
  27 + $this->addError('Licence Expired');
  28 + return false;
27 } 29 }
28 } 30 }
29 31
@@ -38,21 +40,34 @@ class auth extends client_service { @@ -38,21 +40,34 @@ class auth extends client_service {
38 if(!PEAR::isError($session)){ 40 if(!PEAR::isError($session)){
39 $this->Response->setStatus('session_id',$session->get_session()); 41 $this->Response->setStatus('session_id',$session->get_session());
40 }else{ 42 }else{
41 - $this->Response->setDebug('failed login',print_r($session,true));  
42 - throw new Exception('Unknown Login Error'); 43 + $this->setResponse(array('authenticated'=> false, 'message'=> 'Invalid username and/or password.'));
  44 + $this->addDebug('failed login',print_r($session,true));
  45 + $this->addError('Unknown Login Error');
43 return false; 46 return false;
44 } 47 }
45 }else{ 48 }else{
46 - throw new Exception('Incorrect Credentials'); 49 + $this->addError('Incorrect Credentials');
  50 + //throw new Exception('Incorrect Credentials');
47 return false; 51 return false;
48 } 52 }
49 }else{ 53 }else{
50 - throw new Exception('Unrecognized User'); 54 + $this->addError('Incorrect Credentials');
  55 + //throw new Exception('Unrecognized User');
51 return false; 56 return false;
52 } 57 }
53 return true; 58 return true;
54 } 59 }
55 60
  61 + public function japiLogin(){
  62 + global $default;
  63 + $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
  64 + $ret=array(
  65 + 'fullName' =>PEAR::isError($user)?'':$user->getName()
  66 + );
  67 + $this->setResponse($ret);
  68 + return true;
  69 + }
  70 +
56 public function pickup_session(){ 71 public function pickup_session(){
57 $params=$this->AuthInfo; 72 $params=$this->AuthInfo;
58 $app_type=$params['appType']; 73 $app_type=$params['appType'];
@@ -67,6 +82,40 @@ class auth extends client_service { @@ -67,6 +82,40 @@ class auth extends client_service {
67 $this->Response->setStatus('session_id',$session->get_session()); 82 $this->Response->setStatus('session_id',$session->get_session());
68 return true; 83 return true;
69 } 84 }
  85 +
  86 +
  87 + public function ping(){
  88 + global $default;
  89 + $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
  90 + $ret=array(
  91 + 'response' =>'pong',
  92 + 'loginLocation' => '/index.html',
  93 + 'currentversion' =>$default->systemVersion,
  94 + 'requiredversion' =>$default->systemVersion,
  95 + 'versionok' =>true,
  96 + 'fullName' =>PEAR::isError($user)?'':$user->getName()
  97 + );
  98 + $this->setResponse($ret);
  99 + return true;
  100 + }
  101 +
  102 + function logout($params){
  103 + $params=$this->AuthInfo;
  104 + $app_type=$params['appType'];
  105 + $session_id=$params['session'];
  106 + $ip=$_SERVER['REMOTE_ADDR'];
  107 +
  108 + $session = $this->KT->get_active_session($session_id, $ip, $app_type);
  109 +
  110 + if (PEAR::isError($session)){
  111 + return false;
  112 + }
  113 +
  114 + $session->logout();
  115 + $this->setResponse(array('logout'=>true));
  116 + return true;
  117 + }
  118 +
70 } 119 }
71 120
72 ?> 121 ?>
73 \ No newline at end of file 122 \ No newline at end of file
webservice/clienttools/services/3.6.1/kt.php
1 <?php 1 <?php
2 class kt extends client_service { 2 class kt extends client_service {
  3 +
3 4
  5 +
4 /** 6 /**
5 * Get Supported (?) Languages 7 * Get Supported (?) Languages
6 * 8 *
7 * returns array containing languages, count, & defaultlanguage 9 * returns array containing languages, count, & defaultlanguage
8 * 10 *
9 */ 11 */
10 - function get_languages(){ 12 + function get_languages($passthru=false){
11 global $default; 13 global $default;
12 $oReg =& KTi18nregistry::getSingleton(); 14 $oReg =& KTi18nregistry::getSingleton();
13 - $aRegisteredLangs = $oReg->geti18nLanguages('knowledgeTree');  
14 - $aLanguageNames = $oReg->getLanguages('knowledgeTree');  
15 - $languages = array(); 15 + $aRegisteredLangs=$oReg->geti18nLanguages('knowledgeTree');
  16 + $aLanguageNames=$oReg->getLanguages('knowledgeTree');
  17 + $languages=array();
16 18
17 if(!empty($aRegisteredLangs)){ 19 if(!empty($aRegisteredLangs)){
18 foreach (array_keys($aRegisteredLangs) as $sLang){ 20 foreach (array_keys($aRegisteredLangs) as $sLang){
19 - $languages[] = array(  
20 - 'isoCode' => $sLang,  
21 - 'language' => $aLanguageNames[$sLang] 21 + $languages[]=array(
  22 + 'isoCode'=>$sLang,
  23 + 'language'=>$aLanguageNames[$sLang]
22 ); 24 );
23 } 25 }
24 } 26 }
25 -  
26 - $this->setResponse(array('languages' => $languages, 'count' => count($languages), 'defaultLanguage' => $default->defaultLanguage)); 27 + $response=array('languages'=>$languages, 'count'=>count($languages), 'defaultLanguage'=>$default->defaultLanguage);
  28 + if(is_bool($passthru))if($passthru)return $response;
  29 + $this->setResponse($response);
27 } 30 }
28 31
29 32
30 function get_rootfolder_detail($params){ 33 function get_rootfolder_detail($params){
31 - $params['folderId'] = '1'; 34 + $params['folderId']='1';
32 $this->get_folder_detail($params); 35 $this->get_folder_detail($params);
33 } 36 }
34 37
35 38
36 function get_folder_detail($params) { 39 function get_folder_detail($params) {
37 - $kt = &$this->KT; 40 + if(isset($params['node'])&&!isset($params['folderId'])){
  41 + $params['node']=split('_',$params['node']);
  42 + $params['folderId']=$params['node'][1];
  43 + }
  44 + $kt=&$this->KT;
38 45
39 - $folder = &$kt->get_folder_by_id($params['folderId']); 46 + $folder=&$kt->get_folder_by_id($params['folderId']);
40 if (PEAR::isError($folder)) 47 if (PEAR::isError($folder))
41 { 48 {
42 $this->setError("Could not get folder by Id: {$params['folderId']}"); 49 $this->setError("Could not get folder by Id: {$params['folderId']}");
43 $this->setDebug('FolderError',array('kt'=>$kt,'folder'=>$folder)); 50 $this->setDebug('FolderError',array('kt'=>$kt,'folder'=>$folder));
44 - return; 51 + return false;
45 } 52 }
46 53
47 - $detail = $folder->get_detail();  
48 - if (PEAR::isError($detail))  
49 - {  
50 - $this->response= "detail error {$params['node']}"; 54 + $detail=$folder->get_detail();
  55 + if (PEAR::isError($detail)){
  56 + $this->setResponse("detail error {$params['node']}");
  57 + return false;
51 } 58 }
52 59
53 - if(strtolower($detail['folder_name']) == 'root folder') {  
54 - $detail['folder_name'] = 'KnowledgeTree'; 60 + if(strtolower($detail['folder_name'])=='root folder'){
  61 + $detail['folder_name']='KnowledgeTree';
55 } 62 }
56 63
57 $qtip .= $this->xlate('Folder name').": {$detail['folder_name']}<br>"; 64 $qtip .= $this->xlate('Folder name').": {$detail['folder_name']}<br>";
58 - $class = 'folder'; 65 + $class='folder';
59 66
60 - $permissions = $detail['permissions'];  
61 - $perms = '';  
62 - //default write permissions to false  
63 - $canWrite = false; 67 + $permissions=$detail['permissions'];
  68 + $perms='';
  69 + $canWrite=false;
64 70
65 - //iterate through the permissions and convert to human-readable  
66 - for ($j = 0; $j < strlen($permissions); $j++)  
67 - {  
68 - switch (strtoupper($permissions{$j}))  
69 - { 71 + for ($j=0; $j < strlen($permissions); $j++){
  72 + switch (strtoupper($permissions{$j})){
70 case 'W': 73 case 'W':
71 - $canWrite = true; 74 + $canWrite=true;
72 $perms .= $this->xlate('write, '); 75 $perms .= $this->xlate('write, ');
73 break; 76 break;
74 case 'R': 77 case 'R':
@@ -80,227 +83,195 @@ class kt extends client_service { @@ -80,227 +83,195 @@ class kt extends client_service {
80 } 83 }
81 } 84 }
82 85
83 - //now chop off trailing ', ' if any  
84 - if (strlen($perms) > 2)  
85 - {  
86 - $perms = substr($perms, 0, strlen($perms)-2); 86 + if (strlen($perms) > 2){
  87 + $perms=substr($perms, 0, strlen($perms)-2);
87 } 88 }
88 89
89 - //permissions  
90 $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; 90 $qtip .= $this->xlate('Permissions:') . " {$perms}<br>";
91 -  
92 - //comment  
93 $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder'); 91 $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder');
94 92
95 - $result[] = array  
96 - (  
97 - 'text' => $detail['folder_name'],  
98 - 'id' => $params['control'] . $params['node'],  
99 - 'filename' => $detail['folder_name'],  
100 - 'cls' => 'folder',  
101 - 'leaf' => false,  
102 - 'document_type' => '',  
103 - 'item_type' => 'F',  
104 - 'permissions' => $permissions, 93 + $result[]=array(
  94 + 'text'=>$detail['folder_name'],
  95 + 'id'=>'F_'. $params['folderId'],
  96 + 'filename'=>$detail['folder_name'],
  97 + 'cls'=>'folder',
  98 + 'leaf'=>false,
  99 + 'document_type'=>'',
  100 + 'item_type'=>'F',
  101 + 'permissions'=>$permissions,
105 'qtip'=> $qtip 102 'qtip'=> $qtip
106 ); 103 );
107 104
108 $this->setResponse($result); 105 $this->setResponse($result);
  106 + return true;
109 } 107 }
110 108
111 109
112 function get_folder_contents($params){ 110 function get_folder_contents($params){
113 $kt=&$this->KT; 111 $kt=&$this->KT;
114 112
115 - $params['control'] = 'F_';  
116 - $params['node'] = substr($params['node'], strlen($params['control'])); 113 + $params['control']='F_';
  114 + $params['node']=substr($params['node'], strlen($params['control']));
117 115
118 - $folder = &$kt->get_folder_by_id($params['node']);  
119 - if (PEAR::isError($folder)){  
120 - $this->addError("[error 1] Folder Not Found: {$params['control']}{$params['node']}");  
121 - return false;  
122 - } 116 + $folder=&$kt->get_folder_by_id($params['node']);
  117 + if(!$this->checkPearError($folder,"[error 1] Folder Not Found: {$params['control']}{$params['node']}",'',array()))return false;
123 118
124 - $types = (isset($params['types']) ? $params['types'] : 'DF'); 119 + $types=(isset($params['types']) ? $params['types'] : 'DF');
  120 + $listing=$folder->get_listing(1, $types);
  121 + $result=$this->_processListing($listing, 'folderContents', $params);
125 122
126 - $listing = $folder->get_listing(1, $types); 123 + $this->setResponse($result);
  124 + return true;
  125 + }
127 126
128 - $result = $this->_processListing($listing, 'folderContents', $params);  
129 127
130 - $this->setResponse($result); 128 + /**
  129 + * Returns the contents of a folder formatted for a grid view.
  130 + *
  131 + * @param array $arr
  132 + * @return array
  133 + */
  134 + function get_folder_contents_for_grid($arr)
  135 + {
  136 + $kt=&$this->KT;
  137 +
  138 + $arr['control']='F_';
  139 + $arr['node']=substr($arr['node'], strlen($arr['control']));
  140 +
  141 + $folder=&$kt->get_folder_by_id($arr['node']);
  142 + if (PEAR::isError($folder)){
  143 + $this->addError('Folder Not found');
  144 + return false;
  145 + }
  146 +
  147 + $types=(isset($arr['types']) ? $arr['types'] : 'DF');
  148 +
  149 + $listing=$folder->get_listing(1, $types);
  150 +
  151 + $result=$this->_processListing($listing, 'grid', $arr);
  152 +
  153 + $this->setResponse(array('totalCount'=>count($listing), 'items'=>$result));
  154 +
  155 + return true;
131 } 156 }
132 157
133 - 158 +
  159 +
134 private function _processListing($listing, $type, $arr){ 160 private function _processListing($listing, $type, $arr){
135 - $result = array();  
136 - $methodToIncludeItem = '_processItemInclusion_'.$type;  
137 -  
138 - foreach ($listing as $item)  
139 - {  
140 - $filename = $item['filename'];  
141 - $itemType = $item['item_type'];  
142 -  
143 - $includeMe = true;  
144 -  
145 - //build up tooltip  
146 - $qtip = '';  
147 -  
148 - //default write permissions to false  
149 - $canWrite = false;  
150 - //default immutable to false  
151 - $immutable = false;  
152 -  
153 - //first do permissions since they are applicable to both folders and docs  
154 - $permissions = $item['permissions'];  
155 - $perms = '';  
156 -  
157 - //iterate through the permissions and convert to human-readable  
158 - for ($j = 0; $j < strlen($permissions); $j++)  
159 - {  
160 - switch (strtoupper($permissions{$j}))  
161 - { 161 + $result=array();
  162 + $methodToIncludeItem='_processItemInclusion_'.$type;
  163 +
  164 + foreach($listing as $item){
  165 + /* Trying to fix folder sizes */
  166 + if($item['filesize']<=0){
  167 + $item['filesize']='';
  168 + }else{
  169 + $item['filesize']=serviceHelper::size_readable($item['filesize']);
  170 + }
  171 +
  172 + $filename=$item['filename'];
  173 + $itemType=$item['item_type'];
  174 +
  175 + $includeMe=true;
  176 + $qtip='';
  177 + $canWrite=false;
  178 + $immutable=false;
  179 + $permissions=$item['permissions'];
  180 + $perms='';
  181 +
  182 + for ($j=0; $j < strlen($permissions); $j++){
  183 + switch (strtoupper($permissions{$j})){
162 case 'W': 184 case 'W':
163 - $canWrite = true; 185 + $canWrite=true;
164 $perms .= $this->xlate('write, '); 186 $perms .= $this->xlate('write, ');
165 - break; 187 + break;
166 case 'R': 188 case 'R':
167 $perms .= $this->xlate('read, '); 189 $perms .= $this->xlate('read, ');
168 - break; 190 + break;
169 case 'A': 191 case 'A':
170 $perms .= $this->xlate('add folder, '); 192 $perms .= $this->xlate('add folder, ');
171 - break;  
172 - // default:  
173 - // $perms .= strtoupper($permissions{$j});  
174 - // break; 193 + break;
175 } 194 }
176 } 195 }
177 196
178 - //now chop off trailing ', ' if any  
179 - if (strlen($perms) > 2)  
180 - {  
181 - $perms = substr($perms, 0, strlen($perms)-2); 197 + if(strlen($perms) > 2){
  198 + $perms=substr($perms, 0, strlen($perms)-2);
182 } 199 }
183 200
184 - //folders  
185 - if ($itemType == 'F')  
186 - { 201 + if($itemType=='F'){
187 $qtip .= $this->xlate('Folder name').": {$filename}<br>"; 202 $qtip .= $this->xlate('Folder name').": {$filename}<br>";
188 - $class = 'folder';  
189 -  
190 - //permissions 203 + $class='folder';
191 $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; 204 $qtip .= $this->xlate('Permissions:') . " {$perms}<br>";
192 -  
193 - //comment  
194 $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder'); 205 $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder');
195 } 206 }
196 207
197 //documents 208 //documents
198 - else  
199 - {  
200 - $qtip = '';  
201 -  
202 - //get file extension so can determine mimetype  
203 - $extpos = strrpos($filename, '.') ;  
204 -  
205 - if ($extpos === false)  
206 - {  
207 - $class = 'file-unknown'; 209 + else{
  210 + $qtip='';
  211 + $extpos=strrpos($filename, '.') ;
  212 +
  213 + if($extpos === false){
  214 + $class='file-unknown';
  215 + }else{
  216 + $ext=substr($filename, $extpos); // Get Extension including the dot
  217 + $class='file-' . substr($filename, $extpos +1); // Get Extension without the dot
208 } 218 }
209 - else  
210 - {  
211 - $ext = substr($filename, $extpos); // Get Extension including the dot  
212 - $class = 'file-' . substr($filename, $extpos +1); // Get Extension without the dot  
213 - }  
214 -  
215 - // Convert list to array  
216 - $extensions = explode(',', $arr['extensions']);  
217 -  
218 - //don't include results which don't have the correct file extensions  
219 - if(!in_array(strtolower($ext), $extensions))  
220 - {  
221 - $includeMe = false;  
222 - }  
223 - else  
224 - {  
225 - //filename 219 +
  220 + $extensions=explode(',', $arr['extensions']);
  221 + if(!in_array(strtolower($ext), $extensions)){
  222 + $includeMe=false;
  223 + }else{
226 $qtip .= $this->xlate('Filename') . ": {$filename}<br>"; 224 $qtip .= $this->xlate('Filename') . ": {$filename}<br>";
227 -  
228 - //size  
229 - $qtip .= $this->xlate('File Size') . ": " . fsize_desc($item['filesize']) . "<br>";  
230 -  
231 - //last modified 225 + $qtip .= $this->xlate('File Size') . ": " . serviceHelper::fsize_desc($item['filesize']) . "<br>";
232 $qtip .= $this->xlate('Modified') . ": {$item['modified_date']}<br>"; 226 $qtip .= $this->xlate('Modified') . ": {$item['modified_date']}<br>";
233 -  
234 - //owner  
235 $qtip .= $this->xlate('Owner') . ": {$item['created_by']}<br>"; 227 $qtip .= $this->xlate('Owner') . ": {$item['created_by']}<br>";
236 -  
237 - //version  
238 $qtip .= $this->xlate('Version') . ": {$item['version']}<br>"; 228 $qtip .= $this->xlate('Version') . ": {$item['version']}<br>";
239 -  
240 - //immutability  
241 - if (bool2str(strtolower($item['is_immutable'])) == 'true')  
242 - {  
243 - $canWrite = false;  
244 - $immutable = true; 229 + if (serviceHelper::bool2str(strtolower($item['is_immutable']))=='true'){
  230 + $canWrite=false;
  231 + $immutable=true;
245 } 232 }
246 -  
247 - //status, i.e. checked out or not, or immutable  
248 - if ($immutable)  
249 - { 233 +
  234 + if($immutable){
250 $qtip .= $this->xlate('Status: Immutable') . '<br>'; 235 $qtip .= $this->xlate('Status: Immutable') . '<br>';
251 - }  
252 - else if (strtolower($item['checked_out_by']) != 'n/a' && ($item['checked_out_by'] != ''))  
253 - { 236 + }else if (strtolower($item['checked_out_by']) != 'n/a' && ($item['checked_out_by'] != '')){
254 $qtip .= $this->xlate('Status: Checked out by') . " {$item['checked_out_by']}<br>"; 237 $qtip .= $this->xlate('Status: Checked out by') . " {$item['checked_out_by']}<br>";
255 - }  
256 - else  
257 - { 238 + }else{
258 $qtip .= $this->xlate('Status: Available') . '<br>'; 239 $qtip .= $this->xlate('Status: Available') . '<br>';
259 } 240 }
260 -  
261 - //permissions  
262 $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; 241 $qtip .= $this->xlate('Permissions:') . " {$perms}<br>";
263 242
264 - //immutable  
265 - if($immutable)  
266 - { 243 + if($immutable){
267 $qtip .= $this->xlate('This document is not editable'); 244 $qtip .= $this->xlate('This document is not editable');
268 - }  
269 - else if ($canWrite)  
270 - { 245 + }else if ($canWrite){
271 $qtip .= $this->xlate('You may edit this document'); 246 $qtip .= $this->xlate('You may edit this document');
272 - }  
273 - else  
274 - { 247 + }else{
275 $qtip .= $this->xlate('This document is not editable'); 248 $qtip .= $this->xlate('This document is not editable');
276 } 249 }
277 } 250 }
278 }//end of if for files 251 }//end of if for files
279 - if($includeMe)  
280 - {  
281 - $result[] = $this->$methodToIncludeItem($item, $class, $qtip); 252 + if($includeMe){
  253 + $result[]=$this->$methodToIncludeItem($item, $class, $qtip);
282 } 254 }
283 } 255 }
284 -  
285 return $result; 256 return $result;
286 } 257 }
287 258
288 259
289 260
290 261
291 - private function _processItemInclusion_folderContents($item, $class, $qtip)  
292 - { 262 + private function _processItemInclusion_folderContents($item, $class, $qtip){
293 return array ( 263 return array (
294 - 'text' => htmlspecialchars($item['title']),  
295 - 'originaltext' => $item['title'],  
296 - 'id' => ($item['item_type'] == 'F' ? $item['item_type']."_" : "").$item['id'],  
297 - 'filename' => $item['filename'],  
298 - 'cls' => $class,  
299 - 'leaf' => ($item['item_type'] == 'D'),  
300 - 'document_type' => $item['document_type'],  
301 - 'item_type' => $item['item_type'],  
302 - 'permissions' => $item['permissions'],  
303 - 'content_id' => $item['content_id'], 264 + 'text'=>htmlspecialchars($item['title']),
  265 + 'originaltext'=>$item['title'],
  266 + 'id'=>($item['item_type']=='F' ? $item['item_type']."_" : "").$item['id'],
  267 + 'filename'=>$item['filename'],
  268 + 'cls'=>$class,
  269 + 'leaf'=>($item['item_type']=='D'),
  270 + 'document_type'=>$item['document_type'],
  271 + 'item_type'=>$item['item_type'],
  272 + 'permissions'=>$item['permissions'],
  273 + 'content_id'=>$item['content_id'],
  274 + 'checked_out_by'=>$item['checked_out_by'],
304 'qtip'=> $qtip 275 'qtip'=> $qtip
305 ); 276 );
306 } 277 }
@@ -309,128 +280,155 @@ class kt extends client_service { @@ -309,128 +280,155 @@ class kt extends client_service {
309 private function _processItemInclusion_search($item, $class, $qtip) 280 private function _processItemInclusion_search($item, $class, $qtip)
310 { 281 {
311 return array ( 282 return array (
312 - 'text' => htmlspecialchars($item['title']),  
313 - 'originaltext' => $item['title'],  
314 - 'id' => $item['document_id'],  
315 - 'filename' => $item['filename'],  
316 - 'cls' => $class,  
317 - 'leaf' => true,  
318 - 'document_type' => $item['document_type'],  
319 - 'item_type' => 'D',  
320 - 'permissions' => $item['permissions'],  
321 - 'content_id' => $item['content_id'],  
322 - 'relevance' => $item['relevance'], 283 + 'text'=>htmlspecialchars($item['title']),
  284 + 'originaltext'=>$item['title'],
  285 + 'id'=>$item['document_id'],
  286 + 'filename'=>$item['filename'],
  287 + 'cls'=>$class,
  288 + 'leaf'=>true,
  289 + 'document_type'=>$item['document_type'],
  290 + 'item_type'=>'D',
  291 + 'permissions'=>$item['permissions'],
  292 + 'content_id'=>$item['content_id'],
  293 + 'relevance'=>$item['relevance'],
323 'qtip'=> $qtip 294 'qtip'=> $qtip
324 ); 295 );
325 } 296 }
326 297
  298 + private function _processItemInclusion_grid($item, $class, $qtip)
  299 + {
  300 + //var_dump($item);
  301 +
  302 + if ($item['filesize']=='n/a') {
  303 + $item['filesize']=-1;
  304 + }
  305 +
  306 + return array (
  307 + 'text'=>htmlspecialchars($item['title']),
  308 + 'originaltext'=>$item['title'],
  309 + 'id'=>$item['id'],
  310 + 'filename'=>$item['filename'],
  311 + 'cls'=>$class,
  312 + 'owner'=>$item['created_by'],
  313 + 'document_type'=>$item['document_type'],
  314 + 'item_type'=>$item['item_type'],
  315 + 'permissions'=>$item['permissions'],
  316 + 'content_id'=>$item['content_id'],
  317 + 'filesize'=>$item['filesize'],
  318 + 'modified'=>$item['modified_date'],
  319 + 'checked_out_by'=>$item['checked_out_by']
  320 + );
  321 + }
  322 +
327 323
328 -  
329 public function get_metadata($params) { 324 public function get_metadata($params) {
  325 + $kt=&$this->KT;
330 326
331 - $kt = &$this->KT; 327 + if (substr($params['document_id'], 0, 2)=='D_') {
  328 + $params['document_id']=substr($params['document_id'], 2);
  329 + }
332 330
333 - $document_id = (int)$params['document_id']; 331 + $document_id=(int)$params['document_id'];
334 if($document_id > 0) { 332 if($document_id > 0) {
335 - $document = $kt->get_document_by_id($params['document_id']);  
336 - $detail = $document->get_metadata();  
337 - $document_detail = $document->get_detail();  
338 - $title = $document_detail['title'];  
339 - $document_type = $document_detail['document_type']; 333 + $document=$kt->get_document_by_id($params['document_id']);
  334 + $detail=$document->get_metadata();
  335 + $document_detail=$document->get_detail();
  336 + $title=$document_detail['title'];
  337 + $document_type=$document_detail['document_type'];
340 338
341 - } else { 339 + }else{
342 if(isset($params['document_type'])) { 340 if(isset($params['document_type'])) {
343 - $document_type = $params['document_type'];  
344 - } else {  
345 - $document_type = 'Default'; 341 + $document_type=$params['document_type'];
  342 + }else{
  343 + $document_type='Default';
346 } 344 }
347 - $detail = $kt->get_document_type_metadata($document_type);  
348 - $title = ""; 345 + $detail=$kt->get_document_type_metadata($document_type);
  346 + $title="";
349 } 347 }
350 348
351 - $result = array();  
352 - $items = array();  
353 - $index = 0;  
354 - $items[] = array("name" => "__title", "index" => 0, "value" => $title, "control_type" => "string"); 349 + $result=array();
  350 + $items=array();
  351 + $index=0;
  352 + $items[]=array("name"=>"__title", "index"=>0, "value"=>$title, "control_type"=>"string");
355 353
356 354
357 // Commented out for timebeing - will be used by 'Save in Format' 355 // Commented out for timebeing - will be used by 'Save in Format'
358 356
359 if (isset($params['extensions'])) { 357 if (isset($params['extensions'])) {
360 358
361 - $fileParts = pathinfo($document_detail['filename']); 359 + $fileParts=pathinfo($document_detail['filename']);
362 360
363 - $items[] = array("name" => "__document_extension", "index" => 0, "value" => strtolower($fileParts['extension']), "control_type" => "lookup", "selection" => explode(',', str_replace('.', '', $params['extensions']))); 361 + $items[]=array("name"=>"__document_extension", "index"=>0, "value"=>strtolower($fileParts['extension']), "control_type"=>"lookup", "selection"=>explode(',', str_replace('.', '', $params['extensions'])));
364 } 362 }
365 363
366 - $document_types = $this->get_documenttypes($params);  
367 - $json_document_types = array(); 364 + $document_types=$this->get_documenttypes($params);
  365 + $json_document_types=array();
368 foreach($document_types['items'] as $val) { 366 foreach($document_types['items'] as $val) {
369 - $json_document_types[] = $val['name']; 367 + $json_document_types[]=$val['name'];
370 } 368 }
371 - $items[] = array("name" => "__document_type", "index" => 0, "value" => $document_type, "control_type" => "lookup", "selection" => $json_document_types); 369 + $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$json_document_types);
372 370
373 371
374 for($i=0;$i<count($detail);$i++) { 372 for($i=0;$i<count($detail);$i++) {
375 373
376 for($j=0;$j<count($detail[$i]['fields']);$j++) 374 for($j=0;$j<count($detail[$i]['fields']);$j++)
377 { 375 {
378 - $items[] = array(  
379 - 'fieldset' => $detail[$i]['fieldset'],  
380 - 'name' => $detail[$i]['fields'][$j]['name'], 376 + $items[]=array(
  377 + 'fieldset'=>$detail[$i]['fieldset'],
  378 + 'name'=>$detail[$i]['fields'][$j]['name'],
381 379
382 // Change for value. If blank value is set to 1, change value to '' 380 // Change for value. If blank value is set to 1, change value to ''
383 // Overcomes issue of n/a 381 // Overcomes issue of n/a
384 - 'value' => ($document_id > 0 ? ($detail[$i]['fields'][$j]['blankvalue'] == '1' ? '' : $detail[$i]['fields'][$j]['value']) : ''),  
385 -  
386 - 'description' => $detail[$i]['fields'][$j]['description'],  
387 - 'control_type' => $detail[$i]['fields'][$j]['control_type'],  
388 - 'selection' => $detail[$i]['fields'][$j]['selection'],  
389 - 'required' => $detail[$i]['fields'][$j]['required'],  
390 - 'blankvalue' => $detail[$i]['fields'][$j]['blankvalue'],  
391 - 'index' => $index 382 + 'value'=>($document_id > 0 ? ($detail[$i]['fields'][$j]['blankvalue']=='1' ? '' : $detail[$i]['fields'][$j]['value']) : ''),
  383 +
  384 + 'description'=>$detail[$i]['fields'][$j]['description'],
  385 + 'control_type'=>$detail[$i]['fields'][$j]['control_type'],
  386 + 'selection'=>$detail[$i]['fields'][$j]['selection'],
  387 + 'required'=>$detail[$i]['fields'][$j]['required'],
  388 + 'blankvalue'=>$detail[$i]['fields'][$j]['blankvalue'],
  389 + 'index'=>$index
392 ); 390 );
393 $index++; 391 $index++;
394 } 392 }
395 } 393 }
396 394
397 395
398 - $this->setResponse(array('id' => $title, 'items' => $items, 'count' => count($items)));  
399 - 396 + $this->setResponse(array('id'=>$title, 'items'=>$items, 'count'=>count($items)));
400 397
  398 + return true;
401 } 399 }
402 400
403 401
404 public function get_documenttypes($params) { 402 public function get_documenttypes($params) {
405 403
406 - $kt = &$this->KT; 404 + $kt=&$this->KT;
407 405
408 - $detail = $kt->get_documenttypes();  
409 - $result = array();  
410 - $items = array(); 406 + $detail=$kt->get_documenttypes();
  407 + $result=array();
  408 + $items=array();
411 for($i=0;$i<count($detail);$i++) { 409 for($i=0;$i<count($detail);$i++) {
412 if(strtolower(substr($detail[$i], -5)) != 'email') 410 if(strtolower(substr($detail[$i], -5)) != 'email')
413 { 411 {
414 - $items[] = array(  
415 - 'name' => $detail[$i] 412 + $items[]=array(
  413 + 'name'=>$detail[$i]
416 ); 414 );
417 } 415 }
418 } 416 }
419 - $this->setResponse(array('items' => $items, 'count' => count($items))); 417 + $this->setResponse(array('items'=>$items, 'count'=>count($items)));
420 } 418 }
421 419
422 function update_document_type($params) { 420 function update_document_type($params) {
423 - $kt = &$this->KT;  
424 - $document_id = (int)$params['document_id']; 421 + $kt=&$this->KT;
  422 + $document_id=(int)$params['document_id'];
425 if($document_id > 0) { 423 if($document_id > 0) {
426 - $document = $kt->get_document_by_id($document_id); 424 + $document=$kt->get_document_by_id($document_id);
427 $document->change_document_type($params['document_type']); 425 $document->change_document_type($params['document_type']);
428 - $this->setResponse(array('status_code' => 0)); 426 + $this->setResponse(array('status_code'=>0));
429 return true; 427 return true;
430 428
431 }else{ 429 }else{
432 $this->addError("Invalid document Id : {$document_id}"); 430 $this->addError("Invalid document Id : {$document_id}");
433 - $this->setResponse(array('status_code' => 1)); 431 + $this->setResponse(array('status_code'=>1));
434 return false; 432 return false;
435 } 433 }
436 434
@@ -447,35 +445,38 @@ class kt extends client_service { @@ -447,35 +445,38 @@ class kt extends client_service {
447 $session_id=$params['session_id']; 445 $session_id=$params['session_id'];
448 446
449 447
450 - $document = &$kt->get_document_by_id($params['document_id']);  
451 - $docname = $document->document->getFileName(); 448 + $document=&$kt->get_document_by_id($params['document_id']);
452 // $docname='test.txt'; 449 // $docname='test.txt';
453 if (PEAR::isError($document)) 450 if (PEAR::isError($document))
454 { 451 {
455 - $response['message'] = $document->getMessage();  
456 - $this->debug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id); 452 + $response['message']=$document->getMessage();
  453 + $this->addDebug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id);
457 454
458 - $this->setResponse(new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response)); 455 +// $this->setResponse(new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response));
  456 + $this->setResponse($response);
459 return; 457 return;
460 } 458 }
461 -  
462 - $result = $document->download(); 459 + $docname=$document->document->getFileName();
  460 + $result=$document->download();
463 if (PEAR::isError($result)) 461 if (PEAR::isError($result))
464 { 462 {
465 - $response['message'] = $result->getMessage();  
466 - $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage())); 463 + $response['message']=$result->getMessage();
  464 + $this->setResponse(array('status_code'=>1, 'message'=>$result->getMessage()));
467 return; 465 return;
468 } 466 }
469 467
470 - $session = &$kt->get_session();  
471 - $download_manager = new KTDownloadManager(); 468 + $session=&$kt->get_session();
  469 + $download_manager=new KTDownloadManager();
472 $download_manager->set_session($session->session); 470 $download_manager->set_session($session->session);
473 $download_manager->cleanup(); 471 $download_manager->cleanup();
474 - $url = $download_manager->allow_download($document);  
475 -  
476 - $response['status_code'] = 0;  
477 - $response['message'] = $url;  
478 - $response['filename'] = $docname; 472 + $url=$download_manager->allow_download($document);
  473 + //http://ktair.dev?code=750f7a09d40a3d855f2897f417baf0bbb9a1f615&d=16&u=evm2pdkkhfagon47eh2b9slqj6
  474 + $url=split('\?',$url);
  475 + $url=$url[0].'/ktwebservice/download.php?'.$url[1];
  476 +
  477 + $response['status_code']=0;
  478 + $response['message']=$url;
  479 + $response['filename']=$docname;
479 $this->setResponse($response); 480 $this->setResponse($response);
480 } 481 }
481 482
@@ -490,35 +491,35 @@ class kt extends client_service { @@ -490,35 +491,35 @@ class kt extends client_service {
490 * 491 *
491 */ 492 */
492 function checkout_document($params){ 493 function checkout_document($params){
493 - $responseType = 'kt_response'; 494 + $responseType='kt_response';
494 $kt=&$this->KT; 495 $kt=&$this->KT;
495 496
496 - $document = &$kt->get_document_by_id($params['document_id']); 497 + $document=&$kt->get_document_by_id($params['document_id']);
497 if (PEAR::isError($document)) 498 if (PEAR::isError($document))
498 { 499 {
499 $this->addError("checkout_document - cannot get documentid {$params['document_id']} - " . $document->getMessage()); 500 $this->addError("checkout_document - cannot get documentid {$params['document_id']} - " . $document->getMessage());
500 - $this->setResponse(array('status_code' => 1, 'message' => $document->getMessage())); 501 + $this->setResponse(array('status_code'=>1, 'message'=>$document->getMessage()));
501 return; 502 return;
502 } 503 }
503 504
504 - $result = $document->checkout($params['reason']); 505 + $result=$document->checkout($params['reason']);
505 if (PEAR::isError($result)) 506 if (PEAR::isError($result))
506 { 507 {
507 $this->addError($result->getMessage()); 508 $this->addError($result->getMessage());
508 - $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage())); 509 + $this->setResponse(array('status_code'=>1, 'message'=>$result->getMessage()));
509 return; 510 return;
510 } 511 }
511 512
512 - $url = ''; 513 + $url='';
513 if ($params['download']) 514 if ($params['download'])
514 { 515 {
515 - $download_manager = new KTDownloadManager(); 516 + $download_manager=new KTDownloadManager();
516 $download_manager->set_session($params['session_id']); 517 $download_manager->set_session($params['session_id']);
517 $download_manager->cleanup(); 518 $download_manager->cleanup();
518 - $url = $download_manager->allow_download($document); 519 + $url=$download_manager->allow_download($document);
519 } 520 }
520 521
521 - $this->setResponse(array('status_code' => 0, 'message' => $url)); 522 + $this->setResponse(array('status_code'=>0, 'message'=>$url));
522 } 523 }
523 524
524 525
@@ -533,43 +534,43 @@ class kt extends client_service { @@ -533,43 +534,43 @@ class kt extends client_service {
533 * @param array $params 534 * @param array $params
534 */ 535 */
535 function checkin_document($params){ 536 function checkin_document($params){
536 - $session_id = $this->AuthInfo['session'];  
537 - $document_id = $params['document_id'];  
538 - $filename = $params['filename'];  
539 - $reason = $params['reason'];  
540 - $tempfilename = $params['tempfilename'];  
541 - $application = $this->AuthInfo['appType']; 537 + $session_id=$this->AuthInfo['session'];
  538 + $document_id=$params['document_id'];
  539 + $filename=$params['filename'];
  540 + $reason=$params['reason'];
  541 + $tempfilename=$params['tempfilename'];
  542 + $application=$this->AuthInfo['appType'];
542 543
543 $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')"); 544 $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')");
544 - $kt = &$this->KT; 545 + $kt=&$this->KT;
545 546
546 // we need to add some security to ensure that people don't frig the checkin process to access restricted files. 547 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
547 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. 548 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
548 - $upload_manager = new KTUploadManager(); 549 + $upload_manager=new KTUploadManager();
549 if (!$upload_manager->is_valid_temporary_file($tempfilename)) 550 if (!$upload_manager->is_valid_temporary_file($tempfilename))
550 { 551 {
551 - $this->setResponse(array('status_code' => 12)); 552 + $this->setResponse(array('status_code'=>12));
552 return; 553 return;
553 } 554 }
554 555
555 - $document = &$kt->get_document_by_id($document_id); 556 + $document=&$kt->get_document_by_id($document_id);
556 if (PEAR::isError($document)) 557 if (PEAR::isError($document))
557 { 558 {
558 - $this->setResponse(array('status_code' => 13)); 559 + $this->setResponse(array('status_code'=>13));
559 } 560 }
560 561
561 // checkin 562 // checkin
562 - $result = $document->checkin($filename, $reason, $tempfilename, false); 563 + $result=$document->checkin($filename, $reason, $tempfilename, false);
563 if (PEAR::isError($result)) 564 if (PEAR::isError($result))
564 { 565 {
565 - $this->setResponse(array('status_code' => 14)); 566 + $this->setResponse(array('status_code'=>14));
566 } 567 }
567 568
568 // get status after checkin 569 // get status after checkin
569 //$this->response= $this->get_document_detail($session_id, $document_id); 570 //$this->response= $this->get_document_detail($session_id, $document_id);
570 - $detail = $document->get_detail();  
571 - $detail['status_code'] = 0;  
572 - $detail['message'] = ''; 571 + $detail=$document->get_detail();
  572 + $detail['status_code']=0;
  573 + $detail['message']='';
573 574
574 $this->setResponse($detail); 575 $this->setResponse($detail);
575 } 576 }
@@ -581,686 +582,540 @@ class kt extends client_service { @@ -581,686 +582,540 @@ class kt extends client_service {
581 * @param unknown_type $arr 582 * @param unknown_type $arr
582 */ 583 */
583 function add_document_with_metadata($arr){ 584 function add_document_with_metadata($arr){
584 - $session_id = $arr['session_id']; 585 + $session_id=$arr['session_id'];
585 //error_reporting(E_ALL); 586 //error_reporting(E_ALL);
586 - $metadata = array();  
587 - $packed = @json_decode($arr['metadata']); 587 + $metadata=array();
  588 + $packed=@json_decode($arr['metadata']);
588 589
589 $this->debug('Entered add_document_with_metadata'); 590 $this->debug('Entered add_document_with_metadata');
590 591
591 - foreach($packed as $key => $val) { 592 + foreach($packed as $key=>$val) {
592 if(!is_array($metadata[$val->fieldset])) { 593 if(!is_array($metadata[$val->fieldset])) {
593 - $metadata[$val->fieldset]['fieldset'] = $val->fieldset;  
594 - $metadata[$val->fieldset]['fields'] = array(); 594 + $metadata[$val->fieldset]['fieldset']=$val->fieldset;
  595 + $metadata[$val->fieldset]['fields']=array();
595 } 596 }
596 - $metadata[$val->fieldset]['fields'][] = array(  
597 - 'name' => $val->name,  
598 - 'value' => $val->value 597 + $metadata[$val->fieldset]['fields'][]=array(
  598 + 'name'=>$val->name,
  599 + 'value'=>$val->value
599 ); 600 );
600 } 601 }
601 602
602 - $add_result = $this->add_document($arr['session_id'], $arr['folder_id'], $arr['title'], $arr['filename'], $arr['documenttype'], $arr['tempfilename'], $arr['application']); 603 + $add_result=$this->add_document($arr['session_id'], $arr['folder_id'], $arr['title'], $arr['filename'], $arr['documenttype'], $arr['tempfilename'], $arr['application']);
603 $this->debug('$this->response= from add_document'); 604 $this->debug('$this->response= from add_document');
604 605
605 - $status_code = $add_result['status_code']; 606 + $status_code=$add_result['status_code'];
606 if ($status_code != 0) 607 if ($status_code != 0)
607 { 608 {
608 $this->response= $add_result; 609 $this->response= $add_result;
609 } 610 }
610 - $document_id = $add_result['document_id'];  
611 - $content_id = $add_result['content_id']; 611 + $document_id=$add_result['document_id'];
  612 + $content_id=$add_result['content_id'];
612 613
613 - $update_result = $this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array()); 614 + $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
614 $this->debug('$this->response= from update_document_metadata'); 615 $this->debug('$this->response= from update_document_metadata');
615 - $status_code = $update_result['status_code']; 616 + $status_code=$update_result['status_code'];
616 if ($status_code != 0) 617 if ($status_code != 0)
617 { 618 {
618 $this->delete_document($arr['session_id'], $document_id, 'Rollback because metadata could not be added', $arr['application']); 619 $this->delete_document($arr['session_id'], $document_id, 'Rollback because metadata could not be added', $arr['application']);
619 $this->response= $update_result; 620 $this->response= $update_result;
620 } 621 }
621 622
622 - $kt = &$this->KT; 623 + $kt=&$this->KT;
623 if (is_array($kt)) 624 if (is_array($kt))
624 { 625 {
625 - $this->response= array('status_code' => 1); 626 + $this->response= array('status_code'=>1);
626 } 627 }
627 628
628 - $document = $kt->get_document_by_id($document_id);  
629 - $result = $document->removeUpdateNotification(); 629 + $document=$kt->get_document_by_id($document_id);
  630 + $result=$document->removeUpdateNotification();
630 if (PEAR::isError($result)) 631 if (PEAR::isError($result))
631 { 632 {
632 // not much we can do, maybe just log! 633 // not much we can do, maybe just log!
633 } 634 }
634 635
635 636
636 - $result = $document->mergeWithLastMetadataVersion(); 637 + $result=$document->mergeWithLastMetadataVersion();
637 if (PEAR::isError($result)) 638 if (PEAR::isError($result))
638 { 639 {
639 // not much we can do, maybe just log! 640 // not much we can do, maybe just log!
640 } 641 }
641 642
642 - $this->response= array('status_code' => 0, 'document_id' => $document_id, 'content_id' => $content_id); 643 + $this->response= array('status_code'=>0, 'document_id'=>$document_id, 'content_id'=>$content_id);
643 } 644 }
644 645
645 -}  
646 -  
647 -  
648 -/*  
649 -  
650 -  
651 -  
652 646
653 -  
654 -  
655 -  
656 -  
657 -  
658 -  
659 -  
660 -  
661 - function debug($str) {  
662 - $this->response= true;  
663 - if(!is_resource($this->dfp)) {  
664 - $this->dfp = fopen("./debug.log", "a+"); 647 + function get_all_client_policies(){
  648 + $config=KTConfig::getSingleton();
  649 + $this->addDebug('KTConfig Singleton',$config);
  650 +
  651 + $policies=array('allowRememberPassword', 'captureReasonsCheckin', 'captureReasonsCheckout');
  652 +
  653 + $returnPolicies=array();
  654 +
  655 + foreach ($policies as $policy_name)
  656 + {
  657 + $policyInfo=array(
  658 + 'name'=>$policy_name,
  659 + 'value'=>serviceHelper::bool2str($config->get('addInPolicies/'.$policy_name)),
  660 + 'type'=>'boolean'
  661 + );
  662 +
  663 + $returnPolicies[$policy_name] =$policyInfo;
665 } 664 }
666 - fwrite($this->dfp, strftime("[DEBUG %Y-%m-%d %H:%M:%S] ").$str."\r\n"); 665 +
  666 + $languages=$this->get_languages(true);
  667 +
  668 + $metadata=array('totalProperty'=>'resultsCounter', 'root'=>'languages', 'fields'=>array('isoCode', 'language'));
  669 +
  670 + $finalArray=array();
  671 + $finalArray['metaData']=$metadata;
  672 + $finalArray['policies']=$returnPolicies;
  673 + $finalArray['languages']=$languages['languages'];
  674 + $finalArray['defaultLanguage']=$languages['defaultLanguage'];
  675 + $finalArray['resultsCounter']=$languages['count'];
  676 +
  677 +
  678 + $this->setResponse($finalArray);
  679 + return true;
  680 + }
  681 +
  682 + public function switchlang($params){
  683 + setcookie("kt_language", $params['lang'], 2147483647, '/');
667 } 684 }
668 685
669 686
  687 + function add_document_params($params){
  688 + $folder_id=$params['folder_id'];
  689 + $title=$params['title'];
  690 + $filename=$params['filename'];
  691 + $documenttype=$params['documenttype'];
  692 + $tempfilename=$params['tempfilename'];
  693 + $application=$params['application'];
670 694
  695 + $this->addDebug('','Entered add_document');
  696 + $kt=&$this->KT;
671 697
672 - function add_document_params($params)  
673 - {  
674 - $session_id = $params['session_id'];  
675 - $folder_id = $params['folder_id'];  
676 - $title = $params['title'];  
677 - $filename = $params['filename'];  
678 - $documenttype = $params['documenttype'];  
679 - $tempfilename = $params['tempfilename'];  
680 - $application = $params['application'];  
681 -  
682 - $this->debug('Entered add_document');  
683 - $kt = &$this->get$this->xlateapi($session_id, $application);  
684 - if (is_array($kt))  
685 - {  
686 - $this->response= array('status_code' => 1);  
687 - }  
688 - $this->debug("Got \$kt");  
689 -  
690 - $upload_manager = new KTUploadManager();  
691 - if (!$upload_manager->is_valid_temporary_file($tempfilename))  
692 - {  
693 - $this->response= array('status_code' => 1); 698 + $upload_manager=new KTUploadManager();
  699 + if (!$upload_manager->is_valid_temporary_file($tempfilename)) {
  700 + $this->addError('Temporary File Not Valid');
  701 + $this->setResponse(array('status_code'=>1));
  702 + return false;
694 } 703 }
695 - $this->debug('Exited is_valid_temporary file'); 704 + $this->addDebug('','Exited is_valid_temporary file');
696 705
697 - $folder = &$kt->get_folder_by_id($folder_id);  
698 - if (PEAR::isError($folder))  
699 - {  
700 - $this->response= array('status_code' => 1); 706 + $folder=&$kt->get_folder_by_id($folder_id);
  707 + if (PEAR::isError($folder)){
  708 + $this->addError('Could not find Folder '.$folder_id);
  709 + $this->setResponse(array('status_code'=>1));
  710 + return false;
701 } 711 }
702 712
703 - $this->debug('Exited get_folder_by_id'); 713 + $this->addDebug('','Exited get_folder_by_id');
704 714
705 - $document = &$folder->add_document($title, $filename, $documenttype, $tempfilename);  
706 - if (PEAR::isError($document))  
707 - {  
708 - $this->response= array('status_code' => 1); 715 + $document=&$folder->add_document($title, $filename, $documenttype, $tempfilename);
  716 + if (PEAR::isError($document)){
  717 + $this->addError("Could add Document [title:{$title},filename:{$filename},documenttype:{$documenttype},tempfilename:{$tempfilename}]");
  718 + $this->setResponse(array('status_code'=>1));
  719 + return false;
709 } 720 }
710 721
711 - $this->debug('Exited folder add_document'); 722 + $this->addDebug('','Exited folder add_document');
712 723
713 - $detail = $document->get_detail();  
714 - $detail['status_code'] = 0;  
715 - $detail['message'] = '';  
716 -  
717 - $this->response= $detail; 724 + $detail=$document->get_detail();
  725 + $detail['status_code']=0;
  726 + $detail['message']='';
718 727
  728 + $this->setResponse($detail);
719 } 729 }
  730 +
  731 + function delete_document($session_id, $document_id, $reason, $application){
  732 + $kt=&$this->KT;
720 733
721 -  
722 - function add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $application)  
723 - {  
724 - $this->debug('Entered add_document');  
725 - $kt = &$this->get$this->xlateapi($session_id, $application);  
726 - if (is_array($kt))  
727 - {  
728 - $this->response= array('status_code' => 1); 734 + $document=&$kt->get_document_by_id($document_id);
  735 + if (PEAR::isError($document)){
  736 + $this->addError("Invalid document {$document_id}");
  737 + $this->setResponse(array('status_code'=>1));
  738 + return false;
729 } 739 }
730 - $this->debug("Got \$kt");  
731 740
732 - $upload_manager = new KTUploadManager();  
733 - if (!$upload_manager->is_valid_temporary_file($tempfilename))  
734 - {  
735 - $this->response= array('status_code' => 1); 741 + $result=$document->delete($reason);
  742 + if (PEAR::isError($result)) {
  743 + $this->addError("Could not delete document {$document_id}");
  744 + $this->setResponse(array('status_code'=>1));
  745 + return false;
736 } 746 }
737 - $this->debug('Exited is_valid_temporary file');  
738 -  
739 - $folder = &$kt->get_folder_by_id($folder_id);  
740 - if (PEAR::isError($folder))  
741 - {  
742 - $this->response= array('status_code' => 1);  
743 - }  
744 -  
745 - $this->debug('Exited get_folder_by_id');  
746 -  
747 - $document = &$folder->add_document($title, $filename, $documenttype, $tempfilename);  
748 - if (PEAR::isError($document))  
749 - {  
750 - $this->response= array('status_code' => 1);  
751 - }  
752 -  
753 - $this->debug('Exited folder add_document');  
754 -  
755 - $detail = $document->get_detail();  
756 - $detail['status_code'] = 0;  
757 - $detail['message'] = '';  
758 -  
759 - $this->response= $detail; 747 + $this->setResponse(array('status_code'=>0));
  748 + return true;
760 } 749 }
761 750
762 751
763 752
764 - function delete_document($session_id, $document_id, $reason, $application)  
765 - {  
766 - $kt = &$this->get$this->xlateapi($session_id, $application );  
767 - if (is_array($kt))  
768 - {  
769 - $this->response= array('status_code' => 1);  
770 - }  
771 -  
772 -  
773 - $document = &$kt->get_document_by_id($document_id);  
774 - if (PEAR::isError($document))  
775 - {  
776 - $this->response= array('status_code' => 1);  
777 - }  
778 -  
779 - $result = $document->delete($reason);  
780 - if (PEAR::isError($result))  
781 - {  
782 - $this->response= array('status_code' => 1);  
783 - }  
784 - $response['status_code'] = 0;  
785 -  
786 - $this->response= $response;  
787 -  
788 - }  
789 -  
790 - function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null)  
791 - {  
792 - $this->debug('entered update_document_metadata');  
793 - $kt = &$this->get$this->xlateapi($session_id, $application );  
794 - $responseType = 'kt_response';  
795 - if ($this->version >= 2)  
796 - {  
797 - $responseType = 'kt_document_detail';  
798 - } 753 + private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){
  754 + $this->addDebug('','entered update_document_metadata');
  755 + $kt=&$this->KT;
  756 + $responseType='kt_document_detail';
799 757
800 - if (is_array($kt))  
801 - {  
802 - $this->response= array('status_code' => 1, 'kterror'=>$kt); 758 + $document=&$kt->get_document_by_id($document_id);
  759 + if (PEAR::isError($document)){
  760 + return array('status_code'=>1, 'error'=>'Error getting document');
803 } 761 }
804 762
805 - $document = &$kt->get_document_by_id($document_id);  
806 - if (PEAR::isError($document))  
807 - {  
808 - $this->response= array('status_code' => 1, 'error'=>'Error getting document');  
809 - }  
810 -  
811 - $result = $document->update_metadata($metadata);  
812 - if (PEAR::isError($result))  
813 - {  
814 - $this->response= array('status_code' => 1, 'error'=>'Error updating metadata'); 763 + $result=$document->update_metadata($metadata);
  764 + if (PEAR::isError($result)){
  765 + return array('status_code'=>1, 'error'=>'Error updating metadata');
815 } 766 }
816 767
817 - if ($this->version >= 2)  
818 - {  
819 - $result = $document->update_sysdata($sysdata);  
820 - if (PEAR::isError($result))  
821 - {  
822 - $this->response= array('status_code' => 1, 'error'=>'Error update_sysdata');  
823 - }  
824 - }  
825 - $response['status_code'] = 0;  
826 -  
827 - $this->response= array('status_code' => 0);  
828 - }  
829 -  
830 -  
831 - function get_client_policy($arr)  
832 - {  
833 - $policy_name = $arr['policy_name'];  
834 -  
835 - $config = KTConfig::getSingleton();  
836 -  
837 - $policy = array(  
838 - 'name' => $policy_name,  
839 - 'value' => bool2str($config->get($policy_name)),  
840 - 'type' => 'boolean'  
841 - );  
842 -  
843 - $response['policy'] = $policy;  
844 - $response['message'] = 'Knowledgetree client policies retrieval succeeded.';  
845 - $response['status_code'] = 0; 768 + $result=$document->update_sysdata($sysdata);
  769 + if (PEAR::isError($result)){
  770 + return array('status_code'=>1, 'error'=>'Error update_sysdata');
  771 + }
846 772
847 - $this->response= $response; 773 + return array('status_code'=>0);
848 } 774 }
849 775
850 - function get_all_client_policies()  
851 - {  
852 - $config = KTConfig::getSingleton();  
853 -  
854 - $policies = array('allowRememberPassword', 'captureReasonsCheckin', 'captureReasonsCheckout'); 776 + function get_client_policy($arr){
  777 + $policy_name=$arr['policy_name'];
855 778
856 - $$this->response=Policies = array(); 779 + $config=KTConfig::getSingleton();
857 780
858 - foreach ($policies as $policy_name)  
859 - {  
860 - $policyInfo = array(  
861 - 'name' => $policy_name,  
862 - 'value' => bool2str($config->get('addInPolicies/'.$policy_name)),  
863 - 'type' => 'boolean' 781 + $policy=array(
  782 + 'name'=>$policy_name,
  783 + 'value'=>serviceHelper::bool2str($config->get($policy_name)),
  784 + 'type'=>'boolean'
864 ); 785 );
865 786
866 - $this->response=Policies[$policy_name] = $policyInfo;  
867 - }  
868 -  
869 - $languages = $this->get_languages();  
870 -  
871 - $metadata = array('totalProperty'=>'resultsCounter', 'root'=>'languages', 'fields'=>array('isoCode', 'language'));  
872 -  
873 - $finalArray = array();  
874 - $finalArray['metaData'] = $metadata;  
875 - $finalArray['policies'] = $$this->response=Policies;  
876 - $finalArray['languages'] = $languages['languages'];  
877 - $finalArray['defaultLanguage'] = $languages['defaultLanguage'];  
878 - $finalArray['resultsCounter'] = $languages['count']; 787 + $response['policy']=$policy;
  788 + $response['message']='Knowledgetree client policies retrieval succeeded.';
  789 + $response['status_code']=0;
879 790
880 -  
881 - $this->response= $finalArray; 791 + $this->setResponse($response);
  792 + return true;
882 } 793 }
883 794
884 - function search($arr)  
885 - {  
886 - $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application']);  
887 795
888 - if (is_array($kt))  
889 - {  
890 - $this->response= $kt;  
891 - } 796 + function search($arr){
  797 + $kt=&$this->KT;
892 798
893 - $listing = processSearchExpression("(GeneralText contains \"".$arr['query']."\")"); 799 + $listing=processSearchExpression("(GeneralText contains \"".$arr['query']."\")");
894 800
895 - $result = ListController::_processListing($listing, 'search', $arr); 801 + $result=ListController::_processListing($listing, 'search', $arr);
896 802
897 if(!count($result)) { 803 if(!count($result)) {
898 -  
899 - $result[] = array  
900 - (  
901 - 'text' => $this->xlate("No results found"),  
902 - 'id' => ($listing[$i]['item_type'] == 'F' ? $listing[$i]['item_type']."_" : "").$listing[$i]['id'],  
903 - 'leaf' => true,  
904 - 'relevance' => 0, 804 + $result[]=array(
  805 + 'text'=>$this->xlate("No results found"),
  806 + 'id'=>($listing[$i]['item_type']=='F' ? $listing[$i]['item_type']."_" : "").$listing[$i]['id'],
  807 + 'leaf'=>true,
  808 + 'relevance'=>0,
905 'qtip'=> $this->xlate("Please retry your search") 809 'qtip'=> $this->xlate("Please retry your search")
906 ); 810 );
907 - } else {  
908 - $result = array_slice($result, 0, 200); 811 + }else{
  812 + $result=array_slice($result, 0, 200);
909 } 813 }
910 814
911 - $this->response= $result; 815 + $this->setResponse($result);
  816 + return true;
912 } 817 }
913 818
914 - public function update_metadata($arr)  
915 - {  
916 - $session_id = $arr['session_id'];  
917 - $metadata = array();  
918 - $packed = @json_decode($arr['metadata']);  
919 819
920 - $this->debug('Entered add_document_with_metadata'); 820 + public function update_metadata($arr){
  821 + $metadata=array();
  822 + $packed=@json_decode($arr['metadata']);
921 823
922 - $special = array(); 824 + $this->addDebug('','Entered add_document_with_metadata');
923 825
924 - foreach($packed as $key => $val) {  
925 - if(substr($val->name,0,2) != '__') { 826 + $special=array();
926 827
  828 + foreach($packed as $key=>$val) {
  829 + if(substr($val->name,0,2) != '__') {
927 if(!is_array($metadata[$val->fieldset])) { 830 if(!is_array($metadata[$val->fieldset])) {
928 - $metadata[$val->fieldset]['fieldset'] = $val->fieldset;  
929 - $metadata[$val->fieldset]['fields'] = array(); 831 + $metadata[$val->fieldset]['fieldset']=$val->fieldset;
  832 + $metadata[$val->fieldset]['fields']=array();
930 } 833 }
931 - $metadata[$val->fieldset]['fields'][] = array(  
932 - 'name' => $val->name,  
933 - 'value' => $val->value 834 + $metadata[$val->fieldset]['fields'][]=array(
  835 + 'name'=>$val->name,
  836 + 'value'=>$val->value
934 ); 837 );
935 - } else {  
936 - $special[$val->name] = $val->value; 838 + }else{
  839 + $special[$val->name]=$val->value;
937 } 840 }
938 } 841 }
939 842
940 - $document_id = $arr['document_id']; 843 + $document_id=$arr['document_id'];
941 844
942 - $update_result = $this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());  
943 - $this->debug('$this->response= from update_document_metadata');  
944 - $status_code = $update_result['status_code'];  
945 - if ($status_code != 0)  
946 - {  
947 - $this->response= $update_result; 845 + $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
  846 + $this->addDebug('','$this->response= from update_document_metadata');
  847 +
  848 + $status_code=$update_result['status_code'];
  849 + if ($status_code != 0){
  850 + $this->setResponse($update_result);
948 } 851 }
949 852
950 - $kt = &$this->get$this->xlateapi($arr['session_id']);  
951 - if (is_array($kt))  
952 - {  
953 - $this->response= $kt;  
954 - } 853 + $kt=&$this->KT;
955 854
956 if(!empty($special)) { 855 if(!empty($special)) {
957 -  
958 if($document_id > 0) { 856 if($document_id > 0) {
959 - $document = $kt->get_document_by_id($document_id); 857 + $document=$kt->get_document_by_id($document_id);
960 858
961 if(isset($special['__title'])) { 859 if(isset($special['__title'])) {
962 $this->debug("Renaming to {$special['__title']}"); 860 $this->debug("Renaming to {$special['__title']}");
963 - $res = $document->rename($special['__title']); 861 + $res=$document->rename($special['__title']);
964 } 862 }
965 } 863 }
966 } 864 }
967 865
968 - $this->response= array('status_code' => 0, 'document_id' => $document_id); 866 + $this->setResponse(array('status_code'=>0, 'document_id'=>$document_id));
969 } 867 }
970 868
971 - function check_document_title($arr)  
972 - {  
973 -  
974 - $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application'] );  
975 -  
976 869
977 - if (is_array($kt))  
978 - {  
979 - $this->response= array('status_code' => 1);  
980 - }  
981 870
982 - $folder = $kt->get_folder_by_id($arr['folder_id']); 871 + function check_document_title($arr){
  872 + $kt=&$this->KT;
983 873
  874 + $folder=$kt->get_folder_by_id($arr['folder_id']);
984 if(PEAR::isError($folder)) { 875 if(PEAR::isError($folder)) {
985 - $this->response= array('status_code' => 1, 'reason' => 'No such folder'); 876 + $this->setResponse(array('status_code'=>1, 'reason'=>'No such folder'));
  877 + return false;
986 } 878 }
987 879
988 - $doc = $folder->get_document_by_name($arr['title']);  
989 - 880 + $doc=$folder->get_document_by_name($arr['title']);
990 if(PEAR::isError($doc)) { 881 if(PEAR::isError($doc)) {
991 - $this->response= array('status_code' => 1, 'reason' => 'No document with that title '.$arr['title']); 882 + $this->setResponse(array('status_code'=>1, 'reason'=>'No document with that title '.$arr['title']));
  883 + return false;
992 } 884 }
993 885
994 - $this->response= array('status_code' => 0); 886 + $this->setResponse(array('status_code'=>0));
  887 + return true;
995 } 888 }
996 889
997 890
998 - //$session_id, $document_id, $reason  
999 - function cancel_checkout($params)  
1000 - {  
1001 - //$this->debug("undo_document_checkout({$params['session_id']}, {$params['document_id']}, {$params['reason']})");  
1002 -  
1003 - $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );  
1004 - if (is_array($kt))  
1005 - {  
1006 - $this->response= array('status_code' => 1);  
1007 - } 891 + function cancel_checkout($params){
  892 + $kt=&$this->KT;
1008 893
1009 - $document = &$kt->get_document_by_id($params['document_id']);  
1010 - if (PEAR::isError($document))  
1011 - {  
1012 - $this->response= array('status_code' => 1, 'message' => $document->getMessage()); 894 + $document=&$kt->get_document_by_id($params['document_id']);
  895 + if (PEAR::isError($document)){
  896 + $this->setResponse(array('status_code'=>1, 'message'=>$document->getMessage()));
  897 + return false;
1013 } 898 }
1014 899
1015 - $result = $document->undo_checkout($params['reason']);  
1016 - if (PEAR::isError($result))  
1017 - {  
1018 - $this->response= array('status_code' => 1, 'message' => $result->getMessage()); 900 + $result=$document->undo_checkout($params['reason']);
  901 + if (PEAR::isError($result)){
  902 + $this->setResponse(array('status_code'=>1, 'message'=>$result->getMessage()));
  903 + return false;
1019 } 904 }
1020 -  
1021 - $response['status_code'] = 0;  
1022 -  
1023 - $this->response= $response; 905 + $response['status_code']=0;
  906 + $this->setResponse($response);
1024 } 907 }
1025 908
1026 - function get_users_groups($params)  
1027 - {  
1028 - $kt = &$this->get$this->xlateapi($params['session_id'],$params['application'] );  
1029 - if (is_array($kt))  
1030 - {  
1031 - $this->response= array('status_code' => 1);  
1032 - }  
1033 -  
1034 - $query = $params['query'];  
1035 - //$start = $params['start'];  
1036 - //$page = $params['page'];  
1037 909
1038 - $results = KTAPI_User::getList('name LIKE "%'.$query.'%" AND id>0');  
1039 -  
1040 - $$this->response=Array = array();  
1041 -  
1042 - if (count($results) > 0) {  
1043 - foreach ($results as $user)  
1044 - {  
1045 - $$this->response=Array[] = array('emailid'=>'u_'.$user->getId(), 'name'=> $user->getName(), 'to'=>preg_replace('/('.$query.')/i', '<b>${0}</b>', $user->getName())); 910 + public function get_users_groups($params){
  911 + $kt=&$this->KT;
  912 + $query=$params['query'];
  913 + //$start=$params['start'];
  914 + //$page=$params['page'];
  915 +
  916 + $results=KTAPI_User::getList('name LIKE "%'.$query.'%" AND id>0');
  917 + $returnArray=array();
  918 + if (count($results) > 0){
  919 + foreach ($results as $user){
  920 + $returnArray[]=array('emailid'=>'u_'.$user->getId(), 'name'=> $user->getName(), 'to'=>preg_replace('/('.$query.')/i', '<b>${0}</b>', $user->getName()));
1046 } 921 }
1047 } 922 }
1048 -  
1049 - $groups = KTAPI_Group::getList('name LIKE "%'.$query.'%"');  
1050 -  
1051 - if (count($groups) > 0) {  
1052 - foreach ($groups as $group)  
1053 - {  
1054 - $$this->response=Array[] = array('emailid'=>'g_'.$group->getId(), 'name'=> $group->getName(), 'to'=>preg_replace('/('.$query.')/i', '<b>${0}</b>', $group->getName())); 923 +
  924 + $groups=KTAPI_Group::getList('name LIKE "%'.$query.'%"');
  925 + if (count($groups) > 0){
  926 + foreach ($groups as $group){
  927 + $returnArray[]=array('emailid'=>'g_'.$group->getId(), 'name'=> $group->getName(), 'to'=>preg_replace('/('.$query.')/i', '<b>${0}</b>', $group->getName()));
1055 } 928 }
1056 } 929 }
1057 -  
1058 -  
1059 - $sendArray = array ('emails'=>$$this->response=Array, 'metaData'=>array('count'=>count($finalArray), 'root'=>'emails', fields=>array('name', 'to', 'emailid')));  
1060 -  
1061 - $this->response= $sendArray;  
1062 -  
1063 -  
1064 - 930 +
  931 + $sendArray=array ('emails'=>$returnArray, 'metaData'=>array('count'=>count($finalArray), 'root'=>'emails', fields=>array('name', 'to', 'emailid')));
  932 + $this->setResponse($sendArray);
  933 + return true;
1065 } 934 }
1066 -  
1067 - function send_email($params)  
1068 - {  
1069 - $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );  
1070 - if (is_array($kt))  
1071 - {  
1072 - $this->response= array('status_code' => 1);  
1073 - }  
1074 -  
1075 -  
1076 - $message = $params['message'];  
1077 - $list = $params['users'];  
1078 -  
1079 -  
1080 - $recipientsList = array();  
1081 -  
1082 - $list = explode(',', $list);  
1083 -  
1084 - foreach ($list as $recipient)  
1085 - {  
1086 - if (trim($recipient) != '') { // check that value is present  
1087 - 935 +
  936 +
  937 + function send_email($params){
  938 + $kt=&$this->KT;
  939 +
  940 + $message=$params['message'];
  941 + $list=$params['users'];
  942 + $list=explode(',', $list);
  943 +
  944 + $recipientsList=array();
  945 +
  946 + foreach ($list as $recipient){
  947 + if (trim($recipient) != ''){ // check that value is present
1088 // if @ sign is present, signifies email address 948 // if @ sign is present, signifies email address
1089 - if(strpos($recipient, '@') === false) {  
1090 - // Not email  
1091 - $recipient = trim($recipient);  
1092 -  
1093 - switch (substr($recipient, 0, 2))  
1094 - { 949 + if(strpos($recipient, '@') === false) {
  950 + $recipient=trim($recipient);
  951 + switch (substr($recipient, 0, 2)){
1095 case 'u_': 952 case 'u_':
1096 - $id = substr($recipient, 2);  
1097 - $user = KTAPI_User::getById($id);  
1098 -  
1099 - if ($user != null) {  
1100 - $recipientsList[] = $user; 953 + $id=substr($recipient, 2);
  954 + $user=KTAPI_User::getById($id);
  955 + if ($user != null){
  956 + $recipientsList[]=$user;
1101 } 957 }
1102 -  
1103 break; 958 break;
1104 case 'g_': 959 case 'g_':
1105 - $id = substr($recipient, 2);  
1106 - $group = KTAPI_Group::getById($id);  
1107 - 960 + $id=substr($recipient, 2);
  961 + $group=KTAPI_Group::getById($id);
1108 if ($group != null) { 962 if ($group != null) {
1109 - $recipientsList[] = $group; 963 + $recipientsList[]=$group;
1110 } 964 }
1111 break; 965 break;
1112 } 966 }
1113 -  
1114 - } else { // Email - just add to list  
1115 - $recipientsList[] = trim($recipient); 967 + }else{ // Email - just add to list
  968 + $recipientsList[]=trim($recipient);
1116 } 969 }
1117 } 970 }
1118 } 971 }
1119 -  
1120 - $document = $kt->get_document_by_id($params['document']);  
1121 -  
1122 -  
1123 - if (count($recipientsList) == 0) {  
1124 - $this->response= array('status'=>'norecipients');  
1125 - } else { 972 +
  973 + $document=$kt->get_document_by_id($params['document']);
  974 + if (count($recipientsList)==0) {
  975 + $this->setResponse(array('status'=>'norecipients'));
  976 + return false;
  977 + }else{
1126 $document->email($recipientsList, $message, TRUE); // true to attach document 978 $document->email($recipientsList, $message, TRUE); // true to attach document
1127 - $this->response= array('status'=>'documentemailed'); 979 + $this->setResponse(array('status'=>'documentemailed'));
1128 } 980 }
1129 -  
1130 - 981 + return true;
1131 } 982 }
1132 983
1133 984
1134 - function is_latest_version($params)  
1135 - { 985 + function is_latest_version($params){
1136 $kt=&$this->KT; 986 $kt=&$this->KT;
1137 -  
1138 -  
1139 - if (is_array($kt))  
1140 - {  
1141 - $this->response= $kt;  
1142 - }  
1143 -  
1144 - $documentId = $params['document_id'];  
1145 - $contentId = $params['content_id'];  
1146 -  
1147 - $result = $kt->is_latest_version($documentId, $contentId);  
1148 -  
1149 - $this->response= $result;  
1150 - 987 +
  988 + $documentId=$params['document_id'];
  989 + $contentId=$params['content_id'];
  990 +
  991 + $result=$kt->is_latest_version($documentId, $contentId);
  992 +
  993 + $this->setResponse($result);
  994 + return true;
1151 } 995 }
1152 -  
1153 - function check_permission($params)  
1154 - { 996 +
  997 + function check_permission($params){
1155 $kt=&$this->KT; 998 $kt=&$this->KT;
1156 -  
1157 -  
1158 - if (is_array($kt))  
1159 - {  
1160 - $this->response= $kt;  
1161 - }  
1162 -  
1163 - $user = $kt->get_user();  
1164 -  
1165 - $document = $kt->get_document_by_id($params['document_id']);  
1166 -  
1167 - $folder = &$kt->get_folder_by_id($document->ktapi_folder->folderid);  
1168 -  
1169 - $folderDetail = $folder->get_detail();  
1170 -  
1171 - $permissions = $folderDetail['permissions'];  
1172 -  
1173 - if ($user->getId() == $document->document->getCheckedOutUserID()) { 999 +
  1000 + $user=$kt->get_user();
  1001 + $document=$kt->get_document_by_id($params['document_id']);
  1002 + $folder=&$kt->get_folder_by_id($document->ktapi_folder->folderid);
  1003 + $folderDetail=$folder->get_detail();
  1004 + $permissions=$folderDetail['permissions'];
  1005 + if ($user->getId()==$document->document->getCheckedOutUserID()){
1174 $permissions .= 'E'; 1006 $permissions .= 'E';
1175 } 1007 }
1176 -  
1177 - $this->response= array('status_code'=>0, 'permissions'=>$permissions);  
1178 - //$this->response= $permissions; 1008 +
  1009 + $this->setResponse(array('status_code'=>0, 'permissions'=>$permissions));
  1010 + return true;
1179 } 1011 }
1180 1012
  1013 + function copydocument($params){
  1014 + $kt=&$this->KT;
1181 1015
1182 - function renamefolder($params)  
1183 - {  
1184 - $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );  
1185 - if (is_array($kt))  
1186 - {  
1187 - $this->response= array('status_code' => 1);  
1188 - }  
1189 -  
1190 - $response = $kt->rename_folder($params['currentfolderid'], $params['newname']);  
1191 -  
1192 - if ($response['status_code'] == 0) {  
1193 - $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Renamed'), 'message'=>$this->xlate('Folder has been successfully renamed'));  
1194 - } else {  
1195 - $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'] 1016 + $response=$kt->copy_document($params['documentid'], $params['destfolderid']);
  1017 + if ($response['status_code']==0) {
  1018 + $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Document Copied'), 'message'=>$this->xlate('Document has been successfully copied')));
  1019 + return true;
  1020 + }else{
  1021 + $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to copy document'), 'message'=>$this->xlate('Unable to copy document')));
  1022 + return false;
1196 } 1023 }
1197 -  
1198 } 1024 }
1199 1025
1200 - function addfolder($params)  
1201 - {  
1202 - $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );  
1203 - if (is_array($kt))  
1204 - {  
1205 - $this->response= array('status_code' => 1);  
1206 - }  
1207 -  
1208 -  
1209 - $response = $kt->create_folder($params['currentfolderid'], $params['newname']); 1026 + function movedocument($params){
  1027 + $kt=$this->KT;
1210 1028
1211 - if ($response['status_code'] == 0) {  
1212 - $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']);//  
1213 - } else {  
1214 - $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'] 1029 + $response=$kt->move_document($params['documentid'], $params['destfolderid']);
  1030 + if ($response['status_code']==0) {
  1031 + $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Document Moved'), 'message'=>$this->xlate('Document has been successfully moved')));
  1032 + return true;
  1033 + }else{
  1034 + $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to move document'), 'message'=>$this->xlate('Unable to move document')));
  1035 + return false;
1215 } 1036 }
1216 - 1037 +
1217 } 1038 }
1218 -  
1219 - function deletefolder($params)  
1220 - {  
1221 - $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] );  
1222 - if (is_array($kt))  
1223 - {  
1224 - $this->response= array('status_code' => 1); 1039 +
  1040 + function copyfolder($params){
  1041 + $kt=&$this->KT;
  1042 +
  1043 + $response=$kt->copy_folder($params['sourcefolderid'], $params['destfolderid']);
  1044 + if ($response['status_code']==0) {
  1045 + $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Copied'), 'message'=>$this->xlate('Folder has been successfully copied')));
  1046 + return true;
  1047 + }else{
  1048 + $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to copy folder'), 'message'=>$this->xlate('Unable to copy folder')));
  1049 + return false;
1225 } 1050 }
  1051 +
  1052 + }
1226 1053
1227 - $response = $kt->delete_folder($params['folderid'], 'Deleted from office addin'); 1054 + function movefolder($params){
  1055 + $kt=&$this->KT;
1228 1056
1229 - if ($response['status_code'] == 0) {  
1230 - $this->response= array('status_code' => 0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>$this->xlate('Folder Deleted'), 'message'=>$this->xlate('Folder has been successfully deleted'));  
1231 - } else {  
1232 - $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'] 1057 + $response=$kt->move_folder($params['sourcefolderid'], $params['destfolderid']);
  1058 + if ($response['status_code']==0) {
  1059 + $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Moved'), 'message'=>$this->xlate('Folder has been successfully moved')));
  1060 + return true;
  1061 + }else{
  1062 + $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to move folder'), 'message'=>$this->xlate('Unable to move folder')));
  1063 + return false;
1233 } 1064 }
1234 -  
1235 } 1065 }
1236 1066
1237 - function candeletefolder($arr)  
1238 - {  
1239 - $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application']);  
1240 -  
1241 - if (is_array($kt))  
1242 - {  
1243 - $this->response= $kt; 1067 +
  1068 + function renamefolder($params){
  1069 + $kt=&$this->KT;
  1070 +
  1071 + $response=$kt->rename_folder($params['currentfolderid'], $params['newname']);
  1072 + if ($response['status_code']==0) {
  1073 + $this->setResponse(array('status_code'=>0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Renamed'), 'message'=>$this->xlate('Folder has been successfully renamed')));
  1074 + return true;
  1075 + }else{
  1076 + $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to rename folder'), 'message'=>$this->xlate('Unable to rename folder')));
  1077 + return false;
1244 } 1078 }
  1079 + }
1245 1080
1246 -  
1247 - $folder = &$kt->get_folder_by_id($arr['folderid']);  
1248 - if (PEAR::isError($folder))  
1249 - {  
1250 - $response = 'error';  
1251 -  
1252 - $this->response= 'error 1'; 1081 + function addfolder($params) {
  1082 + $kt=&$this->KT;
  1083 + $this->addDebug('parameters',$params);
  1084 + $response=$kt->create_folder($params['currentfolderid'], $params['newname']);
  1085 + $this->setResponse($response);
  1086 + return true;
  1087 + }
  1088 +
  1089 + function deletefolder($params){
  1090 + $kt=&$this->KT;
  1091 +
  1092 + $response=$kt->delete_folder($params['folderid'], 'Deleted from office addin');
  1093 + if ($response['status_code']==0) {
  1094 + $this->setResponse(array('status_code'=>0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>$this->xlate('Folder Deleted'), 'message'=>$this->xlate('Folder has been successfully deleted')));
  1095 + return true;
  1096 + }else{
  1097 + $this->setResponse(array('status_code'=>1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to delete folder'), 'message'=>$this->xlate('Unable to delete folder')));
  1098 + return false;
1253 } 1099 }
1254 -  
1255 -  
1256 - $listing = $folder->get_listing(1, 'DF');  
1257 -  
1258 - if (count($listing) == 0) {  
1259 - $this->response= array('status_code' => 0, 'candelete'=>TRUE);  
1260 - } else {  
1261 - $this->response= array('status_code' => 0, 'candelete'=>FALSE); 1100 + }
  1101 +
  1102 + function candeletefolder($arr){
  1103 + $kt=&$this->KT;
  1104 +
  1105 + $folder=&$kt->get_folder_by_id($arr['folderid']);
  1106 + if (PEAR::isError($folder)){
  1107 + $this->setResponse('error 1');
  1108 + return false;
  1109 + }
  1110 +
  1111 + $listing=$folder->get_listing(1, 'DF');
  1112 + if (count($listing)==0) {
  1113 + $this->setResponse(array('status_code'=>0, 'candelete'=>TRUE));
  1114 + return true;
  1115 + }else{
  1116 + $this->setResponse(array('status_code'=>0, 'candelete'=>FALSE));
  1117 + return true;
1262 } 1118 }
1263 } 1119 }
1264 -  
1265 -*/ 1120 +}
1266 ?> 1121 ?>
1267 \ No newline at end of file 1122 \ No newline at end of file
webservice/clienttools/services/3.6.1/server.php
1 <?php 1 <?php
2 class server extends client_service { 2 class server extends client_service {
3 public function status(){ 3 public function status(){
4 - 4 + $this->setResponse(array('online'=>true));
5 } 5 }
6 6
7 public function ping(){ 7 public function ping(){