ktbulkactions.php.tmp
来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· TMP 代码 · 共 1,219 行 · 第 1/3 页
TMP
1,219 行
<?php/** * * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * 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): ______________________________________ * */require_once(KT_LIB_DIR . '/actions/bulkaction.php');require_once(KT_LIB_DIR . '/widgets/forms.inc.php');require_once(KT_LIB_DIR . '/foldermanagement/compressionArchiveUtil.inc.php');require_once(KT_LIB_DIR . '/subscriptions/Subscription.inc');class KTBulkDeleteAction extends KTBulkAction { var $sName = 'ktcore.actions.bulk.delete'; var $_sPermission = 'ktcore.permissions.delete'; var $_bMutator = true; function getDisplayName() { return _kt('Delete'); } function check_entity($oEntity) { if(is_a($oEntity, 'Document')) { if($oEntity->getImmutable()) { return PEAR::raiseError(_kt('Document cannot be deleted as it is immutable')); } } return parent::check_entity($oEntity); } function form_collectinfo() { $oForm = new KTForm; $oForm->setOptions(array( 'identifier' => 'ktcore.actions.bulk.delete.form', 'label' => _kt('Delete Items'), 'submit_label' => _kt('Delete'), 'action' => 'performaction', 'fail_action' => 'collectinfo', 'cancel_action' => 'main', 'context' => $this, )); $oForm->setWidgets(array( array('ktcore.widgets.reason',array( 'name' => 'reason', 'label' => _kt('Reason'), 'description' => _kt('The reason for the deletion of these documents and folders for historical purposes.'), 'value' => null, 'required' => true, )), )); $oForm->setValidators(array( array('ktcore.validators.string', array( 'test' => 'reason', 'output' => 'reason', )), )); return $oForm; } /** * build the confirmation form that is shown when symlinks are affected by this action. * * @return KTForm the form */ function form_confirm() { $oForm = new KTForm; $oForm->setOptions(array( 'label' => _kt('Are you sure?'), 'description' => _kt('There are shortcuts linking to some of the documents or folders in your selection; continuing will automatically delete the shortcuts. Would you like to continue?'), 'action' => 'collectinfo', 'fail_action' => 'main', 'cancel_url' => KTBrowseUtil::getUrlForFolder($this->oFolder), 'submit_label' => _kt('Continue'), 'context' => $this, )); $oForm->setWidgets(array( array('ktcore.widgets.hidden',array( 'name' => 'delete_confirmed', 'value' => '1' )))); return $oForm; } /** * Shows the confirmation form if symlinks are affected by the current action * * @return Template HTML */ function do_confirm(){ $this->store_lists(); $this->get_lists(); $this->oPage->setBreadcrumbDetails(_kt('Confirm delete')); $oTemplate =& $this->oValidator->validateTemplate('ktcore/bulk_action_confirm'); $oForm = $this->form_confirm(); $oTemplate->setData(array( 'context' => &$this, 'form' => $oForm, )); return $oTemplate->render(); } // info collection step function do_collectinfo() { $this->store_lists(); $this->get_lists(); //check if a the symlinks deletion confirmation has been passed yet if(KTutil::arrayGet($_REQUEST['data'],'delete_confirmed') != 1){ //check if there are actually any symlinks involved. if($this->symlinksLinkingToCurrentList()){ $this->redirectTo("confirm"); } } //render template $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/bulk_action_info'); return $oTemplate->render(array('context' => $this, 'form' => $this->form_collectinfo())); } function do_performaction() { $this->store_lists(); $this->get_lists(); $oForm = $this->form_collectinfo(); $res = $oForm->validate(); if (!empty($res['errors'])) { $oForm->handleError(); } $this->res = $res['results']; return parent::do_performaction(); } function perform_action($oEntity) { $sReason = $this->res['reason']; if(is_a($oEntity, 'Document')) { $res = KTDocumentUtil::delete($oEntity, $sReason); } else if(is_a($oEntity, 'Folder')) { $res = KTFolderUtil::delete($oEntity, $this->oUser, $sReason); } return $res; }}class KTBulkMoveAction extends KTBulkAction { var $sName = 'ktcore.actions.bulk.move'; var $_sPermission = 'ktcore.permissions.write'; var $_bMutator = true; function getDisplayName() { return _kt('Move'); } function form_collectinfo() { $oForm = new KTForm; $oForm->setOptions(array( 'identifier' => 'ktcore.actions.bulk.move.form', 'label' => _kt('Move Items'), 'submit_label' => _kt('Move'), 'action' => 'performaction', 'fail_action' => 'collectinfo', 'cancel_action' => 'main', 'context' => $this, )); // Setup the collection for move display. require_once(KT_LIB_DIR . '/browse/DocumentCollection.inc.php'); $collection = new AdvancedCollection(); $oCR =& KTColumnRegistry::getSingleton(); $col = $oCR->getColumn('ktcore.columns.title'); //$col->setOptions(array('qs_params'=>array('fMoveCode'=>$sMoveCode, // 'fFolderId'=>$oFolder->getId(), // 'action'=>'startMove'))); $collection->addColumn($col); $qObj = new FolderBrowseQuery($this->oFolder->iId); $exclude=array(); foreach( $this->oEntityList->aFolderIds as $folderid) { $exclude[] = $folderid+0; } $qObj->exclude_folders = $exclude; $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array('fFolderId' => $this->oFolder->iId, 'action' => 'collectinfo')); $collection->setOptions($aOptions); $oWF =& KTWidgetFactory::getSingleton(); $oWidget = $oWF->get('ktcore.widgets.collection', array('label' => _kt('Target Folder'), 'description' => _kt('Use the folder collection and path below to browse to the folder you wish to move the documents into.'), 'required' => true, 'name' => 'fFolderId', 'broken_name' => true, 'folder_id' => $this->oFolder->iId, 'collection' => $collection)); $oForm->addInitializedWidget($oWidget); $oForm->addWidget( array('ktcore.widgets.reason',array( 'name' => 'reason', 'label' => _kt('Reason'), 'description' => _kt('The reason for moving these documents and folders, for historical purposes.'), 'value' => null, 'required' => true, ) )); $oForm->setValidators(array( array('ktcore.validators.string', array( 'test' => 'reason', 'output' => 'reason', )), )); return $oForm; } function check_entity($oEntity) { if(is_a($oEntity, 'Document')) { if(!KTDocumentUtil::canBeMoved($oEntity)) { return PEAR::raiseError(_kt('Document cannot be moved')); } } return parent::check_entity($oEntity); } // info collection step function do_collectinfo() { $this->store_lists(); $this->get_lists(); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/bulk_action_info'); return $oTemplate->render(array('context' => $this, 'form' => $this->form_collectinfo())); } 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(); } function perform_action($oEntity) { if(is_a($oEntity, 'Document')) { return KTDocumentUtil::move($oEntity, $this->oTargetFolder, $this->oUser, $this->sReason); } else if(is_a($oEntity, 'Folder')) { return KTFolderUtil::move($oEntity, $this->oTargetFolder, $this->oUser, $this->sReason); } }}class KTBulkCopyAction extends KTBulkAction { var $sName = 'ktcore.actions.bulk.copy'; var $_sPermission = 'ktcore.permissions.read'; var $_bMutator = true; function getDisplayName() { return _kt('Copy'); } function form_collectinfo() { $oForm = new KTForm; $oForm->setOptions(array( 'identifier' => 'ktcore.actions.bulk.copy.form', 'label' => _kt('Copy Items'), 'submit_label' => _kt('Copy'), 'action' => 'performaction', 'fail_action' => 'collectinfo', 'cancel_action' => 'main', 'context' => $this, )); // Setup the collection for move display. require_once(KT_LIB_DIR . '/browse/DocumentCollection.inc.php'); $collection = new AdvancedCollection(); $oCR =& KTColumnRegistry::getSingleton(); $col = $oCR->getColumn('ktcore.columns.title'); //$col->setOptions(array('qs_params'=>array('fMoveCode'=>$sMoveCode, // 'fFolderId'=>$oFolder->getId(), // 'action'=>'startMove'))); $collection->addColumn($col); $qObj = new FolderBrowseQuery($this->oFolder->iId); $exclude=array(); foreach( $this->oEntityList->aFolderIds as $folderid) { $exclude[] = $folderid+0; } $qObj->exclude_folders = $exclude; $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array('fFolderId' => $this->oFolder->iId, 'action' => 'collectinfo')); $collection->setOptions($aOptions); $oWF =& KTWidgetFactory::getSingleton(); $oWidget = $oWF->get('ktcore.widgets.collection', array('label' => _kt('Target Folder'), 'description' => _kt('Use the folder collection and path below to browse to the folder you wish to copy the documents into.'), 'required' => true, 'name' => 'fFolderId', 'broken_name' => true, 'folder_id' => $this->oFolder->iId, 'collection' => $collection)); $oForm->addInitializedWidget($oWidget); $oForm->addWidget( array('ktcore.widgets.reason',array( 'name' => 'reason', 'label' => _kt('Reason'), 'description' => _kt('The reason for copying these documents and folders, for historical purposes.'), 'value' => null, 'required' => true, ) ));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?