Implemented the fully renewed Layout Manager.

Now based on a new database schema, working with events and many more abilities.
An expansion with a built in login page might be possible.
This commit is contained in:
Abel Hoogeveen 2015-08-29 20:30:52 +02:00
parent 714ac95ef8
commit 30f700a727
9 changed files with 1271 additions and 108 deletions

View File

@ -0,0 +1,10 @@
<?php return array (
'contact_email' => '',
'contact_name' => '',
'contact_adress' => '',
'contact_phone' => '',
'contact_postal_code' => '',
'contact_region' => '',
'contact_country' => '',
'contact_city' => ''
) ;

View File

@ -2,6 +2,7 @@
'SITE_URL' => '',
'SITE_DOMAIN' => '',
'SERVER_NAME' => '',
'SITE_LOGO_URL' => '',
'administrator_mail' => '',
'default_controller' => 'standard',
'default_function' => 'index',

View File

@ -120,9 +120,11 @@ class Layout extends Bus {
// Then assign some basic variables for the template
$this->assigned_variables['viewDir'] = $this->config->main->SITE_URL . preg_replace('#/+#','/', substr($directory . "/", -strlen($directory . "/") ) );
$this->assigned_variables['siteURL'] = $this->config->main->SITE_URL;
$this->assigned_variables['siteLogo'] = $this->config->main->SITE_LOGO_URL;
$this->assigned_variables['serverName'] = $this->config->main->SERVER_NAME;
$this->assigned_variables['siteDomain'] = $this->config->main->SITE_DOMAIN;
$this->assigned_variables['adminMail'] = $this->config->main->administrator_mail;
$this->assigned_variables['contact'] = (array) $this->config->contact;
// Select an engine if one is not already selected
if (is_null($this->current_engine)) {

View File

@ -0,0 +1,321 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Verify Email Adress</title>
<style type="text/css">
@media screen and (max-width: 600px) {
table[class="container"] {
width: 95% !important;
}
}
#outlook a {padding:0;}
body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}
.ExternalClass {width:100%;}
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;}
#backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;}
img {outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;}
a img {border:none;}
.image_fix {display:block;}
p {margin: 1em 0;}
h1, h2, h3, h4, h5, h6 {color: black !important;}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {color: blue !important;}
h1 a:active, h2 a:active, h3 a:active, h4 a:active, h5 a:active, h6 a:active {
color: red !important;
}
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited {
color: purple !important;
}
table td {border-collapse: collapse;}
table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }
a {color: #000;}
@media only screen and (max-device-width: 480px) {
a[href^="tel"], a[href^="sms"] {
text-decoration: none;
color: black; /* or whatever your want */
pointer-events: none;
cursor: default;
}
.mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
text-decoration: default;
color: orange !important; /* or whatever your want */
pointer-events: auto;
cursor: default;
}
}
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
a[href^="tel"], a[href^="sms"] {
text-decoration: none;
color: blue; /* or whatever your want */
pointer-events: none;
cursor: default;
}
.mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
text-decoration: default;
color: orange !important;
pointer-events: auto;
cursor: default;
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
/* Put your iPhone 4g styles in here */
}
@media only screen and (-webkit-device-pixel-ratio:.75){
/* Put CSS for low density (ldpi) Android layouts in here */
}
@media only screen and (-webkit-device-pixel-ratio:1){
/* Put CSS for medium density (mdpi) Android layouts in here */
}
@media only screen and (-webkit-device-pixel-ratio:1.5){
/* Put CSS for high density (hdpi) Android layouts in here */
}
/* end Android targeting */
h2{
color:#181818;
font-family:Helvetica, Arial, sans-serif;
font-size:22px;
line-height: 22px;
font-weight: normal;
}
a.link1{
}
a.link2{
color:#fff;
text-decoration:none;
font-family:Helvetica, Arial, sans-serif;
font-size:16px;
color:#fff;border-radius:4px;
}
p{
color:#555;
font-family:Helvetica, Arial, sans-serif;
font-size:16px;
line-height:160%;
}
</style>
<script type="colorScheme" class="swatch active">
{
"name":"Default",
"bgBody":"ffffff",
"link":"fff",
"color":"555555",
"bgItem":"ffffff",
"title":"181818"
}
</script>
</head>
<body>
<!-- Wrapper/Container Table: Use a wrapper table to control the width and the background color consistently of your email. Use this approach instead of setting attributes on the body tag. -->
<table cellpadding="0" width="100%" cellspacing="0" border="0" id="backgroundTable" class='bgBody'>
<tr>
<td>
<table cellpadding="0" width="620" class="container" align="center" cellspacing="0" border="0">
<tr>
<td>
<!-- Tables are the most common way to format your email consistently. Set your table widths inside cells and in most cases reset cellpadding, cellspacing, and border to zero. Use nested tables as a way to space effectively in your message. -->
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" class="container">
<tr>
<td class='movableContentContainer bgItem'>
<div class='movableContent'>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" class="container">
<tr height="40">
<td width="200">&nbsp;</td>
<td width="200">&nbsp;</td>
<td width="200">&nbsp;</td>
</tr>
<tr>
<td width="200" valign="top">&nbsp;</td>
<td width="200" valign="top" align="center">
<div class="contentEditableContainer contentImageEditable">
<div class="contentEditable" align='center' >
<img src="<?php echo($vars["siteLogo"]); ?>" width="155" height="155" alt='Logo' data-default="placeholder" />
</div>
</div>
</td>
<td width="200" valign="top">&nbsp;</td>
</tr>
<tr height="25">
<td width="200">&nbsp;</td>
<td width="200">&nbsp;</td>
<td width="200">&nbsp;</td>
</tr>
</table>
</div>
<div class='movableContent'>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" class="container">
<?php if (isset($vars['verifyURL'])) { ?>
<tr>
<td width="100%" colspan="3" align="center" style="padding-bottom:10px;padding-top:25px;">
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='center' >
<h2 >Welcome to <?php echo($vars['serverName']); ?></h2>
</div>
</div>
</td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td width="400" align="center">
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='left' >
<p >Hello <?php echo($vars['username']); ?>,
<br/>
<br/>
<b>Your account has not yet been verified.</b> Click on the link below to verify your mail adress to grant acess to <?php echo($vars['serverName']); ?>.
<br/><br/>If this account has been created without your knowlegde, please let us know on <a href='<?php echo($vars['siteURL'] ); ?>'>Our Website</a>
</p>
</div>
</div>
</td>
<td width="100">&nbsp;</td>
</tr>
<?php } else { ?>
<tr>
<td width="100%" colspan="3" align="center" style="padding-bottom:10px;padding-top:25px;">
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='center' >
<h2 >Welcome to <?php echo($vars['serverName']); ?></h2>
</div>
</div>
</td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td width="400" align="center">
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='left' >
<p >Hello <?php echo($vars['username']); ?>,
<br/>
<br/>
Your account on <?php echo($vars['serverName']); ?> has been successfully created. You can now start using the website.<br/><br/>
If this account has been created without your knowlegde, please let us know on <a href='<?php echo($vars['siteURL'] ); ?>'>Our Website</a>
</p>
</div>
</div>
</td>
<td width="100">&nbsp;</td>
</tr>
<?php } ?>
</table>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" class="container">
<tr>
<td width="200">&nbsp;</td>
<td width="200" align="center" style="padding-top:25px;">
<?php if (isset($vars['verifyURL'])) { ?>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="200" height="50">
<tr>
<td bgcolor="#ED006F" align="center" style="border-radius:4px;" width="200" height="50">
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='center' >
<a target='_blank' href="<?php echo($vars['verifyURL']); ?>" class='link2'>Verify Email Adress</a>
</div>
</div>
</td>
</tr>
</table>
<?php } ?>
</td>
<td width="200">&nbsp;</td>
</tr>
</table>
</div>
<div class='movableContent'>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" class="container">
<tr>
<td width="100%" colspan="2" style="padding-top:65px;">
<hr style="height:1px;border:none;color:#333;background-color:#ddd;" />
</td>
</tr>
<tr>
<td width="60%" height="70" valign="middle" style="padding-bottom:20px;">
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='left' >
<span style="font-size:13px;color:#181818;font-family:Helvetica, Arial, sans-serif;line-height:200%;">Sent to <?php echo($vars['email']) . (!empty($vars['contact']['contact_name']) ? " by " . $vars['contact']['contact_name'] : "") ?></span>
<br/>
<span style="font-size:11px;color:#555;font-family:Helvetica, Arial, sans-serif;line-height:200%;"><?php echo( (!empty($vars['contact']['contact_adress']) ? $vars['contact']['contact_adress'] : " ") . (!empty($vars['contact']['contact_adress']) || !empty($vars['contact']['contact_phone']) ? " | " : "") . (!empty($vars['contact']['contact_phone']) ? "<a href='tel:".$vars['contact']['contact_phone']."'>".$vars['contact']['contact_phone']."</a>" : "") ); ?></span>
<br/>
<span style="font-size:13px;color:#181818;font-family:Helvetica, Arial, sans-serif;line-height:200%;">
</span>
<br/>
<span style="font-size:13px;color:#181818;font-family:Helvetica, Arial, sans-serif;line-height:200%;">
</div>
</div>
</td>
<td width="40%" height="70" align="right" valign="top" align='right' style="padding-bottom:20px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align='right'>
<tr>
<!-- SOCIAL EXAMPLES HERE
<td width='57%'></td>
<td valign="top" width='34'>
<div class="contentEditableContainer contentFacebookEditable" style='display:inline;'>
<div class="contentEditable" >
<img src="facebook.png" data-default="placeholder" data-max-width='30' data-customIcon="true" width='30' height='30' alt='facebook' style='margin-right:40x;'>
</div>
</div>
</td>
<td valign="top" width='34'>
<div class="contentEditableContainer contentTwitterEditable" style='display:inline;'>
<div class="contentEditable" >
<img src="twitter.png" data-default="placeholder" data-max-width='30' data-customIcon="true" width='30' height='30' alt='twitter' style='margin-right:40x;'>
</div>
</div>
</td>
<td valign="top" width='34'>
<div class="contentEditableContainer contentImageEditable" style='display:inline;'>
<div class="contentEditable" >
<a target='_blank' href="#" data-default="placeholder" style="text-decoration:none;">
<img src="pinterest.png" width="30" height="30" data-max-width="30" alt='pinterest' style='margin-right:40x;' />
</a>
</div>
</div>
</td>-->
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td></tr></table>
</td>
</tr>
</table>
<!-- End of wrapper table -->
</body>
</html>

