add files
Dieser Commit ist enthalten in:
Ursprung
935ba6e5d9
Commit
b75948a709
37 geänderte Dateien mit 4890 neuen und 0 gelöschten Zeilen
180
classes/class.workflow.php
Normale Datei
180
classes/class.workflow.php
Normale Datei
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Workflow management class
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.6
|
||||
* @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
|
||||
*
|
||||
* $Id: class.workflow.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
$cfg["tab"]["workflow"] = $cfg['sql']['sqlprefix'] . "_piwf_workflow";
|
||||
$cfg["tab"]["workflow_allocation"] = $cfg['sql']['sqlprefix'] . "_piwf_allocation";
|
||||
$cfg["tab"]["workflow_art_allocation"] = $cfg['sql']['sqlprefix'] . "_piwf_art_allocation";
|
||||
$cfg["tab"]["workflow_items"] = $cfg['sql']['sqlprefix'] . "_piwf_items";
|
||||
$cfg["tab"]["workflow_user_sequences"] = $cfg['sql']['sqlprefix'] . "_piwf_user_sequences";
|
||||
$cfg["tab"]["workflow_actions"] = $cfg['sql']['sqlprefix'] . "_piwf_actions";
|
||||
|
||||
plugin_include('workflow', 'classes/class.workflowactions.php');
|
||||
plugin_include('workflow', 'classes/class.workflowallocation.php');
|
||||
plugin_include('workflow', 'classes/class.workflowartallocation.php');
|
||||
plugin_include('workflow', 'classes/class.workflowitems.php');
|
||||
plugin_include('workflow', 'classes/class.workflowusersequence.php');
|
||||
|
||||
/**
|
||||
* Class Workflows
|
||||
* Class for workflow management
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.2
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class Workflows extends ItemCollection {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param none
|
||||
*/
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow"], "idworkflow");
|
||||
$this->_setItemClass("Workflow");
|
||||
}
|
||||
|
||||
function create() {
|
||||
global $auth, $client, $lang;
|
||||
$newitem = parent::createNewItem();
|
||||
$newitem->setField("created", date("Y-m-d H-i-s"));
|
||||
$newitem->setField("idauthor", $auth->auth["uid"]);
|
||||
$newitem->setField("idclient", $client);
|
||||
$newitem->setField("idlang", $lang);
|
||||
$newitem->store();
|
||||
|
||||
return ($newitem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all corresponding informations to this workflow and delegate call to parent
|
||||
* @param integer $idWorkflow - id of workflow to delete
|
||||
*/
|
||||
function delete($idWorkflow) {
|
||||
global $cfg;
|
||||
$oDb = new DB_ConLite();
|
||||
|
||||
$aItemIdsDelete = array();
|
||||
$sSql = 'SELECT idworkflowitem FROM ' . $cfg["tab"]["workflow_items"] . ' WHERE idworkflow = ' . Contenido_Security::toInteger($idWorkflow) . ';';
|
||||
$oDb->query($sSql);
|
||||
while ($oDb->next_record()) {
|
||||
array_push($aItemIdsDelete, Contenido_Security::escapeDB($oDb->f('idworkflowitem'), $oDb));
|
||||
}
|
||||
|
||||
$aUserSequencesDelete = array();
|
||||
$sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem in (' . implode(',', $aItemIdsDelete) . ');';
|
||||
$oDb->query($sSql);
|
||||
while ($oDb->next_record()) {
|
||||
array_push($aUserSequencesDelete, Contenido_Security::escapeDB($oDb->f('idusersequence'), $oDb));
|
||||
}
|
||||
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem in (' . implode(',', $aItemIdsDelete) . ');';
|
||||
$oDb->query($sSql);
|
||||
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_actions"] . ' WHERE idworkflowitem in (' . implode(',', $aItemIdsDelete) . ');';
|
||||
$oDb->query($sSql);
|
||||
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_items"] . ' WHERE idworkflow = ' . Contenido_Security::toInteger($idWorkflow) . ';';
|
||||
$oDb->query($sSql);
|
||||
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_allocation"] . ' WHERE idworkflow = ' . Contenido_Security::toInteger($idWorkflow) . ';';
|
||||
$oDb->query($sSql);
|
||||
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequencesDelete) . ');';
|
||||
$oDb->query($sSql);
|
||||
|
||||
parent::delete($idWorkflow);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Workflow
|
||||
* Class for a single workflow item
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.1
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class Workflow extends Item {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @global array $cfg
|
||||
*/
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow"], "idworkflow");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
function getWorkflowForCat($idcat) {
|
||||
global $lang, $cfg;
|
||||
|
||||
$idcatlang = getCatLang($idcat, $lang);
|
||||
$workflows = new WorkflowAllocations;
|
||||
$workflows->select("idcatlang = '$idcatlang'");
|
||||
if ($obj = $workflows->next()) {
|
||||
/* Sanity: Check if the workflow still exists */
|
||||
$workflow = new Workflow;
|
||||
|
||||
$res = $workflow->loadByPrimaryKey($obj->get("idworkflow"));
|
||||
|
||||
if ($res == false) {
|
||||
return 0;
|
||||
} else {
|
||||
return $obj->get("idworkflow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCatLang($idcat, $idlang) {
|
||||
global $lang, $cfg;
|
||||
$db = new DB_ConLite;
|
||||
|
||||
/* Get the idcatlang */
|
||||
$sql = "SELECT idcatlang FROM "
|
||||
. $cfg["tab"]["cat_lang"] .
|
||||
" WHERE idlang = '" . Contenido_Security::escapeDB($idlang, $db) . "' AND
|
||||
idcat = '" . Contenido_Security::escapeDB($idcat, $db) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
|
||||
if ($db->next_record()) {
|
||||
return ($db->f("idcatlang"));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
132
classes/class.workflowactions.php
Normale Datei
132
classes/class.workflowactions.php
Normale Datei
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Management of per-workflowitem actions
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.3
|
||||
* @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
|
||||
*
|
||||
* $Id: class.workflowactions.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowActions
|
||||
* Class for workflow action collections
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.2
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowActions extends ItemCollection {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_actions"], "idworkflowaction");
|
||||
$this->_setItemClass("WorkflowAction");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $idworkflowitem
|
||||
* @param type $action
|
||||
* @return boolean
|
||||
*/
|
||||
function get($idworkflowitem, $action)
|
||||
{
|
||||
$this->select("idworkflowitem = '".Contenido_Security::escapeDB($idworkflowitem, NULL)."' AND action = '".Contenido_Security::escapeDB($action, NULL)."'");
|
||||
if ($this->next())
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getAvailableWorkflowActions ()
|
||||
{
|
||||
$availableWorkflowActions = array (
|
||||
"publish" => i18n("Publish article", "workflow"),
|
||||
"lock" => i18n("Lock article", "workflow"),
|
||||
"last" => i18n("Move back to last editor", "workflow"),
|
||||
"reject" => i18n("Reject article", "workflow"),
|
||||
"articleedit" => i18n("Edit article content", "workflow"),
|
||||
"propertyedit" => i18n("Edit article properties", "workflow"),
|
||||
"templateedit" => i18n("Edit template", "workflow"),
|
||||
"revise" => i18n("Revise article", "workflow"));
|
||||
|
||||
return($availableWorkflowActions);
|
||||
}
|
||||
|
||||
function set ($idworkflowitem, $action)
|
||||
{
|
||||
$this->select("idworkflowitem = '".Contenido_Security::escapeDB($idworkflowitem, NULL)."' AND action = '".Contenido_Security::escapeDB($action, NULL)."'");
|
||||
if (!$this->next())
|
||||
{
|
||||
$newitem = parent::createNewItem();
|
||||
$newitem->setField("idworkflowitem",$idworkflowitem);
|
||||
$newitem->setField("action",$action);
|
||||
$newitem->store();
|
||||
}
|
||||
}
|
||||
|
||||
function remove ($idworkflowitem, $action)
|
||||
{
|
||||
$this->select("idworkflowitem = '$idworkflowitem' AND action = '$action'");
|
||||
if ($item = $this->next())
|
||||
{
|
||||
$this->delete($item->getField("idworkflowaction"));
|
||||
}
|
||||
}
|
||||
|
||||
function select ($where = "", $group_by = "", $order_by = "", $limit = "")
|
||||
{
|
||||
global $client;
|
||||
|
||||
return parent::select($where, $group_by, $order_by, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowAction
|
||||
* Class for a single workflow action
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.1
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowAction extends Item {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @global type $cfg
|
||||
*/
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_actions"], "idworkflowaction");
|
||||
}
|
||||
}
|
||||
?>
|
||||
242
classes/class.workflowallocation.php
Normale Datei
242
classes/class.workflowallocation.php
Normale Datei
|
|
@ -0,0 +1,242 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Workflow allocation class
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.5
|
||||
* @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
|
||||
*
|
||||
* $Id: class.workflowallocation.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowAllocations
|
||||
* Class for workflow allocation management
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.2
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowAllocations extends ItemCollection {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_allocation"], "idallocation");
|
||||
$this->_setItemClass("WorkflowAllocation");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowAllocations()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function delete ($idallocation)
|
||||
{
|
||||
global $cfg, $lang;
|
||||
|
||||
$obj = new WorkflowAllocation;
|
||||
$obj->loadByPrimaryKey($idallocation);
|
||||
|
||||
$idcatlang = $obj->get("idcatlang");
|
||||
|
||||
$db = new DB_ConLite;
|
||||
$sql = "SELECT idcat FROM ".$cfg["tab"]["cat_lang"]." WHERE idcatlang = '".Contenido_Security::toInteger($idcatlang)."'";
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
$idcat = $db->f("idcat");
|
||||
|
||||
$sql = "SELECT idart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."'";
|
||||
$db->query($sql);
|
||||
|
||||
while ($db->next_record())
|
||||
{
|
||||
$idarts[] = $db->f("idart");
|
||||
}
|
||||
|
||||
$idartlangs = array();
|
||||
|
||||
if (is_array($idarts))
|
||||
{
|
||||
foreach ($idarts as $idart)
|
||||
{
|
||||
$sql = "SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' and idlang = '".Contenido_Security::toInteger($lang)."'";
|
||||
$db->query($sql);
|
||||
if ($db->next_record())
|
||||
{
|
||||
$idartlangs[] = $db->f("idartlang");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$workflowArtAllocation = new WorkflowArtAllocation;
|
||||
$workflowArtAllocations = new WorkflowArtAllocations;
|
||||
|
||||
foreach ($idartlangs as $idartlang)
|
||||
{
|
||||
$workflowArtAllocation->loadBy("idartlang", $idartlang);
|
||||
$workflowArtAllocations->delete($workflowArtAllocation->get("idartallocation"));
|
||||
}
|
||||
|
||||
parent::delete($idallocation);
|
||||
}
|
||||
|
||||
function create ($idworkflow, $idcatlang)
|
||||
{
|
||||
$this->select("idcatlang = '$idcatlang'");
|
||||
|
||||
if ($this->next() !== false)
|
||||
{
|
||||
$this->lasterror = i18n("Category already has a workflow assigned", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$workflows = new Workflows;
|
||||
$workflows->select("idworkflow = '$idworkflow'");
|
||||
|
||||
if ($workflows->next() === false)
|
||||
{
|
||||
$this->lasterror = i18n("Workflow doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
$newitem = parent::createNewItem();
|
||||
if (!$newitem->setWorkflow($idworkflow))
|
||||
{
|
||||
$this->lasterror = $newitem->lasterror;
|
||||
$workflows->delete($newitem->getField("idallocation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$newitem->setCatLang($idcatlang))
|
||||
{
|
||||
$this->lasterror = $newitem->lasterror;
|
||||
$workflows->delete($newitem->getField("idallocation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
$newitem->store();
|
||||
|
||||
return ($newitem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowAllocation
|
||||
* Class for a single workflow allocation item
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.1
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowAllocation extends Item {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
parent::__construct($cfg["tab"]["workflow_allocation"], "idallocation");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowAllocation()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden setField function. Users should only use setWorkflow.
|
||||
* @param string $field Void field since we override the usual setField function
|
||||
* @param string $value Void field since we override the usual setField function
|
||||
*/
|
||||
function setField($field, $value, $bSafe = true)
|
||||
{
|
||||
die("Don't use setField for WorkflowAllocation items! Use setWorkflow instead!");
|
||||
}
|
||||
|
||||
/**
|
||||
* setWorkflow sets the workflow for the current item.
|
||||
* @param int $idworkflow Workflow-ID to set the item to
|
||||
*/
|
||||
function setWorkflow ($idworkflow)
|
||||
{
|
||||
$workflows = new Workflows;
|
||||
|
||||
$workflows->select("idworkflow = '$idworkflow'");
|
||||
|
||||
if ($workflows->next() === false)
|
||||
{
|
||||
$this->lasterror = i18n("Workflow doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
parent::setField("idworkflow", $idworkflow);
|
||||
parent::store();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* setCatLang sets the idcatlang for the current item. Should
|
||||
* only be called by the create function.
|
||||
* @param int $idcatlang idcatlang to set.
|
||||
*/
|
||||
function setCatLang ($idcatlang)
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$allocations = new WorkflowAllocations;
|
||||
|
||||
$allocations->select("idcatlang = '$idcatlang'");
|
||||
|
||||
if ($allocations->next() !== false)
|
||||
{
|
||||
$this->lasterror = i18n("Category already has a workflow assigned", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$db = new DB_ConLite;
|
||||
$sql = "SELECT idcatlang FROM ".$cfg["tab"]["cat_lang"]." WHERE idcatlang = '".Contenido_Security::toInteger($idcatlang)."'";
|
||||
$db->query($sql);
|
||||
|
||||
if (!$db->next_record())
|
||||
{
|
||||
$this->lasterror = i18n("Category doesn't exist, assignment failed", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
parent::setField("idcatlang", $idcatlang);
|
||||
parent::store();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
361
classes/class.workflowartallocation.php
Normale Datei
361
classes/class.workflowartallocation.php
Normale Datei
|
|
@ -0,0 +1,361 @@
|
|||
<?php
|
||||
/**
|
||||
* 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 $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
|
||||
$this->_setItemClass("WorkflowArtAllocation");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowArtAllocations()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowArtAllocation()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function getWorkflowItem ()
|
||||
{
|
||||
$userSequence = new WorkflowUserSequence;
|
||||
$userSequence->loadByPrimaryKey($this->values["idusersequence"]);
|
||||
|
||||
return ($userSequence->getWorkflowItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function currentItemPosition()
|
||||
{
|
||||
$idworkflowitem = $this->get("idworkflowitem");
|
||||
|
||||
$workflowItems = new WorkflowItems;
|
||||
$workflowItems->select("idworkflowitem = '$idworkflowitem'");
|
||||
|
||||
if ($item = $workflowItems->next())
|
||||
{
|
||||
return ($item->get("position"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function currentUserPosition()
|
||||
{
|
||||
return ($this->get("position"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriden store function to send mails
|
||||
* @param none
|
||||
*/
|
||||
function store()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$sMailhost = getSystemProperty('system', 'mail_host');
|
||||
if ($sMailhost == '') {
|
||||
$sMailhost = 'localhost';
|
||||
}
|
||||
|
||||
//modified : 2008-06-25 - use php mailer class instead of mail()
|
||||
$oMail = new PHPMailer();
|
||||
$oMail->Host = $sMailhost;
|
||||
$oMail->IsHTML(0);
|
||||
$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();
|
||||
}
|
||||
|
||||
} else {
|
||||
$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();
|
||||
}
|
||||
|
||||
} 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();
|
||||
}
|
||||
|
||||
} else {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return parent::store();
|
||||
}
|
||||
}
|
||||
?>
|
||||
304
classes/class.workflowitems.php
Normale Datei
304
classes/class.workflowitems.php
Normale Datei
|
|
@ -0,0 +1,304 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Workflow items
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.3
|
||||
* @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
|
||||
*
|
||||
* $Id: class.workflowitems.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowItems
|
||||
* Class for workflow item management
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.2
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowItems extends ItemCollection {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_items"], "idworkflowitem");
|
||||
$this->_setItemClass("WorkflowItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowItems() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function delete($id) {
|
||||
global $cfg;
|
||||
$item = new WorkflowItem;
|
||||
$item->loadByPrimaryKey($id);
|
||||
$pos = $item->get("position");
|
||||
$idworkflow = $item->get("idworkflow");
|
||||
$oDb = new DB_ConLite();
|
||||
|
||||
$this->select("position > $pos AND idworkflow = '" . Contenido_Security::escapeDB($idworkflow, $oDb) . "'");
|
||||
while ($obj = $this->next()) {
|
||||
$obj->setPosition($obj->get("position") - 1);
|
||||
$obj->store();
|
||||
}
|
||||
|
||||
$aUserSequencesDelete = array();
|
||||
$sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem = ' . $id . ';';
|
||||
$oDb->query($sSql);
|
||||
while ($oDb->next_record()) {
|
||||
array_push($aUserSequencesDelete, Contenido_Security::escapeDB($oDb->f('idusersequence'), $oDb));
|
||||
}
|
||||
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_actions"] . ' WHERE idworkflowitem = ' . Contenido_Security::escapeDB($id, $oDb) . ';';
|
||||
$oDb->query($sSql);
|
||||
|
||||
$this->updateArtAllocation($id, 1);
|
||||
|
||||
if (count($aUserSequencesDelete) > 0) {
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idusersequence in (' . implode(',', $aUserSequencesDelete) . ');';
|
||||
$oDb->query($sSql);
|
||||
}
|
||||
}
|
||||
|
||||
function updateArtAllocation($idworkflowitem, $delete = false) {
|
||||
global $idworkflow, $cfg;
|
||||
$oDb = new DB_ConLite();
|
||||
|
||||
$aUserSequences = array();
|
||||
$sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem = ' . Contenido_Security::escapeDB($idworkflowitem, $oDb) . ';';
|
||||
|
||||
$oDb->query($sSql);
|
||||
while ($oDb->next_record()) {
|
||||
array_push($aUserSequences, Contenido_Security::escapeDB($oDb->f('idusersequence'), $oDb));
|
||||
}
|
||||
|
||||
$aIdArtLang = array();
|
||||
if (count($aUserSequences) > 0) {
|
||||
$sSql = 'SELECT idartlang FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
|
||||
$oDb->query($sSql);
|
||||
while ($oDb->next_record()) {
|
||||
array_push($aIdArtLang, $oDb->f('idartlang'));
|
||||
}
|
||||
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
|
||||
$oDb->query($sSql);
|
||||
}
|
||||
|
||||
if ($delete) {
|
||||
parent::delete($idworkflowitem);
|
||||
}
|
||||
|
||||
foreach ($aIdArtLang as $iIdArtLang) {
|
||||
setUserSequence($iIdArtLang, $idworkflow);
|
||||
}
|
||||
}
|
||||
|
||||
function swap($idworkflow, $pos1, $pos2) {
|
||||
$this->select("idworkflow = '$idworkflow' AND position = '$pos1'");
|
||||
if (($item = $this->next()) === false) {
|
||||
$this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$pos1ID = $item->getField("idworkflowitem");
|
||||
|
||||
$this->select("idworkflow = '$idworkflow' AND position = '$pos2'");
|
||||
if (($item = $this->next()) === false) {
|
||||
$this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$pos2ID = $item->getField("idworkflowitem");
|
||||
|
||||
$item = new WorkflowItem();
|
||||
$item->loadByPrimaryKey($pos1ID);
|
||||
$item->setPosition($pos2);
|
||||
$item->store();
|
||||
$item->loadByPrimaryKey($pos2ID);
|
||||
$item->setPosition($pos1);
|
||||
$item->store();
|
||||
|
||||
$this->updateArtAllocation($pos1ID);
|
||||
$this->updateArtAllocation($pos2ID);
|
||||
return (true);
|
||||
}
|
||||
|
||||
function create($idworkflow) {
|
||||
$workflows = new Workflows;
|
||||
|
||||
$workflows->select("idworkflow = '$idworkflow'");
|
||||
|
||||
if ($workflows->next() === false) {
|
||||
$this->lasterror = i18n("Can't add item to workflow: Workflow doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->select("idworkflow = '$idworkflow'", "", "position DESC", "1");
|
||||
|
||||
$item = $this->next();
|
||||
|
||||
if ($item === false) {
|
||||
$lastPos = 1;
|
||||
} else {
|
||||
$lastPos = $item->getField("position") + 1;
|
||||
}
|
||||
|
||||
$newItem = parent::createNewItem();
|
||||
if ($newItem->init($idworkflow, $lastPos) === false) {
|
||||
$this->delete($newItem->getField("idworkflowitem"));
|
||||
$this->lasterror = $newItem->lasterror;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item === false) {
|
||||
$this->updateArtAllocation(0);
|
||||
}
|
||||
|
||||
return ($newItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowItem
|
||||
* Class for a single workflow item
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.1
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowItem extends Item {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
|
||||
parent::__construct($cfg["tab"]["workflow_items"], "idworkflowitem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowItem() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function getStepRights() {
|
||||
$idwfi = $this->values["idworkflowitem"];
|
||||
$workflowActions = new WorkflowActions;
|
||||
|
||||
$actions = WorkflowActions::getAvailableWorkflowActions();
|
||||
|
||||
foreach ($actions as $key => $value) {
|
||||
$rights[$key] = $workflowActions->get($idwfi, $key);
|
||||
}
|
||||
|
||||
return $rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden setField function.
|
||||
* @param string $field Void field since we override the usual setField function
|
||||
* @param string $value Void field since we override the usual setField function
|
||||
*/
|
||||
function setField($field, $value, $bSafe = TRUE) {
|
||||
if ($this->virgin == true) {
|
||||
$this->lasterror = i18n("No item loaded", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($field == "idsequence") {
|
||||
die("You can't set the idsequence field using this method. Use 'create' in the WorkflowItems class.");
|
||||
}
|
||||
|
||||
if ($field == "idworkflow") {
|
||||
die("You can't set the workflow ID using this method. Use 'create' in the WorkflowItems class!");
|
||||
}
|
||||
|
||||
if ($field == "position") {
|
||||
die("You can't set the position ID using this method. Use 'create' or 'swap' to create or move items!");
|
||||
}
|
||||
|
||||
if ($field == "idtask" && $value != 0) {
|
||||
$taskCollection = new WorkflowTasks;
|
||||
$taskCollection->select("idtask = '$value'");
|
||||
if ($taskCollection->next() === false) {
|
||||
$this->lasterror = i18n("Requested task doesn't exist, can't assign", "workflow");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
parent::setField($field, $value, $bSafe);
|
||||
}
|
||||
|
||||
/**
|
||||
* init initializes a new wf_items entry. Should
|
||||
* only be called by the create function.
|
||||
* @param int $idworkflow The workflow to set the item to
|
||||
*/
|
||||
function init($idworkflow, $idposition) {
|
||||
global $cfg;
|
||||
|
||||
$workflows = new Workflows;
|
||||
|
||||
$workflows->select("idworkflow = '$idworkflow'");
|
||||
|
||||
if ($workflows->next() === false) {
|
||||
$this->lasterror = i18n("Workflow doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$workflowItems = new WorkflowItems;
|
||||
$workflowItems->select("position = '$idposition' AND idworkflow = '$idworkflow'");
|
||||
if ($workflowItems->next()) {
|
||||
$this->lasterror = i18n("Position in this workflow already exists.", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
parent::setField("idworkflow", $idworkflow);
|
||||
parent::setField("position", $idposition);
|
||||
parent::store();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* setPosition Sets the position for an item. Should only be
|
||||
* called by the "swap" function
|
||||
* @param int $idposition The new position ID
|
||||
*/
|
||||
function setPosition($idposition) {
|
||||
parent::setField("position", $idposition);
|
||||
parent::store();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
106
classes/class.workflowtasks.php
Normale Datei
106
classes/class.workflowtasks.php
Normale Datei
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Simple wrapper for workflow tasks
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.2
|
||||
* @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
|
||||
*
|
||||
* $Id: class.workflowtasks.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowTasks
|
||||
* Class for workflow task collections
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.2
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowTasks extends ItemCollection {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["tasks"], "idtask");
|
||||
$this->_setItemClass("WorkflowTask");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowTasks()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function create ()
|
||||
{
|
||||
$newitem = parent::createNewItem();
|
||||
return ($newitem);
|
||||
}
|
||||
|
||||
function select ($where = "", $group_by = "", $order_by = "", $limit = "")
|
||||
{
|
||||
global $client;
|
||||
|
||||
if ($where != "")
|
||||
{
|
||||
$where = $where . " AND idclient = '".Contenido_Security::escapeDB($client, NULL)."'";
|
||||
}
|
||||
return parent::select($where, $group_by, $order_by, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowTask
|
||||
* Class for a single workflow task item
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.1
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowTask extends Item {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["tasks"], "idtask");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowTask()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
278
classes/class.workflowusersequence.php
Normale Datei
278
classes/class.workflowusersequence.php
Normale Datei
|
|
@ -0,0 +1,278 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Workflow management class
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.3
|
||||
* @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
|
||||
*
|
||||
* $Id: class.workflowusersequence.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowUserSequences
|
||||
* Class for workflow user sequence management
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.2
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowUserSequences extends ItemCollection {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_user_sequences"], "idusersequence");
|
||||
$this->_setItemClass("WorkflowUserSequence");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowUserSequences()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function delete ($id)
|
||||
{
|
||||
global $cfg, $idworkflow;
|
||||
|
||||
$item = new WorkflowUserSequence;
|
||||
$item->loadByPrimaryKey($id);
|
||||
|
||||
$pos = $item->get("position");
|
||||
$idworkflowitem = $item->get("idworkflowitem");
|
||||
$this->select("position > $pos AND idworkflowitem = '".Contenido_Security::escapeDB($idworkflowitem, NULL)."'");
|
||||
while ($obj = $this->next())
|
||||
{
|
||||
$pos = $obj->get("position") -1;
|
||||
$obj->setPosition($pos);
|
||||
$obj->store();
|
||||
}
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
$this->updateArtAllocation($id);
|
||||
}
|
||||
|
||||
function updateArtAllocation ($idusersequence) {
|
||||
global $idworkflow, $cfg;
|
||||
$oDb = new DB_ConLite();
|
||||
|
||||
$aIdArtLang = array();
|
||||
$sSql = 'SELECT idartlang FROM '.$cfg["tab"]["workflow_art_allocation"].' WHERE idusersequence = '.Contenido_Security::escapeDB($idusersequence, $oDb).';';
|
||||
$oDb->query($sSql);
|
||||
while ($oDb->next_record()) {
|
||||
array_push($aIdArtLang, $oDb->f('idartlang'));
|
||||
}
|
||||
|
||||
$sSql = 'DELETE FROM '.$cfg["tab"]["workflow_art_allocation"].' WHERE idusersequence = '.Contenido_Security::escapeDB($idusersequence, $oDb).';';
|
||||
$oDb->query($sSql);
|
||||
|
||||
|
||||
foreach ($aIdArtLang as $iIdArtLang) {
|
||||
setUserSequence($iIdArtLang, $idworkflow);
|
||||
}
|
||||
}
|
||||
|
||||
function create ($idworkflowitem)
|
||||
{
|
||||
global $auth, $client, $idworkflow;
|
||||
$newitem = parent::createNewItem();
|
||||
|
||||
$workflowitems = new WorkflowItems;
|
||||
if (!$workflowitems->exists($idworkflowitem))
|
||||
{
|
||||
$this->delete($newitem->getField("idusersequence"));
|
||||
$this->lasterror = i18n("Workflow item doesn't exist. Can't create entry.", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->select("idworkflowitem = '".Contenido_Security::escapeDB($idworkflowitem, NULL)."'","","position DESC","1");
|
||||
|
||||
$item = $this->next();
|
||||
|
||||
if ($item === false)
|
||||
{
|
||||
$lastPos = 1;
|
||||
} else {
|
||||
$lastPos = $item->getField("position") + 1;
|
||||
}
|
||||
|
||||
$newitem->setWorkflowItem($idworkflowitem);
|
||||
$newitem->setPosition($lastPos);
|
||||
$newitem->store();
|
||||
|
||||
return ($newitem);
|
||||
}
|
||||
|
||||
function swap ($idworkflowitem, $pos1, $pos2)
|
||||
{
|
||||
$this->select("idworkflowitem = '$idworkflowitem' AND position = '".Contenido_Security::escapeDB($pos1, NULL)."'");
|
||||
if (($item = $this->next()) === false)
|
||||
{
|
||||
$this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
$pos1ID = $item->getField("idusersequence");
|
||||
|
||||
$this->select("idworkflowitem = '$idworkflowitem' AND position = '".Contenido_Security::escapeDB($pos2, NULL)."'");
|
||||
if (($item = $this->next()) === false)
|
||||
{
|
||||
$this->lasterror(i18n("Swapping items failed: Item doesn't exist", "workflow"));
|
||||
return false;
|
||||
}
|
||||
|
||||
$pos2ID = $item->getField("idusersequence");
|
||||
|
||||
$item = new WorkflowUserSequence();
|
||||
$item->loadByPrimaryKey($pos1ID);
|
||||
$item->setPosition($pos2);
|
||||
$item->store();
|
||||
$item->loadByPrimaryKey($pos2ID);
|
||||
$item->setPosition($pos1);
|
||||
$item->store();
|
||||
|
||||
$this->updateArtAllocation($pos2ID);
|
||||
$this->updateArtAllocation($pos1ID);
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowUserSequence
|
||||
* Class for a single workflow item
|
||||
* @author Timo A. Hummel <Timo.Hummel@4fb.de>
|
||||
* @version 0.1
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowUserSequence extends Item {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_user_sequences"], "idusersequence");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowUserSequence()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override setField Function to prevent that somebody modifies
|
||||
* idsequence.
|
||||
* @param string $field Field to set
|
||||
* @param string $valie Value to set
|
||||
*/
|
||||
function setField($field, $value, $bSafe = true)
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
switch ($field)
|
||||
{
|
||||
case "idworkflowitem":
|
||||
die("Please use create to modify idsequence. Direct modifications are not allowed");
|
||||
case "idusersequence":
|
||||
die("Please use create to modify idsequence. Direct modifications are not allowed");
|
||||
case "position":
|
||||
die("Please use create and swap to set the position. Direct modifications are not allowed");
|
||||
case "iduser":
|
||||
if ($value != 0)
|
||||
{
|
||||
$db = new DB_ConLite;
|
||||
$sql = "SELECT user_id FROM " . $cfg["tab"]["phplib_auth_user_md5"] .
|
||||
" WHERE user_id = '".Contenido_Security::escapeDB($value, $db)."'";
|
||||
$db->query($sql);
|
||||
|
||||
if (!$db->next_record())
|
||||
{
|
||||
$sql = "SELECT group_id FROM " . $cfg["tab"]["groups"] .
|
||||
" WHERE group_id = '".Contenido_Security::escapeDB($value, $db)."'";
|
||||
|
||||
$db->query($sql);
|
||||
if (!$db->next_record())
|
||||
{
|
||||
$this->lasterror = i18n("Can't set user_id: User or group doesn't exist", "workflow");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$idusersquence = parent::getField('idusersequence');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
parent::setField($field, $value, $bSafe);
|
||||
if ($idusersquence) {
|
||||
WorkflowUserSequences::updateArtAllocation(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associated workflowItem for this user sequence
|
||||
* @param none
|
||||
*/
|
||||
function getWorkflowItem ()
|
||||
{
|
||||
if (!$this->virgin)
|
||||
{
|
||||
$workflowItem = new WorkflowItem;
|
||||
$workflowItem->loadByPrimaryKey($this->values["idworkflowitem"]);
|
||||
return ($workflowItem);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to set idworkflowitem. Should only be called by "create".
|
||||
* @param string $value The value to set
|
||||
*/
|
||||
function setWorkflowItem($value)
|
||||
{
|
||||
parent::setField("idworkflowitem", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to set idworkflowitem. Should only be called by "create".
|
||||
* @param string $value The value to set
|
||||
*/
|
||||
function setPosition($value)
|
||||
{
|
||||
parent::setField("position", $value);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren