phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.23, 1.1.2.24 class.b


From: Joseph Engo <address@hidden>
Subject: [Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.23, 1.1.2.24 class.base.php, 1.1.1.1.2.22, 1.1.1.1.2.23 class.history.php, 1.1.2.3, 1.1.2.4 class.phpgw.php, 1.1.1.1.2.34, 1.1.1.1.2.35
Date: Sat, 15 Nov 2003 04:09:09 +0000

Update of /cvsroot/phpgroupware/api
In directory subversions:/tmp/cvs-serv12408/api

Modified Files:
      Tag: proposal-branch
        class.account_mgr.php class.base.php class.history.php 
        class.phpgw.php 
Log Message:
- Added login / logout history
  Creating the XSLT for this was even more of a bitch then the normal history 
ones :P
- For some ODD reason, using ##REQUIRED## in the "doc array" will make PHP run 
out of memory ... need to talk to Seek3r about WTF this could be


Index: class.account_mgr.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.account_mgr.php,v
retrieving revision 1.1.2.23
retrieving revision 1.1.2.24
diff -C2 -d -r1.1.2.23 -r1.1.2.24
*** class.account_mgr.php       14 Nov 2003 08:23:57 -0000      1.1.2.23
--- class.account_mgr.php       15 Nov 2003 04:09:06 -0000      1.1.2.24
***************
*** 51,60 ****
        );
  
! /*    $functions['edit']    = array(
                'type'         => 'public',
                'title'        => 'Edit user',
                'abstract'     => 'Edit user account',
                'params'       => array(
!                       'account_id'                => array('type' => 'int', 
'default' => '##REQUIRED##', 'desc' => 'Account ID'),
                        'account_lid'               => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'Login ID'),
                        'account_firstname'         => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'First Name'),
--- 51,60 ----
        );
  
!       $functions['edit']    = array(
                'type'         => 'public',
                'title'        => 'Edit user',
                'abstract'     => 'Edit user account',
                'params'       => array(
!                       'account_id'                => array('type' => 'int', 
'default' => '##NOTSET##', 'desc' => 'Account ID'),
                        'account_lid'               => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'Login ID'),
                        'account_firstname'         => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'First Name'),
***************
*** 64,68 ****
                )
        );
- */
  
        $functions['view']    = array(
--- 64,67 ----
***************
*** 71,75 ****
                'abstract'     => 'View user account',
                'params'       => array(
!                       'account_id'               => array('type' => 'int', 
'default' => '##REQUIRD##', 'desc' => 'Account ID number')
                )
        );
--- 70,74 ----
                'abstract'     => 'View user account',
                'params'       => array(
!                       'account_id'               => array('type' => 'int', 
'default' => '##NOTSET##', 'desc' => 'Account ID number')
                )
        );
***************
*** 80,88 ****
                'abstract'     => 'Delete user account',
                'params'       => array(
!                       'account_id'               => array('type' => 'int', 
'default' => '##REQUIRD##', 'desc' => 'Account ID number'),
                        'answer'                   => array('type' => 'any', 
'default' => '##NOTSET##',  'desc' => 'Answer to yes no dialog')
                )
        );
  
        $GLOBALS['docs']['api']['classes']['api_account_mgr'] = array(
                'abstract'  => 'User account management',
--- 79,96 ----
                'abstract'     => 'Delete user account',
                'params'       => array(
!                       'account_id'               => array('type' => 'int', 
'default' => '##NOTSET##', 'desc' => 'Account ID number'),
                        'answer'                   => array('type' => 'any', 
'default' => '##NOTSET##',  'desc' => 'Answer to yes no dialog')
                )
        );
  
+       $functions['login_history'] = array(
+               'type'              => 'public',
+               'title'             => 'User login history',
+               'abstract'          => 'Show users login history',
+               'params'            => array(
+                       'account_id' => array('type' => 'int', 'default' => 
'##REQUIRED##', 'desc' => 'Account ID number')
+               )
+       );
+ 
        $GLOBALS['docs']['api']['classes']['api_account_mgr'] = array(
                'abstract'  => 'User account management',
***************
*** 446,448 ****
--- 454,478 ----
                        return $result;
                }
