3 +--------------------------------------------------------------------+
4 | CiviCRM Widget Creation Interface (WCI) Version 1.0 |
5 +--------------------------------------------------------------------+
6 | Copyright Zyxware Technologies (c) 2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM WCI. |
10 | CiviCRM WCI is free software; you can copy, modify, and distribute |
11 | it under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
14 | CiviCRM WCI is distributed in the hope that it will be useful, |
15 | but 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 along with this program; if not, contact Zyxware |
21 | Technologies at info[AT]zyxware[DOT]com. |
22 +--------------------------------------------------------------------+
24 require_once 'CRM/Core/Page.php';
25 require_once 'CRM/Wci/DAO/ProgressBar.php';
27 class CRM_Wci_Page_ProgressBarList
extends CRM_Core_Page
{
28 private static $_actionLinks;
31 // get the requested action
32 $action = CRM_Utils_Request
::retrieve('action', 'String',
33 // default to 'browse'
34 $this, FALSE, 'browse'
36 // assign vars to templates
37 $this->assign('action', $action);
38 $id = CRM_Utils_Request
::retrieve('id', 'Positive',
42 if ($action & CRM_Core_Action
::UPDATE
) {
43 $controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_ProgressBar',
45 CRM_Core_Action
::UPDATE
47 $controller->set('id', $id);
48 $controller->process();
49 return $controller->run();
51 elseif ($action & CRM_Core_Action
::DELETE
) {
52 $errorScope = CRM_Core_TemporaryErrorScope
::useException();
54 $transaction = new CRM_Core_Transaction();
55 $sql = "DELETE FROM civicrm_wci_progress_bar_formula where progress_bar_id = %1";
56 $params = array(1 => array($id, 'Integer'));
57 CRM_Core_DAO
::executeQuery($sql, $params);
59 $sql = "DELETE FROM civicrm_wci_progress_bar where id = %1";
60 $params = array(1 => array($id, 'Integer'));
61 CRM_Core_DAO
::executeQuery($sql, $params);
62 $transaction->commit();
64 catch (Exception
$e) {
65 $errmgs = $e->getMessage() . ts('. Check whether progressbar is used by any widget or not');
66 CRM_Core_Session
::setStatus($errmgs, '', 'error');
67 $transaction->rollback();
70 // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
71 CRM_Utils_System
::setTitle(ts('Progress Bar List'));
73 $query = "SELECT * FROM civicrm_wci_progress_bar";
76 $dao = CRM_Core_DAO
::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_ProgressBar');
78 while ($dao->fetch()) {
79 $con_page[$dao->id
] = array();
80 CRM_Core_DAO
::storeValues($dao, $con_page[$dao->id
]);
82 $action = array_sum(array_keys($this->actionLinks()));
83 //build the normal action links.
84 $con_page[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::actionLinks(),
85 $action, array('id' => $dao->id
));
88 if (isset($con_page)) {
89 $this->assign('rows', $con_page);
94 function &actionLinks() {
95 // check if variable _actionsLinks is populated
96 if (!isset(self
::$_actionLinks)) {
97 // helper variable for nicer formatting
98 $deleteExtra = ts('Are you sure you want to delete this Progressbar page?');
100 self
::$_actionLinks = array(
101 CRM_Core_Action
::UPDATE
=> array(
102 'name' => ts('Edit'),
103 'url' => CRM_Utils_System
::currentPath(),
104 'qs' => 'action=update&reset=1&id=%%id%%',
105 'title' => ts('Update'),
107 CRM_Core_Action
::DELETE
=> array(
108 'name' => ts('Delete'),
109 'url' => CRM_Utils_System
::currentPath(),
110 'qs' => 'action=delete&reset=1&id=%%id%%',
111 'title' => ts('Delete Custom Field'),
112 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"',
116 return self
::$_actionLinks;