[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] demo index.php inc/class.bodemo.inc.php inc/cla...
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] demo index.php inc/class.bodemo.inc.php inc/cla... |
Date: |
Wed, 15 Nov 2006 14:52:25 +0000 |
CVSROOT: /sources/phpgroupware
Module name: demo
Changes by: Sigurd Nes <sigurdne> 06/11/15 14:52:25
Modified files:
. : index.php
inc : class.bodemo.inc.php class.sodemo.inc.php
class.uidemo.inc.php
setup : default_records.inc.php
templates/base : demo.xsl
Log message:
improved acl-demo
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/demo/index.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/inc/class.bodemo.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/inc/class.sodemo.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/inc/class.uidemo.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/setup/default_records.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/templates/base/demo.xsl?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
Patches:
Index: index.php
===================================================================
RCS file: /sources/phpgroupware/demo/index.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- index.php 10 Nov 2006 15:05:23 -0000 1.1.1.1
+++ index.php 15 Nov 2006 14:52:25 -0000 1.2
@@ -7,7 +7,7 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package hrm
- * @version $Id: index.php,v 1.1.1.1 2006/11/10 15:05:23 sigurdne Exp $
+ * @version $Id: index.php,v 1.2 2006/11/15 14:52:25 sigurdne Exp $
*/
/**
@@ -28,7 +28,7 @@
include('../header.inc.php');
-
$start_page=$GLOBALS['phpgw_info']['user']['preferences'][$currentapp]['default_start_page'];
+
$start_page=(isset($GLOBALS['phpgw_info']['user']['preferences'][$currentapp]['default_start_page'])?$GLOBALS['phpgw_info']['user']['preferences'][$currentapp]['default_start_page']:'');
if ($start_page)
{
Index: inc/class.bodemo.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/class.bodemo.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.bodemo.inc.php 10 Nov 2006 15:05:23 -0000 1.1.1.1
+++ inc/class.bodemo.inc.php 15 Nov 2006 14:52:25 -0000 1.2
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package hrm
* @subpackage demo
- * @version $Id: class.bodemo.inc.php,v 1.1.1.1 2006/11/10 15:05:23
sigurdne Exp $
+ * @version $Id: class.bodemo.inc.php,v 1.2 2006/11/15 14:52:25 sigurdne
Exp $
*/
/**
@@ -110,6 +110,10 @@
$this->cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
}
+ function check_perms($rights, $required)
+ {
+ return ($rights & $required);
+ }
function read()
{
Index: inc/class.sodemo.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/class.sodemo.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.sodemo.inc.php 10 Nov 2006 15:05:23 -0000 1.1.1.1
+++ inc/class.sodemo.inc.php 15 Nov 2006 14:52:25 -0000 1.2
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package hrm
* @subpackage demo
- * @version $Id: class.sodemo.inc.php,v 1.1.1.1 2006/11/10 15:05:23
sigurdne Exp $
+ * @version $Id: class.sodemo.inc.php,v 1.2 2006/11/15 14:52:25 sigurdne
Exp $
*/
/**
@@ -55,6 +55,21 @@
$allrows =
(isset($data['allrows'])?$data['allrows']:'');
}
+ $table = 'phpgw_demo_table';
+ $where= 'WHERE';
+ $filtermethod = '';
+ if (is_array($this->grants))
+ {
+ while (list($user) = each($this->grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where ( $table.user_id IN("
. implode(',',$public_user_list) . "))";
+ $where= 'AND';
+ }
+
+
if ($order)
{
$ordermethod = " order by $order $sort";
@@ -64,18 +79,16 @@
$ordermethod = ' order by name asc';
}
- $table = 'phpgw_demo_table';
-
$querymethod = '';
if($query)
{
$query = ereg_replace("'",'',$query);
$query = ereg_replace('"','',$query);
- $querymethod = " WHERE name $this->like
'%$query%'";
+ $querymethod = " $where name $this->like
'%$query%'";
}
- $sql = "SELECT * FROM $table $querymethod";
+ $sql = "SELECT * FROM $table $filtermethod
$querymethod";
$this->db2->query($sql,__LINE__,__FILE__);
$this->total_records = $this->db2->num_rows();
@@ -94,7 +107,9 @@
$demo_info[] = array
(
'id' => $this->db->f('id'),
- 'name' =>
stripslashes($this->db->f('name'))
+ 'name' =>
stripslashes($this->db->f('name')),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'grants' =>
(int)$this->grants[$this->db->f('user_id')]
);
}
@@ -117,7 +132,8 @@
$values['town'] =
stripslashes($this->db->f('town'));
$values['zip'] =
$this->db->f('zip');
$values['entry_date'] =
$this->db->f('entry_date');
- $values['owner'] =
$this->db->f('owner');
+ $values['user_id'] =
$this->db->f('user_id');
+ $values['grants'] =
(int)$this->grants[$this->db->f('user_id')];
}
return $values;
}
Index: inc/class.uidemo.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/class.uidemo.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.uidemo.inc.php 10 Nov 2006 15:05:23 -0000 1.1.1.1
+++ inc/class.uidemo.inc.php 15 Nov 2006 14:52:25 -0000 1.2
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package hrm
* @subpackage demo
- * @version $Id: class.uidemo.inc.php,v 1.1.1.1 2006/11/10 15:05:23
sigurdne Exp $
+ * @version $Id: class.uidemo.inc.php,v 1.2 2006/11/15 14:52:25 sigurdne
Exp $
*/
/**
@@ -91,26 +91,67 @@
while (is_array($demo_info) && list(,$entry) =
each($demo_info))
{
+
+ if($this->bo->check_perms($entry['grants'],
PHPGW_ACL_READ))
+ {
+ $link_view
= $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
$this->currentapp.'.uidemo.view', 'demo_id'=> $entry['id'],'output'=>$output));
+ $lang_view_demo_text =
lang('view the demo');
+ $text_view
= lang('view');
+ }
+ else
+ {
+ $link_view
= '';
+ $lang_view_demo_text = '';
+ $text_view
= '';
+ }
+
+ if($this->bo->check_perms($entry['grants'],
PHPGW_ACL_EDIT))
+ {
+ $link_edit
= $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
$this->currentapp.'.uidemo.edit', 'demo_id'=> $entry['id'],'output'=>$output));
+ $lang_edit_demo_text =
lang('edit the demo');
+ $text_edit
= lang('edit');
+ }
+ else
+ {
+ $link_edit
= '';
+ $lang_edit_demo_text = '';
+ $text_edit
= '';
+ }
+
+ if($this->bo->check_perms($entry['grants'],
PHPGW_ACL_DELETE))
+ {
+ $link_delete
= $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
$this->currentapp.'.uidemo.delete', 'demo_id'=>
$entry['id'],'output'=>$output));
+ $text_delete
= lang('delete');
+ $lang_delete_demo_text =
lang('delete the demo');
+ }
+ else
+ {
+ $link_delete
= '';
+ $text_delete
= '';
+ $lang_delete_demo_text = '';
+ }
+
$content[] = array
(
'name'
=> $entry['name'],
- 'link_edit'
=> $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
$this->currentapp.'.uidemo.edit', 'demo_id'=> $entry['id'],'output'=>$output)),
- 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
$this->currentapp.'.uidemo.delete', 'demo_id'=>
$entry['id'],'output'=>$output)),
- 'link_view'
=> $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
$this->currentapp.'.uidemo.view', 'demo_id'=> $entry['id'],'output'=>$output)),
- 'lang_view_demo_text' =>
lang('view the demo'),
- 'lang_edit_demo_text' =>
lang('edit the demo'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete'),
- 'lang_delete_demo_text' =>
lang('delete the demo'),
+ 'link_edit'
=> $link_edit,
+ 'link_delete'
=> $link_delete,
+ 'link_view'
=> $link_view,
+ 'lang_view_demo_text' =>
$lang_view_demo_text,
+ 'lang_edit_demo_text' =>
$lang_edit_demo_text,
+ 'text_view'
=> $text_view,
+ 'text_edit'
=> $text_edit,
+ 'text_delete'
=> $text_delete,
+ 'lang_delete_demo_text' =>
$lang_delete_demo_text,
);
}
//_debug_array($content);
+ $acl_edit = $this->acl->check('.demo_location',
PHPGW_ACL_EDIT);
+ $acl_delete = $this->acl->check('.demo_location',
PHPGW_ACL_DELETE);
$table_header[] = array
(
-
'sort_name' =>
$this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
@@ -121,9 +162,9 @@
'cat_id' => $this->cat_id,
'allrows' => $this->allrows)
)),
- 'lang_delete' => lang('delete'),
- 'lang_edit' => lang('edit'),
'lang_view' => lang('view'),
+ 'lang_edit' =>
(isset($acl_edit)?lang('edit'):''),
+ 'lang_delete' =>
(isset($acl_delete)?lang('view'):''),
);
if(!$this->allrows)
Index: setup/default_records.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/setup/default_records.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- setup/default_records.inc.php 10 Nov 2006 15:05:23 -0000 1.1.1.1
+++ setup/default_records.inc.php 15 Nov 2006 14:52:25 -0000 1.2
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package demo
* @subpackage setup
- * @version $Id: default_records.inc.php,v 1.1.1.1 2006/11/10 15:05:23
sigurdne Exp $
+ * @version $Id: default_records.inc.php,v 1.2 2006/11/15 14:52:25
sigurdne Exp $
*/
@@ -20,4 +20,17 @@
$GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_acl_location
WHERE appname = 'demo'");
$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl_location
(appname,id, descr) VALUES ('demo', '.', 'Top')");
$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl_location
(appname,id, descr, allow_grant) VALUES ('demo', '.demo_location', 'Demo
location',1)");
- $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_demo_table
(name,address,zip,town, remark,entry_date) VALUES ('demo name', 'demo address',
'12345','Demo Town', 'Remark', " . time() . ")");
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT max(account_id) as
account_id from phpgw_accounts WHERE account_type = 'u'");
+ $GLOBALS['phpgw_setup']->oProc->next_record();
+ $account_id = $GLOBALS['phpgw_setup']->oProc->f('account_id');
+
+ $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_demo_table
(name,address,zip,town, remark,entry_date,user_id) VALUES ('demo name', 'demo
address', '12345','Demo Town', 'Remark', " . time() . ", '$account_id')");
+ $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_acl WHERE
acl_appname = 'demo'");
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT account_id from
phpgw_accounts WHERE account_lid = 'Default' AND account_type = 'g'");
+ $GLOBALS['phpgw_setup']->oProc->next_record();
+ $account_id = $GLOBALS['phpgw_setup']->oProc->f('account_id');
+ $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl
(acl_appname,acl_location, acl_account,acl_rights, acl_grantor) VALUES
('demo','run', '$account_id', '1', NULL)");
+ $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl
(acl_appname,acl_location, acl_account,acl_rights, acl_grantor) VALUES
('demo','.demo_location', '$account_id', '15', NULL)");
+ $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl
(acl_appname,acl_location, acl_account,acl_rights, acl_grantor) VALUES
('demo','.demo_location', '$account_id', '15', '$account_id')");
+ unset($account_id);
Index: templates/base/demo.xsl
===================================================================
RCS file: /sources/phpgroupware/demo/templates/base/demo.xsl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- templates/base/demo.xsl 10 Nov 2006 15:05:23 -0000 1.1.1.1
+++ templates/base/demo.xsl 15 Nov 2006 14:52:25 -0000 1.2
@@ -1,4 +1,4 @@
-<!-- $Id: demo.xsl,v 1.1.1.1 2006/11/10 15:05:23 sigurdne Exp $ -->
+<!-- $Id: demo.xsl,v 1.2 2006/11/15 14:52:25 sigurdne Exp $ -->
<xsl:template name="app_data">
<xsl:choose>
@@ -57,10 +57,10 @@
<a href="{$sort_name}"><xsl:value-of
select="lang_name"/></a>
</td>
<td class="th_text" width="5%" align="center">
- <xsl:value-of select="lang_edit"/>
+ <xsl:value-of select="lang_view"/>
</td>
<td class="th_text" width="5%" align="center">
- <xsl:value-of select="lang_view"/>
+ <xsl:value-of select="lang_edit"/>
</td>
<td class="th_text" width="5%" align="center">
<xsl:value-of select="lang_delete"/>
@@ -87,22 +87,29 @@
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
-
<td align="left">
<xsl:value-of select="name"/>
</td>
<td align="center">
- <xsl:variable
name="link_edit"><xsl:value-of select="link_edit"/></xsl:variable>
- <a href="{$link_edit}"
onMouseover="window.status='{$lang_edit_place_text}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_edit"/></a>
- </td>
- <td align="center">
<xsl:variable
name="link_view"><xsl:value-of select="link_view"/></xsl:variable>
<a href="{$link_view}"
onMouseover="window.status='{$lang_view_place_text}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_view"/></a>
</td>
+ <xsl:choose>
+ <xsl:when test="link_edit != ''">
+ <td align="center">
+ <xsl:variable
name="link_edit"><xsl:value-of select="link_edit"/></xsl:variable>
+ <a href="{$link_edit}"
onMouseover="window.status='{$lang_edit_place_text}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_edit"/></a>
+ </td>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="link_edit != ''">
<td align="center">
<xsl:variable
name="link_delete"><xsl:value-of select="link_delete"/></xsl:variable>
<a href="{$link_delete}"
onMouseover="window.status='{$lang_delete_place_text}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_delete"/></a>
</td>
+ </xsl:when>
+ </xsl:choose>
</tr>
</xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] demo index.php inc/class.bodemo.inc.php inc/cla...,
Sigurd Nes <=