コード例 #1
0
 function renderData($aDataRow)
 {
     // only _ever_ show this for documents.
     if ($aDataRow["type"] === "folder") {
         return ' ';
     }
     $sUrl = KTUtil::kt_url() . '/' . $this->sPluginPath . '/documentPreview.php';
     $sDir = KT_DIR;
     $iDelay = 1000;
     // milliseconds
     $iDocumentId = $aDataRow['document']->getId();
     $sTitle = _kt('Property Preview');
     $sLoading = _kt('Loading...');
     $width = 500;
     // Check for existence of thumbnail plugin
     if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) {
         // hook into thumbnail plugin to get display for thumbnail
         include_once KT_DIR . '/plugins/thumbnails/thumbnails.php';
         $thumbnailer = new ThumbnailViewlet();
         $thumbnailwidth = $thumbnailer->get_width($iDocumentId);
         $width += $thumbnailwidth + 30;
     }
     //$link = '<a name = "ktP'.$iDocumentId.'" href = "#ktP'.$iDocumentId.'" class="ktAction ktPreview" id = "box_'.$iDocumentId.'" ';
     $link = '<a href = "#browseForm" class="ktAction ktPreview" id = "box_' . $iDocumentId . '" ';
     if ($this->sActivation == 'mouse-over') {
         $sJs = "javascript: this.t = setTimeout('showInfo(\\'{$iDocumentId}\\', \\'{$sUrl}\\', \\'{$sDir}\\', \\'{$sLoading}\\', {$width})', {$iDelay});";
         $link .= 'onmouseover = "' . $sJs . '" onmouseout = "clearTimeout(this.t);">';
     } else {
         $sJs = "javascript: showInfo('{$iDocumentId}', '{$sUrl}', '{$sDir}', '{$sLoading}', {$width});";
         $link .= 'onclick = "' . $sJs . '" title="' . $sTitle . '">';
     }
     return $link . $sTitle . '</a>';
 }
コード例 #2
0
 function predispatch()
 {
     $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Field Management'));
     $this->persistParams(array('fFieldsetId'));
     $this->oFieldset = KTFieldset::get(KTUtil::arrayGet($_REQUEST, 'fFieldsetId'));
     if (PEAR::isError($this->oFieldset)) {
         $this->oFieldset = null;
         unset($_REQUEST['fFieldset']);
         // prevent further attacks.
     } else {
         $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf($this->meldPersistQuery("", "edit")), 'name' => $this->oFieldset->getName());
     }
     $this->bHaveConditional = KTPluginUtil::pluginIsActive('ktextra.conditionalmetadata.plugin');
 }
コード例 #3
0
 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktstandard/ktwebdavdashlet/dashlet');
     $sURL = KTUtil::kt_url();
     // Check if this is a commercial installation - before displaying the KT Tools webdav link
     // Shortcut: Check if the the wintools plugin exists and set to true.
     // Long way: Check that a license is installed - this is only text so having a license is not a requirement.
     $isComm = false;
     if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         $isComm = true;
     }
     $webdavUrl = $sURL . '/ktwebdav/ktwebdav.php';
     $aTemplateData = array('url' => $sURL, 'webdav_url' => $webdavUrl, 'hasLicense' => $isComm);
     return $oTemplate->render($aTemplateData);
 }
コード例 #4
0
ファイル: Rename.php プロジェクト: sfsergey/knowledgetree
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("rename"));
     $this->oPage->setTitle(_kt('Rename folder'));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/rename');
     $fields = array();
     $fields[] = new KTStringWidget(_kt('New folder name'), _kt('The name to which the current folder should be renamed.'), 'foldername', $this->oFolder->getName(), $this->oPage, true);
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to rename a folder');
         $input['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.rename', 'folder', 'rename_folder_form', 'submit', {$this->oFolder->getId()});";
         $input['type'] = 'button';
     } else {
         $input['onclick'] = '';
         $input['type'] = 'submit';
     }
     $oTemplate->setData(array('context' => &$this, 'fields' => $fields, 'input' => $input, 'folderName' => $this->oFolder->getName()));
     return $oTemplate->render();
 }
コード例 #5
0
 /**
  * All for folders only
  * Handles leaf criteria set (ie, no subgroups), generating SQL for
  * the values in the criteria.
  *
  * (This would be the place to extend criteria to support contains,
  * starts with, ends with, greater than, and so forth.)
  */
 function _oneCriteriaFolderSetToSQL($aOneCriteriaSet)
 {
     $aSQL = array();
     $aJoinSQL = array();
     $criteria_set = array();
     /*
      * First phase: get criterion object for search or the direct
      * SQL to use.
      *
      * XXX: Why is there $order there? 
      */
     foreach ($aOneCriteriaSet as $order => $dataset) {
         $type = KTUtil::arrayGet($dataset, "type");
         $sql = KTUtil::arrayGet($dataset, "sql");
         if (!empty($type)) {
             $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
             $oCriterion = $oCriteriaRegistry->getCriterion($dataset['type']);
             if (PEAR::isError($oCriterion)) {
                 return PEAR::raiseError(_kt('Invalid criteria specified.'));
             }
             $criteria_set[] = array($oCriterion, $dataset["data"]);
         } else {
             if (!empty($sql)) {
                 $criteria_set[] = $sql;
             } else {
                 return PEAR::raiseError(_kt('Invalid criteria specified.'));
             }
         }
     }
     /*
      * Second phase: Create an individual SQL query per criteria.
      */
     foreach ($criteria_set as $oCriterionPair) {
         $oCriterion->aLookup[table] = 'folder_field_links';
         $oCriterion = $oCriterionPair[0];
         $aReq = $oCriterionPair[1];
         if (is_object($oCriterion)) {
             // changed by dp start // for multiselect search for folders
             if (is_array($aReq[$oCriterion->sNamespace]) && KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin')) {
                 $aNewSQL = array();
                 foreach ($aReq[$oCriterion->sNamespace] as $kkey => $vval) {
                     $newAReq = $aReq;
                     $newAReq[$oCriterion->sNamespace] = $vval;
                     $res = $oCriterion->searchSQL($newAReq);
                     if (!is_null($res)) {
                         $aNewSQL[] = $res;
                     }
                 }
                 $aNewSQL0 = array();
                 $aNewSQL1 = array();
                 foreach ($aNewSQL as $ind => $sQ) {
                     $aNewSQL0[] = $sQ[0];
                     $aNewSQL1 = array_merge($aNewSQL1, $sQ[1]);
                 }
                 $aSQL[] = array(" ( " . join(" ) " . $aReq[$oCriterion->sNamespace . "_join"] . " ( ", $aNewSQL0) . " ) ", $aNewSQL1);
                 $res = $oCriterion->searchJoinSQL();
                 if (!is_null($res)) {
                     if (strstr($res, 'D.metadata_version_id')) {
                         $res = str_replace('D.metadata_version_id', 'F.metadata_version_id', $res);
                     }
                     if (strstr($res, 'document_fields_link')) {
                         $res = str_replace('document_fields_link', 'folder_fields_link', $res);
                     }
                     $aJoinSQL[] = $res;
                 }
             } else {
                 $res = $oCriterion->searchSQL($aReq);
                 if (!is_null($res)) {
                     $aSQL[] = $res;
                 }
                 $res = $oCriterion->searchJoinSQL();
                 if (!is_null($res)) {
                     if (strstr($res, 'D.metadata_version_id')) {
                         $res = str_replace('D.metadata_version_id', 'F.metadata_version_id', $res);
                     }
                     if (strstr($res, 'document_fields_link')) {
                         $res = str_replace('document_fields_link', 'folder_fields_link', $res);
                     }
                     $aJoinSQL[] = $res;
                 }
             }
         } else {
             $aSQL[] = array($oCriterion, $aReq);
         }
     }
     /*
      * Third phase: build up $aCritQueries and $aCritParams, and put
      * parentheses around them.
      */
     $aCritParams = array();
     $aCritQueries = array();
     foreach ($aSQL as $sSQL) {
         if (is_array($sSQL)) {
             $aCritQueries[] = '(' . $sSQL[0] . ')';
             $aCritParams = kt_array_merge($aCritParams, $sSQL[1]);
         } else {
             $aCritQueries[] = '(' . $sSQL . ')';
         }
     }
     if (count($aCritQueries) == 0) {
         return PEAR::raiseError(_kt("No search criteria were specified"));
     }
     return array($aCritQueries, $aCritParams, $aJoinSQL);
 }
