Esempio n. 1
0
 public function loadDocumentInfo()
 {
     global $default;
     $sql = "SELECT\n\t\t\t\t\td.folder_id, f.full_path, f.name, dcv.size as filesize, dcv.major_version,\n\t\t\t\t\tdcv.minor_version, dcv.filename, cou.name as checkoutuser, w.human_name as workflow, ws.human_name as workflowstate,\n\t\t\t\t\tmt.mimetypes as mimetype, md.mime_doc as mimedoc, d.checkedout, mbu.name as modifiedbyuser, d.modified,\n\t\t\t\t\tcbu.name as createdbyuser, ou.name as owneruser, d.immutable, d.status_id, d.created,dcv.storage_path, dtl.name as document_type,\n\t\t\t\t\tmt.icon_path as mime_icon_path, mt.friendly_name as mime_display, d.oem_no, dmv.name as title\n\t\t\t\tFROM\n\t\t\t\t\tdocuments d\n\t\t\t\t\tINNER JOIN document_metadata_version dmv ON d.metadata_version_id = dmv.id\n\t\t\t\t\tINNER JOIN document_content_version dcv ON dmv.content_version_id = dcv.id\n\t\t\t\t\tINNER JOIN mime_types mt ON dcv.mime_id=mt.id\n\t\t\t\t\tLEFT JOIN document_types_lookup dtl ON dtl.id=dmv.document_type_id\n\t\t\t\t\tLEFT JOIN folders f ON f.id=d.folder_id\n\t\t\t\t\tLEFT JOIN users cou ON d.checked_out_user_id=cou.id\n\t\t\t\t\tLEFT JOIN workflows w ON dmv.workflow_id=w.id\n\t\t\t\t\tLEFT JOIN workflow_states ws ON dmv.workflow_state_id = ws.id\n\t\t\t\t\tLEFT JOIN mime_documents md ON mt.mime_document_id = md.id\n\t\t\t\t\tLEFT JOIN users mbu ON d.modified_user_id=mbu.id\n\t\t\t\t\tLEFT JOIN users cbu ON d.creator_id=cbu.id\n\t\t\t\t\tLEFT JOIN users ou ON d.owner_id=ou.id\n\t\t\t\tWHERE\n\t\t\t\t\td.id={$this->id}";
     if ($this->inclStatus) {
         $sql .= " AND d.status_id = 1";
     }
     $result = DBUtil::getOneResult($sql);
     if (PEAR::isError($result) || empty($result)) {
         $this->live = false;
         if (PEAR::isError($result)) {
             throw new Exception('Database exception! There appears to be an error in the system: ' . $result->getMessage());
         }
         $default->log->error('QueryResultItem: $result is null');
         $msg = 'The database did not have a record matching the result from the document indexer. This may occur if there is an inconsistency between the document indexer and the repository. The indexer needs to be repaired.';
         $default->log->error('QueryResultItem: ' . $msg);
         // TODO: repair process where we scan documents in index, and delete those for which there is nothing in the repository
         throw new IndexerInconsistencyException(sprintf(_kt('%s'), $msg));
     }
     // document_id, relevance, text, title
     $this->documentType = $result['document_type'];
     $this->filename = $result['filename'];
     $this->filesize = KTUtil::filesizeToString($result['filesize']);
     $this->folderId = $result['folder_id'];
     $this->title = $result['title'];
     $this->createdBy = $result['createdbyuser'];
     $this->dateCreated = $result['created'];
     $this->modifiedBy = $result['modifiedbyuser'];
     $this->dateModified = $result['modified'];
     $this->checkedOutUser = $result['checkoutuser'];
     $this->dateCheckedout = $result['checkedout'];
     $this->owner = $result['owneruser'];
     $this->version = $result['major_version'] . '.' . $result['minor_version'];
     $this->immutable = $result['immutable'] + 0 ? _kt('Immutable') : '';
     $this->workflow = $result['workflow'];
     $this->workflowState = $result['workflowstate'];
     $this->oemDocumentNo = $result['oem_no'];
     if (empty($this->oemDocumentNo)) {
         $this->oemDocumentNo = 'n/a';
     }
     if (is_null($result['name'])) {
         $this->fullpath = '(orphaned)';
     } else {
         $this->fullpath = $result['full_path'];
     }
     $this->mimeType = $result['mimetype'];
     $this->mimeIconPath = $result['mime_icon_path'];
     if (empty($this->mimeIconPath)) {
         $this->mimeIconPath = 'unspecified_type';
     }
     $this->mimeDisplay = $result['mime_display'];
     $this->storagePath = $result['storage_path'];
     $this->status = Document::getStatusString($result['status_id']);
 }
Esempio n. 2
0
 public static function getKTUsageStats($update = true)
 {
     $usage = array();
     $oRegistry =& KTPluginRegistry::getSingleton();
     $oPlugin =& $oRegistry->getPlugin('ktcore.housekeeper.plugin');
     $folders = self::getDirectories();
     foreach ($folders as $folder) {
         $directory = $folder['folder'];
         $pattern = $folder['pattern'];
         $canClean = $folder['canClean'];
         $name = $folder['name'];
         $temp = self::scanPath($directory, $pattern);
         $usage[] = array('description' => $name, 'folder' => $directory, 'files' => number_format($temp['files'], 0, '.', ','), 'filesize' => KTUtil::filesizeToString($temp['filesize']), 'action' => $i, 'canClean' => $canClean);
     }
     if ($update) {
         KTUtil::setSystemSetting('KTUsage', serialize($usage));
     }
     return $usage;
 }