1
0
Fork 0

recoding to use as plugin with CL

Dieser Commit ist enthalten in:
o.pinke 2020-08-20 18:30:16 +02:00
Ursprung 244621b05f
Commit e8b0c80921
22 geänderte Dateien mit 2187 neuen und 2341 gelöschten Zeilen

Datei anzeigen

@ -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;
}
}
?>