コード例 #6
0
ファイル: BulkUpload.php プロジェクト: 5haman/knowledgetree
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("bulk upload"));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/bulkUpload');
     $add_fields = array();
     $add_fields[] = new KTFileUploadWidget(_kt('Archive file'), _kt('The archive file containing the documents you wish to add to the document management system.'), 'file', "", $this->oPage, true, "file");
     $aVocab = array('' => _kt('- Please select a document type -'));
     foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) {
         if (!$oDocumentType->getDisabled()) {
             $aVocab[$oDocumentType->getId()] = $oDocumentType->getName();
         }
     }
     $fieldOptions = array("vocab" => $aVocab);
     $add_fields[] = new KTLookupWidget(_kt('Document Type'), _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), 'fDocumentTypeId', null, $this->oPage, true, "add-document-type", $fieldErrors, $fieldOptions);
     $fieldsets = array();
     $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton();
     $activesets = KTFieldset::getGenericFieldsets();
     foreach ($activesets as $oFieldset) {
         $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
         array_push($fieldsets, new $displayClass($oFieldset));
     }
     // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes
     global $default;
     $iFolderId = $this->oFolder->getId();
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to perform a bulk upload');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.bulk_upload', 'bulk', 'bulk_upload_form', 'submit', {$iFolderId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
     }
     $oTemplate->setData(array('context' => &$this, 'submit' => $submit, 'add_fields' => $add_fields, 'generic_fieldsets' => $fieldsets));
     return $oTemplate->render();
 }
コード例 #7
0
 function setupAdmin()
 {
     // set up the categories.
     $this->registerAdminCategory('principals', _kt('Users and Groups'), _kt('Control which users can log in, and are part of which groups and organisational units, from these management panels.'));
     $this->registerAdminCategory('security', _kt('Security Management'), _kt('Assign permissions to users and groups, and specify which permissions are required to interact with various parts of the Document Management System.'));
     //$this->registerAdminCategory("plugins", _kt("Plugin Management"),
     //    _kt("Control which plugins are loaded, register new plugins and configure individual plugins."));
     $this->registerAdminCategory('storage', _kt('Document Storage'), _kt('Manage checked-out, archived and deleted documents.'));
     $this->registerAdminCategory('documents', _kt('Document Metadata and Workflow Configuration'), _kt('Configure the document metadata: Document Types, Document Fieldsets, Link Types and Workflows.'));
     $this->registerAdminCategory('search', _kt('Search and Indexing'), _kt('Search and Indexing Settings'));
     $this->registerAdminCategory('config', _kt('System Configuration'), _kt('System Configuration Settings'));
     $this->registerAdminCategory('misc', _kt('Miscellaneous'), _kt('Various settings which do not fit into the other categories, including managing help and saved searches.'));
     // users and groups
     $this->registerAdminPage('users', 'KTUserAdminDispatcher', 'principals', _kt('Manage Users'), _kt('Add or remove users from the system.'), 'admin/userManagement.php', null);
     $this->registerAdminPage('groups', 'KTGroupAdminDispatcher', 'principals', _kt('Manage Groups'), _kt('Add or remove groups from the system.'), 'admin/groupManagement.php', null);
     $this->registerAdminPage('units', 'KTUnitAdminDispatcher', 'principals', _kt('Control Units'), _kt('Specify which organisational units are available within the repository.'), 'admin/unitManagement.php', null);
     // security
     $this->registerAdminPage('permissions', 'ManagePermissionsDispatcher', 'security', _kt('Permissions'), _kt('Create or delete permissions.'), 'admin/managePermissions.php', null);
     $this->registerAdminPage('roles', 'RoleAdminDispatcher', 'security', _kt('Roles'), _kt('Create or delete roles'), 'admin/roleManagement.php', null);
     $this->registerAdminPage('conditions', 'KTConditionDispatcher', 'security', _kt('Dynamic Conditions'), _kt('Manage criteria which determine whether a user is permitted to perform a system action.'), 'admin/conditions.php', null);
     // documents
     $this->registerAdminPage('typemanagement', 'KTDocumentTypeDispatcher', 'documents', _kt('Document Types'), _kt('Manage the different classes of document which can be added to the system.'), 'admin/documentTypes.php', null);
     $this->registerAdminPage('fieldmanagement2', 'KTDocumentFieldDispatcher', 'documents', _kt('Document Fieldsets'), _kt('Manage the different types of information that can be associated with classes of documents.'), 'admin/documentFieldsv2.php', null);
     if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         $this->registerAdminPage('emailtypemanagement', 'KTEmailDocumentTypeDispatcher', 'documents', _kt('Email Document Types'), _kt('Manage the addition of Email document types to the system.'), '../wintools/email/emailDocumentTypes.php', null);
     }
     $this->registerAdminPage('workflows_2', 'KTWorkflowAdminV2', 'documents', _kt('Workflows'), _kt('Configure automated Workflows that map to document life-cycles.'), 'admin/workflowsv2.php', null);
     // storage
     $this->registerAdminPage('checkout', 'KTCheckoutAdminDispatcher', 'storage', _kt('Checked Out Document Control'), _kt('Override the checked-out status of documents if a user has failed to do so.'), 'admin/documentCheckout.php', null);
     $this->registerAdminPage('archived', 'ArchivedDocumentsDispatcher', 'storage', _kt('Archived Document Restoration'), _kt('Restore old (archived) documents, usually at a user\'s request.'), 'admin/archivedDocuments.php', null);
     $this->registerAdminPage('expunge', 'DeletedDocumentsDispatcher', 'storage', _kt('Restore or Expunge Deleted Documents'), _kt('Restore previously deleted documents, or permanently expunge them.'), 'admin/deletedDocuments.php', null);
     //Search and Indexing
     $this->registerAdminPage('managemimetypes', 'ManageMimeTypesDispatcher', 'search', _kt('Mime Types'), sprintf(_kt('This report lists all mime types and extensions that can be identified by %s.'), APP_NAME), '../search2/reporting/ManageMimeTypes.php', null);
     $this->registerAdminPage('extractorinfo', 'ExtractorInfoDispatcher', 'search', _kt('Extractor Information'), _kt('This report lists the text extractors and their supported mime types.'), '../search2/reporting/ExtractorInfo.php', null);
     $this->registerAdminPage('indexerrors', 'IndexErrorsDispatcher', 'search', _kt('Document Indexing Diagnostics'), _kt('This report will help to diagnose problems with document indexing.'), '../search2/reporting/IndexErrors.php', null);
     $this->registerAdminPage('pendingdocuments', 'PendingDocumentsDispatcher', 'search', _kt('Pending Documents Indexing Queue'), _kt('This report lists documents that are waiting to be indexed.'), '../search2/reporting/PendingDocuments.php', null);
     $this->registerAdminPage('reschedulealldocuments', 'RescheduleDocumentsDispatcher', 'search', _kt('Reschedule all documents'), _kt('This function allows you to re-index your entire repository.'), '../search2/reporting/RescheduleDocuments.php', null);
     // Admin Pages for Previous Dashlets
     $this->registerAdminPage('indexingstatus', 'IndexingStatusDispatcher', 'search', _kt('Document Indexer and External Resource Dependancy Status'), _kt('This report will show the status of external dependencies and the document indexer.'), '../search2/reporting/IndexingStatus.php', null);
     $this->registerAdminPage('lucenestatistics', 'LuceneStatisticsDispatcher', 'search', _kt('Document Indexer Statistics'), _kt('This report will show the Lucene Document Indexing Statistics '), '../search2/reporting/LuceneStatistics.php', null);
     //config
     $this->registerAdminPage('emailconfigpage', 'EmailConfigPageDispatcher', 'config', _kt('Email'), _kt('Define the sending email server address, email password, email port, and user name, and view and modify policies for emailing documents and attachments from KnowledgeTree.'), 'admin/configSettings.php', null);
     $this->registerAdminPage('uiconfigpage', 'UIConfigPageDispatcher', 'config', _kt('User Interface'), _kt('View and modify settings on Browse View actions, OEM name, automatic refresh, search results restrictions, custom logo details, paths to dot binary, graphics, and log directory, and whether to enable/disable condensed UI, \'open\' from downloads, sort metadata, and skinning.'), 'admin/configSettings.php', null);
     $this->registerAdminPage('searchandindexingconfigpage', 'SearchAndIndexingConfigPageDispatcher', 'config', _kt('Search and Indexing'), _kt('View and modify the number of documents indexed / migrated in a cron session, core indexing class, paths to the extractor hook, text extractors, indexing engine, Lucene indexes, and the Java Lucene URL. View and modify search date format, paths to search, indexing fields and libraries, results display format, and results per page.'), 'admin/configSettings.php', null);
     $this->registerAdminPage('clientconfigpage', 'ClientSettingsConfigPageDispatcher', 'config', _kt('Client Tools'), _kt('View and change settings for the KnowledgeTree Tools Server, Client Tools Policies, WebDAV, and the OpenOffice.org service.'), 'admin/configSettings.php', null);
     $this->registerAdminPage('generalconfigpage', 'GeneralConfigPageDispatcher', 'config', _kt('General Settings'), _kt('View and modify settings for the KnowledgeTree cache, custom error message handling, Disk Usage threshold percentages, location of zip binary, paths to external binaries, general server configuration, LDAP authentication, session management, KnowledgeTree storage manager, miscellaneous tweaks, and whether to always display \'Your Checked-out Documents\' dashlet.'), 'admin/configSettings.php', null);
     $this->registerAdminPage('i18nconfigpage', 'i18nConfigPageDispatcher', 'config', _kt('Internationalization'), _kt('View and modify the default language.'), 'admin/configSettings.php', null);
     $this->registerAdminPage('securityconfigpage', 'SecurityConfigPageDispatcher', 'config', _kt('Security'), _kt('View and modify the security settings.'), 'admin/configSettings.php', null);
     // misc
     $this->registerAdminPage('helpmanagement', 'ManageHelpDispatcher', 'misc', _kt('Edit Help files'), _kt('Change the help files that are displayed to users.'), 'admin/manageHelp.php', null);
     $this->registerAdminPage('plugins', 'KTPluginDispatcher', 'misc', _kt('Manage plugins'), _kt('Register new plugins, disable plugins, and so forth'), 'admin/plugins.php', null);
     $this->registerAdminPage('techsupport', 'KTSupportDispatcher', 'misc', _kt('Support and System information'), _kt('Information about this system and how to get support.'), 'admin/techsupport.php', null);
     $this->registerAdminPage('cleanup', 'ManageCleanupDispatcher', 'storage', _kt('Verify Document Storage'), _kt('Performs a check to see if the documents in your repositories all are stored on the back-end storage (usually on disk).'), 'admin/manageCleanup.php', null);
     $this->registerAdminPage('views', 'ManageViewDispatcher', 'misc', _kt('Manage views'), _kt('Allows you to specify the columns that are to be used by a particular view (e.g. Browse documents, Search)'), 'admin/manageViews.php', null);
     // plugins
 }
