本文整理汇总了PHP中Folder::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::getList方法的具体用法?PHP Folder::getList怎么用?PHP Folder::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::getList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _importfolder
function _importfolder($oFolder, $sPath)
{
$oPermission = KTPermission::getByName('ktcore.permissions.addFolder');
$aDocPaths = $this->oStorage->listDocuments($sPath);
if (PEAR::isError($aDocPaths)) {
return $aDocPaths;
}
$oDocObjects = array();
foreach ($aDocPaths as $sDocumentPath) {
$res = $this->_importdocument($oFolder, $sDocumentPath);
if (PEAR::isError($res)) {
return $res;
}
// Store document object
$this->uploadedDocs[] = $res;
}
$aFolderPaths = $this->oStorage->listFolders($sPath);
if (PEAR::isError($aFolderPaths)) {
return $aFolderPaths;
}
$oFolderObjects = array();
foreach ($aFolderPaths as $sFolderPath) {
$sFolderBasePath = basename($sFolderPath);
$sFolderBasePath = $this->is_utf8($sFolderBasePath) ? $sFolderBasePath : utf8_encode($sFolderBasePath);
if (Folder::folderExistsName($sFolderPath, KTUtil::getId($oFolder))) {
$_SESSION['KTErrorMessage'][] = sprintf(_kt("The folder %s is already present in %s. Adding files into pre-existing folder."), $sFolderBasePath, $oFolder->getName());
$aOptions = Folder::getList("parent_id = " . KTUtil::getId($oFolder) . ' AND name = "' . DBUtil::escapeSimple($sFolderBasePath) . '"');
if (PEAR::isError($aOptions)) {
return $aOptions;
}
if (count($aOptions) != 1) {
return PEAR::raiseError(sprintf(_kt("Two folders named %s present in %s. Unable to decide which to use..."), $sFolderName, $oFolder->getName()));
} else {
$oThisFolder = $aOptions[0];
}
} else {
if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $oFolder)) {
$oThisFolder = KTFolderUtil::add($oFolder, $sFolderBasePath, $this->oUser, true);
} else {
$oThisFolder = $oFolder;
if (!in_array('Your documents have been added to this folder and not the folder structure within the upload file because you do not have permission to add any folders.', $_SESSION['KTErrorMessage'])) {
$_SESSION['KTErrorMessage'][] = sprintf(_kt('Your documents have been added to this folder and not the folder structure within the upload file because you do not have permission to add any folders.'));
}
}
}
if (PEAR::isError($oThisFolder)) {
return $oThisFolder;
}
$res = $this->_importfolder($oThisFolder, $sFolderPath);
if (PEAR::isError($res)) {
return $res;
}
// Store folder object
$this->uploadedFolders[] = $res;
}
}
示例2: _GETFolder
/**
* GET method helper
*
* @param array parameter passing array
* @param int MainFolder ID
* @return bool true on success
*/
function _GETFolder(&$options, $iMainFolderID)
{
global $default;
$this->ktwebdavLog("Entering _GETFolder. options are " . print_r($options, true), 'info', true);
$oMainFolder =& Folder::get($iMainFolderID);
$aFolderID = array();
$aChildren = Folder::getList(array('parent_id = ?', $iMainFolderID));
// $sFolderName = $oMainFolder->getName();
if (is_writeable("../var") && is_writeable("../var/log")) {
$writeperms = "<font color=\"green\"><b>OK</b></font>";
} else {
$writeperms = "<font color=\"red\"><b>NOT SET</b></font>";
}
if ($this->ktdmsPath != '') {
$ktdir = $this->ktdmsPath;
}
$srv_proto = split('/', $_SERVER['SERVER_PROTOCOL']);
$proto = strtolower($srv_proto[0]);
// check if ssl enabled
if ($proto == 'http' && $default->sslEnabled) {
$proto = 'https';
}
$dataSafe = '';
if ($this->safeMode != 'off') {
$dataSafe = "<div style=\"color: orange;\" align=\"center\">NOTE: Safe mode is currently enabled, only viewing and downloading of documents will be allowed.</div><br><br>";
}
$data = "<html><head><title>KTWebDAV - The KnowledgeTree WebDAV Server</title></head>";
$data .= "<body>";
$data .= "<div align=\"center\"><IMG src=\"../resources/graphics/ktlogo-topbar_base.png\" width=\"308\" height=\"61\" border=\"0\"></div><br>";
$data .= "<div align=\"center\"><h2><strong>Welcome to KnowledgeTree WebDAV Server</strong></h2></div><br><br>";
$data .= "<div align=\"center\">To access KTWebDAV copy the following URL and paste it into your WebDAV enabled client...</div><br><br>";
$data .= $dataSafe;
$data .= "<div align=\"center\"><strong>" . $proto . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "</strong></div>";
$data .= "</body>";
$options['mimetype'] = 'text/html';
$options["data"] = $data;
return true;
}
示例3: 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..
//.........这里部分代码省略.........
示例4: updatePermissionLookupRecursive
/**
* Updates permission lookups for this folder and any ancestors, but
* only if they use the same permission object.
*
* To be used any time a folder permission object is changed.
*/
function updatePermissionLookupRecursive(&$oDocumentOrFolder)
{
if (is_a($oDocumentOrFolder, 'Document')) {
// XXX: metadata versions may need attention here
KTPermissionUtil::updatePermissionLookup($oDocumentOrFolder);
return;
}
$iFolderID = $oDocumentOrFolder->getID();
$sFolderIDs = Folder::generateFolderIDs($iFolderID);
$sFolderIDs .= '%';
$sWhere = 'permission_object_id = ? AND parent_folder_ids LIKE ?';
$aParams = array($oDocumentOrFolder->getPermissionObjectID(), $sFolderIDs);
$aFolders =& Folder::getList(array($sWhere, $aParams));
foreach ($aFolders as $oFolder) {
KTPermissionUtil::updatePermissionLookup($oFolder);
}
$aDocuments =& Document::getList(array($sWhere, $aParams));
foreach ($aDocuments as $oDocument) {
KTPermissionUtil::updatePermissionLookup($oDocument);
}
}
示例5: checkDirectory
}
}
}
checkDirectory('');
print "\n";
print "Would remove these folders (and all their contents):\n";
foreach ($aFoldersToRemove as $path) {
print "\t{$path}\n";
}
print "\n";
print "Would remove these files:\n";
foreach ($aFilesToRemove as $path) {
print "\t{$path}\n";
}
print "\n";
$aFolders =& Folder::getList();
foreach ($aFolders as $oFolder) {
checkRepoFolder($oFolder);
}
print "These folders are not on the filesystem:\n";
foreach ($aRepoFolderProblems as $path) {
print "\t{$path}\n";
}
$aDocuments =& Document::getList(array('status_id = ?', array(LIVE)));
foreach ($aDocuments as $oDocument) {
checkRepoDocument($oDocument);
}
print "\n";
print "These documents are not on the filesystem:\n";
foreach ($aRepoDocumentProblems as $path) {
print "\t{$path}\n";
示例6: get_full_listing
/**
* Get's a folder listing, recursing to the maximum depth.
* Derived from the get_listing function.
*
* <code>
* $root = $this->ktapi->get_root_folder();
* $listing = $root->get_full_listing();
* foreach($listing as $val) {
* if($val['item_type'] == 'F') {
* // It's a folder
* echo $val['title'];
* }
* }
* </code>
*
* @author KnowledgeTree Team
* @access public
* @param string $what
* @return array
*/
function get_full_listing($what = 'DFS')
{
$what = strtoupper($what);
$read_permission =& KTPermission::getByName(KTAPI_PERMISSION_READ);
$folder_permission =& KTPermission::getByName(KTAPI_PERMISSION_VIEW_FOLDER);
$config = KTConfig::getSingleton();
$wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
$user = $this->ktapi->get_user();
$contents = array();
if (strpos($what, 'F') !== false) {
$folder_children = Folder::getList(array('parent_id = ?', $this->folderid));
foreach ($folder_children as $folder) {
if (KTPermissionUtil::userHasPermissionOnItem($user, $folder_permission, $folder) || KTPermissionUtil::userHasPermissionOnItem($user, $read_permission, $folder)) {
$sub_folder =& $this->ktapi->get_folder_by_id($folder->getId());
if (!PEAR::isError($sub_folder)) {
$items = $sub_folder->get_full_listing($what);
} else {
$items = array();
}
$creator = $this->_resolve_user($folder->getCreatorID());
if ($wsversion >= 2) {
$array = array('id' => (int) $folder->getId(), 'item_type' => 'F', 'custom_document_no' => 'n/a', 'oem_document_no' => 'n/a', 'title' => $folder->getName(), 'document_type' => 'n/a', 'filename' => $folder->getName(), 'filesize' => 'n/a', 'created_by' => is_null($creator) ? 'n/a' : $creator->getName(), 'created_date' => 'n/a', 'checked_out_by' => 'n/a', 'checked_out_date' => 'n/a', 'modified_by' => 'n/a', 'modified_date' => 'n/a', 'owned_by' => 'n/a', 'version' => 'n/a', 'is_immutable' => 'n/a', 'permissions' => KTAPI_Folder::get_permission_string($folder), 'workflow' => 'n/a', 'workflow_state' => 'n/a', 'mime_type' => 'folder', 'mime_icon_path' => 'folder', 'mime_display' => 'Folder', 'storage_path' => 'n/a');
if ($wsversion >= 3) {
$array['linked_folder_id'] = $folder->getLinkedFolderId();
if ($folder->isSymbolicLink()) {
$array['item_type'] = "S";
}
}
$array['items'] = $items;
if ($wsversion < 3 || strpos($what, 'F') !== false && !$folder->isSymbolicLink() || $folder->isSymbolicLink() && strpos($what, 'S') !== false) {
$contents[] = $array;
}
} else {
$contents[] = array('id' => (int) $folder->getId(), 'item_type' => 'F', 'title' => $folder->getName(), 'creator' => is_null($creator) ? 'n/a' : $creator->getName(), 'checkedoutby' => 'n/a', 'modifiedby' => 'n/a', 'filename' => $folder->getName(), 'size' => 'n/a', 'major_version' => 'n/a', 'minor_version' => 'n/a', 'storage_path' => 'n/a', 'mime_type' => 'folder', 'mime_icon_path' => 'folder', 'mime_display' => 'Folder', 'items' => $items, 'workflow' => 'n/a', 'workflow_state' => 'n/a');
}
}
}
}
if (strpos($what, 'D') !== false) {
$document_children = Document::getList(array('folder_id = ? AND status_id = 1', $this->folderid));
// I hate that KT doesn't cache things nicely...
$mime_cache = array();
foreach ($document_children as $document) {
if (KTPermissionUtil::userHasPermissionOnItem($user, $read_permission, $document)) {
$created_by = $this->_resolve_user($document->getCreatorID());
$created_date = $document->getCreatedDateTime();
if (empty($created_date)) {
$created_date = 'n/a';
}
$checked_out_by = $this->_resolve_user($document->getCheckedOutUserID());
$checked_out_date = $document->getCheckedOutDate();
if (empty($checked_out_date)) {
$checked_out_date = 'n/a';
}
$modified_by = $this->_resolve_user($document->getCreatorID());
$modified_date = $document->getLastModifiedDate();
if (empty($modified_date)) {
$modified_date = 'n/a';
}
$owned_by = $this->_resolve_user($document->getOwnerID());
$mimetypeid = $document->getMimeTypeID();
if (!array_key_exists($mimetypeid, $mime_cache)) {
$type = KTMime::getMimeTypeName($mimetypeid);
$icon = KTMime::getIconPath($mimetypeid);
$display = KTMime::getFriendlyNameForString($type);
$mime_cache[$mimetypeid] = array('type' => $type, 'icon' => $icon, 'display' => $display);
}
$mimeinfo = $mime_cache[$mimetypeid];
$workflow = 'n/a';
$state = 'n/a';
$wf = KTWorkflowUtil::getWorkflowForDocument($document);
if (!is_null($wf) && !PEAR::isError($wf)) {
$workflow = $wf->getHumanName();
$ws = KTWorkflowUtil::getWorkflowStateForDocument($document);
if (!is_null($ws) && !PEAR::isError($ws)) {
$state = $ws->getHumanName();
}
}
if ($wsversion >= 2) {
$docTypeId = $document->getDocumentTypeID();
//.........这里部分代码省略.........
示例7: symlinksLinkingToCurrentList
/**
* Checks if there are symlinks that are linking to items in the current list
* Useful if you want to prompt the user with a confirmation because they're
* automatically deleted when their targets are deleted or archived.
*
* @return boolean
*/
function symlinksLinkingToCurrentList()
{
$symlinksPresent = false;
foreach ($this->oActiveEntityList->getDocumentIds() as $iDocument) {
$oDocument = Document::get($iDocument);
if (count($oDocument->getSymbolicLinks()) > 0) {
$symlinksPresent = true;
break;
}
}
if ($symlinksPresent == false) {
foreach ($this->oActiveEntityList->getFolderIds() as $iFolder) {
$oStartFolder = Folder::get($iFolder);
$aRemainingFolders = array($oStartFolder->getId());
while (!empty($aRemainingFolders)) {
$iFolderId = array_pop($aRemainingFolders);
$oFolder = Folder::get($iFolderId);
if (count($oFolder->getSymbolicLinks()) > 0) {
$symlinksPresent = true;
break;
}
$aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId)));
foreach ($aChildDocs as $oDoc) {
if (count($oDoc->getSymbolicLinks()) > 0) {
$symlinksPresent = true;
break;
}
}
$aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
$aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
}
}
}
return $symlinksPresent;
}