本文整理汇总了PHP中KTUtil::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::getTableName方法的具体用法?PHP KTUtil::getTableName怎么用?PHP KTUtil::getTableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::getTableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_main
function do_main()
{
$this->oPage->setBreadcrumbDetails(_kt("transactions"));
$this->oPage->setTitle(_kt('Folder transactions'));
$folder_data = array();
$folder_data["folder_id"] = $this->oFolder->getId();
$this->oPage->setSecondaryTitle($this->oFolder->getName());
$aTransactions = array();
// FIXME do we really need to use a raw db-access here? probably...
$sQuery = "SELECT DTT.name AS transaction_name, FT.transaction_namespace, U.name AS user_name, FT.comment AS comment, FT.datetime AS datetime " . "FROM " . KTUtil::getTableName("folder_transactions") . " AS FT LEFT JOIN " . KTUtil::getTableName("users") . " AS U ON FT.user_id = U.id " . "LEFT JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = FT.transaction_namespace " . "WHERE FT.folder_id = ? ORDER BY FT.datetime DESC";
$aParams = array($this->oFolder->getId());
$res = DBUtil::getResultArray(array($sQuery, $aParams));
if (PEAR::isError($res)) {
var_dump($res);
// FIXME be graceful on failure.
exit(0);
}
// FIXME roll up view transactions
$aTransactions = $res;
// Set the namespaces where not in the transactions lookup
foreach ($aTransactions as $key => $transaction) {
if (empty($transaction['transaction_name'])) {
$aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']);
}
}
// render pass.
$this->oPage->title = _kt("Folder History");
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate("kt3/view_folder_history");
$aTemplateData = array("context" => $this, "folder_id" => $folder_id, "folder" => $this->oFolder, "transactions" => $aTransactions);
return $oTemplate->render($aTemplateData);
}
示例2: transform
function transform()
{
global $default;
$iMimeTypeId = $this->oDocument->getMimeTypeId();
$sMimeType = KTMime::getMimeTypeName($iMimeTypeId);
$sFileName = $this->oDocument->getFileName();
$aTestTypes = array('application/octet-stream', 'application/zip', 'application/x-zip');
if (in_array($sMimeType, $aTestTypes)) {
$sExtension = KTMime::stripAllButExtension($sFileName);
$sTable = KTUtil::getTableName('mimetypes');
$sQuery = "SELECT id, mimetypes FROM {$sTable} WHERE LOWER(filetypes) = ?";
$aParams = array($sExtension);
$aRow = DBUtil::getOneResult(array($sQuery, $aParams));
if (PEAR::isError($aRow)) {
$default->log->debug("ODI: error in query: " . print_r($aRow, true));
return;
}
if (empty($aRow)) {
$default->log->debug("ODI: query returned entry");
return;
}
$id = $aRow['id'];
$mimetype = $aRow['mimetypes'];
$default->log->debug("ODI: query returned: " . print_r($aRow, true));
if (in_array($mimetype, $aTestTypes)) {
// Haven't changed, really not an OpenDocument file...
return;
}
if ($id) {
$this->oDocument->setMimeTypeId($id);
$this->oDocument->update();
}
}
parent::transform();
}
示例3: do_main
function do_main()
{
$this->oPage->setSecondaryTitle($this->oDocument->getName());
$this->oPage->setBreadcrumbDetails(_kt('history'));
$aTransactions = array();
// FIXME create a sane "view user information" page somewhere.
// FIXME do we really need to use a raw db-access here? probably...
$sQuery = 'SELECT DTT.name AS transaction_name, DT.transaction_namespace, U.name AS user_name, DT.version AS version, DT.comment AS comment, DT.datetime AS datetime ' . 'FROM ' . KTUtil::getTableName('document_transactions') . ' AS DT INNER JOIN ' . KTUtil::getTableName('users') . ' AS U ON DT.user_id = U.id ' . 'LEFT JOIN ' . KTUtil::getTableName('transaction_types') . ' AS DTT ON DTT.namespace = DT.transaction_namespace ' . 'WHERE DT.document_id = ? ORDER BY DT.datetime DESC';
$aParams = array($this->oDocument->getId());
$res = DBUtil::getResultArray(array($sQuery, $aParams));
if (PEAR::isError($res)) {
var_dump($res);
// FIXME be graceful on failure.
exit(0);
}
$aTransactions = $res;
// Set the namespaces where not in the transactions lookup
foreach ($aTransactions as $key => $transaction) {
if (empty($transaction['transaction_name'])) {
$aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']);
}
}
// render pass.
$this->oPage->setTitle(_kt('Document History'));
$oTemplate = $this->oValidator->validateTemplate('ktcore/document/transaction_history');
$aTemplateData = array('context' => $this, 'document_id' => $this->oDocument->getId(), 'document' => $this->oDocument, 'transactions' => $aTransactions);
return $oTemplate->render($aTemplateData);
}
示例4: do_update
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'));
}
示例5: outputHelpImage
function outputHelpImage($sSubPath)
{
// FIXME there are error cases here ...
$aPathInfo = KTHelp::_getLocationInfo($sSubPath);
if (PEAR::isError($aPathInfo)) {
return $aPathInfo;
}
// gets caught further up the stack
$pi = pathinfo($aPathInfo['external']);
$mime_type = "";
$sExtension = KTUtil::arrayGet($pi, 'extension');
if (!empty($sExtension)) {
$mime_type = DBUtil::getOneResultKey(array("SELECT mimetypes FROM " . KTUtil::getTableName('mimetypes') . " WHERE LOWER(filetypes) = ?", $sExtension), "mimetypes");
}
header("Content-Type: {$mime_type}");
header("Content-Length: " . filesize($fspath));
readfile($fspath);
// does this output it?!
exit(0);
}
示例6: KTWorkflowAssociationDelegator
function KTWorkflowAssociationDelegator()
{
$oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
$aTriggers = $oKTTriggerRegistry->getTriggers('workflow', 'objectModification');
// if we have _some_ triggers.
if (!empty($aTriggers)) {
$sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection');
$sQuery .= ' WHERE event_ns = ?';
$aParams = array('ktstandard.workflowassociation.handler');
$res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns');
if (PEAR::isError($res)) {
$this->_handler = new KTWorkflowAssociationHandler();
}
if (array_key_exists($res, $aTriggers)) {
$this->_handler = new $aTriggers[$res][0]();
} else {
$this->_handler = new KTWorkflowAssociationHandler();
}
} else {
$this->_handler = new KTWorkflowAssociationHandler();
}
}
示例7: _table
function _table()
{
return KTUtil::getTableName('workflow_trigger_instances');
}
示例8: htmlentities
if (PEAR::isError($dbSupport)) {
print '<p><font color="red">Database support is not currently working. Error is: ' . htmlentities($dbSupport->toString()) . '</font></p>';
} else {
?>
<p>Database connectivity successful.</p>
<h3>Privileges</h3>
<?php
$selectPriv = DBUtil::runQuery('SELECT COUNT(id) FROM ' . $default->documents_table);
if (PEAR::isError($selectPriv)) {
print '<p><font color="red">Unable to do a basic database query.
Error is: ' . htmlentities($selectPriv->toString()) . '</font></p>';
} else {
print '<p>Basic database query successful.</p>';
}
$sTable = KTUtil::getTableName('system_settings');
DBUtil::startTransaction();
$res = DBUtil::autoInsert($sTable, array('name' => 'transactionTest', 'value' => 1));
DBUtil::rollback();
$res = DBUtil::getOneResultKey("SELECT id FROM {$sTable} WHERE name = 'transactionTest'", 'id');
if (!empty($res)) {
print '<p><font color="red">Transaction support not available in database</font></p>';
} else {
print '<p>Database has transaction support.</p>';
}
DBUtil::whereDelete($sTable, array('name' => 'transactionTest'));
?>
<?php
}
?>
示例9: 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();
}
示例10: get_transaction_history
/**
* This returns the transaction history for the document.
*
* @author KnowledgeTree Team
* @access public
* @return array The list of transactions | a PEAR_Error on failure
*/
function get_transaction_history()
{
$sQuery = 'SELECT DTT.name AS transaction_name, U.name AS username, DT.version AS version, DT.comment AS comment, DT.datetime AS datetime ' . 'FROM ' . KTUtil::getTableName('document_transactions') . ' AS DT INNER JOIN ' . KTUtil::getTableName('users') . ' AS U ON DT.user_id = U.id ' . 'INNER JOIN ' . KTUtil::getTableName('transaction_types') . ' AS DTT ON DTT.namespace = DT.transaction_namespace ' . 'WHERE DT.document_id = ? ORDER BY DT.datetime DESC';
$aParams = array($this->documentid);
$transactions = DBUtil::getResultArray(array($sQuery, $aParams));
if (is_null($transactions) || PEAR::isError($transactions)) {
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $transactions);
}
$config = KTConfig::getSingleton();
$wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
foreach ($transactions as $key => $transaction) {
$transactions[$key]['version'] = (double) $transaction['version'];
}
return $transactions;
}
示例11: _getDocumentQuery
function _getDocumentQuery($aOptions = null)
{
$oUser = User::get($_SESSION['userID']);
$res = KTSearchUtil::permissionToSQL($oUser, $this->sPermissionName);
if (PEAR::isError($res)) {
return $res;
}
list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $res;
$aPotentialWhere = array($sPermissionString, 'D.folder_id = ?', 'D.status_id = ' . ARCHIVED);
$aWhere = array();
foreach ($aPotentialWhere as $sWhere) {
if (empty($sWhere)) {
continue;
}
if ($sWhere == '()') {
continue;
}
$aWhere[] = $sWhere;
}
$sWhere = '';
if ($aWhere) {
$sWhere = "\tWHERE " . join(' AND ', $aWhere);
}
$sSelect = KTUtil::arrayGet($aOptions, 'select', 'D.id');
$sQuery = sprintf('SELECT %s FROM %s AS D
LEFT JOIN %s AS DM ON D.metadata_version_id = DM.id
LEFT JOIN %s AS DC ON DM.content_version_id = DC.id
%s %s', $sSelect, KTUtil::getTableName('documents'), KTUtil::getTableName('document_metadata_version'), KTUtil::getTableName('document_content_version'), $sPermissionJoin, $sWhere);
$aParams = array();
$aParams = kt_array_merge($aParams, $aPermissionParams);
$aParams[] = $this->folder_id;
return array($sQuery, $aParams);
}
示例12: delete
function delete($oStartFolder, $oUser, $sReason, $aOptions = null, $bulk_action = false)
{
require_once KT_LIB_DIR . '/unitmanagement/Unit.inc';
$oPerm = KTPermission::getByName('ktcore.permissions.delete');
$bIgnorePermissions = KTUtil::arrayGet($aOptions, 'ignore_permissions');
$aFolderIds = array();
// of oFolder
$aDocuments = array();
// of oDocument
$aFailedDocuments = array();
// of String
$aFailedFolders = array();
// of String
$aRemainingFolders = array($oStartFolder->getId());
DBUtil::startTransaction();
while (!empty($aRemainingFolders)) {
$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));
}
$oUnit = Unit::getByFolder($oFolder);
if (!empty($oUnit)) {
DBUtil::rollback();
return PEAR::raiseError(sprintf(_kt('Cannot remove unit folder: %s.'), $oFolder->getName()));
}
// don't just stop ... plough on.
if (!$bIgnorePermissions && !KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oFolder)) {
$aFailedFolders[] = $oFolder->getName();
} else {
$aFolderIds[] = $iFolderId;
}
// child documents
$aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId)));
foreach ($aChildDocs as $oDoc) {
if (!$bIgnorePermissions && $oDoc->getImmutable()) {
if (!KTBrowseUtil::inAdminMode($oUser, $oStartFolder)) {
$aFailedDocuments[] = $oDoc->getName();
continue;
}
}
if ($bIgnorePermissions || KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDoc) && $oDoc->getIsCheckedOut() == false) {
$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);
}
// FIXME we could subdivide this to provide a per-item display (viz. bulk upload, etc.)
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 delete these items. ') . $sFD . $sFF);
}
// now we can go ahead.
foreach ($aDocuments as $oDocument) {
$res = KTDocumentUtil::delete($oDocument, $sReason);
if (PEAR::isError($res)) {
DBUtil::rollback();
return PEAR::raiseError(_kt('Delete Aborted. Unexpected failure to delete document: ') . $oDocument->getName() . $res->getMessage());
}
}
$oStorage =& KTStorageManagerUtil::getSingleton();
$oStorage->removeFolderTree($oStartFolder);
// Check for symbolic links to the folder and its sub folders
$aSymlinks = array();
foreach ($aFolderIds as $iFolder) {
$oFolder = Folder::get($iFolder);
$aLinks = $oFolder->getSymbolicLinks();
$aSymlinks = array_merge($aSymlinks, $aLinks);
}
// documents all cleared.
$sQuery = 'DELETE FROM ' . KTUtil::getTableName('folders') . ' WHERE id IN (' . DBUtil::paramArray($aFolderIds) . ')';
$aParams = $aFolderIds;
$res = DBUtil::runQuery(array($sQuery, $aParams));
if (PEAR::isError($res)) {
DBUtil::rollback();
return PEAR::raiseError(_kt('Failure deleting folders.'));
}
// now that the folder has been deleted we delete all the shortcuts
if (!empty($aSymlinks)) {
$links = array();
foreach ($aSymlinks as $link) {
$links[] = $link['id'];
}
$linkIds = implode(',', $links);
$query = "DELETE FROM folders WHERE id IN ({$linkIds})";
DBUtil::runQuery($query);
}
/*
//.........这里部分代码省略.........
示例13: rebuildPermissionLookups
function rebuildPermissionLookups($bEmptyOnly = true)
{
if ($bEmptyOnly) {
$sTable = KTUtil::getTableName('folders');
$sQuery = sprintf("SELECT id FROM %s WHERE permission_lookup_id IS NULL AND permission_object_id IS NOT NULL", $sTable);
} else {
$sTable = KTUtil::getTableName('folders');
$sQuery = sprintf("SELECT id FROM %s WHERE permission_object_id IS NOT NULL", $sTable);
}
$aIds = DBUtil::getResultArrayKey($sQuery, 'id');
foreach ($aIds as $iId) {
$oFolder =& Folder::get($iId);
KTPermissionUtil::updatePermissionLookup($oFolder);
}
if ($bEmptyOnly) {
$sTable = KTUtil::getTableName('documents');
$sQuery = sprintf("SELECT id FROM %s WHERE permission_lookup_id IS NULL", $sTable);
} else {
$sTable = KTUtil::getTableName('documents');
$sQuery = sprintf("SELECT id FROM %s", $sTable);
}
$aIds = DBUtil::getResultArrayKey($sQuery, 'id');
foreach ($aIds as $iId) {
$oDocument =& Document::get($iId);
KTPermissionUtil::updatePermissionLookup($oDocument);
}
}
示例14: transform
function transform()
{
$iMimeTypeId = $this->oDocument->getMimeTypeId();
$sMimeType = KTMime::getMimeTypeName($iMimeTypeId);
if (!array_key_exists($sMimeType, $this->mimetypes)) {
return;
}
$oStorage = KTStorageManagerUtil::getSingleton();
$sFile = $oStorage->temporaryFile($this->oDocument);
$tempstub = 'transform';
if ($this->command != null) {
$tempstub = $this->command;
}
$oKTConfig =& KTConfig::getSingleton();
$sBasedir = $oKTConfig->get("urls/tmpDirectory");
$myfilename = tempnam($sBasedir, 'kt.' . $tempstub);
if (OS_WINDOWS) {
$intermediate = tempnam($sBasedir, 'kt.' . $tempstub);
if (!@copy($sFile, $intermediate)) {
return;
}
} else {
$intermediate = $sFile;
}
$contents = $this->extract_contents($intermediate, $myfilename);
@unlink($myfilename);
if (OS_WINDOWS) {
@unlink($intermediate);
}
if (empty($contents)) {
return;
}
$aInsertValues = array('document_id' => $this->oDocument->getId(), 'document_text' => $contents);
$sTable = KTUtil::getTableName('document_text');
// clean up the document query "stuff".
// FIXME this suggests that we should move the _old_ document_searchable_text across to the old-document's id if its a checkin.
DBUtil::runQuery(array('DELETE FROM ' . $sTable . ' WHERE document_id = ?', array($this->oDocument->getId())));
DBUtil::autoInsert($sTable, $aInsertValues, array('noid' => true));
}
示例15: array
function &getAssociatedTypes()
{
// NOTE: this returns null if we are generic (all is the wrong answer)
if ($this->getIsGeneric()) {
return array();
}
$sTable = KTUtil::getTableName('document_type_fieldsets');
$aQuery = array("SELECT document_type_id FROM {$sTable} WHERE fieldset_id = ?", array($this->getId()));
$aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id');
$aRet = array();
foreach ($aIds as $iID) {
$oType = DocumentType::get($iID);
if (!PEAR::isError($oType)) {
$aRet[] = $oType;
}
}
return $aRet;
}