/[drupal]/contributions/modules/addanother/addanother.install
ViewVC logotype

Contents of /contributions/modules/addanother/addanother.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Fri May 29 15:26:29 2009 UTC (5 months, 4 weeks ago) by robinmonks
Branch: MAIN
CVS Tags: DRUPAL-6--1-4, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.1: +19 -1 lines
File MIME type: text/x-php
Patch #418852 (Keyz)
  Patch to improve permissions
  1) Adds an "administer add another" permission to allow finer adjustment of permissions.
  2) Changes "enable add another" permission to "use add another" to prevent confusion of terms.
  3) Many code style corrections.
1 <?php
2 // $Id: addanother.install,v 1.1 2009/01/15 23:22:22 robinmonks Exp $
3
4 /**
5 * @file
6 * Uninstall and update routines for AddAnother module.
7 */
8
9 /**
10 * Implementation of hook_uninstall().
11 */
12 function addanother_uninstall() {
13 variable_del('addanother_nodetypes');
14 }
15
16 /**
17 * Port over to the new variable storage system.
18 */
19 function addanother_update_1() {
20 $types = node_get_types();
21 $addanother_nodetypes = array();
22 foreach ($types as $type) {
23 $typeid = $type->type;
24 $keep = variable_get('addanother_'. $typeid, 0);
25 if ($keep) {
26 $addanother_nodetypes[$typeid] = $typeid;
27 }
28 variable_del('addanother_'. $typeid);
29 }
30 variable_set('addanother_nodetypes', $addanother_nodetypes);
31 return array();
32 }
33
34 /**
35 * Update permission name to 'use add another' instead of 'enable add another' to improve usability/consistency.
36 */
37 function addanother_update_2() {
38 $ret = array();
39 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
40 while ($role = db_fetch_object($result)) {
41 $renamed_permission = preg_replace('/enable add another/', 'use add another', $role->perm);
42 if ($renamed_permission != $role->perm) {
43 $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
44 }
45 }
46 return $ret;
47 }

  ViewVC Help
Powered by ViewVC 1.1.2