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