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
    • NavigationMain
    • 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 functions.
  4:  *
  5:  * @package Plugin
  6:  * @subpackage Workflow
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Timo Hummel
 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: cInclude("includes", "functions.con.php");
 19: 
 20: plugin_include('workflow', 'classes/class.workflowitems.php');
 21: 
 22: function getUsers($listid, $default) {
 23:     global $idclient, $cfg, $auth;
 24: 
 25:     $userColl = new cApiUserCollection();
 26:     $users = $userColl->getAccessibleUsers(explode(',', $auth->auth['perm']));
 27:     $groupColl = new cApiGroupCollection();
 28:     $groups = $groupColl->getAccessibleGroups(explode(',', $auth->auth['perm']));
 29: 
 30:     $tpl2 = new cTemplate();
 31:     $tpl2->set('s', 'NAME', 'user' . $listid);
 32:     $tpl2->set('s', 'CLASS', 'text_small');
 33:     $tpl2->set('s', 'OPTIONS', 'size=1');
 34: 
 35:     $tpl2->set('d', 'VALUE', 0);
 36:     $tpl2->set('d', 'CAPTION', '--- ' . i18n("None", "workflow") . ' ---');
 37:     if ($default == 0) {
 38:         $tpl2->set('d', 'SELECTED', 'SELECTED');
 39:     } else {
 40:         $tpl2->set('d', 'SELECTED', '');
 41:     }
 42:     $tpl2->next();
 43: 
 44:     if (is_array($users)) {
 45:         foreach ($users as $key => $value) {
 46:             $tpl2->set('d', 'VALUE', $key);
 47:             $tpl2->set('d', 'CAPTION', $value["realname"] . " (" . $value["username"] . ")");
 48: 
 49:             if ($default == $key) {
 50:                 $tpl2->set('d', 'SELECTED', 'SELECTED');
 51:             } else {
 52:                 $tpl2->set('d', 'SELECTED', '');
 53:             }
 54: 
 55:             $tpl2->next();
 56:         }
 57:     }
 58: 
 59:     $tpl2->set('d', 'VALUE', '0');
 60:     $tpl2->set('d', 'CAPTION', '------------------------------------');
 61:     $tpl2->set('d', 'SELECTED', 'disabled');
 62:     $tpl2->next();
 63: 
 64:     if (is_array($groups)) {
 65:         foreach ($groups as $key => $value) {
 66:             $tpl2->set('d', 'VALUE', $key);
 67:             $tpl2->set('d', 'CAPTION', $value["groupname"]);
 68: 
 69:             if ($default == $key) {
 70:                 $tpl2->set('d', 'SELECTED', 'SELECTED');
 71:             } else {
 72:                 $tpl2->set('d', 'SELECTED', '');
 73:             }
 74: 
 75:             $tpl2->next();
 76:         }
 77:     }
 78: 
 79:     return $tpl2->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true);
 80: }
 81: 
 82: function isCurrentEditor($uid) {
 83:     global $auth, $cfg;
 84: 
 85:     // Check if the UID is a group. If yes, check if we are in it
 86:     $user = new cApiUser();
 87:     if ($user->loadByPrimaryKey($uid) == false) {
 88:         $db2 = cRegistry::getDb();
 89: 
 90:         // Yes, it's a group. Let's try to load the group members!
 91:         $sql = "SELECT user_id FROM " . $cfg["tab"]["groupmembers"] . "
 92:                 WHERE group_id = '" . cSecurity::escapeDB($uid, $db2) . "'";
 93: 
 94:         $db2->query($sql);
 95: 
 96:         while ($db2->nextRecord()) {
 97:             if ($db2->f("user_id") == $auth->auth["uid"]) {
 98:                 return true;
 99:             }
100:         }
101:     } else {
102:         if ($uid == $auth->auth["uid"]) {
103:             return true;
104:         }
105:     }
106: 
107:     return false;
108: }
109: 
110: function getActionSelect($idartlang, $idusersequence) {
111:     global $cfg;
112: 
113:     $workflowActions = new WorkflowActions();
114: 
115:     $allActions = $workflowActions->getAvailableWorkflowActions();
116: 
117:     $wfSelect = new cTemplate();
118:     $wfSelect->set('s', 'NAME', 'wfselect' . $idartlang);
119:     $wfSelect->set('s', 'CLASS', 'text_medium');
120: 
121:     $userSequence = new WorkflowUserSequence();
122:     $userSequence->loadByPrimaryKey($idusersequence);
123: 
124:     $workflowItem = $userSequence->getWorkflowItem();
125: 
126:     if ($workflowItem === false) {
127:         return;
128:     }
129: 
130:     $wfRights = $workflowItem->getStepRights();
131: 
132:     $artAllocation = new WorkflowArtAllocations();
133:     $artAllocation->select("idartlang = '$idartlang'");
134: 
135:     if (($obj = $artAllocation->next()) !== false) {
136:         $laststep = $obj->get("lastusersequence");
137:     }
138: 
139:     $bExistOption = false;
140:     if ($laststep != $idusersequence) {
141:         $wfSelect->set('d', 'VALUE', 'next');
142:         $wfSelect->set('d', 'CAPTION', i18n("Confirm", "workflow"));
143:         $wfSelect->set('d', 'SELECTED', 'SELECTED');
144:         $wfSelect->next();
145:         $bExistOption = true;
146:     }
147: 
148:     if ($wfRights["last"] == true) {
149:         $wfSelect->set('d', 'VALUE', 'last');
150:         $wfSelect->set('d', 'CAPTION', i18n("Back to last editor", "workflow"));
151:         $wfSelect->set('d', 'SELECTED', '');
152:         $wfSelect->next();
153:         $bExistOption = true;
154:     }
155: 
156:     if ($wfRights["reject"] == true) {
157:         $wfSelect->set('d', 'VALUE', 'reject');
158:         $wfSelect->set('d', 'CAPTION', i18n("Reject article", "workflow"));
159:         $wfSelect->set('d', 'SELECTED', '');
160:         $wfSelect->next();
161:         $bExistOption = true;
162:     }
163: 
164:     if ($wfRights["revise"] == true) {
165:         $wfSelect->set('d', 'VALUE', 'revise');
166:         $wfSelect->set('d', 'CAPTION', i18n("Revise article", "workflow"));
167:         $wfSelect->set('d', 'SELECTED', '');
168:         $wfSelect->next();
169:         $bExistOption = true;
170:     }
171: 
172:     if ($bExistOption)
173:         return ($wfSelect->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true));
174:     else {
175:         return false;
176:     }
177: }
178: 
179: // unction for inserting todos in wokflow_art_allocation used, when a workflow
180: // is associated with a category in content->category
181: function setUserSequence($idartlang, $defaultidworkflow) {
182:     $wfaa = new WorkflowArtAllocations();
183:     $wfaa->select("idartlang = '$idartlang'");
184:     $idusersequence = 0;
185: 
186:     if (($associatedUserSequence = $wfaa->next()) !== false) {
187:         $idartallocation = $associatedUserSequence->get("idartallocation");
188:         $wfaa->delete($idartallocation);
189:     }
190: 
191:     if ($defaultidworkflow != -1) {
192:         $newObj = $wfaa->create($idartlang);
193: 
194:         if (!$newObj) {
195:             return false;
196:         }
197: 
198:         // Get the first idusersequence for the new item
199:         $workflowItems = new WorkflowItems();
200:         $workflowItems->select("idworkflow = '$defaultidworkflow' AND position = '1'");
201: 
202:         if (($obj = $workflowItems->next()) !== false) {
203:             $firstitem = $obj->get("idworkflowitem");
204:         }
205: 
206:         $workflowUserSequences = new WorkflowUserSequences();
207:         $workflowUserSequences->select("idworkflowitem = '$firstitem' AND position = '1'");
208: 
209:         if (($obj = $workflowUserSequences->next()) !== false) {
210:             $firstIDUserSequence = $obj->get("idusersequence");
211:         }
212: 
213:         $newObj->set("idusersequence", $firstIDUserSequence);
214:         $newObj->store();
215: 
216:         $idusersequence = $newObj->get("idusersequence");
217:         $associatedUserSequence = $newObj;
218:     }
219: }
220: 
221: /**
222:  * Returns current user sequence, either from workflow article allocations or
223:  * from workflow user sequnces.
224:  *
225:  * @param int $idartlang Article language id
226:  * @param int $defaultidworkflow Default workflow id
227:  * @return int false of found user sequence or false
228:  */
229: function getCurrentUserSequence($idartlang, $defaultidworkflow) {
230:     $wfaa = new WorkflowArtAllocations();
231:     $wfaa->select("idartlang = '$idartlang'");
232:     $idusersequence = 0;
233: 
234:     if (($associatedUserSequence = $wfaa->next()) !== false) {
235:         $idusersequence = $associatedUserSequence->get("idusersequence");
236:     }
237: 
238:     if ($idusersequence == 0) {
239:         if ($associatedUserSequence != false) {
240:             $newObj = $associatedUserSequence;
241:         } else {
242:             $newObj = $wfaa->create($idartlang);
243: 
244:             if (!$newObj) {
245:                 return false;
246:             }
247:         }
248: 
249:         // Get the first idusersequence for the new item
250:         $workflowItems = new WorkflowItems();
251:         $workflowItems->select("idworkflow = '$defaultidworkflow' AND position = '1'");
252: 
253:         if (($obj = $workflowItems->next()) !== false) {
254:             $firstitem = $obj->get("idworkflowitem");
255:         }
256: 
257:         $workflowUserSequences = new WorkflowUserSequences();
258:         $workflowUserSequences->select("idworkflowitem = '$firstitem' AND position = '1'");
259: 
260:         if (($obj = $workflowUserSequences->next()) !== false) {
261:             $firstIDUserSequence = $obj->get("idusersequence");
262:         }
263: 
264:         $newObj->set("idusersequence", $firstIDUserSequence);
265:         $newObj->store();
266: 
267:         $idusersequence = $newObj->get("idusersequence");
268:         $associatedUserSequence = $newObj;
269:     }
270: 
271:     return $idusersequence;
272: }
273: 
274: function getLastWorkflowStatus($idartlang) {
275:     $wfaa = new WorkflowArtAllocations();
276: 
277:     $wfaa->select("idartlang = '$idartlang'");
278: 
279:     if (($associatedUserSequence = $wfaa->next()) !== false) {
280:         $laststatus = $associatedUserSequence->get("laststatus");
281:     } else {
282:         return false;
283:     }
284: 
285:     switch ($laststatus) {
286:         case "reject":
287:             return (i18n("Rejected", "workflow"));
288:             break;
289:         case "revise":
290:             return (i18n("Revised", "workflow"));
291:             break;
292:         case "last":
293:             return (i18n("Last", "workflow"));
294:             break;
295:         case "confirm":
296:             return (i18n("Confirmed", "workflow"));
297:             break;
298:         default:
299:             return (i18n("None", "workflow"));
300:             break;
301:     }
302:     return "";
303: }
304: 
305: function doWorkflowAction($idartlang, $action) {
306:     global $cfg, $idcat;
307: 
308:     switch ($action) {
309:         case "last":
310:             $artAllocations = new WorkflowArtAllocations();
311:             $artAllocations->select("idartlang = '$idartlang'");
312: 
313:             if (($obj = $artAllocations->next()) !== false) {
314:                 $usersequence = new WorkflowUserSequence();
315:                 $usersequence->loadByPrimaryKey($obj->get("idusersequence"));
316: 
317:                 $workflowitem = $usersequence->getWorkflowItem();
318: 
319:                 $idworkflow = $workflowitem->get("idworkflow");
320:                 $newpos = $workflowitem->get("position") - 1;
321: 
322:                 if ($newpos < 1) {
323:                     $newpos = 1;
324:                 }
325: 
326:                 $workflowitems = new WorkflowItems();
327:                 $workflowitems->select("idworkflow = '$idworkflow' AND position = '" . cSecurity::escapeDB($newpos, NULL) . "'");
328: 
329:                 if (($nextObj = $workflowitems->next()) !== false) {
330:                     $userSequences = new WorkflowUserSequences();
331:                     $idworkflowitem = $nextObj->get("idworkflowitem");
332:                     $userSequences->select("idworkflowitem = '$idworkflowitem'");
333: 
334:                     if (($nextSeqObj = $userSequences->next()) !== false) {
335:                         $obj->set("lastusersequence", $obj->get("idusersequence"));
336:                         $obj->set("idusersequence", $nextSeqObj->get("idusersequence"));
337:                         $obj->set("laststatus", "last");
338:                         $obj->store();
339:                     }
340:                 }
341:             }
342:             break;
343:         case "next":
344:             $artAllocations = new WorkflowArtAllocations();
345:             $artAllocations->select("idartlang = '$idartlang'");
346: 
347:             if (($obj = $artAllocations->next()) !== false) {
348:                 $usersequence = new WorkflowUserSequence();
349:                 $usersequence->loadByPrimaryKey($obj->get("idusersequence"));
350: 
351:                 $workflowitem = $usersequence->getWorkflowItem();
352: 
353:                 $idworkflow = $workflowitem->get("idworkflow");
354:                 $newpos = $workflowitem->get("position") + 1;
355: 
356:                 $workflowitems = new WorkflowItems();
357:                 $workflowitems->select("idworkflow = '$idworkflow' AND position = '" . cSecurity::escapeDB($newpos, NULL) . "'");
358: 
359:                 if (($nextObj = $workflowitems->next()) !== false) {
360:                     $userSequences = new WorkflowUserSequences();
361:                     $idworkflowitem = $nextObj->get("idworkflowitem");
362:                     $userSequences->select("idworkflowitem = '$idworkflowitem'");
363: 
364:                     if (($nextSeqObj = $userSequences->next()) !== false) {
365:                         $obj->set("lastusersequence", '10');
366:                         $obj->set("idusersequence", $nextSeqObj->get("idusersequence"));
367:                         $obj->set("laststatus", "confirm");
368:                         $obj->store();
369:                     }
370:                 } else {
371:                     $workflowitems->select("idworkflow = '$idworkflow' AND position = '" . cSecurity::escapeDB($workflowitem->get("position"), NULL) . "'");
372:                     if (($nextObj = $workflowitems->next()) !== false) {
373:                         $userSequences = new WorkflowUserSequences();
374:                         $idworkflowitem = $nextObj->get("idworkflowitem");
375:                         $userSequences->select("idworkflowitem = '$idworkflowitem'");
376: 
377:                         if (($nextSeqObj = $userSequences->next()) !== false) {
378:                             $obj->set("lastusersequence", $obj->get("idusersequence"));
379:                             $obj->set("idusersequence", $nextSeqObj->get("idusersequence"));
380:                             $obj->set("laststatus", "confirm");
381:                             $obj->store();
382:                         }
383:                     }
384:                 }
385:             }
386:             break;
387:         case "reject":
388:             $artAllocations = new WorkflowArtAllocations();
389:             $artAllocations->select("idartlang = '$idartlang'");
390: 
391:             if (($obj = $artAllocations->next()) !== false) {
392:                 $usersequence = new WorkflowUserSequence();
393:                 $usersequence->loadByPrimaryKey($obj->get("idusersequence"));
394: 
395:                 $workflowitem = $usersequence->getWorkflowItem();
396: 
397:                 $idworkflow = $workflowitem->get("idworkflow");
398:                 $newpos = 1;
399: 
400:                 $workflowitems = new WorkflowItems();
401:                 $workflowitems->select("idworkflow = '$idworkflow' AND position = '" . cSecurity::escapeDB($newpos, NULL) . "'");
402: 
403:                 if (($nextObj = $workflowitems->next()) !== false) {
404:                     $userSequences = new WorkflowUserSequences();
405:                     $idworkflowitem = $nextObj->get("idworkflowitem");
406:                     $userSequences->select("idworkflowitem = '$idworkflowitem'");
407: 
408:                     if (($nextSeqObj = $userSequences->next()) !== false) {
409:                         $obj->set("lastusersequence", $obj->get("idusersequence"));
410:                         $obj->set("idusersequence", $nextSeqObj->get("idusersequence"));
411:                         $obj->set("laststatus", "reject");
412:                         $obj->store();
413:                     }
414:                 }
415:             }
416:             break;
417: 
418:         case "revise":
419:             $db = cRegistry::getDb();
420:             $sql = "SELECT idart, idlang FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = '" . cSecurity::escapeDB($idartlang, $db) . "'";
421:             $db->query($sql);
422:             $db->nextRecord();
423:             $idart = $db->f("idart");
424:             $idlang = $db->f("idlang");
425: 
426:             $newidart = conCopyArticle($idart, $idcat, "foo");
427: 
428:             break;
429:         default:
430:     }
431: }
432: 
433: function getWorkflowForUserSequence($usersequence) {
434:     $usersequences = new WorkflowUserSequences();
435:     $workflowitems = new WorkflowItems();
436:     $usersequences->select("idusersequence = '$usersequence'");
437: 
438:     if (($obj = $usersequences->next()) !== false) {
439:         $idworkflowitem = $obj->get("idworkflowitem");
440:     } else {
441:         return false;
442:     }
443: 
444:     $workflowitems->select("idworkflowitem = '$idworkflowitem'");
445:     if (($obj = $workflowitems->next()) !== false) {
446:         return $obj->get("idworkflow");
447:     } else {
448:         return false;
449:     }
450: }
451: 
452: function workflowSelect($listid, $default, $idcat) {
453:     global $idclient, $cfg, $frame, $area, $workflowworkflows, $client, $lang, $wfcache, $workflowSelectBox;
454: 
455:     $oSelectBox = new cHTMLSelectElement('workflow');
456:     $oSelectBox = $workflowSelectBox;
457: 
458:     $default = (int) $default;
459:     $workflowSelectBox->updateAttributes(array(
460:         "id" => "wfselect" . $idcat
461:     ));
462:     $workflowSelectBox->updateAttributes(array(
463:         "name" => "wfselect" . $idcat
464:     ));
465:     $workflowSelectBox->setDefault($default);
466: 
467:     $sButton = '<a href="javascript:setWorkflow(' . $idcat . ', \'' . "wfselect" . $idcat . '\')"><img src="' . $cfg["path"]["images"] . 'submit.gif" class="spaced"></a>';
468: 
469:     return $workflowSelectBox->render() . $sButton;
470: }
471: 
472: function workflowInherit($idcat) {
473:     global $idclient, $cfg, $frame, $area, $workflowworkflows, $sess;
474:     $sUrl = $sess->url("main.php?area=$area&frame=$frame&modidcat=$idcat&action=workflow_inherit_down");
475:     $sButton = '<a href="' . $sUrl . '"><img src="' . $cfg["path"]["images"] . 'pfeil_runter.gif" class="spaced"></a>';
476:     return $sButton;
477: }
478: 
479: ?>
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0