added cprofile

This commit is contained in:
Pim Snel 2008-01-03 13:29:36 +00:00
parent da908c2311
commit 4796812a17
14 changed files with 806 additions and 0 deletions

1
cybro_profile/README Normal file
View File

@ -0,0 +1 @@
See /doc for all information about this app.

View File

@ -0,0 +1,294 @@
<?php
/**
*
*
*
*
**/
require_once(EGW_INCLUDE_ROOT.'/egwcybroapi/inc/class.bo_cybroapi.inc.php');
class bo_cprofile extends bo_cybroapi
{
var $cp_so;
function bo_cprofile()
{
parent::bo_cybroapi();
$this->cp_so = CreateObject('cybro_profile.so_cprofile');
}
function cp_validate($formvals, $dir)
{
//_debug_array($formvals);
//_debug_array($this->user_arr);
// form validation here
switch($dir)
{
case 'ennudoenweerechtietsmee':
foreach($formvals as $key => $val)
{
if($val == '') $formvals[$key] = "#empty";
}
}
return $formvals;
}
function cp_getValues($template)
{
switch($template)
{
case 'registration':
$record = $this->cp_getregvals($this->user_arr['USER_Name']);
break;
case 'personal':
$record = $this->cp_getpersvals($this->user_arr['USER_Name']);
break;
default:
return 'illegal call to function.';
break;
}
return $this->cp_validate($record, 'out');
}
function cp_updateValues($template, $arr)
{
switch($template)
{
case 'registration':
$msg = $this->cp_updateregvals($arr['firstname'],$arr['lastname']);
if($msg['status'] == 200 )
{
return 'registration info changed.';
}
else return 'update failed. information NOT changed.';
break;
case 'personal':
$procdarr = $arr;
//_debug_array($GLOBALS['egw_info']['user']['preferences']['common']['lang']);
$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $procdarr['language1'];
$GLOBALS['egw']->translation->init();
//_debug_array($GLOBALS['egw_info']['user']['preferences']['common']['lang']);
$msg = $this->cp_updatepersvals($procdarr);
if($msg['status'] == 200)
{
return 'personal info changed.';
}
else return 'update failed. information NOT changed.';
break;
default:
return 'illegal call to function.';
break;
}
}
function cp_changepasswd($arr)
{
$oldpass = $arr['old_pwd'];
$newpass = $arr['new_pwd'];
$msg = $this->update_password($this->user_arr['USER_Id'],$oldpass,$newpass);
return $msg;
}
function cp_getregvals($name)
{
$dataArray = array( new xmlrpcval(
array (
"supname" => new xmlrpcval($name)
),
"struct")
);
$result=$this->xmlrpcdialog('get_profile_reg_vals',$dataArray,0);
if (!$result['faultcode'])
{
$_arr=array(
'useremail',
'cybroorg',
'firstname',
'lastname'
);
for($i=0; $i<$result['max']; $i++)
{
$rec2=$result['v']->arraymem($i);//get the different array (VALUES) members, they are structs
$ret=$this->getStructScalarFromArray($_arr,$rec2);
return $ret;
}
} else $result['faultcode']; // todo:more "elegant" solution please
}
function cp_updateregvals($firstname, $lastname)
{
$dataArray = array( new xmlrpcval(
array (
"supid" => new xmlrpcval($this->user_arr['USER_Id'],'int'),
"firstname" => new xmlrpcval($firstname),
"lastname" => new xmlrpcval($lastname)
),
"struct")
);
$result=$this->xmlrpcdialog('update_profile_reg_vals',$dataArray,0);
if (!$result['faultcode'])
{
$_arr=array(
'status',
);
for($i=0; $i<$result['max']; $i++)
{
$rec2=$result['v']->arraymem($i);//get the different array (VALUES) members, they are structs
$ret=$this->getStructScalarFromArray($_arr,$rec2);
return $ret;
}
} else return $result['faultcode']; // todo:more "elegant" solution please
}
function cp_getpersvals($name)
{
$dataArray = array( new xmlrpcval(
array (
"supname" => new xmlrpcval($name)
),
"struct")
);
$result=$this->xmlrpcdialog('get_profile_pers_vals',$dataArray,0);
if (!$result['faultcode'])
{
$_arr=array(
'language',
'country',
'cybcafe',
'cybprofession',
'birth',
'cybcardid',
'adroneregion',
'cybskype',
'adronelocality',
'userurl',
'telwork',
'telcell',
'aboutmyself'
);
for($i=0; $i<$result['max']; $i++)
{
$rec2=$result['v']->arraymem($i);//get the different array (VALUES) members, they are structs
$ret=$this->getStructScalarFromArray($_arr,$rec2);
}
} else return $result['faultcode']; // todo:more "elegant" solution please
return $ret;
}
function cp_getLangs()
{
return $this->cp_so->getegwlangs();
}
function cp_getCountries()
{
require_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.country.inc.php');
$country = CreateObject('phpgwapi.country');
return $country->countries();
}
function fixbirthd($str)
{
$str = str_replace('/','',$str);
return $str;
}
function cp_updatepersvals($arr)
{
foreach($arr as $key=>$arrval)
{
if ($arrval == '')
{
$arr[$key] = NULL;
}
}
// stuff langs together
$lang = $arr['language1'].','.$arr['language2'].','.$arr['language3'];
$cprof = $arr['cybro_profession'];
$ccardid = $arr['cybro_cardid'];
$ccountry= $arr['adr_one_countryname'];
$ccafe = $arr['cybro_cafe'];
$cregion = $arr['adr_one_region'];
$cskype = $arr['cybro_skype'];
$clocal = $arr['adr_one_locality'];
$userurl = $arr['userurl'];
$ctwork = $arr['tel_work'];
$ctcell = $arr['tel_cell'];
$cnote = $arr['note'];
$cbirthd = $this->fixbirthd($arr['exec']['bday']['str']);
$dataArray = array( new xmlrpcval(
array (
"supid" => new xmlrpcval($this->user_arr['USER_Id'],'int'),
"language" => new xmlrpcval($lang),
"cybprofession" => new xmlrpcval($cprof),
"birthd" => new xmlrpcval($cbirthd,'int'),
"cybcardid" => new xmlrpcval($ccardid,'int'),
"country" => new xmlrpcval($ccountry),
"cybcafe" => new xmlrpcval($ccafe),
"region" => new xmlrpcval($cregion),
"cybskype" => new xmlrpcval($cskype),
"adronelocal" => new xmlrpcval($clocal),
"userurl" => new xmlrpcval($userurl),
"telwork" => new xmlrpcval($ctwork),
"telcell" => new xmlrpcval($ctcell),
"note" => new xmlrpcval($cnote),
),
"struct")
);
$result=$this->xmlrpcdialog('update_profile_pers_vals',$dataArray,0);
if (!$result['faultcode'])
{
$_arr=array(
'status',
);
for($i=0; $i<$result['max']; $i++)
{
$rec2=$result['v']->arraymem($i);//get the different array (VALUES) members, they are structs
$ret=$this->getStructScalarFromArray($_arr,$rec2);
return $ret;
}
}
else
{
return '400';
}
}
function cp_getcafelist()
{
$dataArray = array( new xmlrpcval(
array (
"" => new xmlrpcval()
),
"struct")
);
$result=$this->xmlrpcdialog('get_cafeslist',$dataArray,0);
if (!$result['faultcode'])
{
$_arr=array(
'cafeid', // todo: why does this value disappear?
'cafename'
);
for($i=0; $i<$result['max']; $i++)
{
$rec2=$result['v']->arraymem($i);//get the different array (VALUES) members, they are structs
// $cafeid=$rec2->structmem("cafeid");
// $cafename=$rec2->structmem("cafename");
/// $ret['cafeid']=$this->getStructScalarFromArray($cafeid,$rec2);
// $ret['cafename']=$this->getStructScalarFromArray($cafename,$rec2);
$ret[]=$this->getStructScalarFromArray($_arr,$rec2);
//$ret_arr[]=$ret;
}
} else return $result['faultcode']; // todo:more "elegant" solution please
return $ret;
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
*
*
*
**/
class so_cprofile
{
var $sqldb;
function so_cprofile()
{
$this->sqldb = $GLOBALS['egw']->db;
}
function getegwlangs()
{
$this->sqldb->select('egw_languages','*','',__LINE__,__FILE__);
while($this->sqldb->next_record())
{
$langs[] = $this->sqldb->row();
}
return $langs;
}
}

View File

@ -0,0 +1,205 @@
<?php
/**
*
*
*
**/
class ui_cprofile
{
var $sav2;
var $bo;
var $errormsg;
var $public_functions = Array
(
'registration' => True,
'personal' => True,
'security' => True,
'sidebox_menu' => False,
'assignValues' => False
);
function ui_cprofile()
{
$this->sav2 = CreateObject('phpgwapi.tplsavant2');
$this->bo = CreateObject('cybro_profile.bo_cprofile');
$this->assignValues(); // for now... we need temp. data to see things work
}
function sidebox_menu()
{
$appname = 'cybro_profile';
$content = Array(
'0' => array(
'link'=>$GLOBALS['phpgw']->link('/index.php','menuaction=cybro_profile.ui_cprofile.registration'),
'icon'=>(($_GET['menuaction']=='cybro_profile.ui_cprofile.registration')?'registration_active':'registration_inactive'),
'text'=>'Registration Info'
),
'1' => array(
'link'=>$GLOBALS['phpgw']->link('/index.php','menuaction=cybro_profile.ui_cprofile.personal'),
'icon'=>(($_GET['menuaction']=='cybro_profile.ui_cprofile.personal') ? 'personal_active':'personal_inactive'),
'text'=>'Personal Info'
),
'2' => array(
'link'=>$GLOBALS['phpgw']->link('/index.php','menuaction=cybro_profile.ui_cprofile.security'),
'icon'=>(($_GET['menuaction']=='cybro_profile.ui_cprofile.security') ? 'security_active':'security_inactive'),
'text'=>'Security'
)
);
$menu_title = lang('Cybro Profile Menu');
display_sidebox($appname,$menu_title,$content);
}
function assignValues()
{
// needed by
// :all
$this->sav2->defaultpic = '"'.EGW_INCLUDE_ROOT.'/myprofile/templates/default/images/photo.png'.'"';
//_debug_array($this->sav2->defaultpic);
$this->sav2->postpath = $GLOBALS['phpgw']->link('/index.php','menuaction=cybro_profile.ui_cprofile.');
// :registration
// :personal
// :security
}
function contentBox($template)
{
if(isset($this->errormsg))
{
$this->sav2->errormsg = $this->errormsg;
}
$this->sav2->rootpath = $GLOBALS['egw_info']['server']['webserver_url'];
$this->sav2->postpath = $this->sav2->postpath.$template;
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
$this->sav2->display($template.'.tpl.php');
$GLOBALS['egw']->common->phpgw_footer();
}
function registration()
{
if($_POST['save'] == 'Save')
{
$this->bo->cp_validate($_POST, 'in');
$this->errormsg[] = $this->bo->cp_updateValues('registration', $_POST);
}
$dbarr = $this->bo->cp_getValues('registration');
$this->sav2->cybroid=$this->bo->user_arr['USER_Name'];
$this->sav2->firstname=$dbarr['firstname'];
$this->sav2->lastname=$dbarr['lastname']; // todo: whitespaces?!
$this->sav2->cybemail=$dbarr['useremail'];
$this->sav2->cybrorg=$dbarr['cybroorg'];
$this->sav2->sponsors=array( // todo: sponsors from db
''=>'Select one',
'1'=>'sponsor1',
'2'=>'sponsor2'
);
$this->sav2->sponstypes=array(
''=>'Select one',
'1'=>'type1',
'2'=>'type2'
);
$this->contentBox('registration');
}
function personal()
{
if(isset($_POST['savepic']))
{
//_debug_array($_POST);
}
if($_POST['save'] == 'Save')
{
// dont forget : in 'countries' may be something different
// dont change db if not necessary. default = 0. keys are saved.
$this->bo->cp_validate($_POST,'in');
$this->errormsg[] = $this->bo->cp_updateValues('personal', $_POST);
}
if (!is_object($GLOBALS['phpgw']->jscalendar))
{
$GLOBALS['phpgw']->jscalendar = CreateObject('phpgwapi.jscalendar');
}
$input = $GLOBALS['phpgw']->jscalendar->input($field_name,'',$year,$month,$day);
//$this->sav2->jscal = $input;
$dbarr = $this->bo->cp_getValues('personal');
$pattern = '/(19|20)(\d{2})(\d{2})(\d{2})/';
$replacestr = '\1\2/\3/\4';
$this->sav2->birthday=preg_replace($pattern, $replacestr,$dbarr['birth']);
$this->sav2->cybprofession=$dbarr['cybprofession'];
$this->sav2->cybcardid=$dbarr['cybcardid'];
$this->sav2->adr_one_region=$dbarr['adroneregion'];
$this->sav2->cyskype=$dbarr['cybskype'];
$this->sav2->adr_one_locality=$dbarr['adronelocality'];
$this->sav2->userurl=$dbarr['userurl'];
$this->sav2->tel_work=$dbarr['telwork'];
$this->sav2->tel_cell=$dbarr['telcell'];
$this->sav2->note=$dbarr['aboutmyself'];
// ['language'] is in fact an array
// of up to 3 preferred langs:
$this->sav2->preflang = split(',',($dbarr['language']),3);
$this->sav2->languages=$this->bo->cp_getLangs();
$defaultz = array(
'lang_id' => '',
'lang_name' => 'Select one'
);
array_unshift($this->sav2->languages, $defaultz);
$countries = $this->bo->cp_getCountries();
array_unshift($countries, 'Select one');
$this->sav2->countries = $countries;
$this->sav2->mycountry = $dbarr['country'];
$cafes = $this->bo->cp_getcafelist();
$this->sav2->cafes = $cafes;
$defaultz = array(
'cafeid'=>'',
'cafename'=>'Select one'
);
array_unshift($this->sav2->cafes, $defaultz);
$this->sav2->mycafe = $dbarr['cybcafe'];
$this->contentBox('personal');
}
function security()
{
// validate the postvalues if submitted
if ($_POST['save'] == 'Save')
{
if($_POST['new_pwd'] != $_POST['confirm_pwd'])
{
$this->errormsg[] = 'The two values for your new password do not match.';
$this->errormsg[] = 'Please make sure you type the same password in the confirmation field.';
$this->errormsg[] = 'password NOT changed.';
}
else
{
$this->bo->cp_validate($_POST,'in');
if($this->bo->cp_changepasswd($_POST))
{
$this->errormsg[] = 'password changed.';
}
else
{
$this->errormsg[] = 'password NOT changed.';
}
}
}
// show results. but fake them of course.
$this->sav2->old_pwd='empty';
$this->sav2->new_pwd='empty';
$this->sav2->confirm_pwd='empty';
$this->contentBox('security');
}
}
?>

View File

@ -0,0 +1,14 @@
<?php
/**************************************************************************\
* eGroupWare - Skeleton Application *
* http://www.egroupware.org *
* ----------------------------------------------- *
* 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: functions.inc.php,v 1.2 2004/01/10 07:25:17 shrykedude Exp $ */
?>

View File

@ -0,0 +1,14 @@
<?php
/**************************************************************************\
* eGroupWare - Skeleton Application *
* http://www.egroupware.org *
* ----------------------------------------------- *
* 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: header.inc.php,v 1.4 2004/01/10 07:25:17 shrykedude Exp $ */
?>

View File

@ -0,0 +1,19 @@
<?php
/**************************************************************************\
* eGroupWare - Skeleton Application *
* http://www.egroupware.org *
* ----------------------------------------------- *
* 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: hook_add_def_pref.inc.php,v 1.4 2004/01/10 07:25:17 shrykedude Exp $ */
/*
global $pref;
$pref->change('notes','notes_font','Verdana,Arial,Helvetica,sans-serif');
$pref->change('notes','notes_font_size','3');
*/
?>

View File

@ -0,0 +1,23 @@
<?php
/**************************************************************************\
* eGroupWare - Skeleton Application *
* http://www.egroupware.org *
* ----------------------------------------------- *
* 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: hook_admin.inc.php,v 1.8 2004/01/10 07:25:17 shrykedude Exp $ */
{
// Only Modify the $file and $title variables.....
$title = $appname;
$file = array(
);
// Do not modify below this line
display_section($appname,$title,$file);
}
?>

View File

@ -0,0 +1,67 @@
<?php
/**************************************************************************\
* eGroupWare - E-Mail *
* http://www.egroupware.org *
* -------------------------------------------- *
* 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: hook_home.inc.php,v 1.19 2005/11/20 15:51:58 lkneschke Exp $ */
$d1 = strtolower(substr(EGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
echo 'Failed attempt to break in via an old Security Hole!<br>'."\n";
$GLOBALS['egw']->common->egw_exit();
}
unset($d1);
$GLOBALS['egw']->translation->add_app('cybro_profile');
$title = lang('cybro_profile');
$portalbox =& CreateObject('phpgwapi.listbox',
Array(
'title' => $title,
'primary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
'secondary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
'tertiary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
'width' => '100%',
'outerborderwidth' => '0',
'header_background_image' => $GLOBALS['egw']->common->image('phpgwapi/templates/phpgw_website','bg_filler.gif')
)
);
$app_id = $GLOBALS['egw']->applications->name2id('cybro_profile');
//$GLOBALS['portal_order'][] = $app_id;
$var = Array(
'up' => Array('url' => '/set_box.php', 'app' => $app_id),
'down' => Array('url' => '/set_box.php', 'app' => $app_id),
'close' => Array('url' => '/set_box.php', 'app' => $app_id),
'question' => Array('url' => '/set_box.php', 'app' => $app_id),
'edit' => Array('url' => '/set_box.php', 'app' => $app_id)
);
while(list($key,$value) = each($var))
{
$portalbox->set_controls($key,$value);
}
$portalbox->data = Array();
if($data)
{
$portalbox->data = $data;
}
$this->displayCharset = $GLOBALS['egw']->translation->charset();
$uicybro_profile= CreateObject('cybro_profile.ui_cprofile');
$extra_data = $uicybro_profile->hook_home();
// output the portalbox and below it (1) the folders listbox (if applicable) and (2) Compose New mail link
echo $portalbox->draw($extra_data);
?>

View File

@ -0,0 +1,19 @@
<?php
/**************************************************************************\
* eGroupWare - Skeleton Application *
* http://www.egroupware.org *
* ----------------------------------------------- *
* 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: hook_manual.inc.php,v 1.4 2004/01/10 07:25:17 shrykedude Exp $ */
// Only Modify the $file variable.....
$file = Array();
// Do not modify below this line
display_manual_section($appname,$file);
?>

View File

@ -0,0 +1,22 @@
<?php
/**************************************************************************\
* eGroupWare *
* http://www.egroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* 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: hook_preferences.inc.php,v 1.14 2005/07/23 15:52:48 ralfbecker Exp $ */
{
$title = $appname;
$file = Array(
'Preferences' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname)
);
display_section($appname,$title,$file);
}
?>

View File

@ -0,0 +1,32 @@
<?php
/**************************************************************************\
* eGroupWare - Jinn Preferences *
* http://egroupware.org *
* Written by Pim Snel <pim@egroupware.org> *
* -------------------------------------------- *
* 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; version 2 of the License. *
\**************************************************************************/
// In the future these settings go to the plugin file
/* $Id: hook_settings.inc.php 21614 2006-05-22 18:49:52Z mipmip $ */
if(function_exists('create_section'))
{
create_section('Homepage linker');
}
$yes_no = Array(
'False' => lang('No'),
'True' => lang('Yes')
);
if(function_exists('create_section'))
{
create_select_box('Link OnePage to the homepage?','homepage_display',$yes_no,"Show the status of your credits on the homepage");
}

View File

@ -0,0 +1,40 @@
<?php
/**************************************************************************\
* eGroupWare - Skeleton Application *
* http://www.egroupware.org *
* ----------------------------------------------- *
* 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: hook_sidebox_menu.inc.php,v 1.2 2005/05/02 13:13:56 milosch Exp $ */
{
/*
This hookfile is for generating an app-specific side menu used in the idots
template set.
$menu_title speaks for itself
$file is the array with link to app functions
display_sidebox can be called as much as you like
*/
/*
$menu_title = 'Preferences';
$file = Array(
);
display_sidebox($appname,$menu_title,$file);
*/
if($GLOBALS['egw_info']['user']['apps']['admin'])
{
$menu_title = 'Administration';
$file = array();
display_sidebox($appname,$menu_title,$file);
}
}
?>

27
cybro_profile/index.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**************************************************************************\
* eGroupWare - Ask a Quote *
* http://www.egroupware.org *
* -------------------------------------------------------------------------*
* Copyright (c) 2006 Pim Snel - Lingewoud B.V. <pim@lingewoud.nl> *
* Copyright (c) 2006 MARIN Netherlands <info@marin.nl> *
* -------------------------------------------------------------------------*
* 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 */
$GLOBALS['egw_info'] = array();
$GLOBALS['egw_info']['flags'] = array(
'currentapp' => 'cybro_profile',
'noheader' => True,
'nonavbar' => True,
'enable_nextmatchs_class' => True
);
include('../header.inc.php');
ExecMethod('cybro_profile.ui_cprofile.registration');
?>