2019-11-04 15:22:11 +00:00
|
|
|
<?php
|
2020-08-20 16:30:16 +00:00
|
|
|
|
2019-11-04 15:22:11 +00:00
|
|
|
/**
|
|
|
|
* Project:
|
|
|
|
* Contenido Content Management System
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Workflow allocation class
|
|
|
|
*
|
|
|
|
* Requirements:
|
|
|
|
* @con_php_req 5.0
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @package Contenido Backend classes
|
|
|
|
* @version 1.4
|
|
|
|
* @author Timo Hummel
|
|
|
|
* @copyright four for business AG <www.4fb.de>
|
|
|
|
* @license http://www.contenido.org/license/LIZENZ.txt
|
|
|
|
* @link http://www.4fb.de
|
|
|
|
* @link http://www.contenido.org
|
|
|
|
*
|
|
|
|
* {@internal
|
|
|
|
* created 2003-07-18
|
|
|
|
* modified : 2008-06-25 - use php mailer class instead of mail()
|
|
|
|
*
|
|
|
|
* $Id: class.workflowartallocation.php 128 2019-07-03 11:58:28Z oldperl $:
|
|
|
|
* }}
|
|
|
|
*
|
|
|
|
*/
|
2020-08-20 16:30:16 +00:00
|
|
|
if (!defined('CON_FRAMEWORK')) {
|
|
|
|
die('Illegal call');
|
2019-11-04 15:22:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class WorkflowArtAllocations
|
|
|
|
* Class for workflow art allocation management
|
|
|
|
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
|
|
|
* @version 0.2
|
|
|
|
* @copyright four for business 2003
|
|
|
|
*/
|
|
|
|
class WorkflowArtAllocations extends ItemCollection {
|
2020-08-20 16:30:16 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-04 15:22:11 +00:00
|
|
|
* Constructor Function
|
|
|
|
* @param string $table The table to use as information source
|
|
|
|
*/
|
2020-08-20 16:30:16 +00:00
|
|
|
function __construct() {
|
|
|
|
global $cfg;
|
|
|
|
parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
|
2019-11-04 15:22:11 +00:00
|
|
|
$this->_setItemClass("WorkflowArtAllocation");
|
2020-08-20 16:30:16 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 15:22:11 +00:00
|
|
|
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
2020-08-20 16:30:16 +00:00
|
|
|
function WorkflowArtAllocations() {
|
2019-11-04 15:22:11 +00:00
|
|
|
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
|
|
|
$this->__construct();
|
|
|
|
}
|
|
|
|
|
2020-08-20 16:30:16 +00:00
|
|
|
function create($idartlang) {
|
|
|
|
global $cfg;
|
|
|
|
|
|
|
|
$sql = "SELECT idartlang FROM " . $cfg["tab"]["art_lang"] .
|
|
|
|
" WHERE idartlang = '" . Contenido_Security::escapeDB($idartlang, $this->db) . "'";
|
|
|
|
|
|
|
|
$this->db->query($sql);
|
|
|
|
if (!$this->db->next_record()) {
|
|
|
|
$this->lasterror = i18n("Article doesn't exist", "workflow");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->select("idartlang = '$idartlang'");
|
|
|
|
|
|
|
|
if ($this->next() !== false) {
|
|
|
|
$this->lasterror = i18n("Article is already assigned to a usersequence step.", "workflow");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$newitem = parent::createNewItem();
|
|
|
|
$newitem->setField("idartlang", $idartlang);
|
|
|
|
$newitem->store();
|
|
|
|
|
|
|
|
return ($newitem);
|
|
|
|
}
|
|
|
|
|
2019-11-04 15:22:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class WorkflowArtAllocation
|
|
|
|
* Class for a single workflow allocation item
|
|
|
|
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
|
|
|
* @version 0.1
|
|
|
|
* @copyright four for business 2003
|
|
|
|
*/
|
|
|
|
class WorkflowArtAllocation extends Item {
|
2020-08-20 16:30:16 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-04 15:22:11 +00:00
|
|
|
* Constructor Function
|
|
|
|
* @param string $table The table to use as information source
|
|
|
|
*/
|
2020-08-20 16:30:16 +00:00
|
|
|
function __construct() {
|
|
|
|
global $cfg;
|
|
|
|
|
|
|
|
parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
|
|
|
|
}
|
2019-11-04 15:22:11 +00:00
|
|
|
|
|
|
|
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
2020-08-20 16:30:16 +00:00
|
|
|
function WorkflowArtAllocation() {
|
2019-11-04 15:22:11 +00:00
|
|
|
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
|
|
|
$this->__construct();
|
|
|
|
}
|
|
|
|
|
2020-08-20 16:30:16 +00:00
|
|
|
function getWorkflowItem() {
|
|
|
|
$userSequence = new WorkflowUserSequence;
|
|
|
|
$userSequence->loadByPrimaryKey($this->values["idusersequence"]);
|
|
|
|
|
|
|
|
return ($userSequence->getWorkflowItem());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-11-04 15:22:11 +00:00
|
|
|
* Returns the current item position
|
|
|
|
* @param string $field Void field since we override the usual setField function
|
|
|
|
* @param string $value Void field since we override the usual setField function
|
2020-08-20 16:30:16 +00:00
|
|
|
*/
|
|
|
|
function currentItemPosition() {
|
|
|
|
$idworkflowitem = $this->get("idworkflowitem");
|
|
|
|
|
|
|
|
$workflowItems = new WorkflowItems;
|
|
|
|
$workflowItems->select("idworkflowitem = '$idworkflowitem'");
|
|
|
|
|
|
|
|
if ($item = $workflowItems->next()) {
|
|
|
|
return ($item->get("position"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-11-04 15:22:11 +00:00
|
|
|
* Returns the current user position
|
|
|
|
* @param string $field Void field since we override the usual setField function
|
|
|
|
* @param string $value Void field since we override the usual setField function
|
2020-08-20 16:30:16 +00:00
|
|
|
*/
|
|
|
|
function currentUserPosition() {
|
|
|
|
return ($this->get("position"));
|
|
|
|
}
|
2019-11-04 15:22:11 +00:00
|
|
|
|
2020-08-20 16:30:16 +00:00
|
|
|
/**
|
2019-11-04 15:22:11 +00:00
|
|
|
* Overriden store function to send mails
|
|
|
|
* @param none
|
2020-08-20 16:30:16 +00:00
|
|
|
*/
|
|
|
|
function store() {
|
|
|
|
global $cfg;
|
|
|
|
|
|
|
|
$sMailhost = getSystemProperty('system', 'mail_host');
|
2019-11-04 15:22:11 +00:00
|
|
|
if ($sMailhost == '') {
|
|
|
|
$sMailhost = 'localhost';
|
2020-08-20 16:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//modified : 2008-06-25 - use php mailer class instead of mail()
|
|
|
|
$oMail = new PHPMailer();
|
2019-11-04 15:22:11 +00:00
|
|
|
$oMail->Host = $sMailhost;
|
|
|
|
$oMail->IsHTML(0);
|
2020-08-20 16:30:16 +00:00
|
|
|
$oMail->WordWrap = 1000;
|
|
|
|
$oMail->IsMail();
|
|
|
|
|
|
|
|
if (array_key_exists("idusersequence", $this->modifiedValues)) {
|
|
|
|
$usersequence = new WorkflowUserSequence;
|
|
|
|
$usersequence->loadByPrimaryKey($this->values["idusersequence"]);
|
|
|
|
|
|
|
|
$email = $usersequence->get("emailnoti");
|
|
|
|
$escal = $usersequence->get("escalationnoti");
|
|
|
|
|
|
|
|
if ($email == 1 || $escal == 1) {
|
|
|
|
/* Grab the required informations */
|
|
|
|
$curEditor = getGroupOrUserName($usersequence->get("iduser"));
|
|
|
|
$idartlang = $this->get("idartlang");
|
|
|
|
$timeunit = $usersequence->get("timeunit");
|
|
|
|
$timelimit = $usersequence->get("timelimit");
|
|
|
|
|
|
|
|
$db = new DB_ConLite;
|
|
|
|
$sql = "SELECT author, title, idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = '" . Contenido_Security::escapeDB($idartlang, $db) . "'";
|
|
|
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
if ($db->next_record()) {
|
|
|
|
$idart = $db->f("idart");
|
|
|
|
$title = $db->f("title");
|
|
|
|
$author = $db->f("author");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract category */
|
|
|
|
$sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = '" . Contenido_Security::escapeDB($idart, $db) . "'";
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
if ($db->next_record()) {
|
|
|
|
$idcat = $db->f("idcat");
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "SELECT name FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat = '" . Contenido_Security::escapeDB($idcat, $db) . "'";
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
if ($db->next_record()) {
|
|
|
|
$catname = $db->f("name");
|
|
|
|
}
|
|
|
|
|
|
|
|
$starttime = $this->get("starttime");
|
|
|
|
|
|
|
|
|
|
|
|
$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));
|
|
|
|
|
|
|
|
switch ($timeunit) {
|
|
|
|
case "Seconds":
|
|
|
|
$maxtime = $starttime + $timelimit;
|
|
|
|
break;
|
|
|
|
case "Minutes":
|
|
|
|
$maxtime = $starttime + ($timelimit * 60);
|
|
|
|
break;
|
|
|
|
case "Hours":
|
|
|
|
$maxtime = $starttime + ($timelimit * 3600);
|
|
|
|
break;
|
|
|
|
case "Days":
|
|
|
|
$maxtime = $starttime + ($timelimit * 86400);
|
|
|
|
break;
|
|
|
|
case "Weeks":
|
|
|
|
$maxtime = $starttime + ($timelimit * 604800);
|
|
|
|
break;
|
|
|
|
case "Months":
|
|
|
|
$maxtime = $starttime + ($timelimit * 2678400);
|
|
|
|
break;
|
|
|
|
case "Years":
|
|
|
|
$maxtime = $starttime + ($timelimit * 31536000);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$maxtime = $starttime + $timelimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($email == 1) {
|
|
|
|
$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";
|
|
|
|
|
|
|
|
$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));
|
|
|
|
$user = new User;
|
|
|
|
|
|
|
|
if (isGroup($usersequence->get("iduser"))) {
|
|
|
|
$sql = "select idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
|
|
|
|
group_id = '" . Contenido_Security::escapeDB($usersequence->get("iduser"), $db) . "'";
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
while ($db->next_record()) {
|
|
|
|
$user->loadUserByUserID($db->f("user_id"));
|
|
|
|
//modified : 2008-06-25 - use php mailer class instead of mail()
|
|
|
|
$oMail->AddAddress($user->getField("email"), "");
|
|
|
|
$oMail->Subject = stripslashes(i18n('Workflow notification'));
|
|
|
|
$oMail->Body = $filledMail;
|
|
|
|
$oMail->Send();
|
|
|
|
}
|
2019-11-04 15:22:11 +00:00
|
|
|
} else {
|
2020-08-20 16:30:16 +00:00
|
|
|
$user->loadUserByUserID($usersequence->get("iduser"));
|
|
|
|
//modified : 2008-06-25 - use php mailer class instead of mail()
|
|
|
|
$oMail->AddAddress($user->getField("email"), "");
|
|
|
|
$oMail->Subject = stripslashes(i18n('Workflow notification'));
|
|
|
|
$oMail->Body = $filledMail;
|
|
|
|
$oMail->Send();
|
2019-11-04 15:22:11 +00:00
|
|
|
}
|
2020-08-20 16:30:16 +00:00
|
|
|
} else {
|
|
|
|
$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";
|
|
|
|
|
|
|
|
$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));
|
|
|
|
|
|
|
|
$user = new User;
|
|
|
|
|
|
|
|
if (isGroup($usersequence->get("iduser"))) {
|
|
|
|
|
|
|
|
$sql = "select idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE
|
|
|
|
group_id = '" . Contenido_Security::escapeDB($usersequence->get("iduser"), $db) . "'";
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
while ($db->next_record()) {
|
|
|
|
$user->loadUserByUserID($db->f("user_id"));
|
|
|
|
echo "mail to " . $user->getField("email") . "<br>";
|
|
|
|
//modified : 2008-06-25 - use php mailer class instead of mail()
|
|
|
|
$oMail->AddAddress($user->getField("email"), "");
|
|
|
|
$oMail->Subject = stripslashes(i18n('Workflow escalation'));
|
|
|
|
$oMail->Body = $filledMail;
|
|
|
|
$oMail->Send();
|
|
|
|
}
|
2019-11-04 15:22:11 +00:00
|
|
|
} else {
|
2020-08-20 16:30:16 +00:00
|
|
|
$user->loadUserByUserID($usersequence->get("iduser"));
|
|
|
|
echo "mail to " . $user->getField("email") . "<br>";
|
|
|
|
//modified : 2008-06-25 - use php mailer class instead of mail()
|
|
|
|
$oMail->AddAddress($user->getField("email"), "");
|
|
|
|
$oMail->Subject = stripslashes(i18n('Workflow escalation'));
|
|
|
|
$oMail->Body = $filledMail;
|
|
|
|
$oMail->Send();
|
2019-11-04 15:22:11 +00:00
|
|
|
}
|
2020-08-20 16:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return parent::store();
|
|
|
|
}
|
|
|
|
|
2019-11-04 15:22:11 +00:00
|
|
|
}
|
2020-08-20 16:30:16 +00:00
|
|
|
|
2019-11-04 15:22:11 +00:00
|
|
|
?>
|