/[drupal]/contributions/modules/og_joinrole/og_joinrole.module
ViewVC logotype

Contents of /contributions/modules/og_joinrole/og_joinrole.module

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


Revision 1.3 - (show annotations) (download) (as text)
Wed Feb 13 15:19:03 2008 UTC (21 months, 2 weeks ago) by ultimike
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
Fixed issue with drupal_add_js call.
1 <?php
2 /* $Id: og_joinrole.module,v 1.2 2007/04/23 21:33:27 ultimike Exp $ */
3
4 function og_joinrole_help($section) {
5 switch ($section) {
6 case 'admin/help#og_joinrole':
7 $output = '<p>'. t('The OG joinrole module allows you to force users to have a certain role before they are allowed to join an organic group. This may be useful for membership sites where only certain members are allowed to join groups.') .'</p>';
8 return $output;
9 }
10 }
11
12 function og_joinrole_perm() {
13 return array('subscribe to organic groups');
14 }
15
16 function og_joinrole_menu($may_cache) {
17 $items = array();
18
19 if ($may_cache) {
20 $items[] = array(
21 'path' => 'admin/og/og_joinrole',
22 'title' => t('OG joinrole'),
23 'description' => t('Set various options for the OG join role module.'),
24 'callback' => 'drupal_get_form',
25 'callback arguments' => array('og_joinrole_admin_settings'),
26 'access' => user_access('administer organic groups'),
27 'type' => MENU_NORMAL_ITEM,
28 'description' => t('OG joinrole options.'),
29 );
30 }
31
32 // This menu item overrides the og menu item to add the access stuff. It is outside of $may_cache to help ensure that it is loaded after the og menu item that it is overriding
33 $items[] = array(
34 'path' => 'og/subscribe',
35 'type' => MENU_CALLBACK,
36 'callback' => 'og_subscribe',
37 'access' => user_access('subscribe to organic groups'),
38 'title' => t('Subscribe to group')
39 );
40
41 return $items;
42 }
43
44 function og_joinrole_footer() {
45 /* This replaces any og subscribe links with the text specified on the settings page via javascript.
46 * One weakness of this is that the JavaScript uses some English-only searching to accomplish this.
47 * Non-English languages will need to modify the og_joinrole.js with the search text in their language.
48 */
49 if (!user_access('subscribe to organic groups')) {
50 $js = "var og_joinrole_replacementtext = '". variable_get('og_joinrole_replacementtext', t('You do not have the proper role to join this group or view its private messages.')) ."';";
51 drupal_add_js($js, 'inline');
52 drupal_add_js(drupal_get_path('module', 'og_joinrole') . '/og_joinrole.js');
53 }
54 }
55
56 function og_joinrole_enable() {
57 /*
58 * -set the weight of the module to be higher than that of og so that the menu is sure to get overridden
59 * -if the weight of the og module gets manually changed, then the weight of this module will need to be manually changed as well to something higher
60 */
61 $ogweight = db_result(db_query("SELECT weight FROM {system} WHERE name='og'"));
62 db_query("UPDATE {system} SET weight=%d WHERE name='og_joinrole'", $ogweight + 1);
63 }
64
65 function og_joinrole_admin_settings() {
66 $form = array();
67
68 $form['og_joinrole_replacementtext'] = array(
69 '#type' => 'textfield',
70 '#title' => t('Subscribe Replacement Text'),
71 '#default_value' => variable_get('og_joinrole_replacementtext', t('You do not have the proper role to join this group or view its private messages.')),
72 '#required' => TRUE,
73 '#maxlength' => 100,
74 '#description' => t('Enter the text that will replace any "subscribe" text when the user doesn\'t have the proper role.'),
75 );
76
77 return system_settings_form($form);
78 }

  ViewVC Help
Powered by ViewVC 1.1.2