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 allocation 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 allocation management.
 18:  *
 19:  * @package Plugin
 20:  * @subpackage Workflow
 21:  * @method WorkflowAllocation createNewItem
 22:  * @method WorkflowAllocation next
 23:  */
 24: class WorkflowAllocations extends ItemCollection {
 25:     /**
 26:      * Constructor Function
 27:      *
 28:      * @throws cInvalidArgumentException
 29:      */
 30:     public function __construct() {
 31:         global $cfg;
 32:         parent::__construct($cfg["tab"]["workflow_allocation"], "idallocation");
 33:         $this->_setItemClass("WorkflowAllocation");
 34:     }
 35: 
 36:     /**
 37:      * @param mixed $idallocation
 38:      *
 39:      * @return bool|void
 40:      * @throws cDbException
 41:      * @throws cException
 42:      * @throws cInvalidArgumentException
 43:      */
 44:     public function delete($idallocation) {
 45:         global $cfg, $lang;
 46: 
 47:         $obj = new WorkflowAllocation();
 48:         $obj->loadByPrimaryKey($idallocation);
 49: 
 50:         $idcatlang = $obj->get("idcatlang");
 51: 
 52:         $db = cRegistry::getDb();
 53:         $sql = "SELECT idcat FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcatlang = '" . cSecurity::toInteger($idcatlang) . "'";
 54:         $db->query($sql);
 55:         $db->nextRecord();
 56:         $idcat = $db->f("idcat");
 57: 
 58:         $sql = "SELECT idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idcat = '" . cSecurity::toInteger($idcat) . "'";
 59:         $db->query($sql);
 60: 
 61:         $idarts = [];
 62:         while ($db->nextRecord()) {
 63:             $idarts[] = $db->f("idart");
 64:         }
 65: 
 66:         $idartlangs = array();
 67:         foreach ($idarts as $idart) {
 68:             $sql = "SELECT idartlang FROM " . $cfg["tab"]["art_lang"] . " WHERE idart = '" . cSecurity::toInteger($idart) . "' and idlang = '" . cSecurity::toInteger($lang) . "'";
 69:             $db->query($sql);
 70:             if ($db->nextRecord()) {
 71:                 $idartlangs[] = $db->f("idartlang");
 72:             }
 73:         }
 74: 
 75:         $workflowArtAllocation = new WorkflowArtAllocation();
 76:         $workflowArtAllocations = new WorkflowArtAllocations();
 77: 
 78:         foreach ($idartlangs as $idartlang) {
 79:             $workflowArtAllocation->loadBy("idartlang", $idartlang);
 80:             $workflowArtAllocations->delete($workflowArtAllocation->get("idartallocation"));
 81:         }
 82: 
 83:         parent::delete($idallocation);
 84:     }
 85: 
 86:     /**
 87:      * @param $idworkflow
 88:      * @param $idcatlang
 89:      *
 90:      * @return bool|Item
 91:      * @throws cDbException
 92:      * @throws cException
 93:      * @throws cInvalidArgumentException
 94:      */
 95:     public function create($idworkflow, $idcatlang) {
 96:         $this->select("idcatlang = '$idcatlang'");
 97: 
 98:         if ($this->next() !== false) {
 99:             $this->lasterror = i18n("Category already has a workflow assigned", "workflow");
100:             return false;
101:         }
102: 
103:         $workflows = new Workflows();
104:         $workflows->select("idworkflow = '$idworkflow'");
105: 
106:         if ($workflows->next() === false) {
107:             $this->lasterror = i18n("Workflow doesn't exist", "workflow");
108:             return false;
109:         }
110: 
111:         $newitem = $this->createNewItem();
112:         if (!$newitem->setWorkflow($idworkflow)) {
113:             $this->lasterror = $newitem->lasterror;
114:             $workflows->delete($newitem->getField("idallocation"));
115:             return false;
116:         }
117: 
118:         if (!$newitem->setCatLang($idcatlang)) {
119:             $this->lasterror = $newitem->lasterror;
120:             $workflows->delete($newitem->getField("idallocation"));
121:             return false;
122:         }
123: 
124:         $newitem->store();
125: 
126:         return ($newitem);
127:     }
128: 
129: }
130: 
131: /**
132:  * Class WorkflowAllocation
133:  * Class for a single workflow allocation item
134:  *
135:  * @package Plugin
136:  * @subpackage Workflow
137:  * @author Timo A. Hummel <Timo.Hummel@4fb.de>
138:  * @version 0.1
139:  * @copyright four for business 2003
140:  */
141: class WorkflowAllocation extends Item {
142: 
143:     /**
144:      * Constructor Function
145:      */
146:     public function __construct() {
147:         global $cfg;
148: 
149:         parent::__construct($cfg["tab"]["workflow_allocation"], "idallocation");
150:     }
151: 
152:     /**
153:      * Overridden setField function.
154:      * Users should only use setWorkflow.
155:      *
156:      * @param string $field Void field since we override the usual setField
157:      *                      function
158:      * @param string $value Void field since we override the usual setField
159:      *                      function
160:      * @param bool   $safe
161:      *
162:      * @throws cBadMethodCallException if this function is called
163:      */
164:     public function setField($field, $value, $safe = true) {
165:         throw new cBadMethodCallException("Don't use setField for WorkflowAllocation items! Use setWorkflow instead!");
166:     }
167: 
168:     /**
169:      * setWorkflow sets the workflow for the current item.
170:      *
171:      * @param int $idworkflow Workflow-ID to set the item to
172:      *
173:      * @return bool
174:      * @throws cDbException
175:      * @throws cException
176:      * @throws cInvalidArgumentException
177:      */
178:     public function setWorkflow($idworkflow) {
179:         $workflows = new Workflows();
180: 
181:         $workflows->select("idworkflow = '$idworkflow'");
182: 
183:         if ($workflows->next() === false) {
184:             $this->lasterror = i18n("Workflow doesn't exist", "workflow");
185:             return false;
186:         }
187: 
188:         parent::setField("idworkflow", $idworkflow);
189:         $this->store();
190:         return true;
191:     }
192: 
193:     /**
194:      * setCatLang sets the idcatlang for the current item.
195:      * Should
196:      * only be called by the create function.
197:      *
198:      * @param int $idcatlang idcatlang to set
199:      *
200:      * @return bool
201:      * @throws cDbException
202:      * @throws cException
203:      * @throws cInvalidArgumentException
204:      */
205:     public function setCatLang($idcatlang) {
206:         global $cfg;
207: 
208:         $allocations = new WorkflowAllocations();
209: 
210:         $allocations->select("idcatlang = '$idcatlang'");
211: 
212:         if ($allocations->next() !== false) {
213:             $this->lasterror = i18n("Category already has a workflow assigned", "workflow");
214:             return false;
215:         }
216: 
217:         $db = cRegistry::getDb();
218:         $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcatlang = '" . cSecurity::toInteger($idcatlang) . "'";
219:         $db->query($sql);
220: 
221:         if (!$db->nextRecord()) {
222:             $this->lasterror = i18n("Category doesn't exist, assignment failed", "workflow");
223:             return false;
224:         }
225: 
226:         parent::setField("idcatlang", $idcatlang);
227:         $this->store();
228:         return true;
229:     }
230: 
231: }
232: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0