[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] news_admin inc/class.boacl.inc.php inc/class.bo...
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] news_admin inc/class.boacl.inc.php inc/class.bo... |
Date: |
Sat, 19 Aug 2006 13:38:27 +0000 |
CVSROOT: /cvsroot/phpgroupware
Module name: news_admin
Changes by: Dave Hall <skwashd> 06/08/19 13:38:26
Modified files:
inc : class.boacl.inc.php class.bonews.inc.php
class.sonews.inc.php class.uinews.inc.php
Removed files:
inc : class.soacl.inc.php class.uiacl.inc.php
templates/base : acl.tpl
Log message:
more bug fixes, code cleanup and generally make this a bit leaner
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/news_admin/inc/class.boacl.inc.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/news_admin/inc/class.bonews.inc.php?cvsroot=phpgroupware&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/news_admin/inc/class.sonews.inc.php?cvsroot=phpgroupware&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/news_admin/inc/class.uinews.inc.php?cvsroot=phpgroupware&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/news_admin/inc/class.soacl.inc.php?cvsroot=phpgroupware&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/news_admin/inc/class.uiacl.inc.php?cvsroot=phpgroupware&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/news_admin/templates/base/acl.tpl?cvsroot=phpgroupware&r1=1.1&r2=0
Patches:
Index: inc/class.boacl.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/news_admin/inc/class.boacl.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- inc/class.boacl.inc.php 4 Aug 2005 03:54:31 -0000 1.3
+++ inc/class.boacl.inc.php 19 Aug 2006 13:38:26 -0000 1.4
@@ -7,125 +7,99 @@
* under the terms of the GNU General Public License as published by
the *
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
- * --------------------------------------------
*
\**************************************************************************/
- /* $Id: class.boacl.inc.php,v 1.3 2005/08/04 03:54:31 skwashd Exp $ */
+ /* $Id: class.boacl.inc.php,v 1.4 2006/08/19 13:38:26 skwashd Exp $ */
+ /**
+ * Access Controls class
+ *
+ * @package news_admin
+ */
class boacl
{
- var $acl;
- var $start = 0;
- var $query = '';
- var $sort = '';
- var $total = 0;
- var $accounts;
- var $cats;
-
- var $debug;
- var $use_session = False;
-
- function boacl($session=False)
- {
- $this->so = CreateObject('news_admin.soacl');
- $this->accounts =
$GLOBALS['phpgw']->accounts->get_list();
- $this->debug = False;
- //all this is only needed when called from uiacl. not
from ui,
- if($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- foreach(array('start','query','sort','order')
as $var)
- {
- if (isset($_POST[$var]))
- {
- $this->$var = $_POST[$var];
- }
- elseif (isset($_GET[$var]))
- {
- $this->$var = $_GET[$var];
- }
- }
- $this->save_sessiondata();
- $this->catbo =
createobject('phpgwapi.categories');
-// $main_cat = array(array('id' => 0, 'name' =>
lang('Global news')));
-// $this->cats =
array_merge($main_cat,$this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True));
- $this->cats =
$this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True);
- }
- $this->permissions = $this->get_permissions(True);
- }
-
- function save_sessiondata()
- {
- $data = array(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'limit' => $this->limit,
- );
- if($this->debug) { echo '<br>Read:';
_debug_array($data); }
-
$GLOBALS['phpgw']->session->appsession('session_data','news_admin_acl',$data);
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','news_admin_acl');
- if($this->debug) { echo '<br>Read:';
_debug_array($data); }
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->limit = $data['limit'];
- }
-
- function get_rights($cat_id)
- {
- return $this->so->get_rights('L'.$cat_id);
- }
-
- function is_permitted($cat_id,$right)
- {
- return $this->permissions['L'.$cat_id] & $right;
- }
-
+ /**
+ * @var bool $debug enable debugging in this class
+ */
+ var $debug = false;
+
+ /**
+ * @var array list of permissions for the current user
+ * @access private
+ */
+ var $_permissions;
+
+ /**
+ * @constructor
+ */
+ function boacl()
+ {
+ $this->_permissions = $this->_get_permissions();
+ }
+
+ /**
+ * Checks if the user has the required rights level
+ *
+ * @param int $cat the category to be checked
+ * @param int $right the rights level the user must have
+ * @return bool does the user have the required rights level
+ */
+ function is_permitted($cat_id, $right)
+ {
+ return !! ($this->_permissions['L'.$cat_id] & $right);
+ }
+
+ /**
+ * Checks to see if the user has read access to a category
+ *
+ * @param int $cat_id the category to check
+ * @return bool does the user have read access?
+ */
function is_readable($cat_id)
{
return $this->is_permitted($cat_id,PHPGW_ACL_READ);
}
+ /**
+ * Checks to see if the user has write access to a category
+ *
+ * @param int $cat_id the category to check
+ * @return bool does the user have write access?
+ */
function is_writeable($cat_id)
{
return $this->is_permitted($cat_id,PHPGW_ACL_ADD);
}
- function set_rights($cat_id,$read,$write)
+ /**
+ * Get the access permissions for current user
+ *
+ * @access private
+ * @internal /This could probably be improved, I am open to
suggestions, I just hate mod'ing the API ACL class - skwashd 200608
+ */
+ function _get_permissions()
+ {
+ $rights = array();
+ $read_rights =
$GLOBALS['phpgw']->acl->get_location_list('news_admin', PHPGW_ACL_READ);
+ $add_rights =
$GLOBALS['phpgw']->acl->get_location_list('news_admin', PHPGW_ACL_ADD);
+
+ foreach ( $read_rights as $loc )
{
- $readcat = $read ? $read : array();
- $writecat = $write ? $write : array();
+ $rights[$loc] = PHPGW_ACL_READ;
+ }
- $this->so->remove_location('L' . $cat_id);
- foreach($this->accounts as $ign => $account)
+ foreach ( $add_rights as $loc )
{
- $account_id = $account['account_id'];
- //write implies read
- $rights = in_array($account_id, $writecat)
- ? (PHPGW_ACL_READ |
PHPGW_ACL_ADD)
- :
(in_array($account_id,$readcat) ? PHPGW_ACL_READ : 0 );
- if ($rights)
+ if ( !isset($rights) )
{
-
$GLOBALS['phpgw']->acl->add_repository('news_admin',
-
'L'.$cat_id,
-
$account_id,
-
$rights );
+ $rights[$loc] = PHPGW_ACL_ADD;
}
+ else
+ {
+ $rights[$loc] |= PHPGW_ACL_ADD;
}
}
-
- //access permissions for current user
- function get_permissions($inc_groups = False)
- {
- return
$this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'],
$inc_groups);
+ return $rights;
}
}
\ No newline at end of file
+?>
Index: inc/class.bonews.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/news_admin/inc/class.bonews.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- inc/class.bonews.inc.php 16 Aug 2006 05:06:59 -0000 1.8
+++ inc/class.bonews.inc.php 19 Aug 2006 13:38:26 -0000 1.9
@@ -7,81 +7,177 @@
* under the terms of the GNU General Public License as published by
the *
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
- * --------------------------------------------
*
- * This program was sponsered by Golden Glair productions
*
- * http://www.goldenglair.com
*
\**************************************************************************/
- /* $Id: class.bonews.inc.php,v 1.8 2006/08/16 05:06:59 skwashd Exp $ */
+ /* $Id: class.bonews.inc.php,v 1.9 2006/08/19 13:38:26 skwashd Exp $ */
+ /**
+ * phpGroupWare News Management Logic layer
+ *
+ * @package news_admin
+ */
class bonews
{
- var $sonews;
+ /**
+ * @var object $acl access control object
+ */
var $acl;
- var $start = 0;
- var $query = '';
- var $sort = '';
+
+ /**
+ * @var int $cat_id the category to limit selection to
+ */
var $cat_id;
+
+ /**
+ * @var bool $debug enable debugging
+ */
+ var $debug = false;
+
+ /**
+ * @param string $sort the sort order
+ */
+ var $order = '';
+
+ /**
+ * @var object $sonews storage layer
+ */
+ var $sonews;
+
+ /**
+ * @param string $sort the field to sort on
+ */
+ var $sort = '';
+
+ /**
+ * @var int $start listing
+ */
+ var $start = 0;
+
+ /**
+ * @var int $total number of stories found
+ */
var $total = 0;
- var $debug;
- var $use_session = False;
- var $unixtimestampmax;
+
+ /**
+ * @var bool $use_session is the session cache being used to
store data?
+ */
+ var $use_session = false;
+
+ /**
+ * @var int maximum unix timestamp
+ * @todo change this around 19 Jan 2038 03:14:07 GMT
+ */
+ var $unixtimestampmax = 2147483647;
var $dateformat;
- function bonews($session=False)
+ /**
+ * @constructor
+ */
+ function bonews($session = false)
{
$this->acl = CreateObject('news_admin.boacl');
$this->sonews = CreateObject('news_admin.sonews');
- $this->accounts =
$GLOBALS['phpgw']->accounts->get_list();
- $this->debug = False;
if($session)
{
- $this->read_sessiondata();
+ $this->_read_sessiondata();
$this->use_session = True;
foreach(array('start','query','sort','order','cat_id') as $var)
{
- $this->$var = get_var($var,
array('POST', 'GET'), '');
+ $this->$var = $_REQUEST[$var];
}
$this->cat_id = $this->cat_id ? $this->cat_id :
'all';
- $this->save_sessiondata();
+ $this->_save_sessiondata();
}
$this->catbo =
createobject('phpgwapi.categories','','news_admin');
$this->cats =
$this->catbo->return_array('all',0,False,'','','cat_name',True);
- //change this around 19 Jan 2038 03:14:07 GMT
- $this->unixtimestampmax = 2147483647;
$this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
}
- function save_sessiondata()
+ /**
+ * Add a news story
+ *
+ * @param array $news the news item to add
+ * @return int the ID of the new story (0 == failure)
+ */
+ function add($news)
{
- $data = array(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'cat_id' => $this->cat_id,
- );
- if($this->debug) { echo '<br>Save:';
_debug_array($data); }
-
$GLOBALS['phpgw']->session->appsession('session_data','news_admin',$data);
+ return $this->acl->is_writeable($news['category']) ?
$this->sonews->add($news) : 0;
}
- function read_sessiondata()
+ /**
+ * Delete a news item
+ *
+ * @param int $news_id the story to be deleted
+ */
+ function delete($news_id)
{
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','news_admin');
- if($this->debug) { echo '<br>Read:';
_debug_array($data); }
+ $this->sonews->delete($news_id);
+ }
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
+ /**
+ * Edit a news item
+ *
+ * @param array $news the editted version of the news item
+ * @return bool was the story updated?
+ */
+ function edit($news)
+ {
+ $oldnews = $this->sonews->get_news($news['id']);
+ return ($this->acl->is_writeable($oldnews['category'])
&&
+
$this->acl->is_writeable($news['category'])) ?
+ $this->sonews->edit($news) :
+ false;
}
+ /**
+ * Get a list of most recent news items from any category
(bypasses ACLs)
+ *
+ * @internal this is bad idea and needs to be removed
+ * @deprecated
+ * @param int $limit the maximum number of stories to return
+ * @return array the news stories found
+ */
+ function get_all_public_news($limit = 5)
+ {
+ return $this->sonews->get_all_public_news($limit);
+ }
+
+ /**
+ * Get a single news item
+ *
+ * @param int $news_id the news item sought
+ * @return array the news itme (empty array on failure)
+ */
+ function get_news($news_id)
+ {
+ $news = $this->sonews->get_news($news_id);
+ //echo '<br />BO:<br />'; print_r($news); echo '</pre>';
+ if ($this->acl->is_readable($news['category']))
+ {
+ $this->total = 1;
+ $news['content'] = $news['content'];
+ //echo '<br />BO2:<br />'; print_r($news); echo
'</pre>';
+ return $news;
+ }
+ return false;
+ }
+
+ /**
+ * Get a list of news stories
+ *
+ * @param int $cat the category to take the news items from (0
== all available to the user)
+ * @start int $start the story in the sequence to start at
+ * @param string $order the db field to sort on
+ * @param string $sort "ASC"ending|"DESC"ending
+ * @param int $limit the maximum number of stories to return (0
== no limit)
+ * @param bool $activeonly only return stories which are "active"
+ * @return array the news items (empty array on failure)
+ */
function get_newslist($cat_id, $start=0,
$order='',$sort='',$limit=0,$activeonly=False)
{
- $cats = False;
- if ($cat_id == 'all')
+ $cats = array();
+ if ($cat_id == 0)
{
if(! ($this->cats && is_array($this->cats)) )
{
@@ -105,41 +201,14 @@
$news = $this->sonews->get_newslist($cats,
$start,$order,$sort,$limit,$activeonly,$this->total);
return $news;
}
-
return array();
}
- function get_all_public_news($limit = 5)
- {
- $news = $this->sonews->get_all_public_news($limit);
- foreach($news as $id => $item)
- {
- $news[$id]['content'] = $item['content'];
- }
- return $news;
- }
-
- function delete($news_id)
- {
- $this->sonews->delete($news_id);
- }
-
- function add($news)
- {
- return $this->acl->is_writeable($news['category']) ?
- $this->sonews->add($news) :
- false;
- }
-
- function edit($news)
- {
- $oldnews = $this->sonews->get_news($news['id']);
- return ($this->acl->is_writeable($oldnews['category'])
&&
-
$this->acl->is_writeable($news['category'])) ?
- $this->sonews->edit($news) :
- False;
- }
-
+ /**
+ * Sets the visibility status of a story
+ *
+ * @param array $news a reference to the news story so the date
can be set correctly
+ */
function get_visibility(&$news)
{
$now = time();
@@ -177,8 +246,14 @@
}
}
- //set the begin and end dates
- function set_dates($from,$until,&$news)
+ /**
+ * set the begin and end dates
+ *
+ * @param int $from the unix timestamp the story should be shown
from
+ * @param int $until the unix timestamp the story should be
shown until
+ * @param array the news story
+ */
+ function set_dates($from, $until, &$news)
{
switch($from)
{
@@ -200,21 +275,47 @@
}
}
- function get_news($news_id)
+ /**
+ * Read the values of some basic variable from the session cache
+ *
+ * @access private
+ */
+ function _read_sessiondata()
{
- $news = $this->sonews->get_news($news_id);
- //echo '<br />BO:<br />'; print_r($news); echo '</pre>';
- if ($this->acl->is_readable($news['category']))
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','news_admin');
+ if($this->debug)
{
- $this->total = 1;
- $news['content'] = $news['content'];
- //echo '<br />BO2:<br />'; print_r($news); echo
'</pre>';
- return $news;
+ echo '<br>Read:'; _debug_array($data);
}
- else
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+ /**
+ * Save basic variable values to the session cache
+ *
+ * @access private
+ */
+ function _save_sessiondata()
{
- return False;
+ $data = array(
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'cat_id' => $this->cat_id,
+ );
+
+ if($this->debug)
+ {
+ echo '<br>Save:'; _debug_array($data);
}
+
+
$GLOBALS['phpgw']->session->appsession('session_data','news_admin',$data);
}
}
?>
Index: inc/class.sonews.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/news_admin/inc/class.sonews.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- inc/class.sonews.inc.php 16 Aug 2006 05:06:59 -0000 1.8
+++ inc/class.sonews.inc.php 19 Aug 2006 13:38:26 -0000 1.9
@@ -7,97 +7,31 @@
* under the terms of the GNU General Public License as published by
the *
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
- * --------------------------------------------
*
- * This program was sponsered by Golden Glair productions
*
- * http://www.goldenglair.com
*
\**************************************************************************/
- /* $Id: class.sonews.inc.php,v 1.8 2006/08/16 05:06:59 skwashd Exp $ */
+ /* $Id: class.sonews.inc.php,v 1.9 2006/08/19 13:38:26 skwashd Exp $ */
class sonews
{
+ /**
+ * @var $db reference to the global databse object
+ */
var $db;
+ /**
+ * @constructor
+ */
function sonews()
{
- $this->db = $GLOBALS['phpgw']->db;
- }
-
-
- function get_newslist($cat_id, $start,
$order,$sort,$limit=0,$activeonly,&$total)
- {
- if ($order)
- {
- $ordermethod = ' ORDER BY ' .
$this->db->db_addslashes($order) . ' ' . $this->db->db_addslashes($sort);
- }
- else
- {
- $ordermethod = ' ORDER BY news_date DESC';
- }
-
- if (is_array($cat_id))
- {
- $filter = "IN (" . implode(',',$cat_id) . ')';
- }
- else
- {
- $filter = "=" . intval($cat_id);
- }
-
- $sql = 'SELECT * FROM phpgw_news WHERE news_cat ' .
$filter;
- if ($activeonly)
- {
- $now = time();
- $sql .= " AND news_begin<=$now AND
news_end>=$now";
- }
- $sql .= $ordermethod;
-
- $this->db->query($sql,__LINE__,__FILE__);
- $total = $this->db->num_rows();
-
$this->db->limit_query($sql,$start,__LINE__,__FILE__,$limit);
-
- $news = array();
-
- while ($this->db->next_record())
- {
- $news[$this->db->f('news_id')] = array
- (
- 'subject' =>
$this->db->f('news_subject', True),
- 'submittedby' =>
$this->db->f('news_submittedby'),
- 'date' =>
$this->db->f('news_date'),
- 'id' =>
$this->db->f('news_id'),
- 'begin' =>
$this->db->f('news_begin'),
- 'end' =>
$this->db->f('news_end'),
- 'teaser' =>
$this->db->f('news_teaser', True),
- 'content' =>
$this->db->f('news_content',True),
- 'is_html' =>
($this->db->f('is_html') ? True : False),
- );
- }
- return $news;
- }
-
- function get_all_public_news($limit=5)
- {
- $now = time();
- $this->db->limit_query("SELECT * FROM phpgw_news WHERE
news_begin<=$now AND news_end>=$now ORDER BY news_date
DESC",0,__LINE__,__FILE__,$limit);
-
- $news = array();
-
- while ($this->db->next_record())
- {
- $news[$this->db->f('news_id')] = array(
- 'subject' =>
$this->db->f('news_subject', True),
- 'submittedby' =>
$this->db->f('news_submittedby'),
- 'date' =>
$this->db->f('news_date'),
- 'id' =>
$this->db->f('news_id'),
- 'teaser' =>
$this->db->f('news_teaser', True),
- 'content' =>
$this->db->f('news_content', True),
- 'is_html' =>
($this->db->f('is_html') ? True : False),
- );
- }
- return $news;
+ $this->db =& $GLOBALS['phpgw']->db;
}
+ /**
+ * Add a news story
+ *
+ * @param array $news the news item to add
+ * @return int the ID of the new story (0 == failure)
+ */
function add($news)
{
$sql = 'INSERT INTO phpgw_news '
@@ -117,6 +51,22 @@
return $this->db->get_last_insert_id('phpgw_news',
'news_id');
}
+ /**
+ * Delete a news item
+ *
+ * @param int $news_id the story to be deleted
+ */
+ function delete($news_id)
+ {
+ $this->db->query('DELETE FROM phpgw_news WHERE
news_id=' . intval($news_id) ,__LINE__,__FILE__);
+ }
+
+ /**
+ * Edit a news item
+ *
+ * @param array $news the editted version of the news item
+ * @return bool was the story updated?
+ */
function edit($news)
{
//echo '<br />SO-save:<pre>'; print_r($news); echo
'</pre>';
@@ -129,13 +79,23 @@
. 'news_cat=' . intval($news['category']) . ', '
. 'is_html=' . ($news['is_html'] ? 1 : 0) .' '
. 'WHERE news_id=' .
intval($news['id']),__LINE__,__FILE__);
+ return !!$this->db->affected_rows();
}
- function delete($news_id)
+ /**
+ * DEAD FUNCTION
+ */
+ function get_all_public_news($limit=5)
{
- $this->db->query('DELETE FROM phpgw_news WHERE
news_id=' . intval($news_id) ,__LINE__,__FILE__);
+ die('call to : sonews::get_all_public_news');
}
+ /**
+ * Get a single news item
+ *
+ * @param int $news_id the news item sought
+ * @return array the news itme (empty array on failure)
+ */
function get_news($news_id)
{
$this->db->query('SELECT * FROM phpgw_news WHERE
news_id=' . intval($news_id),__LINE__,__FILE__);
@@ -157,31 +117,67 @@
return $item;
}
-// function getlist($order,$sort,$cat_id)
-// {
-// if ($order)
-// {
-// $ordermethod = ' ORDER BY ' .
$this->db->db_addslashes($order) . ' ' . $this->db->db_addslashes($sort);
-// }
-// else
-// {
-// $ordermethod = ' ORDER BY news_date DESC';
-// }
-
-// $this->db->query('SELECT * FROM phpgw_news WHERE
news_cat=' . intval($cat_id) . $ordermethod,__LINE__,__FILE__);
-// while ($this->db->next_record())
-// {
-// $items[] = array(
-// 'id' =>
$this->db->f('news_id'),
-// 'date' =>
$this->db->f('news_date'),
-// 'subject' =>
$this->db->f('news_subject'),
-// 'submittedby' =>
$this->db->f('news_submittedby'),
-// 'content' =>
$this->db->f('news_content'),
-// 'status' =>
$this->db->f('news_status'),
-// 'cat' =>
$this->db->f('news_cat')
-// );
-// }
-// return $items;
-// }
+ /**
+ * Get a list of news stories
+ *
+ * @param int $cat the category to take the news items from (0
== all available to the user)
+ * @start int $start the story in the sequence to start at
+ * @param string $order the db field to sort on
+ * @param string $sort "ASC"ending|"DESC"ending
+ * @param int $limit the maximum number of stories to return (0
== no limit)
+ * @param bool $activeonly only return stories which are "active"
+ * @return array the news items (empty array on failure)
+ */
+ function get_newslist($cat_id, $start,
$order,$sort,$limit=0,$activeonly,&$total)
+ {
+ if ($order)
+ {
+ $ordermethod = ' ORDER BY ' .
$this->db->db_addslashes($order) . ' ' . $this->db->db_addslashes($sort);
+ }
+ else
+ {
+ $ordermethod = ' ORDER BY news_date DESC';
+ }
+ if (is_array($cat_id))
+ {
+ $filter = "IN (" . implode(',',$cat_id) . ')';
+ }
+ else
+ {
+ $filter = "=" . intval($cat_id);
+ }
+
+ $sql = 'SELECT * FROM phpgw_news WHERE news_cat ' .
$filter;
+ if ($activeonly)
+ {
+ $now = time();
+ $sql .= " AND news_begin<=$now AND
news_end>=$now";
+ }
+ $sql .= $ordermethod;
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $total = $this->db->num_rows();
+
$this->db->limit_query($sql,$start,__LINE__,__FILE__,$limit);
+
+ $news = array();
+
+ while ($this->db->next_record())
+ {
+ $news[$this->db->f('news_id')] = array
+ (
+ 'subject' =>
$this->db->f('news_subject', True),
+ 'submittedby' =>
$this->db->f('news_submittedby'),
+ 'date' =>
$this->db->f('news_date'),
+ 'id' =>
$this->db->f('news_id'),
+ 'begin' =>
$this->db->f('news_begin'),
+ 'end' =>
$this->db->f('news_end'),
+ 'teaser' =>
$this->db->f('news_teaser', True),
+ 'content' =>
$this->db->f('news_content',True),
+ 'is_html' =>
($this->db->f('is_html') ? True : False),
+ );
+ }
+ return $news;
+ }
}
+?>
Index: inc/class.uinews.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/news_admin/inc/class.uinews.inc.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- inc/class.uinews.inc.php 16 Aug 2006 05:07:00 -0000 1.43
+++ inc/class.uinews.inc.php 19 Aug 2006 13:38:26 -0000 1.44
@@ -7,14 +7,9 @@
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
- * -------------------------------------------- *
- * The original version of this program *
- * was sponsered by Golden Glair productions - http://www.goldenglair.com *
- * *
- * Many enhancements were sponsored by ecotrader.net *
\**************************************************************************/
-/* $Id: class.uinews.inc.php,v 1.43 2006/08/16 05:07:00 skwashd Exp $ */
+/* $Id: class.uinews.inc.php,v 1.44 2006/08/19 13:38:26 skwashd Exp $ */
class uinews
{
@@ -613,7 +608,7 @@
)
);
- $news = $this->bo->get_all_public_news(-1);
+ $news = $this->bo->get_newslist(0, 0, '', '', -1);
$i = 0;
foreach($news as $item)
Index: inc/class.soacl.inc.php
===================================================================
RCS file: inc/class.soacl.inc.php
diff -N inc/class.soacl.inc.php
--- inc/class.soacl.inc.php 4 Aug 2005 03:54:31 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-<?php
-
/**************************************************************************\
- * phpGroupWare - News
*
- * http://www.phpgroupware.org
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
- * --------------------------------------------
*
-
\**************************************************************************/
-
- /* $Id: class.soacl.inc.php,v 1.3 2005/08/04 03:54:31 skwashd Exp $ */
-
- class soacl
- {
- var $db;
-
- function soacl()
- {
- $this->db = $GLOBALS['phpgw']->db;
- }
-
- function get_rights($location)
- {
- $result = array();
- $sql = "select acl_account, acl_rights from phpgw_acl
where acl_appname = 'news_admin' and acl_location = '$location'";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $result[$this->db->f('acl_account')] =
$this->db->f('acl_rights');
- }
- return $result;
- }
-
- function remove_location($location)
- {
- $sql = "delete from phpgw_acl where
acl_appname='news_admin' and acl_location='$location'";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- function get_permissions($user, $inc_groups)
- {
- $groups =
$GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $user);
- $result = array();
- $sql = 'SELECT acl_location, acl_rights FROM phpgw_acl
';
- $sql .= "WHERE acl_appname = 'news_admin' ";
- if($inc_groups)
- {
- $sql .= 'AND acl_account IN('. intval($user);
- $sql .= ($groups ? ',' . implode(',', $groups)
: '');
- $sql .= ')';
- }
- else
- {
- $sql .= 'AND acl_account ='. intval($user);
- }
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $result[$this->db->f('acl_location')] |=
$this->db->f('acl_rights');
- }
- return $result;
- }
- }
\ No newline at end of file
Index: inc/class.uiacl.inc.php
===================================================================
RCS file: inc/class.uiacl.inc.php
diff -N inc/class.uiacl.inc.php
--- inc/class.uiacl.inc.php 15 Aug 2006 03:04:56 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,132 +0,0 @@
-<?php
-
/**************************************************************************\
- * phpGroupWare - News
*
- * http://www.phpgroupware.org
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
- * --------------------------------------------
*
-
\**************************************************************************/
-
- /* $Id: class.uiacl.inc.php,v 1.4 2006/08/15 03:04:56 skwashd Exp $ */
-
- class uiacl
- {
- var $start = 0;
- var $query = '';
- var $sort = '';
- var $order = '';
- var $bo;
- var $accounts;
- var $nextmatchs = '';
- var $rights;
- var $public_functions = array(
- 'acllist' => True,
- );
-
- function uiacl()
- {
- $this->bo = createobject('news_admin.boacl',True);
- $this->accounts =
$GLOBALS['phpgw']->accounts->get_list();
- $this->nextmatchs = createobject('phpgwapi.nextmatchs');
- $this->start = $this->bo->start;
- $this->query = $this->bo->query;
- $this->order = $this->bo->order;
- $this->sort = $this->bo->sort;
- $this->cat_id = $this->bo->cat_id;
- }
-
- function acllist()
- {
- if (!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
- {
- $this->deny();
- }
-
- if ($_POST['btnDone'])
- {
-
$GLOBALS['phpgw']->redirect_link('/admin/index.php');
- }
-
- if ($_POST['btnSave'])
- {
- foreach($_POST['catids'] as $cat_id)
- {
-
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id]);
- }
- }
-
- $GLOBALS['phpgw']->template->set_file('acl', 'acl.tpl');
-
$GLOBALS['phpgw']->template->set_block('acl','cat_list','Cblock');
- $GLOBALS['phpgw']->template->set_var(array(
- 'title' =>
$GLOBALS['phpgw_info']['apps']['news_admin']['title'] . ' - ' . lang('Configure
Access Permissions'),
- 'lang_search' => lang('Search'),
- 'lang_save' => lang('Save'),
- 'lang_done' => lang('Done'),
- 'lang_read' => lang('Read permissions'),
- 'lang_write' => lang('Write permissions'),
- 'lang_implies' => lang('implies read
permission'),
- ));
-
- $left =
$this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=news_admin.uiacl.acllist');
- $right =
$this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=news_admin.uiacl.acllist');
-
- $GLOBALS['phpgw']->template->set_var(array(
- 'left' => $left,
- 'right' => $right,
- 'lang_showing' =>
$this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
- 'th_bg' =>
$GLOBALS['phpgw_info']['theme']['th_bg'],
- 'sort_cat' =>
$this->nextmatchs->show_sort_order(
-
$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=news_admin.uiacl.acllist'
- ),
- 'query' => $this->query,
- ));
-
- if ( is_array($this->bo->cats) )
- {
- foreach ( $this->bo->cats as $cat )
- {
- $this->rights =
$this->bo->get_rights($cat['id']);
-
- $tr_color =
$this->nextmatchs->alternate_row_color($tr_color);
-
$GLOBALS['phpgw']->template->set_var(array(
- 'tr_color' => $tr_color,
- 'catname' => $cat['name'],
- 'catid' => $cat['id'],
- 'read' =>
$this->selectlist(PHPGW_ACL_READ),
- 'write' =>
$this->selectlist(PHPGW_ACL_ADD)
- ));
-
$GLOBALS['phpgw']->template->parse('Cblock','cat_list',True);
- }
- }
-
- $GLOBALS['phpgw']->common->phpgw_header();
- echo parse_navbar();
- $GLOBALS['phpgw']->template->pfp('out','acl');
- }
-
- function selectlist($right)
- {
- reset($this->bo->accounts);
- while (list($null,$account) = each($this->bo->accounts))
- {
- $selectlist .= '<option value="' .
$account['account_id'] . '"';
- if($this->rights[$account['account_id']] &
$right)
- {
- $selectlist .= ' selected="selected"';
- }
- $selectlist .= '>' .
$account['account_firstname'] . ' ' . $account['account_lastname']
-
. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
- }
- return $selectlist;
- }
-
- function deny()
- {
- echo '<p><center><b>'.lang('Access not
permitted').'</b></center>';
- $GLOBALS['phpgw']->common->phpgw_exit(True);
- }
- }
-?>
Index: templates/base/acl.tpl
===================================================================
RCS file: templates/base/acl.tpl
diff -N templates/base/acl.tpl
--- templates/base/acl.tpl 15 Aug 2006 11:42:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-<center>
- <table border="0" cellspacing="2" cellpadding="2" width="60%">
- <tr>
- <td colspan="3" align="center" bgcolor="#c9c9c9"><b>{title}<b/></td>
- </tr>
- <tr>
- <td colspan="3" align="left">
- <table border="0" width="100%">
- <tr>
- {left}
- <td align="center">{lang_showing}</td>
- {right}
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td> </td>
- <td colspan="3" align="right">
- <form method="POST"><input type="text" name="query" value="{query}"
/> <input type="submit" name="btnSearch" value="{lang_search}" /></form>
- </td>
- </tr>
- </table>
- <form method="POST">
- <table border="0" cellspacing="2" cellpadding="2" width="60%">
- <tr bgcolor="{th_bg}" valign="middle" align="center">
- <td>{sort_cat}</td>
- <td>{lang_read}</td>
- <td>{lang_write}<br>({lang_implies})</td>
- </tr>
- <!-- BEGIN cat_list -->
- <tr bgcolor="{tr_color}">
- <td>
- {catname}
- <input type="hidden" name="catids[]" value="{catid}" />
- </td>
- <td align="center"><select multiple="multiple" size="5"
name="inputread[{catid}][]">{read}</select></td>
- <td align="center"><select multiple="multiple" size="5"
name="inputwrite[{catid}][]">{write}</select></td>
- </tr>
- <!-- END cat_list -->
- <tr>
- <td colspan="3" align="center">
- <input type="submit" name="btnSave" value="{lang_save}">
- <input type="submit" name="btnDone" value="{lang_done}">
- </td>
- </tr>
- </table>
- </form>
-</center>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] news_admin inc/class.boacl.inc.php inc/class.bo...,
Dave Hall <=