public static function login(WOOOF $wo) { $requestedAction = 'viewUncontroled'; $pageLocation = '3'; $browserTitle = 'MovieRama Login Page'; $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo); if ($wo === FALSE) { die('Failed to getWOOOF()'); } if ($wo->userData['id'] != '0123456789') { $wo->handleShowStopperError('505'); } $content = <<<EOH \t\t<div id='content-main'></div> \t\t\t\t \t\t<script> \t\t\tReactDOM.render( \t\t\t\tReact.createElement( \t\t\t\t\tLoginBox, \t\t\t\t\t{ nextRoute: "" } \t\t\t\t), \t\t\t\tdocument.getElementById('content-main') \t\t\t); \t\t</script> EOH; $tpl = array('browserTitle' => $browserTitle, 'content' => $content, 'errorMessage' => '', 'message' => ''); $wo->fetchApplicationFragment('structural/template.php', [], $tpl); }
public static function profileEdit(WOOOF $wo) { $requestedAction = 'viewUncontroled'; // TODO: should be edit $pageLocation = '3'; $browserTitle = 'MovieRama Edit User Profile'; $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo); if ($wo === FALSE) { die('Failed to getWOOOF()'); } if ($wo->userData['id'] == '0123456789') { $wo->handleShowStopperError('505'); } $data = VO_ProfileData::getMainInfo($wo, $wo->app->userId); if ($data === FALSE) { $wo->handleShowStopperError(); } $data = json_encode($data); $content = "\n\t\t<div id='content-main'></div>\n\n\t\t<script>\n \tvar data = {$data};\n \t\n \tReactDOM.render(\n \t\tReact.createElement(\n \t\t\tProfileEdit, \n \t\t\t{ data: data }\n \t\t), \n \t\tdocument.getElementById('content-main')\n \t);\n\t\t</script>\n\t\t"; $tpl = array('browserTitle' => $browserTitle, 'content' => $content, 'errorMessage' => '', 'message' => ''); $wo->fetchApplicationFragment('structural/template.php', [], $tpl); }
public static function editEvaluationForm(WOOOF $wo, $evaluationId, $whatType) { $requestedAction = 'viewUncontroled'; $pageLocation = '3'; $browserTitle = 'MovieRama Evaluation Edit Page'; $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo); if ($wo === FALSE) { die('Failed to getWOOOF()'); } if ($wo->userData['id'] == '0123456789') { $wo->handleShowStopperError('505'); } if (!$wo->hasContent($evaluationId)) { $wo->logError(self::_ECP . "5087 No value for id of object to evaluate"); return false; } //CHECK IF YOU ARE OWNER OF THE EVALUATION $isEvaluationOwner = VO_Evaluation::isEvaluationOwner($wo, $evaluationId, $wo->app->userId); if ($isEvaluationOwner === FALSE) { return false; } if ($isEvaluationOwner === 0) { $wo->logError(self::_ECP . "5089 I am sorry you can not edit this evaluation, you are not the owner."); return false; } $lookUps = WOOOF_Domains::getMultipleDomains($wo, array('EVALUATION_TYPE')); if ($lookUps === FALSE) { $wo->handleShowStopperError(); } $templates = VO_Evaluation::getTemplates($wo, $whatType, $wo->app->userId); if ($templates === FALSE) { $wo->handleShowStopperError(); } $lookUps['_TEMPLATES'] = $templates; $lookUps = json_encode($lookUps); $requestedEvaluation = $wo->db->getRow('evaluations', $evaluationId); if ($requestedEvaluation === FALSE) { return false; } if ($requestedEvaluation === NULL) { $wo->logError(self::_ECP . "5090 No row with id [{$evaluationId}] found in evaluations!"); return false; } $list = json_encode($requestedEvaluation); $content = <<<EOH \t\t<div id='content-main'></div> \t \t\t<script> \t\t\tvar lookUps = {$lookUps}; \t\t\tvar list = {$list}; \t\t\t\t\t \t\t\tReactDOM.render( \t\t\t\tReact.createElement( \t\t\t\t\tEvaluationEdit, \t\t\t\t\t{ data: list, lookUps: lookUps } \t\t\t\t), \t\t\t\tdocument.getElementById('content-main') \t\t\t); \t\t</script> EOH; $tpl = array('browserTitle' => $browserTitle, 'content' => $content, 'errorMessage' => '', 'message' => ''); $wo->fetchApplicationFragment('structural/template.php', [], $tpl); }
/** * * @param WOOOF $wo * @param array $in // [ 'email', 'password' ] * @return array [ 'loginOK', 'errors' ] */ public static function loginDo(WOOOF $wo, $in) { $place = __CLASS__ . '::' . __FUNCTION__; //$wo->debug( "$place: [$in]" ); $requestedAction = 'logIn'; $pageLocation = '3'; $browserTitle = 'Logging in MovieRama'; $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo); if ($wo === FALSE) { die('Failed to getWOOOF()'); } if ($wo->userData['id'] != '0123456789') { $wo->handleShowStopperError("505 {$place}: " . $wo->userData['id']); } return VO_Registration::loginDo($wo, $in); }
/** * * @param WOOOF $wo * @param string $movieId * @return false | edit movie page */ public static function editMovie(WOOOF $wo, $movieId) { $requestedAction = 'viewUncontroled'; $pageLocation = '3'; $browserTitle = 'MovieRama Movie Edit Page'; $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo); if ($wo === FALSE) { die('Failed to getWOOOF()'); } if ($wo->userData['id'] == '0123456789') { $wo->handleShowStopperError('505'); } $requestedMovie = $wo->db->getRow('movierama_user_movies', $movieId); if ($requestedMovie === FALSE) { return false; } if ($requestedMovie === NULL) { $wo->logError(self::_ECP . "5085 No row with id [{$movieId}] found in movies table!"); return false; } //check if you really have the edit privileges $isSelfMovieOwner = VO_Movies::isUserMovieCreator($wo, $wo->app->userId, $movieId); if ($isSelfMovieOwner === FALSE) { return false; } if ($isSelfMovieOwner === '0') { $wo->logError(self::_ECP . "5087 I am sorry you cannot edit this movie you are not the creator."); return false; } $list = json_encode($requestedMovie); $movieTitle = json_encode($requestedMovie['title']); $content = <<<EOH \t\t<div id='content-main'></div> \t \t\t<script> \t\t\tvar list = {$list}; \t\t\tvar movieTitle = {$movieTitle}; \t\t\tReactDOM.render( \t\t\t\tReact.createElement( \t\t\t\t\tMovieEdit, \t\t\t\t\t{ data: list, title: movieTitle } \t\t\t\t), \t\t\t\tdocument.getElementById('content-main') \t\t\t); \t\t</script> EOH; $tpl = array('browserTitle' => $browserTitle, 'content' => $content, 'errorMessage' => '', 'message' => ''); $wo->fetchApplicationFragment('structural/template.php', [], $tpl); }