commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / drupal / modules / views / civicrm / civicrm_handler_field_event.inc
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
7 | |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
11 | |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Affero General Public |
18 | License and the CiviCRM Licensing Exception along |
19 | with this program; if not, contact CiviCRM LLC |
20 | at info[AT]civicrm[DOT]org. If you have questions about the |
21 | GNU Affero General Public License or the licensing of CiviCRM, |
22 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 +--------------------------------------------------------------------+
24 */
25
26 /**
27 * Field handler for events to provide simple renderer that allows linking
28 * to the event page.
29 *
30 * @ingroup civicrm_field_handlers
31 */
32 class civicrm_handler_field_event extends views_handler_field_markup {
33
34 /**
35 * Provide link to node option
36 */
37 function options_form(&$form, &$form_state) {
38 parent::options_form($form, $form_state);
39 $form['link_to_event'] = array(
40 '#title' => t('Link this field to its event page'),
41 '#type' => 'checkbox',
42 '#default_value' => $this->options['link_to_event'],
43 );
44 }
45
46 function render_link($data, $values) {
47 if (!empty($this->options['link_to_event']) && user_access('view event info') && $values->id) {
48 return civicrm_views_href($data,
49 'civicrm/event/info',
50 "reset=1&id={$values->id}"
51 );
52 }
53 else {
54 return $data;
55 }
56 }
57
58 function render($values) {
59 $format = is_numeric($this->format) ? $this->format : $values->{$this->aliases['format']};
60 return $this->render_link(check_markup($values->{$this->field_alias}, $format, FALSE), $values);
61 }
62 }
63