コード例 #8
0
ファイル: edit.php プロジェクト: 5haman/knowledgetree
 function do_update()
 {
     $oForm = $this->form_edit();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     // we need to format these in MDPack format
     // which is a little archaic:
     //
     //  array(
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //  );
     //
     // we do this the "easy" way.
     $doctypeid = $this->oDocument->getDocumentTypeId();
     if ($_REQUEST['new_type']) {
         $oTestType = DocumentType::get($_REQUEST['new_type']);
         if (!PEAR::isError($oTestType)) {
             $doctypeid = $oTestType->getId();
         }
     }
     $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $doctypeid);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             // for html fields we want to do some stripping :)
             if ($oField->getIsHTML()) {
                 // NOTE this works great...once the text is saved a first time
                 //      but the first time the <script> tags come through encoded, so decode first
                 // HOWEVER html_entity_decode decodes too much (e.g. &nbsp; - which causes a DB error for some reason)!  use this instead
                 // NOTE I considered a preg_replace_callback but str_replace is probably more efficient in this case as we only have
                 //      two symbols to replace
                 $val = str_replace('&lt;', '<', $val);
                 $val = str_replace('&gt;', '>', $val);
                 //$val = preg_replace_callback('/&lt;([^&]*)&gt;/', create_function('$matches', 'return "<" . $matches[1] . ">";'), $val);
                 // in case of script which does not yet contain <!-- //--> around the actual code (i.e. first submission again)
                 // these will not be correctly removed by strip_tags
                 $val = preg_replace('/<script[^>]*>([^<]*)<\\/script>/', '', $val);
                 // remove any attempts to call an onclick/onmouseover/onwhatever call
                 $val = preg_replace_callback('/on[^= ]*=[^; \\/>]*;?"? *\\/? *(>?)/', create_function('$matches', 'if (isset($matches[1])) return $matches[1]; else return null;'), $val);
                 // now strip remaining tags including script tags with code surrounded by <!-- //-->,
                 // which would not be stripped by the previous regex
                 $val = strip_tags($val, '<p><a><b><strong><ol><ul><li><p><br><i><em><u><span>');
                 // remove empty <p> tags?
                 $val = preg_replace('/<p><\\/p>\\r?\\n?/', '', $val);
             }
             if ($oField->getDataType() == "LARGE TEXT" && !is_null($oField->getMaxLength())) {
                 if (strlen(strip_tags($val)) > $oField->getMaxLength()) {
                     $oForm->handleError(sprintf(_kt("Value exceeds max allowed length of %d characters for %s. Current value is %d characters."), $oField->getMaxLength(), $oField->getName(), strlen(strip_tags($val))));
                 }
             }
             // FIXME "null" has strange meanings here.
             if (!is_null($val)) {
                 if (KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && is_array($val) && $oField->getHasInetLookup()) {
                     $val = join(", ", $val);
                 }
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     $this->startTransaction();
     if ($this->oDocument->getDocumentTypeId() != $doctypeid) {
         $this->oDocument->setDocumentTypeId($doctypeid);
     }
     $this->oDocument->setName($data['document_title']);
     $this->oDocument->setLastModifiedDate(getCurrentDateTime());
     $this->oDocument->setModifiedUserId($this->oUser->getId());
     // Update the content version / document version
     global $default;
     if ($default->updateContentVersion) {
         $this->oDocument->startNewContentVersion($this->oUser);
         $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber() + 1);
     } else {
         $this->oDocument->startNewMetadataVersion($this->oUser);
     }
     $res = $this->oDocument->update();
     if (PEAR::isError($res)) {
         $oForm->handleError(sprintf(_kt("Unexpected failure to update document title: %s"), $res->getMessage()));
     }
     $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack);
     if (PEAR::isError($core_res)) {
         $oForm->handleError(sprintf(_kt("Unexpected validation failure: %s."), $core_res->getMessage()));
     }
     // post-triggers.
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->oDocument, "aOptions" => $MDPack);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
     $this->commitTransaction();
     // create the document transaction record
     $oDocumentTransaction =& new DocumentTransaction($this->oDocument, _kt('Document metadata updated'), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     // Check if there are any dynamic conditions / permissions that need to be updated on the document
     // If there are dynamic conditions then update the permissions on the document
     // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction.
     $iPermissionObjectId = $this->oDocument->getPermissionObjectID();
     $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId);
     if (!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)) {
         $res = KTPermissionUtil::updatePermissionLookup($this->oDocument);
     }
     redirect(KTBrowseUtil::getUrlForDocument($this->oDocument->getId()));
     exit(0);
 }
