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 art 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 art allocation management.
 18:  *
 19:  * @package Plugin
 20:  * @subpackage Workflow
 21:  * @method WorkflowArtAllocation createNewItem
 22:  * @method WorkflowArtAllocation next
 23:  */
 24: class WorkflowArtAllocations extends ItemCollection {
 25:     /**
 26:      * Constructor Function
 27:      *
 28:      * @throws cInvalidArgumentException
 29:      */
 30:     public function __construct() {
 31:         global $cfg;
 32:         parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
 33:         $this->_setItemClass("WorkflowArtAllocation");
 34:     }
 35: 
 36:     /**
 37:      * @param $idartlang
 38:      *
 39:      * @return bool|Item
 40:      * @throws cDbException
 41:      * @throws cException
 42:      * @throws cInvalidArgumentException
 43:      */
 44:     public function create($idartlang) {
 45:         global $cfg;
 46: 
 47:         $sql = "SELECT idartlang FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = " . cSecurity::toInteger($idartlang);
 48: 
 49:         $this->db->query($sql);
 50:         if (!$this->db->nextRecord()) {
 51:             $this->lasterror = i18n("Article doesn't exist", "workflow");
 52:             return false;
 53:         }
 54: 
 55:         $this->select("idartlang = '$idartlang'");
 56: 
 57:         if ($this->next() !== false) {
 58:             $this->lasterror = i18n("Article is already assigned to a usersequence step.", "workflow");
 59:             return false;
 60:         }
 61: 
 62:         $newitem = $this->createNewItem();
 63:         $newitem->setField("idartlang", $idartlang);
 64:         $newitem->store();
 65: 
 66:         return ($newitem);
 67:     }
 68: 
 69: }
 70: 
 71: /**
 72:  * Class WorkflowArtAllocation
 73:  * Class for a single workflow allocation item
 74:  *
 75:  * @package Plugin
 76:  * @subpackage Workflow
 77:  * @author Timo A. Hummel <Timo.Hummel@4fb.de>
 78:  * @version 0.1
 79:  * @copyright four for business 2003
 80:  */
 81: class WorkflowArtAllocation extends Item {
 82: 
 83:     /**
 84:      * Constructor Function
 85:      */
 86:     public function __construct() {
 87:         global $cfg;
 88: 
 89:         parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
 90:     }
 91: 
 92:     /**
 93:      * @return bool|WorkflowItem
 94:      * @throws cDbException
 95:      * @throws cException
 96:      */
 97:     public function getWorkflowItem() {
 98:         $userSequence = new WorkflowUserSequence();
 99:         $userSequence->loadByPrimaryKey($this->values["idusersequence"]);
100: 
101:         return ($userSequence->getWorkflowItem());
102:     }
103: 
104:     /**
105:      * Returns the current item position
106:      *
107:      * @throws cDbException
108:      * @throws cException
109:      */
110:     public function currentItemPosition() {
111:         $idworkflowitem = $this->get("idworkflowitem");
112: 
113:         $workflowItems = new WorkflowItems();
114:         $workflowItems->select("idworkflowitem = '$idworkflowitem'");
115: 
116:         if (($item = $workflowItems->next()) !== false) {
117:             return ($item->get("position"));
118:         }
119:     }
120: 
121:     /**
122:      * Returns the current user position
123:      */
124:     public function currentUserPosition() {
125:         return ($this->get("position"));
126:     }
127: 
128:     /**
129:      * Overriden store function to send mails
130:      *
131:      * @return bool
132:      * @throws cDbException
133:      * @throws cException
134:      * @throws cInvalidArgumentException
135:      */
136:     public function store() {
137:         global $cfg;
138: 
139:         $mailer = new cMailer();
140: 
141:         if (array_key_exists("idusersequence", $this->modifiedValues)) {
142:             $usersequence = new WorkflowUserSequence();
143:             $usersequence->loadByPrimaryKey($this->values["idusersequence"]);
144: 
145:             $email = $usersequence->get("emailnoti");
146:             $escal = $usersequence->get("escalationnoti");
147: 
148:             if ($email == 1 || $escal == 1) {
149:                 // Grab the required informations
150:                 $curEditor = getGroupOrUserName($usersequence->get("iduser"));
151:                 $idartlang = $this->get("idartlang");
152:                 $timeunit = $usersequence->get("timeunit");
153:                 $timelimit = $usersequence->get("timelimit");
154: 
155:                 $db = cRegistry::getDb();
156:                 $sql = "SELECT author, title, idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = " . (int) $idartlang;
157: 
158:                 $db->query($sql);
159: 
160:                 if ($db->nextRecord()) {
161:                     $idart = $db->f("idart");
162:                     $title = $db->f("title");
163:                     $author = $db->f("author");
164:                 }
165: 
166:                 // Extract category
167:                 $sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = " . (int) $idart;
168:                 $db->query($sql);
169: 
170:                 if ($db->nextRecord()) {
171:                     $idcat = $db->f("idcat");
172:                 }
173: 
174:                 $sql = "SELECT name FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat = " . (int) $idcat;
175:                 $db->query($sql);
176: 
177:                 if ($db->nextRecord()) {
178:                     $catname = $db->f("name");
179:                 }
180: 
181:                 $starttime = time();
182: 
183:                 switch ($timeunit) {
184:                     case "Seconds":
185:                         $maxtime = $starttime + $timelimit;
186:                         break;
187:                     case "Minutes":
188:                         $maxtime = $starttime + ($timelimit * 60);
189:                         break;
190:                     case "Hours":
191:                         $maxtime = $starttime + ($timelimit * 3600);
192:                         break;
193:                     case "Days":
194:                         $maxtime = $starttime + ($timelimit * 86400);
195:                         break;
196:                     case "Weeks":
197:                         $maxtime = $starttime + ($timelimit * 604800);
198:                         break;
199:                     case "Months":
200:                         $maxtime = $starttime + ($timelimit * 2678400);
201:                         break;
202:                     case "Years":
203:                         $maxtime = $starttime + ($timelimit * 31536000);
204:                         break;
205:                     default:
206:                         $maxtime = $starttime + $timelimit;
207:                 }
208: 
209:                 if ($email == 1) {
210:                     $email = "Hello %s,\n\n" . "you are assigned as the next editor for the Article %s.\n\n" . "More informations:\n" . "Article: %s\n" . "Category: %s\n" . "Editor: %s\n" . "Author: %s\n" . "Editable from: %s\n" . "Editable to: %s\n";
211: 
212:                     $filledMail = sprintf($email, $curEditor, $title, $title, $catname, $curEditor, $author, date("Y-m-d H:i:s", $starttime), date("Y-m-d H:i:s", $maxtime));
213:                     $user = new cApiUser();
214: 
215:                     if (isGroup($usersequence->get("iduser"))) {
216:                         $sql = "SELECT idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
217:                                 group_id = '" . $db->escape($usersequence->get("iduser")) . "'";
218:                         $db->query($sql);
219: 
220:                         while ($db->nextRecord()) {
221:                             $user->loadByPrimaryKey($db->f("user_id"));
222:                             $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow notification')), $filledMail);
223:                         }
224:                     } else {
225:                         $user->loadByPrimaryKey($usersequence->get("iduser"));
226:                         $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow notification')), $filledMail);
227:                     }
228:                 } else {
229:                     $email = "Hello %s,\n\n" . "you are assigned as the escalator for the Article %s.\n\n" . "More informations:\n" . "Article: %s\n" . "Category: %s\n" . "Editor: %s\n" . "Author: %s\n" . "Editable from: %s\n" . "Editable to: %s\n";
230: 
231:                     $filledMail = sprintf($email, $curEditor, $title, $title, $catname, $curEditor, $author, date("Y-m-d H:i:s", $starttime), date("Y-m-d H:i:s", $maxtime));
232: 
233:                     $user = new cApiUser();
234: 
235:                     if (isGroup($usersequence->get("iduser"))) {
236: 
237:                         $sql = "SELECT idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
238:                                 group_id = '" . $db->escape($usersequence->get("iduser")) . "'";
239:                         $db->query($sql);
240: 
241:                         while ($db->nextRecord()) {
242:                             $user->loadByPrimaryKey($db->f("user_id"));
243:                             $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow escalation')), $filledMail);
244:                         }
245:                     } else {
246:                         $user->loadByPrimaryKey($usersequence->get("iduser"));
247:                         $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow escalation')), $filledMail);
248:                     }
249:                 }
250:             }
251:         }
252: 
253:         if (parent::store()) {
254:             $this->db->query("UPDATE " . $this->table . " SET `starttime`=NOW() WHERE `" . $this->getPrimaryKeyName() . "`='" . $this->get($this->getPrimaryKeyName()) . "'");
255:             return true;
256:         } else {
257:             return false;
258:         }
259:     }
260: 
261: }
262: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0