Commit e1c93671d6406e28dc540b448c4bc1d07316dc56
1 parent
d88024d9
KTS-2524
"Create document indexer shutdown script" Implemented. Also did a few other small fixes... Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7426 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
22 additions
and
10 deletions
search2/indexing/indexerCore.inc.php
| @@ -32,13 +32,13 @@ class QueryResultItem | @@ -32,13 +32,13 @@ class QueryResultItem | ||
| 32 | protected $status; | 32 | protected $status; |
| 33 | protected $folderId; | 33 | protected $folderId; |
| 34 | 34 | ||
| 35 | - | ||
| 36 | public function __construct($document_id, $rank=null, $title=null, $text=null) | 35 | public function __construct($document_id, $rank=null, $title=null, $text=null) |
| 37 | { | 36 | { |
| 38 | - $this->document_id=$document_id; | 37 | + $this->document_id=(int) $document_id; |
| 39 | $this->rank= $rank; | 38 | $this->rank= $rank; |
| 40 | $this->title=$title; | 39 | $this->title=$title; |
| 41 | $this->text = $text; | 40 | $this->text = $text; |
| 41 | + $this->live = true; | ||
| 42 | $this->loadDocumentInfo(); | 42 | $this->loadDocumentInfo(); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -57,14 +57,13 @@ class QueryResultItem | @@ -57,14 +57,13 @@ class QueryResultItem | ||
| 57 | return true; // should not be reached | 57 | return true; // should not be reached |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | - private function loadDocumentInfo() | 60 | + public function loadDocumentInfo() |
| 61 | { | 61 | { |
| 62 | $sql = "SELECT | 62 | $sql = "SELECT |
| 63 | - f.folder_id, f.full_path, f.name, dcv.size as filesize, dcv.major_version, | 63 | + d.folder_id, f.full_path, f.name, dcv.size as filesize, dcv.major_version, |
| 64 | dcv.minor_version, dcv.filename, cou.name as checkoutuser, w.human_name as workflow, ws.human_name as workflowstate, | 64 | dcv.minor_version, dcv.filename, cou.name as checkoutuser, w.human_name as workflow, ws.human_name as workflowstate, |
| 65 | mt.mimetypes as mimetype, md.mime_doc as mimedoc, d.checkedout, mbu.name as modifiedbyuser, d.modified, | 65 | mt.mimetypes as mimetype, md.mime_doc as mimedoc, d.checkedout, mbu.name as modifiedbyuser, d.modified, |
| 66 | cbu.name as createdbyuser, ou.name as owneruser, d.immutable, d.status_id, d.created | 66 | cbu.name as createdbyuser, ou.name as owneruser, d.immutable, d.status_id, d.created |
| 67 | - | ||
| 68 | FROM | 67 | FROM |
| 69 | documents d | 68 | documents d |
| 70 | INNER JOIN document_metadata_version dmv ON d.metadata_version_id = dmv.id | 69 | INNER JOIN document_metadata_version dmv ON d.metadata_version_id = dmv.id |
| @@ -78,7 +77,6 @@ class QueryResultItem | @@ -78,7 +77,6 @@ class QueryResultItem | ||
| 78 | LEFT JOIN users mbu ON d.modified_user_id=mbu.id | 77 | LEFT JOIN users mbu ON d.modified_user_id=mbu.id |
| 79 | LEFT JOIN users cbu ON d.creator_id=cbu.id | 78 | LEFT JOIN users cbu ON d.creator_id=cbu.id |
| 80 | LEFT JOIN users ou ON d.owner_id=ou.id | 79 | LEFT JOIN users ou ON d.owner_id=ou.id |
| 81 | - | ||
| 82 | WHERE | 80 | WHERE |
| 83 | d.id=$this->document_id"; | 81 | d.id=$this->document_id"; |
| 84 | 82 | ||
| @@ -87,10 +85,9 @@ class QueryResultItem | @@ -87,10 +85,9 @@ class QueryResultItem | ||
| 87 | if (PEAR::isError($result) || empty($result)) | 85 | if (PEAR::isError($result) || empty($result)) |
| 88 | { | 86 | { |
| 89 | $this->live = false; | 87 | $this->live = false; |
| 90 | - return; | 88 | + throw new Exception('QueryResultItem::loadDocumentInfo failed'); |
| 91 | } | 89 | } |
| 92 | 90 | ||
| 93 | - $this->live = true; | ||
| 94 | if (is_null($result['name'])) | 91 | if (is_null($result['name'])) |
| 95 | { | 92 | { |
| 96 | $this->fullpath = '(orphaned)'; | 93 | $this->fullpath = '(orphaned)'; |
| @@ -137,7 +134,7 @@ class QueryResultItem | @@ -137,7 +134,7 @@ class QueryResultItem | ||
| 137 | case 'Title': return (string) $this->title; | 134 | case 'Title': return (string) $this->title; |
| 138 | case 'FullPath': return (string) $this->fullpath; | 135 | case 'FullPath': return (string) $this->fullpath; |
| 139 | case 'IsLive': return (bool) $this->live; | 136 | case 'IsLive': return (bool) $this->live; |
| 140 | - case 'Filesize': return (int) $this->filesize; | 137 | + case 'Filesize': return $this->filesize; |
| 141 | case 'Version': return (string) $this->version; | 138 | case 'Version': return (string) $this->version; |
| 142 | case 'Filename': return (int)$this->filename; | 139 | case 'Filename': return (int)$this->filename; |
| 143 | case 'FolderId': return (int)$this->folderId; | 140 | case 'FolderId': return (int)$this->folderId; |
| @@ -180,7 +177,13 @@ class QueryResultItem | @@ -180,7 +177,13 @@ class QueryResultItem | ||
| 180 | case 'Status': | 177 | case 'Status': |
| 181 | return $this->status; | 178 | return $this->status; |
| 182 | case 'CanBeReadByUser': | 179 | case 'CanBeReadByUser': |
| 183 | - return (bool) $this->live && (Permission::userHasDocumentReadPermission($this->Document) || Permission::adminIsInAdminMode()); | 180 | + if (!$this->live) |
| 181 | + return false; | ||
| 182 | + if (Permission::userHasDocumentReadPermission($this->Document)) | ||
| 183 | + return true; | ||
| 184 | + if (Permission::adminIsInAdminMode()) | ||
| 185 | + return true; | ||
| 186 | + return false; | ||
| 184 | default: | 187 | default: |
| 185 | throw new Exception("Unknown property '$property' to get on MatchResult"); | 188 | throw new Exception("Unknown property '$property' to get on MatchResult"); |
| 186 | } | 189 | } |
| @@ -1170,6 +1173,15 @@ abstract class Indexer | @@ -1170,6 +1173,15 @@ abstract class Indexer | ||
| 1170 | } | 1173 | } |
| 1171 | 1174 | ||
| 1172 | /** | 1175 | /** |
| 1176 | + * Shuts down the indexer | ||
| 1177 | + * | ||
| 1178 | + */ | ||
| 1179 | + public function shutdown() | ||
| 1180 | + { | ||
| 1181 | + // do nothing generally | ||
| 1182 | + } | ||
| 1183 | + | ||
| 1184 | + /** | ||
| 1173 | * Returns the name of the indexer. | 1185 | * Returns the name of the indexer. |
| 1174 | * | 1186 | * |
| 1175 | * @return string | 1187 | * @return string |