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