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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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 = $this->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:      */
218:     public function setField($field, $value, $safe = true) {
219:         if ($this->virgin == true) {
220:             $this->lasterror = i18n("No item loaded", "workflow");
221:             return false;
222:         }
223: 
224:         if ($field == "idsequence") {
225:             throw new cInvalidArgumentException("You can't set the idsequence field using this method. Use 'create' in the WorkflowItems class.");
226:         }
227: 
228:         if ($field == "idworkflow") {
229:             throw new cInvalidArgumentException("You can't set the workflow ID using this method. Use 'create' in the WorkflowItems class!");
230:         }
231: 
232:         if ($field == "position") {
233:             throw new cInvalidArgumentException("You can't set the position ID using this method. Use 'create' or 'swap' to create or move items!");
234:         }
235: 
236:         if ($field == "idtask" && $value != 0) {
237:             $taskCollection = new WorkflowTasks();
238:             $taskCollection->select("idtask = '$value'");
239:             if ($taskCollection->next() === false) {
240:                 $this->lasterror = i18n("Requested task doesn't exist, can't assign", "workflow");
241:                 return false;
242:             }
243:         }
244: 
245:         parent::setField($field, $value, $safe);
246:     }
247: 
248:     /**
249:      * init initializes a new wf_items entry.
250:      * Should
251:      * only be called by the create function.
252:      *
253:      * @param int $idworkflow The workflow to set the item to
254:      */
255:     public function init($idworkflow, $idposition) {
256:         global $cfg;
257: 
258:         $workflows = new Workflows();
259: 
260:         $workflows->select("idworkflow = '$idworkflow'");
261: 
262:         if ($workflows->next() === false) {
263:             $this->lasterror = i18n("Workflow doesn't exist", "workflow");
264:             return false;
265:         }
266: 
267:         $workflowItems = new WorkflowItems();
268:         $workflowItems->select("position = '$idposition' AND idworkflow = '$idworkflow'");
269:         if ($workflowItems->next()) {
270:             $this->lasterror = i18n("Position in this workflow already exists.", "workflow");
271:             return false;
272:         }
273: 
274:         parent::setField("idworkflow", $idworkflow);
275:         parent::setField("position", $idposition);
276:         $this->store();
277:         return true;
278:     }
279: 
280:     /**
281:      * setPosition Sets the position for an item.
282:      * Should only be
283:      * called by the "swap" function
284:      *
285:      * @param int $idposition The new position ID
286:      */
287:     public function setPosition($idposition) {
288:         parent::setField("position", $idposition);
289:         $this->store();
290:         return true;
291:     }
292: 
293: }
294: 
295: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen