示例#1
0
 /**
  * Method to create a session for a specific User Entity.
  * @param User $user The User Entity with the information for the session.
  * @return bool The state if the session was created successfully.
  * @since 0.0.1-dev
  */
 public function create(User $user)
 {
     //create the session.
     $session = new Session();
     $session->create(Database::getInstance()->getConnection());
     //set the information to the session.
     $_SESSION['user_username'] = $user->username;
     return true;
 }
示例#2
0
 /**
  * Factory to get a initialized object of the ClanUserTableMapper.
  * @return ClanUserTableMapper The ClanUserTableMapper to persist the association on database.
  * @since 1.0.0
  * @uses Database::getInstance()->getConnection() to get a object of PDO.
  */
 public static function build()
 {
     return new self(Database::getInstance()->getConnection());
 }
示例#3
0
<?php

use Clanify\Core\Template\MenuBuilder;
use Clanify\Core\Template\CDN;
use Clanify\Domain\Entity\Team;
use Clanify\Core\CitoEngine;
use Clanify\Core\Template\FormBuilder;
use Clanify\Core\Database;
//get the instance of the CitoEngine.
$cito = CitoEngine::getInstance();
$logo = URL . 'src/View/templates/public/img/clanify-logo.png';
$stylesheet = URL . 'src/View/templates/public/css/style.css';
$clanifyJS = URL . 'src/View/templates/public/js/clanify.js';
$favicon = URL . 'src/View/templates/public/img/favicon.ico';
$menuBuilder = new MenuBuilder(Database::getInstance()->getConnection());
//set the head information of the site.
$title = 'Clanify - Organize Clans, eSport-Teams and Gaming-Communities.';
$description = 'Clanify is a tool to organize Clans, eSport-Teams and Gaming-Communities.';
//set the header content.
$cito->setValue('head', '<meta charset="utf-8">');
$cito->setValue('head', '<meta http-equiv="X-UA-Compatible" content="IE=edge">');
$cito->setValue('head', '<meta name="viewport" content="width=device-width, initial-scale=1">');
$cito->setValue('head', '<title>' . $title . '</title>');
$cito->setValue('head', '<meta name="description" content="' . $description . '"/>');
$cito->setValue('head', '<meta name="keywords" content="clanify, gaming, clan, esport"/>');
$cito->setValue('head', '<link href="' . CDN::getNormalizeCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getBootstrapCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getAnimateCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getFontNunitoCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . $stylesheet . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getFontAwesomeCSS() . '" rel="stylesheet" type="text/css">');
示例#4
0
 /**
  * Method to save the Account.
  * @return boolean The state whether the Account could be saved.
  * @since 1.0.0
  */
 public function accountSave()
 {
     //this method need a Session.
     $this->needSession();
     //get the ID of the Account.
     $account_id = filter_input(INPUT_POST, 'account_id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
     //get the ID of the User.
     $user_id = filter_input(INPUT_POST, 'user_id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
     //check whether a Account should be updated.
     if ($account_id > 0) {
         //create the AccountRepository to load the Account from database.
         $accountRepository = AccountRepository::build();
         $accounts = $accountRepository->findByID($account_id);
         //check whether the Account could be loaded with the AccountRepository.
         if (count($accounts) !== 1) {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::ERROR;
             $jsonOutput['message'] = 'The Account could not be found.';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return false;
         }
         //create a new Account and load the Account from database.
         $account = new Account();
         $account->loadFromObject($accounts[0]);
         $account->loadFromPOST('account_');
         //create a AccountMapper to save the Account on database.
         $accountMapper = AccountMapper::build();
         //check whether the Account could be saved.
         if ($accountMapper->save($account)) {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::INFO;
             $jsonOutput['message'] = 'The Account was successfully saved.';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return true;
         } else {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::ERROR;
             $jsonOutput['message'] = 'The Account could not be saved.';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return false;
         }
     } else {
         //create the UserRepository to load the User from database.
         $userRepository = UserRepository::build();
         $users = $userRepository->findByID($user_id);
         //check whether the User could be loaded with the UserRepository.
         if (count($users) !== 1) {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::ERROR;
             $jsonOutput['message'] = 'The User of the Account could not be found.';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return false;
         }
         //create a new Account and load the Account.
         $account = new Account();
         $account->loadFromPOST('account_');
         //create a AccountDataMapper to save the Account on database.
         $accountMapper = AccountMapper::build();
         //check whether the new Account could be saved.
         if ($accountMapper->save($account) === false) {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::ERROR;
             $jsonOutput['message'] = 'The Account could not be saved!';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return false;
         }
         //get the ID of the new Account on database.
         $account->id = Database::getInstance()->getConnection()->lastInsertId();
         //create a new Account User TableMapper.
         $accountUserTableMapper = AccountUserTableMapper::build();
         //check whether the association between Account and User could be created.
         if ($accountUserTableMapper->create($account, $users[0])) {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::INFO;
             $jsonOutput['message'] = 'The Account was successfully created.';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return true;
         } else {
             $jsonOutput = [];
             $jsonOutput['state'] = LogLevel::ERROR;
             $jsonOutput['message'] = 'The Account could not be saved!';
             $jsonOutput['redirect'] = URL . 'user/edit/' . $user_id;
             $jsonOutput['tab_selected'] = 'tab-accounts';
             echo json_encode($jsonOutput);
             return false;
         }
     }
 }
示例#5
0
<?php

use Clanify\Core\Template\CDN;
use Clanify\Core\Template\MenuBuilder;
use Clanify\Core\CitoEngine;
use Clanify\Core\Template\FormBuilder;
use Clanify\Domain\Entity\User;
use Clanify\Domain\Entity\Clan;
//get the instance of the CitoEngine.
$cito = CitoEngine::getInstance();
$logo = URL . 'src/View/templates/public/img/clanify-logo.png';
$stylesheet = URL . 'src/View/templates/public/css/style.css';
$favicon = URL . 'src/View/templates/public/img/favicon.ico';
$clanifyJS = URL . 'src/View/templates/public/js/clanify.js';
$menuBuilder = new MenuBuilder(\Clanify\Core\Database::getInstance()->getConnection());
//set the head information of the site.
$title = 'Clanify - Organize Clans, eSport-Teams and Gaming-Communities.';
$description = 'Clanify is a tool to organize Clans, eSport-Teams and Gaming-Communities.';
//set the header content.
$cito->setValue('head', '<meta charset="utf-8">');
$cito->setValue('head', '<meta http-equiv="X-UA-Compatible" content="IE=edge">');
$cito->setValue('head', '<meta name="viewport" content="width=device-width, initial-scale=1">');
$cito->setValue('head', '<title>' . $title . '</title>');
$cito->setValue('head', '<meta name="description" content="' . $description . '"/>');
$cito->setValue('head', '<meta name="keywords" content="clanify, gaming, clan, esport"/>');
$cito->setValue('head', '<link href="' . CDN::getNormalizeCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getBootstrapCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getAnimateCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getFontNunitoCSS() . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . $stylesheet . '" rel="stylesheet" type="text/css">');
$cito->setValue('head', '<link href="' . CDN::getFontAwesomeCSS() . '" rel="stylesheet" type="text/css">');
示例#6
0
 /**
  * Method to get a select element for a table.
  * @param string $table The name of the table for the data.
  * @param string $name The name of the select element.
  * @param string $value The value which should be visible on the select.
  * @return string The HTML markup for output.
  * @since 1.0.0
  */
 public static function getSelectByTable($table, $name, $value = '')
 {
     $html = '<div class="form-group">';
     $html .= '<select name="' . $name . '" class="form-control">';
     $pdo = Database::getInstance()->getConnection();
     $rows = $pdo->query('SELECT * FROM ' . $table);
     //create the options from database.
     foreach ($rows as $row) {
         $html .= '<option value="' . $row['id'] . '" ' . ($value == $row['id'] ? 'selected' : '') . '>';
         $html .= $row['name'] . '</option>';
     }
     //close the select element and container and return the output.
     return $html . '</select></div>';
 }