Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • Workflow
  • WorkflowAction
  • WorkflowActions
  • WorkflowAllocation
  • WorkflowAllocations
  • WorkflowArtAllocation
  • WorkflowArtAllocations
  • WorkflowItem
  • WorkflowItems
  • Workflows
  • WorkflowTask
  • WorkflowTasks
  • WorkflowUserSequence
  • WorkflowUserSequences

Functions

  • createNewWorkflow
  • doWorkflowAction
  • editWorkflowStep
  • getActionSelect
  • getCatLang
  • getCurrentUserSequence
  • getLastWorkflowStatus
  • getTimeUnitSelector
  • getUsers
  • getWorkflowForCat
  • getWorkflowForUserSequence
  • getWorkflowList
  • getWorkflowUsers
  • isCurrentEditor
  • piworkflowAllowArticleEdit
  • piworkflowCategoryColumns
  • piworkflowCategoryRenderColumn
  • piworkflowCreateTasksFolder
  • piworkflowProcessActions
  • piworkflowProcessArticleColumns
  • piworkflowRenderAction
  • piworkflowRenderColumn
  • prepareWorkflowItems
  • setUserSequence
  • workflowInherit
  • workflowSelect
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the workflow allocation management.
  4:  *
  5:  * @package Plugin
  6:  * @subpackage Workflow
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author unkown
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: plugin_include('workflow', 'classes/class.workflow.php');
 19: plugin_include('workflow', 'includes/functions.workflow.php');
 20: cInclude("includes", "functions.encoding.php");
 21: 
 22: $page = new cGuiPage("workflow_steps", "workflow");
 23: 
 24: $iIdMarked = (int) $_GET['idworkflowitem'];
 25: 
 26: $workflowActions = new WorkflowActions();
 27: 
 28: $availableWorkflowActions = $workflowActions->getAvailableWorkflowActions();
 29: 
 30: $sCurrentEncoding = getEncodingByLanguage($db, $lang);
 31: 
 32: if (conHtmlentities($adduser, ENT_COMPAT, $sCurrentEncoding) == i18n("Add User", "workflow")) {
 33:     $action = "workflow_create_user";
 34: }
 35: 
 36: // Function: Move step up
 37: if ($action == "workflow_step_up") {
 38:     $workflowitems = new WorkflowItems();
 39:     $workflowitems->swap($idworkflow, $position, $position - 1);
 40: }
 41: 
 42: // Function: Move step down
 43: if ($action == "workflow_step_down") {
 44:     $workflowitems = new WorkflowItems();
 45:     $workflowitems->swap($idworkflow, $position, $position + 1);
 46: }
 47: 
 48: // Function: Move user up
 49: if ($action == "workflow_user_up") {
 50:     $workflowitems = new WorkflowUserSequences();
 51:     $workflowitems->swap($idworkflowitem, $position, $position - 1);
 52: }
 53: 
 54: // Function: Move step down
 55: if ($action == "workflow_user_down") {
 56:     $workflowitems = new WorkflowUserSequences();
 57:     $workflowitems->swap($idworkflowitem, $position, $position + 1);
 58: }
 59: 
 60: // Function: Create new step
 61: if ($action == "workflow_create_step") {
 62:     $workflowitems = new WorkflowItems();
 63:     $item = $workflowitems->create($idworkflow);
 64:     $item->set("name", i18n("New Workflow Step", "workflow"));
 65:     $item->store();
 66:     $idworkflowitem = $item->get("idworkflowitem");
 67: }
 68: 
 69: // Function: Delete step
 70: if ($action == "workflow_step_delete") {
 71:     $workflowitems = new WorkflowItems();
 72:     $workflowitems->delete($idworkflowitem);
 73: }
 74: 
 75: // Function: Add user
 76: if ($action == "workflow_create_user") {
 77:     $workflowusers = new WorkflowUserSequences();
 78:     $new = $workflowusers->create($idworkflowitem);
 79: }
 80: 
 81: // Function: Remove user
 82: if ($action == "workflow_user_delete") {
 83:     $workflowusers = new WorkflowUserSequences();
 84:     $workflowusers->delete($idusersequence);
 85: }
 86: 
 87: // Function: Save step
 88: if ($action == "workflow_save_step" || $action == "workflow_create_user") {
 89:     $workflowactions = new WorkflowActions();
 90: 
 91:     foreach ($availableWorkflowActions as $key => $value) {
 92:         if ($wfactions[$key] == 1) {
 93:             $workflowactions->set($idworkflowitem, $key);
 94:         } else {
 95:             $workflowactions->remove($idworkflowitem, $key);
 96:         }
 97:     }
 98: 
 99:     $workflowitem = new WorkflowItem();
100:     $workflowitem->loadByPrimaryKey($idworkflowitem);
101:     $workflowitem->setField('idtask', $wftaskselect);
102:     $workflowitem->setField('name', str_replace('\\','',$wfstepname));
103:     $workflowitem->setField('description', str_replace('\\','',$wfstepdescription));
104:     $workflowitem->store();
105: 
106:     $usersequences = new WorkflowUserSequences();
107:     $usersequences->select("idworkflowitem = '$idworkflowitem'");
108: 
109:     while (($usersequence = $usersequences->next()) !== false) {
110:         $wftime = "time" . $usersequence->get("idusersequence");
111:         $wfuser = "user" . $usersequence->get("idusersequence");
112: 
113:         $wftimelimit = "wftimelimit" . $usersequence->get("idusersequence");
114:         $usersequence->set("timeunit", $$wftime);
115:         $usersequence->set("iduser", $$wfuser);
116:         $usersequence->set("timelimit", $$wftimelimit);
117:         $usersequence->set("emailnoti", $wfemailnoti[$usersequence->get("idusersequence")]);
118:         $usersequence->set("escalationnoti", $wfescalnoti[$usersequence->get("idusersequence")]);
119:         $usersequence->store();
120:     }
121: }
122: 
123: function getTimeUnitSelector($listid, $default) {
124:     global $idclient, $cfg, $auth;
125: 
126:     $timeunits = array();
127:     $timeunits['Seconds'] = i18n("Seconds", "workflow");
128:     $timeunits['Minutes'] = i18n("Minutes", "workflow");
129:     $timeunits['Hours'] = i18n("Hours", "workflow");
130:     $timeunits['Days'] = i18n("Days", "workflow");
131:     $timeunits['Weeks'] = i18n("Weeks", "workflow");
132:     $timeunits['Months'] = i18n("Months", "workflow");
133:     $timeunits['Years'] = i18n("Years", "workflow");
134: 
135:     $tpl2 = new cTemplate();
136:     $tpl2->set('s', 'NAME', 'time' . $listid);
137:     $tpl2->set('s', 'CLASS', 'text_small');
138:     $tpl2->set('s', 'OPTIONS', 'size=1');
139: 
140:     foreach ($timeunits as $key => $value) {
141:         $tpl2->set('d', 'VALUE', $key);
142:         $tpl2->set('d', 'CAPTION', $value);
143: 
144:         if ($default == $key) {
145:             $tpl2->set('d', 'SELECTED', 'SELECTED');
146:         } else {
147:             $tpl2->set('d', 'SELECTED', '');
148:         }
149: 
150:         $tpl2->next();
151:     }
152: 
153:     return $tpl2->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true);
154: }
155: 
156: function getWorkflowList() {
157:     global $idworkflow, $cfg;
158: 
159:     $backendUrl = cRegistry::getBackendUrl();
160: 
161:     $ui = new cGuiMenu();
162:     $workflowitems = new WorkflowItems();
163: 
164:     $workflowitems->select("idworkflow = '$idworkflow'", "", "position ASC");
165: 
166:     while (($workflowitem = $workflowitems->next()) !== false) {
167:         $pos = $workflowitem->get("position");
168:         $name = preg_replace("/\"/","",($workflowitem->get("name")));
169:         $id = $workflowitem->get("idworkflowitem");
170: 
171:         $edititem = new cHTMLLink();
172:         $edititem->setCLink("workflow_steps", 4, "workflow_step_edit");
173:         $edititem->setCustom("idworkflowitem", $id);
174:         $edititem->setCustom("idworkflow", $idworkflow);
175: 
176:         $moveup = new cHTMLLink();
177:         $moveup->setCLink("workflow_steps", 4, "workflow_step_up");
178:         $moveup->setCustom("idworkflowitem", $id);
179:         $moveup->setCustom("idworkflow", $idworkflow);
180:         $moveup->setCustom("position", $pos);
181:         $moveup->setAlt(i18n("Move step up", "workflow"));
182:         $moveup->setContent('<img border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . "workflow/images/no_verschieben.gif" . '">');
183: 
184:         $movedown = new cHTMLLink();
185:         $movedown->setCLink("workflow_steps", 4, "workflow_step_down");
186:         $movedown->setCustom("idworkflowitem", $id);
187:         $movedown->setCustom("idworkflow", $idworkflow);
188:         $movedown->setCustom("position", $pos);
189:         $movedown->setAlt(i18n("Move step down", "workflow"));
190:         $movedown->setContent('<img border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . "workflow/images/nu_verschieben.gif" . '">');
191: 
192:         $deletestep = new cHTMLLink();
193:         $deletestep->setCLink("workflow_steps", 4, "workflow_step_delete");
194:         $deletestep->setCustom("idworkflowitem", $id);
195:         $deletestep->setCustom("idworkflow", $idworkflow);
196:         $deletestep->setCustom("position", $pos);
197:         $deletestep->setAlt(i18n("Delete step", "workflow"));
198:         $deletestep->setContent('<img border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . "workflow/images/workflow_step_delete.gif" . '">');
199: 
200:         $ui->setTitle($id, "$pos. $name");
201:         $ui->setLink($id, $edititem);
202: 
203:         if ($pos > 1) {
204:             $ui->setActions($id, "moveup", $moveup->render());
205:         } else {
206:             $ui->setActions($id, "moveup", '<img src="images/spacer.gif" width="15" height="1">');
207:         }
208: 
209:         if ($pos < $workflowitems->count()) {
210:             $ui->setActions($id, "movedown", $movedown->render());
211:         } else {
212:             $ui->setActions($id, "movedown", '<img src="images/spacer.gif" width="15" height="1">');
213:         }
214: 
215:         $ui->setActions($id, "delete", $deletestep->render());
216: 
217:         if ($_GET['idworkflowitem'] == $id) {
218:             $ui->setMarked($id);
219:         }
220:     }
221: 
222:     $content = $ui->render(false);
223: 
224:     return ($content);
225: }
226: 
227: function createNewWorkflow() {
228:     global $idworkflow, $cfg;
229: 
230:     $backendUrl = cRegistry::getBackendUrl();
231: 
232:     $content = "";
233:     $ui = new cGuiMenu();
234:     $rowmark = false;
235: 
236:     $createstep = new cHTMLLink();
237:     $createstep->setCLink("workflow_steps", 4, "workflow_create_step");
238:     $createstep->setCustom("idworkflow", $idworkflow);
239: 
240:     // ui->setLink("spacer", NULL);
241:     $ui->setTitle("create", i18n("Create new step", "workflow"));
242:     $ui->setImage("create", $backendUrl . $cfg["path"]["plugins"] . "workflow/images/workflow_step_new.gif");
243:     $ui->setLink("create", $createstep);
244:     $ui->setRowmark($rowmark);
245: 
246:     $content = $ui->render(false);
247:     return $content;
248: }
249: 
250: function editWorkflowStep($idworkflowitem) {
251:     global $area, $idworkflow, $idworkflowitem, $frame, $availableWorkflowActions;
252:     global $notification;
253: 
254:     $workflowitem = new WorkflowItem();
255: 
256:     if ($workflowitem->loadByPrimaryKey($idworkflowitem) == false) {
257:         return "&nbsp;";
258:     }
259: 
260:     $workflowactions = new WorkflowActions();
261: 
262:     $stepname = str_replace('\\','',conHtmlSpecialChars($workflowitem->get("name")));
263:     $stepdescription = str_replace('\\','',conHtmlSpecialChars($workflowitem->get("description")));
264:     $id = $workflowitem->get("idworkflowitem");
265:     $task = $workflowitem->get("idtask");
266: 
267:     $form = new cGuiTableForm("workflow_edit");
268: 
269:     $form->setVar("area", $area);
270:     $form->setVar("action", "workflow_save_step");
271:     $form->setVar("idworkflow", $idworkflow);
272:     $form->setVar("idworkflowitem", $idworkflowitem);
273:     $form->setVar("frame", $frame);
274: 
275:     $form->addHeader(i18n("Edit workflow step", "workflow"));
276:     $oTxtStep = new cHTMLTextbox("wfstepname", $stepname, 40, 255);
277:     $form->add(i18n("Step name", "workflow"), $oTxtStep->render());
278:     $oTxtStepDesc = new cHTMLTextarea("wfstepdescription", $stepdescription, 60, 10);
279:     $form->add(i18n("Step description", "workflow"), $oTxtStepDesc->render());
280: 
281:     $actions = '';
282: 
283:     foreach ($availableWorkflowActions as $key => $value) {
284:         $oCheckbox = new cHTMLCheckbox("wfactions[" . $key . "]", "1", "wfactions[" . $key . "]1", $workflowactions->get($id, $key));
285:         $oCheckbox->setLabelText($value);
286:         $actions .= $oCheckbox->toHTML();
287:     }
288: 
289:     $form->add(i18n("Actions", "workflow"), $actions);
290:     $form->add(i18n("Assigned users", "workflow"), getWorkflowUsers($idworkflowitem));
291: 
292:     return $form->render(true);
293: }
294: 
295: function getWorkflowUsers($idworkflowitem) {
296:     global $idworkflow, $cfg;
297: 
298:     $backendUrl = cRegistry::getBackendUrl();
299: 
300:     $ui = new cGuiMenu();
301:     $workflowusers = new WorkflowUserSequences();
302: 
303:     $workflowusers->select("idworkflowitem = '$idworkflowitem'", "", "position ASC");
304: 
305:     while (($workflowitem = $workflowusers->next()) !== false) {
306:         $pos = $workflowitem->get("position");
307:         $iduser = $workflowitem->get("iduser");
308:         $timelimit = $workflowitem->get("timelimit");
309:         $timeunit = $workflowitem->get("timeunit");
310:         $email = $workflowitem->get("emailnoti");
311:         $escalation = $workflowitem->get("escalationnoti");
312:         $timeunit = $workflowitem->get("timeunit");
313:         $id = $workflowitem->get("idusersequence");
314: 
315:         $moveup = new cHTMLLink();
316:         $moveup->setCLink("workflow_steps", 4, "workflow_user_up");
317:         $moveup->setCustom("idworkflowitem", $idworkflowitem);
318:         $moveup->setCustom("idworkflow", $idworkflow);
319:         $moveup->setCustom("position", $pos);
320:         $moveup->setAlt(i18n("Move user up", "workflow"));
321:         $moveup->setContent('<img border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . "workflow/images/no_verschieben.gif" . '">');
322: 
323:         $movedown = new cHTMLLink();
324:         $movedown->setCLink("workflow_steps", 4, "workflow_user_down");
325:         $movedown->setCustom("idworkflowitem", $idworkflowitem);
326:         $movedown->setCustom("idworkflow", $idworkflow);
327:         $movedown->setCustom("position", $pos);
328:         $movedown->setAlt(i18n("Move user down", "workflow"));
329:         $movedown->setContent('<img border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . "workflow/images/nu_verschieben.gif" . '">');
330: 
331:         $deletestep = new cHTMLLink();
332:         $deletestep->setCLink("workflow_steps", 4, "workflow_user_delete");
333:         $deletestep->setCustom("idworkflowitem", $idworkflowitem);
334:         $deletestep->setCustom("idworkflow", $idworkflow);
335:         $deletestep->setCustom("position", $pos);
336:         $deletestep->setCustom("idusersequence", $id);
337:         $deletestep->setAlt(i18n("Delete user", "workflow"));
338:         $deletestep->setContent('<img border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . "workflow/images/workflow_step_delete.gif" . '">');
339: 
340:         $title = "$pos. " . getUsers($id, $iduser);
341: 
342:         $oTxtTime = new cHTMLTextbox("wftimelimit" . $id, $timelimit, 3, 6);
343:         $title .= $oTxtTime->render();
344:         $title .= getTimeUnitSelector($id, $timeunit);
345:         $altmail = i18n("Notify this user via E-Mail", "workflow");
346:         $altnoti = i18n("Escalate to this user via E-Mail", "workflow");
347: 
348:         $oCheckbox = new cHTMLCheckbox("wfemailnoti[" . $id . "]", "1", "wfemailnoti[" . $id . "]1", $email);
349:         $title .= $oCheckbox->toHTML(false) . '<label for="wfemailnoti[' . $id . ']1"><img alt="' . $altmail . '" title="' . $altmail . '" border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . 'workflow/images/workflow_email_noti.gif"></label>';
350: 
351:         $oCheckbox = new cHTMLCheckbox("wfescalnoti[" . $id . "]", "1", "wfescalnoti[" . $id . "]1", $escalation);
352:         $title .= $oCheckbox->toHTML(false) . '<label for="wfescalnoti[' . $id . ']1"><img alt="' . $altnoti . '" title="' . $altnoti . '" border="0" src="' . $backendUrl . $cfg["path"]["plugins"] . 'workflow/images/workflow_escal_noti.gif"></label>';
353: 
354:         $ui->setTitle($id, $title);
355:         $ui->setLink($id, NULL);
356: 
357:         if ($pos > 1) {
358:             $ui->setActions($id, "moveup", $moveup->render());
359:         } else {
360:             $ui->setActions($id, "moveup", '<img src="images/spacer.gif" width="15" height="1">');
361:         }
362: 
363:         if ($pos < $workflowusers->count()) {
364:             $ui->setActions($id, "movedown", $movedown->render());
365:         } else {
366:             $ui->setActions($id, "movedown", '<img src="images/spacer.gif" width="15" height="1">');
367:         }
368: 
369:         $ui->setActions($id, "delete", $deletestep->render());
370: 
371:         $ui->setImage($id, $backendUrl . $cfg["path"]["plugins"] . "workflow/images/workflow_user.gif");
372:     }
373: 
374:     $createstep = new cHTMLLink();
375:     $createstep->setCLink("workflow_steps", 4, "workflow_create_user");
376:     $createstep->setCustom("idworkflow", $idworkflow);
377:     $createstep->setCustom("idworkflowitem", $idworkflowitem);
378: 
379:     $ui->setLink("spacer", NULL);
380: 
381:     $ui->setTitle("create", '<input class="text_medium" type="submit" name="adduser" value="' . i18n("Add User", "workflow") . '">');
382:     $ui->setLink("create", NULL);
383:     $content = $ui->render(false);
384: 
385:     return $content;
386: }
387: 
388: $page->set('s', 'NEW', createNewWorkflow());
389: $page->set('s', 'STEPS', getWorkflowList());
390: $page->set('s', 'EDITSTEP', editWorkflowStep($idworkflowitem));
391: $page->set('s', 'WARNING', i18n('Warning: Changes will reset active Workflows', 'workflow'));
392: 
393: $page->render();
394: 
395: ?>
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0