Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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

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