$sql="INSERT INTO ".$cfg["tab"]["art"]." (idart, idclient) VALUES ('".Contenido_Security::toInteger($new_idart)."', '".Contenido_Security::toInteger($client)."')";
$db->query($sql);
# Table 'con_stat'
$sql="SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idart = '".Contenido_Security::toInteger($new_idart)."'";
$db->query($sql);
$db->next_record();
$idcatart=$db->f("idcatart");
$a_languages[]=$lang;
foreach($a_languagesas$tmp_lang){
$sql="INSERT INTO ".$cfg["tab"]["stat"]." (idstat, idcatart, idlang, idclient, visited) VALUES ('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["stat"]))."',
$sql="SELECT idcat FROM ".$cfg["tab"]["cat_art"]." WHERE idart='".Contenido_Security::toInteger($idart)."'";// get all idcats that contain art
$db->query($sql);
while($db->next_record()){
$tmp_idcat[]=$db->f("idcat");
}
if(!is_array($idcatnew)){$idcatnew[0]=0;}
if(!is_array($tmp_idcat)){$tmp_idcat[0]=0;}
foreach($idcatnewas$value){
if(!in_array($value,$tmp_idcat)){
# INSERT -> Table 'cat_art'
$sql="INSERT INTO ".$cfg["tab"]["cat_art"]." (idcatart, idcat, idart) VALUES ('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_art"]))."', '".Contenido_Security::toInteger($value)."',
'".Contenido_Security::toInteger($idart)."')";
$db->query($sql);
# Entry in 'stat'-table for all languages
$sql="SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($value)."' AND idart='".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
$db->next_record();
$tmp_idcatart=$db->f("idcatart");
$a_languages=getLanguagesByClient($client);
foreach($a_languagesas$tmp_lang){
$sql="INSERT INTO ".$cfg["tab"]["stat"]." (idstat, idcatart, idlang, idclient, visited) VALUES ('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["stat"]))."',
$sql="SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($value)."' AND idart='".Contenido_Security::toInteger($idart)."'";// get all idcatarts that will no longer exist
$db->query($sql);
//******** delete from 'code'-table *************** // and delete corresponding code
$sql="DELETE FROM ".$cfg["tab"]["code"]." WHERE idcatart='".Contenido_Security::toInteger($db->f("idcatart"))."'";
$db->query($sql);
//******* delete from 'stat'-table ****************
$sql="SELECT * FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($value)."' AND idart='".Contenido_Security::toInteger($idart)."' ";
$db->query($sql);
while($db->next_record()){
$a_idcatart[]=$db->f("idcatart");
}
if(is_array($a_idcatart)){
foreach($a_idcatartAS$value2){
//****** delete from 'stat'-table ************
$sql="DELETE FROM ".$cfg["tab"]["stat"]." WHERE idcatart='".Contenido_Security::toInteger($value2)."'";
$db->query($sql);
}
}
//******** delete from 'cat_art'-table ***************
$sql="DELETE FROM ".$cfg["tab"]["cat_art"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idcat='".Contenido_Security::toInteger($value)."'";
$db->query($sql);
/* Remove startidartlang */
if(isStartArticle($idartlang,$idcat,$lang))
{
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET startidartlang='0' WHERE idcat='".Contenido_Security::toInteger($value)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}
//******** delete from 'tpl_conf'-table ***************
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$tmp_idtplcfg=$db->f('idtplcfg');
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfgm)."'";
$db->query($sql);
}
}
//********* update into 'art_lang'-table for all languages ******
$sql="SELECT idcat FROM ".$cfg["tab"]["cat_art"]." WHERE idart='".Contenido_Security::toInteger($idart)."'";// get all idcats that contain art
$db->query($sql);
while($db->next_record()){
$tmp_idcat[]=$db->f("idcat");
}
if(!is_array($idcatnew)){
$idcatnew[0]=0;
}
if(!is_array($tmp_idcat)){
$tmp_idcat[0]=0;
}
// if (is_array($idcatnew)) {
foreach($idcatnewas$value){
if(!in_array($value,$tmp_idcat)){
# INSERT insert 'cat_art' table
$sql="INSERT INTO ".$cfg["tab"]["cat_art"]." (idcatart, idcat, idart) VALUES ('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_art"]))."', '".Contenido_Security::toInteger($value)."',
'".Contenido_Security::toInteger($idart)."')";
$db->query($sql);
# entry in 'stat'-table for all languages
$sql="SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($value)."' AND idart='".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
$db->next_record();
$tmp_idcatart=$db->f("idcatart");
$a_languages=getLanguagesByClient($client);
foreach($a_languagesas$tmp_lang){
$sql="INSERT INTO ".$cfg["tab"]["stat"]." (idstat, idcatart, idlang, idclient, visited) VALUES ('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["stat"]))."',
$sql="SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($value)."' AND idart='".Contenido_Security::toInteger($idart)."'";// get all idcatarts that will no longer exist
$db->query($sql);
//******** delete from 'code'-table *************** // and delete corresponding code
$sql="DELETE FROM ".$cfg["tab"]["code"]." WHERE idcatart='".Contenido_Security::toInteger($db->f("idcatart"))."'";
$db->query($sql);
//******* delete from 'stat'-table ****************
$sql="SELECT * FROM ".$cfg["tab"]["cat_art"]." WHERE idcat='".Contenido_Security::toInteger($value)."' AND idart='".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
while($db->next_record()){
$a_idcatart[]=$db->f("idcatart");
}
if(is_array($a_idcatart)){
foreach($a_idcatartas$value2){
//****** delete from 'stat'-table ************
$sql="DELETE FROM ".$cfg["tab"]["stat"]." WHERE idcatart='".Contenido_Security::toInteger($value2)."'";
$db->query($sql);
}
}
//******** delete from 'cat_art'-table ***************
$sql="DELETE FROM ".$cfg["tab"]["cat_art"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idcat='".Contenido_Security::toInteger($value)."'";
$db->query($sql);
/* Remove startidartlang */
if(isStartArticle($idartlang,$idcat,$lang))
{
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET startidartlang='0' WHERE idcat='".Contenido_Security::toInteger($value)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}
}
}
// If the user has no right for makeonline, don't update it.
$sql="SELECT * FROM ".$cfg["tab"]["type"]." WHERE type = '".Contenido_Security::escapeDB($type,$db)."'";
$db->query($sql);
$db->next_record();
$idtype=$db->f("idtype");
$sql="SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang='".Contenido_Security::toInteger($idartlang)."' AND idtype='".Contenido_Security::toInteger($idtype)."' AND typeid='".Contenido_Security::toInteger($typeid)."'";
$db->query($sql);
if($db->next_record()){
$sql="UPDATE ".$cfg["tab"]["content"]." SET value='".Contenido_Security::escapeDB($value,$db)."', author='".Contenido_Security::escapeDB($author,$db)."', lastmodified='".Contenido_Security::escapeDB($date,$db)."'
$sql="SELECT online FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$sql="SELECT locked FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$set=($db->f("locked")==0)?1:0;
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET locked = '".Contenido_Security::toInteger($set)."' WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}
/**
*Toggletheonlinestatusof
*acategory
*
*@paramint$idcatidofthecategory
*@paramint$langidofthelanguage
*@paramint$statusstatusofthecategory
*
*@authorJanLengowski<jan.lengowski@4fb.de>
*@copyrightfourforbusinessAG<www.4fb.de>
*/
functionconMakeCatOnline($idcat,$lang,$status)
{
global$cfg,$db;
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET visible = '".Contenido_Security::toInteger($status)."',
" SET public='".Contenido_Security::toInteger($public)."', lastmodified = '".Contenido_Security::escapeDB(date("Y-m-d H:i:s"),$db).
"' WHERE idcat='".Contenido_Security::toInteger($value)."' AND idlang='".Contenido_Security::toInteger($lang)."' ";
$db->query($sql);
}
}
/**
*DeleteanArticle
*
*@paramint$idartArticleId
*
*@authorOlafNiemann<olaf.niemann@4fb-de>
*JanLengowski<jan.lengowski@4fb.de>
*
*@copyrightfourforbusinessAG<www.4fb.de>
*/
functionconDeleteart($idart)
{
global$db,$cfg,$lang,$_cecRegistry;
/* Delete current language */
$sql="SELECT idartlang, idtplcfg FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$idartlang=$db->f("idartlang");
$idtplcfg=$db->f("idtplcfg");
/* Fetch idcat */
$sql="SELECT idcat FROM ".$cfg["tab"]["cat_art"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
$db->next_record();
$idcat=$db->f("idcat");
/* Remove startidartlang */
if(isStartArticle($idartlang,$idcat,$lang))
{
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET startidartlang='0' WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}
$sql="DELETE FROM ".$cfg["tab"]["content"]." WHERE idartlang = '".Contenido_Security::toInteger($idartlang)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["art_lang"]." WHERE idartlang = '".Contenido_Security::toInteger($idartlang)."'";
$db->query($sql);
if($idtplcfg!="0"){
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
}
/* Check if there are remaining languages */
$sql="SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
if($db->num_rows()>0)
{
return;
}
$sql="SELECT * FROM ".$cfg["tab"]["cat_art"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
while($db->next_record()){
$idcatart[]=$db->f("idcatart");
}
if(is_array($idcatart)){
foreach($idcatartAS$value){
//********* delete from code table **********
$sql="DELETE FROM ".$cfg["tab"]["code"]." WHERE idcatart = '".Contenido_Security::toInteger($value)."'";
$db->query($sql);
//****** delete from 'stat'-table ************
$sql="DELETE FROM ".$cfg["tab"]["stat"]." WHERE idcatart = '".Contenido_Security::toInteger($value)."'";
$db->query($sql);
}
}
$sql="SELECT * FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
while($db->next_record()){
$idartlang[]=$db->f("idartlang");
}
if(is_array($idartlang)){
foreach($idartlangAS$value){
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET startidartlang='0' WHERE startidartlang ='".Contenido_Security::toInteger($value)."'";
$db->query($sql);
//********* delete from content table **********
$sql="DELETE FROM ".$cfg["tab"]["content"]." WHERE idartlang = '".Contenido_Security::toInteger($value)."'";
$db->query($sql);
}
}
$sql="DELETE FROM ".$cfg["tab"]["cat_art"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["art"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."'";
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$old_idtplcfg=$db->f("idtplcfg");
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($old_idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($old_idtplcfg)."'";
$db->query($sql);
/*parameter$idtplis0,
resetthetemplate*/
if(0==$idtpl){
/* get $idtplcfg */
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$idtplcfg=$db->f("idtplcfg");
/* DELETE 'template_conf' entry */
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
/* DELETE 'container_conf entries' */
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
/* UPDATE 'cat_lang' table */
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET idtplcfg = '0' WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}else{
if(!is_object($db2))$db2=newDB_ConLite;
/*checkifapre-configuration
isassigned*/
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["tpl"]." WHERE idtpl = '".Contenido_Security::toInteger($idtpl)."'";
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$tmp_idtplcfg=$db->f("idtplcfg");
if($tmp_idtplcfg!=0){
/* DELETE 'template_conf' entry */
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
/* DELETE 'container_conf entries' */
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
}
/* update 'cat_lang' table */
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET idtplcfg = '".Contenido_Security::toInteger($new_idtplcfg)."' WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET idtplcfg = '".Contenido_Security::toInteger($new_idtplcfg)."' WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$sql="UPDATE ".$cfg["tab"]["cat_art"]." SET is_start = 0 WHERE idcatart IN ('".implode("','",$aIDs)."')";
$db->query($sql);
}
$sql="UPDATE ".$cfg["tab"]["cat_art"]." SET is_start='".Contenido_Security::toInteger($is_start)."' WHERE idcatart = '".Contenido_Security::toInteger($idcatart)."'";
$db->query($sql);
}else{
$sql="SELECT idcat, idart FROM ".$cfg["tab"]["cat_art"]." WHERE idcatart='".Contenido_Security::toInteger($idcatart)."'";
$db->query($sql);
$db->next_record();
$idart=$db->f("idart");
$idcat=$db->f("idcat");
$sql="SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE idart='".Contenido_Security::toInteger($idart)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$idartlang=$db->f("idartlang");
if($is_start==1)
{
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET startidartlang='".Contenido_Security::toInteger($idartlang)."' WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}else{
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET startidartlang='0' WHERE idcat='".Contenido_Security::toInteger($idcat)."' AND idlang='".Contenido_Security::toInteger($lang)."' AND startidartlang='".Contenido_Security::toInteger($idartlang)."'";
$db->query($sql);
}
}
if($is_start==1)
{
// Deactivate time management if article is a start article
$sql="SELECT idart FROM ".$cfg["tab"]["cat_art"]." WHERE idcatart = '".Contenido_Security::toInteger($idcatart)."'";
$db->query($sql);
$db->next_record();
$idart=$db->f("idart");
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET timemgmt = 0 WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
/* Set all articles which are before our starttime to offline */
$sql="SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE NOW() < datestart AND datestart != '0000-00-00 00:00:00' AND datestart IS NOT NULL AND timemgmt = 1";
$db->query($sql);
while($db->next_record()){
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET online = 0 WHERE idartlang = '".Contenido_Security::toInteger($db->f("idartlang"))."'";
$db2->query($sql);
}
/* Set all articles which are in between of our start/endtime to online */
$sql="SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE NOW() > datestart AND (NOW() < dateend OR dateend = '0000-00-00 00:00:00') AND ".
"online = 0 AND timemgmt = 1";
$db->query($sql);
while($db->next_record()){
// modified 2007-11-14: Set publish date if article goes online
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET online = 1, published = datestart ".
#Check if article has already been synced to target language
$sql="SELECT * FROM ".$cfg['tab']['art_lang']." WHERE (idart = ".Contenido_Security::toInteger($idart).") AND (idlang= ".Contenido_Security::toInteger($dstlang).")";
$sql="SELECT idart FROM ".$cfg["tab"]["art_lang"]." WHERE idartlang='".Contenido_Security::toInteger($idartlang)."'";
$db->query($sql);
if(!$db->next_record())
{
returnfalse;
}else{
$idart=$db->f("idart");
$sql="SELECT is_start FROM ".$cfg["tab"]["cat_art"]." WHERE is_start = '1' AND idcat='".Contenido_Security::toInteger($idcat)."' AND idart='".Contenido_Security::toInteger($idart)."'";
$db->query($sql);
if($db->next_record())
{
returntrue;
}else{
returnfalse;
}
}
}else{
$sql="SELECT startidartlang FROM ".$cfg["tab"]["cat_lang"]."