| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.5 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
| 7 | +--------------------------------------------------------------------+ |
| 8 | | This file is a part of CiviCRM. | |
| 9 | | | |
| 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. | |
| 13 | | | |
| 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. | |
| 18 | | | |
| 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 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @package CRM |
| 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
| 32 | * $Id$ |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | /** |
| 37 | * Page for displaying Parent Information Section tabs |
| 38 | */ |
| 39 | class CRM_Admin_Page_Persistent extends CRM_Core_Page { |
| 40 | |
| 41 | /** |
| 42 | * The action links that we need to display for the browse screen |
| 43 | * |
| 44 | * @var array |
| 45 | * @static |
| 46 | */ |
| 47 | private static $_stringActionLinks; |
| 48 | private static $_customizeActionLinks; |
| 49 | |
| 50 | /** |
| 51 | * Get action Links |
| 52 | * |
| 53 | * @return array (reference) of action links |
| 54 | */ function &stringActionLinks() { |
| 55 | // check if variable _actionsLinks is populated |
| 56 | if (!isset(self::$_stringActionLinks)) { |
| 57 | |
| 58 | self::$_stringActionLinks = array( |
| 59 | CRM_Core_Action::UPDATE => array( |
| 60 | 'name' => ts('Edit'), |
| 61 | 'url' => 'civicrm/admin/tplstrings/add', |
| 62 | 'qs' => 'reset=1&action=update&id=%%id%%', |
| 63 | 'title' => ts('Configure'), |
| 64 | ), |
| 65 | ); |
| 66 | } |
| 67 | return self::$_stringActionLinks; |
| 68 | } |
| 69 | |
| 70 | function &customizeActionLinks() { |
| 71 | // check if variable _actionsLinks is populated |
| 72 | if (!isset(self::$_customizeActionLinks)) { |
| 73 | |
| 74 | self::$_customizeActionLinks = array( |
| 75 | CRM_Core_Action::UPDATE => array( |
| 76 | 'name' => ts('Edit'), |
| 77 | 'url' => 'civicrm/admin/tplstrings/add', |
| 78 | 'qs' => 'reset=1&action=update&id=%%id%%&config=1', |
| 79 | 'title' => ts('Configure'), |
| 80 | ), |
| 81 | ); |
| 82 | } |
| 83 | return self::$_customizeActionLinks; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Run the basic page (run essentially starts execution for that page). |
| 88 | * |
| 89 | * @return void |
| 90 | */ |
| 91 | function run() { |
| 92 | CRM_Utils_System::setTitle(ts('DB Template Strings')); |
| 93 | $this->browse(); |
| 94 | return parent::run(); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Browse all options |
| 99 | * |
| 100 | * |
| 101 | * @return void |
| 102 | * @access public |
| 103 | * @static |
| 104 | */ |
| 105 | function browse() { |
| 106 | $permission = FALSE; |
| 107 | $this->assign('editClass', FALSE); |
| 108 | if (CRM_Core_Permission::check('access CiviCRM')) { |
| 109 | $this->assign('editClass', TRUE); |
| 110 | $permission = TRUE; |
| 111 | } |
| 112 | |
| 113 | $daoResult = new CRM_Core_DAO_Persistent(); |
| 114 | $daoResult->find(); |
| 115 | $schoolValues = array(); |
| 116 | while ($daoResult->fetch()) { |
| 117 | $values[$daoResult->id] = array(); |
| 118 | CRM_Core_DAO::storeValues($daoResult, $values[$daoResult->id]); |
| 119 | if ($daoResult->is_config == 1) { |
| 120 | $values[$daoResult->id]['action'] = CRM_Core_Action::formLink(self::customizeActionLinks(), |
| 121 | NULL, |
| 122 | array('id' => $daoResult->id), |
| 123 | ts('more'), |
| 124 | FALSE, |
| 125 | 'persistent.config.actions', |
| 126 | 'Persistent', |
| 127 | $daoResult->id |
| 128 | ); |
| 129 | $values[$daoResult->id]['data'] = implode(',', unserialize($daoResult->data)); |
| 130 | $configCustomization[$daoResult->id] = $values[$daoResult->id]; |
| 131 | } |
| 132 | if ($daoResult->is_config == 0) { |
| 133 | $values[$daoResult->id]['action'] = CRM_Core_Action::formLink(self::stringActionLinks(), |
| 134 | NULL, |
| 135 | array('id' => $daoResult->id), |
| 136 | ts('more'), |
| 137 | FALSE, |
| 138 | 'persistent.row.actions', |
| 139 | 'Persistent', |
| 140 | $daoResult->id |
| 141 | ); |
| 142 | $configStrings[$daoResult->id] = $values[$daoResult->id]; |
| 143 | } |
| 144 | } |
| 145 | $rows = array( |
| 146 | 'configTemplates' => $configStrings, |
| 147 | 'customizeTemplates' => $configCustomization, |
| 148 | ); |
| 149 | $this->assign('rows', $rows); |
| 150 | } |
| 151 | } |
| 152 | |