<?php
/**
 * @package linea21.core
 * @subpackage user
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

//////////// Check Inclusion de pages ////////////
if (!class_exists('auth')) {
  include_once("../lib/lib_common.php");
  ReloadIndex('admin');
}
////////////

//////////// Check Droits utilisateur ////////////
if (!$l21auth->isSuperAdmin()) ReloadIndex('admin');
////////////

if(isset($_POST['id']))	$id=$_POST['id'];
if(isset($_GET['id']))	$id=$_GET['id'];

$requete=SQL_getAllUserInfo($id);
$result=$sql_object->DBSelect($requete);
if($result==0 || count($result)!=1) exit;
$user_email=$result[0]['profile_email'];
$user_login=$result[0]['user_login'];

$user_object= new user;
$new_pass=$user_object->GetNewPassword();
$result=$user_object->UpdateUserPassword($id, $new_pass, $sql_object);
/** include envoi de mail */
$todo_mail='change_pass';
include_once(override('../user/mail_actions.php'));
include_once('../mail/template.php');
/** end mail */
$link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
if($result) header("Location: ".$link_confirm);
else  system_error();
?>