public function index() { session_start(); $page = \Repository\Page::createInstance()->selectAllPages(); $this->view->page = $page; $this->view->part('header'); if (isset($_POST['login'])) { $username = $_POST['username']; $password = $_POST['password']; $user = \Repository\User::createInstance()->getOneByDetails($username, $password); $userName = $user->getUsername(); if (empty($userName) || $user->getAdmin() != 1) { $this->redirectControllers('home'); // echo 'Oops! It looks like your admin name and/or password are incorrect. ' // . 'Please try again.'; // die(); } //session_start(); $_SESSION['adminName'] = $userName; $pageTitle = \Repository\Page::createInstance()->selectAllPages(); $this->redirectAdminControllers('Main', 'log'); } $this->view->showView(); $this->view->part('footer'); }
public function getUserModel() { $this->getAllClasses(); $classes = get_declared_classes(); foreach ($classes as $class) { $reflection = new \ReflectionClass($class); foreach ($reflection as $classNamespace) { if (substr($classNamespace, 0, 11) == 'Models\\User') { $methods = $reflection->getMethods(); $properties = $reflection->getProperties(); $classProperties = []; foreach ($properties as $property) { $pole = $this->metadata(); foreach ($pole as $key => $value) { if ($key == $property->name) { $classProperties[] = [$property->name => $value]; } } } $className = str_replace('Models\\', '', $classNamespace); $className = str_replace('Model', '', $className); $model = User::createInstance()->getCheck(lcfirst($className)); if (empty($model)) { $createTable = User::createInstance()->createTable($className, $classProperties); } } } } }
public function createConference(CreateConference $conference) { $this->headerData(); $this->view->showView(); $venueName = $conference->getName(); $venueAddress = $conference->getAddress(); $confName = $conference->getConfName(); $startDate = $conference->getStartDate(); $endDate = $conference->getEndDate(); $userId = $_SESSION['id']; /** * this part added venue's data */ $venue = new VenueModel($venueName, $venueAddress); $venue->save(); $venueId = \Repository\Venue::createInstance()->selectId(); $conference = new ConferenceModel($confName, $startDate, $endDate, $venueId, $userId); $conference->save(); $conf = Conference::createInstance()->selectAllConferencesDetails(); $confId = array_pop($conf); $confId = $confId->getId(); // $confId = array_pop($conf['id']); if ($conference->getConfName() != null) { // var_dump($venueId); $_SESSION['venue_id'] = $venueId; $_SESSION['conferenceId'] = $confId; $user = \Repository\User::createInstance()->editUserId($userId); $this->redirectControllers('hall', 'createHall'); } $this->view->part('footer'); exit; }
public function index() { $this->headerData(); $this->view->showView(); session_start(); //$this->view->part('header'); if (isset($_POST['login'])) { $username = $_POST['username']; $password = $_POST['password']; $_SESSION['user'] = $username; $user = \Repository\User::createInstance()->getOneByDetails($username, $password); $this->load($user); } // if(isset($_SESSION['user'])) { // $username = $_SESSION['user']; // // $user = \Repository\User::createInstance() // ->getOneByName($username); // // $userId = $user->getId(); // // $this->load($user); // } $this->view->part('footer'); }
/** * @GET * @/slice/user/$id=\d * @AUTHORIZE * @param $id */ public function test($id) { $user = User::createInstance()->getOneById($id); $this->view->user = $user; $this->headerData(); $this->view->showCustomView('Neshto'); $this->view->part('footer'); }
/** * @param Index $user */ public function index(Index $user) { $this->headerIndex(); $this->view->showView(); $username = $user->getUsername(); $password = $user->getPassword(); if (!empty($username)) { $user = User::createInstance()->getOneByDetails($username, $password); $adminName = $user->getUsername(); $admin = $user->getAdmin(); if (!empty($adminName) && $admin == 1) { session_start(); $_SESSION['adminName'] = $username; $this->redirectAdminControllers('home', 'log'); } } $this->view->part('footer'); }
public function save() { return \Repository\User::createInstance()->save($this); }