本文整理汇总了PHP中KTUtil::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::getId方法的具体用法?PHP KTUtil::getId怎么用?PHP KTUtil::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrlForDocument
function getUrlForDocument($oDocument)
{
$iDocumentId = KTUtil::getId($oDocument);
$sExt = '.php';
if (KTUtil::arrayGet($_SERVER, 'kt_no_extensions')) {
$sExt = '';
}
return sprintf('%s/view%s?fDocumentId=%d', $GLOBALS['KTRootUrl'], $sExt, $iDocumentId);
}
示例2: do_managetree
function do_managetree()
{
global $default;
// extract.
$iFieldsetId = KTUtil::getId($this->oFieldset);
$iFieldId = KTUtil::getId($this->oField);
$oFieldset =& $this->oFieldset;
$oField =& $this->oField;
$this->oPage->setBreadcrumbDetails(_kt('edit lookup tree'));
$field_id = $iFieldId;
$current_node = KTUtil::arrayGet($_REQUEST, 'current_node', 0);
$subaction = KTUtil::arrayGet($_REQUEST, 'subaction');
// validate
if (empty($field_id)) {
return $this->errorRedirectToMain(_kt("Must select a field to edit."));
}
$oField =& DocumentField::get($field_id);
if (PEAR::isError($oField)) {
return $this->errorRedirectToMain(_kt("Invalid field."));
}
$aErrorOptions = array('redirect_to' => array('editTree', sprintf('field_id=%d', $field_id)));
// under here we do the subaction rendering.
// we do this so we don't have to do _very_ strange things with multiple actions.
//$default->log->debug("Subaction: " . $subaction);
$fieldTree =& new MDTree();
$fieldTree->buildForField($oField->getId());
if ($subaction !== null) {
$target = 'managetree';
$msg = _kt('Changes saved.');
if ($subaction === "addCategory") {
$new_category = KTUtil::arrayGet($_REQUEST, 'category_name');
if (empty($new_category)) {
return $this->errorRedirectTo("managetree", _kt("Must enter a name for the new category."), array("field_id" => $field_id, "fFieldsetId" => $iFieldsetId));
} else {
$this->subact_addCategory($field_id, $current_node, $new_category, $fieldTree);
}
$msg = _kt('Category added') . ': ' . $new_category;
}
if ($subaction === "deleteCategory") {
$this->subact_deleteCategory($fieldTree, $current_node);
$current_node = 0;
// clear out, and don't try and render the newly deleted category.
$msg = _kt('Category removed.');
}
if ($subaction === "linkKeywords") {
$keywords = KTUtil::arrayGet($_REQUEST, 'keywordsToAdd');
$aErrorOptions['message'] = _kt("No keywords selected");
$this->oValidator->notEmpty($keywords, $aErrorOptions);
$this->subact_linkKeywords($fieldTree, $current_node, $keywords);
$current_node = 0;
// clear out, and don't try and render the newly deleted category.
$msg = _kt('Keywords added to category.');
}
if ($subaction === "unlinkKeyword") {
$keyword = KTUtil::arrayGet($_REQUEST, 'keyword_id');
$this->subact_unlinkKeyword($fieldTree, $keyword);
$msg = _kt('Keyword moved to base of tree.');
}
// now redirect
$query = sprintf('field_id=%d&fFieldsetId=%d', $field_id, $iFieldsetId);
return $this->successRedirectTo($target, $msg, $query);
}
if ($fieldTree->root === null) {
return $this->errorRedirectToMain(_kt("Error building tree. Is this a valid tree-lookup field?"));
}
// FIXME extract this from MDTree (helper method?)
$free_metadata = MetaData::getList('document_field_id = ' . $oField->getId() . ' AND (treeorg_parent = 0 OR treeorg_parent IS NULL) AND (disabled = 0)');
// render edit template.
$oTemplate = $this->oValidator->validateTemplate("ktcore/metadata/admin/edit_lookuptree");
$renderedTree = $this->_evilTreeRenderer($fieldTree);
$this->oPage->setTitle(_kt('Edit Lookup Tree'));
if ($current_node == 0) {
$category_name = 'Root';
} else {
$oNode = MDTreeNode::get($current_node);
$category_name = $oNode->getName();
}
$aTemplateData = array("context" => $this, "args" => $this->meldPersistQuery("", "managetree", true), "field" => $oField, "oFieldset" => $oFieldset, "tree" => $fieldTree, "renderedTree" => $renderedTree, "currentNode" => $current_node, 'category_name' => $category_name, "freechildren" => $free_metadata);
return $oTemplate->render($aTemplateData);
}
示例3: nameExists
function nameExists($sName, $oWorkflow)
{
$iWorkflowId = KTUtil::getId($oWorkflow);
$res = KTEntityUtil::getByDict('KTWorkflowState', array('name' => $sName, 'workflow_id' => $iWorkflowId));
// expect KTEntityNoObjects
if (PEAR::isError($res)) {
return false;
}
return true;
}
示例4: array
function &getByLookupAndParentBehaviour($oLookup, $oBehaviour, $aOptions = null)
{
$iLookupId = KTUtil::getId($oLookup);
$iBehaviourId = KTUtil::getId($oBehaviour);
$GLOBALS['default']->log->debug('KTValueInstance::getByLookupAndParentBehaviour: lookup id is ' . print_r($iLookupId, true));
$GLOBALS['default']->log->debug('KTValueInstance::getByLookupAndParentBehaviour: behaviour id is ' . $iBehaviourId);
$sInstanceTable = KTUtil::getTableName('field_value_instances');
$sBehaviourOptionsTable = KTUtil::getTableName('field_behaviour_options');
$aQuery = array("SELECT instance_id FROM {$sBehaviourOptionsTable} AS BO INNER JOIN\n {$sInstanceTable} AS I ON BO.instance_id = I.id WHERE\n BO.behaviour_id = ? AND I.field_value_id = ?", array($iBehaviourId, $iLookupId));
$iId = DBUtil::getOneResultKey($aQuery, 'instance_id');
if (PEAR::isError($iId)) {
$GLOBALS['default']->log->error('KTValueInstance::getByLookupAndParentBehaviour: error from db is: ' . print_r($iId, true));
return $iId;
}
if (is_null($iId)) {
return null;
}
$GLOBALS['default']->log->debug('KTValueInstance::getByLookupAndParentBehaviour: id of instance is ' . $iId);
if (KTUtil::arrayGet($aOptions, 'ids')) {
return $iId;
}
return KTValueInstance::get($iId);
}
示例5: array
function &getByUser($oFolder, $aOptions = null)
{
$aOptions = KTUtil::meldOptions(array('multi' => true), $aOptions);
$iFolderId = KTUtil::getId($oFolder);
return KTEntityUtil::getByDict('KTFolderTransaction', array('folder_id' => $iFolderId), $aOptions);
}
示例6: testConditionOnFolder
function testConditionOnFolder($oSearch, $oFolder)
{
$oSearch =& KTUtil::getObject('KTSavedSearch', $oSearch);
$iFolderId = KTUtil::getId($oFolder);
/*
* Make a new criteria set, an AND of the existing criteria set
* and the sql statement requiring that D.id be the document id
* given to us.
*/
$aCriteriaSet = array("join" => "AND", "subgroup" => array($oSearch->getSearch(), array("join" => "AND", "values" => array(array("sql" => array("F.id = ?", array($iFolderId)))))));
$aOptions = array('select' => 'COUNT(DISTINCT(F.id)) AS cnt');
$aQuery = KTSearchUtil::criteriaToFolderQuery($aCriteriaSet, null, null, $aOptions);
if (PEAR::isError($aQuery)) {
// caused by no permissions being set.
return false;
}
$cnt = DBUtil::getOneResultKey($aQuery, 'cnt');
if (PEAR::isError($cnt)) {
return $cnt;
}
if (is_null($cnt)) {
return false;
}
if (!is_numeric($cnt)) {
return PEAR::raiseError(_kt("Non-integer returned when looking for count"));
}
return $cnt > 0;
}
示例7: array
function &getByTransition($oTransition, $aOptions = null)
{
$iTransitionId = KTUtil::getId($oTransition);
$aOptions = KTUtil::meldOptions($aOptions, array('multi' => true));
return KTEntityUtil::getByDict('KTWorkflowTriggerInstance', array('workflow_transition_id' => $iTransitionId), $aOptions);
}
示例8: getFieldsetsForType
function getFieldsetsForType($iTypeId)
{
$typeid = KTUtil::getId($iTypeId);
$aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false));
$aSpecificFieldsetIds = KTFieldset::getForDocumentType($typeid, array('ids' => false));
$fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds);
return $fieldsets;
}
示例9: array
function &getByDocument($oDocument)
{
$iDocumentId = KTUtil::getId($oDocument);
return KTEntityUtil::getByDict('KTDocumentMetadataVersion', array('document_id' => $iDocumentId), array('multi' => true, 'orderby' => 'version_created DESC'));
}
示例10:
function &getByState($oState)
{
$iStateId = KTUtil::getId($oState);
return KTEntityUtil::GetList2('KTWorkflowStatePermissionAssignment', 'workflow_state_id = ' . $iStateId);
}
示例11: generateStoragePathForVersion
function generateStoragePathForVersion($oContentVersion)
{
$iId = KTUtil::getId($oContentVersion);
$str = (string) $iId;
if (strlen($str) < 4) {
$str = sprintf('%s%s', str_repeat('0', 4 - strlen($str)), $str);
}
if (strlen($str) % 2 == 1) {
$str = sprintf('0%s', $str);
}
$str = substr($str, 0, -2);
$dir = preg_replace('#(\\d\\d)(\\d\\d)#', '\\1/\\2', $str);
// Now, create the directory (including intermediaries)
$oConfig =& KTConfig::getSingleton();
$sDocumentRoot = $oConfig->get('urls/documentRoot');
$path = "";
foreach (split('/', $dir) as $sDirPart) {
$path = sprintf('%s/%s', $path, $sDirPart);
$createPath = sprintf('%s%s', $sDocumentRoot, $path);
if (!file_exists($createPath)) {
$res = @mkdir($createPath, 0777, true);
if ($res === false) {
return PEAR::raiseError(_kt("Could not create directory for storage" . ': ' . $createPath));
}
}
}
return sprintf("%s/%d", $dir, $iId);
}
示例12: pathinfo
function &_add($oFolder, $sFilename, $oUser, $aOptions)
{
global $default;
//$oContents = KTUtil::arrayGet($aOptions, 'contents');
$aMetadata = KTUtil::arrayGet($aOptions, 'metadata', null, false);
$oDocumentType = KTUtil::arrayGet($aOptions, 'documenttype');
$sDescription = KTUtil::arrayGet($aOptions, 'description', '');
if (empty($sDescription)) {
// If no document name is provided use the filename minus the extension
$aFile = pathinfo($sFilename);
$sDescription = isset($aFile['filename']) && !empty($aFile['filename']) ? $aFile['filename'] : $sFilename;
}
$oUploadChannel =& KTUploadChannel::getSingleton();
if ($oDocumentType) {
$iDocumentTypeId = KTUtil::getId($oDocumentType);
} else {
$iDocumentTypeId = 1;
}
$oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating database entry')));
$oDocument =& Document::createFromArray(array('name' => $sDescription, 'description' => $sDescription, 'filename' => $sFilename, 'folderid' => $oFolder->getID(), 'creatorid' => $oUser->getID(), 'documenttypeid' => $iDocumentTypeId));
$oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Storing contents')));
$res = KTDocumentUtil::storeContents($oDocument, '', $aOptions);
if (PEAR::isError($res)) {
if (!PEAR::isError($oDocument)) {
$oDocument->delete();
}
return $res;
}
if (is_null($aMetadata)) {
$res = KTDocumentUtil::setIncomplete($oDocument, 'metadata');
if (PEAR::isError($res)) {
$oDocument->delete();
return $res;
}
} else {
$oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Saving metadata')));
$res = KTDocumentUtil::saveMetadata($oDocument, $aMetadata, $aOptions);
if (PEAR::isError($res)) {
$oDocument->delete();
return $res;
}
}
// setIncomplete and storeContents may change the document's status or
// storage_path, so now is the time to update
$oDocument->update();
return $oDocument;
}
示例13: array
function &getByDocument($oDocument, $aOptions = null)
{
$aOptions = KTUtil::meldOptions(array('multi' => true), $aOptions);
$iDocumentId = KTUtil::getId($oDocument);
return KTEntityUtil::getByDict('KTDocumentContentVersion', array('document_id' => $iDocumentId), $aOptions);
}
示例14: do_assistance
function do_assistance()
{
$sSubject = $this->oValidator->validateString($_REQUEST['subject']);
$sDetails = $this->oValidator->validateString($_REQUEST['details']);
$aUsers = array();
$aGroups = array();
$aRoles = array();
foreach (Group::getAdministratorGroups() as $oGroup) {
$aGroups[$oGroup->getId()] =& $oGroup;
}
foreach (Unit::getUnitsForFolder($this->oDocument->getFolderId()) as $oUnit) {
foreach (Group::getUnitAdministratorGroupsByUnit($oUnit) as $oGroup) {
$aGroups[$oGroup->getId()] =& $oGroup;
}
}
$aRoles[-2] = Role::get(-2);
$oDocument =& $this->oDocument;
foreach ($aRoles as $oRole) {
// Ignore anonymous or Everyone roles
$iRoleId = KTUtil::getId($oRole);
if ($iRoleId == -3 || $iRoleId == -4) {
continue;
}
// first try on the document, then the folder above it.
$oRoleAllocation = DocumentRoleAllocation::getAllocationsForDocumentAndRole($oDocument->getId(), $iRoleId);
if (is_null($oRoleAllocation)) {
// if we don't get a document role, try folder role.
$oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($oDocument->getFolderID(), $oRole->getId());
}
if (is_null($oRoleAllocation) || PEAR::isError($oRoleAllocation)) {
continue;
}
$aRoleUsers = $oRoleAllocation->getUsers();
$aRoleGroups = $oRoleAllocation->getGroups();
foreach ($aRoleUsers as $id => $oU) {
$aUsers[$id] = $oU;
}
foreach ($aRoleGroups as $id => $oGroup) {
$aGroups[$id] = $oGroup;
}
}
$aGroupMembershipSet = GroupUtil::buildGroupArray();
$aAllIds = array_keys($aGroups);
foreach ($aGroups as $id => $oGroup) {
$aAllIds = kt_array_merge($aGroupMembershipSet[$id], $aAllIds);
}
foreach ($aAllIds as $id) {
if (!array_key_exists($id, $aGroups)) {
$aGroups[$id] = Group::get($id);
}
}
// now, merge this (again) into the user-set.
foreach ($aGroups as $oGroup) {
$aNewUsers = $oGroup->getMembers();
foreach ($aNewUsers as $oU) {
$id = $oU->getId();
if (!array_key_exists($id, $aUsers)) {
$aUsers[$id] = $oU;
}
}
}
foreach ($aUsers as $oU) {
if (!PEAR::isError($oU)) {
KTAssistNotification::newNotificationForDocument($this->oDocument, $oU, $this->oUser, $sSubject, $sDetails);
}
}
$this->commitTransaction();
$params = 'fDocumentId=' . $oDocument->getId();
$url = generateControllerLink('viewDocument', $params);
exit(redirect($url));
}
示例15: replaceState
function replaceState($oState, $oReplacement)
{
$state_id = KTUtil::getId($oState);
$replacement_id = KTUtil::getId($oReplacement);
// we need to convert:
// - documents
// - transitions
// before we do a delete.
$doc = KTUtil::getTableName('document_metadata_version');
$aDocQuery = array("UPDATE {$doc} SET workflow_state_id = ? WHERE workflow_state_id = ?", array($replacement_id, $state_id));
$res = DBUtil::runQuery($aDocQuery);
if (PEAR::isError($res)) {
return $res;
}
$wf = KTUtil::getTableName('workflow_transitions');
$aTransitionQuery = array("UPDATE {$wf} SET target_state_id = ? WHERE target_state_id = ?", array($replacement_id, $state_id));
$res = DBUtil::runQuery($aTransitionQuery);
if (PEAR::isError($res)) {
return $res;
}
$wf = KTUtil::getTableName('workflow_state_transitions');
$aTransitionQuery = array("DELETE FROM {$wf} WHERE state_id = ?", array($state_id));
$res = DBUtil::runQuery($aTransitionQuery);
if (PEAR::isError($res)) {
return $res;
}
Document::clearAllCaches();
}