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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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:  * @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:                 $starttime = $this->get("starttime");
133: 
134:                 $db = cRegistry::getDb();
135:                 $sql = "SELECT author, title, idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = " . (int) $idartlang;
136: 
137:                 $db->query($sql);
138: 
139:                 if ($db->nextRecord()) {
140:                     $idart = $db->f("idart");
141:                     $title = $db->f("title");
142:                     $author = $db->f("author");
143:                 }
144: 
145:                 // Extract category
146:                 $sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = " . (int) $idart;
147:                 $db->query($sql);
148: 
149:                 if ($db->nextRecord()) {
150:                     $idcat = $db->f("idcat");
151:                 }
152: 
153:                 $sql = "SELECT name FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat = " . (int) $idcat;
154:                 $db->query($sql);
155: 
156:                 if ($db->nextRecord()) {
157:                     $catname = $db->f("name");
158:                 }
159: 
160:                 // WTF ist this???
161:                 $starttime = strtotime($starttime);
162: 
163:                 switch ($timeunit) {
164:                     case "Seconds":
165:                         $maxtime = $starttime + $timelimit;
166:                         break;
167:                     case "Minutes":
168:                         $maxtime = $starttime + ($timelimit * 60);
169:                         break;
170:                     case "Hours":
171:                         $maxtime = $starttime + ($timelimit * 3600);
172:                         break;
173:                     case "Days":
174:                         $maxtime = $starttime + ($timelimit * 86400);
175:                         break;
176:                     case "Weeks":
177:                         $maxtime = $starttime + ($timelimit * 604800);
178:                         break;
179:                     case "Months":
180:                         $maxtime = $starttime + ($timelimit * 2678400);
181:                         break;
182:                     case "Years":
183:                         $maxtime = $starttime + ($timelimit * 31536000);
184:                         break;
185:                     default:
186:                         $maxtime = $starttime + $timelimit;
187:                 }
188: 
189:                 if ($email == 1) {
190:                     $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";
191: 
192:                     $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));
193:                     $user = new cApiUser();
194: 
195:                     if (isGroup($usersequence->get("iduser"))) {
196:                         $sql = "SELECT idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
197:                                 group_id = '" . $db->escape($usersequence->get("iduser")) . "'";
198:                         $db->query($sql);
199: 
200:                         while ($db->nextRecord()) {
201:                             $user->loadByPrimaryKey($db->f("user_id"));
202:                             $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow notification')), $filledMail);
203:                         }
204:                     } else {
205:                         $user->loadByPrimaryKey($usersequence->get("iduser"));
206:                         $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow notification')), $filledMail);
207:                     }
208:                 } else {
209:                     $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";
210: 
211:                     $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));
212: 
213:                     $user = new cApiUser();
214: 
215:                     if (isGroup($usersequence->get("iduser"))) {
216: 
217:                         $sql = "SELECT idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
218:                                 group_id = '" . $db->escape($usersequence->get("iduser")) . "'";
219:                         $db->query($sql);
220: 
221:                         while ($db->nextRecord()) {
222:                             $user->loadByPrimaryKey($db->f("user_id"));
223:                             $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow escalation')), $filledMail);
224:                         }
225:                     } else {
226:                         $user->loadByPrimaryKey($usersequence->get("iduser"));
227:                         $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow escalation')), $filledMail);
228:                     }
229:                 }
230:             }
231:         }
232: 
233:         if (parent::store()) {
234:             $this->db->query("UPDATE " . $this->table . " SET `starttime`=NOW() WHERE `" . $this->getPrimaryKeyName() . "`='" . $this->get($this->getPrimaryKeyName()) . "'");
235:             return true;
236:         } else {
237:             return false;
238:         }
239:     }
240: 
241: }
242: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0