• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP kt_array_merge函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中kt_array_merge函数的典型用法代码示例。如果您正苦于以下问题:PHP kt_array_merge函数的具体用法?PHP kt_array_merge怎么用?PHP kt_array_merge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了kt_array_merge函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: setOptions

 function setOptions($aOptions = null)
 {
     $this->aOptions = kt_array_merge($this->aOptions, $aOptions);
     $this->sortable = KTUtil::arrayGet($this->aOptions, 'sortable', $this->sortable);
     $this->return_url = KTUtil::arrayGet($this->aOptions, 'return_url', $this->return_url);
     $this->sort_on = KTUtil::arrayGet($this->aOptions, 'sort_on', $this->sort_on);
     $this->sort_direction = KTUtil::arrayGet($this->aOptions, 'sort_on', $this->sort_direction);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:8,代码来源:advancedcolumns.inc.php


示例2: getTypeMetadataFieldsets

 /**
  * Returns the Metadata Fieldsets for the given DocumentId
  * @return KTForm 
  *
  */
 function getTypeMetadataFieldsets($iDocumentTypeID)
 {
     //Creating the form
     $oForm = new KTForm();
     $oFReg =& KTFieldsetRegistry::getSingleton();
     $activesets = KTFieldset::getForDocumentType($iDocumentTypeID);
     foreach ($activesets as $oFieldset) {
         $widgets = kt_array_merge($widgets, $oFReg->widgetsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument));
         $validators = kt_array_merge($validators, $oFReg->validatorsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument));
     }
     $oForm->setWidgets($widgets);
     $oForm->setValidators($validators);
     return $oForm->renderWidgets();
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:19,代码来源:getTypeMetadataFields.php


