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
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the class for workflow item management.
  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: /**
 19:  * Class for workflow item management.
 20:  *
 21:  * @package Plugin
 22:  * @subpackage Workflow
 23:  */
 24: class WorkflowItems extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor Function
 28:      *
 29:      * @param string $table The table to use as information source
 30:      */
 31:     public function __construct() {
 32:         global $cfg;
 33:         parent::__construct($cfg["tab"]["workflow_items"], "idworkflowitem");
 34:         $this->_setItemClass("WorkflowItem");
 35:     }
 36: 
 37:     public function delete($id) {
 38:         global $cfg;
 39:         $item = new WorkflowItem();
 40:         $item->loadByPrimaryKey($id);
 41:         $pos = $item->get("position");
 42:         $idworkflow = $item->get("idworkflow");
 43:         $oDb = cRegistry::getDb();
 44: 
 45:         $this->select("position > $pos AND idworkflow = '" . cSecurity::escapeDB($idworkflow, $oDb) . "'");
 46:         while (($obj = $this->next()) !== false) {
 47:             $obj->setPosition($obj->get("position") - 1);
 48:             $obj->store();
 49:         }
 50: 
 51:         $aUserSequencesDelete = array();
 52:         $sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem = ' . $id . ';';
 53:         $oDb->query($sSql);
 54:         while ($oDb->nextRecord()) {
 55:             array_push($aUserSequencesDelete, cSecurity::escapeDB($oDb->f('idusersequence'), $oDb));
 56:         }
 57: 
 58:         $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_actions"] . ' WHERE idworkflowitem = ' . cSecurity::escapeDB($id, $oDb) . ';';
 59:         $oDb->query($sSql);
 60: 
 61:         $this->updateArtAllocation($id, 1);
 62: 
 63:         if (count($aUserSequencesDelete) > 0) {
 64:             $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idusersequence in (' . implode(',', $aUserSequencesDelete) . ');';
 65:             $oDb->query($sSql);
 66:         }
 67:     }
 68: 
 69:     public function updateArtAllocation($idworkflowitem, $delete = false) {
 70:         global $idworkflow, $cfg;
 71:         $oDb = cRegistry::getDb();
 72: 
 73:         $aUserSequences = array();
 74:         $sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem = ' . cSecurity::escapeDB($idworkflowitem, $oDb) . ';';
 75: 
 76:         $oDb->query($sSql);
 77:         while ($oDb->nextRecord()) {
 78:             array_push($aUserSequences, cSecurity::escapeDB($oDb->f('idusersequence'), $oDb));
 79:         }
 80: 
 81:         $aIdArtLang = array();
 82:         if (count($aUserSequences) > 0) {
 83:             $sSql = 'SELECT idartlang FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
 84:             $oDb->query($sSql);
 85:             while ($oDb->nextRecord()) {
 86:                 array_push($aIdArtLang, $oDb->f('idartlang'));
 87:             }
 88:             $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
 89:             $oDb->query($sSql);
 90:         }
 91: 
 92:         if ($delete) {
 93:             parent::delete($idworkflowitem);
 94:         }
 95: 
 96:         foreach ($aIdArtLang as $iIdArtLang) {
 97:             setUserSequence($iIdArtLang, $idworkflow);
 98:         }
 99:     }
