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