/** * - Validate the user is allowed to be here. * - Redirect if no user id is set in the session. * - Set any messages that need to be displayed. * * @return void */ public function __construct() { if ($_SERVER['HTTP_HOST'] != 'local.restaurants.com') { $this->loadView('404'); } if (!isset($_SESSION['user']['id'])) { header('Location: /signin/'); exit; } $this->db = new Db(); $this->user_id = $_SESSION['user']['id']; $business = new Business($this->db); $this->business_id = $business->getIdFromUserId($this->user_id); }
/** * /admin/business/social_save/ [POST] */ public function social_save($parameters) { if ($parameters || !$_POST) { $this->loadView('404'); } $business = new BusinessModel($this->db, $this->business_id); $business->saveSocialLinks($_POST); $_SESSION['message'] = array('message' => 'Social links saved.', 'status' => 'success'); header('Location: /admin/business/social/'); exit; }