コード例 #9
0
ファイル: plugins.php プロジェクト: sfsergey/knowledgetree
 function do_update()
 {
     $sTable = KTUtil::getTableName('plugins');
     $aIds = (array) KTUtil::arrayGet($_REQUEST, 'pluginids');
     // Update disabled plugins
     $sIds = implode(',', $aIds);
     $sQuery = "UPDATE {$sTable} SET disabled = 1 WHERE id NOT IN ({$sIds})";
     DBUtil::runQuery(array($sQuery));
     // Select disabled plugins that have been enabled
     $sQuery = "SELECT * FROM {$sTable} WHERE disabled = 1 AND id IN ({$sIds})";
     $res = DBUtil::getResultArray($sQuery);
     if (!PEAR::isError($res)) {
         // Enable the disabled plugins
         $sQuery = "UPDATE {$sTable} SET disabled = 0 WHERE id IN ({$sIds})";
         DBUtil::runQuery(array($sQuery));
         // run setup for each plugin
         $aEnabled = array();
         if (!empty($res)) {
             foreach ($res as $item) {
                 $aEnabled[] = $item['id'];
             }
             $sEnabled = implode(',', $aEnabled);
             $sQuery = "SELECT h.classname, h.pathname FROM {$sTable} p\n                    INNER JOIN plugin_helper h ON (p.namespace = h.plugin)\n                    WHERE classtype = 'plugin' AND p.id IN ({$sEnabled})";
             $res = DBUtil::getResultArray($sQuery);
             if (!PEAR::isError($res)) {
                 foreach ($res as $item) {
                     $classname = $item['classname'];
                     $path = $item['pathname'];
                     if (!empty($path)) {
                         require_once $path;
                     }
                     $oPlugin = new $classname($path);
                     $oPlugin->setup();
                 }
             }
         }
     }
     KTPluginEntity::clearAllCaches();
     // FIXME!!! Plugin manager needs to be updated to deal with this situation. This code should be in the plugin.
     //enabling or disabling Tag fieldset depending on whether tag cloud plugin is enabled or disabled.
     //Get tag cloud object
     $oTagClouPlugin = KTPluginEntity::getByNamespace('ktcore.tagcloud.plugin');
     if (!PEAR::isError($oTagClouPlugin) && !is_a($oTagClouPlugin, 'KTEntityNoObjects') && !is_null($oTagClouPlugin)) {
         if ($oTagClouPlugin->getDisabled() == '1') {
             //disable tag fieldset
             $aFV = array('disabled' => true);
             $aWFV = array('namespace' => 'tagcloud');
             $res = DBUtil::whereUpdate('fieldsets', $aFV, $aWFV);
         } else {
             //enable tag fieldset
             $aFV = array('disabled' => false);
             $aWFV = array('namespace' => 'tagcloud');
             $res = DBUtil::whereUpdate('fieldsets', $aFV, $aWFV);
         }
     }
     // we reregister the plugins to ensure they are in the correct order
     KTPluginUtil::registerPlugins();
     $this->successRedirectToMain(_kt('Plugins updated'));
 }
コード例 #10
0
 function render()
 {
     global $default;
     $oConfig = KTConfig::getSingleton();
     if (empty($this->contents)) {
         $this->contents = "";
     }
     if (is_string($this->contents) && trim($this->contents) === "") {
         $this->addError(_kt("This page did not produce any content"));
         $this->contents = "";
     }
     if (!is_string($this->contents)) {
         $this->contents = $this->contents->render();
     }
     // if we have no portlets, make the ui a tad nicer.
     if (empty($this->portlets)) {
         $this->show_portlets = false;
     }
     if (empty($this->title)) {
         if (!empty($this->breadcrumbDetails)) {
             $this->title = $this->breadcrumbDetails;
         } else {
             if (!empty($this->breadcrumbs)) {
                 $this->title = array_slice($this->breadcrumbs, -1);
                 $this->title = $this->title[0]['label'];
             } else {
                 if (!empty($this->breadcrumbSection)) {
                     $this->title = $this->breadcrumbSection['label'];
                 } else {
                     $this->title = $this->componentLabel;
                 }
             }
         }
     }
     $this->userMenu = array();
     $sBaseUrl = KTUtil::kt_url();
     if (!(PEAR::isError($this->user) || is_null($this->user) || $this->user->isAnonymous())) {
         if ($oConfig->get("user_prefs/restrictPreferences", false) && !Permission::userIsSystemAdministrator($this->user->getId())) {
             $this->userMenu['logout'] = array('label' => _kt('Logout'), 'url' => $sBaseUrl . '/presentation/logout.php');
         } else {
             if ($default->enableESignatures) {
                 $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
                 $heading = _kt('You are attempting to modify Preferences');
                 $this->userMenu['preferences']['url'] = '#';
                 $this->userMenu['preferences']['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'dms.administration.accessing_preferences', 'system', '{$sBaseUrl}/preferences.php', 'redirect');";
             } else {
                 $this->userMenu['preferences']['url'] = $sBaseUrl . '/preferences.php';
             }
             //	        $this->userMenu['preferences'] = array('label' => _kt('Preferences'), 'url' => $sBaseUrl.'/preferences.php');
             $this->userMenu['preferences']['label'] = _kt('Preferences');
             $this->userMenu['aboutkt'] = array('label' => _kt('About'), 'url' => $sBaseUrl . '/about.php');
             $this->userMenu['logout'] = array('label' => _kt('Logout'), 'url' => $sBaseUrl . '/presentation/logout.php');
         }
     } else {
         $this->userMenu['login'] = array('label' => _kt('Login'), 'url' => $sBaseUrl . '/login.php');
     }
     // FIXME we need a more complete solution to navigation restriction
     if (!is_null($this->menu['administration']) && !is_null($this->user)) {
         if (!Permission::userIsSystemAdministrator($this->user->getId())) {
             unset($this->menu['administration']);
         }
     }
     $sContentType = 'Content-type: ' . $this->contentType;
     if (!empty($this->charset)) {
         $sContentType .= '; charset=' . $this->charset;
     }
     header($sContentType);
     $savedSearches = SearchHelper::getSavedSearches($_SESSION['userID']);
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate($this->template);
     $aTemplateData = array("page" => $this, "systemversion" => $default->systemVersion, "versionname" => $default->versionName, 'smallVersion' => substr($default->versionName, -17), 'savedSearches' => $savedSearches);
     if ($oConfig->get("ui/automaticRefresh", false)) {
         $aTemplateData['refreshTimeout'] = (int) $oConfig->get("session/sessionTimeout") + 3;
     }
     // unlike the rest of KT, we use echo here.
     echo $oTemplate->render($aTemplateData);
 }
コード例 #11
0
 function do_change_enabled()
 {
     $this->startTransaction();
     $iLicenses = 0;
     $bRequireLicenses = false;
     if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         $path = KTPluginUtil::getPluginPath('ktdms.wintools');
         require_once $path . 'baobabkeyutil.inc.php';
         $iLicenses = BaobabKeyUtil::getLicenseCount();
         $bRequireLicenses = true;
     }
     // admin and anonymous are automatically ignored here.
     $iEnabledUsers = User::getNumberEnabledUsers();
     if ($_REQUEST['update_value'] == 'enable') {
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             // check that we haven't hit max user limit
             if ($bRequireLicenses && $iEnabledUsers >= $iLicenses) {
                 // if so, add to error messages, but commit transaction (break this loop)
                 $_SESSION['KTErrorMessage'][] = _kt('You may only have ') . $iLicenses . _kt(' users enabled at one time.');
                 break;
             }
             // else enable user
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->enable();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers++;
         }
     }
     if ($_REQUEST['update_value'] == 'disable') {
         //echo 'got into disable';
         //exit;
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->disable();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers--;
         }
     }
     if ($_REQUEST['update_value'] == 'delete') {
         //echo 'Delete called';
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->delete();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers--;
         }
     }
     $this->commitTransaction();
     $this->successRedirectToMain(_kt('Users updated'));
 }
