2019-11-04 15:22:11 +00:00
< ? php
2020-08-20 16:30:16 +00:00
2019-11-04 15:22:11 +00:00
/**
* Project :
* Contenido Content Management System
*
* Description :
* Workflow allocation class
*
* Requirements :
* @ con_php_req 5.0
*
*
* @ package Contenido Backend classes
* @ version 1.5
* @ author Timo Hummel
* @ copyright four for business AG < www . 4 fb . de >
* @ license http :// www . contenido . org / license / LIZENZ . txt
* @ link http :// www . 4 fb . de
* @ link http :// www . contenido . org
*
* { @ internal
* created 2003 - 07 - 18
*
* $Id : class . workflowallocation . php 128 2019 - 07 - 03 11 : 58 : 28 Z oldperl $
* }}
*
*/
2020-08-20 16:30:16 +00:00
if ( ! defined ( 'CON_FRAMEWORK' )) {
die ( 'Illegal call' );
2019-11-04 15:22:11 +00:00
}
/**
* Class WorkflowAllocations
* Class for workflow allocation management
* @ author Timo A . Hummel < Timo . Hummel @ 4 fb . de >
* @ version 0.2
* @ copyright four for business 2003
*/
class WorkflowAllocations extends ItemCollection {
2020-08-20 16:30:16 +00:00
/**
2019-11-04 15:22:11 +00:00
* Constructor Function
* @ param string $table The table to use as information source
*/
2020-08-20 16:30:16 +00:00
function __construct () {
global $cfg ;
parent :: __construct ( $cfg [ " tab " ][ " workflow_allocation " ], " idallocation " );
2019-11-04 15:22:11 +00:00
$this -> _setItemClass ( " WorkflowAllocation " );
2020-08-20 16:30:16 +00:00
}
2019-11-04 15:22:11 +00:00
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
2020-08-20 16:30:16 +00:00
function WorkflowAllocations () {
2019-11-04 15:22:11 +00:00
cWarning ( __FILE__ , __LINE__ , " Deprecated method call, use __construct() " );
$this -> __construct ();
}
2020-08-20 16:30:16 +00:00
function 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 );
}
2019-11-04 15:22:11 +00:00
}
/**
* Class WorkflowAllocation
* Class for a single workflow allocation item
* @ author Timo A . Hummel < Timo . Hummel @ 4 fb . de >
* @ version 0.1
* @ copyright four for business 2003
*/
class WorkflowAllocation extends Item {
2020-08-20 16:30:16 +00:00
/**
2019-11-04 15:22:11 +00:00
* Constructor Function
* @ param string $table The table to use as information source
*/
2020-08-20 16:30:16 +00:00
function __construct () {
global $cfg ;
parent :: __construct ( $cfg [ " tab " ][ " workflow_allocation " ], " idallocation " );
}
2019-11-04 15:22:11 +00:00
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
2020-08-20 16:30:16 +00:00
function WorkflowAllocation () {
2019-11-04 15:22:11 +00:00
cWarning ( __FILE__ , __LINE__ , " Deprecated method call, use __construct() " );
$this -> __construct ();
}
2020-08-20 16:30:16 +00:00
/**
2019-11-04 15:22:11 +00:00
* 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
2020-08-20 16:30:16 +00:00
*/
function setField ( $field , $value , $bSafe = true ) {
die ( " Don't use setField for WorkflowAllocation items! Use setWorkflow instead! " );
}
/**
2019-11-04 15:22:11 +00:00
* setWorkflow sets the workflow for the current item .
* @ param int $idworkflow Workflow - ID to set the item to
2020-08-20 16:30:16 +00:00
*/
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 ;
}
/**
2019-11-04 15:22:11 +00:00
* setCatLang sets the idcatlang for the current item . Should
2020-08-20 16:30:16 +00:00
* only be called by the create function .
2019-11-04 15:22:11 +00:00
* @ param int $idcatlang idcatlang to set .
2020-08-20 16:30:16 +00:00
*/
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 ;
}
2019-11-04 15:22:11 +00:00
}
2020-08-20 16:30:16 +00:00
2019-11-04 15:22:11 +00:00
?>