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