New class User
This commit is contained in:
parent
1ad7b352cb
commit
82008f93e7
|
@ -85,11 +85,9 @@ if($Login->role()!=='admin') {
|
||||||
$layout['parameters'] = $Login->username();
|
$layout['parameters'] = $Login->username();
|
||||||
}
|
}
|
||||||
|
|
||||||
$_user = $dbUsers->getDb($layout['parameters']);
|
$_User = $dbUsers->getUser($layout['parameters']);
|
||||||
|
|
||||||
// If the user doesn't exist, redirect to the users list.
|
// If the user doesn't exist, redirect to the users list.
|
||||||
if($_user===false) {
|
if($_User===false) {
|
||||||
Redirect::page('admin', 'users');
|
Redirect::page('admin', 'users');
|
||||||
}
|
}
|
||||||
|
|
||||||
$_user['username'] = $layout['parameters'];
|
|
||||||
|
|
|
@ -272,6 +272,8 @@ button.delete-button:hover {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------- BLUDIT PROFILE PICTURE ----------- */
|
||||||
|
|
||||||
/* ----------- LOGIN FORM ----------- */
|
/* ----------- LOGIN FORM ----------- */
|
||||||
|
|
||||||
div.login-box > h1 {
|
div.login-box > h1 {
|
||||||
|
|
|
@ -16,7 +16,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||||
// Security token
|
// Security token
|
||||||
HTML::formInputHidden(array(
|
HTML::formInputHidden(array(
|
||||||
'name'=>'username',
|
'name'=>'username',
|
||||||
'value'=>$_user['username']
|
'value'=>$_User->username()
|
||||||
));
|
));
|
||||||
|
|
||||||
HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child'));
|
HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child'));
|
||||||
|
@ -24,7 +24,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'usernameDisable',
|
'name'=>'usernameDisable',
|
||||||
'label'=>$L->g('Username'),
|
'label'=>$L->g('Username'),
|
||||||
'value'=>$_user['username'],
|
'value'=>$_User->username(),
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
'disabled'=>true,
|
'disabled'=>true,
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
|
@ -33,7 +33,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'firstName',
|
'name'=>'firstName',
|
||||||
'label'=>$L->g('First name'),
|
'label'=>$L->g('First name'),
|
||||||
'value'=>$_user['firstName'],
|
'value'=>$_User->firstName(),
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
|
@ -41,7 +41,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'lastName',
|
'name'=>'lastName',
|
||||||
'label'=>$L->g('Last name'),
|
'label'=>$L->g('Last name'),
|
||||||
'value'=>$_user['lastName'],
|
'value'=>$_User->lastName(),
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
|
@ -49,7 +49,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
|
||||||
echo '<div class="uk-form-row">
|
echo '<div class="uk-form-row">
|
||||||
<label class="uk-form-label">Password</label>
|
<label class="uk-form-label">Password</label>
|
||||||
<div class="uk-form-controls">
|
<div class="uk-form-controls">
|
||||||
<a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$_user['username'].'">'.$L->g('Change password').'</a>
|
<a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$_User->username().'">'.$L->g('Change password').'</a>
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ if($Login->role()==='admin') {
|
||||||
'name'=>'role',
|
'name'=>'role',
|
||||||
'label'=>$L->g('Role'),
|
'label'=>$L->g('Role'),
|
||||||
'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
|
'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
|
||||||
'selected'=>$_user['role'],
|
'selected'=>$_User->role(),
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -67,17 +67,41 @@ if($Login->role()==='admin') {
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'email',
|
'name'=>'email',
|
||||||
'label'=>$L->g('Email'),
|
'label'=>$L->g('Email'),
|
||||||
'value'=>$_user['email'],
|
'value'=>$_User->email(),
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
'tip'=>$L->g('email-will-not-be-publicly-displayed')
|
'tip'=>$L->g('email-will-not-be-publicly-displayed')
|
||||||
));
|
));
|
||||||
|
|
||||||
HTML::legend(array('value'=>$L->g('Social network')));
|
HTML::legend(array('value'=>'Social networks'));
|
||||||
|
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'twitterUsername',
|
'name'=>'twitterUsername',
|
||||||
'label'=>$L->g('Twitter username'),
|
'label'=>'Twitter username',
|
||||||
'value'=>$_user['twitterUsername'],
|
'value'=>$_User->twitterUsername(),
|
||||||
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
|
'tip'=>''
|
||||||
|
));
|
||||||
|
|
||||||
|
HTML::formInputText(array(
|
||||||
|
'name'=>'facebookUsername',
|
||||||
|
'label'=>'Facebook username',
|
||||||
|
'value'=>$_User->facebookUsername(),
|
||||||
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
|
'tip'=>''
|
||||||
|
));
|
||||||
|
|
||||||
|
HTML::formInputText(array(
|
||||||
|
'name'=>'googleUsername',
|
||||||
|
'label'=>'Google username',
|
||||||
|
'value'=>$_User->googleUsername(),
|
||||||
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
|
'tip'=>''
|
||||||
|
));
|
||||||
|
|
||||||
|
HTML::formInputText(array(
|
||||||
|
'name'=>'instagramUsername',
|
||||||
|
'label'=>'Instagram username',
|
||||||
|
'value'=>$_User->instagramUsername(),
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
|
@ -89,7 +113,7 @@ if($Login->role()==='admin') {
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
if( ($Login->role()==='admin') && ($_user['username']!='admin') ) {
|
if( ($Login->role()==='admin') && ($_User->username()!='admin') ) {
|
||||||
|
|
||||||
HTML::legend(array('value'=>$L->g('Delete')));
|
HTML::legend(array('value'=>$L->g('Delete')));
|
||||||
|
|
||||||
|
@ -108,15 +132,15 @@ echo '</div>';
|
||||||
echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">';
|
echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">';
|
||||||
|
|
||||||
echo '<div id="jsprofilePicture">';
|
echo '<div id="jsprofilePicture">';
|
||||||
if(file_exists(PATH_UPLOADS_PROFILES.$_user['username'].'.jpg')) {
|
if(file_exists(PATH_UPLOADS_PROFILES.$_User->username().'.jpg')) {
|
||||||
echo '<img class="uk-border-rounded" src="'.HTML_PATH_UPLOADS_PROFILES.$_user['username'].'.jpg" alt="">';
|
echo '<img class="uk-border-rounded" src="'.HTML_PATH_UPLOADS_PROFILES.$_User->username().'.jpg" alt="">';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo '<div class="uk-block uk-border-rounded uk-block-muted uk-block-large">'.$L->g('Profile picture').'</div>';
|
echo '<div class="uk-block uk-border-rounded uk-block-muted uk-block-large">'.$L->g('Profile picture').'</div>';
|
||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
HTML::profileUploader($_user['username']);
|
HTML::profileUploader($_User->username());
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
|
@ -66,19 +66,9 @@ function build_page($key)
|
||||||
$pageDateFormated = $Page->dateRaw( $Site->dateFormat() );
|
$pageDateFormated = $Page->dateRaw( $Site->dateFormat() );
|
||||||
$Page->setField('date', $pageDateFormated, true);
|
$Page->setField('date', $pageDateFormated, true);
|
||||||
|
|
||||||
// Parse username for the page.
|
// User object
|
||||||
if( $dbUsers->userExists( $Page->username() ) )
|
$username = $Page->username();
|
||||||
{
|
$Page->setField('user', $dbUsers->getUser($username));
|
||||||
$User = new User();
|
|
||||||
$userDatabase = $dbUsers->getDb( $Page->username() );
|
|
||||||
|
|
||||||
foreach($userDatabase as $key=>$value) {
|
|
||||||
$User->setField($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the User object inside the Page object
|
|
||||||
$Page->setField('user', $User);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Page;
|
return $Page;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,19 +75,9 @@ function buildPost($key)
|
||||||
$postDateFormated = $Post->dateRaw( $Site->dateFormat() );
|
$postDateFormated = $Post->dateRaw( $Site->dateFormat() );
|
||||||
$Post->setField('date', $postDateFormated, true);
|
$Post->setField('date', $postDateFormated, true);
|
||||||
|
|
||||||
// Parse username for the page.
|
// User object
|
||||||
if( $dbUsers->userExists( $Post->username() ) )
|
$username = $Post->username();
|
||||||
{
|
$Post->setField('user', $dbUsers->getUser($username));
|
||||||
$User = new User();
|
|
||||||
$userDatabase = $dbUsers->getDb( $Post->username() );
|
|
||||||
|
|
||||||
foreach($userDatabase as $key=>$value) {
|
|
||||||
$User->setField($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the User object inside the Page object
|
|
||||||
$Post->setField('user', $User);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Post;
|
return $Post;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,24 @@ class dbUsers extends dbJSON
|
||||||
parent::__construct(PATH_DATABASES.'users.php');
|
parent::__construct(PATH_DATABASES.'users.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUser($username)
|
||||||
|
{
|
||||||
|
$User = new User();
|
||||||
|
|
||||||
|
if($this->userExists($username))
|
||||||
|
{
|
||||||
|
$User->setField('username', $username);
|
||||||
|
|
||||||
|
foreach($this->db[$username] as $key=>$value) {
|
||||||
|
$User->setField($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $User;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAll()
|
public function getAll()
|
||||||
{
|
{
|
||||||
return $this->db;
|
return $this->db;
|
||||||
|
|
Loading…
Reference in New Issue