[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/class.base.php, 1.1.1.1.2.28
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/class.base.php, 1.1.1.1.2.28 |
Date: |
Thu, 20 May 2004 15:25:23 -0000 |
Update of /api
Modified Files:
Branch: proposal-branch
class.base.php
date: 2004/04/16 20:59:48; author: seek3r; state: Exp; lines: +136 -110
Log Message:
bringing savannah cvs back up to date with what we were doing on our private
cvs server. We will not be doing dev from this cvs tree
=====================================================================
No syntax errors detected in -
=====================================================================
Index: api/class.base.php
diff -u api/class.base.php:1.1.1.1.2.27 api/class.base.php:1.1.1.1.2.28
--- api/class.base.php:1.1.1.1.2.27 Tue Feb 24 10:51:02 2004
+++ api/class.base.php Fri Apr 16 20:59:48 2004
@@ -45,10 +45,10 @@
'title' => 'Update profile',
'abstract' => 'Update user profile',
'params' => array(
- 'profile_firstname' => array('type' => 'any',
'default' => '##NOTSET##', 'desc' => 'First Name'),
- 'profile_lastname' => array('type' => 'any',
'default' => '##NOTSET##', 'desc' => 'Last Name'),
- 'profile_password' => array('type' => 'any',
'default' => '##NOTSET##', 'desc' => 'Password'),
- 'profile_password_confirm' => array('type' => 'any',
'default' => '##NOTSET##', 'desc' => 'Password confirmation')
+ 'profile_firstname' => array('type' => 'any',
'default' => NOTSET, 'desc' => 'First Name'),
+ 'profile_lastname' => array('type' => 'any',
'default' => NOTSET, 'desc' => 'Last Name'),
+ 'profile_password' => array('type' => 'any',
'default' => NOTSET, 'desc' => 'Password'),
+ 'profile_password_confirm' => array('type' => 'any',
'default' => NOTSET, 'desc' => 'Password confirmation')
)
);
@@ -76,9 +76,9 @@
'abstract' => 'Configuration section',
'discussion' => 'This is used by all apps to create a generic
configuration for there application',
'params' => array(
- 'location' => array('type'=>'string', 'default' =>
'##REQUIRED##', 'desc' => 'Location for there config'),
- 'form_submit' => array('type'=>'any', 'default' =>
'##NOTSET##', 'desc' => 'Set if the user is submitting'),
- 'new_config' => array('type'=>'any', 'default' =>
'##NOTSET##', 'desc' => 'Values submitted from the form')
+ 'location' => array('type'=>'string', 'default' =>
REQUIRED, 'desc' => 'Location for there config'),
+ 'form_submit' => array('type'=>'any', 'default' =>
NOTSET, 'desc' => 'Set if the user is submitting'),
+ 'new_config' => array('type'=>'any', 'default' =>
NOTSET, 'desc' => 'Values submitted from the form')
)
);
@@ -88,9 +88,9 @@
'abstract' => 'Preferences section',
'discussion' => 'This is used by all apps to present
preferences choices to users.',
'params' => array(
- 'appname' => array('type'=>'string', 'default' =>
'##REQUIRED##', 'desc' => 'app to display prefs for'),
- 'form_submit' => array('type'=>'any', 'default' =>
'##NOTSET##', 'desc' => 'Set if the user is submitting'),
- 'new_prefs' => array('type'=>'any', 'default' =>
'##NOTSET##', 'desc' => 'Values submitted from the form')
+ 'appname' => array('type'=>'string', 'default' =>
REQUIRED, 'desc' => 'app to display prefs for'),
+ 'form_submit' => array('type'=>'any', 'default' =>
NOTSET, 'desc' => 'Set if the user is submitting'),
+ 'new_prefs' => array('type'=>'any', 'default' =>
NOTSET, 'desc' => 'Values submitted from the form')
)
);
@@ -115,7 +115,7 @@
$result['text'] = 'This is where the home page will
get its data and be loaded.';
// $result['inputs'] = func_get_args();
$GLOBALS['phpgw']->add_xsl('api.start');
-
$GLOBALS['phpgw']->hooks->execute(array('hook'=>'api.base.start',
'fname'=>'test_firstname', 'lname'=>'test_lastname'));
+
$GLOBALS['phpgw']->hooks->Execute(array('hook'=>'api.base.start',
'fname'=>'test_firstname', 'lname'=>'test_lastname'));
//$GLOBALS['phpgw_xml_apinode']->add_node('Home','title');
return $result;
@@ -125,57 +125,57 @@
function profile()
{
$args = new safe_args();
- $args->set('profile_submit', '##NOTSET##', 'string');
- $args->set('profile_firstname', '##NOTSET##', 'any');
- $args->set('profile_lastname', '##NOTSET##', 'any');
- $args->set('profile_password', '##NOTSET##', 'any');
- $args->set('profile_password_confirm', '##NOTSET##',
'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('profile_submit', NOTSET, 'string');
+ $args->set('profile_firstname', NOTSET, 'any');
+ $args->set('profile_lastname', NOTSET, 'any');
+ $args->set('profile_password', NOTSET, 'any');
+ $args->set('profile_password_confirm', NOTSET, 'any');
+ $args = $args->get(func_get_args());
if ($args['profile_submit'])
{
if (! strlen($args['profile_firstname']))
{
-
$result['missing_fields']['profile_firstname'] = True;
+
$result['missing_fields']['profile_firstname'] = true;
$result['profile_firstname'] =
$GLOBALS['phpgw_data']['user']['firstname'];
- $missing_fields = True;
+ $missing_fields = true;
}
if (! strlen($args['profile_lastname']))
{
-
$result['missing_fields']['profile_lastname'] = True;
+
$result['missing_fields']['profile_lastname'] = true;
$result['profile_lastname'] =
$GLOBALS['phpgw_data']['user']['lastname'];
- $missing_fields = True;
+ $missing_fields = true;
}
if (! strlen($args['profile_password']))
{
-
$result['missing_fields']['profile_password'] = True;
- $missing_fields = True;
+
$result['missing_fields']['profile_password'] = true;
+ $missing_fields = true;
}
if (! strlen($args['profile_password_confirm']))
{
-
$result['missing_fields']['profile_password_confirm'] = True;
- $missing_fields = True;
+
$result['missing_fields']['profile_password_confirm'] = true;
+ $missing_fields = true;
}
else if ($args['profile_password'] !=
$args['profile_password_confirm'])
{
-
$result['missing_fields']['profile_password'] = True;
-
$result['missing_fields']['profile_password_confirm'] = True;
- $missing_fields = True;
- $GLOBALS['msgbox']->add(lang('The
passwords you entered do not match'),__LINE__,__FILE__, 'notice');
+
$result['missing_fields']['profile_password'] = true;
+
$result['missing_fields']['profile_password_confirm'] = true;
+ $missing_fields = true;
+ $GLOBALS['msgbox']->add(lang('The
passwords you entered do not match'), 'notice');
}
else
{
// FIXME: This hasn't been tested yet
-
sanitize($args['profile_password'],'password');
+
validate($args['profile_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');
+ $GLOBALS['msgbox']->add(lang('You
forgot to enter some of the required fields. The missing fields have been
marked with a *'), 'notice');
$GLOBALS['phpgw']->form_lock();
$result['action_type'] = 'profile';
}
@@ -186,7 +186,7 @@
$GLOBALS['phpgw']->accounts->save_repository();
execMethod('api.auth.change_password',array('current_passwd' => '',
'new_passwd' => $args['profile_password'], 'account_id' =>
$GLOBALS['phpgw_data']['user']['id']));
- $GLOBALS['msgbox']->add(lang('Profile
has been updated successfully'),__LINE__,__FILE__, 'notice');
+ $GLOBALS['msgbox']->add(lang('Profile
has been updated successfully'), 'notice');
}
}
else
@@ -222,7 +222,7 @@
{
// 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']);
+ $account =
createObject('api_accounts',$_SESSION['phpgw_session']['session_lid']);
$history->account_id = $account->account_id;
$new_data = array(
@@ -240,38 +240,53 @@
*/
function about()
{
+ $args = new safe_args();
+ $args->set('location','api','string');
+ $args = $args->get(func_get_args());
+
$GLOBALS['phpgw']->add_xsl('api.about');
-
//$GLOBALS['phpgw_xml_apinode']->add_node('About','title');
- return array(lang('This new phpGroupWare framework was
brought to you by the outstanding and brilliant work of Dan Kuykendall (Seek3r)
and Joseph Engo (jengo).
-Details can be found at http://www.kuykendall.org/phpgroupware'));
+
+ if ($args['location'] != 'api')
+ {
+ if (file_exists(PHPGW_ROOT . SEP .
$args['location'] . '/setup/setup.xml'))
+ {
+ $fp = fopen(PHPGW_ROOT . SEP .
$args['location'] . '/setup/setup.xml','r');
+ $buffer = fread($fp,filesize(PHPGW_ROOT
. SEP . $args['location'] . '/setup/setup.xml'));
+ fclose($fp);
+
+ return xml2var($buffer);
+ }
+ }
+
+ return array('name' => 'api');
}
function op_history_redirect()
{
$args = new safe_args();
- $args->set('position_id','##REQUIRED##','string');
- $args->set('set_state_values','##NOTSET##','any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('position_id',REQUIRED,'string');
+ $args->set('set_state_values',NOTSET,'any');
+ $args = $args->get(func_get_args());
- if ($args['set_state_values'] == 'False')
+ if ($args['set_state_values'] == 'false')
{
- $args['set_state_values'] = False;
+ $args['set_state_values'] = false;
}
else
{
- $args['set_state_values'] = True;
+ $args['set_state_values'] = true;
}
- $total =
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']);
+ $total =
count($_SESSION['phpgw_session']['phpgw_data']['op_history']);
for ($i=0; $i<$total; $i++)
{
-
$history[$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$i]['position']]
= $GLOBALS['phpgw_session']['phpgw_data']['op_history'][$i];
+
$history[$_SESSION['phpgw_session']['phpgw_data']['op_history'][$i]['position']]
= $_SESSION['phpgw_session']['phpgw_data']['op_history'][$i];
}
$loc_data = $history[$args['position_id']];
if (! $loc_data['title'])
{
- $GLOBALS['msgbox']->add(lang('History on this
operation not valid or expired'),__LINE__,__FILE__, 'warning');
+ $GLOBALS['msgbox']->add(lang('History on this
operation not valid or expired'), 'warning');
return;
}
@@ -283,14 +298,14 @@
}
$result = array();
- $result = execMethod($loc_data['op'],$loc_data['data'],
False);
+ $result = execMethod($loc_data['op'],$loc_data['data'],
false);
-
$GLOBALS['phpgw_session']['phpgw_data']['current_history_position'] =
$args['position_id'];
+
$_SESSION['phpgw_session']['phpgw_data']['current_history_position'] =
$args['position_id'];
if ($args['set_state_values'])
{
- if
(isset($GLOBALS['phpgw_session']['form_state_values'][$loc_data['op']]))
+ if
(isset($_SESSION['phpgw_session']['form_state_values'][$loc_data['op']]))
{
- $result['form_state_values'] =
$GLOBALS['phpgw_session']['form_state_values'][$loc_data['op']];
+ $result['form_state_values'] =
$_SESSION['phpgw_session']['form_state_values'][$loc_data['op']];
}
}
@@ -301,10 +316,10 @@
function acl()
{
$args = new safe_args();
- $args->set('location','##REQUIRED##','string');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('location',REQUIRED,'string');
+ $args = $args->get(func_get_args());
- $user = array('username' =>
$GLOBALS['phpgw_session']['session_lid']);
+ $user = array('username' =>
$_SESSION['phpgw_session']['session_lid']);
$GLOBALS['phpgw_xml_apinode']->add_node($user,'user');
$GLOBALS['phpgw']->add_xsl('api.acl_popup');
@@ -312,16 +327,16 @@
$result['acl_location'] = $args['location'];
$GLOBALS['phpgw_xmldoc']->add_node($result,'APP');
- $GLOBALS['phpgw']->finish(False);
+ $GLOBALS['phpgw']->finish(false);
}
function config()
{
$args = new safe_args();
- $args->set('location','##REQUIRED##','string');
- $args->set('form_submit','##NOTSET##','any');
- $args->set('new_config','##NOTSET##','any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('location',REQUIRED,'string');
+ $args->set('form_submit',NOTSET,'any');
+ $args->set('new_config',NOTSET,'any');
+ $args = $args->get(func_get_args());
$GLOBALS['phpgw']->add_xsl('api.widgets');
if (strpos($args['location'],'.'))
@@ -340,7 +355,7 @@
if (! is_array($obj->config) && ! count($obj->config))
{
$this->method_titles['start'] = lang('Home');
- $GLOBALS['msgbox']->add(lang('Configuration not
available or missing for this application'),__LINE__,__FILE__, 'warning');
+ $GLOBALS['msgbox']->add(lang('Configuration not
available or missing for this application'), 'warning');
return array();
}
@@ -348,7 +363,7 @@
{
- $GLOBALS['msgbox']->add(lang('Configuration
have been saved'),__LINE__,__FILE__, 'notice');
+ $GLOBALS['msgbox']->add(lang('Configuration
have been saved'), 'notice');
return array();
}
else
@@ -369,30 +384,30 @@
if ($result['config_widget'][$i]['type'] ==
'checkbox')
{
// FIXME: The value should be casted to
a boolean type, don't test as a string
- if
($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']] == 'True')
+ if
($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']] == 'true')
{
-
$result['pref_widget'][$i]['checked'] = True;
+
$result['pref_widget'][$i]['checked'] = true;
}
else
{
-
$result['pref_widget'][$i]['checked'] = False;
+
$result['pref_widget'][$i]['checked'] = false;
}
}
if ($result['config_widget'][$i]['type'] ==
'selectbox')
{
- // If there is a value present, then
reset all "selected" values to False, to be set again
+ // If there is a value present, then
reset all "selected" values to false, to be set again
if
(strlen($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']]))
{
$t =
count($result['config_widget'][$i]['values']);
for ($j=0; $j<$t; $j++)
{
-
$result['pref_widget'][$i]['values'][$j]['selected'] = False;
+
$result['pref_widget'][$i]['values'][$j]['selected'] = false;
if
($result['pref_widget'][$i]['values'][$j]['value'] ==
$GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']])
{
-
$result['pref_widget'][$i]['values'][$j]['selected'] = True;
+
$result['pref_widget'][$i]['values'][$j]['selected'] = true;
}
}
@@ -403,17 +418,35 @@
return $result;
}
+ function menu()
+ {
+ $GLOBALS['phpgw']->add_xsl('api.menu');
+ $GLOBALS['phpgw']->finish(false);
+ }
+
+ function frames()
+ {
+ $GLOBALS['phpgw']->add_xsl('api.findex');
+ $GLOBALS['phpgw']->finish(false);
+ }
+
+ function cron()
+ {
+ $GLOBALS['phpgw']->add_xsl('api.cron');
+ $GLOBALS['phpgw']->finish(false);
+ }
+
function prefs()
{
$args = new safe_args();
- $args->set('appname','##REQUIRED##','string');
- $args->set('form_submit','##NOTSET##','any');
- $args->set('new_prefs','##NOTSET##','any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('appname',REQUIRED,'string');
+ $args->set('form_submit',NOTSET,'any');
+ $args->set('new_prefs',NOTSET,'any');
+ $args = $args->get(func_get_args());
- if
(isset($GLOBALS['phpgw_session']['form_state_vales'][$methodname]))
+ if
(isset($_SESSION['phpgw_session']['form_state_values'][$methodname]))
{
-
$GLOBALS['phpgw_xml_appnode']->add_node($GLOBALS['phpgw_session']['form_state_vales'][$methodname],'form_state_values');
+
$GLOBALS['phpgw_xml_appnode']->add_node($_SESSION['phpgw_session']['form_state_values'][$methodname],'form_state_values');
}
$GLOBALS['phpgw']->add_xsl('api.widgets');
@@ -429,10 +462,10 @@
$GLOBALS['phpgw']->prefs->load($GLOBALS['phpgw_data']['user']['id'],$args['appname']);
}
- if (! is_array($obj->prefs) && ! count($obj->prefs))
+ if (!is_array($obj->prefs) && !count($obj->prefs))
{
$this->method_titles['start'] = lang('Home');
- $GLOBALS['msgbox']->add(lang('Preferences not
available or missing for this application'),__LINE__,__FILE__, 'warning');
+ trigger_error(lang('Preferences not available
or missing for this application'),E_USER_WARNING);
return array();
}
@@ -446,7 +479,7 @@
$GLOBALS['phpgw']->prefs->set($args['appname'] . '.' .
$key,(string)$value,$GLOBALS['phpgw_data']['user']['id']);
}
}
- $GLOBALS['msgbox']->add(lang('Preferences have
been saved'),__LINE__,__FILE__, 'notice');
+ $GLOBALS['msgbox']->add(lang('Preferences have
been saved'), 'notice');
return array();
}
else
@@ -456,46 +489,39 @@
$result['pref_widget'] = $obj->prefs;
- $total = count($result['pref_widget']);
- for ($i=0; $i<$total; $i++)
+ foreach ($result['pref_widget'] as $i => $widget)
{
// The following "value setting" give me
headaches as well, your not the only one (jengo)
- if ($result['pref_widget'][$i]['type'] ==
'inputbox')
+ switch ($widget['type'])
{
- $result['pref_widget'][$i]['value'] =
$GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']];
- }
-
- if ($result['pref_widget'][$i]['type'] ==
'checkbox')
- {foreach ($args['new_prefs'] as $key =>
$value)foreach ($args['new_prefs'] as $key => $value)
- // FIXME: The value should be casted to
a boolean type, don't test as a string
- if
($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']] == 'True')
- {
-
$result['pref_widget'][$i]['checked'] = True;
- }
- else
- {
-
$result['pref_widget'][$i]['checked'] = False;
- }
- }
-
- if ($result['pref_widget'][$i]['type'] ==
'selectbox')
- {
- // If there is a value present, then
reset all "selected" values to False, to be set again
- if
(strlen($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']]))
- {
-
- $t =
count($result['pref_widget'][$i]['values']);
- for ($j=0; $j<$t; $j++)
+ case 'inputbox':
+
$result['pref_widget'][$i]['value'] =
$GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' . $widget['name']];
+ break;
+ case 'checkbox':
+ // FIXME: The value should be
casted to a boolean type, don't test as a string
+ if
($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' . $widget['name']] ==
'true')
{
-
$result['pref_widget'][$i]['values'][$j]['selected'] = False;
-
- if
($result['pref_widget'][$i]['values'][$j]['value'] ==
$GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']])
+
$result['pref_widget'][$i]['checked'] = true;
+ }
+ else
+ {
+
$result['pref_widget'][$i]['checked'] = false;
+ }
+ break;
+ case 'selectbox':
+ // If there is a value present,
then reset all "selected" values to false, to be set again
+ if
(strlen($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$result['pref_widget'][$i]['name']]))
+ {
+ foreach
($result['pref_widget'][$i]['values'] as $j => $val)
{
-
$result['pref_widget'][$i]['values'][$j]['selected'] = True;
+
$result['pref_widget'][$i]['values'][$j]['selected'] = false;
+ if
($val['value'] == $GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' .
$widget['name']])
+ {
+
$result['pref_widget'][$i]['values'][$j]['selected'] = true;
+ }
}
}
-
- }
+ break;
}
}
return $result;
@@ -1999,7 +2025,7 @@
9 => array(
'value' => 'en_US',
'text' => 'English (US)',
- 'selected' => True
+ 'selected' => true
),
10 => array(
'value' => 'et',
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/class.base.php, 1.1.1.1.2.28,
nomail <=