本文整理汇总了PHP中Permission::userHasFolderWritePermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::userHasFolderWritePermission方法的具体用法?PHP Permission::userHasFolderWritePermission怎么用?PHP Permission::userHasFolderWritePermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::userHasFolderWritePermission方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_copy
function do_copy()
{
$oForm = $this->form_copyselection();
$res = $oForm->validate();
$errors = $res['errors'];
$data = $res['results'];
$sReason = $data['reason'];
$extra_errors = array();
if (!is_null($data['browse'])) {
$bNameClash = KTDocumentUtil::nameExists($data['browse'], $this->oDocument->getName());
if ($bNameClash && isset($data['name'])) {
$name = $data['name'];
$bNameClash = KTDocumentUtil::nameExists($data['browse'], $name);
} else {
$name = $this->oDocument->getName();
}
if ($bNameClash) {
$extra_errors['name'] = _kt('A document with this title already exists in your chosen folder. Please choose a different folder, or specify a new title for the copied document.');
}
$bFileClash = KTDocumentUtil::fileExists($data['browse'], $this->oDocument->getFilename());
if ($bFileClash && isset($data['filename'])) {
$filename = $data['filename'];
$bFileClash = KTDocumentUtil::fileExists($data['browse'], $filename);
} else {
$filename = $this->oDocument->getFilename();
}
if ($bFileClash) {
$extra_errors['filename'] = _kt('A document with this filename already exists in your chosen folder. Please choose a different folder, or specify a new filename for the copied document.');
}
if (!Permission::userHasFolderWritePermission($data['browse'])) {
$extra_errors['browse'] = _kt('You do not have permission to create new documents in that folder.');
}
}
if (!empty($errors) || !empty($extra_errors)) {
return $oForm->handleError(null, $extra_errors);
}
// FIXME agree on document-duplication rules re: naming, etc.
$this->startTransaction();
// now try update it.
$oNewDoc = KTDocumentUtil::copy($this->oDocument, $data['browse'], $sReason);
if (PEAR::isError($oNewDoc)) {
$this->errorRedirectTo('main', _kt('Failed to copy document: ') . $oNewDoc->getMessage(), sprintf('fDocumentId=%d&fFolderId=%d', $this->oDocument->getId(), $this->oFolder->getId()));
exit(0);
}
$oNewDoc->setName($name);
$oNewDoc->setFilename($filename);
$res = $oNewDoc->update();
if (PEAR::isError($res)) {
return $this->errorRedirectTo('main', _kt('Failed to copy document: ') . $res->getMessage(), sprintf('fDocumentId=%d&fFolderId=%d', $this->oDocument->getId(), $this->oFolder->getId()));
}
$this->commitTransaction();
$_SESSION['KTInfoMessage'][] = _kt('Document copied.');
controllerRedirect('viewDocument', 'fDocumentId=' . $oNewDoc->getId());
exit(0);
}
示例2: get_permission_string
/**
* Get's a permission string for a folder eg: 'RW' or 'RWA'
*
* @author KnowledgeTree Team
* @access public
* @param Folder $folder
* @return string
*/
function get_permission_string($folder)
{
$perms = '';
if (Permission::userHasFolderReadPermission($folder)) {
$perms .= 'R';
}
if (Permission::userHasFolderWritePermission($folder)) {
$perms .= 'W';
}
if (Permission::userHasAddFolderPermission($folder)) {
$perms .= 'A';
}
// root folder cannot be renamed or deleted.
if ($folder->iId != 1) {
if (Permission::userHasRenameFolderPermission($folder)) {
$perms .= 'N';
}
if (Permission::userHasDeleteFolderPermission($folder)) {
$perms .= 'D';
}
}
return $perms;
}
示例3: do_performaction
function do_performaction()
{
$this->store_lists();
$this->get_lists();
$oForm = $this->form_collectinfo();
$res = $oForm->validate();
if (!empty($res['errors'])) {
$oForm->handleError();
}
$this->sReason = $_REQUEST['data']['reason'];
$this->iTargetFolderId = $_REQUEST['data']['fFolderId'];
$this->oTargetFolder = Folder::get($this->iTargetFolderId);
$_REQUEST['fReturnData'] = '';
$_REQUEST['fFolderId'] = $this->iTargetFolderId;
// does it exists
if (PEAR::isError($this->oTargetFolder)) {
return PEAR::raiseError(_kt('Invalid target folder selected'));
}
// does the user have write permission
if (!Permission::userHasFolderWritePermission($this->oTargetFolder)) {
$this->errorRedirectTo('collectinfo', _kt('You do not have permission to move items to this location'));
}
return parent::do_performaction();
}
示例4: get_permission_string
/**
* Get's a permission string for a folder eg: 'RW' or 'RWA'
*
* @author KnowledgeTree Team
* @access public
* @param Folder $folder
* @return string
*/
function get_permission_string($folder)
{
$perms = '';
if (Permission::userHasFolderReadPermission($folder)) {
$perms .= 'R';
}
if (Permission::userHasFolderWritePermission($folder)) {
$perms .= 'W';
}
if (Permission::userHasAddFolderPermission($folder)) {
$perms .= 'A';
}
return $perms;
}