コード例 #12
0
ファイル: admin.php プロジェクト: 5haman/knowledgetree
$sub_url = trim($sub_url);
$sub_url = trim($sub_url, '/');
if (empty($sub_url)) {
    $oDispatcher = new AdminSplashDispatcher();
} else {
    $oRegistry =& KTAdminNavigationRegistry::getSingleton();
    if ($oRegistry->isRegistered($sub_url)) {
        $oDispatcher = $oRegistry->getDispatcher($sub_url);
        $aParts = explode('/', $sub_url);
        $oRegistry =& KTAdminNavigationRegistry::getSingleton();
        $aCategory = $oRegistry->getCategory($aParts[0]);
        $oDispatcher->aBreadcrumbs = array();
        $oDispatcher->aBreadcrumbs[] = array('action' => 'administration', 'name' => _kt('Administration'));
        $oDispatcher->aBreadcrumbs[] = array('name' => $aCategory['title'], 'url' => KTUtil::ktLink('admin.php', $aParts[0]));
    } else {
        // FIXME (minor) redirect to no-suburl?
        $oDispatcher = new AdminSplashDispatcher();
        $oDispatcher->category = $sub_url;
    }
}
// Implement an electronic signature for accessing the admin section, it will appear every 10 minutes
global $main;
global $default;
if ($default->enableAdminSignatures && $_SESSION['electronic_signature_time'] < time()) {
    $sBaseUrl = KTUtil::kt_url();
    $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
    $heading = _kt('You are attempting to access Administration');
    $main->setBodyOnload("javascript: showSignatureForm('{$sUrl}', '{$heading}', 'dms.administration.administration_section_access', 'admin', '{$sBaseUrl}/browse.php', 'close');");
}
$oDispatcher->dispatch();
// we _may_ be redirected at this point (see KTAdminNavigation)
コード例 #13
0
 private function getThumbnail()
 {
     $sInfo = '';
     // Check for existence of thumbnail plugin
     if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) {
         // hook into thumbnail plugin to get display for thumbnail
         include_once KT_DIR . '/plugins/thumbnails/thumbnails.php';
         $thumbnailer = new ThumbnailViewlet();
         $thumbnailer->setDocument($this->_oDocument);
         $thumbnailDisplay = $thumbnailer->renderThumbnail($this->_IDocId);
         if ($thumbnailDisplay != '') {
             $sInfo = "<div>{$thumbnailDisplay}</div>";
         }
     }
     return $sInfo;
 }
コード例 #14
0
 function do_editRoleGroups()
 {
     $iFolderId = $this->oFolder->getId();
     $role_allocation_id = KTUtil::arrayGet($_REQUEST, 'alloc_id');
     if ($iFolderId == 1 && is_null($role_allocation_id)) {
         $oRoleAllocation = $this->rootoverride($_REQUEST['role_id']);
     } else {
         $oRoleAllocation = RoleAllocation::get($role_allocation_id);
     }
     if (PEAR::isError($oRoleAllocation) || $oRoleAllocation === false) {
         $this->errorRedirectToMain(_kt('No such role allocation.'), sprintf('fFolderId=%d', $iFolderId));
     }
     $oRole = Role::get($oRoleAllocation->getRoleId());
     $this->oPage->setBreadcrumbDetails(_kt('Manage Groups for Role'));
     $this->oPage->setTitle(sprintf(_kt('Manage Groups for Role "%s"'), $oRole->getName()));
     $initJS = 'var optGroup = new OptionTransfer("groupSelect","chosenGroups"); ' . 'function startTrans() { var f = getElement("grouproleform"); ' . ' optGroup.saveNewRightOptions("groupFinal"); ' . ' optGroup.init(f); }; ' . ' addLoadEvent(startTrans); ';
     $this->oPage->requireJSStandalone($initJS);
     $aInitialUsers = $oRoleAllocation->getGroups();
     $aAllUsers = Group::getList();
     // FIXME this is massively non-performant for large userbases..
     $aRoleUsers = array();
     $aFreeUsers = array();
     foreach ($aInitialUsers as $oGroup) {
         $aRoleUsers[$oGroup->getId()] = $oGroup;
     }
     foreach ($aAllUsers as $oGroup) {
         if (!array_key_exists($oGroup->getId(), $aRoleUsers)) {
             $aFreeUsers[$oGroup->getId()] = $oGroup;
         }
     }
     // Include the electronic signature on the permissions action
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to modify roles');
         $input['type'] = 'button';
         $input['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.role_allocations_change', 'folder', 'grouproleform', 'submit', {$iFolderId});";
     } else {
         $input['type'] = 'submit';
         $input['onclick'] = '';
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("ktcore/folder/roles_managegroups");
     $aTemplateData = array("context" => $this, "edit_rolealloc" => $oRoleAllocation, 'unused_groups' => $aFreeUsers, 'role_groups' => $aRoleUsers, 'rolename' => $oRole->getName(), 'input' => $input);
     return $oTemplate->render($aTemplateData);
 }
コード例 #15
0
 /**
  * Edits fields
  * @return template
  * 
  * iNET Process
  */
 function do_edit()
 {
     // here we engage in some major evil.
     // we check for the subevent var
     // and subdispatch if appropriate.
     //
     // saves a little code-duplication (actually, a lot of code-duplication)
     // FIXME this is essentially a stub for the fieldset-delegation code.
     if ($this->oFieldset->getIsConditional()) {
         require_once KT_DIR . '/plugins/ktcore/admin/fieldsets/conditional.inc.php';
         $oSubDispatcher = new ConditionalFieldsetManagementDispatcher();
     } else {
         // multiselect change start
         if (KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin')) {
             require_once KT_DIR . '/plugins/multiselect/inetbasic.inc.php';
             $oSubDispatcher = new InetBasicFieldsetManagementDispatcher();
         } else {
             require_once KT_DIR . '/plugins/ktcore/admin/fieldsets/basic.inc.php';
             $oSubDispatcher = new BasicFieldsetManagementDispatcher();
         }
         // multiselect change end
     }
     $subevent_var = 'fieldset_action';
     $subevent = KTUtil::arrayGet($_REQUEST, $subevent_var);
     if (!empty($subevent)) {
         // do nothing, since this will handle everything
         $this_url = KTUtil::addQueryStringSelf($this->meldPersistQuery("", "edit"));
         $oSubDispatcher->redispatch($subevent_var, null, $this, $this_url);
         exit(0);
     } else {
         // what we want is the "additional info" section
         $additional = $oSubDispatcher->describe_fieldset($this->oFieldset);
     }
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/metadata/admin/edit');
     $oTemplate->setData(array('context' => $this, 'fieldset_name' => $this->oFieldset->getName(), 'additional' => $additional));
     return $oTemplate->render();
 }
コード例 #16
0
ファイル: ktapi.inc.php プロジェクト: 5haman/knowledgetree
 /**
  * Method to check whether electronic signatures are enabled
  *
  * @author KnowledgeTree Team
  * @access public
  * @return bool $enabled true or false
  */
 public function electronic_sig_enabled()
 {
     // Check that the wintools plugin is active and available, return false if not.
     if (!KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         return false;
     }
     // Check config for api signatures enabled
     $oConfig =& KTConfig::getSingleton();
     $enabled = $oConfig->get('e_signatures/enableApiSignatures', false);
     // Check that the license is valid
     $enabled = BaobabKeyUtil::getLicenseCount() >= MIN_LICENSES & $enabled;
     return $enabled;
 }
