-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin functionality added to the project
- Loading branch information
1 parent
cd822e1
commit 2a69096
Showing
60 changed files
with
2,779 additions
and
46 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,57 @@ | ||
<?php | ||
class AddHouseController{ | ||
protected $model; | ||
|
||
private function addHouse($newFormData){ | ||
$login=adminCHeck(); //check if the admin is logged in; | ||
//[DataType,required=1 | optional=0] | ||
//key of validate is the same as the name of form field | ||
$validate=["size_measurement"=>"Number,1","size_measure_unit"=>"MeasuringUnit,1","category"=>"String,1","houseCategory"=>"String,1","propType"=>"String,1","Country"=>"Country,1","State"=>"State,1","area_located"=>"String,1","address"=>"String,1","fixed_price"=>"Number,1","fixed_price_currency"=>"Currency,1","room"=>"Number,1","bath"=>"Number,1","description"=>"String,1","features"=>"String,0","amenities"=>"String,0"]; | ||
|
||
|
||
//validate the data | ||
$error = $this->model->validate($newFormData,$validate); | ||
//pass the data on th model for insert | ||
if(empty($error)){ | ||
$cleanData = $this->model->removeEmptyfield($newFormData); | ||
$Alreadyexist = $this->model->houseExist($cleanData); | ||
|
||
if($Alreadyexist){ | ||
$houseId = $this->model->getLastHouseId($cleanData); | ||
$_SESSION['house-message'] = "Already Exist: The house is already in your collections,Check it out <a href='/admin/view-house/$houseId' class='btn btn-outline-warning'>here</a>"; | ||
header("Location: /admin/add-house"); | ||
exit(); | ||
} | ||
|
||
$house_id =$this->model->saveNewHouse($cleanData); | ||
if($house_id !==false){ | ||
//set session of message | ||
$_SESSION['house-message'] = "House added successfully"; | ||
//redirect to gallery step under add house | ||
$_SESSION['gallery-referer'] = "/admin/add-house/gallery/$house_id"; | ||
header("Location: /admin/add-house/gallery/$house_id"); | ||
exit(); | ||
} | ||
|
||
|
||
}else{ | ||
$_SESSION['add-house-error']=$error; | ||
header("Location: /admin/add-house"); | ||
exit(); | ||
} | ||
|
||
// $view = new addHouseView; | ||
// include_once $view->run(); | ||
} | ||
private function doNothing(){ | ||
header("Location: /admin"); | ||
exit(); | ||
} | ||
public function run($method,$param) | ||
{ | ||
$this->model = new housedataModel; | ||
$run = method_exists($this,$method)?$method:"doNothing"; | ||
|
||
$this->{$run}($param); | ||
} | ||
} |
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,56 @@ | ||
<?php | ||
|
||
class adminLoginController{ | ||
private $model; | ||
protected function loginCheck($token){ | ||
//check if token given is correct | ||
if(!$this->model->loginTokenCheck($token)){ | ||
header("Location: /home"); | ||
exit(); | ||
} | ||
} | ||
private function login($loginToken){ | ||
$this->loginCheck($loginToken);//login token check | ||
//show login page | ||
//view | ||
$error=isset($_SESSION['adminLoginError'])?$_SESSION['adminLoginError']:null; | ||
|
||
|
||
$login=new adminLoginView; | ||
|
||
include_once $login->run(); | ||
|
||
if(isset($_SESSION['adminLoginError'])){ | ||
unset($_SESSION['adminLoginError']); | ||
} | ||
} | ||
|
||
private function logAdminIn($credencials) | ||
{ | ||
//with token | ||
$loginToken = $credencials['loginToken']; | ||
$this->loginCheck($loginToken);//login token check | ||
|
||
$loginDetails = $credencials['loginDetails']; | ||
|
||
|
||
$login=$this->model->adminLogin($loginDetails['username'],$loginDetails['password'],$loginToken); | ||
if($login){ | ||
header("Location: /admin"); | ||
}else{ | ||
$_SESSION['adminLoginError'] = "Wrong Login Credentials: Try again"; | ||
header("Location: /admin/login/$loginToken"); | ||
} | ||
exit(); | ||
} | ||
|
||
public function run($method,$arg){ | ||
|
||
$this->model=new adminModel; | ||
|
||
//load needed models to render current view | ||
$run=method_exists($this,$method)?$method:'login'; | ||
$this->{$run}($arg); | ||
} | ||
|
||
} |
Oops, something went wrong.