/[drupal]/contributions/modules/invite/invite_admin.inc
ViewVC logotype

Diff of /contributions/modules/invite/invite_admin.inc

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

revision 1.3, Tue Sep 2 17:02:14 2008 UTC revision 1.4, Fri Oct 9 20:28:19 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: invite_admin.inc,v 1.2 2008/08/20 13:26:12 smk Exp $  // $Id: invite_admin.inc,v 1.3 2008/09/02 17:02:14 smk Exp $
3    
4    /**
5     * @file
6     * Administration functions for invite module.
7     */
8    
9  /**  /**
10   * Menu callback; display invite settings form.   * Menu callback; display invite settings form.
11   */   */
12  function invite_settings() {  function invite_settings() {
13    $roles = user_roles(0, 'send invitations');    $roles = user_roles(FALSE, 'send invitations');
14    if (count($roles) == 0) {    if (count($roles) == 0) {
15      drupal_set_message(t('Please enable the <em>send invitations</em> permission for at least one role. This can be done on the <a href="!permissions-url">Permissions page</a>.', array('!permissions-url' => url('admin/user/permissions'))));      drupal_set_message(t('Please enable the <em>send invitations</em> permission for at least one role. This can be done on the <a href="!permissions-url">Permissions page</a>.', array('!permissions-url' => url('admin/user/permissions'))));
16    }    }
17    $target_roles = user_roles(1);    $target_roles = user_roles(TRUE);
18    
19    // General settings.    // General settings.
20    $form['general'] = array(    $form['general'] = array(
# Line 45  function invite_settings() { Line 50  function invite_settings() {
50      '#collapsed' => TRUE,      '#collapsed' => TRUE,
51    );    );
52    
53    foreach ($roles as $role) {    foreach ($roles as $rid => $role) {
54      $role_no_space = str_replace(' ', '_', $role);      $form['role'][$rid] = array(
     $form['role'][$role_no_space] = array(  
55        '#type' => 'fieldset',        '#type' => 'fieldset',
56        '#title' => t('@role settings', array('@role' => ucfirst($role))),        '#title' => t('@role settings', array('@role' => drupal_ucfirst($role))),
57        '#collapsible' => TRUE,        '#collapsible' => TRUE,
58        '#collapsed' => TRUE,        '#collapsed' => TRUE,
59      );      );
60      $form['role'][$role_no_space]['invite_target_role_'. $role_no_space] = array(      $form['role'][$rid]['invite_target_role_'. $rid] = array(
61        '#type' => 'select',        '#type' => 'select',
62        '#title' => t('Target role'),        '#title' => t('Target role'),
63        '#default_value' => variable_get('invite_target_role_'. $role_no_space, DRUPAL_AUTHENTICATED_RID),        '#default_value' => variable_get('invite_target_role_'. $rid, DRUPAL_AUTHENTICATED_RID),
64        '#options' => $target_roles,        '#options' => $target_roles,
65        '#description' => t('You may choose to add invited users to another role (in addition to the default role set in the general section) when they have been invited by a member of %role.', array('%role' => $role)),        '#description' => t('You may choose to add invited users to another role (in addition to the default role set in the general section) when they have been invited by a member of %role.', array('%role' => $role)),
66        '#required' => TRUE,        '#required' => TRUE,
67      );      );
68      $form['role'][$role_no_space]['invite_maxnum_'. $role_no_space] = array(      $form['role'][$rid]['invite_maxnum_'. $rid] = array(
69        '#type' => 'select',        '#type' => 'select',
70        '#title' => t('Invitation limit'),        '#title' => t('Invitation limit'),
71        '#default_value' => variable_get('invite_maxnum_'. $role_no_space, INVITE_UNLIMITED),        '#default_value' => variable_get('invite_maxnum_'. $rid, INVITE_UNLIMITED),
72        '#options' => array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500, 1000 => 1000, INVITE_UNLIMITED => t('unlimited')),        '#options' => array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500, 1000 => 1000, INVITE_UNLIMITED => t('unlimited')),
73        '#description' => t('Allows to limit the total number of invitations members of %role can send.', array('%role' => $role)),        '#description' => t('Allows to limit the total number of invitations members of %role can send.', array('%role' => $role)),
74        '#multiple' => FALSE,        '#multiple' => FALSE,
# Line 185  function invite_admin_overview() { Line 189  function invite_admin_overview() {
189      $query = 'filter='. $filter_args;      $query = 'filter='. $filter_args;
190      unset($_SESSION[INVITE_ADMIN_SESSION]);      unset($_SESSION[INVITE_ADMIN_SESSION]);
191    }    }
192    $sql  = "SELECT i.uid, u1.name, COUNT(*) AS invites, u1.data FROM {invite} i INNER JOIN {users} u1 ON u1.uid = i.uid". $filter ." GROUP BY i.uid";    $sql  = "SELECT i.uid, u1.name, COUNT(*) AS invites, u1.data FROM {invite} i INNER JOIN {users} u1 ON u1.uid = i.uid". $filter ." GROUP BY i.uid, u1.name, u1.data";
193    $sql .= tablesort_sql($header);    $sql .= tablesort_sql($header);
194    $count_sql  = "SELECT COUNT(DISTINCT i.uid) FROM {invite} i". $filter;    $count_sql  = "SELECT COUNT(DISTINCT i.uid) FROM {invite} i". $filter;
195    $result = pager_query($sql, 50, 0, $count_sql, $filter_args);    $result = pager_query($sql, 50, 0, $count_sql, $filter_args);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2