Merge branch 'Misc' into 'master'
Many Misceleanous solvings Because I don't care to describe it all See merge request !38
This commit is contained in:
commit
187a33d3d7
|
@ -50,7 +50,7 @@
|
|||
<script>
|
||||
var currentPage = 0;
|
||||
var currentProgress = 0;
|
||||
|
||||
|
||||
start();
|
||||
function start() {
|
||||
$("#contentPanel").fadeIn(500);
|
|
@ -54,6 +54,23 @@ class LayoutException extends Exception{}
|
|||
*/
|
||||
class ConfigException extends Exception{}
|
||||
|
||||
/**
|
||||
* Class ModelException
|
||||
* @package net.techfuze.fuzeworks.core
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class ModelException extends Exception{}
|
||||
|
||||
/**
|
||||
* Class LoggerException
|
||||
* @package net.techfuze.fuzeworks.core
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class LoggerException extends Exception{}
|
||||
|
||||
/**
|
||||
* Class RouterException
|
||||
* @package net.techfuze.fuzeworks.core
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
|
|
|
@ -318,7 +318,8 @@ class Modules extends Bus{
|
|||
if (isset($cfg->aliases)) {
|
||||
foreach ($cfg->aliases as $alias) {
|
||||
$register[$alias] = (array) $cfg;
|
||||
$this->logger->log("[ON] '".$alias."' (alias of '".$name."')");
|
||||
unset($register[$alias]['events']);
|
||||
$this->logger->log(" '".$alias."' (alias of '".$name."')");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -334,7 +335,8 @@ class Modules extends Bus{
|
|||
if (isset($cfg->aliases)) {
|
||||
foreach ($cfg->aliases as $alias) {
|
||||
$register[$alias] = (array) $cfg2;
|
||||
$this->logger->log("[OFF] '".$alias."' (alias of '".$name."')");
|
||||
unset($register[$alias]['events']);
|
||||
$this->logger->log(" '".$alias."' (alias of '".$name."')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +349,8 @@ class Modules extends Bus{
|
|||
if (isset($cfg->aliases)) {
|
||||
foreach ($cfg->aliases as $alias) {
|
||||
$register[$alias] = (array) $cfg;
|
||||
$this->logger->log("[ON] '".$alias."' (alias of '".$name."')");
|
||||
unset($register[$alias]['events']);
|
||||
$this->logger->log(" '".$alias."' (alias of '".$name."')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,11 @@ return array(
|
|||
'dependencies' => array(),
|
||||
'events' => array(),
|
||||
'sections' => array(),
|
||||
'aliases' => array(),
|
||||
|
||||
'name' => 'FuzeWorks Api Module',
|
||||
'description' => 'A Controller server for multiple types of API\'s like REST and SOAP',
|
||||
'author' => 'TechFuze',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
|
|
|
@ -38,10 +38,11 @@ return array(
|
|||
'dependencies' => array(),
|
||||
'events' => array(),
|
||||
'sections' => array(),
|
||||
'aliases' => array('techfuze/database'),
|
||||
|
||||
'name' => 'FuzeWorks Database Module',
|
||||
'description' => 'PDO Wrapper class for FuzeWorks',
|
||||
'author' => 'TechFuze',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
|
|
|
@ -6,13 +6,14 @@ return array(
|
|||
'module_name' => 'DatabaseUtils',
|
||||
|
||||
'abstract' => false,
|
||||
'dependencies' => array('techfuze/database'),
|
||||
'dependencies' => array('core/database'),
|
||||
'events' => array(),
|
||||
'sections' => array(),
|
||||
'aliases' => array('techfuze/databaseutils'),
|
||||
|
||||
'name' => 'FuzeWorks Database Utilities',
|
||||
'description' => 'Automatically build SQL queries using methods in this class',
|
||||
'author' => 'TechFuze',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
namespace Module\Example;
|
||||
use \FuzeWorks\Module;
|
||||
use \FuzeWorks\Event;
|
||||
use \FuzeWorks\EventPriority;
|
||||
|
||||
/**
|
||||
* Example module.
|
||||
|
@ -43,10 +45,13 @@ class Main extends Module {
|
|||
|
||||
/**
|
||||
* Loads the module and registers the events
|
||||
*
|
||||
* Every main moduleclass needs an onLoad method. This method is called first before anything else and cam be used to do some global actions.
|
||||
* @access public
|
||||
*/
|
||||
public function onLoad() {
|
||||
// Do Something
|
||||
// Here we register an eventListener for the ExampleEvent. See ExampleListener for more info
|
||||
$this->events->addListener(array($this, 'exampleListener'), 'ExampleEvent', EventPriority::NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,6 +62,58 @@ class Main extends Module {
|
|||
return "It works!";
|
||||
}
|
||||
|
||||
/**
|
||||
* An example listener that introduces you to the basics of event handling
|
||||
* @param ExampleEvent $event The event to listen for
|
||||
* @return ExampleEvent The event after it has been handled
|
||||
*/
|
||||
public function exampleListener($event) {
|
||||
$this->logger->log("Called the eventListener. This listener can now handle the event and change some data");
|
||||
// For this listener, we only change one variable
|
||||
$event->setVariable("New Value");
|
||||
|
||||
// And then we return it
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* In this example we create a simple event. This event will be created, passed around and then received in the example listener.
|
||||
*/
|
||||
public function createEvent() {
|
||||
// First we log some data
|
||||
$this->logger->log("Now creating a test event.");
|
||||
|
||||
// First we create the event object and some variables to assign to it
|
||||
$eventObject = new ExampleEvent();
|
||||
$variable = "Test Variable";
|
||||
|
||||
// Then we fire the event by parsing the event object and the variables into the fireEvent function.
|
||||
$event = $this->events->fireEvent($eventObject, $variable);
|
||||
|
||||
// Here we can read some variables from the event
|
||||
$result = $event->getVariable();
|
||||
|
||||
// And now we can do things with the data. For now we just return it
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ExampleEvent extends Event {
|
||||
|
||||
private $var1;
|
||||
|
||||
public function init($variable) {
|
||||
$this->var1 = $variable;
|
||||
}
|
||||
|
||||
public function getVariable() {
|
||||
return $this->var1;
|
||||
}
|
||||
|
||||
public function setVariable($var) {
|
||||
$this->var1 = $var;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -30,24 +30,48 @@
|
|||
|
||||
return array(
|
||||
|
||||
// The class name of the module. This class will be loaded upon requesting the module
|
||||
'module_class' => 'Module\Example\Main',
|
||||
|
||||
// The file that will be loaded upon requesting the module
|
||||
'module_file' => 'class.main.php',
|
||||
|
||||
// The name of the module. When the module is loaded it can be called throughout the framework with $this->mods->example;
|
||||
'module_name' => 'Example',
|
||||
|
||||
// Wether this module is an abstract. Making this abstract will only load the file, but not the class.
|
||||
'abstract' => false,
|
||||
'aliases' => array('techfuze/example'),
|
||||
'dependencies' => array(),
|
||||
'events' => array(),
|
||||
'sections' => array(),
|
||||
|
||||
// Other names for this module. Setting an alias will allow you to load the module with a different name.
|
||||
'aliases' => array('techfuze/example'),
|
||||
|
||||
// Array of modules that should be loaded before this module
|
||||
'dependencies' => array(),
|
||||
|
||||
// Events that this module listens for. When the exampleEvent is fired, this module will be loaded so the module can handle the event
|
||||
'events' => array('exampleEvent'),
|
||||
|
||||
// The name of the module as it will be logged. This does not affect usage of the module in any way
|
||||
'name' => 'FuzeWorks Example Module',
|
||||
|
||||
// A description of the module.
|
||||
'description' => 'A descriptive module that functions as an example',
|
||||
|
||||
// The author of the module. The author is the first part of the module name used for requesting. eg mycorp/example
|
||||
'author' => 'MyCorp',
|
||||
|
||||
// The current version of the module. Will be used for looking for updates
|
||||
'version' => '1.0.0',
|
||||
|
||||
// The website to look at for the module update
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
// The initial creation of the module.
|
||||
'date_created' => '29-04-2015',
|
||||
|
||||
// The last update of this module
|
||||
'date_updated' => '29-04-2015',
|
||||
|
||||
// Wether the module is enabled or not. If it is disabled, it can not be loaded.
|
||||
'enabled' => true
|
||||
);
|
||||
|
|
|
@ -35,10 +35,11 @@ return array(
|
|||
'module_name' => 'Mailer',
|
||||
|
||||
'dependencies' => array(),
|
||||
'aliases' => array('techfuze/mailer'),
|
||||
|
||||
'name' => 'Mailer',
|
||||
'description' => 'PHPMailer wrapper for FuzeWorks',
|
||||
'author' => 'TechFuze',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Controller;
|
||||
use \FuzeWorks\Controller;
|
||||
|
||||
class Standard extends Controller {
|
||||
public function __construct(&$core) {
|
||||
parent::__construct($core);
|
||||
}
|
||||
|
||||
public function index($path = null) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -28,7 +28,7 @@
|
|||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Sessions;
|
||||
namespace Module\Users;
|
||||
use \FuzeWorks\Event;
|
||||
|
||||
/**
|
|
@ -28,7 +28,7 @@
|
|||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Sessions;
|
||||
namespace Module\Users;
|
||||
use \FuzeWorks\Module;
|
||||
use \FuzeWorks\EventPriority;
|
||||
|
||||
|
@ -39,7 +39,7 @@ use \FuzeWorks\EventPriority;
|
|||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2015, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class Session extends Module {
|
||||
class Users extends Module {
|
||||
|
||||
/**
|
||||
* UDT of the current session, send to the user
|
||||
|
@ -771,6 +771,24 @@ class Session extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if a password matches the user
|
||||
* @param Int $userId User ID of the user
|
||||
* @param String $password Password of the user
|
||||
* @return true on valid, false on invalid
|
||||
*/
|
||||
public function verifyPassword($userId, $password) {
|
||||
$prefix = $this->db->getPrefix();
|
||||
$stmnt = $this->mods->database->prepare("SELECT * FROM ".$prefix."session_users WHERE user_id = ?");
|
||||
$stmnt->execute([$userId]);
|
||||
$data = $stmnt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
if (!empty($data)) {
|
||||
return password_verify($password, $data[0]['user_password']);
|
||||
} else {
|
||||
throw new SessionException("Could not verify password. User not found", 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks wether a user has permission to a certain action
|
||||
* If a userID is provided, a specific user is checked. Otherwise the current session is used
|
|
@ -33,6 +33,6 @@ return array(
|
|||
'cookie_name' => 'FuzeCookie',
|
||||
|
||||
// Should be filled in if you want email verification to work
|
||||
'verify_controller' => '',
|
||||
'verify_controller' => 'login',
|
||||
|
||||
);
|
|
@ -30,15 +30,17 @@
|
|||
|
||||
return array(
|
||||
|
||||
'module_class' => '\Module\Sessions\Session',
|
||||
'module_file' => 'class.sessions.php',
|
||||
'module_name' => 'sessions',
|
||||
'module_class' => '\Module\Users\Users',
|
||||
'module_file' => 'class.users.php',
|
||||
'module_name' => 'users',
|
||||
|
||||
'dependencies' => array('techfuze/database'),
|
||||
'dependencies' => array('core/database'),
|
||||
'aliases' => array('techfuze/sessions'),
|
||||
'events' => array(),
|
||||
|
||||
'name' => 'Sessions',
|
||||
'name' => 'Users',
|
||||
'description' => 'Lightweight user and permissions system',
|
||||
'author' => 'TechFuze',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
Loading…
Reference in New Issue