View File

@ -1,44 +1,70 @@
<?php
/**
* FuzeWorks
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
* @version Version 0.0.1
*/
namespace Module\Sessions;
use \FuzeWorks\Event;
/**
* An Event that gets fired when an email is about to be sent to the user upon registration
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class RegisterMailEvent extends Event {
class SessionRegisterMailEvent extends Event {
/**
* UDT of the user to send the mail to
* @access public
* User Data Table of the user to send the mail to
* @var Array UDT
*/
public $udt;
/**
* HTML of the final mail
* @access public
* @var HTML
*/
*/
public $html;
/**
* Identifier for the verification of a user
* @access public
* @var String Code
*/
public $verifyCode;
/**
* URL to send the verification to
* @access public
* @var String URL
*/
public $verifyURL;
/**
* Wether to use custom HTML or not
* @access public
* @var Boolean true of using custom HTML
*/
public $customHtml = false;
@ -54,7 +80,7 @@ class RegisterMailEvent extends Event {
if (is_bool($bool)) {
$this->customHtml = $bool;
return true;
}
}
throw new ServiceException("Could not set customHtml. Input is not a Boolean", 1);
}
@ -67,6 +93,544 @@ class RegisterMailEvent extends Event {
*/
public function init($udt, $verifyCode, $verifyURL) {
$this->udt = $udt;
$this->verifyCode = $verifyCode;
$this->verifyURL = $verifyURL;
}
}
/**
* Event that is fired when a user tries to log in.
* Event should be cancelled if you want to deny a user to log in.
* If you want to use your own authenticator service, please provide a User Data Table so the authenticator can be successfully identified.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionLoginEvent extends Event {
/**
* The username of the user.
* Available if the user has been successfully verified by the sessions module
* @var String Username
*/
public $username;
/**
* Identifier used when logging in. Usefull for if another module wants to log users in
* @var String Identifier
*/
public $identifier;
/**
* The password used to identify a user
* @var String password
*/
public $password;
/**
* The email of the user.
* Available if the user has been successfully verified by the sessions module
* @var String Email
*/
public $email;
/**
* User id of the user
* @var Int User Id
*/
public $user_id;
/**
* Wether the user has been successfully verified.
* Set to true (AND PROVIDE A UDT) to log a custom user in using another mechanism.
* @var boolean true if verified.
*/
public $verified = false;
/**
* Wether the user should be logged in for a very long time.
* @var boolean true if remember for long time.
*/
public $remember_me = false;
/**
* User Data Table for when the user is verified by the sessions module.
* @var Array User Data Table
*/
public $udt;
/**
* Initializes the event.
* @param String $identifier Can be an email or username
* @param String $password Password of the user
* @param boolean $remember_me Wether the user should be logged in for a long time
* @param String $username Username of a user (optional)
* @param String $email Email of a user (optional)
* @param Array $udt User Data Table of a user (optional)
*/
public function init($identifier, $password, $remember_me, $user_id, $username = null, $email = null, $udt = null) {
$this->identifier = $identifier;
$this->password = $password;
$this->remember_me = $remember_me;
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
$this->udt = $udt;
}
}
/**
* Set the verification of this user
* @param boolean $verified True if verified.
*/
public function setVerified($verified = false) {
$this->verified = $verified;
}
/**
* Sets the UserId of a user
* @param Int $user_id Id of the user
*/
public function setUserId($user_id) {
$this->user_id = $user_id;
}
/**
* Sets the username when a user is successfully verified
* @param String $username Username of the user
*/
public function setUsername($username) {
$this->username = $username;
}
/**
* Sets the email when a user is successfully verified
* @param String $email Email of the user
*/
public function setEmail($email) {
$this->email = $email;
}
/**
* Sets the User Data Table when a user is successfully verified
* @param Array $udt User Data Table
*/
public function setUdt($udt) {
$this->udt = $udt;
}
}
/**
* Event gets fired when a user tries to log out
* Cancel the event to deny a logout.
* The Event only provides information. Changing variables will not log someone else out.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionLogoutEvent extends Event {
/**
* User ID of a user
* @var Int User ID
*/
public $user_id;
/**
* Username of a user
* @var String username
*/
public $username;
/**
* Email of a user
* @var String Email
*/
public $email;
/**
* Initializes the event
* @param String $user_id User ID of a user
* @param String $username Username of a user
* @param String $email Email of a user
*/
public function init($user_id, $username, $email) {
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
}
}
/**
* Event that gets fired when a new user get's created.
* Cancel the event to deny user creation.
* The Event only provides information. Changing variables will not register with new data.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionUserCreateEvent extends Event {
/**
* Username of a user
* @var String Username
*/
public $username;
/**
* Email of a user
* @var String Email
*/
public $email;
/**
* User ID of a user
* @var Int UserId
*/
public $user_id;
/**
* Initializes the event
* @param Int $user_id User ID of a user
* @param String $username Username of a user
* @param String $email Email of a user
*/
public function init($user_id, $username, $email) {
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
}
}
/**
* Event that gets fired when a user is modified.
* Cancel the event to deny the change.
* Change variables to change what gets changed.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionUserModifyEvent extends Event {
/**
* User ID of a user
* @var Int User ID
*/
public $user_id;
/**
* The key that get's changed
* @var String name of key
*/
public $key;
/**
* The original value that is getting changed.
* @var Mixed Value
*/
public $from;
/**
* The value it is getting changed into
* @var Mixed value
*/
public $value;
/**
* Initializes the Event
* @param Int $user_id User ID of a user
* @param String $key The key that get's changed
* @param Mixed $value The original value that is getting changed.
* @param Mixed $from The value it is getting changed into
*/
public function init($user_id, $key, $value, $from) {
$this->user_id = $user_id;
$this->key = $key;
$this->value = $value;
$this->from = $from;
}
}
/**
* Event that gets fired when a user is getting removed.
* Cancel the event to deny the user removal.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionUserRemoveEvent extends Event {
/**
* User ID of the user
* @var Int User ID
*/
public $user_id;
/**
* Username of the user
* @var String username
*/
public $username;
/**
* Email of the user
* @var String email
*/
public $email;
/**
* Initializes the event
* @param Int $user_id User ID of the user
* @param String $username Username of the user
* @param String $email Email of the user
*/
public function init($user_id, $username, $email) {
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
}
}
/**
* Event that gets fired when a password is changed.
* Cancel the event to deny password change
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionChangePasswordEvent extends Event {
/**
* User ID of the user
* @var Int UserId
*/
public $user_id;
/**
* Username of the user
* @var String Username
*/
public $username;
/**
* Old Password of the user. (the one that it is being changed from).
* It will be null when the oldPassword is not required
* @var String|null Password
*/
public $oldPassword;
/**
* New Password of the user. (the one that it is being changed to)
* @var String password
*/
public $newPassword;
/**
* Initializes the Event
* @param Int $user_id User ID of the user
* @param String $username Username of the user
* @param String|null $oldPassword Old Password of the user. (the one that it is being changed from)
* @param String $newPassword New Password of the user. (the one that it is being changed to)
*/
public function init($user_id, $username, $oldPassword = null, $newPassword) {
$this->user_id = $user_id;
$this->username = $username;
$this->oldPassword = $oldPassword;
$this->newPassword = $newPassword;
}
}
/**
* Event that gets fired when a user is suspended
* Cancel event to deny user suspension
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionUserSuspendEvent extends Event {
/**
* User ID of the user
* @var Int User ID
*/
public $user_id;
/**
* Username of the user
* @var String username
*/
public $username;
/**
* Email of the user
* @var String email
*/
public $email;
/**
* Initializes the event
* @param Int $user_id User ID of the user
* @param String $username Username of the user
* @param String $email Email of the user
*/
public function init($user_id, $username, $email) {
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
}
}
/**
* Event that gets fired when a user is unsuspended
* Cancel event to deny user unsuspension
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionUserUnsuspendEvent extends Event {
/**
* User ID of the user
* @var Int User ID
*/
public $user_id;
/**
* Username of the user
* @var String username
*/
public $username;
/**
* Email of the user
* @var String email
*/
public $email;
/**
* Initializes the event
* @param Int $user_id User ID of the user
* @param String $username Username of the user
* @param String $email Email of the user
*/
public function init($user_id, $username, $email) {
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
}
}
/**
* Event that gets fired when a user is registering.
* Gets called before the SessionUserCreateEvent, so the userdata can still be changed.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionRegisterEvent extends Event {
/**
* Username of the user
* @var String username
*/
public $username;
/**
* Email of the user
* @var String email
*/
public $email;
/**
* The password of the user
* @var String password
*/
public $password;
/**
* Initializes the Event
* @param String $username Username of the user
* @param String $email Email of the user
* @param String $password The password of the user
*/
public function init($username, $email, $password) {
$this->username = $username;
$this->email = $email;
$this->password = $password;
}
}
/**
* Event that gets fired when a session gets started.
* Cancel the event so that the user gets a guest session
* Change the UDT to change the session information
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionStartEvent extends Event {
/**
* User ID of the user
* @var Int User ID
*/
public $user_id;
/**
* Username of the user
* @var String username
*/
public $username;
/**
* Email of the user
* @var String email
*/
public $email;
/**
* User Data Table of the user
* @var Array UDT
*/
public $udt;
/**
* Wether the session is from a guest.
* @var boolean true if a guest session
*/
public $guest_session = true;
/**
* Initializes the event
* @param Int $user_id User ID of the user
* @param String $username Username of the user
* @param String $email Email of the user
* @param Array $udt User Data Table of the user
* @param boolean $guest_session Wether the session is from a guest.
*/
public function init($user_id, $username, $email, $udt = null, $guest_session = true) {
$this->user_id = $user_id;
$this->username = $username;
$this->email = $email;
$this->udt = $udt;
$this->guest_session = $guest_session;
}
/**
* Set wether the session is a guest session
* @param boolean $bool Wether the session is from a guest
*/
public function setGuestSession($bool) {
$this->guest_session = $bool;
}
/**
* Set a new User Data Table.
* @param Array $udt UDT
*/
public function setUdt($udt) {
$this->udt = $udt;
}
}

