recoding to use as plugin with CL
Dieser Commit ist enthalten in:
Ursprung
244621b05f
Commit
e8b0c80921
22 geänderte Dateien mit 2187 neuen und 2341 gelöschten Zeilen
|
|
@ -30,20 +30,6 @@ 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
|
||||
|
|
@ -136,45 +122,4 @@ class Workflow extends Item {
|
|||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
|
@ -25,8 +26,7 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
|
@ -38,77 +38,69 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @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");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,14 +111,16 @@ class WorkflowActions extends ItemCollection {
|
|||
* @copyright four for business 2003
|
||||
*/
|
||||
class WorkflowAction extends Item {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @global type $cfg
|
||||
*/
|
||||
function __construct() {
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_actions"], "idworkflowaction");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
|
@ -25,12 +26,10 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowAllocations
|
||||
* Class for workflow allocation management
|
||||
|
|
@ -39,112 +38,100 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @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");
|
||||
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()
|
||||
{
|
||||
function WorkflowAllocations() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function delete ($idallocation)
|
||||
{
|
||||
global $cfg, $lang;
|
||||
function delete($idallocation) {
|
||||
global $cfg, $lang;
|
||||
|
||||
$obj = new WorkflowAllocation;
|
||||
$obj->loadByPrimaryKey($idallocation);
|
||||
|
||||
$idcatlang = $obj->get("idcatlang");
|
||||
$obj = new WorkflowAllocation;
|
||||
$obj->loadByPrimaryKey($idallocation);
|
||||
|
||||
$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"));
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -155,88 +142,82 @@ class WorkflowAllocations extends ItemCollection {
|
|||
* @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");
|
||||
}
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
|
||||
parent::__construct($cfg["tab"]["workflow_allocation"], "idallocation");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowAllocation()
|
||||
{
|
||||
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!");
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
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;
|
||||
*/
|
||||
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;
|
||||
}
|
||||
$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.
|
||||
* 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;
|
||||
}
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
parent::setField("idcatlang", $idcatlang);
|
||||
parent::store();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
|
@ -26,12 +27,10 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowArtAllocations
|
||||
* Class for workflow art allocation management
|
||||
|
|
@ -40,53 +39,49 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @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");
|
||||
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()
|
||||
{
|
||||
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)."'";
|
||||
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);
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,265 +92,241 @@ class WorkflowArtAllocations extends ItemCollection {
|
|||
* @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");
|
||||
}
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
|
||||
parent::__construct($cfg["tab"]["workflow_art_allocation"], "idartallocation");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowArtAllocation()
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
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"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
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"));
|
||||
}
|
||||
*/
|
||||
function currentUserPosition() {
|
||||
return ($this->get("position"));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Overriden store function to send mails
|
||||
* @param none
|
||||
*/
|
||||
function store()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$sMailhost = getSystemProperty('system', 'mail_host');
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
//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;
|
||||
$oMail->WordWrap = 1000;
|
||||
$oMail->IsMail();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return parent::store();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
|
@ -25,12 +26,10 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowTasks
|
||||
* Class for workflow task collections
|
||||
|
|
@ -39,41 +38,37 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @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");
|
||||
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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,23 +79,22 @@ class WorkflowTasks extends ItemCollection {
|
|||
* @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");
|
||||
}
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["tasks"], "idtask");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowTask()
|
||||
{
|
||||
function WorkflowTask() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
|
@ -25,12 +26,10 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowUserSequences
|
||||
* Class for workflow user sequence management
|
||||
|
|
@ -39,131 +38,122 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @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");
|
||||
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()
|
||||
{
|
||||
function WorkflowUserSequences() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
function delete ($id)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
$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) {
|
||||
}
|
||||
|
||||
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).';';
|
||||
$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).';';
|
||||
|
||||
$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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,105 +164,95 @@ class WorkflowUserSequences extends ItemCollection {
|
|||
* @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");
|
||||
}
|
||||
|
||||
function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["workflow_user_sequences"], "idusersequence");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function WorkflowUserSequence()
|
||||
{
|
||||
function WorkflowUserSequence() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Override setField Function to prevent that somebody modifies
|
||||
* idsequence.
|
||||
* 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');
|
||||
}
|
||||
function setField($field, $value, $bSafe = true) {
|
||||
global $cfg;
|
||||
|
||||
}
|
||||
|
||||
parent::setField($field, $value, $bSafe);
|
||||
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);
|
||||
}
|
||||
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 setPosition($value)
|
||||
{
|
||||
parent::setField("position", $value);
|
||||
}
|
||||
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