[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9319] property: dimb acl
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9319] property: dimb acl |
Date: |
Tue, 08 May 2012 17:49:09 +0000 |
Revision: 9319
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9319
Author: sigurdne
Date: 2012-05-08 17:49:08 +0000 (Tue, 08 May 2012)
Log Message:
-----------
property: dimb acl
Modified Paths:
--------------
trunk/property/inc/class.sodimb_role_user.inc.php
trunk/property/inc/class.soinvoice.inc.php
trunk/property/inc/class.uidimb_role_user.inc.php
trunk/property/js/portico/ajax_dimb_role_user.js
trunk/property/templates/base/dimb_role_user.xsl
Modified: trunk/property/inc/class.sodimb_role_user.inc.php
===================================================================
--- trunk/property/inc/class.sodimb_role_user.inc.php 2012-05-08 14:25:06 UTC
(rev 9318)
+++ trunk/property/inc/class.sodimb_role_user.inc.php 2012-05-08 17:49:08 UTC
(rev 9319)
@@ -26,6 +26,7 @@
* @version $Id$
*/
+ phpgw::import_class('phpgwapi.datetime');
class property_sodimb_role_user
{
@@ -34,7 +35,7 @@
function __construct()
{
- $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->account_id = (int)
$GLOBALS['phpgw_info']['user']['account_id'];
$this->db = & $GLOBALS['phpgw']->db;
$this->db2 = clone($this->db);
$this->join = & $this->db->join;
@@ -45,6 +46,9 @@
function read($data)
{
+ $query_start =
phpgwapi_datetime::date_to_timestamp($data['query_start']);
+ $query_end =
phpgwapi_datetime::date_to_timestamp($data['query_end']);
+
$dimb_id = (int) $data['dimb_id'];
if(isset($data['user_id']) && $data['user_id'])
{
@@ -78,7 +82,16 @@
$where = 'AND';
}
+ if($query_start)
+ {
+ $filtermethod .= "{$where} active_from <
$query_start";
+ }
+ if($query_end)
+ {
+ $filtermethod .= "{$where} (active_to >
$query_end OR active_to = 0)";
+ }
+
$sql = "SELECT fm_ecodimb_role_user.id, fm_ecodimb.id
as ecodimb, user_id,role_id, active_from, active_to, default_user,
fm_ecodimb_role.name as role"
. " FROM fm_ecodimb_role_user"
. " {$this->join} fm_ecodimb ON fm_ecodimb.id =
fm_ecodimb_role_user.ecodimb"
@@ -173,10 +186,100 @@
public function edit($data)
{
- _debug_array($data);
- die();
- return $values;
- }
+ $active_from =
phpgwapi_datetime::date_to_timestamp($data['active_from']);
+ $active_to =
phpgwapi_datetime::date_to_timestamp($data['active_to']);
+ $delete = isset($data['delete']) &&
is_array($data['delete']) ? $data['delete'] : array();
+ $default_user = isset($data['default_user']) &&
is_array($data['default_user']) ? $data['default_user'] : array();
+ $alter_date = isset($data['alter_date']) &&
is_array($data['alter_date']) ? $data['alter_date'] : array();
+ $add = isset($data['add']) &&
is_array($data['add']) ? $data['add'] : array();
+ $this->db->transaction_begin();
+ $c_default_user = 0;
+ foreach($default_user as $id)
+ {
+ if( !in_array($id, $delete) )
+ {
+ $this->db->query("UPDATE
fm_ecodimb_role_user SET default_user = 1 WHERE id =
'{$id}'",__LINE__,__FILE__);
+ $c_default_user ++;
+ }
+ }
+
+ unset($id);
+
+ $c_alter_date = 0;
+ foreach($alter_date as $id)
+ {
+ if( !in_array($id, $delete) )
+ {
+ $value_set = array();
+ if($active_from)
+ {
+ $value_set['active_from'] =
$active_from;
+ }
+ if($active_to)
+ {
+ $value_set['active_to'] =
$active_to;
+ }
+
+ if($value_set)
+ {
+ $value_set =
$this->db->validate_update($value_set);
+ $this->db->query("UPDATE
fm_ecodimb_role_user SET {$value_set} WHERE id = '{$id}'",__LINE__,__FILE__);
+ unset($value_set);
+ }
+ $c_alter_date ++;
+ }
+ }
+ unset($id);
+
+ foreach($add as $info)
+ {
+ $user_arr = explode('_', $info);
+ $value_set = array
+ (
+ 'ecodimb' => $user_arr[0],
+ 'role_id' => $user_arr[1],
+ 'user_id' => $user_arr[2],
+ 'default_user' => false,
+ 'active_from' => $active_from ?
$active_from : time(),
+ 'active_to' => $active_to ?
$active_to : 0,
+ 'created_on' => time(),
+ 'created_by' => $this->account_id
+ );
+
+ $sql = 'INSERT INTO fm_ecodimb_role_user (' .
implode(',', array_keys($value_set)) . ') VALUES (' .
$this->db->validate_insert(array_values($value_set)) . ')';
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ $ok = false;
+ if($this->db->transaction_commit())
+ {
+ $ok = true;
+ foreach($delete as $id)
+ {
+ $this->db->query('UPDATE
fm_ecodimb_role_user SET expired_on =' . time() . " , expired_by =
{$this->account_id} WHERE id = '{$id}'",__LINE__,__FILE__);
+ }
+
+ if($delete)
+ {
+ phpgwapi_cache::message_set(lang('%1
roles deleted', count($delete)), 'message');
+ }
+ if($c_alter_date)
+ {
+ phpgwapi_cache::message_set(lang('%1
dates altered', $c_alter_date), 'message');
+ }
+ if($add)
+ {
+ phpgwapi_cache::message_set(lang('%1
roles added', count($add)), 'message');
+ }
+
+ if($c_default_user)
+ {
+ phpgwapi_cache::message_set(lang('%1
roles set at default', $c_default_user), 'message');
+ }
+ }
+
+ return $ok;
+ }
}
Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php 2012-05-08 14:25:06 UTC (rev
9318)
+++ trunk/property/inc/class.soinvoice.inc.php 2012-05-08 17:49:08 UTC (rev
9319)
@@ -1045,15 +1045,15 @@
{
$dimb = (int) $dimb;
$filter_dimb = $dimb ? "AND ecodimb = {$dimb}"
: '';
- $this->db->query("SELECT user_id FROM
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id = 1
{$filter_dimb} AND expired_on IS NULL");
+ $this->db->query("SELECT user_id FROM
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id = 1
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time(). ' AND
(active_to > ' . time() . ' OR active_to = 0)');
$this->db->next_record();
$this->role['is_janitor'] =
!!$this->db->f('user_id');
- $this->db->query("SELECT user_id FROM
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id = 2
{$filter_dimb} AND expired_on IS NULL");
+ $this->db->query("SELECT user_id FROM
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id = 2
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time(). ' AND
(active_to > ' . time() . ' OR active_to = 0)');
$this->db->next_record();
$this->role['is_supervisor'] =
!!$this->db->f('user_id');
- $this->db->query("SELECT user_id FROM
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id = 3
{$filter_dimb} AND expired_on IS NULL");
+ $this->db->query("SELECT user_id FROM
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id = 3
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time(). ' AND
(active_to > ' . time() . ' OR active_to = 0)');
$this->db->next_record();
$this->role['is_budget_responsible'] =
!!$this->db->f('user_id');
@@ -1075,9 +1075,11 @@
$filter_dimb = $dimb ? "AND ecodimb = {$dimb}" : '';
$role_id = (int) $role_id;
$sql = "SELECT DISTINCT account_lid,account_lastname,
account_firstname FROM fm_ecodimb_role_user"
- ." {$this->db->join} phpgw_accounts ON
fm_ecodimb_role_user.user_id = phpgw_accounts.account_id"
- ." WHERE role_id = {$role_id} {$filter_dimb} AND
expired_on IS NULL"
- ." ORDER BY account_lastname ASC, account_firstname
ASC";
+ . " {$this->db->join} phpgw_accounts ON
fm_ecodimb_role_user.user_id = phpgw_accounts.account_id"
+ . " WHERE role_id = {$role_id} {$filter_dimb} AND
expired_on IS NULL"
+ . ' AND active_from < ' . time()
+ . ' AND (active_to > ' . time() . ' OR active_to = 0)'
+ . " ORDER BY account_lastname ASC, account_firstname
ASC";
//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
Modified: trunk/property/inc/class.uidimb_role_user.inc.php
===================================================================
--- trunk/property/inc/class.uidimb_role_user.inc.php 2012-05-08 14:25:06 UTC
(rev 9318)
+++ trunk/property/inc/class.uidimb_role_user.inc.php 2012-05-08 17:49:08 UTC
(rev 9319)
@@ -255,6 +255,8 @@
'update_action'
=> self::link(array('menuaction' => 'property.uidimb_role_user.edit'))
);
+ $GLOBALS['phpgw']->jqcal->add_listener('query_start');
+ $GLOBALS['phpgw']->jqcal->add_listener('query_end');
$GLOBALS['phpgw']->jqcal->add_listener('active_from');
$GLOBALS['phpgw']->jqcal->add_listener('active_to');
@@ -285,10 +287,11 @@
$user_id = phpgw::get_var('user_id', 'int');
$dimb_id = phpgw::get_var('dimb_id', 'int');
$role_id = phpgw::get_var('role_id', 'int');
- $query = phpgw::get_var('query');
+ $query_start = phpgw::get_var('query_start');
+ $query_end = phpgw::get_var('query_end');
// $this->bo->allrows = true;
- $values = $this->bo->read(array('user_id' => $user_id,
'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query' => $query));
+ $values = $this->bo->read(array('user_id' => $user_id,
'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query_start' => $query_start,
'query_end' => $query_end));
foreach($values as &$entry)
{
@@ -353,6 +356,10 @@
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
$result['receipt'] = $receipt;
}
+ else
+ {
+ $result['receipt'] = array();
+ }
return $result;
}
else
Modified: trunk/property/js/portico/ajax_dimb_role_user.js
===================================================================
--- trunk/property/js/portico/ajax_dimb_role_user.js 2012-05-08 14:25:06 UTC
(rev 9318)
+++ trunk/property/js/portico/ajax_dimb_role_user.js 2012-05-08 17:49:08 UTC
(rev 9319)
@@ -22,8 +22,6 @@
});
$("#acl_form").live("submit", function(e){
- return;
-
e.preventDefault();
var thisForm = $(this);
var submitBnt = $(thisForm).find("input[type='submit']");
@@ -46,7 +44,7 @@
if(obj.status == "updated")
{
$(submitBnt).val("Lagret");
- var oArgs =
{menuaction:'property.uidimb_role_user.query', dimb_id:$("#dimb_id").val(),
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query:$("#query").val()};
+ var oArgs =
{menuaction:'property.uidimb_role_user.query', dimb_id:$("#dimb_id").val(),
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query_start:$("#query_start").val(),query_end:$("#query_end").val()};
execute_async(myDataTable_0,oArgs);
}
else
@@ -82,8 +80,6 @@
}
$("#receipt").html(htmlString);
-
- update_form_values(line_id,
voucher_id_orig);
}
}
});
@@ -93,8 +89,9 @@
function update_dimb_role_user_table()
{
- var oArgs = {menuaction:'property.uidimb_role_user.query',
dimb_id:$("#dimb_id").val(),
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query:$("#query").val()};
+ var oArgs = {menuaction:'property.uidimb_role_user.query',
dimb_id:$("#dimb_id").val(),
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query_start:$("#query_start").val(),query_end:$("#query_end").val()};
execute_async(myDataTable_0, oArgs);
+ $("#receipt").html('');
}
Modified: trunk/property/templates/base/dimb_role_user.xsl
===================================================================
--- trunk/property/templates/base/dimb_role_user.xsl 2012-05-08 14:25:06 UTC
(rev 9318)
+++ trunk/property/templates/base/dimb_role_user.xsl 2012-05-08 17:49:08 UTC
(rev 9319)
@@ -24,18 +24,6 @@
<style type="text/css">
#box { width: 200px; height: 5px; background: blue; }
//select { width: 200px; }
- #voucher_id_filter { width: 800px; }
- #dim_b { width: 200px; }
- #dim_e { width: 200px; }
- #period { width: 200px; }
- #periodization { width: 200px; }
- #periodization_start { width: 200px; }
- #process_code { width: 200px; }
- #tax_code { width: 200px; }
- #approve_as { width: 200px; }
- #_oppsynsmannid { width: 200px; }
- #_saksbehandlerid { width: 200px; }
- #_budsjettansvarligid { width: 200px; }
.row_on,.th_bright
{
background-color: #CCEEFF;
@@ -112,8 +100,10 @@
<td>
<xsl:value-of select="php:function('lang', 'role')" />
</td>
- <td>
+ <td colspan = "2" align = "center">
<xsl:value-of select="php:function('lang', 'search')" />
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="php:function('lang', 'date')" />
</td>
</tr>
<tr id="filters">
@@ -133,9 +123,12 @@
</select>
</td>
<td>
- <input type="text" name="query" id="query"/>
+ <input type="text" name="query_start" id="query_start"
size = "10"/>
</td>
<td>
+ <input type="text" name="query_end" id="query_end" size
= "10"/>
+ </td>
+ <td>
<xsl:variable name="lang_search"><xsl:value-of
select="php:function('lang', 'Search')" /></xsl:variable>
<input type="button" id = "search" name="search"
value="{$lang_search}" title = "{$lang_search}" />
</td>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9319] property: dimb acl,
Sigurd Nes <=