[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Users/ -> Save.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the 
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/Save.php,v 1.14 2005/03/17 06:37:39 rank Exp $
  17   * Description:  TODO: To be written.
  18   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19   * All Rights Reserved.
  20   * Contributor(s): ______________________________________..
  21   ********************************************************************************/
  22  
  23  require_once ('modules/Users/Users.php');
  24  require_once ('include/logging.php');
  25  require_once ('include/utils/UserInfoUtil.php');
  26  $log =& LoggerManager::getLogger('index');
  27  
  28  
  29  global $adb;
  30  $user_name = $_REQUEST['userName'];
  31  if(isset($_REQUEST['dup_check']) && $_REQUEST['dup_check'] != '')
  32  {
  33          $query = "SELECT user_name FROM vtiger_users WHERE user_name ='".$user_name."'";
  34          $result = $adb->query($query);
  35          if($adb->num_rows($result) > 0)
  36          {
  37          echo 'User Name Already Exists!';
  38          die;
  39      }else
  40      {
  41              echo 'SUCCESS';
  42              die;
  43      }
  44  }
  45                                                                          
  46  if (isset($_POST['record']) && !is_admin($current_user) && $_POST['record'] != $current_user->id) echo ("Unauthorized access to user administration.");
  47  elseif (!isset($_POST['record']) && !is_admin($current_user)) echo ("Unauthorized access to user administration.");
  48  
  49  $focus = new Users();
  50  if(isset($_REQUEST["record"]) && $_REQUEST["record"] != '')
  51  {
  52      $focus->mode='edit';
  53      $focus->id = $_REQUEST["record"];
  54  }
  55  else
  56  {
  57      $focus->mode='';
  58  }    
  59  
  60  
  61  if($_REQUEST['changepassword'] == 'true')
  62  {
  63      $focus->retrieve_entity_info($_REQUEST['record'],'Users');
  64      $focus->id = $_REQUEST['record'];
  65  if (isset($_POST['new_password'])) {
  66          $new_pass = $_POST['new_password'];
  67          $new_passwd = $_POST['new_password'];
  68          $new_pass = md5($new_pass);
  69          $old_pass = $_POST['old_password'];
  70          $uname = $_POST['user_name'];
  71          if (!$focus->change_password($_POST['old_password'], $_POST['new_password'])) {
  72          
  73              header("Location: index.php?action=Error&module=Users&error_string=".urlencode($focus->error_string));
  74          exit;
  75  }
  76  }
  77      
  78  }    
  79  
  80      
  81  //save user Image
  82  if(! $_REQUEST['changepassword'] == 'true')
  83  {
  84      if(strtolower($current_user->is_admin) == 'off'  && $current_user->id != $focus->id)
  85      {
  86          $log->fatal("SECURITY:Non-Admin ". $current_user->id . " attempted to change settings for user:". $focus->id);
  87          header("Location: index.php?module=Users&action=Logout");
  88          exit;
  89      }
  90      if(strtolower($current_user->is_admin) == 'off'  && isset($_POST['is_admin']) && strtolower($_POST['is_admin']) == 'on')
  91      {
  92          $log->fatal("SECURITY:Non-Admin ". $current_user->id . " attempted to change is_admin settings for user:". $focus->id);
  93          header("Location: index.php?module=Users&action=Logout");
  94          exit;
  95      }
  96      
  97      if (!isset($_POST['is_admin'])) $_REQUEST["is_admin"] = 'off';
  98      //Code contributed by mike crowe for rearrange the home page and tab
  99      if (!isset($_POST['deleted'])) $_REQUEST["deleted"] = '0';
 100      if (!isset($_POST['homeorder']) || $_POST['homeorder'] == "" ) $_REQUEST["homeorder"] = 'ILTI,QLTQ,ALVT,PLVT,CVLVT,HLT,OLV,GRT,OLTSO';
 101  
 102      setObjectValuesFromRequest(&$focus);
 103      $focus->saveentity("Users");
 104      //$focus->imagename = $image_upload_array['imagename'];
 105      $focus->saveHomeOrder($focus->id);
 106      $return_id = $focus->id;
 107  
 108  if (isset($_POST['user_name']) && isset($_POST['new_password'])) {
 109          $new_pass = $_POST['new_password'];
 110          $new_passwd = $_POST['new_password'];
 111          $new_pass = md5($new_pass);
 112          $uname = $_POST['user_name'];
 113          if (!$focus->change_password($_POST['confirm_new_password'], $_POST['new_password'])) {
 114          
 115              header("Location: index.php?action=Error&module=Users&error_string=".urlencode($focus->error_string));
 116          exit;
 117  }
 118  }  
 119  
 120  if(isset($focus->id) && $focus->id != '')
 121  {
 122  
 123    if(isset($_POST['user_role']))
 124    {
 125      updateUser2RoleMapping($_POST['user_role'],$focus->id);
 126    }
 127    if(isset($_POST['group_name']) && $_POST['group_name'] != '')
 128    {
 129      updateUsers2GroupMapping($_POST['group_name'],$focus->id);
 130    }
 131  }
 132  else
 133  {
 134    if(isset($_POST['user_role']))
 135    {
 136      insertUser2RoleMapping($_POST['user_role'],$focus->id);
 137    }
 138    if(isset($_POST['group_name']))
 139    {
 140      insertUsers2GroupMapping($_POST['group_name'],$focus->id);
 141    }
 142  }
 143  
 144  //Creating the Privileges Flat File
 145  require_once ('modules/Users/CreateUserPrivilegeFile.php');
 146  createUserPrivilegesfile($focus->id);
 147  createUserSharingPrivilegesfile($focus->id);
 148  
 149  }
 150  if(isset($_POST['return_module']) && $_POST['return_module'] != "") $return_module = $_POST['return_module'];
 151  else $return_module = "Users";
 152  if(isset($_POST['return_action']) && $_POST['return_action'] != "") $return_action = $_POST['return_action'];
 153  else $return_action = "DetailView";
 154  if(isset($_POST['return_id']) && $_POST['return_id'] != "") $return_id = $_POST['return_id'];
 155  if(isset($_REQUEST['activity_mode']))   $activitymode = '&activity_mode='.$_REQUEST['activity_mode'];
 156  if(isset($_POST['parenttab'])) $parenttab = $_POST['parenttab'];
 157  
 158  $log->debug("Saved record with id of ".$return_id);
 159  
 160  
 161  
 162  if($_REQUEST['modechk'] == 'prefview')
 163      header("Location: index.php?action=$return_action&module=$return_module&record=$return_id");
 164  else
 165      header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&parenttab=$parenttab");
 166  
 167  
 168  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7