Commit 4b8cd0112a919fae87a5af45cc50a731c5399c60
Merge branch 'edge' of github.com:ktgit/knowledgetree into edge
Showing
35 changed files
with
1371 additions
and
951 deletions
.gitignore
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 | 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 | 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 | 69 | \ No newline at end of file | ... | ... |
ktwebservice/KTDownloadManager.inc.php
| ... | ... | @@ -60,10 +60,8 @@ class KTDownloadManager |
| 60 | 60 | $this->age = $config->get('webservice/downloadExpiry',5); |
| 61 | 61 | |
| 62 | 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 | 65 | $this->random=$config->get('webservice/randomKeyText','jhsdf8q1jkjpoiudfs7sd3ds1'); |
| 68 | 66 | } |
| 69 | 67 | ... | ... |
ktwebservice/KTUploadManager.inc.php
| ... | ... | @@ -110,7 +110,6 @@ class KTUploadManager |
| 110 | 110 | return ($tempdir == $this->temp_dir); |
| 111 | 111 | */ |
| 112 | 112 | } |
| 113 | - | |
| 114 | 113 | function store_base64_file($base64, $prefix= 'sa_') |
| 115 | 114 | { |
| 116 | 115 | $tempfilename = $this->get_temp_filename($prefix); |
| ... | ... | @@ -134,36 +133,6 @@ class KTUploadManager |
| 134 | 133 | |
| 135 | 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 | 138 | * This tells the manager to manage a file that has been uploaded. | ... | ... |
ktwebservice/download.php
| ... | ... | @@ -77,7 +77,7 @@ $response = $download_manager->download($document_id, $hash, null, $apptype); |
| 77 | 77 | if (PEAR::isError($response)) |
| 78 | 78 | { |
| 79 | 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 | 81 | exit; |
| 82 | 82 | } |
| 83 | 83 | ... | ... |
ktwebservice/upload.php
| ... | ... | @@ -117,6 +117,7 @@ foreach($_FILES as $key =>$file) |
| 117 | 117 | $tempfile=$file['tmp_name']; |
| 118 | 118 | |
| 119 | 119 | $error=$file['error']; |
| 120 | + $extra = $filename.'-'.$tempfile.'-'.$error; | |
| 120 | 121 | if ($error == UPLOAD_ERR_OK) |
| 121 | 122 | { |
| 122 | 123 | $result = $upload_manager->uploaded($filename, $tempfile, $action); |
| ... | ... | @@ -145,7 +146,7 @@ if ($failed) |
| 145 | 146 | } |
| 146 | 147 | else |
| 147 | 148 | { |
| 148 | - respond(0, '', $added); | |
| 149 | + respond(0, 'It worked'.$extra, $added); | |
| 149 | 150 | } |
| 150 | 151 | |
| 151 | 152 | function respond($code, $msg, $uploads=array()) | ... | ... |
setup/wizard/installUtil.php
| ... | ... | @@ -280,6 +280,7 @@ class InstallUtil { |
| 280 | 280 | |
| 281 | 281 | if(is_writable($dir)){ |
| 282 | 282 | $ret['class'] = 'tick'; |
| 283 | + | |
| 283 | 284 | return $ret; |
| 284 | 285 | } |
| 285 | 286 | |
| ... | ... | @@ -357,6 +358,14 @@ class InstallUtil { |
| 357 | 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 | 369 | public function javaBridge() { |
| 361 | 370 | try { |
| 362 | 371 | $javaSystem = new Java('java.lang.System'); |
| ... | ... | @@ -365,8 +374,16 @@ class InstallUtil { |
| 365 | 374 | } |
| 366 | 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 | 387 | $response = $this->pexec("java -version"); // Java Runtime Check |
| 371 | 388 | if(empty($response['out'])) { |
| 372 | 389 | return false; |
| ... | ... | @@ -375,7 +392,15 @@ class InstallUtil { |
| 375 | 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 | 404 | $response = $this->pexec("java"); // Java Runtime Check |
| 380 | 405 | if(empty($response['out'])) { |
| 381 | 406 | return false; |
| ... | ... | @@ -384,7 +409,15 @@ class InstallUtil { |
| 384 | 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 | 421 | $response = $this->pexec("whereis java"); // Java Runtime Check |
| 389 | 422 | if(empty($response['out'])) { |
| 390 | 423 | return false; |
| ... | ... | @@ -454,7 +487,7 @@ class InstallUtil { |
| 454 | 487 | $response = $this->tryJava3(); |
| 455 | 488 | } |
| 456 | 489 | } |
| 457 | - | |
| 490 | +// return false; | |
| 458 | 491 | return $response; |
| 459 | 492 | } |
| 460 | 493 | |
| ... | ... | @@ -468,7 +501,16 @@ class InstallUtil { |
| 468 | 501 | */ |
| 469 | 502 | function getPhp() { |
| 470 | 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 | 514 | if(is_array($response['out'])) { |
| 473 | 515 | if (isset($response['out'][0])) { |
| 474 | 516 | $broke = explode(' ', $response['out'][0]); |
| ... | ... | @@ -481,7 +523,7 @@ class InstallUtil { |
| 481 | 523 | } |
| 482 | 524 | } |
| 483 | 525 | |
| 484 | - return ''; | |
| 526 | + return ''; | |
| 485 | 527 | } |
| 486 | 528 | |
| 487 | 529 | function getOpenOffice() { | ... | ... |
setup/wizard/lib/services/unixLucene.php
| ... | ... | @@ -180,6 +180,7 @@ class unixLucene extends unixService { |
| 180 | 180 | |
| 181 | 181 | public function start() { |
| 182 | 182 | $state = $this->status(); |
| 183 | + return ; | |
| 183 | 184 | if($state != 'STARTED') { |
| 184 | 185 | $cmd = "cd ".$this->getLuceneDir()."; "; |
| 185 | 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 | 125 | |
| 126 | 126 | public function start() { |
| 127 | 127 | $state = $this->status(); |
| 128 | + return ; | |
| 128 | 129 | if($state != 'STARTED') { |
| 129 | 130 | $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; |
| 130 | 131 | $response = $this->util->pexec($cmd); | ... | ... |
setup/wizard/lib/services/unixScheduler.php
| ... | ... | @@ -150,6 +150,7 @@ class unixScheduler extends unixService { |
| 150 | 150 | function start() { |
| 151 | 151 | // TODO : Write sh on the fly? Not sure the reasoning here |
| 152 | 152 | $source = $this->getSchedulerSourceLoc(); |
| 153 | + return ; | |
| 153 | 154 | if($source) { // Source |
| 154 | 155 | $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; |
| 155 | 156 | $response = $this->util->pexec($cmd); | ... | ... |
setup/wizard/output/outJV deleted
setup/wizard/resources/wizard.css
| ... | ... | @@ -299,6 +299,11 @@ select { |
| 299 | 299 | margin-top:10px; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | +.textinput { | |
| 303 | + margin-top:0px; | |
| 304 | + float:left; | |
| 305 | +} | |
| 306 | + | |
| 302 | 307 | .step input { |
| 303 | 308 | background-image: url("graphics/dame/kt_gradient.jpg"); |
| 304 | 309 | background-repeat:repeat-x; |
| ... | ... | @@ -326,11 +331,6 @@ select { |
| 326 | 331 | margin-top:10px; |
| 327 | 332 | } |
| 328 | 333 | |
| 329 | -.textinput { | |
| 330 | - margin-top:0px; | |
| 331 | - float:left; | |
| 332 | -} | |
| 333 | - | |
| 334 | 334 | .buttons a { |
| 335 | 335 | background: #DDDDDD; |
| 336 | 336 | border: solid 1px #888; |
| ... | ... | @@ -528,4 +528,12 @@ td.dir_description { |
| 528 | 528 | .description_click { |
| 529 | 529 | line-height:150%; |
| 530 | 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 | 540 | \ No newline at end of file | ... | ... |
setup/wizard/resources/wizard.js
| ... | ... | @@ -5,18 +5,20 @@ function wizard() { |
| 5 | 5 | // Does a form check on every new page load |
| 6 | 6 | wizard.prototype.doFormCheck = function() { |
| 7 | 7 | w.addReadOnly(); |
| 8 | - w.load(); | |
| 8 | + w.preload(); | |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 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 | 14 | if(el[0].style.display == 'none') { |
| 15 | 15 | el[0].style.display = 'block'; |
| 16 | - document.getElementById(option).innerHTML = "Hide Details"; | |
| 16 | + if(document.getElementById(option).innerHTML != ' Advanced Options') | |
| 17 | + document.getElementById(option).innerHTML = "Hide Details"; | |
| 17 | 18 | } else { |
| 18 | 19 | el[0].style.display = 'none'; |
| 19 | - document.getElementById(option).innerHTML = "Show Details"; | |
| 20 | + if(document.getElementById(option).innerHTML != ' 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 | 53 | j = p-1; |
| 52 | 54 | } |
| 53 | 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 | 59 | return true; |
| 57 | 60 | } |
| 58 | 61 | |
| ... | ... | @@ -170,17 +173,26 @@ wizard.prototype.valRegHelper = function() { |
| 170 | 173 | var first = document.getElementById('first'); |
| 171 | 174 | var last = document.getElementById('last'); |
| 172 | 175 | var email = document.getElementById('email'); |
| 173 | - | |
| 174 | - if(first.value.length < 2) { | |
| 176 | + if(first.value.length < 1) { | |
| 175 | 177 | document.getElementById("reg_error").innerHTML = "Please enter a First Name"; |
| 176 | 178 | w.focusElement(first); |
| 177 | 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 | 187 | document.getElementById("reg_error").innerHTML = "Please enter a Last Name"; |
| 181 | 188 | w.focusElement(last); |
| 182 | 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 | 196 | if(!w.emailCheck(email.value)) { |
| 185 | 197 | document.getElementById("reg_error").innerHTML = "Please enter a valid email address"; |
| 186 | 198 | w.focusElement(email); |
| ... | ... | @@ -190,8 +202,18 @@ wizard.prototype.valRegHelper = function() { |
| 190 | 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 | 214 | // Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) |
| 194 | 215 | wizard.prototype.emailCheck = function(str) { |
| 216 | + str = w.trim(str); | |
| 195 | 217 | var at="@"; |
| 196 | 218 | var dot="."; |
| 197 | 219 | var lat=str.indexOf(at); |
| ... | ... | @@ -221,6 +243,20 @@ wizard.prototype.emailCheck = function(str) { |
| 221 | 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 | 260 | // Disable DnD on element |
| 225 | 261 | // Element has to have a readOnly status set to readonly |
| 226 | 262 | wizard.prototype.disableDnd = function(el_id) { |
| ... | ... | @@ -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 | 283 | // $('#tooltips').tooltip(); |
| 248 | 284 | } |
| 249 | 285 | \ No newline at end of file | ... | ... |
setup/wizard/step.php
setup/wizard/steps/configuration.php
| ... | ... | @@ -47,17 +47,73 @@ class configuration extends Step |
| 47 | 47 | * |
| 48 | 48 | * @author KnowledgeTree Team |
| 49 | 49 | * @access private |
| 50 | - * @var array | |
| 51 | - */ | |
| 50 | + * @var object | |
| 51 | + */ | |
| 52 | 52 | private $_dbhandler = null; |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Database host | |
| 56 | + * | |
| 57 | + * @author KnowledgeTree Team | |
| 58 | + * @access private | |
| 59 | + * @var string | |
| 60 | + */ | |
| 53 | 61 | private $host; |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Database port | |
| 65 | + * | |
| 66 | + * @author KnowledgeTree Team | |
| 67 | + * @access private | |
| 68 | + * @var string | |
| 69 | + */ | |
| 54 | 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 | 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 | 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 | 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 | 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 | 115 | public $displayFirst = true; |
| 116 | + | |
| 61 | 117 | /** |
| 62 | 118 | * Flag to store class information in session |
| 63 | 119 | * |
| ... | ... | @@ -66,6 +122,7 @@ class configuration extends Step |
| 66 | 122 | * @var array |
| 67 | 123 | */ |
| 68 | 124 | protected $storeInSession = true; |
| 125 | + | |
| 69 | 126 | /** |
| 70 | 127 | * Flag if step needs to be installed |
| 71 | 128 | * |
| ... | ... | @@ -84,7 +141,26 @@ class configuration extends Step |
| 84 | 141 | */ |
| 85 | 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 | 162 | protected $util = null; |
| 163 | + | |
| 88 | 164 | /** |
| 89 | 165 | * Class constructor |
| 90 | 166 | * |
| ... | ... | @@ -99,21 +175,6 @@ class configuration extends Step |
| 99 | 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 | 179 | * Control function for position within the step |
| 119 | 180 | * |
| ... | ... | @@ -123,6 +184,7 @@ class configuration extends Step |
| 123 | 184 | */ |
| 124 | 185 | public function doStep() { |
| 125 | 186 | if(!$this->inStep("configuration")) { |
| 187 | + $this->setDetails(); | |
| 126 | 188 | $this->doRun(); |
| 127 | 189 | return 'landing'; |
| 128 | 190 | } |
| ... | ... | @@ -133,26 +195,51 @@ class configuration extends Step |
| 133 | 195 | } |
| 134 | 196 | return 'error'; |
| 135 | 197 | } else if($this->previous()) { |
| 136 | -// $this->setDetails(); | |
| 137 | 198 | return 'previous'; |
| 138 | 199 | } else if($this->confirm()) { |
| 200 | + $this->setDetails(); | |
| 139 | 201 | if($this->doRun()) { |
| 140 | 202 | return 'next'; |
| 141 | 203 | } |
| 142 | 204 | return 'error'; |
| 143 | 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 | 214 | $this->doRun(); |
| 153 | 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 | 243 | public function loadTemplateDefaults() { |
| 157 | 244 | $this->temp_variables['paths_perms'] = 'tick'; |
| 158 | 245 | } |
| ... | ... | @@ -164,13 +251,13 @@ class configuration extends Step |
| 164 | 251 | * @access public |
| 165 | 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 | 256 | $server = $this->getServerInfo(); |
| 170 | - $this->temp_variables['server'] = $server; | |
| 257 | + if(!$edit) $this->temp_variables['server'] = $server; | |
| 171 | 258 | |
| 172 | 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 | 262 | // Running user |
| 176 | 263 | // Logging |
| ... | ... | @@ -338,7 +425,11 @@ class configuration extends Step |
| 338 | 425 | */ |
| 339 | 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 | 433 | $varDirectory = $fileSystemRoot . DS . 'var'; |
| 343 | 434 | foreach ($dirs as $key => $dir){ |
| 344 | 435 | $path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path']; |
| ... | ... | @@ -348,14 +439,16 @@ class configuration extends Step |
| 348 | 439 | } |
| 349 | 440 | if(WINDOWS_OS) |
| 350 | 441 | $path = preg_replace('/\//', '\\',$path); |
| 351 | - | |
| 352 | 442 | $dirs[$key]['path'] = $path; |
| 353 | 443 | $class = $this->util->checkPermission($path, $dir['create']); |
| 354 | - | |
| 355 | 444 | if($class['class'] != 'tick') { |
| 356 | 445 | $this->temp_variables['paths_perms'] = $class['class']; |
| 357 | 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 | 453 | $dirs[$key] = array_merge($dirs[$key], $class); |
| 361 | 454 | } |
| ... | ... | @@ -381,8 +474,24 @@ class configuration extends Step |
| 381 | 474 | array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true), |
| 382 | 475 | array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true), |
| 383 | 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 | 498 | \ No newline at end of file | ... | ... |
setup/wizard/steps/database.php
| ... | ... | @@ -196,15 +196,6 @@ class database extends Step |
| 196 | 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 | 199 | * List of errors encountered |
| 209 | 200 | * |
| 210 | 201 | * @author KnowledgeTree Team |
| ... | ... | @@ -315,6 +306,8 @@ class database extends Step |
| 315 | 306 | return 'next'; |
| 316 | 307 | } else if($this->edit()) { |
| 317 | 308 | $this->setDataFromSession("database"); // Set Session Information, since its an edit |
| 309 | + $this->temp_variables['state'] = 'edit'; | |
| 310 | + | |
| 318 | 311 | return 'landing'; |
| 319 | 312 | } |
| 320 | 313 | } |
| ... | ... | @@ -469,6 +462,11 @@ class database extends Step |
| 469 | 462 | * @return void |
| 470 | 463 | */ |
| 471 | 464 | private function setDetails() { |
| 465 | + if($this->edit()) { | |
| 466 | + $this->temp_variables['state'] = 'edit'; | |
| 467 | + } else { | |
| 468 | + $this->temp_variables['state'] = ''; | |
| 469 | + } | |
| 472 | 470 | $this->temp_variables['dtype'] = $this->getPostSafe('dtype'); |
| 473 | 471 | $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases; |
| 474 | 472 | $this->temp_variables['dhost'] = $this->getPostSafe('dhost'); | ... | ... |
setup/wizard/steps/registration.php
| ... | ... | @@ -42,6 +42,15 @@ |
| 42 | 42 | |
| 43 | 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 | 55 | * Initialise the registration step |
| 47 | 56 | * |
| ... | ... | @@ -63,7 +72,9 @@ class registration extends Step |
| 63 | 72 | public function doStep() |
| 64 | 73 | { |
| 65 | 74 | $this->setFormInfo(); |
| 75 | + $this->loadFromSession(); | |
| 66 | 76 | if(!$this->inStep("registration")) { |
| 77 | + $this->loadFromSession(); | |
| 67 | 78 | return 'landing'; |
| 68 | 79 | } |
| 69 | 80 | if($this->next()) { |
| ... | ... | @@ -71,14 +82,48 @@ class registration extends Step |
| 71 | 82 | return 'confirm'; |
| 72 | 83 | return 'error'; |
| 73 | 84 | } else if($this->previous()) { |
| 85 | + | |
| 74 | 86 | return 'previous'; |
| 75 | 87 | }else if($this->confirm()) { |
| 76 | 88 | |
| 77 | 89 | return 'next'; |
| 78 | 90 | } |
| 91 | + | |
| 79 | 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 | 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 | 136 | if(isset($_POST['registered']) && $_POST['registered'] == 'yes'){ |
| 92 | 137 | return true; |
| 93 | 138 | } |
| 94 | -return true; | |
| 139 | + $this->setInSession(); | |
| 140 | + return true; | |
| 95 | 141 | //$this->postForm($_POST); |
| 96 | 142 | //$this->sendToHost($_POST); |
| 97 | 143 | |
| 98 | 144 | // Post the form using curl |
| 99 | 145 | $this->curlForm($_POST); |
| 100 | - | |
| 146 | + | |
| 101 | 147 | // Prevent the form being reposted. |
| 102 | 148 | $_POST['registered'] = 'yes'; |
| 103 | 149 | return true; |
| ... | ... | @@ -500,5 +546,17 @@ return true; |
| 500 | 546 | $this->temp_variables['industries'] = $industries; |
| 501 | 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 | 563 | \ No newline at end of file | ... | ... |
setup/wizard/steps/services.php
| ... | ... | @@ -123,6 +123,9 @@ class services extends Step |
| 123 | 123 | * @var mixed |
| 124 | 124 | */ |
| 125 | 125 | private $javaCheck = 'cross'; |
| 126 | + | |
| 127 | + | |
| 128 | + public $providedJava = false; | |
| 126 | 129 | |
| 127 | 130 | /** |
| 128 | 131 | * Flag if services are already Installed |
| ... | ... | @@ -215,7 +218,7 @@ class services extends Step |
| 215 | 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 | 223 | * @author KnowledgeTree Team |
| 221 | 224 | * @access public |
| ... | ... | @@ -224,6 +227,15 @@ class services extends Step |
| 224 | 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 | 239 | * Holds path error, if php is specified |
| 228 | 240 | * |
| 229 | 241 | * @author KnowledgeTree Team |
| ... | ... | @@ -257,16 +269,21 @@ class services extends Step |
| 257 | 269 | $this->doRun(); |
| 258 | 270 | return 'landing'; |
| 259 | 271 | } |
| 260 | - // Check dependencies | |
| 261 | - $passed = $this->doRun(); | |
| 262 | 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 | 279 | return 'next'; |
| 265 | 280 | else |
| 266 | 281 | return 'error'; |
| 267 | 282 | } else if($this->previous()) { |
| 268 | 283 | return 'previous'; |
| 269 | 284 | } |
| 285 | + | |
| 286 | + $passed = $this->doRun(); | |
| 270 | 287 | return 'landing'; |
| 271 | 288 | } |
| 272 | 289 | |
| ... | ... | @@ -406,14 +423,17 @@ class services extends Step |
| 406 | 423 | $this->setJava(); // Check if java has been auto detected |
| 407 | 424 | if($this->util->javaSpecified()) { |
| 408 | 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 | 431 | } else { |
| 411 | 432 | $auto = $this->useBridge(); // Use Bridge to get java settings |
| 412 | 433 | if($auto) { |
| 413 | 434 | return $auto; |
| 414 | 435 | } else { |
| 415 | - // Check if auto detected java works | |
| 416 | - $auto = $this->useDetected(); | |
| 436 | + $auto = $this->useDetected(); // Check if auto detected java works | |
| 417 | 437 | if($auto) { |
| 418 | 438 | $this->disableExtension = true; // Disable the use of the php bridge extension |
| 419 | 439 | return $auto; |
| ... | ... | @@ -434,7 +454,7 @@ class services extends Step |
| 434 | 454 | * @return boolean |
| 435 | 455 | */ |
| 436 | 456 | private function useDetected() { |
| 437 | - return $this->detSettings(true); | |
| 457 | + return $this->detSettings(); | |
| 438 | 458 | } |
| 439 | 459 | |
| 440 | 460 | private function specifyJava() { |
| ... | ... | @@ -480,24 +500,34 @@ class services extends Step |
| 480 | 500 | if($matches[1] < $this->javaVersion) { // Check Version of java |
| 481 | 501 | $this->javaVersionInCorrect(); |
| 482 | 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 | 505 | return false; |
| 485 | 506 | } else { |
| 486 | 507 | $this->javaVersionCorrect(); |
| 487 | 508 | $this->javaInstalled(); |
| 488 | 509 | $this->javaCheck = 'tick'; |
| 510 | + $this->providedJava = true; | |
| 489 | 511 | |
| 490 | 512 | return true; |
| 491 | 513 | } |
| 492 | 514 | } else { |
| 493 | 515 | $this->javaVersionWarning(); |
| 494 | 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 | 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 | 531 | return false; |
| 502 | 532 | } |
| 503 | 533 | |
| ... | ... | @@ -875,6 +905,7 @@ class services extends Step |
| 875 | 905 | $this->temp_variables['luceneInstalled'] = $this->luceneInstalled; |
| 876 | 906 | $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled; |
| 877 | 907 | $this->temp_variables['javaExeError'] = $this->javaExeError; |
| 908 | + $this->temp_variables['javaExeMessage'] = $this->javaExeMessage; | |
| 878 | 909 | $this->temp_variables['javaCheck'] = $this->javaCheck; |
| 879 | 910 | $this->temp_variables['javaExtCheck'] = $this->javaExtCheck; |
| 880 | 911 | // TODO : PHP detection |
| ... | ... | @@ -882,6 +913,8 @@ class services extends Step |
| 882 | 913 | $this->temp_variables['phpExeError'] = '';//$this->phpExeError; |
| 883 | 914 | $this->temp_variables['serviceCheck'] = $this->serviceCheck; |
| 884 | 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 | 920 | private function setPhp() { | ... | ... |
setup/wizard/templates/configuration.tpl
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <!--Warning and Error Messages--> |
| 18 | 18 | <?php if($errors) { ?> |
| 19 | 19 | <span class='cross'> </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’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 | 21 | <br/> |
| 22 | 22 | <?php } elseif ($warnings) { |
| 23 | 23 | ?> |
| ... | ... | @@ -84,7 +84,7 @@ |
| 84 | 84 | </p> |
| 85 | 85 | <table> |
| 86 | 86 | <?php |
| 87 | - if($errors && $warnings) { | |
| 87 | + if($errors || $warnings) { | |
| 88 | 88 | $width = "290px"; |
| 89 | 89 | } else { |
| 90 | 90 | $width = "520px"; |
| ... | ... | @@ -98,7 +98,7 @@ |
| 98 | 98 | <?php if(isset($path['msg'])) { |
| 99 | 99 | ?> |
| 100 | 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 | 102 | <?php |
| 103 | 103 | } else { |
| 104 | 104 | ?> | ... | ... |
setup/wizard/templates/configuration_confirm.tpl
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | <!--Warning and Error Messages--> |
| 12 | 12 | <?php if($errors) { ?> |
| 13 | 13 | <span class='cross'> </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’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 | 15 | <br/> |
| 16 | 16 | <?php } elseif ($warnings) { |
| 17 | 17 | ?> | ... | ... |
setup/wizard/templates/database.tpl
| ... | ... | @@ -12,37 +12,44 @@ |
| 12 | 12 | user on the database server are required in order to be able to configure and install the installation database. |
| 13 | 13 | </div> |
| 14 | 14 | <div id="step_content_database" class="step"> |
| 15 | + | |
| 15 | 16 | <table class="dbconf"> |
| 17 | + <?php | |
| 18 | + $input_size = '45'; | |
| 19 | + $align = 'left'; | |
| 20 | + ?> | |
| 16 | 21 | <!-- TODO: Different Databases--> |
| 22 | +<?php if($state != 'edit') { ?> | |
| 17 | 23 | <tr><td>Your current database type is: </td> |
| 18 | 24 | <?php if($dtypes) { |
| 19 | 25 | foreach($dtypes as $k=>$v) { |
| 20 | 26 | ?><td> |
| 21 | 27 | |
| 22 | - <?php echo ucwords($v);?> | |
| 28 | + <?php echo ucwords($v)." (Currently the only supported database.)";?> | |
| 23 | 29 | <input type="hidden" name="dtype" value="<?php echo $v; ?>" <?php if(!$k)echo 'checked="checked"'; ?>/> |
| 24 | 30 | </td> |
| 25 | 31 | <?php } |
| 26 | 32 | } |
| 27 | 33 | ?> |
| 28 | 34 | </tr> |
| 35 | +<?php } ?> | |
| 29 | 36 | <tr> |
| 30 | 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 | 39 | <td id="error" class="error"><?php if($errors['dname']) echo $errors['dname']; ?></td> |
| 33 | 40 | </tr> |
| 34 | 41 | <tr> |
| 35 | 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 | 44 | <td id="error" class="error"><?php if($errors['duname']) echo $errors['duname']; ?></td> |
| 38 | 45 | </tr> |
| 39 | 46 | <tr> |
| 40 | 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 | 49 | <td id="error" class="error"><?php if($errors['dpassword']) echo $errors['dpassword']; ?></td> |
| 43 | 50 | </tr> |
| 44 | 51 | </table> |
| 45 | - | |
| 52 | +<br/><br/> | |
| 46 | 53 | <div id="option3" class="onclick" onclick="javascript:{w.toggleClass('adv_options', 'option3');}"> Advanced Options</div> |
| 47 | 54 | <div id="database" class="adv_options" style="display:none;"> |
| 48 | 55 | <div class="description"> |
| ... | ... | @@ -52,7 +59,7 @@ |
| 52 | 59 | <tr> |
| 53 | 60 | <td width="10px"> <label for='dhost'>Host: </label> </td> |
| 54 | 61 | <td width="205px"> <div id="tooltips" title="The address of the server where the database is located, if different to the current server"> </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 | 63 | </tr> |
| 57 | 64 | <tr> |
| 58 | 65 | <td> <label for='dport'>Port: </label> </td> |
| ... | ... | @@ -62,7 +69,7 @@ |
| 62 | 69 | <tr> |
| 63 | 70 | <td> <label for='dbbinary'>Socket: </label> </td> |
| 64 | 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"> </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 | 73 | </tr> |
| 67 | 74 | </table> |
| 68 | 75 | </div> | ... | ... |
setup/wizard/templates/database_confirm.tpl
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <p class="title">Confirming Database Configurations</p> |
| 3 | 3 | |
| 4 | 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 | 6 | </div> |
| 7 | 7 | <div id="step_content_database_confirm" class="step"> |
| 8 | 8 | <h3><b>Database Settings</b></h3> |
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <tr> |
| 18 | 18 | <td width="153px">Database Type: </td> |
| 19 | 19 | <td width="15px"> <div id="tooltips" title="Type of database being used."> </div> </td> |
| 20 | - <td><?php echo $type; ?></td> | |
| 20 | + <td><?php echo $type." (Currently the only supported database.)"; ?></td> | |
| 21 | 21 | </tr> |
| 22 | 22 | <?php } ?> |
| 23 | 23 | <tr> |
| ... | ... | @@ -69,7 +69,7 @@ |
| 69 | 69 | <?php } ?> |
| 70 | 70 | </table> |
| 71 | 71 | |
| 72 | - <h3><b>Database Users</b></h3> | |
| 72 | + <h3><b>Database Users (System Generated)</b></h3> | |
| 73 | 73 | |
| 74 | 74 | <table class="dbconf"> |
| 75 | 75 | <?php //if (!$silent) { ?> | ... | ... |
setup/wizard/templates/dependencies.tpl
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <!--Warning and Error Messages--> |
| 18 | 18 | <?php if($errors) { ?> |
| 19 | 19 | <span class='cross'> </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’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 | 21 | <br/> |
| 22 | 22 | <?php } elseif ($warnings) { ?> |
| 23 | 23 | <span class='cross_orange'> </span> | ... | ... |
setup/wizard/templates/registration.tpl
| 1 | 1 | <form id="registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post" onsubmit="w.validateRegistration();return false;"> |
| 2 | 2 | <p class="title">Registering KnowledgeTree</p> |
| 3 | - | |
| 3 | + <?php | |
| 4 | + //echo $sel_country; | |
| 5 | + ?> | |
| 4 | 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 | 8 | <a href="index.php?step_name=install">Skip Registration</a> |
| 7 | 9 | </p> |
| 8 | 10 | <!-- Hidden Fields --> |
| ... | ... | @@ -20,18 +22,18 @@ |
| 20 | 22 | <tr> |
| 21 | 23 | <td><label for='first'>First Name</label></td> |
| 22 | 24 | <td rowspan='6' width='5%'> </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 | 26 | <td rowspan='6' width='5%'> </td> |
| 25 | 27 | <td rowspan='6'> <img src='resources/graphics/dropbox.png' /> </td> |
| 26 | 28 | </tr> |
| 27 | 29 | |
| 28 | 30 | <tr> |
| 29 | 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 | 33 | </tr> |
| 32 | 34 | <tr> |
| 33 | 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 | 37 | </tr> |
| 36 | 38 | <tr> |
| 37 | 39 | <td><label for='country'>Country</label></td> |
| ... | ... | @@ -40,7 +42,12 @@ |
| 40 | 42 | <?php |
| 41 | 43 | $str = ''; |
| 42 | 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 | 53 | echo $str; |
| ... | ... | @@ -55,7 +62,11 @@ |
| 55 | 62 | <?php |
| 56 | 63 | $str = ''; |
| 57 | 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 | 72 | echo $str; |
| ... | ... | @@ -70,7 +81,11 @@ |
| 70 | 81 | <?php |
| 71 | 82 | $str = ''; |
| 72 | 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 | 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 | 8 | <p class="title">Checking Service Dependencies</p> |
| 3 | 9 | |
| 4 | 10 | <p class="description"> |
| ... | ... | @@ -17,7 +23,7 @@ |
| 17 | 23 | <!--Warning and Error Messages--> |
| 18 | 24 | <?php if($errors) { ?> |
| 19 | 25 | <span class='cross'> </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’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 | 27 | <br/> |
| 22 | 28 | <?php } elseif ($warnings) { |
| 23 | 29 | ?> |
| ... | ... | @@ -28,18 +34,22 @@ |
| 28 | 34 | }?> |
| 29 | 35 | <?php |
| 30 | 36 | if($errors || $warnings) { |
| 37 | +// var_dump($errors); | |
| 31 | 38 | ?> |
| 32 | 39 | <a href="http://wiki.knowledgetree.com/Web_Based_Installer#Service_Dependencies" target="_blank">Click here for help on overcoming service issues</a> |
| 33 | 40 | <?php } ?> |
| 34 | 41 | <!--Content--> |
| 35 | 42 | <div id="step_content_configuration" style="width:755px;" class="step"> |
| 36 | 43 | <?php if(!$alreadyInstalled) { ?> |
| 37 | - <?php if($javaExeError != '') { ?> | |
| 44 | + <?php //var_dump($javaExeError); ?> | |
| 45 | + <?php if($javaExeError) { ?> | |
| 38 | 46 | Specify the location of your Java executable |
| 39 | 47 | |
| 40 | 48 | <input name='java' id='port' size='25' value='<?php echo $java['location']; ?>' style="float:none;"/> |
| 41 | 49 | |
| 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 | 53 | <?php } ?> |
| 44 | 54 | <?php if($phpExeError != '') { ?> |
| 45 | 55 | <br /> |
| ... | ... | @@ -53,9 +63,6 @@ |
| 53 | 63 | |
| 54 | 64 | <?php if($phpExeError != true) { ?><span class="error"><?php echo $phpExeError; ?></span><?php } ?> |
| 55 | 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 | 66 | <h3><?php echo "<span class='{$javaCheck}'> </span>"; ?>Java Check</h3> |
| 60 | 67 | <?php if($silent) { ?> |
| 61 | 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 | 7 | public $request=NULL; |
| 8 | 8 | public $kt=NULL; |
| 9 | 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 | 13 | // set a local copy of the json request wrapper |
| 14 | + $noAuthRequests=is_array($noAuthRequests)?$noAuthRequests:split(',',(string)$noAuthRequests); | |
| 15 | + $this->registerNoAuthRequest($noAuthRequests); | |
| 13 | 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 | 25 | // set the response object |
| ... | ... | @@ -22,6 +29,7 @@ class ajaxHandler{ |
| 22 | 29 | $this->ret=new jsonResponseObject(); |
| 23 | 30 | } |
| 24 | 31 | $this->ret->setRequest($this->req->jsonArray); |
| 32 | + $this->ret->setTitle($this->request['service'].'::'.$this->request['function']); | |
| 25 | 33 | |
| 26 | 34 | if(get_class($kt)=='KTAPI'){ |
| 27 | 35 | $this->kt=&$kt; |
| ... | ... | @@ -41,21 +49,32 @@ class ajaxHandler{ |
| 41 | 49 | |
| 42 | 50 | if(!$this->verifySession()){ |
| 43 | 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 | 57 | $this->dispatch(); |
| 48 | 58 | |
| 49 | 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 | 67 | public function dispatch(){ |
| 53 | 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 | 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 | 78 | $service->$request['function']($request['parameters']); |
| 60 | 79 | }else{ |
| 61 | 80 | $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}"); |
| ... | ... | @@ -97,7 +116,7 @@ class ajaxHandler{ |
| 97 | 116 | } |
| 98 | 117 | |
| 99 | 118 | protected function isAuthenticated(){ |
| 100 | - return true; | |
| 119 | + return $this->authenticator->pickup_session(); | |
| 101 | 120 | } |
| 102 | 121 | |
| 103 | 122 | protected function doLogin(){ |
| ... | ... | @@ -113,6 +132,26 @@ class ajaxHandler{ |
| 113 | 132 | echo $this->ret->getJson(); |
| 114 | 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 | 158 | \ No newline at end of file | ... | ... |
webservice/clienttools/client_service.php
| ... | ... | @@ -41,6 +41,17 @@ class client_service{ |
| 41 | 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 | 58 | \ No newline at end of file | ... | ... |
webservice/clienttools/comms.php
| ... | ... | @@ -38,12 +38,23 @@ $old_error_handler=set_error_handler('error_handler',E_ERROR); |
| 38 | 38 | //Interpret the Json Object that was passed |
| 39 | 39 | include_once('jsonWrapper.php'); |
| 40 | 40 | include_once('ajaxhandler.php'); |
| 41 | +include_once('serviceHelper.php'); | |
| 41 | 42 | include_once('client_service.php'); |
| 42 | 43 | |
| 43 | 44 | //Instantiate base classes |
| 44 | 45 | $KT = new KTAPI(); |
| 45 | 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 | 12 | protected $request=array(); |
| 13 | 13 | protected $debug=array(); |
| 14 | 14 | public $additional=array(); |
| 15 | + public $isDataSource=false; | |
| 15 | 16 | |
| 16 | 17 | public $response=array( |
| 17 | 18 | 'requestName' =>'', |
| ... | ... | @@ -60,7 +61,7 @@ class jsonResponseObject{ |
| 60 | 61 | |
| 61 | 62 | public function getJson(){ |
| 62 | 63 | $response=array_merge(array( |
| 63 | - 'title' =>$this->title, | |
| 64 | + 'requestName' =>$this->title, | |
| 64 | 65 | 'errors' =>array( |
| 65 | 66 | 'hadErrors' =>(count($this->errors)>0?1:0), |
| 66 | 67 | 'errors' =>$this->errors |
| ... | ... | @@ -71,7 +72,11 @@ class jsonResponseObject{ |
| 71 | 72 | 'debug' =>$this->debug, |
| 72 | 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 | 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 | 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 | 23 | require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); |
| 24 | 24 | |
| 25 | 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 | 40 | if(!PEAR::isError($session)){ |
| 39 | 41 | $this->Response->setStatus('session_id',$session->get_session()); |
| 40 | 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 | 46 | return false; |
| 44 | 47 | } |
| 45 | 48 | }else{ |
| 46 | - throw new Exception('Incorrect Credentials'); | |
| 49 | + $this->addError('Incorrect Credentials'); | |
| 50 | + //throw new Exception('Incorrect Credentials'); | |
| 47 | 51 | return false; |
| 48 | 52 | } |
| 49 | 53 | }else{ |
| 50 | - throw new Exception('Unrecognized User'); | |
| 54 | + $this->addError('Incorrect Credentials'); | |
| 55 | + //throw new Exception('Unrecognized User'); | |
| 51 | 56 | return false; |
| 52 | 57 | } |
| 53 | 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 | 71 | public function pickup_session(){ |
| 57 | 72 | $params=$this->AuthInfo; |
| 58 | 73 | $app_type=$params['appType']; |
| ... | ... | @@ -67,6 +82,40 @@ class auth extends client_service { |
| 67 | 82 | $this->Response->setStatus('session_id',$session->get_session()); |
| 68 | 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 | 122 | \ No newline at end of file | ... | ... |
webservice/clienttools/services/3.6.1/kt.php
| 1 | 1 | <?php |
| 2 | 2 | class kt extends client_service { |
| 3 | + | |
| 3 | 4 | |
| 5 | + | |
| 4 | 6 | /** |
| 5 | 7 | * Get Supported (?) Languages |
| 6 | 8 | * |
| 7 | 9 | * returns array containing languages, count, & defaultlanguage |
| 8 | 10 | * |
| 9 | 11 | */ |
| 10 | - function get_languages(){ | |
| 12 | + function get_languages($passthru=false){ | |
| 11 | 13 | global $default; |
| 12 | 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 | 19 | if(!empty($aRegisteredLangs)){ |
| 18 | 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 | 33 | function get_rootfolder_detail($params){ |
| 31 | - $params['folderId'] = '1'; | |
| 34 | + $params['folderId']='1'; | |
| 32 | 35 | $this->get_folder_detail($params); |
| 33 | 36 | } |
| 34 | 37 | |
| 35 | 38 | |
| 36 | 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 | 47 | if (PEAR::isError($folder)) |
| 41 | 48 | { |
| 42 | 49 | $this->setError("Could not get folder by Id: {$params['folderId']}"); |
| 43 | 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 | 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 | 73 | case 'W': |
| 71 | - $canWrite = true; | |
| 74 | + $canWrite=true; | |
| 72 | 75 | $perms .= $this->xlate('write, '); |
| 73 | 76 | break; |
| 74 | 77 | case 'R': |
| ... | ... | @@ -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 | 90 | $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; |
| 91 | - | |
| 92 | - //comment | |
| 93 | 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 | 102 | 'qtip'=> $qtip |
| 106 | 103 | ); |
| 107 | 104 | |
| 108 | 105 | $this->setResponse($result); |
| 106 | + return true; | |
| 109 | 107 | } |
| 110 | 108 | |
| 111 | 109 | |
| 112 | 110 | function get_folder_contents($params){ |
| 113 | 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 | 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 | 184 | case 'W': |
| 163 | - $canWrite = true; | |
| 185 | + $canWrite=true; | |
| 164 | 186 | $perms .= $this->xlate('write, '); |
| 165 | - break; | |
| 187 | + break; | |
| 166 | 188 | case 'R': |
| 167 | 189 | $perms .= $this->xlate('read, '); |
| 168 | - break; | |
| 190 | + break; | |
| 169 | 191 | case 'A': |
| 170 | 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 | 202 | $qtip .= $this->xlate('Folder name').": {$filename}<br>"; |
| 188 | - $class = 'folder'; | |
| 189 | - | |
| 190 | - //permissions | |
| 203 | + $class='folder'; | |
| 191 | 204 | $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; |
| 192 | - | |
| 193 | - //comment | |
| 194 | 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 | 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 | 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 | 226 | $qtip .= $this->xlate('Modified') . ": {$item['modified_date']}<br>"; |
| 233 | - | |
| 234 | - //owner | |
| 235 | 227 | $qtip .= $this->xlate('Owner') . ": {$item['created_by']}<br>"; |
| 236 | - | |
| 237 | - //version | |
| 238 | 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 | 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 | 237 | $qtip .= $this->xlate('Status: Checked out by') . " {$item['checked_out_by']}<br>"; |
| 255 | - } | |
| 256 | - else | |
| 257 | - { | |
| 238 | + }else{ | |
| 258 | 239 | $qtip .= $this->xlate('Status: Available') . '<br>'; |
| 259 | 240 | } |
| 260 | - | |
| 261 | - //permissions | |
| 262 | 241 | $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; |
| 263 | 242 | |
| 264 | - //immutable | |
| 265 | - if($immutable) | |
| 266 | - { | |
| 243 | + if($immutable){ | |
| 267 | 244 | $qtip .= $this->xlate('This document is not editable'); |
| 268 | - } | |
| 269 | - else if ($canWrite) | |
| 270 | - { | |
| 245 | + }else if ($canWrite){ | |
| 271 | 246 | $qtip .= $this->xlate('You may edit this document'); |
| 272 | - } | |
| 273 | - else | |
| 274 | - { | |
| 247 | + }else{ | |
| 275 | 248 | $qtip .= $this->xlate('This document is not editable'); |
| 276 | 249 | } |
| 277 | 250 | } |
| 278 | 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 | 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 | 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 | 275 | 'qtip'=> $qtip |
| 305 | 276 | ); |
| 306 | 277 | } |
| ... | ... | @@ -309,128 +280,155 @@ class kt extends client_service { |
| 309 | 280 | private function _processItemInclusion_search($item, $class, $qtip) |
| 310 | 281 | { |
| 311 | 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 | 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 | 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 | 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 | 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 | 355 | // Commented out for timebeing - will be used by 'Save in Format' |
| 358 | 356 | |
| 359 | 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 | 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 | 372 | for($i=0;$i<count($detail);$i++) { |
| 375 | 373 | |
| 376 | 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 | 380 | // Change for value. If blank value is set to 1, change value to '' |
| 383 | 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 | 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 | 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 | 409 | for($i=0;$i<count($detail);$i++) { |
| 412 | 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 | 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 | 423 | if($document_id > 0) { |
| 426 | - $document = $kt->get_document_by_id($document_id); | |
| 424 | + $document=$kt->get_document_by_id($document_id); | |
| 427 | 425 | $document->change_document_type($params['document_type']); |
| 428 | - $this->setResponse(array('status_code' => 0)); | |
| 426 | + $this->setResponse(array('status_code'=>0)); | |
| 429 | 427 | return true; |
| 430 | 428 | |
| 431 | 429 | }else{ |
| 432 | 430 | $this->addError("Invalid document Id : {$document_id}"); |
| 433 | - $this->setResponse(array('status_code' => 1)); | |
| 431 | + $this->setResponse(array('status_code'=>1)); | |
| 434 | 432 | return false; |
| 435 | 433 | } |
| 436 | 434 | |
| ... | ... | @@ -447,35 +445,38 @@ class kt extends client_service { |
| 447 | 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 | 449 | // $docname='test.txt'; |
| 453 | 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 | 457 | return; |
| 460 | 458 | } |
| 461 | - | |
| 462 | - $result = $document->download(); | |
| 459 | + $docname=$document->document->getFileName(); | |
| 460 | + $result=$document->download(); | |
| 463 | 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 | 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 | 470 | $download_manager->set_session($session->session); |
| 473 | 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 | 480 | $this->setResponse($response); |
| 480 | 481 | } |
| 481 | 482 | |
| ... | ... | @@ -490,35 +491,35 @@ class kt extends client_service { |
| 490 | 491 | * |
| 491 | 492 | */ |
| 492 | 493 | function checkout_document($params){ |
| 493 | - $responseType = 'kt_response'; | |
| 494 | + $responseType='kt_response'; | |
| 494 | 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 | 498 | if (PEAR::isError($document)) |
| 498 | 499 | { |
| 499 | 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 | 502 | return; |
| 502 | 503 | } |
| 503 | 504 | |
| 504 | - $result = $document->checkout($params['reason']); | |
| 505 | + $result=$document->checkout($params['reason']); | |
| 505 | 506 | if (PEAR::isError($result)) |
| 506 | 507 | { |
| 507 | 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 | 510 | return; |
| 510 | 511 | } |
| 511 | 512 | |
| 512 | - $url = ''; | |
| 513 | + $url=''; | |
| 513 | 514 | if ($params['download']) |
| 514 | 515 | { |
| 515 | - $download_manager = new KTDownloadManager(); | |
| 516 | + $download_manager=new KTDownloadManager(); | |
| 516 | 517 | $download_manager->set_session($params['session_id']); |
| 517 | 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 | 534 | * @param array $params |
| 534 | 535 | */ |
| 535 | 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 | 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 | 547 | // we need to add some security to ensure that people don't frig the checkin process to access restricted files. |
| 547 | 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 | 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 | 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 | 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 | 562 | // checkin |
| 562 | - $result = $document->checkin($filename, $reason, $tempfilename, false); | |
| 563 | + $result=$document->checkin($filename, $reason, $tempfilename, false); | |
| 563 | 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 | 569 | // get status after checkin |
| 569 | 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 | 575 | $this->setResponse($detail); |
| 575 | 576 | } |
| ... | ... | @@ -581,686 +582,540 @@ class kt extends client_service { |
| 581 | 582 | * @param unknown_type $arr |
| 582 | 583 | */ |
| 583 | 584 | function add_document_with_metadata($arr){ |
| 584 | - $session_id = $arr['session_id']; | |
| 585 | + $session_id=$arr['session_id']; | |
| 585 | 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 | 590 | $this->debug('Entered add_document_with_metadata'); |
| 590 | 591 | |
| 591 | - foreach($packed as $key => $val) { | |
| 592 | + foreach($packed as $key=>$val) { | |
| 592 | 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 | 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 | 607 | if ($status_code != 0) |
| 607 | 608 | { |
| 608 | 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 | 615 | $this->debug('$this->response= from update_document_metadata'); |
| 615 | - $status_code = $update_result['status_code']; | |
| 616 | + $status_code=$update_result['status_code']; | |
| 616 | 617 | if ($status_code != 0) |
| 617 | 618 | { |
| 618 | 619 | $this->delete_document($arr['session_id'], $document_id, 'Rollback because metadata could not be added', $arr['application']); |
| 619 | 620 | $this->response= $update_result; |
| 620 | 621 | } |
| 621 | 622 | |
| 622 | - $kt = &$this->KT; | |
| 623 | + $kt=&$this->KT; | |
| 623 | 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 | 631 | if (PEAR::isError($result)) |
| 631 | 632 | { |
| 632 | 633 | // not much we can do, maybe just log! |
| 633 | 634 | } |
| 634 | 635 | |
| 635 | 636 | |
| 636 | - $result = $document->mergeWithLastMetadataVersion(); | |
| 637 | + $result=$document->mergeWithLastMetadataVersion(); | |
| 637 | 638 | if (PEAR::isError($result)) |
| 638 | 639 | { |
| 639 | 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 | 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 | 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 | 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 | 855 | if(!empty($special)) { |
| 957 | - | |
| 958 | 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 | 859 | if(isset($special['__title'])) { |
| 962 | 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 | 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 | 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 | 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 | 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 | 958 | break; |
| 1104 | 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 | 962 | if ($group != null) { |
| 1109 | - $recipientsList[] = $group; | |
| 963 | + $recipientsList[]=$group; | |
| 1110 | 964 | } |
| 1111 | 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 | 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 | 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 | 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 | 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 | 1122 | \ No newline at end of file | ... | ... |