[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sitemgr/inc/class.Content_SO.inc.php, 1.14
From: |
nomail |
Subject: |
[Phpgroupware-cvs] sitemgr/inc/class.Content_SO.inc.php, 1.14 |
Date: |
Wed, 21 Jul 2004 01:22:53 +0200 |
Update of /sitemgr/inc
Modified Files:
Branch:
class.Content_SO.inc.php
date: 2004/07/20 23:22:53; author: skwashd; state: Exp; lines: +136 -82
Log Message:
merge from 16
=====================================================================
Index: sitemgr/inc/class.Content_SO.inc.php
diff -u sitemgr/inc/class.Content_SO.inc.php:1.13
sitemgr/inc/class.Content_SO.inc.php:1.14
--- sitemgr/inc/class.Content_SO.inc.php:1.13 Sat Jun 14 03:34:02 2003
+++ sitemgr/inc/class.Content_SO.inc.php Tue Jul 20 23:22:53 2004
@@ -19,25 +19,29 @@
{
$block->page__id = 0;
}
- $sql = "INSERT INTO phpgw_sitemgr_blocks
(area,module_id,page_id,cat_id,sort_order,viewable) VALUES ('" .
- $block->area . "'," . $block->module_id . "," .
$block->page_id . "," . $block->cat_id . ",0,0)";
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('INSERT INTO phpgw_sitemgr_blocks
(area,module_id,page_id,'
+ . 'cat_id,sort_order,viewable) '
+ . "VALUES ('" .
$this->db->db_addslashes($block->area) . "',"
+ . intval($block->module_id) .
","
+ . intval($block->page_id) . ","
+ . intval($block->cat_id) .
',0,0)', __LINE__, __FILE__);
return
$this->db->get_last_insert_id('phpgw_sitemgr_blocks','block_id');
}
function createversion($blockid)
{
- $sql = "INSERT INTO phpgw_sitemgr_content
(block_id,state) VALUES ($blockid," . SITEMGR_STATE_DRAFT . ")";
- return $this->db->query($sql,__LINE__,__FILE__);
+ return $this->db->query('INSERT INTO
phpgw_sitemgr_content (block_id,state)'
+ . ' VALUES (' .
intval($blockid) . ',' . SITEMGR_STATE_DRAFT
+ . ')', __LINE__, __FILE__);
}
function deleteversion($id)
{
- $sql = "DELETE FROM phpgw_sitemgr_content WHERE
version_id = $id";
+ $sql = 'DELETE FROM phpgw_sitemgr_content WHERE
version_id = ' . intval($id);
if ($this->db->query($sql,__LINE__,__FILE__))
{
- $sql = "DELETE FROM phpgw_sitemgr_content_lang
WHERE version_id = $id";
- return $this->db->query($sql,__LINE__,__FILE__);
+ return $this->db->query('DELETE FROM
phpgw_sitemgr_content_lang'
+ . ' WHERE version_id = ' . intval($id),
__LINE__,__FILE__);
}
else
{
@@ -47,18 +51,18 @@
function getblockidforversion($versionid)
{
- $sql = "SELECT block_id FROM phpgw_sitemgr_content
WHERE version_id = $versionid";
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT block_id FROM
phpgw_sitemgr_content'
+ . ' WHERE version_id = ' .
intval($versionid), __LINE__, __FILE__);
return $this->db->next_record() ?
$this->db->f('block_id') : false;
}
function removeblock($id)
{
- $sql = "DELETE FROM phpgw_sitemgr_blocks WHERE block_id
= $id";
+ $sql = 'DELETE FROM phpgw_sitemgr_blocks WHERE block_id
= '. intval($id);
if ($this->db->query($sql,__LINE__,__FILE__))
{
- $sql = "DELETE FROM phpgw_sitemgr_blocks_lang
WHERE block_id = $id";
- return $this->db->query($sql,__LINE__,__FILE__);
+ return $this->db->query('DELETE FROM
phpgw_sitemgr_blocks_lang'
+ . ' WHERE block_id = '
. intval($id), __LINE__, __FILE__);
}
else
{
@@ -68,11 +72,16 @@
function getblocksforscope($cat_id,$page_id)
{
- $sql = "SELECT
t1.block_id,t1.module_id,module_name,area FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND cat_id =
$cat_id AND page_id = $page_id ORDER by sort_order";
$block = CreateObject('sitemgr.Block_SO',True);
+ $this->db->query('SELECT
t1.block_id,t1.module_id,module_name,area'
+ . ' FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_modules AS t2'
+ . ' WHERE t1.module_id = t2.module_id'
+ . ' AND cat_id = ' . intval($cat_id)
+ . ' AND page_id = ' . intval($page_id)
+ . ' ORDER by sort_order', __LINE__,
__FILE__);
+
$result = array();
- $this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
@@ -88,11 +97,15 @@
function getallblocksforarea($area,$cat_list,$page_id,$lang)
{
- $sql = "SELECT t1.block_id, area, cat_id, page_id,
t1.module_id, module_name, sort_order, title, viewable"
- . " FROM phpgw_sitemgr_blocks AS t1 LEFT JOIN "
- . " phpgw_sitemgr_modules AS t2 ON
t1.module_id=t2.module_id LEFT JOIN "
- . " phpgw_sitemgr_blocks_lang AS t3 ON
(t1.block_id=t3.block_id AND lang='$lang') "
- . " WHERE area = '$area' AND ((page_id = 0 and
cat_id = ". CURRENT_SITE_ID . ")";
+ $sql = 'SELECT t1.block_id, area, cat_id, page_id,
t1.module_id, '
+ . 'module_name, sort_order, title,
viewable'
+ . ' FROM phpgw_sitemgr_blocks AS t1 '
+ . ' LEFT JOIN phpgw_sitemgr_modules AS t2 ON
t1.module_id=t2.module_id'
+ . ' LEFT JOIN phpgw_sitemgr_blocks_lang AS t3
ON (t1.block_id=t3.block_id'
+ . " AND lang='" .
$this->db->db_addslashes($lang) . "') "
+ . " WHERE area = '" .
$this->db->db_addslashes($area) . "'"
+ . ' AND ((page_id = 0 and cat_id = '.
CURRENT_SITE_ID . ')';
+
if ($cat_list)
{
$sql .= " OR (page_id = 0 AND cat_id IN (" .
implode(',',$cat_list) . "))";
@@ -126,9 +139,9 @@
function getversionidsforblock($blockid)
{
- $sql = "SELECT version_id FROM phpgw_sitemgr_content
WHERE block_id = $blockid";
+ $this->db->query('SELECT version_id FROM
phpgw_sitemgr_content'
+ . ' WHERE block_id = ' .
intval($blockid), __LINE__, __FILE__);
$result = array();
- $this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
@@ -140,10 +153,13 @@
function getallversionsforblock($blockid,$lang)
{
- $sql = "SELECT t1.version_id,
arguments,arguments_lang,state FROM phpgw_sitemgr_content AS t1 LEFT JOIN "
- . "phpgw_sitemgr_content_lang AS t2 ON
(t1.version_id=t2.version_id AND lang = '$lang') WHERE block_id = $blockid ";
+ $this->db->query('SELECT t1.version_id,
arguments,arguments_lang,state'
+ . ' FROM phpgw_sitemgr_content AS t1'
+ . ' LEFT JOIN
phpgw_sitemgr_content_lang AS t2 ON (t1.version_id=t2.version_id'
+ . " AND lang = '" .
$this->db->db_addslashes($lang) . "')"
+ . ' WHERE block_id =' .
intval($blockid), __LINE__, __FILE__);
+
$result = array();
- $this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
@@ -163,13 +179,16 @@
function getallblocks($cat_list,$states)
{
$cat_list[] = CURRENT_SITE_ID;
- $sql = "SELECT COUNT(state) AS
cnt,t1.block_id,area,cat_id,page_id,viewable,state FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_content as t2 WHERE t1.block_id=t2.block_id AND cat_id IN (" .
implode(',',$cat_list) . ")";
- $sql .= " AND state IN (" . implode(',',$states) .")
GROUP BY t1.block_id,area,cat_id,page_id,viewable";
-
$block = CreateObject('sitemgr.Block_SO',True);
- $result = array();
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT COUNT(state) AS
cnt,t1.block_id,area,cat_id,page_id,viewable,state '
+ . ' FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_content AS t2 '
+ . ' WHERE t1.block_id=t2.block_id '
+ . ' AND cat_id IN (' .
implode(',',$cat_list) . ')'
+ . ' AND state IN (' .
implode(',',$states) .')'
+ . ' GROUP BY
t1.block_id,area,cat_id,page_id,viewable', __LINE__, __FILE__);
+
+ $result = array();
while ($this->db->next_record())
{
@@ -197,23 +216,28 @@
$viewable .= $isuser ? SITEMGR_VIEWABLE_USER :
SITEMGR_VIEWABLE_ANONYMOUS;
$viewable .= $isadmin ? (',' . SITEMGR_VIEWABLE_ADMIN)
: '';
- $sql = "SELECT
t1.block_id,area,cat_id,page_id,t1.module_id,module_name,state,version_id " .
- "FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_modules AS t2,phpgw_sitemgr_content AS t3 " .
- "WHERE t1.module_id = t2.module_id AND
t1.block_id=t3.block_id AND area = '$area' " .
- "AND ((page_id = 0 and cat_id = ".
CURRENT_SITE_ID . ")";
+ $sql = 'SELECT
t1.block_id,area,cat_id,page_id,t1.module_id,module_name,state,version_id'
+ . ' FROM phpgw_sitemgr_blocks AS t1,
phpgw_sitemgr_modules AS t2,'
+ . ' phpgw_sitemgr_content AS t3'
+ . ' WHERE t1.module_id = t2.module_id'
+ . " AND t1.block_id=t3.block_id AND area = '" .
$this->db->db_addslashes($area) . "'"
+ . ' AND ((page_id = 0 and cat_id = '.
CURRENT_SITE_ID . ')';
if ($cat_list)
{
- $sql .= " OR (page_id = 0 AND cat_id IN (" .
implode(',',$cat_list) . "))";
+ $sql .= ' OR (page_id = 0 AND cat_id IN (' .
implode(',',$cat_list) . '))';
}
if ($page_id)
{
- $sql .= " OR (page_id = $page_id) ";
+ $sql .= ' OR (page_id = ' . intval($page_id) .
')';
}
- $sql .= ") AND viewable IN (" . $viewable . ") AND
state IN (" . implode(',',$GLOBALS['Common_BO']->visiblestates) . ") ORDER by
sort_order";
+ $sql .= ') AND viewable IN (' . $viewable . ') '
+ . ' AND state IN (' .
implode(',',$GLOBALS['Common_BO']->visiblestates) . ')'
+ . ' ORDER by sort_order';
+
$block = CreateObject('sitemgr.Block_SO',True);
$result = array();
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query($sql, __LINE__, __FILE__);
while ($this->db->next_record())
{
@@ -235,7 +259,8 @@
function getlangarrayforblocktitle($block_id)
{
$retval = array();
- $this->db->query("SELECT lang FROM
phpgw_sitemgr_blocks_lang WHERE block_id = $block_id",__LINE__,__FILE__);
+ $this->db->query('SELECT lang FROM
phpgw_sitemgr_blocks_lang'
+ . ' WHERE block_id = ' .
intval($block_id), __LINE__, __FILE__);
while ($this->db->next_record())
{
$retval[] = $this->db->f('lang');
@@ -247,7 +272,8 @@
function getlangarrayforversion($version_id)
{
$retval = array();
- $this->db->query("SELECT lang FROM
phpgw_sitemgr_content_lang WHERE version_id = $version_id",__LINE__,__FILE__);
+ $this->db->query('SELECT lang FROM
phpgw_sitemgr_content_lang'
+ . ' WHERE version_id = ' .
intval($version_id), __LINE__, __FILE__);
while ($this->db->next_record())
{
$retval[] = $this->db->f('lang');
@@ -259,18 +285,20 @@
function getversion($version_id,$lang=false)
{
$fields = "arguments" . ($lang ? ', arguments_lang' :
'');
- $lang_join = $lang ? "LEFT JOIN
phpgw_sitemgr_content_lang AS t2 ON (t1.version_id = t2.version_id AND
lang='$lang')" : '';
- $sql = "SELECT $fields FROM phpgw_sitemgr_content AS t1
$lang_join WHERE t1.version_id = $version_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
+ $lang_join = $lang ? 'LEFT JOIN
phpgw_sitemgr_content_lang AS t2'
+ . ' ON (t1.version_id =
t2.version_id'
+ . " AND lang='" .
$this->db->db_addslashes($lang) . "')"
+ : '';
+ $this->db->query("SELECT $fields FROM
phpgw_sitemgr_content AS t1 $lang_join "
+ . ' WHERE t1.version_id = ' .
intval($version_id), __LINE__, __FILE__);
if ($this->db->next_record())
{
return $lang ?
array_merge(
-
unserialize(stripslashes($this->db->f('arguments'))),
-
unserialize(stripslashes($this->db->f('arguments_lang')))
+
unserialize($this->db->f('arguments', True)),
+
unserialize($this->db->f('arguments_lang', True))
) :
-
unserialize(stripslashes($this->db->f('arguments')));
+ unserialize($this->db->f('arguments',
True));
}
else
{
@@ -280,11 +308,13 @@
function getblock($block_id,$lang)
{
- $sql = "SELECT
area,cat_id,page_id,area,t1.module_id,module_name,sort_order,title,viewable"
- . " FROM phpgw_sitemgr_blocks AS t1 LEFT JOIN "
- . " phpgw_sitemgr_modules as t2 ON
t1.module_id=t2.module_id LEFT JOIN "
- . " phpgw_sitemgr_blocks_lang AS t3 ON
(t1.block_id=t3.block_id AND lang='$lang') WHERE t1.block_id = $block_id";
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT
area,cat_id,page_id,area,t1.module_id,module_name,sort_order,'
+ . ' title,viewable'
+ . ' FROM phpgw_sitemgr_blocks AS t1 '
+ . ' LEFT JOIN phpgw_sitemgr_modules as t2 ON
t1.module_id=t2.module_id '
+ . ' LEFT JOIN phpgw_sitemgr_blocks_lang AS t3 '
+ . " ON (t1.block_id=t3.block_id AND
lang='" . $this->db->db_addslashes($lang) . "')"
+ . ' WHERE t1.block_id = ' . intval($block_id),
__LINE__, __FILE__);
if ($this->db->next_record())
{
$block = CreateObject('sitemgr.Block_SO',True);
@@ -308,8 +338,11 @@
//this function only retrieves basic info for the block
function getblockdef($block_id)
{
- $sql = "SELECT
cat_id,page_id,area,t1.module_id,module_name FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND
t1.block_id = $block_id";
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT
cat_id,page_id,area,t1.module_id,module_name '
+ . ' FROM phpgw_sitemgr_blocks AS
t1,phpgw_sitemgr_modules AS t2'
+ . ' WHERE t1.module_id = t2.module_id '
+ . ' AND t1.block_id = ' .
intval($block_id), __LINE__, __FILE__);
+
if ($this->db->next_record())
{
$block = CreateObject('sitemgr.Block_SO',True);
@@ -331,32 +364,38 @@
{
if ($lang)
{
- $sql = "SELECT title FROM
phpgw_sitemgr_blocks_lang WHERE block_id = $id AND lang = '$lang'";
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT title FROM
phpgw_sitemgr_blocks_lang'
+ . ' WHERE block_id =' .
intval($id)
+ . " AND lang = '" .
$this->db->db_addslashes($lang) . "'", __LINE__, __FILE__);
return $this->db->next_record() ?
$this->db->f('title') : false;
}
else
{
- $sql = "SELECT title FROM
phpgw_sitemgr_blocks_lang WHERE block_id = $id";
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT title FROM
phpgw_sitemgr_blocks_lang'
+ . ' WHERE block_id =' .
intval($id), __LINE__, __FILE__);
return $this->db->next_record() ?
$this->db->f('title') : false;
}
}
function saveblockdata($block)
{
- $sql = "UPDATE phpgw_sitemgr_blocks SET sort_order = "
. (int)$block->sort_order .
- ", viewable = " . $block->view . " WHERE
block_id = " . $block->id;
- return $this->db->query($sql,__LINE__,__FILE__);
+ return $this->db->query('UPDATE phpgw_sitemgr_blocks '
+ . ' SET sort_order = ' .
intval($block->sort_order) . ', '
+ . ' viewable = ' . intval($block->view)
+ . ' WHERE block_id = ' .
intval($block->id), __LINE__, __FILE__);
}
function saveblockdatalang($id,$title,$lang)
{
- $sql = "DELETE FROM phpgw_sitemgr_blocks_lang WHERE
block_id = $id AND lang = '$lang'";
- $this->db->query($sql,__LINE__,__FILE__);
- $sql = "INSERT INTO phpgw_sitemgr_blocks_lang
(block_id,title,lang) VALUES ($id,'$title','$lang')";
- return $this->db->query($sql,__LINE__,__FILE__);
- }
+ $this->db->query('DELETE FROM phpgw_sitemgr_blocks_lang
'
+ . ' WHERE block_id = ' . intval($id)
+ . " AND lang = '" .
$this->db->db_addslashes($lang) . "'", __LINE__, __FILE__);
+
+ return $this->db->query('INSERT INTO
phpgw_sitemgr_blocks_lang (block_id,title,lang)'
+ . ' VALUES (' . intval($id) .
','
+ . "'" .
$this->db->db_addslashes($title) . "',"
+ . "'" .
$this->db->db_addslashes($lang) . "')", __LINE__, __FILE__);
+ }
function saveversiondata($block_id,$version_id,$data)
{
@@ -367,14 +406,18 @@
}
$s = $this->db->db_addslashes(serialize($data));
//by requiring block_id, we make sur that we only touch
versions that really belong to the block
- $sql = "UPDATE phpgw_sitemgr_content SET arguments =
'$s' WHERE version_id = $version_id AND block_id = $block_id";
- return $this->db->query($sql,__LINE__,__FILE__);
+ return $this->db->query('UPDATE phpgw_sitemgr_content'
+ . " SET arguments = '$s' "
+ . ' WHERE version_id = ' .
intval($version_id)
+ . ' AND block_id = ' .
intval($block_id), __LINE__, __FILE__);
}
function saveversionstate($block_id,$version_id,$state)
{
- $sql = "UPDATE phpgw_sitemgr_content SET state = $state
WHERE version_id = $version_id AND block_id = $block_id";
- return $this->db->query($sql,__LINE__,__FILE__);
+ return $this->db->query('UPDATE phpgw_sitemgr_content '
+ . ' SET state = ' .
intval($state)
+ . ' WHERE version_id = ' .
intval($version_id)
+ . ' AND block_id = ' .
intval($block_id), __LINE__, __FILE__);
}
function saveversiondatalang($id,$data,$lang)
@@ -386,10 +429,13 @@
}
$s = $this->db->db_addslashes(serialize($data));
$blockid = $block->id;
- $sql = "DELETE FROM phpgw_sitemgr_content_lang WHERE
version_id = $id AND lang = '$lang'";
- $this->db->query($sql,__LINE__,__FILE__);
- $sql = "INSERT INTO phpgw_sitemgr_content_lang
(version_id,lang,arguments_lang) VALUES ($id,'$lang','$s')";
- return $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('DELETE FROM
phpgw_sitemgr_content_lang '
+ . ' WHERE version_id = ' . intval($id)
+ . " AND lang = '" .
$this->db->db_addslashes($lang). "'", __LINE__, __FILE__);
+ return $this->db->query('INSERT INTO
phpgw_sitemgr_content_lang (version_id,lang,arguments_lang) '
+ . ' VALUES (' . intval($id) .
','
+ . "'" .
$this->db->db_addslashes($lang) . "',"
+ . "'$s')", __LINE__, __FILE__);
}
function remove_magic_quotes(&$data)
@@ -397,7 +443,7 @@
if (is_array($data))
{
reset($data);
- while (list($key,$val) = each($data))
+ foreach($data as $key => $val)
{
$this->remove_magic_quotes($data[$key]);
}
@@ -410,15 +456,23 @@
function commit($block_id)
{
- $sql = "UPDATE phpgw_sitemgr_content SET state = " .
SITEMGR_STATE_PUBLISH . " WHERE state = " . SITEMGR_STATE_PREPUBLISH . " AND
block_id = $block_id";
- $this->db->query($sql, __LINE__,__FILE__);
- $sql = "UPDATE phpgw_sitemgr_content SET state = " .
SITEMGR_STATE_ARCHIVE . " WHERE state = " . SITEMGR_STATE_PREUNPUBLISH . " AND
block_id = $block_id";;
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_content '
+ . ' SET state = ' .
SITEMGR_STATE_PUBLISH
+ . ' WHERE state = ' .
SITEMGR_STATE_PREPUBLISH
+ . ' AND block_id = ' .
intval($block_id), __LINE__, __FILE__);
+
+ $this->db->query('UPDATE phpgw_sitemgr_content '
+ . ' SET state = ' .
SITEMGR_STATE_ARCHIVE
+ . ' WHERE state = ' .
SITEMGR_STATE_PREUNPUBLISH
+ . ' AND block_id = ' .
intval($block_id), __LINE__, __FILE__);
}
function reactivate($block_id)
{
- $sql = "UPDATE phpgw_sitemgr_content SET state
= " . SITEMGR_STATE_DRAFT . " WHERE state = " . SITEMGR_STATE_ARCHIVE . " AND
block_id = $block_id";;
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_content '
+ . ' SET state = ' . SITEMGR_STATE_DRAFT
+ . ' WHERE state = ' .
SITEMGR_STATE_ARCHIVE
+ . ' AND block_id = ' .
intval($block_id), __LINE__, __FILE__);
}
- }
\ No newline at end of file
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sitemgr/inc/class.Content_SO.inc.php, 1.14,
nomail <=