コード例 #17
0
ファイル: BulkUpload.php プロジェクト: 5haman/knowledgetree
 /**
  * make uploads
  * @return
  *
  * iNET Process
  */
 function do_upload()
 {
     set_time_limit(0);
     global $default;
     $aErrorOptions = array('redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())));
     $aErrorOptions['message'] = _kt('Invalid document type provided');
     $requestDocumentType = $_REQUEST['fDocumentTypeId'];
     //Backwards compatibility
     if ($requestDocumentType == '' || $requestDocumentType == NULL) {
         $requestDocumentType = $_REQUEST['data'];
         $requestDocumentType = $requestDocumentType['fDocumentTypeId'];
         //New elements come through as arrays
     }
     $oDocumentType = $this->oValidator->validateDocumentType($requestDocumentType, $aErrorOptions);
     unset($aErrorOptions['message']);
     $fileData = $_FILES['file'];
     $fileName = 'file';
     if ($fileData == '' || $fileData == NULL) {
         $fileData = $_FILES['_kt_attempt_unique_file'];
         //$_FILES['_kt_attempt_unique_file'];
         $fileName = '_kt_attempt_unique_file';
     }
     $aFile = $this->oValidator->validateFile($fileData, $aErrorOptions);
     // Lets move the file from the windows temp directory into our own directory
     $oKTConfig =& KTConfig::getSingleton();
     $sBasedir = $oKTConfig->get("urls/tmpDirectory");
     $tmpFilename = tempnam($sBasedir, 'kt_storebulk');
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $res = $oStorage->uploadTmpFile($fileData['tmp_name'], $tmpFilename, array('copy_upload' => 'true'));
     // Save the new temp filename in the file data array
     $fileData['tmp_name'] = $tmpFilename;
     if ($res === false) {
         $default->log->error('File could not be copied from the system temp directory.');
         exit('File could not be copied from the system temp directory.');
     }
     $matches = array();
     $aFields = array();
     // author: Charl Mert
     // Older kt3 form field submission used name='metadata_9 etc and the aFields array contained them.'
     // Should keep open here for backwards compatibility but will close it to "discover" the other
     // old interfaces.
     /*
     foreach ($_REQUEST as $k => $v) {
     	if (preg_match('/^metadata_(\d+)$/', $k, $matches)) {
     		// multiselect change start
     		$oDocField = DocumentField::get($matches[1]);
     
     		if(KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && $oDocField->getHasInetLookup() && is_array($v))
     		{
     			$v = join(", ", $v);
     		}
     		$aFields[] = array($oDocField, $v);
     
     		// previously it was just one line which is commented, just above line
     		// multiselect change end
     	}
     }
     */
     //Newer metadata form field catcher that works with ktcore form array type fields named like
     //name='metadata[fieldset][metadata_9]'
     $aData = $_REQUEST['data'];
     /* //This validation breaks with ajax loaded form items e.g. a non generic fieldset that submits
     		 * //values doesn't pass the check below.
     		$oForm = $this->getBulkUploadForm();
             $res = $oForm->validate();
             if (!empty($res['errors'])) {
                 return $oForm->handleError();
             }
             $data = $res['results'];
             var_dump($data);
             */
     $data = $aData;
     $doctypeid = $requestDocumentType;
     $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false));
     $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false));
     $fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         //var_dump($values);
         foreach ($fields as $oField) {
             //var_dump($oField->getId());
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             //Fix for multiselect not submitting data due to the value not being flat.
             $sVal = '';
             if (is_array($val)) {
                 foreach ($val as $v) {
                     $sVal .= $v . ", ";
                 }
                 $sVal = substr($sVal, 0, strlen($sVal) - 2);
                 $val = $sVal;
             }
             if ($oFieldset->getIsConditional()) {
                 if ($val == _kt('No selection.')) {
                     $val = null;
                 }
             }
             if (!is_null($val)) {
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     $aOptions = array('documenttype' => $oDocumentType, 'metadata' => $MDPack);
     $fs =& new KTZipImportStorage($fileName, $fileData);
     if (!$fs->CheckFormat()) {
         $sFormats = $fs->getFormats();
         $this->addErrorMessage(sprintf(_kt("Bulk Upload failed. Archive is not an accepted format. Accepted formats are: .%s"), $sFormats));
         controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID());
         exit;
     }
     if (KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) {
         require_once KT_DIR . "/plugins/foldermetadata/import/bulkimport.inc.php";
         $bm =& new KTINETBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
     } else {
         $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
     }
     $this->startTransaction();
     $res = $bm->import();
     $aErrorOptions['message'] = _kt("Bulk Upload failed");
     $this->oValidator->notError($res, $aErrorOptions);
     $this->addInfoMessage(_kt("Bulk Upload successful"));
     $this->commitTransaction();
     controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID());
     exit(0);
 }
コード例 #18
0
ファイル: thumbnails.php プロジェクト: 5haman/knowledgetree
 public function renderThumbnail($documentId)
 {
     // Set up the template
     $oKTTemplating =& KTTemplating::getSingleton();
     $oTemplate =& $oKTTemplating->loadTemplate('thumbnail_viewlet');
     if (is_null($oTemplate)) {
         return '';
     }
     // Check that the thumbnail exists on disk
     global $default;
     $varDir = $default->varDirectory;
     $thumbnailCheck = $varDir . '/thumbnails/' . $documentId . '.jpg';
     // Use correct slashes for windows
     if (strpos(PHP_OS, 'WIN') !== false) {
         $thumbnailCheck = str_replace('/', '\\', $thumbnailCheck);
     }
     // if the thumbnail doesn't exist try to create it
     if (!file_exists($thumbnailCheck)) {
         $thumbnailer = new thumbnailGenerator();
         $thumbnailer->setDocument($this->oDocument);
         $thumbnailer->processDocument();
         // if it still doesn't exist, return an empty string
         if (!file_exists($thumbnailCheck)) {
             return '';
         }
     }
     // check for existence and status of the instant view plugin
     $url = '';
     if (KTPluginUtil::pluginIsActive('instaview.processor.plugin')) {
         require_once KTPluginUtil::getPluginPath('instaview.processor.plugin') . 'instaViewLinkAction.php';
         $ivLinkAction = new instaViewLinkAction();
         $url = $ivLinkAction->getViewLink($documentId, 'document');
     }
     // Get the url to the thumbnail and render it
     // Ensure url has correct slashes
     $sHostPath = KTUtil::kt_url();
     $plugin_path = KTPluginUtil::getPluginPath('thumbnails.generator.processor.plugin');
     $thumbnailUrl = $plugin_path . 'thumbnail_view.php?documentId=' . $documentId;
     $thumbnailUrl = str_replace('\\', '/', $thumbnailUrl);
     $thumbnailUrl = str_replace(KT_DIR, $sHostPath, $thumbnailUrl);
     $oTemplate->setData(array('thumbnail' => $thumbnailUrl, 'url' => $url));
     return $oTemplate->render();
 }
コード例 #19
0
ファイル: Rename.php プロジェクト: 5haman/knowledgetree
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("Rename"));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/rename');
     $fields = array();
     $fields[] = new KTStaticTextWidget(_kt('Current file name'), _kt('The current file name is shown below:'), 'oldfilename', $this->oDocument->getFileName(), $this->oPage, false);
     $fields[] = new KTStringWidget(_kt('New file name'), _kt('The name to which the current file should be renamed.'), 'filename', $this->oDocument->getFileName(), $this->oPage, true);
     // Add an electronic signature
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to rename the document');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.rename', 'document', 'document_rename_form', 'submit', {$this->oDocument->iId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
     }
     $oTemplate->setData(array('context' => &$this, 'fields' => $fields, 'submit' => $submit));
     return $oTemplate->render();
 }
コード例 #20
0
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt('workflow'));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/workflow/documentWorkflow');
     $oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
     $oWorkflow = KTWorkflowUtil::getWorkflowForDocument($oDocument);
     $oWorkflowState = KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
     $oUser =& User::get($_SESSION['userID']);
     // If the document is checked out - set transitions and workflows to empty and set checkedout to true
     $bIsCheckedOut = $this->oDocument->getIsCheckedOut();
     if ($bIsCheckedOut) {
         $aTransitions = array();
         $aWorkflows = array();
         $transition_fields = array();
         $bHasPerm = FALSE;
     } else {
         $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($oDocument, $oUser);
         $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1 ');
         $bHasPerm = false;
         if (KTPermissionUtil::userHasPermissionOnItem($oUser, 'ktcore.permissions.workflow', $oDocument)) {
             $bHasPerm = true;
         }
         $fieldErrors = null;
         $transition_fields = array();
         if ($aTransitions) {
             $aVocab = array();
             foreach ($aTransitions as $oTransition) {
                 if (is_null($oTransition) || PEAR::isError($oTransition)) {
                     continue;
                 }
                 $aVocab[$oTransition->getId()] = $oTransition->showDescription();
             }
             $fieldOptions = array('vocab' => $aVocab);
             $transition_fields[] = new KTLookupWidget(_kt('Transition to perform'), _kt('The transition listed will cause the document to change from its current state to the listed destination state.'), 'fTransitionId', null, $this->oPage, true, null, $fieldErrors, $fieldOptions);
             $transition_fields[] = new KTTextWidget(_kt('Reason for transition'), _kt('Describe why this document qualifies to be changed from its current state to the destination state of the transition chosen.'), 'fComments', '', $this->oPage, true, null, null, array('cols' => 80, 'rows' => 4));
         }
     }
     // Add an electronic signature
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to modify the document workflow');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.modify_workflow', 'document', 'start_workflow_form', 'submit', {$this->oDocument->iId});";
         $heading2 = _kt('You are attempting to transition the document workflow');
         $submit2['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading2}', 'ktcore.transactions.transition_workflow', 'document', 'transition_wf_form', 'submit', {$this->oDocument->iId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
         $submit2['onclick'] = '';
     }
     $aTemplateData = array('oDocument' => $oDocument, 'oWorkflow' => $oWorkflow, 'oState' => $oWorkflowState, 'aTransitions' => $aTransitions, 'aWorkflows' => $aWorkflows, 'transition_fields' => $transition_fields, 'bHasPerm' => $bHasPerm, 'bIsCheckedOut' => $bIsCheckedOut, 'submit' => $submit, 'submit2' => $submit2);
     return $oTemplate->render($aTemplateData);
 }
