Exemple #1
0
 function actionNewReply($params = '')
 {
     if ($this->objAuthentication->loggedIn()) {
         if (!empty($params['newPost']) && $params['newPost'] == 1) {
             $forumModel = new ForumModel();
             if (!$forumModel->isThreadLocked($params['threadId'])) {
                 $post = array();
                 $post['postid'] = $params['threadId'];
                 $post['topic'] = $params['topic'];
                 $post['message'] = $params['message'];
                 $newPost = $forumModel->addReply($post);
                 if ($newPost) {
                     $objSettings = Settings::getInstance();
                     $perPage = $objSettings->getEntry('per_page_posts');
                     $thread = $forumModel->getThread($post['postid']);
                     $category = $forumModel->getCategory($thread['topic']['catid']);
                     $channel = $forumModel->getChannel($category['channelid']);
                     $totalPages = ceil($forumModel->numbReplies($thread['topic']['id']) / $perPage);
                     if ($totalPages == 0) {
                         $totalPages = 1;
                     }
                     header("Location: http://" . URL . "/community/" . preg_replace('/[^a-zA-Z]/', '_', $channel['name']) . "-" . $channel['id'] . "/" . preg_replace('/[^a-zA-Z]/', '_', $category['name']) . "-" . $category['id'] . "/" . preg_replace('/[^a-zA-Z]/', '_', $thread['topic']['topic']) . "-" . $thread['topic']['id'] . "-" . $totalPages . ".html#" . $newPost);
                 }
             } else {
                 $this->view->assign('content', 'This thread is locked');
                 $this->finish();
             }
         } else {
             $objDispatcher = new Dispatcher();
             $objDispatcher->setController('Forum');
             $objDispatcher->setAction('Index');
             $objDispatcher->setParams($params);
             $objDispatcher->dispatch();
         }
     } else {
         $this->view->assign('errorMsg', 'You must login to make a post');
         $this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
         $this->finish();
     }
 }
Exemple #2
0
$objAuthentication = Authentication::getInstance();
$objSettings = Settings::getInstance();
$objDispatcher = new Dispatcher();
// custom url rewriting
$objUrls = new FriendlyurlModel();
$objUrls->parseRequest($params['_urlrequest']);
if (!empty($objUrls->requestParams)) {
    $params = array_merge($params, $objUrls->requestParams);
}
// start up
try {
    $objSettings->loadSettings();
    $objDispatcher->setDirectory('frontend');
    $objDispatcher->setController($objUrls->requestController);
    $objDispatcher->setAction($objUrls->requestAction);
    $objDispatcher->setParams($params);
    $objDispatcher->dispatch();
} catch (Exception $e) {
    $objEmail = new Emailer();
    $objEmail->addTO(ERROR_EMAIL);
    $objEmail->setFrom(ERROR_EMAIL);
    $objEmail->setSubject('FATAL ERROR | Exception thrown on ' . URL);
    $objEmail->setBody('Fatal Exception! ' . $e->getMessage() . print_r($params, true));
    //$objEmail->sendMail();
    die('Error<br/>' . $e->getMessage() . '<br/><a href="http://' . URL . '">' . PRODUCT_NAME . '</a>');
}
// time to clean up
$dbQueries = $objDatabase->getNumbQueries();
$objDatabase->disconnect();
//end timer
$endTime = microtime(true);
Exemple #3
0
 function actionSubmit($params2 = '')
 {
     // loading $params from global so that the View can load the proper _urlrequest
     global $params;
     $params = array_merge($params, $params2);
     $hasError = false;
     $formErrors = array();
     if (!empty($params['formSubmit'])) {
         $objEmail = new EmailSender();
         $objForm = new FormModel();
         if (!empty($params['formSubmit']['id'])) {
             $formInfo = $objForm->loadForm($params['formSubmit']['id']);
             // validate forms fields
             if (!empty($formInfo['fields'])) {
                 foreach ($formInfo['fields'] as $formField) {
                     if ($formField['required'] == 1) {
                         if (empty($params['formSubmit']['fields'][$formField['id']])) {
                             $hasError = true;
                             $formError = array('field_id' => $formField['id'], 'errorMsg' => $formField['name'] . ' is required.');
                             $formErrors[] = $formError;
                         }
                     }
                 }
             }
             if ($hasError) {
                 // return to page with error message
                 if (!empty($params['returnUrlRequest']) && $params['returnUrlRequest'] != 'Form/submit') {
                     $objDispatcher = new Dispatcher();
                     $objFriendlyUrl = new FriendlyurlModel();
                     $objFriendlyUrl->parseRequest($params['returnUrlRequest']);
                     $controller = $objFriendlyUrl->requestController;
                     $action = $objFriendlyUrl->requestAction;
                     $params = array_merge($params, $objFriendlyUrl->requestParams);
                     $params['_urlrequest'] = $params['returnUrlRequest'];
                     $params['formErrors'] = $formErrors;
                     $objDispatcher->setDirectory('frontend');
                     $objDispatcher->setController($controller);
                     $objDispatcher->setAction($action);
                     $objDispatcher->setParams($params);
                     $objDispatcher->dispatch();
                     exit;
                 } else {
                     die('Please go back and retry submitting the form. Errors: ' . print_r($formErrors));
                 }
             }
             // save to database
             $submission_id = $this->saveToDb($params);
             if ($submission_id) {
                 $params['submission_id'] = $submission_id;
             }
             // email notification
             $objEmail->sendForm($params);
             // return to page with thanks message
             if (!empty($params['returnUrlRequest'])) {
                 header("Location: http://" . URL . '/' . $params['returnUrlRequest'] . '?formSubmitted=true');
             } else {
                 header("Location: http://" . URL . '/');
             }
         }
     }
 }