Browse Source

Start rewrite of user edit

Léo Serre 11 months ago
parent
commit
604e42d323

+ 8
- 8
controllers/d.users.php View File

@@ -39,7 +39,7 @@ if(isset($controller->splitted_url[1])) {
39 39
 					// PROCESS DATA FROM FORM
40 40
 					$user = new User();
41 41
 					$user->name = $_POST['login'];
42
-					$user->email = strtolower($_POST['mail']);
42
+					$user->email = strtolower($_POST['email']);
43 43
 					$user->rank = "registered";
44 44
 
45 45
 					if($_POST['captcha'] == -2) {
@@ -54,7 +54,7 @@ if(isset($controller->splitted_url[1])) {
54 54
 								}
55 55
 							}
56 56
 							else {
57
-								header('Location: '.$config['rel_root_folder'].'user/signin?error=mail');
57
+								header('Location: '.$config['rel_root_folder'].'user/signin?error=email');
58 58
 							}
59 59
 						}
60 60
 						else {
@@ -76,7 +76,7 @@ if(isset($controller->splitted_url[1])) {
76 76
 				if (isset($_POST['submit'])) {
77 77
 					// PROCESS DATA FROM FORM
78 78
 					$user = new User();
79
-					$user->email = strtolower($_POST['mail']);
79
+					$user->email = strtolower($_POST['email']);
80 80
 
81 81
 					if($user->availableMail()) {
82 82
 						header('Location: '.$config['rel_root_folder'].'user/password_lost?error=1');
@@ -116,11 +116,11 @@ if(isset($controller->splitted_url[1])) {
116 116
 							$userProfile->name = $receivedUser->name;
117 117
 						else if($receivedUser->name != $userProfile->name)
118 118
 							$nameError=1;
119
-						$receivedUser->mail = strtolower($_POST['mail']);
120
-						if($receivedUser->mail != $userProfile->mail && $receivedUser->availableMail())
121
-							$userProfile->mail = $receivedUser->mail;
122
-						else if ($receivedUser->mail != $userProfile->mail)
123
-							$mailError=1;
119
+						$receivedUser->email = strtolower($_POST['email']);
120
+						if($receivedUser->email != $userProfile->email && $receivedUser->availableMail())
121
+							$userProfile->email = $receivedUser->email;
122
+						else if ($receivedUser->email != $userProfile->email)
123
+							$emailError=1;
124 124
 						if($_POST['password']!='')
125 125
 							$userProfile->password=sha1($_POST['password']);
126 126
 						$userProfile->locale=$_POST['locale'];

+ 7
- 7
models/d.users.php View File

@@ -11,12 +11,12 @@
11 11
 require_once($config['models_folder']."d.locales.php");
12 12
 
13 13
 $ranks = array(
14
-	"administrator"	=> array(1000,"Administrateur", "red"),
15
-	"moderator" 	=> array(800,"Modérateur", "orangered"),
16
-	"premium" 		=> array(600,"Membre premium", "orange"),
17
-	"registered"	=> array(400,"Utilisateur", "green"),
18
-	"blocked"		=> array(200,"Membre archivé", "#aaa"),
19
-	"visitor"		=> array(0,"Visiteur", "black")
14
+	"administrator"	=> array(1000,"Administrateur", "red", "administrator"),
15
+	"moderator" 	=> array(800,"Modérateur", "orangered", "moderator"),
16
+	"premium" 		=> array(600,"Membre premium", "orange", "premium"),
17
+	"registered"	=> array(400,"Utilisateur", "green", "registered"),
18
+	"blocked"		=> array(200,"Membre archivé", "#aaa", "blocked"),
19
+	"visitor"		=> array(0,"Visiteur", "black", "visitor")
20 20
 );
21 21
 
22 22
 class User
@@ -117,7 +117,7 @@ class User
117 117
 		global $ranks;
118 118
 
119 119
 		if( $no_html )
120
-			return $ranks[$this->rank][1];
120
+			return $this->rank;
121 121
 		else
122 122
 			return '<span class="userrole" style="color: '.$ranks[$this->rank][2].';">'.$ranks[$this->rank][1].'</span>';
123 123
 	}

+ 3
- 3
views/blocks/d.nav.html View File

@@ -11,9 +11,9 @@
11 11
 						<li class="on-bar"><a class="on-bar" href="<?=$config['rel_root_folder']?>community">Contribuer</a></li>
12 12
 						<li class="on-bar has-sub">
13 13
 							<? if ($user->get_id() == 0) { ?>
14
-							<a class="on-bar" href="#"><i class="icon fa fa-user"></i></a>
14
+							<a class="on-bar" href="#"><i class="icon fas fa-user"></i></a>
15 15
 							<? } elseif ($user->get_avatar() == NULL) { ?>
16
-							<a class="on-bar" href="#"><i class="icon fa fa-user-secret"></i></a>
16
+							<a class="on-bar" href="#"><i class="icon fas fa-user-secret"></i></a>
17 17
 							<? } else { ?>
18 18
 							<a class="on-bar" href="#"><img alt="Avatar" class="icon avatar" src="<?=$config['rel_root_folder']?>medias/avatars/<?=$user->get_avatar()?>_s.jpg"></a>
19 19
 							<? } ?>
@@ -37,7 +37,7 @@
37 37
 								<? } ?>
38 38
 							</ul>
39 39
 						</li>
40
-						<li class="on-bar has-sub"><a class="on-bar" href="#"><i class="icon fa fa-question"></i></a>
40
+						<li class="on-bar has-sub"><a class="on-bar" href="#"><i class="icon fas fa-question"></i></a>
41 41
 							<ul>
42 42
 								<li><a href="<?=$config['rel_root_folder']?>wiki/help">Aide</a></li>
43 43
 								<li><a href="<?=$config['rel_root_folder']?>blog">Blog</a></li>

+ 1
- 1
views/d.user.password_lost.html View File

@@ -13,7 +13,7 @@
13 13
 				<? if(isset($_GET['error']) AND $_GET['error']==1) { ?>
14 14
 					<p style="color: red;">Cette adresse mail n'existe pas.</p>
15 15
 				<? } ?>
16
-				<input type="text" name="mail" id="mail" placeholder="Adresse mail">
16
+				<input type="text" name="email" id="email" placeholder="Adresse mail">
17 17
 				<input type="submit" name="submit" value="Envoyer un nouveau mot de passe">
18 18
 			</form>
19 19
 		</section>

+ 33
- 33
views/d.user.profile.edit.html View File

@@ -8,59 +8,59 @@
8 8
 		<? include('blocks/d.nav.html'); ?>
9 9
 
10 10
 		<section id="profile">
11
-			<? if ($userProfile->id != 0) { ?>
11
+			<? if ($userProfile->get_id() != 0) { ?>
12 12
 				<h1><?=$userProfile->name?></h1>
13 13
 				<article>
14 14
 					<? if(isset($nameError) AND $nameError==1) { ?>
15 15
 						<p style="color: #660000;">Veuillez choisir un autre nom d'utilisateur.</p>
16 16
 					<? } ?>
17
-					<? if(isset($nameError) AND $nameError==1) { ?>
18
-						<p style="color: #660000;">Veuillez choisir un autre nom d'utilisateur.</p>
17
+					<? if(isset($emailError) AND $emailError==1) { ?>
18
+						<p style="color: #660000;">Veuillez choisir un autre email.</p>
19 19
 					<? } ?>
20 20
 					<? if(isset($updated) AND $updated==1) { ?>
21 21
 						<p style="color: #006600;">Le profil a été mis à jour.</p>
22 22
 					<? } ?>
23
-					<form action="<?=$config['rel_root_folder']?>user/p/<?=$userProfile->id?>/edit" method="post" class="edituser" enctype="multipart/form-data">
24
-						<aside class="<?=$userProfile->avatar=='t'?'':'no'?>avatar">
23
+					<form action="<?=$config['rel_root_folder']?>user/p/<?=$userProfile->get_id()?>/edit" method="post" class="edituser" enctype="multipart/form-data">
24
+						<aside class="<?=$userProfile->get_avatar()!=NULL?'':'no'?>avatar">
25 25
 							<div id="picturebuttonscontainer">
26 26
 								<div id="picturebuttons">
27
-									<a href="#" id="uploadavatar"><i class="fa fa-camera"></i></a><a <?=$userProfile->avatar=='t'?'':'style="display: none;"'?> href="#" id="deleteavatar" style="font-size: 1.1em;"><i class="fa 	fa-trash"></i></a>
27
+									<a href="#" id="uploadavatar"><i class="fas fa-camera"></i></a><a <?=$userProfile->get_avatar()!=NULL?'':'style="display: none;"'?> href="#" id="deleteavatar" style="font-size: 1.1em;"><i class="fas fa-trash"></i></a>
28 28
 								</div>
29 29
 							</div>
30 30
 
31
-							<img alt="Avatar" id="profileavatar" src="<?=$config['rel_root_folder']?>medias/avatars/<?=$userProfile->id?>_p.jpg" alt="Profile picture">
32
-							<i id="profilenoavatar" class="fa fa-user-secret"></i>
31
+							<img alt="Avatar" id="profileavatar" src="<?=$config['rel_root_folder']?>medias/avatars/<?=$userProfile->get_id()?>_p.jpg" alt="Profile picture">
32
+							<i id="profilenoavatar" class="fas fa-user-secret"></i>
33 33
 						</aside>
34 34
 
35
-						<input id="avatarcheckbox" style="display: none;" type="checkbox" name="avatar" <?=$userProfile->avatar=='t'?'checked':''?>>
35
+						<input id="avatarcheckbox" style="display: none;" type="checkbox" name="avatar" <?=$userProfile->get_avatar()!=NULL?'checked':''?>>
36 36
 						<input type="hidden" name="MAX_FILE_SIZE" value="4194304" />
37 37
 						<input id="avatarfile" name="avatarfile" style="display: none;" type="file" accept="image/*" />
38 38
 
39
-							<div id="description">
40
-								<ul>
41
-									<li><label for="name">Nom d'utilisateur :</label><input name="name" id="name" type="text" value="<?=$userProfile->name?>" placeholder="Charlie"></li>
42
-									<li><label for="mail">Adresse mail :</label><input name="mail" id="mail" type="text" value="<?=$userProfile->mail?>" placeholder="charlie@mountain.org"></li>
43
-									<li><label for="password">Mot de passe :</label><input name="password" id="password" type="password" placeholder="Nouveau mot de passe"></li>
44
-									<li><label for="locale">Langue :</label>
45
-										<select name="locale" id="locale">
46
-											<? foreach($config['locales'] as $locale) { ?>
47
-												<option <?=$userProfile->locale==$locale[0]?'selected':''?> value="<?=$locale[0]?>"><?=$locale[5]?></option>
48
-											<? } ?>
49
-										</select></li>
50
-									<? if($user->role >= 1000) { ?>
51
-									<li><label for="role">Rang : </label>
52
-										<select name="role" id="role">
53
-											<? foreach($config['roles'] as $role) { ?>
54
-												<option <?=$userProfile->role==$role[0]?'selected':''?> value="<?=$role[0]?>"><?=$role[1]?></option>
55
-											<? } ?>
56
-										</select></li>
57
-									<? } ?>
58
-									<li><label for="website">Site internet :</label><input name="website" id="website" type="text" value="<?=$userProfile->website?>" placeholder="mountain.org"></li>
39
+						<div id="description">
40
+							<ul>
41
+								<li><label for="name">Nom d'utilisateur :</label><input name="name" id="name" type="text" value="<?=$userProfile->name?>" placeholder="Charlie"></li>
42
+								<li><label for="email">Adresse mail :</label><input name="email" id="email" type="text" value="<?=$userProfile->email?>" placeholder="charlie@mountain.org"></li>
43
+								<li><label for="password">Mot de passe :</label><input name="password" id="password" type="password" placeholder="Nouveau mot de passe"></li>
44
+								<li><label for="locale">Langue :</label>
45
+									<select name="locale" id="locale">
46
+										<? foreach($config['locales'] as $locale) { ?>
47
+											<option <?=$userProfile->locale==$locale[0]?'selected':''?> value="<?=$locale[0]?>"><?=$locale[5]?></option>
48
+										<? } ?>
49
+									</select></li>
50
+								<? if($user->rankIsHigher("administrator")) { ?>
51
+								<li><label for="rank">Rang : </label>
52
+									<select name="rank" id="rank">
53
+										<? foreach($ranks as $rank) { ?>
54
+											<option <?=$userProfile->get_rank(true)==$rank[3]?'selected':''?> value="<?=$rank[0]?>"><?=$rank[1]?></option>
55
+										<? } ?>
56
+									</select></li>
57
+								<? } ?>
58
+								<li><label for="website">Site internet :</label><input name="website" id="website" type="text" value="<?=$userProfile->website?>" placeholder="mountain.org"></li>
59 59
 
60
-									<input name="submit" id="submit" type="submit" value="Envoyer">
61
-								</ul>
62
-							</div>
63
-							<div style="clear:both;"></div>
60
+								<input name="submit" id="submit" type="submit" value="Envoyer">
61
+							</ul>
62
+						</div>
63
+						<div style="clear:both;"></div>
64 64
 					</form>
65 65
 				</article>
66 66
 			<? } else { ?>

+ 2
- 2
views/d.user.signin.html View File

@@ -13,7 +13,7 @@
13 13
 				<? if(isset($_GET['error']) AND $_GET['error']=="name") { ?>
14 14
 					<p style="color: red;">Veuillez choisir un autre nom d'utilisateur.</p>
15 15
 				<? } ?>
16
-				<? if(isset($_GET['error']) AND $_GET['error']=="mail") { ?>
16
+				<? if(isset($_GET['error']) AND $_GET['error']=="email") { ?>
17 17
 					<p style="color: red;">Cette adresse mail est déjà prise.</p>
18 18
 				<? } ?>
19 19
 				<? if(isset($_GET['error']) AND $_GET['error']=="empty") { ?>
@@ -25,7 +25,7 @@
25 25
 				<? } ?>
26 26
 				<input type="text" name="login" id="login" placeholder="Nom d'utilisateur">
27 27
 				<input type="password" name="password" id="password" placeholder="Mot de passe">
28
-				<input type="text" name="mail" id="mail" placeholder="Adresse mail">
28
+				<input type="text" name="email" id="email" placeholder="Adresse mail">
29 29
 				<p id="captcha">
30 30
 					<input type="hidden" id="captchahidden" name="captcha" value="10">
31 31
 					<span id="captchatext">Merci d'attendre <b id="captchasec">10 s</b> avant de pouvoir vous inscrire.<br>

Loading…
Cancel
Save