コード例 #21
0
ファイル: dmsDefaults.php プロジェクト: 5haman/knowledgetree
// site map definition
require_once KT_DIR . '/config/siteMap.inc';
require_once KT_LIB_DIR . '/session/Session.inc';
require_once KT_LIB_DIR . '/session/control.inc';
require_once KT_LIB_DIR . '/plugins/pluginutil.inc.php';
if ($checkup !== true) {
    // Replace function later
    /* ** Get the page being loaded and load the plugins specific to the page ** */
    $sScriptName = $GLOBALS['_SERVER']['SCRIPT_NAME'];
    $sScript = basename($sScriptName);
    $pos = strpos($sScript, '.');
    $sType = substr($sScript, 0, $pos);
    KTPluginUtil::loadPlugins($sType);
}
if ($checkup !== true) {
    if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
        $path = KTPluginUtil::getPluginPath('ktdms.wintools');
        require_once $path . 'baobabkeyutil.inc.php';
        $name = BaobabKeyUtil::getName();
        if ($name) {
            $default->versionName = sprintf('%s %s', $default->versionName, $name);
        }
    } else {
        $default->versionName = $default->versionName . ' ' . _kt('(Community Edition)');
    }
}
if (!extension_loaded('mbstring')) {
    require_once KT_LIB_DIR . '/mbstring.inc.php';
}
require_once KT_LIB_DIR . '/templating/kt3template.inc.php';
$GLOBALS['main'] = new KTPage();
コード例 #22
0
ファイル: search.inc.php プロジェクト: 5haman/knowledgetree
 public static function getFields($fieldsetID)
 {
     if ($fieldsetID < 0) {
         $documentTypeID = sanitizeForSQL(-$fieldsetID);
         if (KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin')) {
             $sql = "SELECT\n\t\t\t\t\t\tdf.id, df.name, df.data_type, df.has_lookup,df.has_inetlookup, df.inetlookup_type , df.has_lookuptree, df.description\n\t\t\t\t\tFROM\n\t\t\t\t\t\tdocument_type_fields_link dtfl\n\t\t\t\t        \tINNER JOIN  document_fields df on dtfl.field_id=df.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tdtfl.document_type_id={$documentTypeID}\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tdf.name";
         } else {
             $sql = "SELECT\n\t\t\t\t\t\t\t\t\tdf.id, df.name, df.data_type, df.has_lookup, df.has_lookuptree, df.description\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tdocument_type_fields_link dtfl\n\t\t\t\t\t\t\t\t\tINNER JOIN  document_fields df on dtfl.field_id=df.id\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tdtfl.document_type_id={$documentTypeID}\n\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\tdf.name";
         }
     } else {
         $fieldsetID = sanitizeForSQL($fieldsetID);
         if (KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin')) {
             $sql = "SELECT id, name, data_type, has_lookup,has_inetlookup, inetlookup_type, has_lookuptree, description FROM document_fields WHERE parent_fieldset={$fieldsetID} ORDER BY name";
         } else {
             $sql = "SELECT id, name, data_type, has_lookup, has_lookuptree, description FROM document_fields WHERE parent_fieldset={$fieldsetID} ORDER BY name";
         }
     }
     $rs = DBUtil::getResultArray($sql);
     if (PEAR::isError($rs)) {
         return $rs;
     }
     if (count($rs) == 0) {
         return new PEAR_Error(_kt('Fieldset was not found'));
     }
     $result = array();
     foreach ($rs as $item) {
         $fieldid = $item['id'];
         $type = 'normal';
         $options = array();
         $haslookup = $item['has_lookup'] + 0 > 0;
         $hastree = $item['has_lookuptree'] + 0 > 1;
         $hasinetlookup = $item['has_inetlookup'] + 0 > 0;
         if ($haslookup || $hastree || $hasinetlookup) {
             $type = 'lookup';
             $sql = "select id, name from metadata_lookup where document_field_id={$fieldid}";
             $options = DBUtil::getResultArray($sql);
         }
         $inetlookup_type = "";
         if ($hasinetlookup) {
             $type = 'inetlookup';
             $inetlookup_type = $item['inetlookup_type'];
         }
         /*if ($hastree)
         		{
         			$type = 'lookup';
         			$sql = "select id, name, metadata_lookup_tree_parent as parent from metadata_lookup_tree where document_field_id=$fieldid";
         			$options = DBUtil::getResultArray($sql);
         		}*/
         if ($item['data_type'] == 'USERLIST') {
             $type = 'lookup';
             $sql = "SELECT id, name from users WHERE disabled=0";
             $options = DBUtil::getResultArray($sql);
         }
         $ritem = array('id' => $fieldid, 'name' => $item['name'], 'description' => $item['description'], 'datatype' => $item['data_type'], 'control' => $type, 'inetlookup_type' => $inetlookup_type, 'options' => $options);
         $result[] = $ritem;
     }
     return $result;
 }
コード例 #23
0
 function do_external()
 {
     $this->oPage->setBreadcrumbDetails(_kt("New External Link"));
     $this->oPage->setTitle(_kt("New External Link"));
     $oPermission =& KTPermission::getByName('ktcore.permissions.write');
     if (PEAR::isError($oPermission) || !KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) {
         $this->errorRedirectToMain(_kt('You do not have sufficient permissions to add a document link'), sprintf("fDocumentId=%d", $this->oDocument->getId()));
         exit(0);
     }
     $oParentDocument =& $this->oDocument;
     $iParentId = $oParentDocument->getId();
     // Add an electronic signature
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to add an external document link');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.add_external_link', 'document', 'document_add_ext_link_form', 'submit', {$oParentDocument->iId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
     }
     $aTemplateData = array('context' => $this, 'iDocId' => $iParentId, 'link_types' => LinkType::getList("id > 0"), 'submit' => $submit);
     $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link_external');
     return $oTemplate->render($aTemplateData);
 }
