本文整理汇总了PHP中CBPDocument::canUserOperateDocument方法的典型用法代码示例。如果您正苦于以下问题:PHP CBPDocument::canUserOperateDocument方法的具体用法?PHP CBPDocument::canUserOperateDocument怎么用?PHP CBPDocument::canUserOperateDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBPDocument
的用法示例。
在下文中一共展示了CBPDocument::canUserOperateDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: terminateWorkflow
protected function terminateWorkflow($workflowId, $elementId)
{
$this->checkPermission();
if (!CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser(), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), array("DocumentStates" => $this->documentStates))) {
$this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
}
if ($this->errorCollection->hasErrors()) {
$this->sendJsonErrorResponse();
}
if (CIBlockElementRights::userHasRightTo($this->iblockId, $elementId, "element_rights_edit")) {
$errors = array();
CBPDocument::terminateWorkflow($workflowId, BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), $errors);
foreach ($errors as $error) {
$this->errorCollection->add(array(new Error($error["message"])));
}
} else {
$this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
}
if ($this->errorCollection->hasErrors()) {
$this->sendJsonErrorResponse();
}
}
示例2: getData
protected function getData()
{
$this->arResult['SHOW_MODE'] = 'SelectWorkflow';
$this->arResult['TEMPLATES'] = array();
$this->arResult['PARAMETERS_VALUES'] = array();
$this->arResult['ERROR_MESSAGE'] = '';
$runtime = CBPRuntime::getRuntime();
$runtime->startRuntime();
$this->arResult['DocumentService'] = $runtime->getService('DocumentService');
foreach ($this->arResult['DOCUMENT_DATA'] as $nameModule => $data) {
$workflowTemplateObject = CBPWorkflowTemplateLoader::getList(array(), array('DOCUMENT_TYPE' => $data['DOCUMENT_TYPE'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'DESCRIPTION', 'MODIFIED', 'USER_ID', 'PARAMETERS'));
while ($workflowTemplate = $workflowTemplateObject->getNext()) {
if (!CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser()->getID(), $data['DOCUMENT_ID'], array())) {
continue;
}
if ($nameModule == 'DISK') {
$this->arResult['TEMPLATES'][$workflowTemplate['ID']] = $workflowTemplate;
$this->arResult['TEMPLATES'][$workflowTemplate['ID']]['URL'] = htmlspecialcharsex($this->getApplication()->getCurPageParam('workflow_template_id=' . $workflowTemplate['ID'] . '&' . bitrix_sessid_get(), array('workflow_template_id', 'sessid')));
} else {
$this->arResult['TEMPLATES_OLD'][$workflowTemplate['ID']] = $workflowTemplate;
$this->arResult['TEMPLATES_OLD'][$workflowTemplate['ID']]['URL'] = htmlspecialcharsex($this->getApplication()->getCurPageParam('workflow_template_id=' . $workflowTemplate['ID'] . '&old=1&' . bitrix_sessid_get(), array('workflow_template_id', 'sessid')));
}
}
}
if ($this->arParams['TEMPLATE_ID'] > 0 && strlen($this->request->getPost('CancelStartParamWorkflow')) <= 0 && (array_key_exists($this->arParams['TEMPLATE_ID'], $this->arResult['TEMPLATES']) || array_key_exists($this->arParams['TEMPLATE_ID'], $this->arResult['TEMPLATES_OLD']))) {
if (array_key_exists($this->arParams['TEMPLATE_ID'], $this->arResult['TEMPLATES'])) {
$templates = $this->arResult['TEMPLATES'];
$documentParameters = $this->arResult['DOCUMENT_DATA']['DISK'];
$this->arResult['CHECK_TEMPLATE'] = 'DISK';
} else {
$templates = $this->arResult['TEMPLATES_OLD'];
$documentParameters = $this->arResult['DOCUMENT_DATA']['WEBDAV'];
$this->arResult['CHECK_TEMPLATE'] = 'WEBDAV';
}
$workflowTemplate = $templates[$this->arParams['TEMPLATE_ID']];
$arWorkflowParameters = array();
$canStartWorkflow = false;
if (count($workflowTemplate['PARAMETERS']) <= 0) {
$canStartWorkflow = true;
} elseif ($this->request->isPost() && strlen($this->request->getPost('DoStartParamWorkflow')) > 0 && check_bitrix_sessid()) {
$errorsTemporary = array();
$request = $this->request->getPostList()->toArray();
foreach ($_FILES as $key => $value) {
if (array_key_exists('name', $value)) {
if (is_array($value['name'])) {
$keys = array_keys($value['name']);
for ($i = 0, $cnt = count($keys); $i < $cnt; $i++) {
$array = array();
foreach ($value as $k1 => $v1) {
$array[$k1] = $v1[$keys[$i]];
}
$request[$key][] = $array;
}
} else {
$request[$key] = $value;
}
}
}
$arWorkflowParameters = CBPWorkflowTemplateLoader::checkWorkflowParameters($workflowTemplate['PARAMETERS'], $request, $documentParameters['DOCUMENT_TYPE'], $errorsTemporary);
if (count($errorsTemporary) > 0) {
$canStartWorkflow = false;
foreach ($errorsTemporary as $e) {
$this->errorCollection->add(array(new Error($e['message'])));
}
} else {
$canStartWorkflow = true;
}
}
if ($canStartWorkflow) {
$errorsTemporary = array();
$workflowId = CBPDocument::startWorkflow($this->arParams['TEMPLATE_ID'], $documentParameters['DOCUMENT_ID'], array_merge($arWorkflowParameters, array('TargetUser' => 'user_' . intval($this->getUser()->getID()))), $errorsTemporary);
if (count($errorsTemporary) > 0) {
$this->arResult['SHOW_MODE'] = 'StartWorkflowError';
foreach ($errorsTemporary as $e) {
$this->errorCollection->add(array(new Error('[' . $e['code'] . '] ' . $e['message'])));
}
} else {
$this->arResult['SHOW_MODE'] = 'StartWorkflowSuccess';
if (strlen($this->arResult['back_url']) > 0) {
LocalRedirect(str_replace('#WF#', $workflowId, $this->request->getQuery('back_url')));
$this->end(true);
}
}
} else {
$doStartParam = $this->request->isPost() && strlen($this->request->getPost('DoStartParamWorkflow') && check_bitrix_sessid()) > 0;
$keys = array_keys($workflowTemplate['PARAMETERS']);
foreach ($keys as $key) {
$value = $doStartParam ? $this->request->getQuery($key) : $workflowTemplate['PARAMETERS'][$key]['Default'];
if (!is_array($value)) {
$this->arResult['PARAMETERS_VALUES'][$key] = CBPHelper::convertParameterValues($value);
} else {
$keys1 = array_keys($value);
foreach ($keys1 as $key1) {
$this->arResult['PARAMETERS_VALUES'][$key][$key1] = CBPHelper::convertParameterValues($value[$key1]);
}
}
}
$this->arResult['SHOW_MODE'] = 'WorkflowParameters';
}
if ($this->errorCollection->hasErrors()) {
//.........这里部分代码省略.........
示例3: completeWorkflow
/**
* @param string $workflowId
* @param string $iblockType
* @param int $elementId
* @param int $iblockId
* @param string $action Action stop or delete
* @return string error
*/
public static function completeWorkflow($workflowId, $iblockType, $elementId, $iblockId, $action)
{
if (!Loader::includeModule('bizproc')) {
return Loc::getMessage('LISTS_MODULE_BIZPROC_NOT_INSTALLED');
}
global $USER;
$userId = $USER->getID();
$documentType = BizprocDocument::generateDocumentComplexType($iblockType, $iblockId);
$documentId = BizprocDocument::getDocumentComplexId($iblockType, $elementId);
$documentStates = CBPDocument::getDocumentStates($documentType, $documentId);
$permission = CBPDocument::canUserOperateDocument($action == 'stop' ? CBPCanUserOperateOperation::StartWorkflow : CBPCanUserOperateOperation::CreateWorkflow, $userId, $documentId, array("DocumentStates" => $documentStates));
if (!$permission) {
return Loc::getMessage('LISTS_ACCESS_DENIED');
}
$stringError = '';
if ($action == 'stop') {
$errors = array();
CBPDocument::terminateWorkflow($workflowId, $documentId, $errors);
if (!empty($errors)) {
$stringError = '';
foreach ($errors as $error) {
$stringError .= $error['message'];
}
$listError[] = array('id' => 'stopBizproc', 'text' => $stringError);
}
} else {
$errors = array();
if (isset($documentStates[$workflowId]['WORKFLOW_STATUS']) && $documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) {
CBPDocument::terminateWorkflow($workflowId, $documentId, $errors);
}
if (!empty($errors)) {
$stringError = '';
foreach ($errors as $error) {
$stringError .= $error['message'];
}
$listError[] = array('id' => 'stopBizproc', 'text' => $stringError);
} else {
CBPTaskService::deleteByWorkflow($workflowId);
CBPTrackingService::deleteByWorkflow($workflowId);
CBPStateService::deleteWorkflow($workflowId);
}
}
if (empty($listError) && Loader::includeModule('socialnetwork') && $iblockType == COption::getOptionString("lists", "livefeed_iblock_type_id")) {
$sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
$resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID'));
while ($log = $resultQuery->fetch()) {
CSocNetLog::delete($log['ID']);
}
}
if (!empty($listError)) {
$errorObject = new CAdminException($listError);
$stringError = $errorObject->getString();
}
return $stringError;
}
示例4: showBizProc
protected function showBizProc($documentData)
{
$this->arResult['BIZPROC_PERMISSION'] = array();
$this->arResult['BIZPROC_PERMISSION']['START'] = CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser()->getId(), $documentData['DISK']['DOCUMENT_ID']);
$this->arResult['BIZPROC_PERMISSION']['VIEW'] = CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $this->getUser()->getId(), $documentData['DISK']['DOCUMENT_ID']);
$this->arResult['BIZPROC_PERMISSION']['STOP'] = $this->arResult['BIZPROC_PERMISSION']['START'];
$this->arResult['BIZPROC_PERMISSION']['DROP'] = CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser()->getId(), $documentData['DISK']['DOCUMENT_ID']);
foreach ($documentData as $nameModuleId => $data) {
$temporary[$nameModuleId] = CBPDocument::getDocumentStates($data['DOCUMENT_TYPE'], $data['DOCUMENT_ID']);
}
if (isset($temporary['OLD_FILE'])) {
$allBizProcArray = array_merge($temporary['DISK'], $temporary['WEBDAV'], $temporary['OLD_FILE']);
} else {
$allBizProcArray = array_merge($temporary['DISK'], $temporary['WEBDAV']);
}
if (!empty($allBizProcArray)) {
$userGroup = $this->getUser()->getUserGroupArray();
$userGroup[] = 'author';
if ($this->request->isPost() && intval($this->request->getPost('bizproc_index')) > 0) {
$bizProcWorkflowId = array();
$bizprocIndex = intval($this->request->getPost('bizproc_index'));
for ($i = 1; $i <= $bizprocIndex; $i++) {
$bpId = trim($this->request->getPost("bizproc_id_" . $i));
$bpTemplateId = intval($this->request->getPost("bizproc_template_id_" . $i));
$bpEvent = trim($this->request->getPost("bizproc_event_" . $i));
if (strlen($bpId) > 0) {
if (!array_key_exists($bpId, $allBizProcArray)) {
continue;
}
} else {
if (!array_key_exists($bpTemplateId, $allBizProcArray)) {
continue;
}
$bpId = $bizProcWorkflowId[$bpTemplateId];
}
if (strlen($bpEvent) > 0) {
$errors = array();
CBPDocument::sendExternalEvent($bpId, $bpEvent, array("Groups" => $userGroup, "User" => $this->getUser()->getId()), $errors);
} else {
$errors = array();
foreach ($allBizProcArray as $idBizProc => $bizProcArray) {
if ($idBizProc == $bpId) {
CBPDocument::TerminateWorkflow($bpId, $bizProcArray['DOCUMENT_ID'], $errors);
}
}
}
if (!empty($errors)) {
foreach ($errors as $error) {
$this->arResult['ERROR_MESSAGE'] = $error['message'];
}
} else {
LocalRedirect($this->arResult['PATH_TO_FILE_VIEW'] . "#tab-bp");
}
}
}
$this->arResult['BIZPROC_LIST'] = array();
$count = 1;
foreach ($allBizProcArray as $idBizProc => $bizProcArray) {
if (intVal($bizProcArray["WORKFLOW_STATUS"]) < 0 || $idBizProc <= 0) {
continue;
} else {
if (!CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $this->getUser()->getId(), $documentData['DISK']['DOCUMENT_ID'], array("DocumentStates" => $bizProcArray, "WorkflowId" => $bizProcArray["ID"] > 0 ? $bizProcArray["ID"] : $bizProcArray["TEMPLATE_ID"]))) {
continue;
}
}
$groups = CBPDocument::getAllowableUserGroups($documentData['DISK']['DOCUMENT_TYPE']);
foreach ($groups as $key => $val) {
$groups[strtolower($key)] = $val;
}
$users = array();
$dmpWorkflow = CBPTrackingService::getList(array("ID" => "DESC"), array("WORKFLOW_ID" => $idBizProc, "TYPE" => array(CBPTrackingType::Report, CBPTrackingType::Custom, CBPTrackingType::FaultActivity)), false, array("nTopCount" => 5), array("ID", "TYPE", "MODIFIED", "ACTION_NOTE", "ACTION_TITLE", "ACTION_NAME", "EXECUTION_STATUS", "EXECUTION_RESULT"));
while ($track = $dmpWorkflow->getNext()) {
$messageTemplate = "";
switch ($track["TYPE"]) {
case 1:
$messageTemplate = Loc::getMessage("DISK_FILE_VIEW_BPABL_TYPE_1");
break;
case 2:
$messageTemplate = Loc::getMessage("DISK_FILE_VIEW_BPABL_TYPE_2");
break;
case 3:
$messageTemplate = Loc::getMessage("DISK_FILE_VIEW_BPABL_TYPE_3");
break;
case 4:
$messageTemplate = Loc::getMessage("DISK_FILE_VIEW_BPABL_TYPE_4");
break;
case 5:
$messageTemplate = Loc::getMessage("DISK_FILE_VIEW_BPABL_TYPE_5");
break;
default:
$messageTemplate = Loc::getMessage("DISK_FILE_VIEW_BPABL_TYPE_6");
}
$name = strlen($track["ACTION_TITLE"]) > 0 ? $track["ACTION_TITLE"] : $track["ACTION_NAME"];
switch ($track["EXECUTION_STATUS"]) {
case CBPActivityExecutionStatus::Initialized:
$status = Loc::getMessage("DISK_FILE_VIEW_BPABL_STATUS_1");
break;
case CBPActivityExecutionStatus::Executing:
$status = Loc::getMessage("DISK_FILE_VIEW_BPABL_STATUS_2");
break;
//.........这里部分代码省略.........