b8b3a6490d089ca9fe2055c875b3e7c3fd8846ce
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 list of categories
39 class CRM_Admin_Page_Tag
extends CRM_Core_Page_Basic
{
41 public $useLivePageJS = TRUE;
44 * The action links that we need to display for the browse screen
49 static $_links = NULL;
54 * @return string Classname of BAO.
56 function getBAOName() {
57 return 'CRM_Core_BAO_Tag';
63 * @return array (reference) of action links
66 if (!(self
::$_links)) {
67 self
::$_links = array(
68 CRM_Core_Action
::UPDATE
=> array(
70 'url' => 'civicrm/admin/tag',
71 'qs' => 'action=update&id=%%id%%&reset=1',
72 'title' => ts('Edit Tag'),
74 CRM_Core_Action
::DELETE
=> array(
75 'name' => ts('Delete'),
76 'url' => 'civicrm/admin/tag',
77 'qs' => 'action=delete&id=%%id%%',
78 'title' => ts('Delete Tag'),
80 CRM_Core_Action
::FOLLOWUP
=> array(
81 'name' => ts('Merge'),
82 'class' => 'merge_tag',
83 'title' => ts('Merge Tag'),
91 * Get name of edit form
93 * @return string Classname of edit form.
96 return 'CRM_Admin_Form_Tag';
100 * Get form name for edit form
102 * @return string name of this page.
104 function editName() {
109 * Get form name for delete form
111 * @return string name of this page.
113 function deleteName() {
122 * @return string user context.
124 function userContext($mode = NULL) {
125 return 'civicrm/admin/tag';
129 * Get name of delete form
131 * @return string Classname of delete form.
133 function deleteForm() {
134 return 'CRM_Admin_Form_Tag';
138 * Override function browse()
140 * @param null $action
143 function browse($action = NULL, $sort = NULL) {
144 $adminTagSet = FALSE;
145 if (CRM_Core_Permission
::check('administer Tagsets')) {
148 $this->assign('adminTagSet', $adminTagSet);
150 $reservedClause = !CRM_Core_Permission
::check('administer reserved tags') ?
"AND t1.is_reserved != 1" : '';
151 $query = "SELECT t1.name, t1.id
152 FROM civicrm_tag t1 LEFT JOIN civicrm_tag t2 ON t1.id = t2.parent_id
153 WHERE t2.id IS NULL {$reservedClause}";
154 $tag = CRM_Core_DAO
::executeQuery($query);
156 $mergeableTags = array();
157 while ($tag->fetch()) {
158 $mergeableTags[$tag->id
] = 1;
161 $usedFor = CRM_Core_OptionGroup
::values('tag_used_for');
163 $query = "SELECT t1.name, t1.id, t2.name as parent, t1.description, t1.used_for, t1.is_tagset,
164 t1.is_reserved, t1.parent_id, t1.used_for
165 FROM civicrm_tag t1 LEFT JOIN civicrm_tag t2 ON t1.parent_id = t2.id
166 GROUP BY t1.parent_id, t1.id";
168 $tag = CRM_Core_DAO
::executeQuery($query);
171 $action = CRM_Core_Action
::UPDATE + CRM_Core_Action
::DELETE
;
172 $permission = CRM_Core_Permission
::EDIT
;
174 while ($tag->fetch()) {
175 $values[$tag->id
] = (array) $tag;
178 if ($values[$tag->id
]['used_for']) {
179 $usedArray = explode(",", $values[$tag->id
]['used_for']);
180 foreach ($usedArray as $key => $value) {
181 $used[$key] = $usedFor[$value];
186 $values[$tag->id
]['used_for'] = implode(", ", $used);
189 $newAction = $action;
190 if ($values[$tag->id
]['is_reserved']) {
191 $newAction = CRM_Core_Action
::UPDATE
;
194 if ($values[$tag->id
]['is_tagset'] && !CRM_Core_Permission
::check('administer Tagsets')) {
198 if (array_key_exists($tag->id
, $mergeableTags)) {
199 $newAction +
= CRM_Core_Action
::FOLLOWUP
;
202 // populate action links
204 $this->action($tag, $newAction, $values[$tag->id
], self
::links(), $permission, TRUE);
207 $values[$tag->id
]['action'] = '';
211 $this->assign('rows', $values);