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 class for workflow user sequence managements.
  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 user sequence management.
 18:  *
 19:  * @package Plugin
 20:  * @subpackage Workflow
 21:  * @method WorkflowUserSequence createNewItem
 22:  * @method WorkflowUserSequence next
 23:  */
 24: class WorkflowUserSequences extends ItemCollection {
 25:     /**
 26:      * Constructor Function
 27:      *
 28:      * @throws cInvalidArgumentException
 29:      */
 30:     public function __construct() {
 31:         global $cfg;
 32:         parent::__construct($cfg["tab"]["workflow_user_sequences"], "idusersequence");
 33:         $this->_setItemClass("WorkflowUserSequence");
 34:     }
 35: 
 36:     /**
 37:      * @param mixed $id
 38:      *
 39:      * @return bool|void
 40:      * @throws cDbException
 41:      * @throws cException
 42:      */
 43:     public function delete($id) {
 44:         global $cfg, $idworkflow;
 45: 
 46:         $item = new WorkflowUserSequence();
 47:         $item->loadByPrimaryKey($id);
 48: 
 49:         $pos = $item->get("position");
 50:         $idworkflowitem = $item->get("idworkflowitem");
 51:         $this->select("position > $pos AND idworkflowitem = " . (int) $idworkflowitem);
 52:         while (($obj = $this->next()) !== false) {
 53:             $pos = $obj->get("position") - 1;
 54:             $obj->setPosition($pos);
 55:             $obj->store();
 56:         }
 57: 
 58:         parent::delete($id);
 59: 
 60:         $this->updateArtAllocation($id);
 61:     }
 62: 
 63:     /**
 64:      * @param $idusersequence
 65:      *
 66:      * @throws cDbException
 67:      * @throws cException
 68:      * @throws cInvalidArgumentException
 69:      */
 70:     public function updateArtAllocation($idusersequence) {
 71:         global $idworkflow, $cfg;
 72:         $oDb = cRegistry::getDb();
 73: 
 74:         $aIdArtLang = array();
 75:         $sSql = 'SELECT idartlang FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence = ' . $oDb->escape($idusersequence) . ';';
 76:         $oDb->query($sSql);
 77:         while ($oDb->nextRecord()) {
 78:             array_push($aIdArtLang, $oDb->f('idartlang'));
 79:         }
 80: 
 81:         $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence = ' . $oDb->escape($idusersequence) . ';';
 82:         $oDb->query($sSql);
 83: 
 84:         foreach ($aIdArtLang as $iIdArtLang) {
 85:             setUserSequence($iIdArtLang, $idworkflow);
 86:         }
 87:     }
 88: 
 89:     /**
 90:      * @param $idworkflowitem
 91:      *
 92:      * @return bool|Item
 93:      * @throws cDbException
 94:      * @throws cException
 95:      * @throws cInvalidArgumentException
 96:      */
 97:     public function create($idworkflowitem) {
 98:         global $auth, $client, $idworkflow;
 99: 
100:         $workflowitems = new WorkflowItems();
101:         if (!$workflowitems->exists($idworkflowitem)) {
102:             $this->lasterror = i18n("Workflow item doesn't exist. Can't create entry.", "workflow");
103:             return false;
104:         }
105: 
106:         $this->select("idworkflowitem = " . (int) $idworkflowitem, "", "position DESC", "1");
107: 
108:         $item = $this->next();
109: 
110:         if ($item === false) {
111:             $lastPos = 1;
112:         } else {
113:             $lastPos = $item->getField("position") + 1;
114:         }
115: 
116:         $newitem = $this->createNewItem();
117:         $newitem->setWorkflowItem($idworkflowitem);
118:         $newitem->setPosition($lastPos);
119:         $newitem->store();
120: 
121:         return $newitem;
122:     }
123: 
124:     /**
125:      * @param $idworkflowitem
126:      * @param $pos1
127:      * @param $pos2
128:      *
129:      * @return bool
130:      * @throws cDbException
131:      * @throws cException
132:      * @throws cInvalidArgumentException
133:      */
134:     public function swap($idworkflowitem, $pos1, $pos2) {
135:         $this->select("idworkflowitem = '$idworkflowitem' AND position = " . (int) $pos1);
136:         if (($item = $this->next()) === false) {
137:             $this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
138:             return false;
139:         }
140: 
141:         $pos1ID = $item->getField("idusersequence");
142: 
143:         $this->select("idworkflowitem = '$idworkflowitem' AND position = " . (int) $pos2);
144:         if (($item = $this->next()) === false) {
145:             $this->lasterror(i18n("Swapping items failed: Item doesn't exist", "workflow"));
146:             return false;
147:         }
148: 
149:         $pos2ID = $item->getField("idusersequence");
150: 
151:         $item = new WorkflowUserSequence();
152:         $item->loadByPrimaryKey($pos1ID);
153:         $item->setPosition($pos2);
154:         $item->store();
155:         $item->loadByPrimaryKey($pos2ID);
156:         $item->setPosition($pos1);
157:         $item->store();
158: 
159:         $this->updateArtAllocation($pos2ID);
160:         $this->updateArtAllocation($pos1ID);
161: 
162:         return true;
163:     }
164: 
165: }
166: 
167: /**
168:  * Class WorkflowUserSequence
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 WorkflowUserSequence extends Item {
178: 
179:     /**
180:      * Constructor Function
181:      */
182:     public function __construct() {
183:         global $cfg;
184:         parent::__construct($cfg["tab"]["workflow_user_sequences"], "idusersequence");
185:     }
186: 
187:     /**
188:      * Override setField Function to prevent that somebody modifies
189:      * idsequence.
190:      *
191:      * @param string $field Field to set
192:      * @param string $value Value to set
193:      * @param bool   $safe
194:      *
195:      * @return bool
196:      * @throws cDbException
197:      * @throws cException
198:      * @throws cInvalidArgumentException if the field is idworkflowitem,
199:      *         idusersequence or position
200:      */
201:     public function setField($field, $value, $safe = true) {
202:         global $cfg;
203: 
204:         switch ($field) {
205:             case "idworkflowitem":
206:                 throw new cInvalidArgumentException("Please use create to modify idsequence. Direct modifications are not allowed");
207:             case "idusersequence":
208:                 throw new cInvalidArgumentException("Please use create to modify idsequence. Direct modifications are not allowed");
209:             case "position":
210:                 throw new cInvalidArgumentException("Please use create and swap to set the position. Direct modifications are not allowed");
211:             case "iduser":
212:                 if ($value != 0) {
213:                     $db = cRegistry::getDb();
214:                     $sql = "SELECT user_id FROM " . $cfg['tab']['user'] . " WHERE user_id = '" . $db->escape($value) . "'";
215:                     $db->query($sql);
216: 
217:                     if (!$db->nextRecord()) {
218:                         $sql = "SELECT group_id FROM " . $cfg["tab"]["groups"] . " WHERE group_id = '" . $db->escape($value) . "'";
219: 
220:                         $db->query($sql);
221:                         if (!$db->nextRecord()) {
222:                             $this->lasterror = i18n("Can't set user_id: User or group doesn't exist", "workflow");
223:                             return false;
224:                         }
225:                     }
226:                     $idusersquence = parent::getField('idusersequence');
227:                 }
228:         }
229: 
230:         parent::setField($field, $value, $safe);
231:         if ($idusersquence) {
232:             $workflowUserSequences = new WorkflowUserSequences();
233:             $workflowUserSequences->updateArtAllocation(0);
234:         }
235:     }
236: 
237:     /**
238:      * Returns the associated workflowItem for this user sequence
239:      *
240:      * @return bool|WorkflowItem
241:      * @throws cDbException
242:      * @throws cException
243:      */
244:     public function getWorkflowItem() {
245:         if ($this->isLoaded()) {
246:             $workflowItem = new WorkflowItem();
247:             $workflowItem->loadByPrimaryKey($this->values["idworkflowitem"]);
248:             return ($workflowItem);
249:         } else {
250:             return false;
251:         }
252:     }
253: 
254:     /**
255:      * Interface to set idworkflowitem.
256:      * Should only be called by "create".
257:      *
258:      * @param string $value The value to set
259:      */
260:     public function setWorkflowItem($value) {
261:         parent::setField("idworkflowitem", $value);
262:     }
263: 
264:     /**
265:      * Interface to set idworkflowitem.
266:      * Should only be called by "create".
267:      *
268:      * @param string $value The value to set
269:      */
270:     public function setPosition($value) {
271:         parent::setField("position", $value);
272:     }
273: 
274: }
275: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0