View File

@ -1,14 +1,45 @@
<?php
/**
* FuzeWorks
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
* @version Version 0.0.1
*/
namespace Module\Sessions;
use \FuzeWorks\Module;
use \FuzeWorks\EventPriority;
/**
* Sessions and User Management.
* Manages users and login requests from FuzeWorks.
* Main class of the Sessions and User Management module.
* Manages users and login requests from FuzeWorks.
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class Main extends Module {
class Session extends Module {
/**
* UDT of the current session, send to the user
@ -24,6 +55,10 @@ class Main extends Module {
*/
private $db;
/**
* Gets called upon module initialization
* @access public
*/
public function onLoad() {
require_once($this->getmodulePath() . "/class.events.php");
$this->setModuleConfig($this->config->loadConfigFile('sessions', $this->getModulePath()));
@ -42,17 +77,40 @@ class Main extends Module {
$sessionKey = (isset($_COOKIE[$this->cfg->cookie_name]) ? $_COOKIE[$this->cfg->cookie_name] : (isset($_REQUEST['sessionKey']) ? $_REQUEST['sessionKey'] : $sessionKey ));
// If a sessionKey is given, check it
if (!is_null($sessionKey)) {
if (is_null($sessionKey)) {
$data = false;
} else {
$data = $this->sessionIsValid($sessionKey, true);
if ($data !== false) {
$udt = $this->convertUserData($data);
if (!$this->sessionBlocked($udt)) {
return $this->sendUserSession($udt);
}
}
}
return $this->sendGuestSession();
$udt = null;
// Prepare for the event
if ($data !== false) {
$udt = $this->convertUserData($data);
$user_id = $udt['user_id'];
$username = $udt['user_username'];
$email = $udt['user_email'];
$guest_session = false;
} else {
$udt = $this->getGuestUdt();
$user_id = 0;
$username = 'Guest';
$email = 'Guest@'.$this->config->main->SITE_DOMAIN;
$guest_session = true;
}
// Fire the event
$event = $this->events->fireEvent(new SessionStartEvent(), $user_id, $username, $email, $udt, $guest_session);
if ($event->isCancelled() || $event->guest_session) {
return $this->sendUserSession($udt);
}
if ($this->sessionBlocked($event->udt)) {
return $this->sendUserSession($udt);
}
return $this->sendUserSession($event->udt);
}
/**
@ -64,7 +122,19 @@ class Main extends Module {
if (isset($_COOKIE[$this->cfg->cookie_name])) {
setcookie($this->cfg->cookie_name, '', time()-3600, '/', $this->config->main->SITE_DOMAIN);
}
$udt = array(
$udt = $this->getGuestUdt();
$this->udt = $udt;
$this->logSessionData();
return $udt;
}
/**
* Returns the standard User Data Table of a guest account
* @access private
* @return Array UDT
*/
private function getGuestUdt() {
return array(
'user_id' => 0,
'user_username' => 'Guest',
'username' => 'Guest',
@ -73,9 +143,6 @@ class Main extends Module {
'permissions' => array('GUEST' => 'GUEST', 'LOGIN' => 'LOGIN'),
'session_hash' => '0'
);
$this->udt = $udt;
$this->logSessionData();
return $udt;
}
/**
@ -100,7 +167,7 @@ class Main extends Module {
private function logSessionData() {
$this->logger->newLevel("Activating Session");
$this->logger->logInfo("<br />SessionKey: " . $this->session_hash . "<br />Username: " . $this->user_username . "<br/>Email: " . $this->user_email . "<br/>Permissions: " . implode('-', $this->permissions));
$this->logger->stopLevel();
$this->logger->stopLevel();
}
/**
@ -108,11 +175,11 @@ class Main extends Module {
* @access private
* @param Array SessionData
* @return Array Userdata
* @todo change this
* @todo change this into a version that uses an external table for more user data
*/
private function convertUserData($userData) {
$udt = array();
for ($i=0; $i < count($userData); $i++) {
for ($i=0; $i < count($userData); $i++) {
foreach ($userData[$i] as $key => $value) {
if (strpos($key, 'user_') === 0 || strpos($key, 'session_') === 0) {
$udt[$key] = $value;
@ -147,15 +214,15 @@ class Main extends Module {
$prefix = $this->db->getPrefix();
$query = "
SELECT *
FROM ".$prefix."session_permissions AS permissions
FROM ".$prefix."session_permissions AS permissions
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_tags AS tags
ON permissions.permission_tag_id=tags.tag_id
ON permissions.permission_tag_id=tags.tag_id
LEFT JOIN ".$prefix."session_sessions AS sessions
LEFT JOIN ".$prefix."session_sessions AS sessions
ON permissions.permission_user_id=sessions.session_user_id
WHERE sessions.session_hash = ?
@ -185,7 +252,6 @@ class Main extends Module {
* @param String password
* @param Boolean Wether to remember the session (true for 100 years, false for incremental)
* @param Boolean propagate, wether the login should be propagated to the database (default true)
* @todo Add ADMITTED Tag to check wether a user is allowed to log in
* @return Array SessionData
*/
public function login($identifier, $password, $remember_me = false, $propagate = true) {
@ -193,7 +259,7 @@ class Main extends Module {
$prefix = $this->db->getPrefix();
$query = "
SELECT *
FROM ".$prefix."session_users AS users
FROM ".$prefix."session_users AS users
WHERE users.user_email = :identifier OR users.user_username = :identifier";
$stmnt = $this->db->prepare($query);
$stmnt->execute(array('identifier' => $identifier));
@ -208,7 +274,7 @@ class Main extends Module {
// If correct, prepare sessionData
// Create Session
$one = uniqid();
$two = sha1(uniqid() . $identifier);
$two = sha1(uniqid() . $identifier);
$three = uniqid();
$hash = sha1($one . $two . $three);
@ -225,21 +291,65 @@ class Main extends Module {
// Add the success value
$sessionData['valid'] = true;
if ($propagate) {
$this->propagate($sessionData);
}
$valid = true;
} else {
// Password incorrect
$sessionData['valid'] = false;
$sessionData['reason'] = "PASSWORD_INCORRECT";
$sessionData['reason_explained'] = "Username and/or password is incorrect";
$valid = false;
}
} else {
// User not found
$sessionData['valid'] = false;
$sessionData['reason'] = "USER_NOT_FOUND";
$sessionData['reason_explained'] = "Username and/or password is incorrect";
$valid = false;
}
// Broadcast data with an event
if ($valid) {
// If valid, provide all required data
$event = $this->events->fireEvent(new SessionLoginEvent(),
$identifier,
$password,
$remember_me,
$sessionData['user_id'],
$sessionData['user_username'],
$sessionData['user_email']
);
} else {
// If not, provide only the identifiers
$event = $this->events->fireEvent(new SessionLoginEvent(), $identifier, $password, $remember_me);
}
// Firest check for full blown deny
if ($event->isCancelled()) {
$sessionData['valid'] = false;
$sessionData['reason'] = "USER_DENIED";
$sessionData['reason_explained'] = "The User has been denied by an internal proces";
}
// Then check for verification
if ($event->verified) {
$sessionData['user_id'] = $event->user_id;
$sessionData['user_username'] = $event->username;
$sessionData['username'] = $event->username;
$sessionData['user_email'] = $event->email;
$sessionData['email'] = $event->email;
} else {
// If not verified, deny access
$sessionData['valid'] = false;
if ($valid) {
// If denied by event, export reason
$sessionData['reason'] = "USER_DENIED";
$sessionData['reason_explained'] = "The User has been denied by an internal proces";
}
}
// Propagate if valid
if ($propagate) {
$this->propagate($sessionData);
}
return $sessionData;
@ -255,14 +365,14 @@ class Main extends Module {
$prefix = $this->db->getPrefix();
// The variables to insert
$insert_array = array(
'hash' => $sessionData['hash'],
'user_id' => $sessionData['user_id'],
'info' => $sessionData['info'],
'ip' => $sessionData['ip'],
'hash' => $sessionData['hash'],
'user_id' => $sessionData['user_id'],
'info' => $sessionData['info'],
'ip' => $sessionData['ip'],
'session_start' => $sessionData['session_start']);
$query = "
INSERT INTO ".$prefix."session_sessions
INSERT INTO ".$prefix."session_sessions
(session_hash,session_user_id,session_info,session_ip,session_start)
VALUES (:hash, :user_id, :info, :ip, :session_start)
";
@ -280,11 +390,11 @@ class Main extends Module {
/**
* Sign a user out of the system
*
*
* @access public
* @param String SessionKey (optional)
* @param Boolean Propagate the logout to the database (default true)
* @return Boolean true on success
* @return Boolean true on success, false on deny
* @throws SessionException on fatal error
*/
public function logout($sessionKey = null, $propagate = true) {
@ -296,6 +406,16 @@ class Main extends Module {
// Fetch the session data
$data = $this->sessionIsValid($sessionKey, true);
if ($data !== false) {
$username = $data[0]['user_username'];
$email = $data[0]['user_email'];
$user_id = $data[0]['user_id'];
// Then fire the event
$event = $this->events->fireEvent(new SessionLogoutEvent(), $user_id, $username, $email);
if ($event->isCancelled()) {
return false;
}
// If valid, remove the current session
$this->udt = null;
if ($propagate) {
@ -311,18 +431,18 @@ class Main extends Module {
setcookie($this->cfg->cookie_name, $sessionKey, date('U') - 3600, '/', $this->config->main->SITE_DOMAIN);
return true;
}
throw new SessionException("Could not log user out. Database error", 1);
}
}
}
throw new SessionException("Could not log user out. SessionKey not found", 1);
}
/**
* Register a new User. Features input handling
* @access public
* @access public
* @param String Username. Username of the new user
* @param String email. Email of the new user
* @param String password. Password of the new user
@ -334,7 +454,7 @@ class Main extends Module {
$errors = [];
// Email
if (!preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/',$email)) {
if (!preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/',$email)) {
// Invalid
$errors[] = 'Invalid Email';
}
@ -350,9 +470,15 @@ class Main extends Module {
throw new SessionException("Could not register user. " . implode(' .', $errors), 1);
}
// Fire the event
$event = $this->events->fireEvent(new SessionRegisterEvent(), $username, $email, $password);
if ($event->isCancelled()) {
return false;
}
// And perform the handling
try {
return $this->createUser($username, $email, $password, true);
return $this->createUser($event->username, $event->email, $event->password, true);
} catch (SessionException $e) {
throw new SessionException("Could not register user. '" . $e->getMessage() . "'", 1, $e);
}
@ -391,6 +517,13 @@ class Main extends Module {
$id = $this->mods->database->lastInsertId();
$stmnt2->execute(['tag_id' => 1, 'user_id' => $id]);
// And then fire the event
$event = $this->events->fireEvent(new SessionUserCreateEvent(), $user_id, $username, $password);
if ($event->isCancelled()) {
$this->mods->database->rollBack();
return false;
}
$this->mods->database->commit();
// After that send a registration mail
@ -411,7 +544,6 @@ class Main extends Module {
* @param Int UserID
* @param Boolean Verify. Wether the user needs to verify using the email (default false)
* @throws SessionException on fatal error
* @todo Apply new Template Engine
*/
public function registerMail($userId, $verify = false) {
$udt = $this->getUsersByIds(intval($userId));
@ -425,13 +557,16 @@ class Main extends Module {
$mailer->setFrom('no-reply@'.$this->config->main->SITE_DOMAIN, 'Auth Service');
// First prepare the layout manager
// $this->layout->setEngine('PHP');
$this->layout->setEngine('PHP');
// Assign all variables
$verifyCode = $udt['user_verify_code'];
$verifyURL = '';
if (empty($this->cfg->verify_controller) && $verify) {
throw new SessionException("Could not send mail. No verification controller set. Please set one in the sessions config.", 1);
}
$verifyURL = $this->config->main->SITE_URL . "/" . $this->cfg->verify_controller . "?verify&code=".$verifyCode;
$event = $this->events->fireEvent(new RegisterMailEvent(), $udt, $verifyCode, $verifyURL);
$event = $this->events->fireEvent(new SessionRegisterMailEvent(), $udt, $verifyCode, $verifyURL);
if ($event->isCancelled()) {
$this->logger->log("Sending of Registration Mail has been cancelled");
return false;
@ -441,13 +576,12 @@ class Main extends Module {
$udt = $event->udt;
// Assign new variables
$this->layout->assign('serverName', $this->config->main->SERVER_NAME);
$this->layout->assign('logo', $this->config->main->SITE_LOGO_URL);
$this->layout->assign('username', $udt['user_username']);
$this->layout->assign('email', $udt['user_email'] );
// More if there is a need to verify
if ($verify) {
$this->layout->assign('verifyURL', $event->verifyURL);
$this->layout->assign('verifyCode', $event->verifyCode);
}
// Check if a custom HTML should be used
@ -466,7 +600,7 @@ class Main extends Module {
$mailer->send();
if (!empty($mailer->ErrorInfo)) {
// Throw Exception if something goes wrong
throw new SessionException("Could not send mailer. PHPMailer Error", 1);
throw new SessionException("Could not send mail. PHPMailer Error", 1);
}
}
@ -476,27 +610,42 @@ class Main extends Module {
* @param Int UserID to edit
* @param String column to edit
* @param Mixed value to apply
* @return true on success
* @return true on success or false on deny
* @throws \Exception|SessionException on fatal error
*/
public function modifyUser($userId, $key, $value) {
// Fetch user data
$udt = $this->getUsersByIds($userId)[0];
// And fetch tag information
$prefix = $this->db->getPrefix();
$stmnt = $this->mods->database->prepare("UPDATE ".$prefix."session_users SET $key = ?");
$stmnt->execute([$value]);
if ($stmnt->rowCount() == 1) {
return true;
// Check if key exists
if (isset($udt[$key])) {
$from = $udt[$key];
// Then fire the event
$event = $this->events->fireEvent(new SessionUserModifyEvent(), $userId, $key, $value, $from);
if ($event->isCancelled()) {
return false;
}
// And fetch tag information
$prefix = $this->db->getPrefix();
$stmnt = $this->mods->database->prepare("UPDATE ".$prefix."session_users SET $key = ?");
$stmnt->execute([$value]);
if ($stmnt->rowCount() == 1) {
return true;
}
throw new SessionException("Could not modify user. Database error", 1);
}
throw new SessionException("Could not modify user. Database error", 1);
throw new SessionException("Could not modify user. Key does not exist", 1);
}
/**
* Changes the password of a user
* @access public
* @param Int UserID to edit
* @param String|null Old password of the user or nothing if trying to change as admin
* @param String|null Old password of the user or nothing if trying to change as admin
* @param String New password of the user
* @return true on success
* @throws \Exception|SessionException on fatal error
@ -505,11 +654,24 @@ class Main extends Module {
$udt = $this->getUsersByIds($userId)[0];
// First check if the oldPassword is correct
if (is_null($oldPassword) || password_verify($oldPassword, $udt['user_password'])) {
// Send out the event
$event = $this->events->fireEvent(new SessionChangePasswordEvent(),
$userId,
$udt['user_username'],
$oldPassword,
$newPassword
);
// Stop if cancelled
if ($event->isCancelled()) {
return false;
}
// Then apply the new password
$hash = password_hash($newPassword, PASSWORD_DEFAULT);
$hash = password_hash($event->newPassword, PASSWORD_DEFAULT);
$this->modifyUser($userId, 'user_password', $hash);
return true;
}
}
throw new SessionException("Could not change password. Old password did not match", 1);
}
@ -522,7 +684,21 @@ class Main extends Module {
* @throws SessionException on fatal error
*/
public function suspendUser($userId) {
return $this->removePermission('ADMITTED', $userId, false);
// First get all the relevant data
$udt = $this->getUsersByIds($userId)[0];
$user_id = $udt['user_id'];
$username = $udt['user_username'];
$email = $udt['user_email'];
// Then fire the event
$event = $this->events->fireEvent(new SessionUserSuspendEvent(), $user_id, $username, $email);
// Cancel if denied by module
if ($event->isCancelled()) {
return false;
}
return $this->addPermission('BLOCKED', $userId, false);
}
/**
@ -533,7 +709,21 @@ class Main extends Module {
* @throws SessionException on fatal error
*/
public function unsuspendUser($userId) {
return $this->addPermission('ADMITTED', $userId, false);
// First get all the relevant data
$udt = $this->getUsersByIds($userId)[0];
$user_id = $udt['user_id'];
$username = $udt['user_username'];
$email = $udt['user_email'];
// Then fire the event
$event = $this->events->fireEvent(new SessionUserUnsuspendEvent(), $user_id, $username, $email);
// Cancel if denied by module
if ($event->isCancelled()) {
return false;
}
return $this->removePermission('BLOCKED', $userId, false);
}
/**
@ -547,6 +737,14 @@ class Main extends Module {
// First get all relevant data
$udt = $this->getUsersByIds($userId)[0];
$userId = $udt['user_id'];
$username = $udt['user_username'];
$email = $udt['user_email'];
// Then fire an event
$event = $this->events->fireEvent(new SessionUserRemoveEvent(), $userId, $username, $email);
if ($event->isCancelled()) {
return false;
}
// Remove the active permission, effectively removing the user
return $this->removePermission('ACTIVE', $userId, false, true);
@ -611,7 +809,7 @@ class Main extends Module {
} else {
if (isset($udt['permissions'][$tag]) || isset($udt['permissions']['ADMIN'])) {
return true;
}
}
}
return false;
@ -680,7 +878,7 @@ class Main extends Module {
return true;
}
throw new SessionException("Could not remove permission. Database error", 1);
}
@ -733,7 +931,7 @@ class Main extends Module {
if ($stmnt->rowCount() == 1) {
return true;
}
}
throw new SessionException("Could not add permission. Database Error", 1);
}
@ -743,25 +941,27 @@ class Main extends Module {
* @access public
* @param Array of usernames
* @return Array of UDT's
* @todo Support for 1 parameter (STRING)
*/
public function getUsersByName($usernames = array()) {
if (is_string($usernames)) {
$usernames = array($usernames);
}
$prefix = $this->db->getPrefix();
$query = "
SELECT *
FROM ".$prefix."session_permissions AS permissions
FROM ".$prefix."session_permissions AS permissions
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_tags AS tags
ON permissions.permission_tag_id=tags.tag_id
ON permissions.permission_tag_id=tags.tag_id
WHERE users.user_username = ?
";
$stmnt = $this->mods->database->prepare($query);
$users = array();
for ($i=0; $i < count($usernames); $i++) {
for ($i=0; $i < count($usernames); $i++) {
$username = $usernames[$i];
$stmnt->execute(array($username));
$user_data = $stmnt->fetchAll(\PDO::FETCH_ASSOC);
@ -786,26 +986,26 @@ class Main extends Module {
$prefix = $this->db->getPrefix();
$query = "
SELECT *
FROM ".$prefix."session_permissions AS permissions
FROM ".$prefix."session_permissions AS permissions
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_tags AS tags
ON permissions.permission_tag_id=tags.tag_id
ON permissions.permission_tag_id=tags.tag_id
WHERE users.user_id = ?
";
$stmnt = $this->mods->database->prepare($query);
$users = array();
for ($i=0; $i < count($ids); $i++) {
for ($i=0; $i < count($ids); $i++) {
$id = $ids[$i];
$stmnt->execute(array($id));
$user_data = $stmnt->fetchAll(\PDO::FETCH_ASSOC);
if (!empty($user_data)) {
$users[] = $this->handleUserSelectData($user_data);
}
}
}
return $users;
}
@ -815,25 +1015,27 @@ class Main extends Module {
* @access public
* @param Array of emails
* @return Array of UDT's
* @todo Support for 1 parameter (STRING)
*/
public function getUsersByEmails($emails = array()) {
if (is_string($emails)) {
$emails = array($emails);
}
$prefix = $this->db->getPrefix();
$query = "
SELECT *
FROM ".$prefix."session_permissions AS permissions
FROM ".$prefix."session_permissions AS permissions
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_tags AS tags
ON permissions.permission_tag_id=tags.tag_id
ON permissions.permission_tag_id=tags.tag_id
WHERE users.user_email = ?
";
$stmnt = $this->mods->database->prepare($query);
$users = array();
for ($i=0; $i < count($emails); $i++) {
for ($i=0; $i < count($emails); $i++) {
$email = $emails[$i];
$stmnt->execute(array($email));
$user_data = $stmnt->fetchAll(\PDO::FETCH_ASSOC);
@ -849,25 +1051,27 @@ class Main extends Module {
* @access public
* @param String Permission Tag
* @return Array of UDT's
* @todo Support for 1 parameter (STRING)
*/
public function getUsersByPermissions($permissionTags = array()) {
if (is_string($permissionTags)) {
$permissionTags = array($permissionTags);
}
$prefix = $this->db->getPrefix();
$query = "
SELECT *
FROM ".$prefix."session_permissions AS permissions
FROM ".$prefix."session_permissions AS permissions
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_users AS users
ON permissions.permission_user_id=users.user_id
LEFT JOIN ".$prefix."session_tags AS tags
ON permissions.permission_tag_id=tags.tag_id
ON permissions.permission_tag_id=tags.tag_id
WHERE tags.tag_name = ?
";
$stmnt = $this->mods->database->prepare($query);
$users = array();
for ($i=0; $i < count($permissionTags); $i++) {
for ($i=0; $i < count($permissionTags); $i++) {
$tag = $permissionTags[$i];
$stmnt->execute(array($tag));
@ -895,7 +1099,7 @@ class Main extends Module {
}
$user['permissions'] = array();
for ($j=0; $j < count($user_data); $j++) {
for ($j=0; $j < count($user_data); $j++) {
$user['permissions'][ $user_data[$j]['tag_name'] ] = $user_data[$j]['tag_name'];
}
$user['username'] = $user['user_username'];
@ -912,13 +1116,13 @@ class Main extends Module {
public function __get($key) {
return $this->udt[$key];
}
}
/**
* Exception class for the Sessions Module
* @package net.techfuze.fuzeworks.sessions
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
*/
class SessionException extends \Exception {}

View File

@ -1,6 +1,38 @@
<?php
/**
* FuzeWorks
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
* @version Version 0.0.1
*/
return array(
'cookie_name' => 'FuzeCookie',
// Should be filled in if you want email verification to work
'verify_controller' => '',
);

View File

@ -1,7 +1,36 @@
<?php
/**
* FuzeWorks
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
* @version Version 0.0.1
*/
return array(
'module_class' => '\Module\Sessions\Main',
'module_class' => '\Module\Sessions\Session',
'module_file' => 'class.sessions.php',
'module_name' => 'sessions',
@ -14,5 +43,5 @@ return array(
'website' => 'http://fuzeworks.techfuze.net/',
'date_created' => '23-02-2015',
'date_updated' => '19-08-2015',
'date_updated' => '29-08-2015',
);