/[drupal]/contributions/modules/mlm/include/mlm.form.inc
ViewVC logotype

Diff of /contributions/modules/mlm/include/mlm.form.inc

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

revision 1.2, Mon Aug 10 01:57:46 2009 UTC revision 1.3, Sun Aug 23 23:06:28 2009 UTC
# Line 1  Line 1 
1  <?php // $Id: mlm.form.inc,v 1.1 2009/05/15 14:34:32 vauxia Exp $  <?php // $Id: mlm.form.inc,v 1.2 2009/08/10 01:57:46 vauxia Exp $
   
 /**  
  * Page callback to handle user subscription requests for all lists.  
  */  
 function mlm_admin_lists($list = NULL, $mail='') {  
   // Set a reasonable $mail default  
   if (!valid_email_address($mail)) $mail = '';  
   if (!$mail && $user) $mail = $user->mail;  
   
   if ($list) {  
     $lists = array($list);  
   }  
   else {  
     $lists = mlm_lists(NULL, NULL, $mail);  
   }  
   if (!count($lists)) {  
     return t('There are no mailing lists for this site');  
   }  
   
   $help = variable_get('mlm_help', '');  
   $help = check_markup($help, variable_get('mlm_help_format', 0));  
   if (user_access('administer mlm')) {  
     $help .= l(t('Edit help text'), 'admin/user/mlm/settings');  
   }  
   
   return drupal_get_form('mlm_form', $user, $lists, $help);  
 }  
2    
3  /**  /**
4   * List creation and editing form.   * List creation and editing form.
5   */   */
6  function mlm_form($form_state, $list = NULL) {  function mlm_form($form_state, $mlm = NULL) {
7    if (!$list) {    if (!$mlm) {
8      if (count($backends = mlm_backends()) == 1) {      if (count($backends = mlm_backend_names()) == 1) {
9        $list = mlm_load(current($backends));        $mlm = mlm_load(key($backends));
10      }      }
11      elseif (isset($form_state['storage']['set_mlm_list'])) {      elseif (isset($form_state['storage']['set_mlm_list'])) {
12        $list = mlm_load($form_state['storage']['set_mlm_list']);        $mlm = mlm_load($form_state['storage']['set_mlm_list']);
13      }      }
14      else {      else {
15        // List type selection form.        // List type selection form.
       foreach ($backends as $name => $info) {  
         $options[$name] = $info['title'];  
       }  
16        $form['set_mlm_list'] = array(        $form['set_mlm_list'] = array(
17          '#type' => 'select',          '#type' => 'select',
18          '#title' => t('Mailing list backend'),          '#title' => t('Mailing list backend'),
19          '#options' => $options,          '#options' => $backends,
20        );        );
21        $form['submit'] = array(        $form['submit'] = array(
22          '#type' => 'submit',          '#type' => 'submit',
# Line 54  function mlm_form($form_state, $list = N Line 24  function mlm_form($form_state, $list = N
24        );        );
25      }      }
26    }    }
27    if ($list) {    if ($mlm) {
28      $form = $list->_edit_form($form_state);      $form = $mlm->_edit_form($form_state);
29    
30      $title = $list->lid ? $list->title() : t('Add a list');      $title = $mlm->lid ? $mlm->title() : t('Add a list');
31      drupal_set_title($title);      drupal_set_title($title);
32    
     $form['title'] = array(  
       '#type' => 'textfield',  
       '#title' => t('List name'),  
       '#default_value' => $list->title,  
       '#description' => t(''),  
       '#weight' => -10,  
     );  
33      $form['submit'] = array(      $form['submit'] = array(
34        '#type' => 'submit',        '#type' => 'submit',
35        '#value' => t('Submit'),        '#value' => t('Submit'),
# Line 105  function mlm_form_submit($form, &$form_s Line 68  function mlm_form_submit($form, &$form_s
68      $form_state['redirect'] = $mlm->path();      $form_state['redirect'] = $mlm->path();
69    }    }
70  }  }
   
 /**  
  * Menu callback for a "subscribe" and "unsubscribe" links on an MLM list.  
  */  
 function mlm_admin_callback(&$list, $op, $mail = NULL) {  
   if (!$mail) {  
     global $user;  
     $mail = $user;  
   }  
   switch ($op) {  
     case 'subscribe':  
       $list->_subscribe($mail, TRUE);  
       break;  
   
     case 'unsubscribe':  
       $list->_unsubscribe($mail, TRUE);  
       break;  
   }  
   drupal_goto();  
 }  

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

  ViewVC Help
Powered by ViewVC 1.1.2