100: 
101:     public function swap($idworkflow, $pos1, $pos2) {
102:         $this->select("idworkflow = '$idworkflow' AND position = '$pos1'");
103:         if (($item = $this->next()) === false) {
104:             $this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
105:             return false;
106:         }
107: 
108:         $pos1ID = $item->getField("idworkflowitem");
109: 
110:         $this->select("idworkflow = '$idworkflow' AND position = '$pos2'");
111:         if (($item = $this->next()) === false) {
112:             $this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
113:             return false;
114:         }
115: 
116:         $pos2ID = $item->getField("idworkflowitem");
117: 
118:         $item = new WorkflowItem();
119:         $item->loadByPrimaryKey($pos1ID);
120:         $item->setPosition($pos2);
121:         $item->store();
122:         $item->loadByPrimaryKey($pos2ID);
123:         $item->setPosition($pos1);
124:         $item->store();
125: 
126:         $this->updateArtAllocation($pos1ID);
127:         $this->updateArtAllocation($pos2ID);
128:         return (true);
129:     }
130: 
131:     public function create($idworkflow) {
132:         $workflows = new Workflows();
133: 
134:         $workflows->select("idworkflow = '$idworkflow'");
135: 
136:         if ($workflows->next() === false) {
137:             $this->lasterror = i18n("Can't add item to workflow: Workflow doesn't exist", "workflow");
138:             return false;
139:         }
140: 
141:         $this->select("idworkflow = '$idworkflow'", "", "position DESC", "1");
142: 
143:         $item = $this->next();
144: 
145:         if ($item === false) {
146:             $lastPos = 1;
147:         } else {
148:             $lastPos = $item->getField("position") + 1;
149:         }
150: 
151:         $newItem = parent::createNewItem();
152:         if ($newItem->init($idworkflow, $lastPos) === false) {
153:             $this->delete($newItem->getField("idworkflowitem"));
154:             $this->lasterror = $newItem->lasterror;
155:             return false;
156:         }
157: 
158:         if ($item === false) {
159:             $this->updateArtAllocation(0);
160:         }
161: 
162:         return ($newItem);
163:     }
164: 
165: }
166: 
167: /**
168:  * Class WorkflowItem
169:  * Class for a single workflow item
170:  *
171:  * @package Plugin
172:  * @subpackage Workflow
173:  * @author Timo A. Hummel <Timo.Hummel@4fb.de>
174:  * @version 0.1
175:  * @copyright four for business 2003
176:  */
177: class WorkflowItem extends Item {
178: 
179:     /**
180:      * Constructor Function
181:      *
182:      * @param string $table The table to use as information source
183:      */
184:     public function __construct() {
185:         global $cfg;
186: 
187:         parent::__construct($cfg["tab"]["workflow_items"], "idworkflowitem");
188:     }
189: 
190:     public function getStepRights() {
191:         $idwfi = $this->values["idworkflowitem"];
192:         $workflowActions = new WorkflowActions();
193: 
194:         $actions = $workflowActions->getAvailableWorkflowActions();
195: 
196:         foreach ($actions as $key => $value) {
197:             $rights[$key] = $workflowActions->get($idwfi, $key);
198:         }
199: 
200:         return $rights;
201:     }
202: 
203:     /**
204:      * Overridden setField function.
205:      *
206:      * @param string $field Void field since we override the usual setField
207:      *            function
208:      * @param string $value Void field since we override the usual setField
209:      *            function
210:      * @throws cInvalidArgumentException if the field is idsequence, idworkflow
211:      *         or position
212:      * @return void
213:      */
214:     public function setField($field, $value, $safe = true) {
215:         if ($this->virgin == true) {
216:             $this->lasterror = i18n("No item loaded", "workflow");
217:             return false;
218:         }
219: 
220:         if ($field == "idsequence") {
221:             throw new cInvalidArgumentException("You can't set the idsequence field using this method. Use 'create' in the WorkflowItems class.");
222:         }
223: 
224:         if ($field == "idworkflow") {
225:             throw new cInvalidArgumentException("You can't set the workflow ID using this method. Use 'create' in the WorkflowItems class!");
226:         }
227: 
228:         if ($field == "position") {
229:             throw new cInvalidArgumentException("You can't set the position ID using this method. Use 'create' or 'swap' to create or move items!");
230:         }
231: 
232:         if ($field == "idtask" && $value != 0) {
233:             $taskCollection = new WorkflowTasks();
234:             $taskCollection->select("idtask = '$value'");
235:             if ($taskCollection->next() === false) {
236:                 $this->lasterror = i18n("Requested task doesn't exist, can't assign", "workflow");
237:                 return false;
238:             }
239:         }
240: 
241:         parent::setField($field, $value, $safe);
242:     }
243: 
244:     /**
245:      * init initializes a new wf_items entry.
246:      * Should
247:      * only be called by the create function.
248:      *
249:      * @param int $idworkflow The workflow to set the item to
250:      */
251:     public function init($idworkflow, $idposition) {
252:         global $cfg;
253: 
254:         $workflows = new Workflows();
255: 
256:         $workflows->select("idworkflow = '$idworkflow'");
257: 
258:         if ($workflows->next() === false) {
259:             $this->lasterror = i18n("Workflow doesn't exist", "workflow");
260:             return false;
261:         }
262: 
263:         $workflowItems = new WorkflowItems();
264:         $workflowItems->select("position = '$idposition' AND idworkflow = '$idworkflow'");
265:         if ($workflowItems->next()) {
266:             $this->lasterror = i18n("Position in this workflow already exists.", "workflow");
267:             return false;
268:         }
269: 
270:         parent::setField("idworkflow", $idworkflow);
271:         parent::setField("position", $idposition);
272:         parent::store();
273:         return true;
274:     }
275: 
276:     /**
277:      * setPosition Sets the position for an item.
278:      * Should only be
279:      * called by the "swap" function
280:      *
281:      * @param int $idposition The new position ID
282:      */
283:     public function setPosition($idposition) {
284:         parent::setField("position", $idposition);
285:         parent::store();
286:         return true;
287:     }
288: 
289: }
290: 
291: ?>
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0