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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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 = " . cSecurity::toInteger($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 = $this->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:                 $starttime = $this->get("starttime");
149: 
150:                 $db = cRegistry::getDb();
151:                 $sql = "SELECT author, title, idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = " . (int) $idartlang;
152: 
153:                 $db->query($sql);
154: 
155:                 if ($db->nextRecord()) {
156:                     $idart = $db->f("idart");
157:                     $title = $db->f("title");
158:                     $author = $db->f("author");
159:                 }
160: 
161:                 // Extract category
162:                 $sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = " . (int) $idart;
163:                 $db->query($sql);
164: 
165:                 if ($db->nextRecord()) {
166:                     $idcat = $db->f("idcat");
167:                 }
168: 
169:                 $sql = "SELECT name FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat = " . (int) $idcat;
170:                 $db->query($sql);
171: 
172:                 if ($db->nextRecord()) {
173:                     $catname = $db->f("name");
174:                 }
175: 
176:                 // WTF ist this???
177:                 $starttime = strtotime($starttime);
178: 
179:                 switch ($timeunit) {
180:                     case "Seconds":
181:                         $maxtime = $starttime + $timelimit;
182:                         break;
183:                     case "Minutes":
184:                         $maxtime = $starttime + ($timelimit * 60);
185:                         break;
186:                     case "Hours":
187:                         $maxtime = $starttime + ($timelimit * 3600);
188:                         break;
189:                     case "Days":
190:                         $maxtime = $starttime + ($timelimit * 86400);
191:                         break;
192:                     case "Weeks":
193:                         $maxtime = $starttime + ($timelimit * 604800);
194:                         break;
195:                     case "Months":
196:                         $maxtime = $starttime + ($timelimit * 2678400);
197:                         break;
198:                     case "Years":
199:                         $maxtime = $starttime + ($timelimit * 31536000);
200:                         break;
201:                     default:
202:                         $maxtime = $starttime + $timelimit;
203:                 }
204: 
205:                 if ($email == 1) {
206:                     $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";
207: 
208:                     $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));
209:                     $user = new cApiUser();
210: 
211:                     if (isGroup($usersequence->get("iduser"))) {
212:                         $sql = "SELECT idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
213:                                 group_id = '" . $db->escape($usersequence->get("iduser")) . "'";
214:                         $db->query($sql);
215: 
216:                         while ($db->nextRecord()) {
217:                             $user->loadByPrimaryKey($db->f("user_id"));
218:                             $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow notification')), $filledMail);
219:                         }
220:                     } else {
221:                         $user->loadByPrimaryKey($usersequence->get("iduser"));
222:                         $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow notification')), $filledMail);
223:                     }
224:                 } else {
225:                     $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";
226: 
227:                     $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));
228: 
229:                     $user = new cApiUser();
230: 
231:                     if (isGroup($usersequence->get("iduser"))) {
232: 
233:                         $sql = "SELECT idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
234:                                 group_id = '" . $db->escape($usersequence->get("iduser")) . "'";
235:                         $db->query($sql);
236: 
237:                         while ($db->nextRecord()) {
238:                             $user->loadByPrimaryKey($db->f("user_id"));
239:                             $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow escalation')), $filledMail);
240:                         }
241:                     } else {
242:                         $user->loadByPrimaryKey($usersequence->get("iduser"));
243:                         $mailer->sendMail(NULL, $user->getField("email"), stripslashes(i18n('Workflow escalation')), $filledMail);
244:                     }
245:                 }
246:             }
247:         }
248: 
249:         if (parent::store()) {
250:             $this->db->query("UPDATE " . $this->table . " SET `starttime`=NOW() WHERE `" . $this->primaryKey . "`='" . $this->get($this->primaryKey) . "'");
251:             return true;
252:         } else {
253:             return false;
254:         }
255:     }
256: 
257: }
258: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen