3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * Page for displaying Surveys
39 class CRM_Campaign_Page_Survey
extends CRM_Core_Page
{
41 public $useLivePageJS = TRUE;
43 private static $_actionLinks;
48 function &actionLinks() {
49 // check if variable _actionsLinks is populated
50 if (!isset(self
::$_actionLinks)) {
52 self
::$_actionLinks = array(
53 CRM_Core_Action
::UPDATE
=> array(
55 'url' => 'civicrm/survey/add',
56 'qs' => 'action=update&id=%%id%%&reset=1',
57 'title' => ts('Update Survey'),
59 CRM_Core_Action
::DISABLE
=> array(
60 'name' => ts('Disable'),
61 'ref' => 'crm-enable-disable',
62 'title' => ts('Disable Survey'),
64 CRM_Core_Action
::ENABLE
=> array(
65 'name' => ts('Enable'),
66 'ref' => 'crm-enable-disable',
67 'title' => ts('Enable Survey'),
69 CRM_Core_Action
::DELETE
=> array(
70 'name' => ts('Delete'),
71 'url' => 'civicrm/survey/delete',
72 'qs' => 'id=%%id%%&reset=1',
73 'title' => ts('Delete Survey'),
77 return self
::$_actionLinks;
82 $surveys = CRM_Campaign_BAO_Survey
::getSurveySummary();
84 if (!empty($surveys)) {
86 $surveyType = CRM_Campaign_BAO_Survey
::getSurveyActivityType();
87 $campaigns = CRM_Campaign_BAO_Campaign
::getAllCampaign();
88 $activityTypes = CRM_Core_OptionGroup
::values('activity_type', FALSE, FALSE, FALSE, FALSE, 'name');
89 foreach ($surveys as $sid => $survey) {
90 $surveys[$sid]['campaign_id'] = $campaigns[$survey['campaign_id']];
91 $surveys[$sid]['activity_type_id'] = $surveyType[$survey['activity_type_id']];
92 $surveys[$sid]['release_frequency'] = $survey['release_frequency_interval'] . ' ' . $survey['release_frequency_unit'];
94 $action = array_sum(array_keys($this->actionLinks()));
95 if ($survey['is_active']) {
96 $action -= CRM_Core_Action
::ENABLE
;
99 $action -= CRM_Core_Action
::DISABLE
;
102 $surveys[$sid]['action'] = CRM_Core_Action
::formLink(
103 $this->actionLinks(),
108 'survey.selector.row',
115 $this->assign('surveys', $surveys);
116 $this->assign('addSurveyUrl', CRM_Utils_System
::url('civicrm/survey/add', 'reset=1&action=add'));
123 if (!CRM_Campaign_BAO_Campaign
::accessCampaign()) {
124 CRM_Utils_System
::permissionDenied();
127 $action = CRM_Utils_Request
::retrieve('action', 'String',
130 $this->assign('action', $action);
133 return parent
::run();