[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.5, 1.1.2.6 starter.i
From: |
Dan Kuykendall <address@hidden> |
Subject: |
[Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.5, 1.1.2.6 starter.inc.php, 1.1.1.1.2.6, 1.1.1.1.2.7 |
Date: |
Mon, 27 Oct 2003 19:25:36 +0000 |
Update of /cvsroot/phpgroupware/api
In directory subversions:/tmp/cvs-serv14195/api
Modified Files:
Tag: proposal-branch
class.account_mgr.php starter.inc.php
Log Message:
added prevop to the options for when method doesnt exist
Index: class.account_mgr.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.account_mgr.php,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** class.account_mgr.php 27 Oct 2003 08:57:34 -0000 1.1.2.5
--- class.account_mgr.php 27 Oct 2003 19:25:33 -0000 1.1.2.6
***************
*** 1,199 ****
! <?php
!
/**************************************************************************\
! * phpGroupWare
*
! * http://www.phpgroupware.org
*
! * This file written by Joseph Engo <address@hidden> *
! * Copyright (C) 2003 Joseph Engo
*
! *
-------------------------------------------------------------------------*
! * 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$ */
! /* $Source$ */
!
! class api_account_mgr
! {
! function api_account_mgr()
! {
! $appmenu[] = array(
! 'title' => 'Add User',
! 'op' => 'api.account_mgr.create',
! );
! $appmenu[] = array(
! 'title' => 'Show Users',
! 'op' => 'api.account_mgr.show',
! );
! $appmenu[] = array(
! 'title' => 'Add Group',
! 'op' => 'api.group_mgr.create',
! );
! $appmenu[] = array(
! 'title' => 'Show Groups',
! 'op' => 'api.group_mgr.show',
! );
!
$GLOBALS['phpgw_xml_apinode']->add_node($appmenu,'appmenu');
! $GLOBALS['phpgw']->add_xsl('api.account_mgr');
! }
!
! function show()
! {
! $result['accounts'] =
$GLOBALS['phpgw']->accounts->list_repository();
!
! return $result;
! }
!
! function create()
! {
! $args = new safe_args();
! $args->set('create_account_submit', '##NOTSET##',
'string');
! $args->set('account_lid', '##NOTSET##', 'any');
! $args->set('account_firstname', '##NOTSET##', 'any');
! $args->set('account_lastname', '##NOTSET##', 'any');
! $args->set('account_password', '##NOTSET##', 'any');
! $args->set('account_password_confirm', '##NOTSET##',
'any');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $GLOBALS['phpgw']->add_xsl('api.account_mgr');
!
! $result['add_account'] = array(
! 'account_lid' => $args['account_lid'],
! 'account_firstname' =>
$args['account_firstname'],
! 'account_lastname' => $args['account_lastname']
! );
!
! // Yes, this is supposed to be a string, NOT a boolean
value
! if ($args['create_account_submit'] == 'True')
! {
! if (! strlen($args['account_lid']))
! {
!
$result['add_account']['missing_fields']['account_lid'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_firstname']))
! {
!
$result['add_account']['missing_fields']['account_firstname'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_lastname']))
! {
!
$result['add_account']['missing_fields']['account_lastname'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_password']))
! {
!
$result['add_account']['missing_fields']['account_password'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_password_confirm']))
! {
!
$result['add_account']['missing_fields']['account_password_confirm'] = True;
! $missing_fields = True;
! }
! else if ($args['account_password'] !=
$args['account_password_confirm'])
! {
!
$result['add_account']['missing_fields']['account_password'] = True;
!
$result['add_account']['missing_fields']['account_password_confirm'] = True;
! $GLOBALS['msgbox']->add(lang('The
passwords you entered do not match'),__LINE__,__FILE__, 'notice');
!
! }
! else
! {
! // FIXME: This hasn't been tested yet
!
sanitize($args['account_password'],'password');
! }
!
! if ($missing_fields)
! {
! $GLOBALS['msgbox']->add(lang('You
forgot to enter some of the required fields. The missing fields have been
marked with a *'),__LINE__,__FILE__, 'notice');
! }
! else
! {
! $args['account_type'] = 'u';
! $args['account_status'] = 'A';
! $args['account_expires'] =
gmmktime(23,59,59,12,30,2037);
!
! if
($GLOBALS['phpgw']->accounts->create($args))
! {
!
$GLOBALS['msgbox']->add(lang('Account has been created
successfully'),__LINE__,__FILE__, 'notice');
! unset($result);
! }
! }
!
! }
! return $result;
! }
!
! function view()
! {
! $args = new safe_args();
! $args->set('account_id', '##NOTSET##', 'int');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $args['account'] = $args['account_id'];
! $accounts =
CreateObject('api_accounts',$args);
! $result['view_account'] = $accounts->data;
!
! return $result;
! }
!
! function delete()
! {
! $args = new safe_args();
! $args->set('answer', '##NOVAR##', 'any');
! $args->set('account_id', '##REQUIRED##', 'int');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $account_lid =
$GLOBALS['phpgw']->accounts->cross_reference((int)$args['account_id']);
!
! if ($args['account_id'] ==
$GLOBALS['phpgw_data']['user']['id'])
! {
! $GLOBALS['msgbox']->add(lang('You can not
delete your own account'),__LINE__,__FILE__, 'warning');
! return;
! }
!
! if ($account_lid == 'anonymous')
! {
! $GLOBALS['msgbox']->add(lang('You can not
delete the anonymous account'),__LINE__,__FILE__, 'warning');
! return;
! }
!
! if ($args['answer'] == '##NOVAR##')
! {
! $GLOBALS['phpgw']->add_xsl('api.widgets');
! $result['dialog'] = array(
! 'question' => lang('Are you sure you
want to delete the user %s ?',$account_lid),
! 'yes_op' => 'api.account_mgr.delete',
! 'no_op' => 'api.account_mgr.show',
! 'current_inputs' => array(
! 0 => array(
! 'name' => 'account_id',
! 'value' =>
$args['account_id']
! )
! )
! );
!
! $result['delete_account'] = True;
! }
! else if ($args['answer'] == 'Yes')
! {
! if
($GLOBALS['phpgw']->accounts->delete($args['account_id']))
! {
! $GLOBALS['msgbox']->add(lang('The
account %s has been deleted successfully',$account_lid),__LINE__,__FILE__,
'notice');
! }
! else
! {
! $GLOBALS['msgbox']->add(lang('There was
a problem deleting the account %s',$account_lid),__LINE__,__FILE__, 'warning');
! }
! }
!
! return $result;
! }
! }
!
--- 1,203 ----
! <?php
!
/**************************************************************************\
! * phpGroupWare
*
! * http://www.phpgroupware.org
*
! * This file written by Joseph Engo <address@hidden> *
! * Copyright (C) 2003 Joseph Engo
*
! *
-------------------------------------------------------------------------*
! * 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$ */
! /* $Source$ */
!
! $GLOBALS['api_account_mgr_menus_loaded'] = False;
! class api_account_mgr
! {
! function api_account_mgr()
! {
! if(!$GLOBALS['api_account_mgr_menus_loaded'])
! {
! $appmenu[] = array(
! 'title' => 'Add User',
! 'op' => 'api.account_mgr.create',
! );
! $appmenu[] = array(
! 'title' => 'Show Users',
! 'op' => 'api.account_mgr.show',
! );
! $appmenu[] = array(
! 'title' => 'Add Group',
! 'op' => 'api.group_mgr.create',
! );
! $appmenu[] = array(
! 'title' => 'Show Groups',
! 'op' => 'api.group_mgr.show',
! );
!
$GLOBALS['phpgw_xml_apinode']->add_node($appmenu,'appmenu');
! $GLOBALS['phpgw']->add_xsl('api.account_mgr');
! $GLOBALS['api_account_mgr_menus_loaded'] = True;
! }
! }
!
! function show()
! {
! $result['accounts'] =
$GLOBALS['phpgw']->accounts->list_repository();
!
! return $result;
! }
!
! function create()
! {
! $args = new safe_args();
! $args->set('create_account_submit', '##NOTSET##',
'string');
! $args->set('account_lid', '##NOTSET##', 'any');
! $args->set('account_firstname', '##NOTSET##', 'any');
! $args->set('account_lastname', '##NOTSET##', 'any');
! $args->set('account_password', '##NOTSET##', 'any');
! $args->set('account_password_confirm', '##NOTSET##',
'any');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $GLOBALS['phpgw']->add_xsl('api.account_mgr');
!
! $result['add_account'] = array(
! 'account_lid' => $args['account_lid'],
! 'account_firstname' =>
$args['account_firstname'],
! 'account_lastname' => $args['account_lastname']
! );
!
! // Yes, this is supposed to be a string, NOT a boolean
value
! if ($args['create_account_submit'] == 'True')
! {
! if (! strlen($args['account_lid']))
! {
!
$result['add_account']['missing_fields']['account_lid'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_firstname']))
! {
!
$result['add_account']['missing_fields']['account_firstname'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_lastname']))
! {
!
$result['add_account']['missing_fields']['account_lastname'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_password']))
! {
!
$result['add_account']['missing_fields']['account_password'] = True;
! $missing_fields = True;
! }
!
! if (! strlen($args['account_password_confirm']))
! {
!
$result['add_account']['missing_fields']['account_password_confirm'] = True;
! $missing_fields = True;
! }
! else if ($args['account_password'] !=
$args['account_password_confirm'])
! {
!
$result['add_account']['missing_fields']['account_password'] = True;
!
$result['add_account']['missing_fields']['account_password_confirm'] = True;
! $GLOBALS['msgbox']->add(lang('The
passwords you entered do not match'),__LINE__,__FILE__, 'notice');
!
! }
! else
! {
! // FIXME: This hasn't been tested yet
!
sanitize($args['account_password'],'password');
! }
!
! if ($missing_fields)
! {
! $GLOBALS['msgbox']->add(lang('You
forgot to enter some of the required fields. The missing fields have been
marked with a *'),__LINE__,__FILE__, 'notice');
! }
! else
! {
! $args['account_type'] = 'u';
! $args['account_status'] = 'A';
! $args['account_expires'] =
gmmktime(23,59,59,12,30,2037);
!
! if
($GLOBALS['phpgw']->accounts->create($args))
! {
!
$GLOBALS['msgbox']->add(lang('Account has been created
successfully'),__LINE__,__FILE__, 'notice');
! unset($result);
! }
! }
!
! }
! return $result;
! }
!
! function view()
! {
! $args = new safe_args();
! $args->set('account_id', '##NOTSET##', 'int');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $args['account'] = $args['account_id'];
! $accounts =
CreateObject('api_accounts',$args);
! $result['view_account'] = $accounts->data;
!
! return $result;
! }
!
! function delete()
! {
! $args = new safe_args();
! $args->set('answer', '##NOVAR##', 'any');
! $args->set('account_id', '##REQUIRED##', 'int');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $account_lid =
$GLOBALS['phpgw']->accounts->cross_reference((int)$args['account_id']);
!
! if ($args['account_id'] ==
$GLOBALS['phpgw_data']['user']['id'])
! {
! $GLOBALS['msgbox']->add(lang('You can not
delete your own account'),__LINE__,__FILE__, 'warning');
! return;
! }
!
! if ($account_lid == 'anonymous')
! {
! $GLOBALS['msgbox']->add(lang('You can not
delete the anonymous account'),__LINE__,__FILE__, 'warning');
! return;
! }
!
! if ($args['answer'] == '##NOVAR##')
! {
! $GLOBALS['phpgw']->add_xsl('api.widgets');
! $result['dialog'] = array(
! 'question' => lang('Are you sure you
want to delete the user %s ?',$account_lid),
! 'yes_op' => 'api.account_mgr.delete',
! 'no_op' => 'api.account_mgr.show',
! 'current_inputs' => array(
! 0 => array(
! 'name' => 'account_id',
! 'value' =>
$args['account_id']
! )
! )
! );
!
! $result['delete_account'] = True;
! }
! else if ($args['answer'] == 'Yes')
! {
! if
($GLOBALS['phpgw']->accounts->delete($args['account_id']))
! {
! $GLOBALS['msgbox']->add(lang('The
account %s has been deleted successfully',$account_lid),__LINE__,__FILE__,
'notice');
! }
! else
! {
! $GLOBALS['msgbox']->add(lang('There was
a problem deleting the account %s',$account_lid),__LINE__,__FILE__, 'warning');
! }
! }
!
! return $result;
! }
! }
Index: starter.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/starter.inc.php,v
retrieving revision 1.1.1.1.2.6
retrieving revision 1.1.1.1.2.7
diff -C2 -d -r1.1.1.1.2.6 -r1.1.1.1.2.7
*** starter.inc.php 27 Oct 2003 19:12:06 -0000 1.1.1.1.2.6
--- starter.inc.php 27 Oct 2003 19:25:34 -0000 1.1.1.1.2.7
***************
*** 208,215 ****
$result = execmethod($methodname,$inputs);
! /* If the method doesnt exist, then we try and keep the user in
the app and class they requested */
if($result == '##NOMETHOD##')
{
! $methodname =
$GLOBALS['phpgw_data']['flags']['req_app'].'.'.$GLOBALS['phpgw_data']['flags']['req_class'].'.start';
$result = execmethod($methodname,$inputs);
--- 208,223 ----
$result = execmethod($methodname,$inputs);
! /* If the method doesnt exist, then we try and handle the
situation nicely. */
if($result == '##NOMETHOD##')
{
! if(isset($HTTP_SESSION_VARS['phpgw_session']['prevop']))
! {
! $methodname =
$HTTP_SESSION_VARS['phpgw_session']['prevop'];
! }
! else
! {
! /* Otherwise then we try and keep the user in
the app and class they requested */
! $methodname =
$GLOBALS['phpgw_data']['flags']['req_app'].'.'.$GLOBALS['phpgw_data']['flags']['req_class'].'.start';
! }
$result = execmethod($methodname,$inputs);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.5, 1.1.2.6 starter.inc.php, 1.1.1.1.2.6, 1.1.1.1.2.7,
Dan Kuykendall <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] api core_functions.inc.php, 1.1.1.1.2.6, 1.1.1.1.2.7 starter.inc.php, 1.1.1.1.2.5, 1.1.1.1.2.6
- Next by Date:
[Phpgroupware-cvs] api starter.inc.php,1.1.1.1.2.7,1.1.1.1.2.8
- Previous by thread:
[Phpgroupware-cvs] api core_functions.inc.php, 1.1.1.1.2.6, 1.1.1.1.2.7 starter.inc.php, 1.1.1.1.2.5, 1.1.1.1.2.6
- Next by thread:
[Phpgroupware-cvs] api starter.inc.php,1.1.1.1.2.7,1.1.1.1.2.8
- Index(es):