当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtil::autoInsert方法代码示例

本文整理汇总了PHP中DBUtil::autoInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::autoInsert方法的具体用法?PHP DBUtil::autoInsert怎么用?PHP DBUtil::autoInsert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


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

示例1: saveTransitionSources

 function saveTransitionSources($oTransition, $aStateIds)
 {
     $sTable = KTUtil::getTableName('workflow_state_transitions');
     $aQuery = array("DELETE FROM {$sTable} WHERE transition_id = ?", array($oTransition->getId()));
     $res = DBUtil::runQuery($aQuery);
     if (PEAR::isError($res)) {
         return $res;
     }
     $aOptions = array('noid' => true);
     if (empty($aStateIds)) {
         return;
         // don't fail if there are no transitions.
     }
     foreach ($aStateIds as $iStateId) {
         $res = DBUtil::autoInsert($sTable, array('state_id' => $iStateId, 'transition_id' => $oTransition->getId()), $aOptions);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     return;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:21,代码来源:workflowadminutil.inc.php

示例2: createFeed

 function createFeed($sFeedTitle, $sFeedUrl, $iUserId)
 {
     $aParams = array('user_id' => $iUserId, 'url' => $sFeedUrl, 'title' => $sFeedTitle);
     $res = DBUtil::autoInsert('plugin_rss', $aParams);
     return $res;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:6,代码来源:KTrss.inc.php

示例3: registerPluginHelper

 /**
  * Register the plugin in the DB
  *
  * @param unknown_type $sClassName
  * @param unknown_type $path
  * @param unknown_type $object
  * @param unknown_type $type
  */
 function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type)
 {
     $sql = "SELECT id FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'";
     $res = DBUtil::getOneResult($sql);
     $aValues = array();
     $aValues['namespace'] = $sNamespace;
     $aValues['plugin'] = !empty($this->sNamespace) ? $this->sNamespace : $sNamespace;
     $aValues['classname'] = $sClassName;
     $aValues['pathname'] = $path;
     $aValues['object'] = $object;
     $aValues['viewtype'] = $view;
     $aValues['classtype'] = $type;
     // if record exists - update it.
     if (!empty($res)) {
         $id = $res['id'];
         $updateRes = DBUtil::autoUpdate('plugin_helper', $aValues, $id);
         if (PEAR::isError($updateRes)) {
             return $updateRes;
         }
         return true;
     }
     // Insert into DB
     $res = DBUtil::autoInsert('plugin_helper', $aValues);
     if (PEAR::isError($res)) {
         return $res;
     }
     return true;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:36,代码来源:plugin.inc.php

示例4: saveAssignment

 function saveAssignment($aPermissions)
 {
     $sTable = KTUtil::getTableName('permission_dynamic_assignments');
     $aQuery = array("DELETE FROM {$sTable} WHERE dynamic_condition_id = ?", array($this->getId()));
     $res = DBUtil::runQuery($aQuery);
     if (PEAR::isError($res)) {
         return $res;
     }
     $aInsertOptions = array('noid' => true);
     foreach ($aPermissions as $oPermission) {
         $iPermissionId = KTUtil::getId($oPermission);
         $aInsert = array('dynamic_condition_id' => $this->getId(), 'permission_id' => $iPermissionId);
         $res = DBUtil::autoInsert($sTable, $aInsert, $aInsertOptions);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:18,代码来源:permissiondynamiccondition.inc.php

示例5: createFolderDetailsPermission

 function createFolderDetailsPermission()
 {
     $sPermissionsTable = KTUtil::getTableName('permissions');
     $bExists = DBUtil::getOneResultKey("SELECT COUNT(id) AS cnt FROM {$sPermissionsTable} WHERE name = 'ktcore.permissions.folder_details'", 'cnt');
     if ($bExists) {
         return;
     }
     DBUtil::startTransaction();
     $aPermissionInfo = array('human_name' => 'Core: Folder Details', 'name' => 'ktcore.permissions.folder_details', 'built_in' => true);
     $res = DBUtil::autoInsert($sPermissionsTable, $aPermissionInfo);
     if (PEAR::isError($res)) {
         return $res;
     }
     $iFolderDetailsPermissionId = $res;
     $sQuery = "SELECT id FROM {$sPermissionsTable} WHERE name = ?";
     $aParams = array("ktcore.permissions.read");
     $iReadPermissionId = DBUtil::getOneResultKey(array($sQuery, $aParams), "id");
     $sPermissionAssignmentsTable = KTUtil::getTableName('permission_assignments');
     $sQuery = "SELECT permission_object_id, permission_descriptor_id FROM {$sPermissionAssignmentsTable} WHERE permission_id = ?";
     $aParams = array($iReadPermissionId);
     $aRows = DBUtil::getResultArray(array($sQuery, $aParams));
     foreach ($aRows as $aRow) {
         $aRow['permission_id'] = $iFolderDetailsPermissionId;
         DBUtil::autoInsert($sPermissionAssignmentsTable, $aRow);
     }
     $sDocumentTable = KTUtil::getTableName('documents');
     $sFolderTable = KTUtil::getTableName('folders');
     DBUtil::runQuery("UPDATE {$sDocumentTable} SET permission_lookup_id = NULL");
     DBUtil::runQuery("UPDATE {$sFolderTable} SET permission_lookup_id = NULL");
     DBUtil::commit();
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:UpgradeFunctions.inc.php

示例6: array

 * details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, 
 * California 94120-7775, or email info@knowledgetree.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * KnowledgeTree" logo and retain the original copyright notice. If the display of the 
 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
 * must display the words "Powered by KnowledgeTree" and retain the original 
 * copyright notice.
 * Contributor( s): ______________________________________
 *
 */
$checkup = true;
require_once '../../config/dmsDefaults.php';
$s = array("sql*2.99.5*0*2.99.5/dashlet_disabling.sql", "sql*2.99.5*0*2.99.5/role_allocations.sql", "sql*2.99.5*0*2.99.5/transaction_namespaces.sql", "sql*2.99.5*0*2.99.5/fieldset_field_descriptions.sql", "sql*2.99.5*0*2.99.5/role_changes.sql");
$sTable = KTUtil::getTableName('upgrades');
foreach ($s as $u) {
    var_dump($u);
    $f = array('descriptor' => $u, 'result' => true);
    $res = DBUtil::autoInsert($sTable, $f);
    var_dump($res);
}
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:pre-upgrade-3.0b3.php

示例7: 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

示例8: setDisabledActionsForState

 function setDisabledActionsForState($oState, $aActions)
 {
     $iStateId = KTUtil::getId($oState);
     $sTable = KTUtil::getTableName('workflow_state_disabled_actions');
     $aQuery = array("DELETE FROM {$sTable} WHERE state_id = ?", array($iStateId));
     $res = DBUtil::runQuery($aQuery);
     if (PEAR::isError($res)) {
         return $res;
     }
     if (!is_array($aActions)) {
         return;
     }
     $aOptions = array('noid' => true);
     foreach ($aActions as $sAction) {
         $res = DBUtil::autoInsert($sTable, array('state_id' => $iStateId, 'action_name' => $sAction), $aOptions);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     return;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:21,代码来源:workflowutil.inc.php

示例9: allow_download

 /**
  * This returns
  *
  * @access public
  * @param KTAPI_Document $document
  * @return string
  */
 function allow_download($document, $content_version = null, $multipart = false)
 {
     assert(!is_null($document));
     $content_version = 0;
     $filesize = 0;
     if ($document instanceof KTAPI_Document) {
         $doc_id = $document->documentid;
         $content_version = $document->document->getContentVersionId();
         $filesize = $document->document->getFileSize();
     } else {
         if ($document instanceof Document || $document instanceof DocumentProxy) {
             $doc_id = $document->getId();
             $content_version = $document->getContentVersionId();
             $filesize = $document->getFileSize();
         } else {
             if (is_numeric($document)) {
                 $doc_id = $document;
             } else {
                 die('gracefully');
             }
         }
     }
     //assert(is_a($document, 'KTAPI_Document'));
     $hash = sha1("{$doc_id} {$this->session} {$this->random}");
     $id = DBUtil::autoInsert('download_files', array('document_id' => $doc_id, 'session' => $this->session, 'download_date' => date('Y-m-d H:i:s'), 'content_version' => $content_version, 'filesize' => $filesize, 'hash' => $hash), array('noid' => true));
     return $multipart ? $this->build_multipart_url($hash, $doc_id) : $this->build_url($hash, $doc_id);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:34,代码来源:KTDownloadManager.inc.php

示例10: registerMimeTypes

 /**
  * This associates all the mime types associated with the extractor class.
  *
  */
 public function registerMimeTypes()
 {
     $types = $this->getSupportedMimeTypes();
     if (empty($types)) {
         return;
     }
     $classname = get_class($this);
     $sql = "select id as extractor_id from mime_extractors WHERE name='{$classname}'";
     $rs = DBUtil::getResultArray($sql);
     if (count($rs) == 0) {
         $extractor_id = DBUtil::autoInsert('mime_extractors', array('name' => $classname, 'active' => 1));
     } else {
         $extractor_id = $rs[0]['extractor_id'];
     }
     foreach ($types as $type) {
         $sql = "update mime_types set extractor_id={$extractor_id} where mimetypes='{$type}' and extractor_id is null";
         $rs = DBUtil::runQuery($sql);
     }
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:23,代码来源:extractorCore.inc.php

示例11: do_storeRelationship

 function do_storeRelationship()
 {
     // handle the store, and DON'T give a 500 ;)  does not act on the information.
     global $default;
     $default->log->error(http_build_query($_REQUEST));
     $iFieldsetId = KTUtil::arrayGet($_REQUEST, 'fieldset_id');
     $parent_field = KTUtil::arrayGet($_REQUEST, 'parent_field');
     $parent_lookup = KTUtil::arrayGet($_REQUEST, 'parent_lookup');
     $child_lookups = KTUtil::arrayGet($_REQUEST, 'child_lookups');
     // child lookups is a nested array. in python it would be:
     // child_lookups =
     //  {
     //     field_id:[lookup_id, lookup_id],
     //     field_id:[lookup_id, lookup_id],
     //  }
     $oFieldset =& KTFieldset::get($iFieldsetId);
     $oFieldset->setIsComplete(false);
     $oFieldset->update();
     $oParentInstance = KTMetadataUtil::getOrCreateValueInstanceForLookup($parent_lookup);
     $iBehaviourId = $oParentInstance->getBehaviourId();
     $oParentMetadata =& MetaData::get($oParentInstance->getFieldValueId());
     if (is_null($iBehaviourId)) {
         $oBehaviour =& KTFieldBehaviour::createFromArray(array('name' => 'autoinstance' . $oParentInstance->getId(), 'humanname' => 'Auto instance' . $oParentMetadata->getName(), 'fieldid' => $oParentInstance->getFieldId()));
     } else {
         $oBehaviour =& KTFieldBehaviour::get($iBehaviourId);
     }
     if (PEAR::isError($oBehaviour)) {
         var_dump($oBehaviour);
         return $oBehaviour;
     }
     $iBehaviourId = $oBehaviour->getId();
     $oParentInstance->setBehaviourId($iBehaviourId);
     $oParentInstance->update();
     $sTable = KTUtil::getTableName('field_behaviour_options');
     $aOptions = array('noid' => true);
     $aQuery = array("DELETE FROM {$sTable} WHERE behaviour_id = ?", array($iBehaviourId));
     $res = DBUtil::runQuery($aQuery);
     foreach ($child_lookups as $iFieldId => $aLookups) {
         foreach ($aLookups as $iLookupId) {
             $oValueInstance =& KTMetadataUtil::getOrCreateValueInstanceForLookup($iLookupId);
             if (PEAR::isError($oValueInstance)) {
                 var_dump($oValueInstance);
                 return $oValueInstance;
             }
             $res = DBUtil::autoInsert($sTable, array('behaviour_id' => $iBehaviourId, 'field_id' => $iFieldId, 'instance_id' => $oValueInstance->getId()), $aOptions);
             if (PEAR::isError($res)) {
                 var_dump($res);
                 return $res;
             }
         }
     }
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:52,代码来源:ajaxSimpleConditionals.php

示例12: do_allocate

 function do_allocate()
 {
     $fWorkflowId = KTUtil::arrayGet($_REQUEST, 'fWorkflowId', null);
     $this->startTransaction();
     $sQuery = 'DELETE FROM ' . KTUtil::getTableName('folder_workflow_map') . ' WHERE folder_id = ?';
     $aParams = array($this->oFolder->getId());
     DBUtil::runQuery(array($sQuery, $aParams));
     if (is_null($fWorkflowId)) {
         $this->successRedirectToMain(_kt('Workflow assignment removed.'), 'fFolderId=' . $this->oFolder->getId());
     }
     $aOptions = array('noid' => true);
     $sTable = KTUtil::getTableName('folder_workflow_map');
     if ($fWorkflowId == null) {
         $fWorkflowId = null;
     }
     $res = DBUtil::autoInsert($sTable, array('folder_id' => $this->oFolder->getId(), 'workflow_id' => $fWorkflowId), $aOptions);
     if (PEAR::isError($res)) {
         $this->errorRedirectToMain(_kt('Error assigning workflow.'), 'fFolderId=' . $this->oFolder->getId());
     }
     $this->successRedirectToMain(_kt('Workflow assignment updated.'), 'fFolderId=' . $this->oFolder->getId());
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:21,代码来源:FolderAssociator.php

示例13: copy

 function copy($oDocument, $oDestinationFolder, $sReason = null, $sDestinationDocName = null)
 {
     // 1. generate a new triad of content, metadata and core objects.
     // 2. update the storage path.
     //print '--------------------------------- BEFORE';
     //print_r($oDocument);
     // TODO: this is not optimal. we have get() functions that will do SELECT when we already have the data in arrays
     // get the core record to be copied
     $sDocumentTable = KTUtil::getTableName('documents');
     $sQuery = 'SELECT * FROM ' . $sDocumentTable . ' WHERE id = ?';
     $aParams = array($oDocument->getId());
     $aCoreRow = DBUtil::getOneResult(array($sQuery, $aParams));
     // we unset the id as a new one will be created on insert
     unset($aCoreRow['id']);
     // get a copy of the latest metadata version for the copied document
     $iOldMetadataId = $aCoreRow['metadata_version_id'];
     $sMetadataTable = KTUtil::getTableName('document_metadata_version');
     $sQuery = 'SELECT * FROM ' . $sMetadataTable . ' WHERE id = ?';
     $aParams = array($iOldMetadataId);
     $aMDRow = DBUtil::getOneResult(array($sQuery, $aParams));
     // we unset the id as a new one will be created on insert
     unset($aMDRow['id']);
     // set the name for the document, possibly using name collission
     if (empty($sDestinationDocName)) {
         $aMDRow['name'] = KTDocumentUtil::getUniqueDocumentName($oDestinationFolder, $aMDRow['name']);
     } else {
         $aMDRow['name'] = $sDestinationDocName;
     }
     // get a copy of the latest content version for the copied document
     $iOldContentId = $aMDRow['content_version_id'];
     $sContentTable = KTUtil::getTableName('document_content_version');
     $sQuery = 'SELECT * FROM ' . $sContentTable . ' WHERE id = ?';
     $aParams = array($iOldContentId);
     $aContentRow = DBUtil::getOneResult(array($sQuery, $aParams));
     // we unset the id as a new one will be created on insert
     unset($aContentRow['id']);
     // set the filename for the document, possibly using name collission
     if (empty($sDestinationDocName)) {
         $aContentRow['filename'] = KTDocumentUtil::getUniqueFilename($oDestinationFolder, $aContentRow['filename']);
     } else {
         $aContentRow['filename'] = $sDestinationDocName;
     }
     // create the new document record
     $aCoreRow['modified'] = date('Y-m-d H:i:s');
     $aCoreRow['folder_id'] = $oDestinationFolder->getId();
     // new location.
     $id = DBUtil::autoInsert($sDocumentTable, $aCoreRow);
     if (PEAR::isError($id)) {
         return $id;
     }
     $iNewDocumentId = $id;
     // create the new metadata record
     $aMDRow['document_id'] = $iNewDocumentId;
     $aMDRow['description'] = $aMDRow['name'];
     $id = DBUtil::autoInsert($sMetadataTable, $aMDRow);
     if (PEAR::isError($id)) {
         return $id;
     }
     $iNewMetadataId = $id;
     // the document metadata version is still pointing to the original
     $aCoreUpdate = array();
     $aCoreUpdate['metadata_version_id'] = $iNewMetadataId;
     $aCoreUpdate['metadata_version'] = 0;
     // create the new content version
     $aContentRow['document_id'] = $iNewDocumentId;
     $id = DBUtil::autoInsert($sContentTable, $aContentRow);
     if (PEAR::isError($id)) {
         return $id;
     }
     $iNewContentId = $id;
     // the metadata content version is still pointing to the original
     $aMetadataUpdate = array();
     $aMetadataUpdate['content_version_id'] = $iNewContentId;
     $aMetadataUpdate['metadata_version'] = 0;
     // apply the updates to the document and metadata records
     $res = DBUtil::autoUpdate($sDocumentTable, $aCoreUpdate, $iNewDocumentId);
     if (PEAR::isError($res)) {
         return $res;
     }
     $res = DBUtil::autoUpdate($sMetadataTable, $aMetadataUpdate, $iNewMetadataId);
     if (PEAR::isError($res)) {
         return $res;
     }
     // now, we have a semi-sane document object. get it.
     $oNewDocument = Document::get($iNewDocumentId);
     //print '--------------------------------- AFTER';
     //print_r($oDocument);
     //print '======';
     //print_r($oNewDocument);
     // copy the metadata from old to new.
     $res = KTDocumentUtil::copyMetadata($oNewDocument, $iOldMetadataId);
     if (PEAR::isError($res)) {
         return $res;
     }
     // Ensure the copied document is not checked out
     $oNewDocument->setIsCheckedOut(false);
     $oNewDocument->setCheckedOutUserID(-1);
     // finally, copy the actual file.
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $res = $oStorage->copy($oDocument, $oNewDocument);
//.........这里部分代码省略.........
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:101,代码来源:documentutil.inc.php

示例14: do_useBehaviourAndAssign

 function do_useBehaviourAndAssign()
 {
     $parent_behaviour = KTUtil::arrayGet($_REQUEST, 'parent_behaviour');
     $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id');
     $field_id = KTUtil::arrayGet($_REQUEST, 'field_id');
     $behaviour_id = KTUtil::arrayGet($_REQUEST, 'behaviour_id');
     $lookups_to_assign = KTUtil::arrayGet($_REQUEST, 'lookups_to_assign');
     // array
     $oBehaviour =& $this->oValidator->validateBehaviour($behaviour_id);
     $aValueInstanceIds = array();
     foreach ($lookups_to_assign as $iLookupId) {
         $res = $oValueInstance =& KTValueInstance::createFromArray(array('fieldid' => $field_id, 'behaviourid' => $oBehaviour->getId(), 'fieldvalueid' => abs($iLookupId)));
         $aValueInstanceIds[] = $res->getId();
     }
     if ($parent_behaviour) {
         $oParentBehaviour =& $this->oValidator->validateBehaviour($parent_behaviour);
         $sTable = KTUtil::getTableName('field_behaviour_options');
         $aOptions = array('noid' => true);
         foreach ($aValueInstanceIds as $iId) {
             $res = DBUtil::autoInsert($sTable, array('behaviour_id' => $oParentBehaviour->getId(), 'field_id' => $field_id, 'instance_id' => $iId), $aOptions);
         }
     }
     header('Content-type: application/xml');
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate =& $oTemplating->loadTemplate('ktcore/metadata/conditional/ajax_complex_use_behaviour_and_assign');
     return $oTemplate->render();
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:27,代码来源:ajaxComplexConditionals.php

示例15: _check_session

 /**
  * Checks whether a session exists for the given user and creates a new one or updates the existing one.
  *
  * @author KnowledgeTree Team
  * @access protected
  * @static
  * @param User $user The User object
  * @param int $ip The users IP address
  * @param string $app The originating application type - ws => webservices | webapp => web application | webdav
  * @return array|PEAR_Error Returns the session string and session id (DB) | a PEAR_Error on failure
  */
 function _check_session(&$user, $ip, $app)
 {
     $user_id = $user->getId();
     Session::removeStaleSessions($user_id);
     $config =& KTConfig::getSingleton();
     $validateSession = $config->get('webservice/validateSessionCount', false);
     if ($validateSession) {
         $sql = "SELECT count(*) >= u.max_sessions as over_limit FROM active_sessions ass INNER JOIN users u ON ass.user_id=u.id WHERE ass.user_id = {$user_id} AND ass.apptype != 'ws'";
         $row = DBUtil::getOneResult($sql);
         if (PEAR::isError($row)) {
             return $row;
         }
         if (is_null($row)) {
             return new PEAR_Error('No record found for user?');
         }
         if ($row['over_limit'] + 0 == 1) {
             return new PEAR_Error('Session limit exceeded. Logout of any active sessions.');
         }
     }
     $session = session_id();
     $newSessionRequired = false;
     if ($app == 'ws') {
         $sql = "select id from active_sessions where user_id={$user_id} AND apptype='ws' and ip='{$ip}'";
         $row = DBUtil::getOneResult($sql);
         if (empty($row)) {
             $newSessionRequired = true;
         } else {
             $sessionid = $row['id'];
             $sql = "update active_sessions set session_id='{$session}' where id={$sessionid}";
             DBUtil::runQuery($sql);
         }
     } else {
         $newSessionRequired = true;
     }
     if ($newSessionRequired) {
         $sessionid = DBUtil::autoInsert('active_sessions', array('user_id' => $user_id, 'session_id' => session_id(), 'lastused' => date('Y-m-d H:i:s'), 'ip' => $ip, 'apptype' => $app));
         if (PEAR::isError($sessionid)) {
             return $sessionid;
         }
     }
     return array($session, $sessionid);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:53,代码来源:KTAPISession.inc.php


注:本文中的DBUtil::autoInsert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。