3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * Page for displaying Surveys
39 class CRM_Campaign_Page_Survey
extends CRM_Core_Page
{
41 private static $_actionLinks;
43 function &actionLinks() {
44 // check if variable _actionsLinks is populated
45 if (!isset(self
::$_actionLinks)) {
47 self
::$_actionLinks = array(
48 CRM_Core_Action
::UPDATE
=> array(
50 'url' => 'civicrm/survey/add',
51 'qs' => 'action=update&id=%%id%%&reset=1',
52 'title' => ts('Update Survey'),
54 CRM_Core_Action
::DISABLE
=> array(
55 'name' => ts('Disable'),
56 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Campaign_BAO_Survey' . '\',\'' . 'enable-disable' . '\' );"',
57 'ref' => 'disable-action',
58 'title' => ts('Disable Survey'),
60 CRM_Core_Action
::ENABLE
=> array(
61 'name' => ts('Enable'),
62 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Campaign_BAO_Survey' . '\',\'' . 'disable-enable' . '\' );"',
63 'ref' => 'enable-action',
64 'title' => ts('Enable Survey'),
66 CRM_Core_Action
::DELETE
=> array(
67 'name' => ts('Delete'),
68 'url' => 'civicrm/survey/delete',
69 'qs' => 'id=%%id%%&reset=1',
70 'title' => ts('Delete Survey'),
74 return self
::$_actionLinks;
79 $surveys = CRM_Campaign_BAO_Survey
::getSurveySummary();
81 if (!empty($surveys)) {
83 $surveyType = CRM_Campaign_BAO_Survey
::getSurveyActivityType();
84 $campaigns = CRM_Campaign_BAO_Campaign
::getAllCampaign();
85 $activityTypes = CRM_Core_OptionGroup
::values('activity_type', FALSE, FALSE, FALSE, FALSE, 'name');
86 foreach ($surveys as $sid => $survey) {
87 $surveys[$sid]['campaign_id'] = $campaigns[$survey['campaign_id']];
88 $surveys[$sid]['activity_type_id'] = $surveyType[$survey['activity_type_id']];
89 $surveys[$sid]['release_frequency'] = $survey['release_frequency_interval'] . ' ' . $survey['release_frequency_unit'];
91 $action = array_sum(array_keys($this->actionLinks()));
92 if ($survey['is_active']) {
93 $action -= CRM_Core_Action
::ENABLE
;
96 $action -= CRM_Core_Action
::DISABLE
;
99 $surveys[$sid]['action'] = CRM_Core_Action
::formLink($this->actionLinks(), $action, array('id' => $sid));
103 $this->assign('surveys', $surveys);
104 $this->assign('addSurveyUrl', CRM_Utils_System
::url('civicrm/survey/add', 'reset=1&action=add'));
108 if (!CRM_Campaign_BAO_Campaign
::accessCampaign()) {
109 CRM_Utils_System
::permissionDenied();
112 $action = CRM_Utils_Request
::retrieve('action', 'String',
115 $this->assign('action', $action);
118 return parent
::run();