[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 23/30: Add email, change preference and admin
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 23/30: Add email, change preference and administration for this |
Date: |
Tue, 02 Jun 2015 22:29:13 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 603f502579dbb72b0d5a3083b6e768ee44f8f6f5
Author: Dany De Bontridder <address@hidden>
Date: Tue Jun 2 19:52:36 2015 +0200
Add email, change preference and administration for this
---
html/do.php | 2 +
html/user_login.php | 2 +
include/ajax_preference.php | 9 +++-
include/class_user.php | 7 ++-
include/user_detail.inc.php | 121 ++++++++++++++++++++++++------------------
5 files changed, 87 insertions(+), 54 deletions(-)
diff --git a/html/do.php b/html/do.php
index b61b689..2f52600 100644
--- a/html/do.php
+++ b/html/do.php
@@ -144,6 +144,8 @@ if ( isset ($_POST['set_preference'])) {
$_SESSION['g_theme']=$style_user;
$_SESSION['g_pagesize']=$p_size;
$_SESSION['g_lang']=$lang;
+ $g_user->email=$p_email;
+ $g_user->save();
}
/*
diff --git a/html/user_login.php b/html/user_login.php
index 1df4193..a76aa54 100644
--- a/html/user_login.php
+++ b/html/user_login.php
@@ -110,6 +110,8 @@ if ( isset ($_POST['set_preference'])) {
$User->save_global_preference('LANG', $lang);
$_SESSION['g_theme']=$style_user;
$_SESSION['g_lang']=$lang;
+ $User->load();
+ $User->save_email($p_email);
}
echo '<div class="welcome"> ';
/**
diff --git a/include/ajax_preference.php b/include/ajax_preference.php
index 3e1beab..ffa6b56 100644
--- a/include/ajax_preference.php
+++ b/include/ajax_preference.php
@@ -20,7 +20,6 @@
/**\file
* \brief this file is always included and then executed
* it permits to change the user preferences
- * \see user_pref.php
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
require_once('class_user.php');
@@ -69,6 +68,14 @@ if (isset($_REQUEST['gDossier']) && $_REQUEST['gDossier']<>0)
<FORM METHOD="POST">
<fieldset style="margin: 1%"><legend><?php echo _('Options
Générales')?></legend>
<table>
+ <tr>
+ <td>
+ <?php echo _('Email')?>
+ </td>
+ <td>
+ <input type="text" name="p_email" value="<?php echo
$g_user->email?>" class="input_text">
+ </td>
+ </tr>
<tr><td>
Mot de passe :
</td>
diff --git a/include/class_user.php b/include/class_user.php
index 9874df1..cc8e7ff 100644
--- a/include/class_user.php
+++ b/include/class_user.php
@@ -120,6 +120,7 @@ class User
$row = Database::fetch_array($Res, 0);
$this->id = $row['use_id'];
$this->first_name = $row['use_first_name'];
+ $this->last_name = $row['use_name'];
$this->name = $row['use_name'];
$this->active = $row['use_active'];
$this->login = $row['use_login'];
@@ -1169,7 +1170,11 @@ class User
alert(_("Les mots de passe ne correspondent pas. Mot de passe
inchangé"));
}
}
-
+ function save_email($p_email)
+ {
+ $repo=new Database();
+ $repo->exec_sql("update ac_users set use_email=$1 where use_login=$2",
array($p_email, $_SESSION['g_user']));
+ }
}
?>
diff --git a/include/user_detail.inc.php b/include/user_detail.inc.php
index d4a457b..c3aa149 100644
--- a/include/user_detail.inc.php
+++ b/include/user_detail.inc.php
@@ -42,7 +42,9 @@ if ($UserChange->id == false)
html_page_stop();
}
-/* Save the changes */
+/*
+ * Update user changes
+ */
if (isset($_POST['SAVE']))
{
$uid = $_POST['UID'];
@@ -50,29 +52,42 @@ if (isset($_POST['SAVE']))
// Update User
$cn = new Database();
$UserChange = new User($cn, $uid);
+
if ($UserChange->load() == -1)
{
alert("Cet utilisateur n'existe pas");
}
else
{
- $UserChange->first_name = $_POST['fname'];
- $UserChange->last_name = $_POST['lname'];
- $UserChange->active = $_POST['Actif'];
- $UserChange->admin = $_POST['Admin'];
- if ( trim($_POST['password'])<>'')
+ $UserChange->first_name =HtmlInput::default_value_post('fname',null);
+ $UserChange->last_name = HtmlInput::default_value_post('lname',null);
+ $UserChange->active = HtmlInput::default_value_post('Actif',-1);
+ $UserChange->admin = HtmlInput::default_value_post('Admin',-1);
+ $UserChange->email = HtmlInput::default_value_post('email',null);
+ if ($UserChange->active ==-1 || $UserChange->admin ==-1)
+ {
+ var_dump($_POST);
+ var_dump($UserChange);
+ die ('Missing data');
+ }
+ else if ( trim($_POST['password'])<>'')
{
- $UserChange->pass = md5($_POST['password']);
- } else
- {
- $UserChange->pass=$UserChange->password;
- }
- $UserChange->save();
+ $UserChange->pass = md5($_POST['password']);
+ $UserChange->save();
+ }
+ else
+ {
+ $UserChange->pass=$UserChange->password;
+ $UserChange->save();
+ }
}
}
else
{
+ //
+ // Delete the user
+ //
if (isset($_POST["DELETE"]))
{
$cn = new Database();
@@ -111,54 +126,56 @@ $it_pass->value="";
</TR>
<tr>
<td>
+ <?php
+ echo _('email');
+ ?>
+ </td>
+ <td>
+ <INPUT class="input_text" type="text" NAME="email"
value="<?php echo $UserChange->email;?>">
+ </td>
+ </tr>
+ <tr>
+ <td>
Mot de passe :<span class="info">Laisser à VIDE pour ne PAS le
changer</span>
</td>
<td>
<?php echo $it_pass->input();?>
</td>
</tr>
+ <tr>
+ <td>
+ <?php echo _('Actif');?>
+ </td>
+ <td>
+ <?php
+ $select_actif=new ISelect('Actif');
+ $select_actif->value=array(
+ array('value'=>0,'label'=>_('Non')),
+ array('value'=>1,'label'=>_('Oui'))
+ );
+ $select_actif->selected=$UserChange->active;
+ echo $select_actif->input();
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <?php echo _('Type');?>
+ </td>
+ <td>
+ <?php
+ $select_admin=new ISelect('Admin');
+ $select_admin->value=array(
+ array('value'=>0,'label'=>_('Utilisateur normal')),
+ array('value'=>1,'label'=>_('Administrateur'))
+ );
+ $select_admin->selected=$UserChange->admin;
+ echo $select_admin->input();
+ ?>
+ </td>
+ </tr>
</table>
- <TABLE>
-<?php
-if ($UserChange->active == 1)
-{
- $ACT = "CHECKED";
- $NACT = "UNCHECKED";
-}
-else
-{
- $ACT = "UNCHECKED";
- $NACT = "CHECKED";
-}
-echo "<TR><TD>";
-printf('<INPUT type="RADIO" NAME="Actif" VALUE="1" %s> Actif', $ACT);
-echo "</TD><TD>";
-printf('<INPUT type="RADIO" NAME="Actif" VALUE="0" %s> Non Actif', $NACT);
-echo "</TD></TR>";
-?>
- </TABLE>
-</TD>
-<TD>
- <TABLE>
-<?php
-if ($UserChange->admin == 1)
-{
- $ACT = "CHECKED";
- $NACT = "UNCHECKED";
-}
-else
-{
- $ACT = "UNCHECKED";
- $NACT = "CHECKED";
-}
-echo "<TR><TD>";
-printf('<INPUT type="RADIO" NAME="Admin" VALUE="1" %s> Administrateur global',
$ACT);
-echo "</TD><TD>";
-printf('<INPUT type="RADIO" NAME="Admin" VALUE="0" %s> Pas administrateur
global ', $NACT);
-echo "</TD></TR>";
-?>
- </TABLE>
<input type="Submit" class="button" NAME="SAVE" VALUE="Sauver les
changements" onclick="return confirm('Confirmer changement ?');">
<input type="Submit" class="button" NAME="DELETE" VALUE="Effacer"
onclick="return confirm('Confirmer effacement ?');" >
- [Noalyss-commit] [noalyss] 14/30: Administration user : add condition if no folder exists + esthetic, (continued)
- [Noalyss-commit] [noalyss] 14/30: Administration user : add condition if no folder exists + esthetic, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 15/30: Administration user : esthetic + rewrite add user Correct bug : ajax_admin.js, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 17/30: Administration user : esthetic, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 18/30: HtmlInput : add a new function to create an empty anchor, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 12/30: Administration user : Add / remove right on folder in ajax, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 19/30: HtmlInput :: anchor_empty add a title, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 20/30: Message when no financial ledger are found, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 21/30: Message when no financial ledger are found, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 22/30: Fix bug in authentication for normal user, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 24/30: Add email, change preference and administration for this, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 23/30: Add email, change preference and administration for this,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 26/30: fix bug with email user, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 25/30: Remove obsolete file, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 27/30: Documentation, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 28/30: Esthetique, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 29/30: Remove button (x) + center the text, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 30/30: Esthetic, Dany De Bontridder, 2015/06/02