generated from github/welcome-to-github
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from lbr38/devel
3.6.1
- Loading branch information
Showing
45 changed files
with
942 additions
and
803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Controllers; | ||
|
||
use Exception; | ||
|
||
class History | ||
{ | ||
private $model; | ||
|
||
public function __construct() | ||
{ | ||
$this->model = new \Models\History(); | ||
} | ||
|
||
/** | ||
* Retrieve all history | ||
*/ | ||
public function getAll() | ||
{ | ||
return $this->model->getAll(); | ||
} | ||
|
||
/** | ||
* Retrieve all history from a user | ||
*/ | ||
public function getByUser(int $userId) | ||
{ | ||
$userId = \Controllers\Common::validateData($userId); | ||
|
||
if (!is_numeric($userId)) { | ||
printAlert('User Id is invalid', 'error'); | ||
return; | ||
} | ||
|
||
return $this->model->getByUser($userId); | ||
} | ||
|
||
/** | ||
* Add new history line in database | ||
*/ | ||
public function set(string $username, string $action, string $state) | ||
{ | ||
$mylogin = new \Controllers\Login(); | ||
|
||
$username = \Controllers\Common::validateData($username); | ||
$action = \Controllers\Common::validateData($action); | ||
$state = \Controllers\Common::validateData($state); | ||
|
||
/** | ||
* Check if user exists | ||
*/ | ||
if (!$mylogin->userExists($username)) { | ||
throw new Exception('User ' . $username . ' does not exist'); | ||
} | ||
|
||
/** | ||
* Retrieve user Id from username | ||
*/ | ||
$userId = $mylogin->getIdByUsername($username); | ||
|
||
$this->model->set($userId, $action, $state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.