[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 15/30: Administration user : esthetic + rewri
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 15/30: Administration user : esthetic + rewrite add user Correct bug : ajax_admin.js |
Date: |
Tue, 02 Jun 2015 22:29:09 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 1d177f5ebf4190e51a5faa7eb7758a2834149c05
Author: Dany De Bontridder <address@hidden>
Date: Mon Jun 1 22:17:33 2015 +0200
Administration user : esthetic + rewrite add user
Correct bug : ajax_admin.js
---
include/ajax_admin.php | 2 +-
include/class_user.php | 39 +++++++++++++++++++++-------
include/constant.php | 11 +++++---
include/user.inc.php | 64 ++++++++++++++++++++++++++++++-----------------
4 files changed, 78 insertions(+), 38 deletions(-)
diff --git a/include/ajax_admin.php b/include/ajax_admin.php
index c2baed0..df96795 100644
--- a/include/ajax_admin.php
+++ b/include/ajax_admin.php
@@ -138,7 +138,7 @@ if ($op=='folder_display') // operation
</form>
<p>
<?php
- $found_dossier=count($a_dossier);
+ $nb_dossier=count($a_dossier);
$max=(
$nb_dossier>=MAX_FOLDER_TO_SHOW)?MAX_FOLDER_TO_SHOW:$nb_dossier;
echo _('Dossiers trouvés').':'.$nb_dossier." "._('Dossiers
affichés').$max;
?>
diff --git a/include/class_user.php b/include/class_user.php
index 2e9f408..195d333 100644
--- a/include/class_user.php
+++ b/include/class_user.php
@@ -40,7 +40,13 @@ class User
var $db;
var $admin;
var $valid;
-
+ var $first_name;
+ var $name;
+ var $active ;
+ var $login ;
+ var $password ;
+ var $email ;
+
function User(&$p_cn, $p_id = -1)
{
// if p_id is not set then check the connected user
@@ -99,13 +105,14 @@ class User
$sql_array = array($this->id);
}
$sql = "select use_id,
- use_first_name,
- use_name,
- use_login,
- use_active,
- use_admin,
- use_pass
- from ac_users ";
+ use_first_name,
+ use_name,
+ use_login,
+ use_active,
+ use_admin,
+ use_pass,
+ use_email
+ from ac_users ";
$cn = new Database();
$Res = $cn->exec_sql($sql . $sql_cond, $sql_array);
if (($Max = Database::num_row($Res)) == 0)
@@ -118,15 +125,27 @@ class User
$this->login = $row['use_login'];
$this->admin = $row['use_admin'];
$this->password = $row['use_pass'];
+ $this->email=$row['use_email'];
}
function save()
{
$Sql = "update ac_users set use_first_name=$1, use_name=$2
- ,use_active=$3,use_admin=$4,use_pass=$5 where use_id=$6";
+ ,use_active=$3,use_admin=$4,use_pass=$5 ,use_email = $7 where
use_id=$6";
+ $cn = new Database();
+ $Res = $cn->exec_sql($Sql, array($this->first_name,
$this->last_name, $this->active, $this->admin, $this->pass,
$this->id,$this->email));
+ }
+ function insert()
+ {
+
+ $Sql = "INSERT INTO ac_users(
+ use_first_name, use_name, use_login, use_active,
use_pass,
+ use_admin, use_email)
+ VALUES ($1, $2, $3, $4, $5, $6, $7) returning
use_id";
+
$cn = new Database();
- $Res = $cn->exec_sql($Sql, array($this->first_name,
$this->last_name, $this->active, $this->admin, $this->pass, $this->id));
+ $this->id= $cn->get_value($Sql, array($this->first_name,
$this->last_name, $this->login,0,0, $this->pass,$this->email));
}
/**
diff --git a/include/constant.php b/include/constant.php
index 35b065f..e5e86f2 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -31,6 +31,11 @@ global $version_noalyss;
*/
$inc_path=get_include_path();
$dirname=dirname(__FILE__);
+/* Global variable of the include dir */
+global $g_include_dir,$g_ext_dir;
+$g_include_dir=$dirname;
+$g_ext_dir = $dirname."/ext";
+
if ( strpos($inc_path,";") != 0 ) {
$new_path=$inc_path.';'.$dirname;
$os=0; /* $os is 0 for windoz */
@@ -60,19 +65,17 @@ $g_failed="<span
style=\"font-size:18px;color:red\">✖</span>";
$g_succeed="<span style=\"font-size:18px;color:green\">✓</span>";
/* uncomment for development */
-/*
define ('SVNINFO',6800);
define ("DEBUG",true);
define ("LOGINPUT",true);
- */
-define ('SVNINFO',6803);
+/*define ('SVNINFO',6801);
define ("DEBUG",false);
define ("LOGINPUT",false);
-
+*/
$version_noalyss=SVNINFO;
// If you don't want to be notified of the update
// define ("SITE_UPDATE",'');
diff --git a/include/user.inc.php b/include/user.inc.php
index 85799ee..e0842eb 100644
--- a/include/user.inc.php
+++ b/include/user.inc.php
@@ -35,23 +35,27 @@ if ( isset ($_POST["ADD"]) )
{
$cn=new Database();
$pass5=md5($_POST['PASS']);
-
- $first_name=Database::escape_string($_POST['FNAME']);
- $last_name=Database::escape_string($_POST['LNAME']);
- $login=$_POST['LOGIN'];
+ $new_user=new User($cn,0);
+ $new_user->first_name=HtmlInput::default_value_post('FNAME','');
+ $new_user->last_name=HtmlInput::default_value_post('LNAME','');
+ $login=HtmlInput::default_value_post('LOGIN','');
$login=str_replace("'","",$login);
$login=str_replace('"',"",$login);
$login=str_replace(" ","",$login);
$login=strtolower($login);
+ $new_user->login=$login;
+ $new_user->email=HtmlInput::default_value_post('EMAIL','');
if ( trim($login)=="")
{
alert("Le login ne peut pas être vide");
}
else
{
- $Res=$cn->exec_sql("insert into
ac_users(use_first_name,use_name,use_login,use_active,use_pass)
- values ($1,$2,$3,1,$4)",
- array($first_name,$last_name,$login,$pass5));
+ $new_user->insert();
+ $new_user->load();
+ $_REQUEST['use_id']=$new_user->id;
+ require_once("user_detail.inc.php");
+ return;
}
} //SET login
@@ -65,30 +69,44 @@ if ( isset($_REQUEST['det']))
}
?>
-<div id="create_user" style="display:none">
-<h2>Gestion Utilisateurs</h2>
-<TABLE> <TR>
-<form action="admin_repo.php?action=user_mgt" method="POST">
- <TD><H3>
- <?php
- echo _("Ajout d'utilisateur");
-echo '<H3></TD></TR>';
-echo '<TR><TD> First Name </TD><TD><INPUT class="input_text" TYPE="TEXT"
NAME="FNAME"></TD>';
-echo '<TD> Last Name </TD><TD><INPUT class="input_text" TYPE="TEXT"
NAME="LNAME"></TD></TR>';
-echo '<TR><TD> login </TD><TD><INPUT class="input_text" TYPE="TEXT"
NAME="LOGIN"></TD>';
-echo '<TD> password </TD><TD> <INPUT class="input_text" TYPE="TEXT"
NAME="PASS"></TD></TR>';
-echo '</TABLE>';
+<div id="create_user" style="display:none;width:30%;margin-right: 20%"
class="inner_box">
+<?php echo HtmlInput::title_box(_('Ajout Utilisateur'),"create_user","hide");?>
+ <form action="admin_repo.php?action=user_mgt" method="POST"
onsubmit="return check_form()">
+ <div style="text-align: center">
+<TABLE class="result" >
+ <TR><TD style="text-align: right"> <?php echo
_('login')?></TD><TD><INPUT id="input_login" class="input_text" TYPE="TEXT"
NAME="LOGIN"></TD></tr>
+ <TR><TD style="text-align: right"> <?php echo
_('Prénom')?></TD><TD><INPUT class="input_text" TYPE="TEXT"
NAME="FNAME"></TD></tr>
+ <TR><TD style="text-align: right"> <?php echo _('Nom')?></TD><TD><INPUT
class="input_text" TYPE="TEXT" NAME="LNAME"></TD></TR>
+ <TR><TD style="text-align: right"> <?php echo _('Mot de
passe')?></TD><TD> <INPUT id="input_password" class="input_text" TYPE="TEXT"
NAME="PASS"></TD></TR>
+ <TR><TD style="text-align: right"> <?php echo _('Email')?></TD><TD>
<INPUT class="input_text" TYPE="TEXT" NAME="EMAIL"></TD></TR>
+</TABLE>
+<?php
echo HtmlInput::submit("ADD",'Créer Utilisateur');
-echo HtmlInput::button_action("Fermer",
"$('create_user').style.display='none';$('cu').style.display='block'");
-
+echo HtmlInput::button_action("Fermer",
"$('create_user').style.display='none';");
?>
+</div>
</FORM>
+ <script>
+ function check_form() {
+ if ($F('input_login') == "") {
+ alert('<?php echo _('Le login ne peut être vide') ?>');
+ $('input_login').setStyle({border:"red solid 2px"});
+ return false;
+ }
+ if ($F('input_password') == "") {
+ alert('<?php echo _('Le mot de passe ne peut être vide') ?>');
+ $('input_password').setStyle({border:"red solid 2px"});
+ return false;
+ }
+ return true;
+ }
+ </script>
</div>
<?php
echo '<p>';
-echo HtmlInput::button_action("Ajout utilisateur",
"$('create_user').show();$('cu').hide()","cu");
+echo HtmlInput::button_action("Ajout utilisateur",
"$('create_user').show();","cu");
echo '</p>';
// Show all the existing user on 7 columns
$repo=new Dossier(0);
- [Noalyss-commit] [noalyss] 06/30: #1118 : partage de note Esthétique Zoom des notes partagées, (continued)
- [Noalyss-commit] [noalyss] 06/30: #1118 : partage de note Esthétique Zoom des notes partagées, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 04/30: Icon in the menu, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 07/30: Improve method HtmlInput::title_box, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 08/30: #1118 : partage de note Ne peut partager note non sauvée, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 09/30: #1118 : partage de note Esthétique zoom, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 10/30: Database improve : new function get_affected returns the number of rows affected by the last query, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 13/30: Administration user : add condition if no folder exists + esthetic, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 11/30: Remove table priv_user, the local admin and plugin user are obsolete, Dany De Bontridder, 2015/06/02
- [Noalyss-commit] [noalyss] 16/30: Administration user : esthetic, Dany De Bontridder, 2015/06/02
- [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 <=
- [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, 2015/06/02
- [Noalyss-commit] [noalyss] 26/30: fix bug with email user, Dany De Bontridder, 2015/06/02