[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sitemgr/inc/class.Categories_SO.inc.php, 1.19
From: |
nomail |
Subject: |
[Phpgroupware-cvs] sitemgr/inc/class.Categories_SO.inc.php, 1.19 |
Date: |
Wed, 21 Jul 2004 01:22:53 +0200 |
Update of /sitemgr/inc
Modified Files:
Branch:
class.Categories_SO.inc.php
date: 2004/07/20 23:22:53; author: skwashd; state: Exp; lines: +72 -41
Log Message:
merge from 16
=====================================================================
Index: sitemgr/inc/class.Categories_SO.inc.php
diff -u sitemgr/inc/class.Categories_SO.inc.php:1.18
sitemgr/inc/class.Categories_SO.inc.php:1.19
--- sitemgr/inc/class.Categories_SO.inc.php:1.18 Sat May 31 03:53:51 2003
+++ sitemgr/inc/class.Categories_SO.inc.php Tue Jul 20 23:22:53 2004
@@ -17,23 +17,26 @@
{
$states = $GLOBALS['Common_BO']->visiblestates;
}
- $sql = "SELECT cat_id from
phpgw_sitemgr_categories_state WHERE cat_id = $cat_id AND state IN (" .
implode(',',$states) . ")";
+ $this->db->query('SELECT cat_id from
phpgw_sitemgr_categories_state '
+ . ' WHERE cat_id = ' . intval($cat_id)
+ . ' AND state IN ( ' . implode(',',$states) .
')', __LINE__, __FILE__);
- $this->db->query($sql,__LINE__,__FILE__);
return $this->db->next_record();
}
function getChildrenIDList($parent)
{
- //TODO add a return_id_array function to the API
category class
- $cats =
$this->cats->return_array('all','',False,'','','',False,$parent);
+ $cats =
$this->cats->return_array('all','',False,'','','cat_data',False,$parent,-1,'id');
$result = array();
- while (list(,$subs) = @each($cats))
+ if(is_array($cats))
{
- $subs_id_list[] = $subs['id'];
+ foreach($cats as $ign => $subs)
+ {
+ $result[] = $subs['id'];
+ }
}
- return $subs_id_list;
+ return $result;
}
function addCategory($name, $description, $parent = False)
@@ -47,18 +50,20 @@
'old_parent' => $parent
);
$cat_id = $this->cats->add($data);
- $sql = "INSERT INTO phpgw_sitemgr_categories_state
(cat_id) VALUES ($cat_id)";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('INSERT INTO
phpgw_sitemgr_categories_state (cat_id)'
+ . ' VALUES (' . intval($cat_id) . ')',
__LINE__, __FILE__);
return $cat_id;
}
function removeCategory($cat_id)
{
+ $cat_id = intval($cat_id);
$this->cats->delete($cat_id,False,True);
- $sql = "DELETE FROM phpgw_sitemgr_categories_lang WHERE
cat_id = $cat_id";
- $this->db->query($sql, __LINE__,__FILE__);
- $sql = "DELETE FROM phpgw_sitemgr_categories_state
WHERE cat_id = $cat_id";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('DELETE FROM
phpgw_sitemgr_categories_lang'
+ . " WHERE cat_id = $cat_id", __LINE__,
__FILE__);
+
+ $this->db->query('DELETE FROM
phpgw_sitemgr_categories_state'
+ . " WHERE cat_id = $cat_id", __LINE__,
__FILE__);
return True;
}
@@ -68,34 +73,47 @@
(
'name' => $cat_info->name,
'descr' => $cat_info->description,
- 'data' => (int) $cat_info->sort_order,
+ 'data' =>
intval($cat_info->sort_order),
'access' => 'public',
'id' => $cat_info->id,
'parent' => $cat_info->parent,
- 'old_parent' => $cat_info->old_parent
+ 'old_parent' => $cat_info->old_parent
);
$this->cats->edit($data);
- $sql = "UPDATE phpgw_sitemgr_categories_state SET state
= " . $cat_info->state . " WHERE cat_id = " . $cat_info->id;
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_categories_state'
+ . ' SET state = ' .
intval($cat_info->state)
+ . ' WHERE cat_id = ' .
intval($cat_info->id), __LINE__,__FILE__);
}
function saveCategoryLang($cat_id, $cat_name, $cat_description,
$lang)
{
- $this->db->query("SELECT * FROM
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id' and lang='$lang'",
__LINE__,__FILE__);
+ $this->db->query('SELECT * FROM
phpgw_sitemgr_categories_lang '
+ . 'WHERE cat_id=' . intval($cat_id)
+ ." AND lang='" .
$this->db->db_addslashes($lang) . "'", __LINE__,__FILE__);
if ($this->db->next_record())
{
- $this->db->query("UPDATE
phpgw_sitemgr_categories_lang SET name='$cat_name',
description='$cat_description' WHERE cat_id='$cat_id' and lang='$lang'",
__LINE__,__FILE__);
+ $this->db->query('UPDATE
phpgw_sitemgr_categories_lang '
+ . "SET name='" .
$this->db->db_addslashes($cat_name) . "', "
+ . " description='" .
$this->db->db_addslashes($cat_description) . "' "
+ . 'WHERE cat_id=' .
intval($cat_id)
+ . " AND lang='" .
$this->db->db_addslashes($lang) . "'", __LINE__,__FILE__);
}
else
{
- $this->db->query("INSERT INTO
phpgw_sitemgr_categories_lang (cat_id,lang,name,description) VALUES
('$cat_id','$lang','$cat_name','$cat_description')", __LINE__,__FILE__);
+ $this->db->query('INSERT INTO
phpgw_sitemgr_categories_lang (cat_id,lang,name,description) '
+ . 'VALUES (' . intval($cat_id)
. ','
+ . "'" .
$this->db->db_addslashes($lang) . "',"
+ . "'" .
$this->db->db_addslashes($cat_name) . "',"
+ . "'" .
$this->db->db_addslashes($cat_description)
+ . "')", __LINE__,__FILE__);
}
}
function getlangarrayforcategory($cat_id)
{
$retval = array();
- $this->db->query("SELECT lang FROM
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
+ $this->db->query('SELECT lang FROM
phpgw_sitemgr_categories_lang'
+ . ' WHERE cat_id=' . intval($cat_id),
__LINE__, __FILE__);
while ($this->db->next_record())
{
$retval[] = $this->db->f('lang');
@@ -109,21 +127,26 @@
if (is_array($cat))
{
- $cat_info =
CreateObject('sitemgr.Category_SO', True);
- $cat_info->id = $cat[0]['id'];
- //$cat_info->name =
stripslashes($cat[0]['name']);
+ $cat_info =
CreateObject('sitemgr.Category_SO', True);
+ $cat_info->id = $cat[0]['id'];
+ //$cat_info->name =
stripslashes($cat[0]['name']);
$cat_info->sort_order = $cat[0]['data'];
- //$cat_info->description =
stripslashes($cat[0]['description']);
- $cat_info->parent =
$cat[0]['parent'];
- $cat_info->depth =
$cat[0]['level'];
- $cat_info->root =
$cat[0]['main'];
+ //$cat_info->description=
stripslashes($cat[0]['description']);
+ $cat_info->parent = $cat[0]['parent'];
+ $cat_info->depth = $cat[0]['level'];
+ $cat_info->root = $cat[0]['main'];
- $this->db->query("SELECT state FROM
phpgw_sitemgr_categories_state WHERE cat_id=$cat_id");
+ $this->db->query('SELECT state FROM
phpgw_sitemgr_categories_state'
+ . ' WHERE cat_id=' .
intval($cat_id), __LINE__, __FILE__);
$cat_info->state = $this->db->next_record() ?
$this->db->f('state') : 0;
if ($lang)
{
- $this->db->query("SELECT * FROM
phpgw_sitemgr_categories_lang WHERE cat_id=$cat_id and lang='$lang'");
+ $this->db->query('SELECT * FROM
phpgw_sitemgr_categories_lang'
+ . ' WHERE cat_id=' .
intval($cat_id)
+ . " AND lang='" .
$this->db->db_addslashes($lang)
+ . "'", __LINE__,
__FILE__);
+
if ($this->db->next_record())
{
$cat_info->name =
$this->db->f('name');
@@ -139,7 +162,8 @@
//if there is no lang argument we return the
content in whatever languages turns up first
else
{
- $this->db->query("SELECT * FROM
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
+ $this->db->query('SELECT * FROM
phpgw_sitemgr_categories_lang'
+ . ' WHERE cat_id=' .
intval($cat_id), __LINE__, __FILE__);
if ($this->db->next_record())
{
$cat_info->name =
$this->db->f('name');
@@ -162,28 +186,35 @@
function removealllang($lang)
{
- $sql = "DELETE FROM phpgw_sitemgr_categories_lang WHERE
lang='$lang'";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('DELETE FROM
phpgw_sitemgr_categories_lang '
+ . "WHERE lang='" .
$this->db->db_addslashes($lang), __LINE__, __FILE__);
}
function migratealllang($oldlang,$newlang)
{
- $sql = "UPDATE phpgw_sitemgr_categories_lang SET
lang='$newlang' WHERE lang='$oldlang'";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_categories_lang'
+ . " SET lang='" .
$this->db->db_addslashes($newlang) . "'"
+ . " WHERE lang='" .
$this->db->db_addslashes($oldlang) . "'", __LINE__,__FILE__);
}
function commit($cat_id)
{
- $sql = "UPDATE phpgw_sitemgr_categories_state SET state
= " . SITEMGR_STATE_PUBLISH . " WHERE state = " . SITEMGR_STATE_PREPUBLISH . "
AND cat_id = $cat_id";
- $this->db->query($sql, __LINE__,__FILE__);
- $sql = "UPDATE phpgw_sitemgr_categories_state SET state
= " . SITEMGR_STATE_ARCHIVE . " WHERE state = " . SITEMGR_STATE_PREUNPUBLISH .
" AND cat_id = $cat_id";;
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_categories_state'
+ . ' SET state = ' .
SITEMGR_STATE_PUBLISH
+ . ' WHERE state = ' .
SITEMGR_STATE_PREPUBLISH
+ . ' AND cat_id = ' . intval($cat_id),
__LINE__, __FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_categories_state
'
+ . ' SET state = ' .
SITEMGR_STATE_ARCHIVE
+ . ' WHERE state = ' .
SITEMGR_STATE_PREUNPUBLISH
+ . ' AND cat_id = ' . intval($cat_id),
__LINE__, __FILE__);
}
function reactivate($cat_id)
{
- $sql = "UPDATE phpgw_sitemgr_categories_state SET state
= " . SITEMGR_STATE_DRAFT . " WHERE state = " . SITEMGR_STATE_ARCHIVE . " AND
cat_id = $cat_id";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_categories_state'
+ . ' SET state = ' . SITEMGR_STATE_DRAFT
+ . ' WHERE state = ' .
SITEMGR_STATE_ARCHIVE
+ . ' AND cat_id = ' . intval($cat_id),
__LINE__, __FILE__);
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sitemgr/inc/class.Categories_SO.inc.php, 1.19,
nomail <=