home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / configuration / account / index.php next >
Encoding:
PHP Script  |  2004-03-08  |  7.4 KB  |  236 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14.  
  15. $GO_SECURITY->authenticate();
  16. //if the user is authorising but it's logged in under another user log him out first.
  17. if(isset($_REQUEST['requested_user_id']) && $_REQUEST['requested_user_id'] != $GO_SECURITY->user_id)
  18. {
  19.     SetCookie("GO_UN","",time()-3600,"/","",0);
  20.     SetCookie("GO_PW","",time()-3600,"/","",0);
  21.     unset($_SESSION);
  22.     unset($_COOKIES);
  23.     $GO_SECURITY->logout();
  24.     $GO_SECURITY->authenticate();
  25. }
  26.  
  27. $return_to = $GO_CONFIG->host.'configuration/';
  28.  
  29. require($GO_LANGUAGE->get_language_file('account'));
  30.  
  31. //load account management class
  32. require_once($GO_CONFIG->class_path."users.class.inc");
  33. $users = new users();
  34.  
  35. $page_title = $acTitle;
  36.  
  37. $tabtable = new tabtable('account', $acManager, '600', '300');
  38. $tabtable->add_tab('profile.inc', $acProfile);
  39. $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
  40.  
  41. switch($task)
  42. {
  43.     case 'accept':
  44.         if (isset($_REQUEST['requested_user_id']) && isset($_REQUEST['authcode']))
  45.         {
  46.             if ($user = $users->get_user($_REQUEST['requesting_user_id']))
  47.             {
  48.                 $middle_name = $user['middle_name'] == '' ? '' : $user['middle_name'].' ';
  49.                 $user_name = $middle_name.$user['last_name'];
  50.  
  51.                 if($users->authorize($_REQUEST['requesting_user_id'], $_REQUEST['authcode'], $GO_SECURITY->user_id))
  52.                 {
  53.                     $feedback = $ac_auth_success.'<br /><br />';
  54.  
  55.                     $mail_body = $ac_salutation." ".$sir_madam[$user['sex']]." ".$user_name.",\r\n\r\n";
  56.                     $mail_body .= $_SESSION['GO_SESSION']['name']." ".$ac_auth_accept_mail_body;
  57.  
  58.                     sendmail($user['email'], $GO_CONFIG->webmaster_email, $GO_CONFIG->title, $ac_auth_accept_mail_title, $mail_body,'3 (Normal)', 'text/plain');
  59.                 }
  60.  
  61.             }else
  62.             {
  63.                 $feedback = '<p class="Error">'.$ac_auth_error.'</p>';
  64.             }
  65.             $task = 'privacy';
  66.             $tabtable->set_active_tab(2);
  67.         }
  68.     break;
  69.  
  70.     case 'decline':
  71.         if (isset($_REQUEST['requested_user_id']) && isset($_REQUEST['authcode']))
  72.         {
  73.             if ($user = $users->get_user($_REQUEST['requesting_user_id']))
  74.             {
  75.                 $middle_name = $user['middle_name'] == '' ? '' : $user['middle_name'].' ';
  76.                 $user_name = $middle_name.$user['last_name'];
  77.  
  78.                 $feedback = $ac_auth_decline.'<br /><br />';
  79.                 $mail_body = $ac_salutation." ".$sir_madam[$user['sex']]." ".$user_name.",\r\n\r\n";
  80.                 $mail_body .= $_SESSION['GO_SESSION']['name']." ".$ac_auth_decline_mail_body;
  81.                 sendmail($user['email'], $GO_CONFIG->webmaster_email, $GO_CONFIG->title, $ac_auth_decline_mail_title, $mail_body,'3 (Normal)', 'text/plain');
  82.  
  83.             }else
  84.             {
  85.                 $feedback = '<p class="Error">'.$ac_auth_error.'</p>';
  86.             }
  87.             $task = 'privacy';
  88.             $tabtable->set_active_tab(2);
  89.         }
  90.     break;
  91.  
  92.     case 'save_profile':
  93.         require($GO_CONFIG->class_path."/validate.class.inc");
  94.         $val = new validate();
  95.         //translate the given birthdayto gmt unix time
  96.         $birthday = date_to_db_date($_POST['birthday']);
  97.  
  98.         $val->error_required = $error_required;
  99.         $val->error_min_length = $error_min_length;
  100.         $val->error_max_length = $error_max_length;
  101.         $val->error_expression = $error_email;
  102.         $val->error_match = $error_match_auth;
  103.  
  104.  
  105.         $val->name="first_name";
  106.         $val->input=$_POST['first_name'];
  107.         $val->max_length=50;
  108.         $val->required=true;
  109.         $val->validate_input();
  110.  
  111.         $val->name="last_name";
  112.         $val->input=$_POST['first_name'];
  113.         $val->max_length=50;
  114.         $val->required=true;
  115.         $val->validate_input();
  116.  
  117.  
  118.         $val->name="email";
  119.         $val->input=$_POST['email'];
  120.         $val->max_length=75;
  121.         $val->required=true;
  122.         $val->expression="^([a-z0-9]+)([._-]([a-z0-9]+))*[@]([a-z0-9]+)([._-]([a-z0-9]+))*[.]([a-z0-9]){2}([a-z0-9])?([a-z0-9])?$";
  123.         $val->validate_input();
  124.         if ($val->validated == true)
  125.         {
  126.             if (!$users->update_profile($GO_SECURITY->user_id, $_POST['first_name'],$_POST['middle_name'], $_POST['last_name'], $_POST['initials'], $_POST['title'], $_POST['sex'], $birthday, $_POST['email'], $_POST['work_phone'], $_POST['home_phone'], $_POST['fax'], $_POST['cellular'], $_POST['country'], $_POST['state'], $_POST['city'], $_POST['zip'], $_POST['address'], $_POST['company'], $_POST['work_country'], $_POST['work_state'], $_POST['work_city'], $_POST['work_zip'], $_POST['work_address'], $_POST['work_fax'], $_POST['homepage'],  $_POST['department'], $_POST['function']))
  127.             {
  128.                 $feedback = "<p class=\"Error\">".$strSaveError."</p>";
  129.             }elseif (isset($_POST['load_frames']))
  130.             {
  131.                 header('Location: '.$GO_CONFIG->host);
  132.                 exit();
  133.             }elseif ($_POST['close'] == 'true')
  134.             {
  135.                 header('Location: '.$return_to);
  136.                 exit();
  137.             }
  138.         }else
  139.         {
  140.             $feedback ="<p class='Error'>".$errors_in_form."</p>";
  141.         }
  142.  
  143.  
  144.     break;
  145.  
  146.     case 'change_password':
  147.         require($GO_CONFIG->class_path."/validate.class.inc");
  148.         $val = new validate;
  149.         $val->error_required = $error_required;
  150.         $val->error_min_length = $error_min_length;
  151.         $val->error_max_length = $error_max_length;
  152.         $val->error_expression = $error_email;
  153.         $val->error_match = $error_match_auth;
  154.  
  155.         $val->name="currentpassword";
  156.         $val->input=$_POST['currentpassword'];
  157.         $val->max_length=20;
  158.         $val->required=true;
  159.         $val->validate_input();
  160.  
  161.         $val->name="newpass1";
  162.         $val->input=$_POST['newpass1'];
  163.         $val->min_length=3;
  164.         $val->max_length=20;
  165.         $val->required=true;
  166.         $val->validate_input();
  167.  
  168.         $val->name="newpass2";
  169.         $val->input=$_POST['newpass2'];
  170.         $val->min_length=3;
  171.         $val->max_length=20;
  172.         $val->required=true;
  173.         $val->validate_input();
  174.  
  175.         $val->name="newpass1";
  176.         $val->match1=$_POST['newpass1'];
  177.         $val->match2=$_POST['newpass2'];
  178.         $val->validate_input();
  179.  
  180.         if ($val->validated == true)
  181.         {
  182.             if (!$users->check_password($_POST['currentpassword']))
  183.             {
  184.                 $feedback = "<p class=\"Error\">".$security_wrong_password."</p>";
  185.             }else
  186.             {
  187.                 if ($_POST['newpass1'] != "")
  188.                 {
  189.                     if ($users->update_password($GO_SECURITY->user_id, $_POST['newpass1'],$_POST['currentpassword']))
  190.                     {
  191.                         $feedback = "<p class=\"Success\">".$security_password_update."</p>";
  192.  
  193.                         if ($_POST['close'] == 'true')
  194.                         {
  195.                             header('Location: '.$return_to);
  196.                             exit();
  197.                         }
  198.                     }else
  199.                     {
  200.                         $feedback = "<p class=\"Error\">".$strSaveError."</p>";
  201.                     }
  202.                 }
  203.             }
  204.         }
  205.     break;
  206. }
  207.  
  208. $profile = $users->get_user($GO_SECURITY->user_id);
  209.  
  210. $datepicker = new date_picker();
  211. $GO_HEADER['head'] = $datepicker->get_header();
  212.  
  213. require($GO_THEME->theme_path."header.inc");
  214. if ($_SESSION['GO_SESSION']['first_name'] != '' && $_SESSION['GO_SESSION']['last_name'] != '' && $_SESSION['GO_SESSION']['email'] != '')
  215. {
  216.     if ($_SESSION['GO_SESSION']['auth_src'] =='sql' && $GO_CONFIG->allow_password_change)
  217.     {
  218.         $tabtable->add_tab('security.inc', $acSecurity);
  219.     }
  220.     $tabtable->add_tab('privacy.inc', $acPrivacy);
  221.     $tabtable->add_tab('statistics.inc', $acStatistics);
  222. }
  223. ?>
  224. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="account_form" method="post">
  225. <input type="hidden" name="task" />
  226. <input type="hidden" name="close" value="false" />
  227. <?php
  228. $tabtable->print_head();
  229. require($tabtable->get_active_tab_id());
  230. $tabtable->print_foot();
  231. ?>
  232. </form>
  233. <?php
  234. require($GO_THEME->theme_path."footer.inc");
  235. ?>
  236.