+ 
+               function login_history()
+               {
+                       $args = new safe_args();
+                       $args->set('account_id', '##REQUIRED##', 'int');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ 
+                       $GLOBALS['phpgw_xml_apinode']->add_node(lang('Login 
history for 
%s',$GLOBALS['phpgw']->accounts->cross_reference((int)$args['account_id'])),'title');
+                       $history                = createObject('api_history');
+                       $history->actions       = array(
+                               'C' => lang('Login'),
+                               'D' => lang('Logout')
+                       );
+                       $history->field_desc    = array(
+                               'ip_address' => 'IP Address'
+                       );
+                       $result['history_data'] = $history->get('api.sessions.' 
. $args['account_id']);
+                       $result['action_type']  = 'login_history';
+ 
+                       return $result;
+               }
        }
+ 

Index: class.base.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.base.php,v
retrieving revision 1.1.1.1.2.22
retrieving revision 1.1.1.1.2.23
diff -C2 -d -r1.1.1.1.2.22 -r1.1.1.1.2.23
*** class.base.php      14 Nov 2003 08:23:57 -0000      1.1.1.1.2.22
--- class.base.php      15 Nov 2003 04:09:06 -0000      1.1.1.1.2.23
***************
*** 209,212 ****
--- 209,224 ----
                function logout()
                {
+                       // I didn't want to put this in interface, since it 
would just end up being duplicate code.
+                       $history             = createObject('api_history');
+                       $account             = 
createObject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
+ 
+                       $history->account_id = $account->account_id;
+                       $ip_address          = 
($_SERVER['HTTP_X_FORWARDED_FOR'] ? $_SERVER['HTTP_X_FORWARDED_FOR'] : 
$_SERVER['REMOTE_ADDR']);
+                       $new_data = array(
+                               'ip_address' => $ip_address,
+                               'sessionid'  => session_id()
+                       );
+                       $history->set('api.sessions.' . 
$account->account_id,$new_data,array(' ',' '),'D');
+ 
                        $GLOBALS['phpgw']->interface->logout();
                }

Index: class.history.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.history.php,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** class.history.php   14 Nov 2003 03:26:17 -0000      1.1.2.3
--- class.history.php   15 Nov 2003 04:09:06 -0000      1.1.2.4
***************
*** 135,138 ****
--- 135,150 ----
                }
  
+               function record_count()
+               {
+                       $args = new safe_args();
+                       $args->set('location','##REQUIRED##','string');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ 
+                       $this->db->query("select count(id) from phpgw_history 
where history_location='" . $args['location'] . "'",__LINE__,__FILE__);
+                       $this->db->next_record();
+ 
+                       return $this->db->f(0);
+               }
+ 
                // FIXME: Something needs to be added to make sure this can NOT 
be called from a browser no matter what (jengo)
                function clear()

Index: class.phpgw.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.phpgw.php,v
retrieving revision 1.1.1.1.2.34
retrieving revision 1.1.1.1.2.35
diff -C2 -d -r1.1.1.1.2.34 -r1.1.1.1.2.35
*** class.phpgw.php     14 Nov 2003 08:23:57 -0000      1.1.1.1.2.34
--- class.phpgw.php     15 Nov 2003 04:09:06 -0000      1.1.1.1.2.35
***************
*** 83,88 ****
                                {
                                        $this->auth = createobject('api_auth');
!                                       
if($this->auth->authenticate($GLOBALS['phpgw_data']['api']['phpgw_user'], 
$GLOBALS['phpgw_data']['api']['phpgw_pass']))
                                        {
                                                
$this->session->create($GLOBALS['phpgw_data']['api']['phpgw_user']);
                                                
unset($GLOBALS['phpgw_data']['api']['op']);
--- 83,98 ----
                                {
                                        $this->auth = createobject('api_auth');
!                                       if 
($this->auth->authenticate($GLOBALS['phpgw_data']['api']['phpgw_user'], 
$GLOBALS['phpgw_data']['api']['phpgw_pass']))
                                        {
+                                               $account             = 
createObject('api_accounts',$GLOBALS['phpgw_data']['api']['phpgw_user']);
+                                               $history             = 
createObject('api_history');
+                                               $history->account_id = 
$account->account_id;
+                                               $ip_address          = 
($_SERVER['HTTP_X_FORWARDED_FOR'] ? $_SERVER['HTTP_X_FORWARDED_FOR'] : 
$_SERVER['REMOTE_ADDR']);
+                                               $new_data = array(
+                                                       'ip_address' => 
$ip_address,
+                                                       'sessionid'  => 
session_id()
+                                               );
+                                               $history->set('api.sessions.' . 
$history->account_id,$new_data,array());
+ 
                                                
$this->session->create($GLOBALS['phpgw_data']['api']['phpgw_user']);
                                                
unset($GLOBALS['phpgw_data']['api']['op']);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]