/** * Create new shouts view. */ public function __construct() { parent::__construct(); $this->id = 'shouts'; $this->title = HTML::anchor(Route::url('shouts'), __('Shouts')); $this->_can_shout = Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE); }
/** * Render view. * * @return string */ public function content() { ob_start(); $foursquare = $this->venue->foursquare(); if (!$foursquare) { echo new View_Alert(__('This venue has not been linked to Foursquare yet.'), null, View_Alert::INFO); } else { // Homepage echo HTML::anchor(Arr::path($foursquare, 'short_url'), HTML::image(Arr::path($foursquare, 'primarycategory.iconurl'), array('alt' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')), 'title' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')))) . ' ' . HTML::chars(Arr::path($foursquare, 'primarycategory.nodename'))), '<br />'; // Mayor if ($mayor = Arr::path($foursquare, 'stats.mayor.user')) { echo __('Mayor: :mayor, :city', array(':mayor' => HTML::anchor('http://foursquare.com/user/' . Arr::get($mayor, 'id'), HTML::chars(Arr::get($mayor, 'firstname')) . ' ' . HTML::chars(Arr::get($mayor, 'lastname'))), ':city' => HTML::chars($mayor['homecity']))), '<br />'; } // Checkins echo __('Check-ins: :checkins', array(':checkins' => '<var>' . Arr::path($foursquare, 'stats.checkins') . '</var>')), '<br />'; // Here now echo __('Here now: :herenow', array(':herenow' => '<var>' . Arr::path($foursquare, 'stats.herenow') . '</var>')), '<br />'; // Tips if ($tips = Arr::path($foursquare, 'tips')) { echo '<h5>', __('Tips (:tips)', array(':tips' => '<var>' . count($tips) . '</var>')), '</h5><dl>'; foreach (array_slice($tips, 0, 5) as $tip) { echo '<dt>', HTML::anchor('http://foursquare.com/user/' . Arr::path($tip, 'user.id'), HTML::chars(Arr::path($tip, 'user.firstname')) . ' ' . HTML::chars(Arr::path($tip, 'user.lastname'))), ', ', HTML::chars(Arr::path($tip, 'user.homecity')), ':</dt>'; echo '<dd>', Text::auto_p(HTML::chars(Arr::path($tip, 'text'))), '</dd>'; } echo '</dl>'; } } // Admin controls if (Permission::has($this->venue, Model_Venue::PERMISSION_UPDATE)) { echo HTML::anchor('#map', __('Link to Foursquare'), array('class' => 'action', 'id' => 'link-foursquare')); echo $this->form(); } return ob_get_clean(); }
/** * Action: edit */ public function action_edit() { $this->history = false; // Load role $role_id = (int) $this->request->param('id', 0); if ($role_id) { $role = Model_Role::factory($role_id); if (!$role->loaded()) { throw new Model_Exception($role, $role_id); } Permission::required($role, Model_Role::PERMISSION_UPDATE, self::$user); } else { $role = Model_Role::factory(); Permission::required($role, Model_Role::PERMISSION_CREATE, self::$user); } // Handle post $errors = array(); if ($_POST) { $role->name = Arr::get($_POST, 'name'); $role->description = Arr::get($_POST, 'description'); try { $role->save(); $this->request->redirect(Route::url('roles')); } catch (Validation_Exception $e) { $errors = $e->array->errors('validate'); } } // Set title $this->view = View_Page::factory(__('Role') . ($role->name ? ': ' . $role->name : '')); // Set actions if ($role->loaded() && Permission::has($role, Model_Role::PERMISSION_DELETE, self::$user)) { $this->page_actions[] = array('link' => Route::model($role, 'delete') . '?token=' . Security::csrf(), 'text' => '<i class="icon-trash icon-white"></i> ' . __('Delete role'), 'class' => 'btn btn-danger role-delete'); } $this->view->add(View_Page::COLUMN_MAIN, $this->section_role($role, $errors)); }
/** * Create new shouts view. */ public function __construct() { parent::__construct(); $this->id = 'shouts'; $this->title = __('Shouts'); $this->_can_shout = Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE, self::$_user); }
/** * Construct controller */ public function before() { parent::before(); $this->page_title = __('Forum'); // Generic page actions $this->page_actions['new-posts'] = array('link' => Route::url('forum'), 'text' => '<i class="icon-comment icon-white"></i> ' . __('New posts')); // Forum areas dropdown $groups = Model_Forum_Group::factory()->find_all(); $areas = array(); foreach ($groups as $group) { $divider = false; foreach ($group->areas() as $area) { if (Permission::has($area, Model_Forum_Area::PERMISSION_READ, self::$user)) { $divider = true; $areas[] = array('link' => Route::model($area), 'text' => HTML::entities($area->name)); } } if ($divider) { $areas[] = array('divider' => true); } } array_pop($areas); $this->page_actions['areas'] = array('link' => Route::url('forum_group'), 'text' => '<i class="icon-folder-open icon-white"></i> ' . __('Areas')); $this->page_actions['area'] = array('link' => Route::url('forum_group'), 'text' => '', 'dropdown' => $areas); if (self::$user) { $this->page_actions['private-messages'] = array('link' => Forum::private_messages_url(), 'text' => '<i class="icon-envelope icon-white"></i> ' . __('Private messages')); } }
/** * Add a Notification. * * @static * @param Model_User $user * @param Model_User $target * @param string $class e.g. 'user' * @param string $type e.g. 'login' * @param integer $data_id * @param string $text extra data * @return boolean */ protected static function add(Model_User $user, Model_User $target, $class, $type, $data_id = null, $text = null) { $notification = new Model_Notification(); $notification->set_fields(array('user_id' => $user->id, 'target_id' => $target->id, 'class' => $class, 'type' => $type, 'data_id' => $data_id, 'text' => $text, 'stamp' => time())); if (!Permission::has($notification, Model_Notification::PERMISSION_CREATE, $user)) { return false; } $notification->save(); return $notification->loaded(); }
/** * Controller default action */ public function action_index() { $this->page_title = __('Welcome to :site', array(':site' => Kohana::config('site.site_name'))); // Display news feed $newsfeed = new NewsFeed(self::$user); $newsfeed->max_items = 25; Widget::add('main', View_Module::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array()))); // Shout $shouts = Jelly::select('shout')->limit(10)->execute(); Widget::add('side', View_Module::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE), 'errors' => array(), 'values' => array()))); }
public static function get_24hour_graph() { /* Permission check. */ if (Permission::has('operator_parking_usage')) { /* Select query. */ $select = Database::query("SELECT rc.type_card, UNIX_TIMESTAMP(p.start_date) AS start_date, UNIX_TIMESTAMP(p.end_date) AS end_date FROM parking AS p INNER JOIN rfid_card AS rc ON rc.id = p.rfid_id WHERE start_date > (NOW() - INTERVAL 24 HOUR)"); /* Controleren of query is gelukt. */ if ($select) { /* Maak return array aan. */ $return = array('totaal' => array(), 'ad-hoc' => array(), 'subscription' => array(), 'guest' => array()); /* Maak database array aan. */ $db_array = array(); /* Doorloop alle items. */ while ($obj = $select->fetch_object()) { /* Zet object in array. */ $db_array[] = array('type' => $obj->type_card, 'start' => $obj->start_date, 'end' => $obj->end_date == null || $obj->end_date == '' ? time() : $obj->end_date); } /* Tel db_array. */ $db_array_count = count($db_array); /* Loop 12 keer. */ for ($i = 24; $i > -1; $i--) { /* Bereken timestamp van $i * 2 uren terug. */ $from = strtotime('-' . $i . ' hours'); /* Stel de variabelen in, en zet ze op 0. */ $return['totaal'][$i] = 0; $return['ad-hoc'][$i] = 0; $return['subscription'][$i] = 0; $return['guest'][$i] = 0; /* Loop de hele db_array door. */ for ($j = 0; $j < $db_array_count; $j++) { /* Var $item maken. */ $item = $db_array[$j]; /* Kijken of het huidige item tussen het start datum, en het eind datum van de meting valt. */ if ($item['start'] < $from && $item['end'] > $from) { /* Dat valt dit item, dus tel + 1 bij het item op, en bij totaal. */ $return[strtolower($item['type'])][$i]++; $return['totaal'][$i]++; } } } /* Return de return array. */ return $return; } else { /* Foutmelding. */ throw new Exception('Er ging wat fout bij het berekenen van het parkeer verbruik.'); } } else { /* Geen rechten. */ throw new Exception('U heeft geen rechten om het parkeer verbruik te mogen zien.'); } }
/** * Action: index */ public function action_index() { // Load groups $groups = Model_Forum_Group::factory()->find_all(); // Build page $this->view = new View_Page(__('Forum')); $this->view->tab = 'areas'; // Set actions if (Permission::has(new Model_Forum_Group(), Model_Forum_Group::PERMISSION_CREATE)) { $this->view->actions[] = array('link' => Route::url('forum_group_add'), 'text' => '<i class="icon-plus-sign icon-white"></i> ' . __('New group')); } $this->view->add(View_Page::COLUMN_CENTER, $this->section_groups($groups)); $this->_side_views(); }
/** * Create new view. * * @param Model_Blog_Entry $blog_entry * @param boolean $show_title */ public function __construct(Model_Blog_Entry $blog_entry, $show_title = false) { parent::__construct(); $this->blog_entry = $blog_entry; if ($show_title) { $author = $blog_entry->author(); // $this->avatar = HTML::avatar($author['avatar'], $author['username']); $this->title = HTML::anchor(Route::model($blog_entry), HTML::chars($blog_entry->name)); $this->subtitle = __('By :user, :date', array(':user' => HTML::user($author), ':date' => date('l ', $blog_entry->created) . Date::format(Date::DMY_SHORT, $blog_entry->created))); if (Permission::has($blog_entry, Model_Blog_Entry::PERMISSION_COMMENTS)) { $this->subtitle .= ' | ' . HTML::anchor(Route::model($blog_entry), __('Comments') . ' (' . (int) $blog_entry->comment_count . ')'); } } }
/** * Check permission * * @param string $permission * @param Model_User $user * @return boolean */ public function has_permission($permission, $user) { switch ($permission) { case self::PERMISSION_READ: return Permission::has($this->topic(), Model_Forum_Topic::PERMISSION_READ, $user) && (!$user || !$user->is_ignored($this->author_id)); // No permission if the author is ignored break; // Allow modifying and deleting also from locked topics, fyi // Allow modifying and deleting also from locked topics, fyi case self::PERMISSION_UPDATE: case self::PERMISSION_DELETE: return $user && ($user->id == $this->author_id || $user->has_role('admin')); } return false; }
/** * Action: latest posts */ public function action_index() { $this->view = new View_Page(__('New posts')); $this->view->tab = 'areas'; // Actions if (Permission::has(new Model_Forum_Group(), Model_Forum_Group::PERMISSION_CREATE)) { $this->view->actions[] = array('link' => Route::url('forum_group_add'), 'text' => '<i class="icon-plus-sign"></i> ' . __('New group')); } // New posts $this->view->add(View_Page::COLUMN_CENTER, $this->section_topics(Model_Forum_Topic::factory()->find_active(20))); // Areas $groups = Model_Forum_Group::factory()->find_all(); $this->view->add(View_Page::COLUMN_RIGHT, $this->section_groups($groups)); // $this->_side_views(); }
public function set_new_two_way($accountId, $secret) { /* Controleren of de gebruiker rechten heeft. */ if (Permission::has('panel_account_two_way')) { /* Update query uitvoeren om de secret in te stellen. */ $update = Database::query("UPDATE customer SET secret = '" . Database::escape($secret) . "' WHERE id = " . Database::escape($accountId)); /* Kijken of de query is gelukt. */ if ($update) { /* Secret instellen zodat de two-way geactiveerd is in de huidige sessie. */ $_SESSION['login']['secret'] = true; } else { /* Query ging fout, geef foutmelding terug. */ throw new Exception(Database::error()); } } }
/** * Render view. * * @return string */ public function content() { ob_start(); if ($this->gallery->links) { $links = explode("\n", $this->gallery->links); $count = 0; ?> <ul class="list-unstyled"> <?php foreach ($links as $link) { list($user_id, $url) = explode(',', $link, 2); ?> <li> <?php echo HTML::anchor($url, Text::limit_url($url, 75)); ?> © <?php echo HTML::user($user_id); ?> <?php if (Visitor::$user && $user_id == Visitor::$user->id || Permission::has($this->gallery, Model_Gallery::PERMISSION_UPDATE)) { ?> <?php echo HTML::anchor(Route::model($this->gallery) . '?delete_link=' . $count . '&' . Security::csrf_query(), __('Remove'), array('class' => 'btn btn-danger btn-xs link-delete')); ?> <?php } ?> </li> <?php $count++; } ?> </ul> <?php } // Add new link if (Permission::has($this->gallery, Model_Gallery::PERMISSION_CREATE)) { echo HTML::anchor('#add-link', '<i class="fa fa-plus-circle"></i> ' . __('Add link'), array('data-toggle' => 'collapse', 'data-target' => '#form-link')); echo $this->form(); } return ob_get_clean(); }
/** * Render favorites. * * @return string */ public function favorites() { // Clickable favorites if (Permission::has($this->event, Model_Event::PERMISSION_FAVORITE, self::$_user)) { if ($this->event->is_favorite(self::$_user)) { // Favorite event, click to unfavorite return HTML::anchor(Route::model($this->event, 'unfavorite') . '?token=' . Security::csrf(), '<i class="icon-heart icon-white"></i> ' . $this->event->favorite_count, array('title' => __('Remove favorite'), 'class' => 'ajaxify btn btn-small btn-lovely active')); } else { // Non-favorite event, click to favorite if ($this->event->favorite_count) { return HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="icon-heart icon-white"></i> ' . $this->event->favorite_count, array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-small btn-inverse active')); } else { return HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="icon-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-small btn-inverse active')); } } } return $this->event->favorite_count ? '<span class="btn btn-small btn-inverse disabled"><i class="icon-heart icon-white"></i> ' . $this->event->favorite_count . '</a>' : ''; }
/** * Get favorites. * * @return array */ public function actions() { // Clickable favorites if (Permission::has($this->event, Model_Event::PERMISSION_FAVORITE)) { if ($this->event->is_favorite(Visitor::$user)) { // Favorite event, click to unfavorite return array(HTML::anchor(Route::model($this->event, 'unfavorite') . '?token=' . Security::csrf(), $this->event->favorite_count . ' <i class="fa fa-heart"></i>', array('title' => __('Remove favorite'), 'class' => 'ajaxify btn btn-xs btn-lovely'))); } else { // Non-favorite event, click to favorite if ($this->event->favorite_count > 1) { return array(HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), $this->event->favorite_count . ' <i class="fa fa-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-xs btn-default'))); } else { return array(HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="fa fa-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-xs btn-default text-muted'))); } } } return $this->event->favorite_count ? array('<span class="btn btn-xs btn-default disabled"><i class="fa fa-heart"></i> ' . $this->event->favorite_count . '</span>') : null; }
/** * Action: shout */ public function action_shout() { $shout = Model_Shout::factory(); $errors = array(); if (Permission::has($shout, Permission_Interface::PERMISSION_CREATE) && Security::csrf_valid()) { $shout->author_id = self::$user->id; $shout->shout = $_POST['shout']; $shout->created = time(); try { $shout->save(); } catch (Validation_Exception $e) { $errors = $e->array->errors('validate'); } } if ($this->ajax) { echo new View_Index_Shouts(); exit; } $this->request->redirect(Route::get('shouts')->uri()); }
/** * Action: shout */ public function action_shout() { $shout = Model_Shout::factory(); if (Permission::has($shout, Permission_Interface::PERMISSION_CREATE) && Security::csrf_valid()) { $shout->author_id = Visitor::$user->id; $shout->shout = $_POST['shout']; $shout->created = time(); try { $shout->save(); } catch (Validation_Exception $e) { } } if ($this->ajax) { $section = $this->section_shouts(); $section->aside = true; $this->response->body($section); return; } $this->request->redirect(Route::get('shouts')->uri()); }
public static function get_invoices($cid, $amount = null, $return_type = null) { /* Kijken of $cid null is. */ if ($cid == null) { /* Omdat we nu alle facturen gaan terug gegeven, kijken of de gebruiker rechten heeft. */ if (Permission::has('operator_invoice_show')) { /* Kijken of alle regels terug moeten, of alleen het aantal. */ if ($return_type != null) { /* Select query met alleen de onbetaalde facturen. */ $query = Database::query("SELECT COUNT(id) AS aantal FROM invoice WHERE paid = 0"); } else { /* Select query */ $query = Database::query("SELECT * FROM invoice ORDER BY create_date"); } /* Kijken of query gelukt is. */ if ($query) { /* Return mysql object. */ return $query; } else { /* MySQL foutmelding. */ throw new Exception('Er ging wat fout bij het ophalen van de facturen.<br />' . Database::error()); } } else { /* Geen rechten */ throw new Exception('U heeft geen rechten om alle facturen te mogen inzien.'); } } else { /* Select query */ $query = Database::query("SELECT id, paid, UNIX_TIMESTAMP(create_date) AS create_date, UNIX_TIMESTAMP(paid_date) AS paid_date FROM invoice WHERE customer_id = " . (int) Database::escape($cid) . ' ORDER BY create_date ' . ($amount != null && is_numeric($amount) ? 'LIMIT ' . Database::escape($amount) : '')); /* Kijken of query gelukt is. */ if ($query) { /* Return mysql object. */ return $query; } else { /* MySQL foutmelding. */ throw new Exception('Er ging wat fout bij het ophalen van uw facturen.<br />' . Database::error()); } } }
public static function save($name, $value) { /* Permission check. */ if (Permission::has('operator_settings_edit')) { /* Kijken of de setting bestaat. */ if (Self::get($name) != null) { /* Update query aanmaken. */ $update = Database::query("UPDATE citypark_setting SET setting_value = '" . Database::escape($value) . "' WHERE setting_name = '" . Database::escape($name) . "'"); /* Controleren of de query is mislukt. */ if (!$update) { /* Foutmelding. */ throw new Exception('Er ging wat fout bij het aanpassen van de instelling.<br />' . Database::error()); } } else { /* Setting bestaat niet. */ throw new Exception('De permissie \'' . $name . '\' bestaat niet.'); } } else { /* Geen rechten. */ throw new Exception('U heeft geen rechten om een instellingen te wijzigen.'); } }
/** * Action: edit */ public function action_edit() { $this->history = false; // Load role $role_id = (int) $this->request->param('id', 0); if ($role_id) { $role = Jelly::select('role', $role_id); if (!$role->loaded()) { throw new Model_Exception($role, $role_id); } Permission::required($role, Model_Role::PERMISSION_UPDATE, self::$user); } else { $role = Jelly::factory('role'); Permission::required($role, Model_Role::PERMISSION_CREATE, self::$user); } // Handle post $errors = array(); if ($_POST) { $role->set($_POST); try { $role->save(); $this->request->redirect(Route::get('roles')->uri()); } catch (Validate_Exception $e) { $errors = $e->array->errors('validate'); } } // Set title $this->page_title = __('Role') . ($role->name ? ': ' . HTML::chars($role->name) : ''); // Set actions if ($role->loaded() && Permission::has($role, Model_Role::PERMISSION_DELETE, self::$user)) { $this->page_actions[] = array('link' => Route::model($role, 'delete', false), 'text' => __('Delete role'), 'class' => 'role-delete'); } // Build form $form = array('values' => $role, 'errors' => $errors, 'cancel' => Request::back(Route::get('roles')->uri(), true), 'groups' => array(array('fields' => array('name' => array(), 'description' => array())))); //Widget::add('main', View_Module::factory('roles/edit', array('role' => $role, 'errors' => $errors))); Widget::add('main', View_Module::factory('form/anqh', array('form' => $form))); }
/** * Action: shout */ public function action_shout() { $shout = Jelly::factory('shout'); $errors = array(); if (Permission::has($shout, Permission_Interface::PERMISSION_CREATE) && Security::csrf_valid()) { $shout->author = self::$user; $shout->shout = $_POST['shout']; try { $shout->save(); if (!$this->ajax) { $this->request->redirect(Route::get('shouts')->uri()); } } catch (Validate_Exception $e) { $errors = $e->array->errors('validate'); } } $shouts = Jelly::select('shout')->limit(10)->execute(); $view = View_Module::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => Permission::has($shout, Model_Shout::PERMISSION_CREATE), 'errors' => $errors)); if ($this->ajax) { echo $view; } else { Widget::add('side', $view); } }
<?php /* Kijken of de gebruiker permissies heeft om een verzoek of ticket aan te maken. */ if (isset($_GET['request']) && Permission::has('panel_request_new') || !isset($_GET['request']) && Permission::has('panel_ticket_new')) { $permission = true; } else { $permission = false; } /* Wanneer de pagina met een POST request aangeroepen wordt. */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { /* Kijken of de gebruiker permissies heeft om een verzoek of ticket aan te maken. */ if ($permission) { /* Probeer het onderstaande. */ try { /* Maak een nieuwe ticket aan. */ $id = Ticket::nieuw(!isset($_GET['request'])); /* Kijken of het een ticket is die aangemaakt is, of een verzoek dat is ingedient. */ if (isset($_GET['request'])) { /* Het is een verzoek, geef dit in succes message door. */ $_SESSION['ticket']['success'] = 'Uw verzoek is ingedient.'; /* Ga naar het ingediende verzoek. */ echo '<script>window.location = \'./verzoek/' . $id . '\';</script>'; } else { /* Het is een ticket, geef dit in de succes message door. */ $_SESSION['ticket']['success'] = 'Uw ticket is aangemaakt.'; /* Ga naar het gemaakte ticket. */ echo '<script>window.location = \'./ticket/' . $id . '\';</script>'; } /* Stop het script, zodat de pagina direct door gevoerd wordt. */ exit; } catch (Exception $e) {
/** * Render view. * * @return string */ public function content() { ob_start(); // Load images $flyers = $this->event->flyers(); if (!count($flyers) && $this->event->flyer_front_url) { // Legacy support echo HTML::image($this->event->flyer_front_url, array('width' => 290)); } elseif (count($flyers)) { // Check for actions if (Permission::has($this->event, Model_Event::PERMISSION_UPDATE, self::$_user)) { $action_uri = Route::model($this->event, 'image'); } // Check for missing default image $active_id = $this->event->flyer_front_image_id; if (!$active_id) { $active_id = $flyers->current()->image_id; } ?> <div class="carousel-inner"> <?php foreach ($flyers as $flyer) { ?> <div class="item<?php echo $flyer->image_id == $active_id ? ' active' : ''; ?> "> <?php echo HTML::image($flyer->image()->get_url(), array('width' => 290)); ?> <?php if (isset($action_uri)) { ?> <div class="btn-group"> <?php if ($flyer->image_id == $this->event->flyer_front_image_id) { echo HTML::anchor('#', __('As front'), array('class' => 'btn btn-mini image-change disabled')); echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&back=' . $flyer->image_id, __('As back'), array('class' => 'btn btn-mini image-change')); } elseif ($flyer->image_id == $this->event->flyer_back_image_id) { echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&front=' . $flyer->image_id, __('As front'), array('class' => 'btn btn-mini image-change')); echo HTML::anchor('#', __('As back'), array('class' => 'btn btn-mini image-change disabled')); } else { echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&front=' . $flyer->image_id, __('As front'), array('class' => 'btn btn-mini image-change')); echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&back=' . $flyer->image_id, __('As back'), array('class' => 'btn btn-mini image-change')); } ?> <?php echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&delete=' . $flyer->image_id, '<i class="icon-trash"></i> ' . __('Delete'), array('class' => 'btn btn-mini image-delete')); ?> </div> <?php } ?> </div> <?php } ?> </div> <?php if (count($flyers) > 1) { ?> <a class="carousel-control left" href="#<?php echo $this->id; ?> " data-slide="prev">‹</a> <a class="carousel-control right" href="#<?php echo $this->id; ?> " data-slide="next">›</a> <?php } ?> <?php } elseif (Permission::has($this->event, Model_Event::PERMISSION_UPDATE, self::$_user)) { // Add new flyer echo HTML::anchor(Route::model($this->event, 'image'), '<i class="icon-picture icon-white"></i> ' . __('Add flyer'), array('class' => 'empty ajaxify')); } return ob_get_clean(); }
<?php /* Kijken of de gebruiker rechten heeft op deze pagina. */ if (Permission::has('operator_chart_parking')) { $permission = true; } else { $permission = false; } /* Kijken of de gebruiker permissies heeft. */ if ($permission) { /* Probeer onderstaande. */ try { /* Haal de parkeer grafiek data op. */ $graph_data = Chart::get_guestpass_data(); } catch (Exception $e) { /* Foutmelding gevangen, laat deze zien. */ echo '<div class="col-xs-12">'; echo '<div class="alert alert-danger">'; echo '<a href="#" class="close" data-dismiss="alert">×</a>'; echo '<strong>Foutmelding!</strong> ' . $e->getMessage(); echo '</div>'; echo '</div>'; } } ?> <a><strong><i class="fa fa-info"></i> Gasten pas overzicht</strong></a> <hr /> <?php /* Kijken of de gebruiker de permissies heeft. */
public static function remove_solo($id, $pid) { /* Permissie check. */ if (Permission::has('operator_permission_edit')) { /* Escape ID. */ $id = Database::escape($id); /* Escape permission id. */ $pid = Database::escape($pid); /* Select query. */ $select = Database::query("SELECT id FROM permission_customer_has WHERE customer_id = " . $id . " AND permission_id = " . $pid . " LIMIT 1"); /* Kijken of query gelukt is. */ if ($select) { /* Kijken of het item bestaat. */ if ($select->num_rows != 0) { /* Delete query */ $delete = Database::query("DELETE FROM permission_customer_has WHERE customer_id = " . $id . " AND permission_id = " . $pid . " LIMIT 1"); /* Delete check */ if (!$delete) { /* Foutmelding. */ throw new Exception('Er ging wat fout bij het verwijderen van de recht.<Br />' . Database::error()); } } else { /* Bestaat niet. */ throw new Exception('De recht die u wenst te verijderen bestaat niet.'); } } else { /* Foutmelding. */ throw new Exception('Er ging wat fout bij de controle.<br />' . Database::error()); } } else { /* Geen rechten. */ throw new Exception('U heeft niet de bevoegdheden om rechten toe te mogen voegen,'); } }
<?php /* Kijken of de gebruiker rechten heeft op deze pagina. */ if (Permission::has('operator_subscription_price')) { $permission = true; } else { $permission = false; } /* Kijken of de gebruiker permissies heeft. */ if ($permission) { /* Wanneer de pagina met een POST request aangeroepen wordt, en of action niet leeg is. */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { /* Probeer onderstaande. */ try { /* Probeer prijs aan te passen. */ Pricing::edit_subscription_price(); /* Success bericht. */ $_SESSION['subscription']['success'] = 'De wijziging van de abonnement prijs is succesvol geplant, en wordt uitgevoerd wanneer de maand queue verwerkt wordt.'; /* Javascript gebruiken om de pagina te 'refreshen'. */ echo '<script>window.location = \'./operator_abonnement_prijs\';</script>'; /* Exit het script, zodat er direct geredirect wordt. */ exit; } catch (Exception $e) { /* Foutmelding gevangen, sla deze op. */ $errorMessage = $e->getMessage(); } } /* Probeer onderstaande. */ try { /* Probeer de prijs categorieen op te halen. */ $categories = Pricing::get_category();
/** * Get empty event gallery. * * @param Model_Event $event * @return View_Alert */ public function section_gallery_empty(Model_Event $event) { $can_upload = Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_CREATE, self::$user); $section = new View_Alert(__('.. this event seems to be lacking in the image department.') . ($can_upload ? '<br /><br />' . HTML::anchor(Route::url('galleries', array('action' => 'upload')) . '?from=' . $event->id, '<i class="icon-upload icon-white"></i> ' . __('Upload images'), array('class' => 'btn btn-primary')) : ''), __('Uh oh..'), View_Alert::INFO); return $section; }
/** * Edit forum topic * * @param integer $area_id * @param integer $topic_id * * @throws Model_Exception invalid area, invalid topic * @throws InvalidArgumentException missing area and topic */ protected function _edit_topic($area_id = null, $topic_id = null) { $this->history = false; $this->view = new View_Page(); if ($area_id && !$topic_id) { // Start new topic $mode = View_Forum_PostEdit::NEW_TOPIC; /** @var Model_Forum_Private_Area|Model_Forum_Area $area */ $area = $this->private ? Model_Forum_Private_Area::factory($area_id) : Model_Forum_Area::factory($area_id); if (!$area->loaded()) { throw new Model_Exception($area, $area_id); } Permission::required($area, Model_Forum_Area::PERMISSION_POST, self::$user); $this->view->title = HTML::chars($area->name); if ($this->private) { $topic = new Model_Forum_Private_Topic(); $post = new Model_Forum_Private_Post(); $cancel = Route::url('forum_area', array('id' => 'private', 'action' => '')); $recipients = array(); } else { $topic = new Model_Forum_Topic(); $post = new Model_Forum_Post(); $cancel = Route::model($area); } } else { if ($topic_id) { // Edit old topic $mode = View_Forum_PostEdit::EDIT_TOPIC; /** @var Model_Forum_Private_Topic|Model_Forum_Topic $topic */ $topic = $this->private ? Model_Forum_Private_Topic::factory($topic_id) : Model_Forum_Topic::factory($topic_id); if (!$topic->loaded()) { throw new Model_Exception($topic, $topic_id); } Permission::required($topic, Model_Forum_Topic::PERMISSION_UPDATE, self::$user); // Build recipients list if ($this->private) { $recipients = $topic->find_recipient_names(); } $this->view->title_html = Forum::topic($topic); $cancel = Route::model($topic); // Set actions if (Permission::has($topic, Model_Forum_Topic::PERMISSION_DELETE, self::$user)) { $this->view->actions[] = array('link' => Route::model($topic, 'delete') . '?' . Security::csrf_query(), 'text' => '<i class="icon-trash icon-white"></i> ' . __('Delete topic'), 'class' => 'btn btn-danger topic-delete'); } } else { throw new InvalidArgumentException('Topic and area missing'); } } $errors = array(); if ($_POST && Security::csrf_valid()) { // Get recipients if ($this->private) { $post_recipients = array(); foreach (explode(',', Arr::get_once($_POST, 'recipients')) as $recipient) { if ($user = Model_User::find_user_light(trim($recipient))) { $post_recipients[$user['id']] = $user['username']; } } // Make sure author is included $post_recipients[self::$user->id] = self::$user->username; } if (isset($post)) { // New topic $post->post = $_POST['post']; $post->forum_area_id = $area->id; $post->author_id = self::$user->id; $post->author_name = self::$user->username; $post->author_ip = Request::$client_ip; $post->author_host = Request::host_name(); $post->created = time(); try { $post->is_valid(); } catch (Validation_Exception $e) { $errors += $e->array->errors('validate'); } $topic->author_id = self::$user->id; $topic->author_name = self::$user->username; $topic->name = $_POST['name']; $topic->forum_area_id = $area->id; $topic->created = time(); try { $topic->is_valid(); } catch (Validation_Exception $e) { $errors += $e->array->errors('validate'); } // If no errors found, save models if (empty($errors)) { $topic->save(); // Recipients if ($this->private) { $topic->set_recipients($post_recipients); } // Post $post->forum_topic_id = $topic->id; $post->save(); // Topic $topic->first_post_id = $topic->last_post_id = $post->id; $topic->last_poster = self::$user->username; $topic->last_posted = time(); $topic->post_count = 1; $topic->save(); // Area, only public forums if (!$this->private) { $area->last_topic_id = $topic->id; $area->post_count++; $area->topic_count++; $area->save(); } // User self::$user->post_count++; self::$user->save(); // News feed if (!$this->private) { NewsfeedItem_Forum::topic(self::$user, $topic); } $this->request->redirect(Route::model($topic)); } isset($post_recipients) and $recipients = $post_recipients; } else { // Old topic $topic->set_fields(Arr::intersect($_POST, array('name', 'status', 'sticky'))); try { $topic->save(); // Recipients if ($this->private) { $topic->set_recipients($post_recipients); } $this->request->redirect(Route::model($topic)); } catch (Validation_Exception $e) { $errors = $e->array->errors('validate'); } } } $form['errors'] = $errors; $section = $this->section_post_edit($mode, isset($post) ? $post : null); $section->forum_topic = $topic; $section->errors = $errors; $section->cancel = $cancel; $section->recipients = isset($recipients) ? implode(', ', $recipients) : null; $this->view->add(View_Page::COLUMN_MAIN, $section); }
/** * Set generic page parameters * * @param Model_User $user */ protected function _set_page(Model_User $user) { // Build page $this->view = new View_Page($user->username); if ($user->name) { // $this->view->title_html = HTML::chars($user->username) . ' <small>' . HTML::chars($user->name) . '</small>'; } if ($user->title) { $this->view->subtitle = HTML::chars($user->title); } // Set actions if (self::$user) { // Friend actions if (Permission::has($user, Model_User::PERMISSION_FRIEND, self::$user)) { if (self::$user->is_friend($user)) { $this->view->actions[] = array('link' => URL::user($user, 'unfriend') . '?token=' . Security::csrf(), 'text' => '<i class="icon-heart icon-white"></i> ' . __('Remove friend'), 'class' => 'btn-inverse friend-delete'); } else { $this->view->actions[] = array('link' => URL::user($user, 'friend') . '?token=' . Security::csrf(), 'text' => '<i class="icon-heart icon-white"></i> ' . __('Add to friends'), 'class' => 'btn-primary friend-add'); } } // Ignore actions if (Permission::has($user, Model_User::PERMISSION_IGNORE, self::$user)) { if (self::$user->is_ignored($user)) { $this->view->actions[] = array('link' => URL::user($user, 'unignore') . '?token=' . Security::csrf(), 'text' => '<i class="icon-ban-circle icon-white"></i> ' . __('Unignore'), 'class' => 'btn-inverse ignore-delete'); } else { $this->view->actions[] = array('link' => URL::user($user, 'ignore') . '?token=' . Security::csrf(), 'text' => '<i class="icon-ban-circle icon-white"></i> ' . __('Ignore')); } } $this->view->tabs['profile'] = array('link' => URL::user($user), 'text' => '<i class="icon-user icon-white"></i> ' . __('Profile')); $this->view->tabs['favorites'] = array('link' => URL::user($user, 'favorites'), 'text' => '<i class="icon-calendar icon-white"></i> ' . __('Favorites')); $this->view->tabs['friends'] = array('link' => URL::user($user, 'friends'), 'text' => '<i class="icon-heart icon-white"></i> ' . __('Friends')); // Owner / admin actions if (Permission::has($user, Model_User::PERMISSION_UPDATE, self::$user)) { $this->view->tabs['ignores'] = array('link' => URL::user($user, 'ignores'), 'text' => '<i class="icon-ban-circle icon-white"></i> ' . __('Ingores')); $this->view->tabs['settings'] = array('link' => URL::user($user, 'settings'), 'text' => '<i class="icon-cog icon-white"></i> ' . __('Settings')); } } }