コード例 #1
0
ファイル: AgendaPoint.php プロジェクト: Comsa-Veurne/modules
 private function loadData()
 {
     if (isset($this->data['id'])) {
         $this->record = FrontendAgendaModel::getById($this->data['id']);
         $this->record['allow_subscriptions'] = $this->record['allow_subscriptions'] == 'Y';
     }
 }
コード例 #2
0
 /**
  * Parse
  */
 private function parse()
 {
     // get agenda (null means unlimited items)
     $agenda = FrontendAgendaModel::getAllUpcomingAgendaItems();
     // assign agenda
     $this->tpl->assign('widgetUpcomingAgendaFull', $agenda);
 }
コード例 #3
0
ファイル: Categories.php プロジェクト: Comsa-Veurne/modules
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $categories = FrontendAgendaModel::getAllCategories();
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('Agenda', 'Category');
         // loop and reset url
         foreach ($categories as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetAgendaCategories', $categories);
 }
コード例 #4
0
ファイル: Category.php プロジェクト: Comsa-Veurne/modules
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $parameter_count = count($this->URL->getParameters(false));
     if ($parameter_count <= 0) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get category
     $this->category = FrontendAgendaModel::getCategory($this->URL->getParameter($parameter_count - 1));
     if (empty($this->category)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('Agenda', 'Category') . '/' . $this->category['url'];
     $this->pagination['limit'] = FrontendModel::getModuleSetting('Agenda', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendAgendaModel::getCategoryCount($this->category['id']);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
     // timestamps
     // @todo SET CORRECT TIMES
     $startTimestamp = strtotime('last Monday 00:59', time());
     // first day of the week
     $endTimestamp = strtotime("next Monday 0:59", time());
     // last day of the week
     // get items
     $this->items = FrontendAgendaModel::getAllByCategory($this->category['id'], $this->pagination['limit'], $this->pagination['offset'], $startTimestamp, $endTimestamp);
     // sort dates
     usort($this->items, "self::cmpValues");
 }
コード例 #5
0
ファイル: Detail.php プロジェクト: Comsa-Veurne/modules
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // get settings
     $subscriptionsAllowed = isset($this->settings['allow_subscriptions']) && $this->settings['allow_subscriptions'];
     // subscriptions aren't allowed so we don't have to validate
     if (!$subscriptionsAllowed) {
         return false;
     }
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // does the key exists?
         if (\SpoonSession::exists('agenda_subscription_' . $this->record['id'])) {
             // calculate difference
             $diff = time() - (int) \SpoonSession::get('agenda_subscription_' . $this->record['id']);
             // calculate difference, it it isn't 10 seconds the we tell the user to slow down
             if ($diff < 10 && $diff != 0) {
                 $this->frm->getField('message')->addError(FL::err('CommentTimeout'));
             }
         }
         // validate required fields
         $this->frm->getField('name')->isFilled(FL::err('NameIsRequired'));
         $this->frm->getField('email')->isEmail(FL::err('EmailIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // get module setting
             $moderationEnabled = isset($this->settings['moderation']) && $this->settings['moderation'];
             // reformat data
             $name = $this->frm->getField('name')->getValue();
             $email = $this->frm->getField('email')->getValue();
             // build array
             $subscription['agenda_id'] = $this->record['id'];
             $subscription['language'] = FRONTEND_LANGUAGE;
             $subscription['created_on'] = FrontendModel::getUTCDate();
             $subscription['name'] = $name;
             $subscription['email'] = $email;
             $subscription['status'] = 'subscribed';
             // get URL for article
             $permaLink = $this->record['full_url'];
             $redirectLink = $permaLink;
             // is moderation enabled
             if ($moderationEnabled) {
                 // if the commenter isn't moderated before alter the subscription status so it will appear in the moderation queue
                 if (!FrontendAgendaModel::isModerated($name, $email)) {
                     $subscription['status'] = 'moderation';
                 }
             }
             // insert comment
             $subscription['id'] = FrontendAgendaModel::insertSubscription($subscription);
             // trigger event
             FrontendModel::triggerEvent('agenda', 'after_add_subscription', array('subscription' => $subscription));
             // append a parameter to the URL so we can show moderation
             if (strpos($redirectLink, '?') === false) {
                 if ($subscription['status'] == 'moderation') {
                     $redirectLink .= '?subscription=moderation#' . FL::act('Subscribe');
                 }
                 if ($subscription['status'] == 'subscribed') {
                     $redirectLink .= '?subscription=true#subscription-' . $subscription['id'];
                 }
             } else {
                 if ($subscription['status'] == 'moderation') {
                     $redirectLink .= '&subscription=moderation#' . FL::act('Subscribe');
                 }
                 if ($subscription['status'] == 'subscribed') {
                     $redirectLink .= '&subscription=true#comment-' . $subscription['id'];
                 }
             }
             // set title
             $subscription['agenda_title'] = $this->record['title'];
             $subscription['agenda_url'] = $this->record['url'];
             // notify the admin
             FrontendAgendaModel::notifyAdmin($subscription);
             // store timestamp in session so we can block excessive usage
             \SpoonSession::set('agenda_subscription_' . $this->record['id'], time());
             // store author-data in cookies
             try {
                 Cookie::set('subscription_author', $name);
                 Cookie::set('subscription_email', $email);
             } catch (Exception $e) {
                 // settings cookies isn't allowed, but because this isn't a real problem we ignore the exception
             }
             // redirect
             $this->redirect($redirectLink);
         }
     }
 }
コード例 #6
0
ファイル: AgendaAll.php プロジェクト: Comsa-Veurne/modules
 private function loadData()
 {
     $this->topitems = FrontendAgendaModel::getAllUpcomingAgendaItems(0, 4);
     $this->items = FrontendAgendaModel::getAllUpcomingAgendaItems(4);
 }
コード例 #7
0
ファイル: Index.php プロジェクト: Comsa-Veurne/modules
 /**
  * Get the data (agenda)
  */
 private function getData()
 {
     $this->topitems = FrontendAgendaModel::getAllUpcomingAgendaItems(0, 4);
     $this->items = FrontendAgendaModel::getAllUpcomingAgendaItems(4);
     //      // requested view
     //        $this->view = $this->URL->getParameter('view', 'string', 'month');
     //
     //        // requested timestamp
     //        $this->timestamp = $this->URL->getParameter('timestamp', 'string', time());
     //
     //        if ($this->URL->getParameter('timestamp', 'string')) {
     //            // add no-index, so the additional pages (next/previous day,month,week,year) won't get accidentally indexed
     //            $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     //        }
     // calculate the timespan of view
     //        $timespan = self::calculateTimespan($this->view, $this->timestamp);
     // get agenda between timespan
     //        $this->items = FrontendAgendaModel::getAllByDate($timespan['beginTimestamp'], $timespan['endTimestamp']);
     // sort dates
     //        usort($this->items, "self::cmpValues");
     // generate next and previous timestamp
     //        $nextTimestamp = strtotime('+1 ' . $this->view . 's', $this->timestamp);
     //        $prevTimestamp = strtotime('-1 ' . $this->view . 's', $this->timestamp);
     //
     //        // generate next and previous urls
     //        $this->nextUrl = '?timestamp=' . $nextTimestamp . '&amp;view=' . $this->view;
     //        $this->prevUrl = '?timestamp=' . $prevTimestamp . '&amp;view=' . $this->view;
 }