public function doControl() { $loginOutput = null; $registerOutput = null; $recBoxOutput = null; $body = ''; // instances $dbConfig = new \permag\database\DBConfig(); $db = new \permag\database\Database($dbConfig); // db connect $db->connect(); $loginHandler = new \permag\model\LoginHandler($db); $pageView = new \permag\common\PageView(); $masterView = new \permag\view\MasterView(); $pageNavigationView = new \permag\view\PageNavigationView(); $pageCompositionView = new \permag\view\PageCompositionView(); $recListNavView = new \permag\view\RecordingListNavigationView($pageNavigationView); // show logo $pageCompositionView->addToLeftSection($masterView->doLogo()); // login doControl $loginController = new \permag\controller\LoginController(); $loginOutput = $loginController->doControl($loginHandler, $pageNavigationView); // page navigation switch ($pageNavigationView->getController()) { default: case \permag\view\PageNavigationView::HOME: if ($loginHandler->isLoggedIn()) { // recorder doControl $recController = new \permag\controller\RecordController($loginHandler, $db); $recordingController = new \permag\controller\RecordingController($loginHandler, $db, $recListNavView); // page comp $pageCompositionView->addToLeftSection($masterView->doNavigationMenu($recListNavView)); $pageCompositionView->addToLeftSection($loginOutput); $pageCompositionView->addToRightSection($recController->doControlBox()); $pageCompositionView->addToMainSection($recordingController->doControlRecordingsList()); } else { $pageNavigationView->redirectTo($pageNavigationView->getLoginLink()); } break; case \permag\view\PageNavigationView::LOGIN: // page comp $pageCompositionView->addToRightSection($masterView->doDescription()); $pageCompositionView->addToMainSection($loginOutput); break; case \permag\view\PageNavigationView::REGISTER: // register doControl $regController = new \permag\controller\RegisterController(); $registerOutput = $regController->doControl($loginHandler, $db, $pageNavigationView); // page comp $pageCompositionView->addToRightSection($masterView->doDescription()); $pageCompositionView->addToMainSection($registerOutput); break; } // kill db conn $db = null; // composition $body = $pageCompositionView->mergeSectionsToPage(); // page view return $pageView->getHTMLPage(self::TITLE, $body); }
public function __construct() { // DB $dbConfig = new \permag\database\DBConfig(); $db = new \permag\database\Database($dbConfig); $db->connect(); $this->m_db = $db; }
/** * Get username * @return array for json output */ public function getUsername() { $dbConfig = new \permag\database\DBConfig(); $db = new \permag\database\Database($dbConfig); $db->connect(); $memberModel = new \permag\model\Membermodel($db); $getUsernameAutocompleteView = new GetUsernameAutocompleteView(); // array for result in JSON. $usernames = array(); // get search term from ajax autocomplete $searchTerm = $getUsernameAutocompleteView->getSearchTerm(); // get username suggestions $usernames = $memberModel->getUsernameFromAjaxAutocomplete($searchTerm); // kill DB conn $db = null; // return array return $usernames; }
/** * Get memberId from username, store memberId in SESSION. * @return int memberId of member to receive recording */ public function init() { $shareToUsername = ShareGetMemberIdFromUsernameView::getUsername(); // get username from ajax parameter if (isset($shareToUsername)) { $dbConfig = new \permag\database\DBConfig(); $db = new \permag\database\Database($dbConfig); $db->connect(); $memberModel = new \permag\model\MemberModel($db); $memberId = $memberModel->getMemberIdFromUsername($shareToUsername); $db = null; if ($memberId != null || $memberId != '') { // write session $_SESSION[self::$m_ajaxMemberIdToShare] = $memberId; return $memberId; } else { return null; } } }