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