* @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']; $workflowmode = $this->params['workflowmode']; $tasks = array(); if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { $tasks['approval'] = array(); if($workflowmode == 'traditional') $tasks['review'] = array(); } elseif($workflowmode == 'advanced') $tasks['workflow'] = array(); if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { $resArr = $dms->getDocumentList('ApproveByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; // $tasks['approval'][] = array('id'=>$res['id'], 'name'=>$res['name']); } } 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') { $resArr = $dms->getDocumentList('ReviewByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($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()); } } } elseif($workflowmode == 'advanced') { $resArr = $dms->getDocumentList('WorkflowByMe', $user); if($resArr) { $docs = array(); foreach ($resArr as $res) { $document = $dms->getDocument($res["id"]); if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { $docs[] = $document; // $tasks['workflow'][] = array('id'=>$res['id'], 'name'=>$res['name']); } } if($this->hasHook('filterWorkflowTaskList')) $docs = $this->callHook('filterWorkflowTaskList', $docs); foreach($docs as $doc) $tasks['workflow'][] = 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 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 * * @param array $clipboard clipboard containing two arrays for both * documents and folders. * @return string html code */ function menuTasks() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $tasks = $this->__myTasks(); $content = ''; $content .= " \n"; echo $content; } /* }}} */ /** * Returns the html needed for the clipboard list in the menu * * This function renders the clipboard 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 */ public function menuClipboard() { /* {{{ */ $clipboard = $this->params['session']->getClipboard(); if ($this->params['user']->isGuest() || (count($clipboard['docs']) + count($clipboard['folders'])) == 0) { return ''; } $content = ''; $content .= " \n"; echo $content; } /* }}} */ /** * Return clipboard content rendered as html * * @param array clipboard * @return string rendered html content */ public function mainClipboard() { /* {{{ */ $dms = $this->params['dms']; $clipboard = $this->params['session']->getClipboard(); $cachedir = $this->params['cachedir']; $previewwidth = $this->params['previewWidthList']; $timeout = $this->params['timeout']; $xsendfile = $this->params['xsendfile']; $previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile); $content = ''; $foldercount = $doccount = 0; if($clipboard['folders']) { foreach($clipboard['folders'] as $folderid) { /* FIXME: check for access rights, which could have changed after adding the folder to the clipboard */ if($folder = $dms->getFolder($folderid)) { $comment = $folder->getComment(); if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "..."; // $content .= "getID()."\" class=\"folder table-row-folder\" formtoken=\"".createFormKey('movefolder')."\">"; $content .= $this->folderListRowStart($folder); $content .= "getID()."&showtree=".showtree()."\">imgpath."folder.png\" width=\"24\" height=\"24\" border=0>\n"; $content .= "getID()."&showtree=".showtree()."\">" . htmlspecialchars($folder->getName()) . ""; if($comment) { $content .= "
".htmlspecialchars($comment).""; } $content .= "\n"; $content .= "\n"; $content .= "
params['folder']) ? $this->params['folder']->getID() : '')."&id=".$folderid."&type=folder\" title=\"".getMLText('rm_from_clipboard')."\">
"; $content .= "\n"; //$content .= "\n"; $content .= $this->folderListRowEnd($folder); $foldercount++; } } } if($clipboard['docs']) { foreach($clipboard['docs'] as $docid) { /* FIXME: check for access rights, which could have changed after adding the document to the clipboard */ if($document = $dms->getDocument($docid)) { $comment = $document->getComment(); if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "..."; if($latestContent = $document->getLatestContent()) { $previewer->createPreview($latestContent); $version = $latestContent->getVersion(); $status = $latestContent->getStatus(); $content .= ""; if (file_exists($dms->contentDir . $latestContent->getPath())) { $content .= ""; if($previewer->hasPreview($latestContent)) { $content .= "getID()."&version=".$latestContent->getVersion()."&width=40\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; } else { $content .= "getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; } $content .= ""; } else $content .= "getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; $content .= "" . htmlspecialchars($document->getName()) . ""; if($comment) { $content .= "
".htmlspecialchars($comment).""; } $content .= "\n"; $content .= "\n"; $content .= "
params['folder']) ? $this->params['folder']->getID() : '')."&id=".$docid."&type=document\" title=\"".getMLText('rm_from_clipboard')."\">
"; $content .= "\n"; $content .= ""; $doccount++; } } } } /* $foldercount or $doccount will only count objects which are * actually available */ if($foldercount || $doccount) { $content = "".$content; $content .= "
"; } else { } $content .= "
".getMLText("drag_icon_here")."
"; echo $content; } /* }}} */ }