Client space
In the table role
of the DB, add the role client
:
IMPORTANT: Change the table prefix of the DB if it's not izendsms_
.
Code
Rename the file actions/home.php to actions/main.php.
Edit the file actions/main.php.
Rename the function main
.
Recreate the file actions/home.php with the following content:
- require_once 'userhasrole.php';
- function home($lang) {
- if (user_has_role('client')) {
- return run('client', $lang);
- }
- return run('main', $lang);
- }
Runs the action client
if the user is connected as a client or the action main
by default.
Create the file actions/client.php with the following content:
- function client($lang) {
- head('title', translate('client:title', $lang));
- $banner = build('banner', $lang);
- $info = build('clientinfo', $lang);
- $content=view('client', $lang, compact('info'));
- $output = layout('standard', compact('banner', 'content'));
- return $output;
- }
Add the translation of the title of the page in the file includes/strings.inc in English and in French:
- 'client:title' => 'Client',
- 'client:title' => 'Client',
The block clientinfo
details a client's account.
Create the file blocks/clientinfo.php with the following content:
- require_once 'userprofile.php';
- function clientinfo($lang) {
- $name=user_profile('name');
- $mail=user_profile('mail');
- $account_page=url('account', $lang);
- $output = view('clientinfo', $lang, compact('name', 'mail', 'account_page'));
- return $output;
- }
Add the file views/en/clientinfo.phtml:
- <p><span id="clientname" title="Identification"><?php echo $name; ?></span>
- <img src="<?php echo $base_path; ?>/avatars/<?php echo $name; ?>.png" alt="" title="<?php echo $name; ?>" />
- <span id="clientmail" title="Email"><?php echo $mail; ?></span></p>
- <p class="info noprint">To modify your identifier, your email or change your password, <a href="<?php echo $account_page; ?>" title="Modify your personal information">click here</a>.</p>
Add the file views/fr/clientinfo.phtml:
- <p><span id="clientname" title="Identification"><?php echo $name; ?></span>
- <img src="<?php echo $base_path; ?>/avatars/<?php echo $name; ?>.png" alt="" title="<?php echo $name; ?>" />
- <span id="clientmail" title="Email"><?php echo $mail; ?></span></p>
- <p class="info noprint">Pour modifier votre identifiant, votre email ou changer votre mot de passe, <a href="<?php echo $account_page; ?>" title="Modifiez vos informations personnelles">cliquez ici</a>.</p>
Add the CSS for the identifier and the email address at the end of the file css/theme.css:
Add the file views/en/client.phtml:
- <h3>Your account</h3>
- <?php echo $info; ?>
Add the file views/fr/client.phtml:
- <h3>Votre compte</h3>
- <?php echo $info; ?>
Add the role client
to the configuration parameter $supported_roles
in includes/config.inc:
- $supported_roles=array('administrator', 'writer', 'reader', 'moderator', 'client');
Add the translation of the role client
in the files views/en/useredit.phtml et views/fr/useredit.phtml:
- <?php $rolename=array('administrator' => 'administrator', 'writer' => 'writer', 'reader' => 'reader', 'moderator' => 'moderator', 'client' => 'client'); ?>
- <?php $rolename=array('administrator' => 'administrateur', 'writer' => 'rédacteur', 'reader' => 'lecteur', 'moderator' => 'modérateur', 'client' => 'client'); ?>
Authorize a user to modify his password in the file blocks/useredit.php:
- $with_newpassword=($user_id != 1 and $is_owner);
Systematically create a user account for a client in the file blocks/register.php:
- $user_id = $r;
- user_set_role($user_id, 'client');
Test
Connect as an administrator. Enter in the administrative part of the site.
Create an account for the user barfoo
with the password barf00
.
Go back to the administrative part.
Search for the user barfoo
and edit his profile.
Verify that the role client
is checked.
administrator writer reader moderator client
Connect as a client with the identifier barfoo
.
The home page of the site displays the client space.
Your account
barfoo barfoo@izendsms.com
Git
- /izendsms.com
- avatars
- barfoo.png
- actions
- client.php
- home.php
- main.php
- blocks
- clientinfo.php
- register.php
- useredit.php
- css
- theme.css
- includes
- config.inc
- strings.inc
- views
- en
- client.phtml
- clientinfo.phtml
- useredit.phtml
- fr
- client.phtml
- clientinfo.phtml
- useredit.phtml
- en
- avatars
Commit this version:
$ git status
$ git add --update
$ git commit -m'Creates client space'
IMPORTANT: Edit the DB connector in the file includes/db.inc.
Comments