コード例 #24
0
function getWidgetForMetadataField($field, $current_value, $page, $errors = null, $vocab = null, $aOptions = null)
{
    // all fields have these elements.
    $fieldLabel = $field->getName();
    $fieldDescription = $field->getDescription();
    $fieldValue = $current_value;
    $fieldErrors = $errors;
    // array of strings
    $fieldName = 'metadata_' . $field->getID();
    $fieldOptions = array();
    $fieldRequired = $field->getIsMandatory() || KTUtil::arrayGet($aOptions, 'required', false);
    if ($fieldRequired == 1) {
        $fieldRequired = true;
    }
    if ($errors === null) {
        $fieldErrors = array();
    } else {
        $fieldErrors = $errors;
    }
    // now we need to break, based on a few aspects of the oField (DocumentField)
    if ($field->getHasLookup()) {
        // could either be normal, or a tree.
        // ignore trees (for now).
        if (!$field->getHasLookupTree()) {
            // FIXME we need to somehow handle both value-value and id-value here
            // extract the lookup.
            if ($vocab === null) {
                // allow override
                $lookups = MetaData::getEnabledByDocumentField($field);
                $fieldOptions['vocab'] = array();
                // FIXME handle lookups
                $fieldOptions['vocab'][''] = _kt('Select a value');
                foreach ($lookups as $md) {
                    $fieldOptions['vocab'][$md->getName()] = $md->getName();
                }
            } else {
                $fieldOptions['vocab'] = $vocab;
            }
            $oField = new KTLookupWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
        } else {
            // FIXME vocab's are _not_ supported for tree-inputs.  this means conditional-tree-widgets are not unsupported.
            // for trees, we are currently brutal.
            $fieldTree = new MDTree();
            $fieldTree->buildForField($field->getId());
            $fieldTree->setActiveItem($current_value);
            $fieldOptions['tree'] = $fieldTree->_evilTreeRenderer($fieldTree, $fieldName);
            $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
        }
    } else {
        if (KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && $field->getHasInetLookup()) {
            require_once KT_DIR . "/plugins/multiselect/InetWidgets.php";
            if ($vocab === null) {
                // allow override
                $lookups = MetaData::getEnabledByDocumentField($field);
                $fieldOptions['vocab'] = array();
                // FIXME handle lookups
                foreach ($lookups as $md) {
                    $fieldOptions['vocab'][$md->getName()] = $md->getName();
                }
            } else {
                $fieldOptions['vocab'] = $vocab;
            }
            $fieldOptions['multi'] = true;
            $fieldOptions['lookup_type'] = $field->getInetLookupType();
            $oField = new InetMultiselectWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
        } else {
            $oField = new KTBaseWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
        }
    }
    return $oField;
}
コード例 #25
0
 function do_edit()
 {
     $this->oPage->setBreadcrumbDetails(_kt('Viewing Permissions'));
     $iFolderId = $this->oFolder->getId();
     $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
     $aOptions = array('redirect_to' => array('main', 'fFolderId=' . $iFolderId));
     if (!KTBrowseUtil::inAdminMode($this->oUser, $this->oFolder)) {
         $this->oValidator->userHasPermissionOnItem($this->oUser, $this->_sEditShowPermission, $this->oFolder, $aOptions);
     }
     // copy permissions if they were inherited
     $oInherited = KTPermissionUtil::findRootObjectForPermissionObject($oPO);
     if ($oInherited->getId() !== $iFolderId) {
         $override = KTUtil::arrayGet($_REQUEST, 'override', false);
         if (empty($override)) {
             $this->errorRedirectToMain(_kt('This folder does not override its permissions'), sprintf('fFolderId=%d', $iFolderId));
         }
         $this->startTransaction();
         $this->_copyPermissions();
         $this->commitTransaction();
         $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
     }
     // permissions in JS format
     $aPermissionsToJSON = array();
     $aPermList = KTPermission::getList();
     foreach ($aPermList as $oP) {
         $aPermissionsToJSON[] = array('id' => $oP->getId(), 'name' => $oP->getHumanName());
     }
     $oJSON = new Services_JSON();
     $sJSONPermissions = $oJSON->encode($aPermissionsToJSON);
     // dynamic conditions
     $aDynamicConditions = KTPermissionDynamicCondition::getByPermissionObject($oPO);
     // templating
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/folder/permissions');
     $bCanInherit = $iFolderId != 1;
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to modify permissions');
         $input['type'] = 'button';
         $input['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.permissions_change', 'folder', 'update_permissions_form', 'submit', {$iFolderId});";
     } else {
         $input['type'] = 'submit';
         $input['onclick'] = '';
     }
     $perms = $aPermList;
     $docperms = KTPermission::getDocumentRelevantList();
     $aTemplateData = array('iFolderId' => $iFolderId, 'roles' => Role::getList(), 'groups' => Group::getList(), 'conditions' => KTSavedSearch::getConditions(), 'dynamic_conditions' => $aDynamicConditions, 'context' => &$this, 'foldername' => $this->oFolder->getName(), 'jsonpermissions' => $sJSONPermissions, 'edit' => true, 'permissions' => $perms, 'document_permissions' => $docperms, 'can_inherit' => $bCanInherit, 'input' => $input);
     return $oTemplate->render($aTemplateData);
 }
コード例 #26
0
ファイル: BulkImport.php プロジェクト: 5haman/knowledgetree
 /**
  * Performs actual import action. | iNET Process
  * @Return.
  * @param.
  */
 function do_import()
 {
     set_time_limit(0);
     $aErrorOptions = array('redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())));
     $aErrorOptions['message'] = _kt('Invalid document type provided');
     $requestDocumentType = $_REQUEST['fDocumentTypeId'];
     //Backwards compatibility
     if ($requestDocumentType == '' || $requestDocumentType == NULL) {
         $requestDocumentType = $_REQUEST['data'];
         $requestDocumentType = $requestDocumentType['fDocumentTypeId'];
         //New elements come through as arrays
     }
     $oDocumentType = $this->oValidator->validateDocumentType($requestDocumentType, $aErrorOptions);
     $aErrorOptions['message'] = _kt('Invalid path provided');
     $tmpPath = $_REQUEST['path'];
     //Backwards compatibility
     if ($tmpPath == '') {
         $tmpPath = $_REQUEST['data'];
         $tmpPath = $tmpPath['path'];
     }
     $sPath = $this->oValidator->validateString($tmpPath, $aErrorOptions);
     /*
             $matches = array();
             $aFields = array();
             foreach ($_REQUEST as $k => $v) {
                 if (preg_match('/^metadata_(\d+)$/', $k, $matches)) {
                    
     		 // multiselect change start
     		$oDocField = DocumentField::get($matches[1]);
     		if(KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && $oDocField->getHasInetLookup() && is_array($v))
     		{
     			$v = join(", ", $v);
     		}
                     $aFields[] = array($oDocField, $v);
     		
     		// previously it was just one line which is commented, just above line
     		// multiselect change end
                 }
             }
     
             $aOptions = array(
                 'documenttype' => $oDocumentType,
                 'metadata' => $aFields,
                 'copy_upload' => 'true',
             );
     */
     // Newer metadata form field catcher that works with ktcore form array type fields named like
     // name='metadata[fieldset][metadata_9]'
     $aData = $_REQUEST['data'];
     $data = $aData;
     /*
     		$oForm = $this->getBulkImportForm();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     */
     $doctypeid = $requestDocumentType;
     $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false));
     $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false));
     $fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             //Fix for multiselect not submitting data due to the value not being flat.
             $sVal = '';
             if (is_array($val)) {
                 foreach ($val as $v) {
                     $sVal .= $v . ", ";
                 }
                 $sVal = substr($sVal, 0, strlen($sVal) - 2);
                 $val = $sVal;
             }
             if ($oFieldset->getIsConditional()) {
                 if ($val == _kt('No selection.')) {
                     $val = null;
                 }
             }
             if (!is_null($val)) {
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     $aOptions = array('documenttype' => $oDocumentType, 'metadata' => $MDPack, 'copy_upload' => 'true');
     $po =& new JavascriptObserver($this);
     $po->start();
     $oUploadChannel =& KTUploadChannel::getSingleton();
     $oUploadChannel->addObserver($po);
     $fs =& new KTFSImportStorage($sPath);
     $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
     if (KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) {
         require_once KT_DIR . "/plugins/foldermetadata/import/bulkimport.inc.php";
         $bm =& new KTINETBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
     } else {
         $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions);
     }
     DBUtil::startTransaction();
     $res = $bm->import();
     if (PEAR::isError($res)) {
         DBUtil::rollback();
         $_SESSION["KTErrorMessage"][] = _kt("Bulk import failed") . ": " . $res->getMessage();
     } else {
         DBUtil::commit();
         $this->addInfoMessage(_kt("Bulk import succeeded"));
     }
     $po->redirectToFolder($this->oFolder->getId());
     exit(0);
 }
コード例 #27
0
 function _walk($path, &$files)
 {
     if (!is_dir($path)) {
         return;
     }
     $dirh = opendir($path);
     while (($entry = readdir($dirh)) !== false) {
         if (in_array($entry, array('.', '..'))) {
             continue;
         }
         $newpath = $path . '/' . $entry;
         if (is_dir($newpath)) {
             KTPluginUtil::_walk($newpath, $files);
         }
         if (!is_file($newpath)) {
             continue;
         }
         $files[] = $newpath;
     }
 }
コード例 #28
0
ファイル: system_info.php プロジェクト: 5haman/knowledgetree
function getKTEdition()
{
    $edition = 'Community|-';
    if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
        $path = KTPluginUtil::getPluginPath('ktdms.wintools');
        require_once $path . 'baobabkeyutil.inc.php';
        $edition = BaobabKeyUtil::getName();
        // this could be done with regular expressions...
        // Remove the brackets around the name
        $edition = substr($edition, 1);
        $edition = substr($edition, 0, strlen($edition) - 1);
        // Remove the "users"
        $pos = strpos($edition, 'users');
        $edition = $pos === false ? $edition . '|-' : substr($edition, 0, $pos - 1);
        // Replace the , with |
        $edition = str_replace(', ', '|', $edition);
    }
    return $edition;
}