[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sitemgr/inc class.Pages_SO.inc.php,1.12.2.9.4.1
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] sitemgr/inc class.Pages_SO.inc.php,1.12.2.9.4.1 |
Date: |
Tue, 6 Dec 2005 13:08:00 +0100 |
Update of sitemgr/inc
Modified Files:
Branch: skwashd-16-compat
class.Pages_SO.inc.php lines: +5 -0
Log Message:
fix bug #7390
====================================================
Index: sitemgr/inc/class.Pages_SO.inc.php
diff -u sitemgr/inc/class.Pages_SO.inc.php:1.12
sitemgr/inc/class.Pages_SO.inc.php:1.12.2.9.4.1
--- sitemgr/inc/class.Pages_SO.inc.php:1.12 Tue Jan 28 20:00:00 2003
+++ sitemgr/inc/class.Pages_SO.inc.php Tue Dec 6 12:08:33 2005
@@ -8,58 +8,72 @@
$this->db = $GLOBALS['phpgw']->db;
}
- function getPageIDList($cat_id=0)
- {
- if (!$cat_id)
- {
- $sql = 'SELECT page_id FROM phpgw_sitemgr_pages
WHERE 1=1 ORDER BY cat_id, sort_order ASC';
- }
- else
- {
- $sql = 'SELECT page_id FROM phpgw_sitemgr_pages
WHERE cat_id=\'' . $cat_id . '\' ORDER BY sort_order';
- }
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $page_id_list[] = $this->db->f('page_id');
- }
- if (!is_array($page_id_list))
+
+ //if $cats is an array, pages from this list are retrieved,
+ //is $cats is an int, pages from this cat are retrieved,
+ //if $cats is 0 or false, pages from currentcats are retrieved
+ function getPageIDList($cats=False,$states=false)
+ {
+ if (!$states)
+ {
+ $states = $GLOBALS['Common_BO']->visiblestates;
+ }
+
+ $page_id_list = array();
+ $cat_list = (is_array($cats)
+ ? implode(',',$cats)
+ : ($cats
+ ? $cats
+ :
($GLOBALS['Common_BO']->cats->currentcats
+ ?
implode(',',$GLOBALS['Common_BO']->cats->currentcats)
+ : false
+ )
+ )
+ );
+ if ($cat_list)
{
- $page_id_list = array();
+ $sql = "SELECT page_id FROM phpgw_sitemgr_pages
WHERE cat_id IN ($cat_list) ";
+ if ($states)
+ {
+ $sql .= 'AND state in ('.
implode(',',$states) . ')';
+ }
+ $sql .=' ORDER BY cat_id, sort_order ASC';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $page_id_list[] =
$this->db->f('page_id');
+ }
}
return $page_id_list;
}
function addPage($cat_id)
{
- $sql = 'INSERT INTO phpgw_sitemgr_pages (cat_id) VALUES
(\'' . $cat_id . '\')';
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('INSERT INTO phpgw_sitemgr_pages
(cat_id)'
+ . ' VALUES (' . intval($cat_id) . ')',
__LINE__, __FILE__);
return
$this->db->get_last_insert_id('phpgw_sitemgr_pages','page_id');
}
function removePage($page_id)
{
- $sql = 'DELETE FROM phpgw_sitemgr_pages WHERE
page_id=\'' . $page_id . '\'';
- $this->db->query($sql, __LINE__,__FILE__);
- $sql = 'DELETE FROM phpgw_sitemgr_pages_lang WHERE
page_id=\'' . $page_id . '\'';
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('DELETE FROM phpgw_sitemgr_pages'
+ . ' WHERE page_id=' . intval($page_id),
__LINE__, __FILE__);
+
+ $this->db->query('DELETE FROM phpgw_sitemgr_pages_lang'
+ . ' WHERE page_id=' . intval($page_id),
__LINE__, __FILE__);
}
- function pageExists($page_name,$exclude_page_id)
+ //this function should be a deprecated function - IMHO - skwashd
+ function pageExists($page_name, $exclude_page_id='')
{
- $sql = 'SELECT page_id FROM phpgw_sitemgr_pages WHERE
name=\'' . $page_name . '\'';
- if ($exclude_page_id)
+ $page_id = $this->PagetoID($page_name);
+ if($page_id)
{
- $sql .= ' and page_id!=\''. $exclude_page_id .
'\'';
- }
- $this->db->query($sql,__LINE__,__FILE__);
- if ($this->db->next_record())
- {
- return $this->db->f('page_id');
+ return ($page_id != $exclude_page_id ? $page_id
: False);
}
else
{
- return false;
+ return False;
}
}
@@ -67,7 +81,8 @@
function getlangarrayforpage($page_id)
{
$retval = array();
- $this->db->query("SELECT lang FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id'");
+ $this->db->query('SELECT lang FROM
phpgw_sitemgr_pages_lang'
+ . ' WHERE page_id=' . intval($page_id),
__LINE__, __FILE__);
while ($this->db->next_record())
{
$retval[] = $this->db->f('lang');
@@ -77,7 +92,24 @@
function PagetoID($page_name)
{
- $sql = 'SELECT page_id FROM phpgw_sitemgr_pages WHERE
name=\'' . $page_name . '\'';
+ $cats = CreateObject('phpgwapi.categories', -1,
'sitemgr');
+ $cat_list = $cats->return_sorted_array(0, False, '',
'', '', False, CURRENT_SITE_ID);
+
+ if($cat_list)
+ {
+ foreach($cat_list as $null => $val)
+ {
+ $site_cats[] = $val['id'];
+ }
+ }
+
+ $sql = 'SELECT page_id FROM phpgw_sitemgr_pages '
+ . " WHERE name='" .
$this->db->db_addslashes($page_name) . "' ";
+ if($site_cats)
+ {
+ $sql .= 'AND cat_id IN(' . implode(',',
$site_cats) . ')';
+ }
+
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
@@ -89,10 +121,24 @@
}
}
+ function getcatidforpage($page_id)
+ {
+ $this->db->query('SELECT cat_id FROM
phpgw_sitemgr_pages'
+ . ' WHERE page_id = ' . intval($page_id),
__LINE__, __FILE__);
+ if ($this->db->next_record())
+ {
+ return $this->db->f('cat_id');
+ }
+ else
+ {
+ return false;
+ }
+ }
+
function getPage($page_id,$lang=False)
{
- $sql = 'SELECT * FROM phpgw_sitemgr_pages WHERE
page_id=\'' . $page_id . '\'';
- $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT * FROM phpgw_sitemgr_pages'
+ . ' WHERE page_id=' . intval($page_id),
__LINE__, __FILE__);
if ($this->db->next_record())
{
$page = CreateObject('sitemgr.Page_SO', True);
@@ -101,11 +147,14 @@
$page->sort_order = (int)
$this->db->f('sort_order');
$page->name =
stripslashes($this->db->f('name'));
$page->hidden = $this->db->f('hide_page');
+ $page->state = $this->db->f('state');
if ($lang)
{
- $sql = "SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'";
-
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT * FROM
phpgw_sitemgr_pages_lang'
+ . ' WHERE page_id=' .
intval($page_id)
+ . " AND lang='" .
$this->db->db_addslashes($lang) . "'"
+ , __LINE__, __FILE__);
if ($this->db->next_record())
{
@@ -122,8 +171,8 @@
//if there is no lang argument we return the
content in whatever languages turns up first
else
{
- $sql = "SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='" . $page->id . "'";
-
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->query('SELECT * FROM
phpgw_sitemgr_pages_lang'
+ . ' WHERE page_id=' .
intval($page->id), __LINE__, __FILE__);
if ($this->db->next_record())
{
@@ -147,48 +196,81 @@
function savePageInfo($pageInfo)
{
- $sql = 'UPDATE phpgw_sitemgr_pages SET ' .
- 'cat_id=\'' . $pageInfo->cat_id . '\',' .
- 'name=\'' .
$this->db->db_addslashes($pageInfo->name) . '\',' .
- 'sort_order=\'' . (int) $pageInfo->sort_order .
'\',' .
- 'hide_page=\'' . $pageInfo->hidden . '\' ' .
- 'WHERE page_id=\'' . $pageInfo->id . '\'';
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_pages SET '
+ . 'cat_id=' . intval($pageInfo->cat_id)
. ', '
+ . 'name=\'' .
$this->db->db_addslashes($pageInfo->name) . '\', '
+ . 'sort_order=' .
intval($pageInfo->sort_order) . ', '
+ . 'hide_page=' .
intval($pageInfo->hidden) . ', '
+ . 'state=' . intval($pageInfo->state) .
' '
+ . 'WHERE page_id=' .
intval($pageInfo->id) . '', __LINE__, __FILE__);
+
+ //This doesn't really belong here but it is the easiest
way to fix the cat for the page when it is moved
+ $this->db->query('UPDATE phpgw_sitemgr_blocks'
+ . ' SET cat_id = ' .
intval($pageInfo->cat_id)
+ . ' WHERE page_id=' .
intval($pageInfo->id), __LINE__. __FILE__);
return true;
}
function savePageLang($pageInfo,$lang)
{
$page_id = $pageInfo->id;
- $this->db->query("SELECT * FROM
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'",
__LINE__,__FILE__);
+ $this->db->query('SELECT * FROM
phpgw_sitemgr_pages_lang'
+ . ' WHERE page_id=' . intval($page_id)
+ . " AND lang='" .
$this->db->db_addslashes($lang). "'", __LINE__,__FILE__);
if ($this->db->next_record())
{
- $sql = "UPDATE phpgw_sitemgr_pages_lang SET " .
- "title='" .
$this->db->db_addslashes($pageInfo->title) . "'," .
- "subtitle='" .
$this->db->db_addslashes($pageInfo->subtitle) . "' WHERE page_id='$page_id' and
lang='$lang'";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE
phpgw_sitemgr_pages_lang SET '
+ . " title='" .
$this->db->db_addslashes($pageInfo->title) . "',"
+ . " subtitle='" .
$this->db->db_addslashes($pageInfo->subtitle) . "'"
+ . ' WHERE page_id=' .
intval($page_id)
+ . " AND lang='" .
$this->db->db_addslashes($lang) . "'"
+ , __LINE__,__FILE__);
return true;
}
else
{
- $sql = "INSERT INTO phpgw_sitemgr_pages_lang
(page_id,lang,title,subtitle) VALUES ('$page_id','$lang','" .
-
$this->db->db_addslashes($pageInfo->title) . "','" .
-
$this->db->db_addslashes($pageInfo->subtitle) . "')";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('INSERT INTO
phpgw_sitemgr_pages_lang (page_id,lang,title,subtitle)'
+ . ' VALUES ('. intval($page_id)
. ','
+ . "'" .
$this->db->db_addslashes($lang) . "',"
+ . "'" .
$this->db->db_addslashes($pageInfo->title) . "',"
+ . "'" .
$this->db->db_addslashes($pageInfo->subtitle) . "')"
+ , __LINE__,__FILE__);
return true;
}
}
function removealllang($lang)
{
- $sql = "DELETE FROM phpgw_sitemgr_pages_lang WHERE
lang='$lang'";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('DELETE FROM phpgw_sitemgr_pages_lang '
+ . " WHERE lang='" .
$this->db->db_addslashes($lang) . "'", __LINE__, __FILE__);
}
function migratealllang($oldlang,$newlang)
{
- $sql = "UPDATE phpgw_sitemgr_pages_lang SET
lang='$newlang' WHERE lang='$oldlang'";
- $this->db->query($sql, __LINE__,__FILE__);
+ $this->db->query('UPDATE phpgw_sitemgr_pages_lang SET'
+ . " lang='" .
$this->db->db_addslashes($newlang) . "'"
+ . " WHERE lang='" .
$this->db->db_addslashes($oldlang) . "'", __LINE__, __FILE__);
+ }
+
+ function commit($page_id)
+ {
+ $this->db->query('UPDATE phpgw_sitemgr_pages SET'
+ . ' state = ' . SITEMGR_STATE_PUBLISH
+ . ' WHERE state = ' .
SITEMGR_STATE_PREPUBLISH
+ . ' AND page_id = ' . intval($page_id),
__LINE__, __FILE__);
+
+ $this->db->query('UPDATE phpgw_sitemgr_pages SET'
+ . ' state = ' . SITEMGR_STATE_ARCHIVE
+ . ' WHERE state = ' .
SITEMGR_STATE_PREUNPUBLISH
+ . ' AND page_id = ' . intval($page_id),
__LINE__, __FILE__);
+ }
+
+ function reactivate($page_id)
+ {
+ $this->db->query('UPDATE phpgw_sitemgr_pages SET'
+ . ' state = ' . SITEMGR_STATE_DRAFT
+ . ' WHERE state = ' .
SITEMGR_STATE_ARCHIVE
+ . ' AND page_id = ' . intval($page_id),
__LINE__, __FILE__);
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sitemgr/inc class.Pages_SO.inc.php,1.12.2.9.4.1,
skwashd <=