public function allow() { if (!$this->public_folder && !Current_User::isLogged()) { return false; } if (!$this->key_id) { return true; } $key = new Key($this->key_id); return $key->allowView(); }
/** * Pathing for which view to display */ public function view() { require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Event.php'; $key = new Key($this->calendar->schedule->key_id); if (!$key->allowView()) { $this->calendar->loadDefaultSchedule(); } $schedule_key = $this->calendar->schedule->getKey(); if (!$this->calendar->schedule->public && !$schedule_key->allowView()) { PHPWS_Core::errorPage('403'); } \Layout::disableRobots(); $current_date = $this->calendar->current_date * 1000; switch ($this->current_view) { case 'day': $this->content = $this->day(); break; case 'grid': if (ALLOW_CACHE_LITE && Current_User::allow('calendar')) { if (strftime('%Y%m', $this->calendar->today) == strftime('%Y%m', $this->calendar->current_date)) { $current_date = $this->calendar->today * 1000; } $this->resetCacheLink('grid', $this->calendar->int_month, $this->calendar->int_year, $this->calendar->schedule->id); } $this->content = $this->month_grid(); break; case 'list': if (ALLOW_CACHE_LITE && Current_User::allow('calendar')) { $this->resetCacheLink('list', $this->calendar->int_month, $this->calendar->int_year, $this->calendar->schedule->id); } $this->content = $this->month_list(); break; case 'week': $this->content = $this->week(); break; case 'event': if (isset($_REQUEST['page'])) { $event_id = (int) $_REQUEST['page']; } elseif (isset($_REQUEST['event_id'])) { $event_id = $_REQUEST['event_id']; } else { $this->content = $this->day(); } if (!$this->loadEvent($event_id) || !$this->event->id) { $this->content = $this->day(); break; } if (isset($_REQUEST['js'])) { $this->content = $this->event(true); Layout::nakedDisplay($this->content); return; } else { $this->content = $this->event(); } break; default: $this->content = dgettext('calendar', 'Incorrect option'); break; } if ($this->calendar->schedule->checkPermissions()) { if ($this->calendar->schedule->id) { require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Admin.php'; $event = new Calendar_Event(0, $this->calendar->schedule); Layout::add(\Calendar_Admin::eventModal($event)); \Calendar_Admin::includeEventJS(); $link = '<a style="cursor:pointer" class="add-event" data-schedule-id="' . $this->calendar->schedule->id . '" data-date="' . $current_date * 1000 . '">Add event</a>'; MiniAdmin::add('calendar', $link); MiniAdmin::add('calendar', $this->calendar->schedule->uploadEventsLink()); } } if ($this->current_view == 'event') { $this->event->flagKey(); } else { $schedule_key->flag(); } }
/** * Displays the blog entry * * @param boolean edit If true, show edit link * @param boolean summarized If true, this is a summarized entry */ public function view($edit = true, $summarized = true) { if (!$this->id) { PHPWS_Core::errorPage(404); } $key = new Key($this->key_id); if (!$key->allowView() || !Blog_User::allowView()) { Current_User::requireLogin(); return dgettext('blog', 'You do not have permission to view this entry.'); } $template['TITLE'] = sprintf('<a href="%s" rel="bookmark">%s</a>', $this->getViewLink(true), $this->title); $template['TITLE_NO_LINK'] = $this->title; if ($this->publish_date > time()) { $template['UNPUBLISHED'] = dgettext('blog', 'Unpublished'); } elseif ($this->expire_date && $this->expire_date < time()) { $template['UNPUBLISHED'] = dgettext('blog', 'Expired'); } $template['LOCAL_DATE'] = $this->getPublishDate(); $summary = $this->getSummary(true); $entry = $this->getEntry(true); if ($summarized) { if (empty($summary)) { $template['SUMMARY'] = PHPWS_Text::parseTag($entry); } else { if (!empty($entry)) { $template['READ_MORE'] = PHPWS_Text::rewriteLink(Icon::get('chevron-circle-down') . ' ' . dgettext('blog', 'Read more'), 'blog', array('id' => $this->id), null, 'Read more of this entry', 'btn btn-default'); } $template['SUMMARY'] = PHPWS_Text::parseTag($summary); } } else { $template['SUMMARY'] = PHPWS_Text::parseTag($summary); $template['ENTRY'] = PHPWS_Text::parseTag($entry); } $template['IMAGE'] = $this->getFile($this->thumbnail && $summarized); if ($edit && (Current_User::allow('blog', 'edit_blog', $this->id, 'entry') || Current_User::allow('blog', 'edit_blog') && $this->author_id == Current_User::getId())) { $vars['blog_id'] = $this->id; $vars['action'] = 'admin'; $vars['command'] = 'edit'; $template['EDIT_LINK'] = PHPWS_Text::secureLink(dgettext('blog', 'Edit'), 'blog', $vars); $template['EDIT_URI'] = PHPWS_Text::linkAddress('blog', $vars, true); if (!$summarized) { MiniAdmin::add('blog', array(PHPWS_Text::secureLink(dgettext('blog', 'Edit blog'), 'blog', $vars))); } } // Check setting for showing when the entry was posted if (PHPWS_Settings::get('blog', 'show_posted_by')) { $template['POSTED_BY'] = dgettext('blog', 'By'); $template['AUTHOR'] = $this->author; } // Check settings for showing the author of the entry if (PHPWS_Settings::get('blog', 'show_posted_date')) { $template['PUBLISHED'] = dgettext('blog', 'Published'); $template['POSTED_ON'] = dgettext('blog', 'Posted on'); $template['PUBLISHED_DATE'] = $this->getPublishDateShort(); } if ($summarized) { $view_tpl = 'view_list.tpl'; } else { $template['COMMENT_SCRIPT'] = PHPWS_Settings::get('blog', 'comment_script'); $key->flag(); $view_tpl = 'view_full.tpl'; } return PHPWS_Template::process($template, 'blog', $view_tpl); }