3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
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.
48 static $_links = NULL;
56 public function getBAOName() {
57 return 'CRM_Core_BAO_Tag';
64 * (reference) of action links
66 public function &links() {
67 if (!(self
::$_links)) {
68 self
::$_links = array(
69 CRM_Core_Action
::UPDATE
=> array(
71 'url' => 'civicrm/admin/tag',
72 'qs' => 'action=update&id=%%id%%&reset=1',
73 'title' => ts('Edit Tag'),
75 CRM_Core_Action
::DELETE
=> array(
76 'name' => ts('Delete'),
77 'url' => 'civicrm/admin/tag',
78 'qs' => 'action=delete&id=%%id%%',
79 'title' => ts('Delete Tag'),
81 CRM_Core_Action
::FOLLOWUP
=> array(
82 'name' => ts('Merge'),
83 'class' => 'merge_tag',
84 'title' => ts('Merge Tag'),
92 * Get name of edit form.
95 * Classname of edit form.
97 public function editForm() {
98 return 'CRM_Admin_Form_Tag';
102 * Get form name for edit form.
107 public function editName() {
112 * Get form name for delete form.
117 public function deleteName() {
129 public function userContext($mode = NULL) {
130 return 'civicrm/admin/tag';
134 * Get name of delete form.
137 * Classname of delete form.
139 public function deleteForm() {
140 return 'CRM_Admin_Form_Tag';
144 * Override function browse()
146 * @param null $action
149 public function browse($action = NULL, $sort = NULL) {
150 $adminTagSet = FALSE;
151 if (CRM_Core_Permission
::check('administer Tagsets')) {
154 $this->assign('adminTagSet', $adminTagSet);
156 $reservedClause = !CRM_Core_Permission
::check('administer reserved tags') ?
"AND t1.is_reserved != 1" : '';
157 $query = "SELECT t1.name, t1.id
158 FROM civicrm_tag t1 LEFT JOIN civicrm_tag t2 ON t1.id = t2.parent_id
159 WHERE t2.id IS NULL {$reservedClause}";
160 $tag = CRM_Core_DAO
::executeQuery($query);
162 $mergeableTags = array();
163 while ($tag->fetch()) {
164 $mergeableTags[$tag->id
] = 1;
167 $usedFor = CRM_Core_OptionGroup
::values('tag_used_for');
169 $query = "SELECT t1.name, t1.id, t2.name as parent, t1.description, t1.used_for, t1.is_tagset,
170 t1.is_reserved, t1.parent_id, t1.used_for
171 FROM civicrm_tag t1 LEFT JOIN civicrm_tag t2 ON t1.parent_id = t2.id
172 GROUP BY t1.parent_id, t1.id";
174 $tag = CRM_Core_DAO
::executeQuery($query);
177 $action = CRM_Core_Action
::UPDATE + CRM_Core_Action
::DELETE
;
178 $permission = CRM_Core_Permission
::EDIT
;
180 while ($tag->fetch()) {
181 $values[$tag->id
] = (array) $tag;
184 if ($values[$tag->id
]['used_for']) {
185 $usedArray = explode(",", $values[$tag->id
]['used_for']);
186 foreach ($usedArray as $key => $value) {
187 $used[$key] = $usedFor[$value];
192 $values[$tag->id
]['used_for'] = implode(", ", $used);
195 $newAction = $action;
196 if ($values[$tag->id
]['is_reserved']) {
197 $newAction = CRM_Core_Action
::UPDATE
;
200 if ($values[$tag->id
]['is_tagset'] && !CRM_Core_Permission
::check('administer Tagsets')) {
204 if (array_key_exists($tag->id
, $mergeableTags)) {
205 $newAction +
= CRM_Core_Action
::FOLLOWUP
;
208 // populate action links
210 $this->action($tag, $newAction, $values[$tag->id
], self
::links(), $permission, TRUE);
213 $values[$tag->id
]['action'] = '';
217 $this->assign('rows', $values);