Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SIWECOS
    • 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
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the Workflow management class.
  4:  *
  5:  * @package Plugin
  6:  * @subpackage Workflow
  7:  * @author Timo Hummel
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: $cfg["tab"]["workflow"] = $cfg['sql']['sqlprefix'] . "_piwf_workflow";
 17: $cfg["tab"]["workflow_allocation"] = $cfg['sql']['sqlprefix'] . "_piwf_allocation";
 18: $cfg["tab"]["workflow_art_allocation"] = $cfg['sql']['sqlprefix'] . "_piwf_art_allocation";
 19: $cfg["tab"]["workflow_items"] = $cfg['sql']['sqlprefix'] . "_piwf_items";
 20: $cfg["tab"]["workflow_tasks"] = $cfg['sql']['sqlprefix'] . "_piwf_tasks";
 21: $cfg["tab"]["workflow_user_sequences"] = $cfg['sql']['sqlprefix'] . "_piwf_user_sequences";
 22: $cfg["tab"]["workflow_actions"] = $cfg['sql']['sqlprefix'] . "_piwf_actions";
 23: 
 24: plugin_include('workflow', 'classes/class.workflowactions.php');
 25: plugin_include('workflow', 'classes/class.workflowallocation.php');
 26: plugin_include('workflow', 'classes/class.workflowartallocation.php');
 27: plugin_include('workflow', 'classes/class.workflowitems.php');
 28: plugin_include('workflow', 'classes/class.workflowusersequence.php');
 29: 
 30: /**
 31:  * Workflow management class.
 32:  *
 33:  * @package Plugin
 34:  * @subpackage Workflow
 35:  * @method Workflow createNewItem
 36:  * @method Workflow next
 37:  */
 38: class Workflows extends ItemCollection {
 39:     /**
 40:      * Constructor Function
 41:      *
 42:      * @throws cInvalidArgumentException
 43:      */
 44:     public function __construct() {
 45:         global $cfg;
 46:         parent::__construct($cfg["tab"]["workflow"], "idworkflow");
 47:         $this->_setItemClass("Workflow");
 48:     }
 49: 
 50:     /**
 51:      * @return Workflow
 52:      * @throws cDbException
 53:      * @throws cInvalidArgumentException
 54:      */
 55:     public function create() {
 56:         global $auth, $client, $lang;
 57:         $newitem = $this->createNewItem();
 58:         $newitem->setField("created", date('Y-m-d H:i:s'));
 59:         $newitem->setField("idauthor", $auth->auth["uid"]);
 60:         $newitem->setField("idclient", $client);
 61:         $newitem->setField("idlang", $lang);
 62:         $newitem->store();
 63: 
 64:         return $newitem;
 65:     }
 66: 
 67:     /**
 68:      * Deletes all corresponding informations to this workflow and delegate call
 69:      * to parent
 70:      *
 71:      * @param int $idWorkflow - id of workflow to delete
 72:      *
 73:      * @throws cDbException
 74:      */
 75:     public function delete($idWorkflow) {
 76:         global $cfg;
 77:         $oDb = cRegistry::getDb();
 78: 
 79:         $aItemIdsDelete = array();
 80:         $sSql = 'SELECT idworkflowitem FROM ' . $cfg["tab"]["workflow_items"] . ' WHERE idworkflow = ' . cSecurity::toInteger($idWorkflow) . ';';
 81:         $oDb->query($sSql);
 82:         while ($oDb->nextRecord()) {
 83:             $aItemIdsDelete[] = (int) $oDb->f('idworkflowitem');
 84:         }
 85: 
 86:         if (!empty($aItemIdsDelete)) {
 87:             $aUserSequencesDelete = array();
 88:             $sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem in (' . implode(',', $aItemIdsDelete) . ');';
 89:             $oDb->query($sSql);
 90:             while ($oDb->nextRecord()) {
 91:                 $aUserSequencesDelete[] = (int) $oDb->f('idusersequence');
 92:             }
 93: 
 94:             $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem in (' . implode(',', $aItemIdsDelete) . ');';
 95:             $oDb->query($sSql);
 96: 
 97:             $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_actions"] . ' WHERE idworkflowitem in (' . implode(',', $aItemIdsDelete) . ');';
 98:             $oDb->query($sSql);
 99:         }
100: 
101:         if (!empty($aUserSequencesDelete)) {
102:             $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequencesDelete) . ');';
103:             $oDb->query($sSql);
104:         }
105: 
106:         $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_items"] . ' WHERE idworkflow = ' . cSecurity::toInteger($idWorkflow) . ';';
107:         $oDb->query($sSql);
108: 
109:         $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_allocation"] . ' WHERE idworkflow = ' . cSecurity::toInteger($idWorkflow) . ';';
110:         $oDb->query($sSql);
111: 
112:         parent::delete($idWorkflow);
113:     }
114: 
115: }
116: 
117: /**
118:  * Class Workflow
119:  * Class for a single workflow item
120:  *
121:  * @package Plugin
122:  * @subpackage Workflow
123:  * @author Timo A. Hummel <Timo.Hummel@4fb.de>
124:  * @version 0.1
125:  * @copyright four for business 2003
126:  */
127: class Workflow extends Item {
128: 
129:     /**
130:      * Constructor Function
131:      */
132:     public function __construct() {
133:         global $cfg;
134: 
135:         parent::__construct($cfg["tab"]["workflow"], "idworkflow");
136:     }
137: 
138: }
139: 
140: /**
141:  * @param $idcat
142:  *
143:  * @return int|mixed
144:  * @throws cDbException
145:  * @throws cException
146:  */
147: function getWorkflowForCat($idcat) {
148:     global $lang;
149: 
150:     $idcatlang = getCatLang($idcat, $lang);
151:     if (!$idcatlang) {
152:         return 0;
153:     }
154:     $workflows = new WorkflowAllocations();
155:     $workflows->select('idcatlang = ' . (int) $idcatlang);
156:     if (($obj = $workflows->next()) !== false) {
157:         // Sanity: Check if the workflow still exists
158:         $workflow = new Workflow();
159:         $res = $workflow->loadByPrimaryKey($obj->get('idworkflow'));
160:         return ($res == true) ? $obj->get('idworkflow') : 0;
161:     }
162: }
163: 
164: /**
165:  * @param $idcat
166:  * @param $idlang
167:  *
168:  * @return int
169:  * @throws cDbException
170:  */
171: function getCatLang($idcat, $idlang) {
172:     // Get the idcatlang
173:     $oCatLangColl = new cApiCategoryLanguageCollection();
174:     $aIds = $oCatLangColl->getIdsByWhereClause('idlang = ' . (int) $idlang . ' AND idcat = ' . (int) $idcat);
175:     return (count($aIds) > 0) ? $aIds[0] : 0;
176: }
177: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0