示例3: getInternalFeed

 function getInternalFeed($iUserId)
 {
     $documents = KTrss::getDocuments($iUserId);
     $folders = KTrss::getFolders($iUserId);
     if (is_null($documents)) {
         $documents = array();
     }
     if (is_null($folders)) {
         $folders = array();
     }
     $response = '';
     $aFullList = kt_array_merge($documents, $folders);
     if (!empty($aFullList)) {
         $internalFeed = KTrss::arrayToXML($aFullList);
         $response = rss2arrayBlock($internalFeed);
     }
     return $response;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:18,代码来源:KTrss.inc.php


示例4: hasUsers

 function hasUsers($aUsers)
 {
     $sTable = KTUtil::getTableName('permission_descriptor_users');
     if (count($aUsers) === 0) {
         return false;
     }
     $aUserIDs = array();
     foreach ($aUsers as $oUser) {
         $aUserIDs[] = $oUser->getID();
     }
     $sUserIDs = DBUtil::paramArray($aUserIDs);
     $sQuery = "SELECT COUNT(user_id) AS num FROM {$sTable}\n            WHERE descriptor_id = ? AND user_id IN ({$sUserIDs})";
     $aParams = array($this->getID());
     $aParams = kt_array_merge($aParams, $aUserIDs);
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'num');
     if (PEAR::isError($res)) {
         return $res;
     }
     if ((int) $res === 0) {
         return false;
     }
     return true;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:23,代码来源:permissiondescriptor.inc.php


示例5: check

 function check()
 {
     $this->browse_mode = KTUtil::arrayGet($_REQUEST, 'fBrowseMode', 'folder');
     $action = KTUtil::arrayGet($_REQUEST, $this->event_var, 'main');
     $this->editable = false;
     // catch the alternative actions.
     if ($action != 'main') {
         return true;
     }
     // if we're going to main ...
     // folder browse mode
     if ($this->browse_mode == 'folder') {
         $in_folder_id = KTUtil::arrayGet($_REQUEST, 'fFolderId');
         if (empty($in_folder_id)) {
             $oConfig = KTConfig::getSingleton();
             if ($oConfig->get('tweaks/browseToUnitFolder')) {
                 $iHomeFolderId = $this->oUser->getHomeFolderId();
                 if ($iHomeFolderId) {
                     $in_folder_id = $iHomeFolderId;
                 }
             }
         }
         $folder_id = (int) $in_folder_id;
         // conveniently, will be 0 if not possible.
         if ($folder_id == 0) {
             $folder_id = 1;
         }
         $_REQUEST['fBrowseMode'] = 'folder';
         // here we need the folder object to do the breadcrumbs.
         $oFolder =& Folder::get($folder_id);
         if (PEAR::isError($oFolder)) {
             return false;
             // just fail.
         }
         // check whether the user can edit this folder
         $oPerm = KTPermission::getByName('ktcore.permissions.write');
         if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oFolder)) {
             $this->editable = true;
         } else {
             $this->editable = false;
         }
         // set the title and breadcrumbs...
         $this->oPage->setTitle(_kt('Browse'));
         if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $oFolder)) {
             $this->oPage->setSecondaryTitle($oFolder->getName());
         } else {
             if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
                 $this->oPage->setSecondaryTitle(sprintf('(%s)', $oFolder->getName()));
             } else {
                 $this->oPage->setSecondaryTitle('...');
             }
         }
         //Figure out if we came here by navigating trough a shortcut.
         //If we came here from a shortcut, the breadcrumbspath should be relative
         //to the shortcut folder.
         $iSymLinkFolderId = KTUtil::arrayGet($_REQUEST, 'fShortcutFolder', null);
         if (is_numeric($iSymLinkFolderId)) {
             $oBreadcrumbsFolder = Folder::get($iSymLinkFolderId);
             $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($oBreadcrumbsFolder, array('final' => false)));
             $this->aBreadcrumbs[] = array('name' => $oFolder->getName());
         } else {
             $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($oFolder));
         }
         $this->oFolder =& $oFolder;
         // we now have a folder, and need to create the query.
         $aOptions = array('ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder));
         $this->oQuery = new BrowseQuery($oFolder->getId(), $this->oUser, $aOptions);
         $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $oFolder->getId()));
         // and the portlets
         $portlet = new KTActionPortlet(sprintf(_kt('About this folder')));
         $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser);
         $portlet->setActions($aActions, $this->sName);
         $this->oPage->addPortlet($portlet);
         $portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder')));
         $aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $this->oUser);
         $portlet->setActions($aActions, null);
         $this->oPage->addPortlet($portlet);
     } else {
         if ($this->browse_mode == 'lookup_value') {
             // browsing by a lookup value
             $this->editable = false;
             // check the inputs
             $field = KTUtil::arrayGet($_REQUEST, 'fField', null);
             $oField = DocumentField::get($field);
             if (PEAR::isError($oField) || $oField == false) {
                 $this->errorRedirectToMain('No Field selected.');
                 exit(0);
             }
             $value = KTUtil::arrayGet($_REQUEST, 'fValue', null);
             $oValue = MetaData::get($value);
             if (PEAR::isError($oValue) || $oValue == false) {
                 $this->errorRedirectToMain('No Value selected.');
                 exit(0);
             }
             $this->oQuery = new ValueBrowseQuery($oField, $oValue);
             $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fBrowseMode=lookup_value&fField=%d&fValue=%d', $field, $value));
             // setup breadcrumbs
             $this->aBreadcrumbs = array(array('name' => _kt('Lookup Values'), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectField')), array('name' => $oField->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectLookup&fField=' . $oField->getId())), array('name' => $oValue->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fBrowseMode=lookup_value&fField=%d&fValue=%d', $field, $value))));
         } else {
             if ($this->browse_mode == 'document_type') {
//.........这里部分代码省略.........
开发者ID:5haman,项目名称:knowledgetree,代码行数:101,代码来源:browse.php


示例6: fieldsetsForDocument

 function fieldsetsForDocument($oDocument, $iTypeOverride = null)
 {
     global $default;
     $oDocument = KTUtil::getObject('Document', $oDocument);
     $iMetadataVersionId = $oDocument->getMetadataVersionId();
     $iDocumentTypeId = $oDocument->getDocumentTypeId();
     if (!is_null($iTypeOverride)) {
         $iDocumentTypeId = $iTypeOverride;
     }
     $sQuery = "SELECT DISTINCT F.id AS fieldset_id " . "FROM {$default->document_metadata_version_table} AS DM INNER JOIN document_fields_link AS DFL ON DM.id = DFL.metadata_version_id " . "INNER JOIN {$default->document_fields_table} AS DF ON DF.ID = DFL.document_field_id " . "INNER JOIN {$default->fieldsets_table} AS F ON F.id = DF.parent_fieldset " . "WHERE DM.id = ?" . "AND F.disabled = false";
     $aParam = array($iMetadataVersionId);
     $aDocumentFieldsetIds = DBUtil::getResultArrayKey(array($sQuery, $aParam), 'fieldset_id');
     $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => true));
     $aSpecificFieldsetIds = KTFieldset::getForDocumentType($iDocumentTypeId, array('ids' => true));
     $aFieldsetIds = kt_array_merge($aDocumentFieldsetIds, $aGenericFieldsetIds, $aSpecificFieldsetIds);
     $aFieldsetIds = array_unique($aFieldsetIds);
     sort($aFieldsetIds);
     $aRet = array();
     foreach ($aFieldsetIds as $iID) {
         $aRet[] = call_user_func(array('KTFieldset', 'get'), $iID);
     }
     return $aRet;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:23,代码来源:metadatautil.inc.php


示例7: do_new

 function do_new()
 {
     $this->oPage->setBreadcrumbDetails(_kt("New Link"));
     $this->oPage->setTitle(_kt("New 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;
     if (PEAR::isError($oParentDocument)) {
         $this->errorRedirectToMain(_kt('Invalid parent document selected.'));
         exit(0);
     }
     $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', $oParentDocument->getFolderID()));
     if (PEAR::isError($oFolder) || $oFolder == false) {
         $this->errorRedirectToMain(_kt('Invalid folder selected.'));
         exit(0);
     }
     $iFolderId = $oFolder->getId();
     // Setup the collection for move display.
     $collection = new AdvancedCollection();
     $aBaseParams = array('fDocumentId' => $oParentDocument->getId());
     $oCR =& KTColumnRegistry::getSingleton();
     $col = $oCR->getColumn('ktcore.columns.selection');
     $aColOptions = array();
     $aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId()));
     $aColOptions['show_folders'] = false;
     $aColOptions['show_documents'] = true;
     $aColOptions['rangename'] = 'linkselection[]';
     $col->setOptions($aColOptions);
     $collection->addColumn($col);
     $col = $oCR->getColumn('ktdocumentlinks.columns.title');
     $col->setOptions(array('qs_params' => kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId' => $oFolder->getId()))));
     $collection->addColumn($col);
     $qObj = new BrowseQuery($iFolderId);
     $collection->setQueryObject($qObj);
     $aOptions = $collection->getEnvironOptions();
     //$aOptions['is_browse'] = true;
     $aResultUrl = $aBaseParams;
     $aResultUrl['fFolderId'] = $oFolder->getId();
     $aResultUrl['action'] = 'new';
     $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aResultUrl);
     $collection->setOptions($aOptions);
     $aURLParams = $aBaseParams;
     $aURLParams['action'] = 'new';
     $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams);
     // Add an electronic signature
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to add a document link');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.add_link', 'document', 'document_add_link_form', 'submit', {$oParentDocument->iId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
     }
     $aTemplateData = array('context' => $this, 'folder' => $oFolder, 'parent' => $oParentDocument, 'breadcrumbs' => $aBreadcrumbs, 'collection' => $collection, 'link_types' => LinkType::getList("id > 0"), 'submit' => $submit);
     $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link');
     return $oTemplate->render($aTemplateData);
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:62,代码来源:KTDocumentLinks.php


示例8: do_login

 function do_login()
 {
     $aExtra = array();
     $oUser =& KTInterceptorRegistry::checkInterceptorsForAuthenticated();
     if (is_a($oUser, 'User')) {
         $res = $this->performLogin($oUser);
         if ($res) {
             $oUser = array($res);
         }
     }
     if (is_array($oUser)) {
         foreach ($oUser as $oError) {
             if (is_a($oError, 'KTNoLocalUser')) {
                 $aExtra = kt_array_merge($aExtra, $oError->aExtra);
             }
         }
     }
     KTInterceptorRegistry::checkInterceptorsForTakeOver();
     $this->check();
     global $default;
     $language = KTUtil::arrayGet($_REQUEST, 'language');
     if (empty($language)) {
         $language = $default->defaultLanguage;
     }
     setcookie("kt_language", $language, 2147483647, '/');
     $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect'));
     $url = $_SERVER["PHP_SELF"];
     $queryParams = array();
     if (!empty($redirect)) {
         $queryParams[] = 'redirect=' . urlencode($redirect);
     }
     $username = KTUtil::arrayGet($_REQUEST, 'username');
     $password = KTUtil::arrayGet($_REQUEST, 'password');
     if (empty($username)) {
         $this->simpleRedirectToMain(_kt('Please enter your username.'), $url, $queryParams);
     }
     $oUser =& User::getByUsername($username);
     if (PEAR::isError($oUser) || $oUser === false) {
         if (is_a($oUser, 'ktentitynoobjects')) {
             $this->handleUserDoesNotExist($username, $password, $aExtra);
         }
         $this->simpleRedirectToMain(_kt('Login failed.  Please check your username and password, and try again.'), $url, $queryParams);
         exit(0);
     }
     if (empty($password)) {
         $this->simpleRedirectToMain(_kt('Please enter your password.'), $url, $queryParams);
     }
     $authenticated = KTAuthenticationUtil::checkPassword($oUser, $password);
     if (PEAR::isError($authenticated)) {
         $this->simpleRedirectToMain(_kt('Authentication failure.  Please try again.'), $url, $queryParams);
         exit(0);
     }
     if ($authenticated !== true) {
         $this->simpleRedirectToMain(_kt('Login failed.  Please check your username and password, and try again.'), $url, $queryParams);
         exit(0);
     }
     $res = $this->performLogin($oUser);
     if ($res) {
         $this->simpleRedirectToMain($res->getMessage(), $url, $queryParams);
         exit(0);
     }
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:62,代码来源:login.php


示例9: do_viewComparison

 function do_viewComparison()
 {
     $document_data = array();
     $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     if ($document_id === null) {
         $this->oPage->addError(sprintf(_kt("No document was requested.  Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl()));
         return $this->do_error();
     }
     $document_data['document_id'] = $document_id;
     $base_version = KTUtil::arrayGet($_REQUEST, 'fBaseVersion');
     // try get the document.
     $oDocument =& Document::get($document_id, $base_version);
     if (PEAR::isError($oDocument)) {
         $this->oPage->addError(sprintf(_kt("The base document you attempted to retrieve is invalid.   Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl()));
         return $this->do_error();
     }
     if (!Permission::userHasDocumentReadPermission($oDocument)) {
         // FIXME inconsistent.
         $this->oPage->addError(_kt('You are not allowed to view this document'));
         return $this->permissionDenied();
     }
     $this->oDocument =& $oDocument;
     $this->oPage->setSecondaryTitle($oDocument->getName());
     $aOptions = array('documentaction' => 'viewDocument', 'folderaction' => 'browse');
     $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions));
     $this->oPage->setBreadcrumbDetails(_kt('compare versions'));
     $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion');
     if ($comparison_version === null) {
         $this->oPage->addError(sprintf(_kt("No comparison version was requested.  Please <a href=\"%s\">select a version</a>."), KTUtil::addQueryStringSelf('action=history&fDocumentId=' . $document_id)));
         return $this->do_error();
     }
     $oComparison =& Document::get($oDocument->getId(), $comparison_version);
     if (PEAR::isError($oComparison)) {
         $this->errorRedirectToMain(_kt('Invalid document to compare against.'));
     }
     $comparison_data = array();
     $comparison_data['document_id'] = $oComparison->getId();
     $document_data['document'] = $oDocument;
     $comparison_data['document'] = $oComparison;
     $document_data['document_type'] =& DocumentType::get($oDocument->getDocumentTypeID());
     $comparison_data['document_type'] =& DocumentType::get($oComparison->getDocumentTypeID());
     // follow twice:  once for normal, once for comparison.
     $is_valid_doctype = true;
     if (PEAR::isError($document_data['document_type'])) {
         $this->oPage->addError(_kt('The document you requested has an invalid <strong>document type</strong>.  Unfortunately, this means that we cannot effectively display it.'));
         $is_valid_doctype = false;
     }
     // we want to grab all the md for this doc, since its faster that way.
     $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($base_version)));
     $field_values = array();
     foreach ($mdlist as $oFieldLink) {
         $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
     }
     $document_data['field_values'] = $field_values;
     $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($comparison_version)));
     $field_values = array();
     foreach ($mdlist as $oFieldLink) {
         $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
     }
     $comparison_data['field_values'] = $field_values;
     // Fieldset generation.
     //
     //   we need to create a set of FieldsetDisplay objects
     //   that adapt the Fieldsets associated with this lot
     //   to the view (i.e. ZX3).   Unfortunately, we don't have
     //   any of the plumbing to do it, so we handle this here.
     $fieldsets = array();
     // we always have a generic.
     array_push($fieldsets, new GenericFieldsetDisplay());
     // FIXME can we key this on fieldset namespace?  or can we have duplicates?
     // now we get the other fieldsets, IF there is a valid doctype.
     if ($is_valid_doctype) {
         // these are the _actual_ fieldsets.
         $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton();
         // and the generics
         $activesets = KTFieldset::getGenericFieldsets();
         foreach ($activesets as $oFieldset) {
             $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
             array_push($fieldsets, new $displayClass($oFieldset));
         }
         $activesets = KTFieldset::getForDocumentType($oDocument->getDocumentTypeID());
         foreach ($activesets as $oFieldset) {
             $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
             array_push($fieldsets, new $displayClass($oFieldset));
         }
     }
     // FIXME handle ad-hoc fieldsets.
     $this->addPortlets();
     $oTemplate = $this->oValidator->validateTemplate('ktcore/document/compare');
     $aTemplateData = array('context' => $this, 'document_id' => $document_id, 'document' => $oDocument, 'document_data' => $document_data, 'comparison_data' => $comparison_data, 'comparison_document' => $oComparison, 'fieldsets' => $fieldsets);
     //var_dump($aTemplateData['comparison_data']);
     return $oTemplate->render($aTemplateData);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:93,代码来源:view.php


示例10: criteriaToQuery

 /**
  * Converts a criteria set into a SQL query that (by default)
  * returns the ids of documents that fulfil the criteria.
  *
  * $aOptions is a dictionary that can contain:
  *      - select - a string that contains the list of columns
  *        selected in the query
  *      - join - a string that contains join conditions to satisfy
  *        the select string passed or limit the documents included
  *
  * A list with the following elements is returned:
  *      - String containing the parameterised SQL query
  *      - Array containing the parameters for the SQL query
  */
 function criteriaToQuery($aCriteriaSet, $oUser, $sPermissionName, $aOptions = null)
 {
     global $default;
     $sSelect = KTUtil::arrayGet($aOptions, 'select', 'D.id AS document_id');
     $sInitialJoin = KTUtil::arrayGet($aOptions, 'join', '');
     if (is_array($sInitialJoin)) {
         $aInitialJoinParams = $sInitialJoin[1];
         $sInitialJoin = $sInitialJoin[0];
     }
     $res = KTSearchUtil::criteriaSetToSQL($aCriteriaSet);
     if (PEAR::isError($res)) {
         return $res;
     }
     list($sSQLSearchString, $aCritParams, $sCritJoinSQL) = $res;
     $sToSearch = KTUtil::arrayGet($aOrigReq, 'fToSearch', 'Live');
     // actually never present in this version.
     $res = KTSearchUtil::permissionToSQL($oUser, $sPermissionName);
     if (PEAR::isError($res)) {
         // only occurs if the group has no permissions.
         return $res;
     } else {
         list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $res;
     }
     /*
      * This is to overcome the problem where $sPermissionString (or
      * even $sSQLSearchString) is empty, leading to leading or
      * trailing ANDs.
      */
     $aPotentialWhere = array($sPermissionString, 'SL.name = ?', "({$sSQLSearchString})");
     $aWhere = array();
     foreach ($aPotentialWhere as $sWhere) {
         if (empty($sWhere)) {
             continue;
         }
         if ($sWhere == "()") {
             continue;
         }
         $aWhere[] = $sWhere;
     }
     $sWhere = "";
     if ($aWhere) {
         $sWhere = "\tWHERE " . join(" AND ", $aWhere);
     }
     //$sQuery = DBUtil::compactQuery("
     $sQuery = sprintf("\n    SELECT\n        %s\n    FROM\n        %s AS D\n        LEFT JOIN %s AS DM ON D.metadata_version_id = DM.id\n        LEFT JOIN %s AS DC ON DM.content_version_id = DC.id\n        INNER JOIN {$default->status_table} AS SL on D.status_id=SL.id\n        %s\n        %s\n        %s\n        %s", $sSelect, KTUtil::getTableName('documents'), KTUtil::getTableName('document_metadata_version'), KTUtil::getTableName('document_content_version'), $sInitialJoin, $sCritJoinSQL, $sPermissionJoin, $sWhere);
     // GROUP BY D.id
     $aParams = array();
     $aParams = kt_array_merge($aParams, $aInitialJoinParams);
     $aParams = kt_array_merge($aParams, $aPermissionParams);
     $aParams[] = $sToSearch;
     $aParams = kt_array_merge($aParams, $aCritParams);
     return array($sQuery, $aParams);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:67,代码来源:searchutil.inc.php


示例11: getBrowseableFolders

 /**
  * Finds folders that aren't reachable by the user but to which the
  * user has read permissions.
  *
  * Returns an array of Folder objects.
  */
 function getBrowseableFolders($oUser)
 {
     $aPermissionDescriptors = KTPermissionUtil::getPermissionDescriptorsForUser($oUser);
     if (empty($aPermissionDescriptors)) {
         return array();
     }
     $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors);
     $oPermission = KTPermission::getByName('ktcore.permissions.read');
     $oPermission2 = KTPermission::getByName('ktcore.permissions.folder_details');
     $aPermissionIds = array($oPermission->getId(), $oPermission->getId(), $oPermission2->getId(), $oPermission2->getId());
     $sFoldersTable = KTUtil::getTableName('folders');
     $sPLTable = KTUtil::getTableName('permission_lookups');
     $sPLATable = KTUtil::getTableName('permission_lookup_assignments');
     $sQuery = "SELECT DISTINCT F.id AS id FROM\n            {$sFoldersTable} AS F\n                LEFT JOIN {$sPLTable} AS PL ON F.permission_lookup_id = PL.id\n                LEFT JOIN {$sPLATable} AS PLA ON PLA.permission_lookup_id = PL.id AND (PLA.permission_id = ? || PLA.permission_id = ?)\n\n            LEFT JOIN {$sFoldersTable} AS F2 ON F.parent_id = F2.id\n                LEFT JOIN {$sPLTable} AS PL2 ON F2.permission_lookup_id = PL2.id\n                LEFT JOIN {$sPLATable} AS PLA2 ON PLA2.permission_lookup_id = PL2.id AND (PLA2.permission_id = ? || PLA.permission_id = ?)\n            WHERE\n                PLA.permission_descriptor_id IN ({$sPermissionDescriptors})\n                AND F2.id <> 1\n                AND NOT (PLA2.permission_descriptor_id IN ({$sPermissionDescriptors}))";
     $aParams = kt_array_merge($aPermissionIds, $aPermissionDescriptors, $aPermissionDescriptors);
     $res = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id');
     if (PEAR::isError($res)) {
         return $res;
     }
     $aFolders = array();
     foreach ($res as $iFolderId) {
         $aFolders[] = Folder::get($iFolderId);
     }
     return $aFolders;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:browseutil.inc.php


示例12: json_getUsers

 function json_getUsers()
 {
     $oConfig = KTConfig::getSingleton();
     $bOnlyOwnGroup = $oConfig->get('email/onlyOwnGroups', false);
     $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false);
     $aUserList = array('off' => _kt('-- Please filter --'));
     if ($sFilter && trim($sFilter)) {
         $sWhere = sprintf('name LIKE \'%%%s%%\' AND disabled = \'0\'', $sFilter);
         if ($bOnlyOwnGroup != true) {
             $aUsers = User::getEmailUsers($sWhere);
         } else {
             $aGroups = GroupUtil::listGroupsForUser($this->oUser);
             $aMembers = array();
             foreach ($aGroups as $oGroup) {
                 $aMembers = kt_array_merge($aMembers, $oGroup->getMembers());
             }
             $aUsers = array();
             $aUserIds = array();
             foreach ($aMembers as $oUser) {
                 if (in_array($oUser->getId(), $aUserIds)) {
                     continue;
                 }
                 $aUsers[] = $oUser;
             }
         }
         $aUserList = array();
         foreach ($aUsers as $u) {
             $aUserList[$u->getId()] = $u->getName();
         }
     }
     return $aUserList;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:32,代码来源:KTEmail.php


示例13: persistParams

 function persistParams($aParamKeys)
 {
     $this->aPersistParams = kt_array_merge($this->aPersistParams, $aParamKeys);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:4,代码来源:dispatcher.inc.php


示例14: do_main

 function do_main()
 {
     $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents'));
     $this->oPage->setBreadcrumbDetails(_kt('browse'));
     $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1));
     if (PEAR::isError($oFolder)) {
         $this->errorRedirectToMain(_kt('Invalid folder selected.'));
         exit(0);
     }
     // Setup the collection for restore display.
     $aBaseParams = array();
     $collection = new AdvancedCollection();
     $oCR =& KTColumnRegistry::getSingleton();
     $col = $oCR->getColumn('ktcore.columns.selection');
     $aColOptions = array();
     //$aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId()));
     $aColOptions['show_folders'] = false;
     $aColOptions['show_documents'] = true;
     $aColOptions['rangename'] = '_d[]';
     $col->setOptions($aColOptions);
     $collection->addColumn($col);
     $col = $oCR->getColumn('ktcore.columns.title');
     //$col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId'=>$oFolder->getId()))));
     $col->setOptions(array('link_documents' => false));
     $collection->addColumn($col);
     //$qObj = new BrowseQuery($iFolderId);
     $qObj = new ArchivedBrowseQuery($oFolder->getId());
     $collection->setQueryObject($qObj);
     $aOptions = $collection->getEnvironOptions();
     $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId()))));
     $collection->setOptions($aOptions);
     $aURLParams = $aBaseParams;
     $aURLParams['action'] = 'restore';
     $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams);
     $aTemplateData = array('context' => $this, 'folder' => $oFolder, 'breadcrumbs' => $aBreadcrumbs, 'collection' => $collection);
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/document/admin/archivebrowse');
     return $oTemplate->render($aTemplateData);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:38,代码来源:archivedDocuments.php


示例15: _regeneratePermissionsForRole

 /**
  * Regenerate permissions for a role.
  *
  * Adapted from KTRoleAllocationPlugin::regeneratePermissionsForRole()
  *
  * @author KnowledgeTree Team
  * @access public
  * @access private
  * @param int $iRoleId
  */
 private function _regeneratePermissionsForRole($iRoleId)
 {
     $object = $this->folderItem->getObject();
     $iStartFolderId = $object->getId();
     /*
      * 1. find all folders & documents "below" this one which use the role
      *    definition _active_ (not necessarily present) at this point.
      * 2. tell permissionutil to regen their permissions.
      *
      * The find algorithm is:
      *
      *  folder_queue <- (iStartFolderId)
      *  while folder_queue is not empty:
      *     active_folder =
      *     for each folder in the active_folder:
      *         find folders in _this_ folder without a role-allocation on the iRoleId
      *            add them to the folder_queue
      *         update the folder's permissions.
      *         find documents in this folder:
      *            update their permissions.
      */
     $sRoleAllocTable = KTUtil::getTableName('role_allocations');
     $sFolderTable = KTUtil::getTableName('folders');
     $sQuery = sprintf('SELECT f.id as id FROM %s AS f LEFT JOIN %s AS ra ON (f.id = ra.folder_id) WHERE ra.id IS NULL AND f.parent_id = ?', $sFolderTable, $sRoleAllocTable);
     $folder_queue = array($iStartFolderId);
     while (!empty($folder_queue)) {
         $active_folder = array_pop($folder_queue);
         $aParams = array($active_folder);
         $aNewFolders = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id');
         if (PEAR::isError($aNewFolders)) {
             $this->errorRedirectToMain(_kt('Failure to generate folderlisting.'));
         }
         $folder_queue = kt_array_merge($folder_queue, (array) $aNewFolders);
         // push.
         // update the folder.
         $oFolder =& Folder::get($active_folder);
         if (PEAR::isError($oFolder) || $oFolder == false) {
             $this->errorRedirectToMain(_kt('Unable to locate folder: ') . $active_folder);
         }
         KTPermissionUtil::updatePermissionLookup($oFolder);
         $aDocList =& Document::getList(array('folder_id = ?', $active_folder));
         if (PEAR::isError($aDocList) || $aDocList === false) {
             $this->errorRedirectToMain(sprintf(_kt('Unable to get documents in folder %s: %s'), $active_folder, $aDocList->getMessage()));
         }
         foreach ($aDocList as $oDoc) {
             if (!PEAR::isError($oDoc)) {
                 KTPermissionUtil::updatePermissionLookup($oDoc);
             }
         }
     }
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:61,代码来源:KTAPIAcl.inc.php


示例16: copy

 function copy($oSrcFolder, $oDestFolder, $oUser, $sReason, $sDestFolderName = NULL, $copyAll = true)
 {
     $sDestFolderName = empty($sDestFolderName) ? $oSrcFolder->getName() : $sDestFolderName;
     if (KTFolderUtil::exists($oDestFolder, $sDestFolderName)) {
         return PEAR::raiseError(_kt("Folder with the same name already exists in the new parent folder"));
     }
     //
     // FIXME the failure cleanup code here needs some serious work.
     //
     $oPerm = KTPermission::getByName('ktcore.permissions.read');
     $oBaseFolderPerm = KTPermission::getByName('ktcore.permissions.addFolder');
     if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oBaseFolderPerm, $oDestFolder)) {
         return PEAR::raiseError(_kt('You are not allowed to create folders in the destination.'));
     }
     // Check if the source folder inherits its permissions
     // Get source PO id and its parent PO id
     $iSrcPoId = $oSrcFolder->getPermissionObjectID();
     $oSrcParent = Folder::get($oSrcFolder->getParentID());
     $iSrcParentPoId = $oSrcParent->getPermissionObjectID();
     // If the folder defines its own permissions then we copy the permission object
     // If the source folder inherits permissions we must change it to inherit from the new parent folder
     $bInheritPermissions = false;
     if ($iSrcPoId == $iSrcParentPoId) {
         $bInheritPermissions = true;
     }
     $aFolderIds = array();
     // of oFolder
     $aDocuments = array();
     // of oDocument
     $aFailedDocuments = array();
     // of String
     $aFailedFolders = array();
     // of String
     $aRemainingFolders = array($oSrcFolder->getId());
     DBUtil::startTransaction();
     while (!empty($aRemainingFolders) && $copyAll) {
         $iFolderId = array_pop($aRemainingFolders);
         $oFolder = Folder::get($iFolderId);
         if (PEAR::isError($oFolder) || $oFolder == false) {
             DBUtil::rollback();
             return PEAR::raiseError(sprintf(_kt('Failure resolving child folder with id = %d.'), $iFolderId));
         }
         // don't just stop ... plough on.
         if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oFolder)) {
             $aFolderIds[] = $iFolderId;
         } else {
             $aFailedFolders[] = $oFolder->getName();
         }
         // child documents
         $aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId)));
         foreach ($aChildDocs as $oDoc) {
             if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDoc)) {
                 $aDocuments[] = $oDoc;
             } else {
                 $aFailedDocuments[] = $oDoc->getName();
             }
         }
         // child folders.
         $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
         $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
     }
     if (!empty($aFailedDocuments) || !empty($aFailedFolders)) {
         $sFD = '';
         $sFF = '';
         if (!empty($aFailedDocuments)) {
             $sFD = _kt('Documents: ') . implode(', ', $aFailedDocuments) . '. ';
         }
         if (!empty($aFailedFolders)) {
             $sFF = _kt('Folders: ') . implode(', ', $aFailedFolders) . '.';
         }
         return PEAR::raiseError(_kt('You do not have permission to copy these items. ') . $sFD . $sFF);
     }
     // first we walk the tree, creating in the new location as we go.
     // essentially this is an "ok" pass.
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $aFolderMap = array();
     $sTable = 'folders';
     $sGetQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ? ';
     $aParams = array($oSrcFolder->getId());
     $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams));
     unset($aRow['id']);
     $aRow['name'] = $sDestFolderName;
     $aRow['description'] = $sDestFolderName;
     $aRow['parent_id'] = $oDestFolder->getId();
     $aRow['parent_folder_ids'] = sprintf('%s,%s', $oDestFolder->getParentFolderIDs(), $oDestFolder->getId());
     $aRow['full_path'] = $oDestFolder->getFullPath() . '/' . $aRow['name'];
     $id = DBUtil::autoInsert($sTable, $aRow);
     if (PEAR::isError($id)) {
         DBUtil::rollback();
         return $id;
     }
     $sSrcFolderId = $oSrcFolder->getId();
     $aFolderMap[$sSrcFolderId]['parent_id'] = $id;
     $aFolderMap[$sSrcFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids'];
     $aFolderMap[$sSrcFolderId]['full_path'] = $aRow['full_path'];
     $aFolderMap[$sSrcFolderId]['name'] = $aRow['name'];
     $oNewBaseFolder = Folder::get($id);
     $res = $oStorage->createFolder($oNewBaseFolder);
     if (PEAR::isError($res)) {
         // it doesn't exist, so rollback and raise..
//.........这里部分代码省略.........
开发者ID:5haman,项目名称:knowledgetree,代码行数:101,代码来源:folderutil.inc.php


示例17: _pruneAlertedUsers

 function _pruneAlertedUsers($aUserIds)
 {
     $returnArray = array_diff($aUserIds, $this->alertedUsers);
     $this->alertedUsers = kt_array_merge($returnArray, $this->alertedUsers);
     // now contains all users who will have been alerted.
     return $returnArray;
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:7,代码来源:subscriptions.inc.php


示例18: kt_array_merge

                // create rss xml for error
                $error = KTrss::errorToXML(_kt('This document has returned a empty response'));
            }
        } else {
            // create rss xml for error
            $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' . ' Please visit http://' . $_SERVER['HTTP_HOST'] . '/' . $GLOBALS['KTRootUrl'] . '/ to browse for a valid folder.'));
        }
        if (isset($error)) {
            // if an error exist, output...else out the result
            echo $error;
        } else {
            echo $folderFeed;
        }
    } else {
        // else do normal rss parsing
        // get full list of subscribed documents and folders
        $aFullList = kt_array_merge(KTrss::getDocuments($id), KTrss::getFolders($id));
        $internalFeed = KTrss::arrayToXML($aFullList);
        echo $internalFeed;
    }
}
// Validate user credentials
function validateUser($username, $password)
{
    //return DBAuthenticator::checkPassword($username, $password);
    $oUser =& User::getByUsername($username);
    if (PEAR::isError($oUser) || is_a($oUser, 'KTEntityNoObjects')) {
        return false;
    }
    return KTAuthenticationUtil::checkPassword($oUser, $password);
}
开发者ID:5haman,项目名称:knowledgetree,代码行数:31

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP kt_download_media函数代码示例发布时间:2022-05-15
下一篇:
PHP kt_add_menu_item函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap