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