[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/preferences/inc/ -> class.uipassword.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare - preferences                                                 *
   4      * http://www.egroupware.org                                                *
   5      * Written by Joseph Engo <jengo@phpgroupware.org>                          *
   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      /* $Id: class.uipassword.inc.php 19417 2005-10-14 14:31:35Z ralfbecker $ */
  14  
  15      class uipassword
  16      {
  17          var $public_functions = array(
  18              'change' => True
  19          );
  20  
  21  		function uipassword()
  22          {
  23              $this->bo =& CreateObject('preferences.bopassword');
  24  
  25          }
  26  
  27  		function change()
  28          {
  29              $n_passwd   = $_POST['n_passwd'];
  30              $n_passwd_2 = $_POST['n_passwd_2'];
  31              $o_passwd_2 = $_POST['o_passwd_2'];
  32  
  33              if(!$GLOBALS['egw']->acl->check('changepassword', 1) || $_POST['cancel'])
  34              {
  35                   $GLOBALS['egw']->redirect_link('/preferences/index.php');
  36                  $GLOBALS['egw']->common->egw_exit();
  37              }
  38  
  39              $GLOBALS['egw']->template->set_file(array(
  40                  'form' => 'changepassword.tpl'
  41              ));
  42              $GLOBALS['egw']->template->set_var('lang_enter_password',lang('Enter your new password'));
  43              $GLOBALS['egw']->template->set_var('lang_reenter_password',lang('Re-enter your password'));
  44              $GLOBALS['egw']->template->set_var('lang_enter_old_password',lang('Enter your old password'));
  45              $GLOBALS['egw']->template->set_var('lang_change',lang('Change'));
  46              $GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
  47              $GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=preferences.uipassword.change'));
  48  
  49              if($GLOBALS['egw_info']['server']['auth_type'] != 'ldap')
  50              {
  51                  $GLOBALS['egw']->template->set_var('sql_message',lang('note: This feature does *not* change your email password. This will '
  52                      . 'need to be done manually.'));
  53              }
  54  
  55              if($_POST['change'])
  56              {
  57                  $o_passwd = $GLOBALS['egw_info']['user']['passwd'];
  58  
  59                  if($o_passwd != $o_passwd_2)
  60                  {
  61                      $errors[] = lang('The old password is not correct');
  62                  }
  63  
  64                  if($n_passwd != $n_passwd_2)
  65                  {
  66                      $errors[] = lang('The two passwords are not the same');
  67                  }
  68  
  69                  if(!$n_passwd)
  70                  {
  71                      $errors[] = lang('You must enter a password');
  72                  }
  73  
  74                  if(is_array($errors))
  75                  {
  76                      $GLOBALS['egw']->common->egw_header();
  77                      echo parse_navbar();
  78                      $GLOBALS['egw']->template->set_var('messages',$GLOBALS['egw']->common->error_list($errors));
  79                      $GLOBALS['egw']->template->pfp('out','form');
  80                      $GLOBALS['egw']->common->egw_exit(True);
  81                  }
  82  
  83                  $passwd_changed = $this->bo->changepass($o_passwd, $n_passwd);
  84                  if(!$passwd_changed)
  85                  {
  86                      $errors[] = lang('Failed to change password.  Please contact your administrator.');
  87                      $GLOBALS['egw']->common->egw_header();
  88                      echo parse_navbar();
  89                      $GLOBALS['egw']->template->set_var('messages',$GLOBALS['egw']->common->error_list($errors));
  90                      $GLOBALS['egw']->template->pfp('out','form');
  91                      $GLOBALS['egw']->common->egw_exit(True);
  92                  }
  93                  else
  94                  {
  95                      $GLOBALS['egw']->session->appsession('password','phpgwapi',base64_encode($n_passwd));
  96                      $GLOBALS['egw_info']['user']['passwd'] = $n_passwd;
  97                      $GLOBALS['hook_values']['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
  98                      $GLOBALS['hook_values']['old_passwd'] = $o_passwd;
  99                      $GLOBALS['hook_values']['new_passwd'] = $n_passwd;
 100  
 101                      // called for every app now, not only for the ones enabled for the user
 102                      $GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
 103                          'location' => 'changepassword',
 104                      ),False,True);
 105                      $GLOBALS['egw']->redirect_link('/preferences/index.php','cd=18');
 106                  }
 107              }
 108              else
 109              {
 110                  $GLOBALS['egw_info']['flags']['app_header'] = lang('Change your password');
 111                  $GLOBALS['egw']->common->egw_header();
 112                  echo parse_navbar();
 113  
 114                  $GLOBALS['egw']->template->pfp('out','form');
 115                  $GLOBALS['egw']->common->egw_footer();
 116              }
 117          }
 118      }
 119  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7