PHP7 compability stuff, added db-tables for releasetool

Dieser Commit ist enthalten in:
Oldperl 2016-10-10 15:13:19 +00:00
Ursprung c6b32de9d2
Commit 0f907bbfa8
4 geänderte Dateien mit 328 neuen und 359 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -25,18 +26,17 @@
* }}
*
*/
if(!defined('CON_FRAMEWORK')) {
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";
$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');
@ -63,8 +63,7 @@ class Workflows extends ItemCollection {
$this->_setItemClass("Workflow");
}
function create ()
{
function create() {
global $auth, $client, $lang;
$newitem = parent::createNewItem();
$newitem->setField("created", date("Y-m-d H-i-s"));
@ -85,36 +84,37 @@ class Workflows extends ItemCollection {
$oDb = new DB_ConLite();
$aItemIdsDelete = array();
$sSql = 'SELECT idworkflowitem FROM '.$cfg["tab"]["workflow_items"].' WHERE idworkflow = '. Contenido_Security::toInteger($idWorkflow) .';';
$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).');';
$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).');';
$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).');';
$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).';';
$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).';';
$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).');';
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequencesDelete) . ');';
$oDb->query($sSql);
parent::delete($idWorkflow);
}
}
/**
@ -135,53 +135,46 @@ class Workflow extends Item {
global $cfg;
parent::__construct($cfg["tab"]["workflow"], "idworkflow");
}
}
}
/* Helper functions */
function getWorkflowForCat ($idcat)
{
function getWorkflowForCat($idcat) {
global $lang, $cfg;
$idcatlang = getCatLang($idcat, $lang);
$workflows = new WorkflowAllocations;
$workflows->select("idcatlang = '$idcatlang'");
if ($obj = $workflows->next())
{
if ($obj = $workflows->next()) {
/* Sanity: Check if the workflow still exists */
$workflow = new Workflow;
$res = $workflow->loadByPrimaryKey($obj->get("idworkflow"));
if ($res == false)
{
if ($res == false) {
return 0;
} else {
return $obj->get("idworkflow");
}
}
}
function getCatLang ($idcat, $idlang)
{
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)."'";
. $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())
{
if ($db->next_record()) {
return ($db->f("idcatlang"));
}
}
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -25,12 +26,10 @@
* }}
*
*/
if(!defined('CON_FRAMEWORK')) {
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
/**
* Class WorkflowItems
* Class for workflow item management
@ -44,22 +43,19 @@ class WorkflowItems extends ItemCollection {
* Constructor Function
* @param string $table The table to use as information source
*/
function __construct()
{
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()
{
function WorkflowItems() {
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
$this->__construct();
}
function delete ($id)
{
function delete($id) {
global $cfg;
$item = new WorkflowItem;
$item->loadByPrimaryKey($id);
@ -67,37 +63,36 @@ class WorkflowItems extends ItemCollection {
$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);
$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.';';
$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).';';
$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).');';
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idusersequence in (' . implode(',', $aUserSequencesDelete) . ');';
$oDb->query($sSql);
}
}
function updateArtAllocation ($idworkflowitem, $delete = false) {
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).';';
$sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem = ' . Contenido_Security::escapeDB($idworkflowitem, $oDb) . ';';
$oDb->query($sSql);
while ($oDb->next_record()) {
@ -106,12 +101,12 @@ class WorkflowItems extends ItemCollection {
$aIdArtLang = array();
if (count($aUserSequences) > 0) {
$sSql = 'SELECT idartlang FROM '.$cfg["tab"]["workflow_art_allocation"].' WHERE idusersequence in ('.implode(',', $aUserSequences).');';
$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).');';
$sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
$oDb->query($sSql);
}
@ -124,12 +119,9 @@ class WorkflowItems extends ItemCollection {
}
}
function swap ($idworkflow, $pos1, $pos2)
{
function swap($idworkflow, $pos1, $pos2) {
$this->select("idworkflow = '$idworkflow' AND position = '$pos1'");
if (($item = $this->next()) === false)
{
if (($item = $this->next()) === false) {
$this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
return false;
}
@ -137,8 +129,7 @@ class WorkflowItems extends ItemCollection {
$pos1ID = $item->getField("idworkflowitem");
$this->select("idworkflow = '$idworkflow' AND position = '$pos2'");
if (($item = $this->next()) === false)
{
if (($item = $this->next()) === false) {
$this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
return false;
}
@ -158,32 +149,28 @@ class WorkflowItems extends ItemCollection {
return (true);
}
function create ($idworkflow)
{
function create($idworkflow) {
$workflows = new Workflows;
$workflows->select("idworkflow = '$idworkflow'");
if ($workflows->next() === false)
{
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");
$this->select("idworkflow = '$idworkflow'", "", "position DESC", "1");
$item = $this->next();
if ($item === false)
{
if ($item === false) {
$lastPos = 1;
} else {
$lastPos = $item->getField("position") + 1;
}
$newItem = parent::createNewItem();
if ($newItem->init($idworkflow, $lastPos) === false)
{
if ($newItem->init($idworkflow, $lastPos) === false) {
$this->delete($newItem->getField("idworkflowitem"));
$this->lasterror = $newItem->lasterror;
return false;
@ -195,6 +182,7 @@ class WorkflowItems extends ItemCollection {
return ($newItem);
}
}
/**
@ -210,29 +198,25 @@ class WorkflowItem extends Item {
* Constructor Function
* @param string $table The table to use as information source
*/
function __construct()
{
function __construct() {
global $cfg;
parent::__construct($cfg["tab"]["workflow_items"], "idworkflowitem");
}
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
function WorkflowItem()
{
function WorkflowItem() {
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
$this->__construct();
}
function getStepRights ()
{
function getStepRights() {
$idwfi = $this->values["idworkflowitem"];
$workflowActions = new WorkflowActions;
$actions = WorkflowActions::getAvailableWorkflowActions();
foreach ($actions as $key => $value)
{
foreach ($actions as $key => $value) {
$rights[$key] = $workflowActions->get($idwfi, $key);
}
@ -244,35 +228,28 @@ class WorkflowItem extends Item {
* @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)
{
if ($this->virgin == true)
{
function setField($field, $value, $bSafe = TRUE) {
if ($this->virgin == true) {
$this->lasterror = i18n("No item loaded", "workflow");
return false;
}
if ($field == "idsequence")
{
if ($field == "idsequence") {
die("You can't set the idsequence field using this method. Use 'create' in the WorkflowItems class.");
}
if ($field == "idworkflow")
{
if ($field == "idworkflow") {
die("You can't set the workflow ID using this method. Use 'create' in the WorkflowItems class!");
}
if ($field == "position")
{
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)
{
if ($field == "idtask" && $value != 0) {
$taskCollection = new WorkflowTasks;
$taskCollection->select("idtask = '$value'");
if ($taskCollection->next() === false)
{
if ($taskCollection->next() === false) {
$this->lasterror = i18n("Requested task doesn't exist, can't assign", "workflow");
return false;
}
@ -286,24 +263,21 @@ class WorkflowItem extends Item {
* only be called by the create function.
* @param int $idworkflow The workflow to set the item to
*/
function init ($idworkflow, $idposition)
{
function init($idworkflow, $idposition) {
global $cfg;
$workflows = new Workflows;
$workflows->select("idworkflow = '$idworkflow'");
if ($workflows->next() === false)
{
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())
{
if ($workflowItems->next()) {
$this->lasterror = i18n("Position in this workflow already exists.", "workflow");
return false;
}
@ -319,11 +293,12 @@ class WorkflowItem extends Item {
* called by the "swap" function
* @param int $idposition The new position ID
*/
function setPosition ($idposition)
{
function setPosition($idposition) {
parent::setField("position", $idposition);
parent::store();
return true;
}
}
?>

Datei anzeigen

@ -70,9 +70,10 @@ $cfg["tab"]["container"] = $cfg['sql']['sqlprefix']."_container";
$cfg["tab"]["container_conf"] = $cfg['sql']['sqlprefix']."_container_conf";
$cfg["tab"]["files"] = $cfg['sql']['sqlprefix']."_files";
$cfg["tab"]["framefiles"] = $cfg['sql']['sqlprefix']."_frame_files";
$cfg["tab"]["plugins"] = $cfg['sql']['sqlprefix']."_plugins";
$cfg["tab"]["phplib_active_sessions"] = $cfg['sql']['sqlprefix']."_phplib_active_sessions";
$cfg["tab"]["phplib_auth_user_md5"] = $cfg['sql']['sqlprefix']."_phplib_auth_user_md5";
$cfg["tab"]["plugins"] = $cfg['sql']['sqlprefix']."_plugins";
$cfg["tab"]["plugins_rel"] = $cfg['sql']['sqlprefix']."_plugins_rel";
$cfg["tab"]["actionlog"] = $cfg['sql']['sqlprefix']."_actionlog";
$cfg["tab"]["link"] = $cfg['sql']['sqlprefix']."_link";
$cfg["tab"]["meta_type"] = $cfg['sql']['sqlprefix']."_meta_type";

Datei anzeigen

@ -134,7 +134,7 @@ $cfg['AvailableCharsets'] = array(
*/
/* Don't display errors */
@ini_set("display_errors",true);
@ini_set("display_errors",false);
/* Log errors to a file */
@ini_set("log_errors",true);