* @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ /** * Include parent class */ require_once("class.Bootstrap.php"); /** * Include class to preview documents */ require_once("SeedDMS/Preview.php"); /** * Class which outputs the html page for clipboard view * * @category DMS * @package SeedDMS * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann * @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ class SeedDMS_View_Tasks extends SeedDMS_Bootstrap_Style { private function __myTasks() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $enablereceiptworkflow = $this->params['enablereceiptworkflow']; $enablerevisionworkflow = $this->params['enablerevisionworkflow']; $workflowmode = $this->params['workflowmode']; $tasksinmenu = $this->params['tasksinmenu']; $tasks = array(); if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { $tasks['approval'] = array(); if($workflowmode == 'traditional') $tasks['review'] = array(); } elseif($workflowmode == 'advanced') $tasks['workflow'] = array(); $tasks['rejected'] = array(); $tasks['checkedout'] = array(); if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') if(!$tasksinmenu || in_array('approval', $tasksinmenu)) { $tasks['approval'] = array(); $resArr = $dms->getDocumentList('ApproveByMe', $user, false, '', '', false); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterApprovalTaskList')) $docs = $this->callHook('filterApprovalTaskList', $docs); foreach($docs as $doc) $tasks['approval'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if($workflowmode == 'traditional') if(!$tasksinmenu || in_array('review', $tasksinmenu)) { $tasks['review'] = array(); $resArr = $dms->getDocumentList('ReviewByMe', $user, false, '', '', false); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; // $tasks['review'][] = array('id'=>$res['id'], 'name'=>$res['name']); } } if($this->hasHook('filterReviewTaskList')) $docs = $this->callHook('filterReviewTaskList', $docs); foreach($docs as $doc) $tasks['review'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if($enablereceiptworkflow) if(!$tasksinmenu || in_array('receipt', $tasksinmenu)) { $tasks['receipt'] = array(); $resArr = $dms->getDocumentList('ReceiptByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterReceiptTaskList')) $docs = $this->callHook('filterReceiptTaskList', $docs); foreach($docs as $doc) $tasks['receipt'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if($enablerevisionworkflow) if(!$tasksinmenu || in_array('revision', $tasksinmenu)) { $tasks['revision'] = array(); $resArr = $dms->getDocumentList('ReviseByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterRevisionTaskList')) $docs = $this->callHook('filterRevisionTaskList', $docs); foreach($docs as $doc) $tasks['revision'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if(!$tasksinmenu || in_array('needscorrection', $tasksinmenu)) { $tasks['needscorrection'] = array(); $resArr = $dms->getDocumentList('NeedsCorrectionOwner', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterNeedsCorrectionTaskList')) $docs = $this->callHook('filterNeedsCorrectionTaskList', $docs); foreach($docs as $doc) $tasks['needscorrection'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if($workflowmode == 'advanced') if(!$tasksinmenu || in_array('workflow', $tasksinmenu)) { $tasks['workflow'] = array(); $resArr = $dms->getDocumentList('WorkflowByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterWorkflowTaskList')) $docs = $this->callHook('filterWorkflowTaskList', $docs); foreach($docs as $doc) $tasks['workflow'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if(!$tasksinmenu || in_array('rejected', $tasksinmenu)) { $tasks['rejected'] = array(); $resArr = $dms->getDocumentList('RejectOwner', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterRejectedTaskList')) $docs = $this->callHook('filterRejectedTaskList', $docs); foreach($docs as $doc) $tasks['rejected'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } if(!$tasksinmenu || in_array('checkedout', $tasksinmenu)) { $tasks['checkedout'] = array(); $resArr = $dms->getDocumentList('CheckedOutByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document && $document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; } } if($this->hasHook('filterCheckedOutTaskList')) $docs = $this->callHook('filterCheckedOutTaskList', $docs); foreach($docs as $doc) $tasks['checkedout'][] = array('id'=>$doc->getId(), 'name'=>$doc->getName()); } } return $tasks; } /* }}} */ /** * Returns the html needed for the task list in the menu * * This function renders the tasks in a way suitable to be * used as a menu * * @param array $clipboard clipboard containing two arrays for both * documents and folders. * @return string html code */ function countTasks() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $enablereceiptworkflow = $this->params['enablereceiptworkflow']; $enablerevisionworkflow = $this->params['enablerevisionworkflow']; $workflowmode = $this->params['workflowmode']; $tasksinmenu = $this->params['tasksinmenu']; $startts = microtime(true); $tasks = array(); if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') if(!$tasksinmenu || in_array('approval', $tasksinmenu)) { $tasks['approval'] = $dms->countTasks('ApproveByMe', $user); } if($workflowmode == 'traditional') if(!$tasksinmenu || in_array('review', $tasksinmenu)) { $tasks['review'] = $dms->countTasks('ReviewByMe', $user); } if($workflowmode == 'advanced') if(!$tasksinmenu || in_array('workflow', $tasksinmenu)) { $tasks['workflow'] = $dms->countTasks('WorkflowByMe', $user); } if($enablereceiptworkflow) if(!$tasksinmenu || in_array('receipt', $tasksinmenu)) $tasks['receipt'] = $dms->countTasks('ReceiptByMe', $user); if($enablerevisionworkflow) if(!$tasksinmenu || in_array('revision', $tasksinmenu)) $tasks['revision'] = $dms->countTasks('ReviseByMe', $user); if(!$tasksinmenu || in_array('needscorrection', $tasksinmenu)) $tasks['needscorrection'] = $dms->countTasks('NeedsCorrectionOwner', $user); header('Content-Type: application/json'); echo json_encode(array('error'=>0, 'data'=>$tasks, 'processing_time'=>microtime(true)-$startts)); } /* }}} */ /** * Returns a json array of tasks to be done * * @return string json string */ function myTasks() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $startts = microtime(true); $tasks = $this->__myTasks(); header('Content-Type: application/json'); echo json_encode(array('error'=>0, 'data'=>$tasks, 'processing_time'=>microtime(true)-$startts)); } /* }}} */ /** * Returns the html needed for the task list in the menu * * This function renders the tasks in a way suitable to be * used as a menu * * @return string html code */ function menuTasks() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $accessobject = $this->params['accessobject']; if(!$tasks = $this->__myTasks()) { echo ''; return; } $content = ''; $content .= "