/[drupal]/contributions/modules/buddylist2/buddylist_ui/buddylist_ui.admin.inc
ViewVC logotype

Diff of /contributions/modules/buddylist2/buddylist_ui/buddylist_ui.admin.inc

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

revision 1.1.2.1, Tue Jul 29 07:32:59 2008 UTC revision 1.1.2.2, Tue Sep 2 13:16:04 2008 UTC
# Line 36  function buddylist_ui_admin_get_rtypes($ Line 36  function buddylist_ui_admin_get_rtypes($
36      // only add to table if the state matches      // only add to table if the state matches
37      if ($rtype->active == $active_state) {      if ($rtype->active == $active_state) {
38        $path = 'admin/buddylist/rtypes/'. $rtype->rtid;        $path = 'admin/buddylist/rtypes/'. $rtype->rtid;
39        $id = $rtype->rtid;        $id = $rtype->rtid;
40        $final_types[$id] = (array)$rtype;  
41        $ops = array();        $ops = array();
42        $ops[] = l(t('edit'), $path .'/edit');        $ops[] = l(t('edit'), $path .'/edit');
43          $ops[] = l(t('delete'), $path .'/delete');
44    
45        // only type 1 relationtypes can be deleted        $final_types[$id] = (array)$rtype;
46        if($rtype->type == 1)        $final_types[$id]['oneway'] = ($final_types[$id]['oneway'] == 1) ? t('Yes') : t('No');
47          $ops[] = l(t('delete'), $path .'/delete');        $final_types[$id]['backrelation'] = ($final_types[$id]['backrelation'] == 1) ? t('Yes') : t('No');
48          $final_types[$id][] = implode(' ', $ops);
       $final_types[$id]['oneway'] = ($final_types[$id]['oneway'] == 1) ? t('Yes') : t('No');  
       $final_types[$id]['type'] = ($final_types[$id]['type'] == 1) ? t('User') : t('Module');  
49    
50          // do not show if its active
51        unset($final_types[$id]['active']);        unset($final_types[$id]['active']);
   
       $final_types[$id][] = implode(' ', $ops);  
52      }      }
53    }    }
54    
# Line 59  function buddylist_ui_admin_get_rtypes($ Line 57  function buddylist_ui_admin_get_rtypes($
57      return array('#value' => '<p>'. t('None') .'</p>');      return array('#value' => '<p>'. t('None') .'</p>');
58    }    }
59    
60    $header = array(t('Relation ID'), t('Name'), t('Oneway'), t('Type'), t('Operations'));    $header = array(t('Relation ID'), t('Machine Readable Name'), t('Name'), t('Oneway'), t('Free Backrelation'), t('Operations'));
61    return array('#value' => theme('table', $header, $final_types));    return array('#value' => theme('table', $header, $final_types));
62  }  }
63    
64  /**  /**
65   * Returns the form for editing/adding a rtype   * Returns the form for editing/adding a rtype
66   */   */
67  function buddylist_ui_admin_form_edit(&$form_state, $rtid = NULL) {  function buddylist_ui_admin_form_edit(&$form_state, $rtype = NULL) {
68    $form = array();    $form = array();
69    
70    $form['name'] = array(    $form['name'] = array(
71      '#type'           => 'textfield',      '#type'           => 'textfield',
72      '#title'          => t('Name'),      '#title'          => t('Name'),
73      '#maxlength'      => 255,      '#maxlength'      => 255,
74      '#default_value'  => $rtid->name,      '#default_value'  => $rtype->name,
75      '#description'    => t("Example: buddy, friend, colleague."),      '#description'    => t("Example: buddy, friend, colleague."),
76      '#required'       => TRUE,      '#required'       => TRUE,
77    );    );
78    $form['oneway'] = array(    $form['oneway'] = array(
79      '#type'           => 'checkbox',      '#type'           => 'checkbox',
80      '#title'          => t('This is a oneway relationship'),      '#title'          => t('This is a oneway relationship'),
81      '#default_value'  => $rtid->oneway,      '#default_value'  => $rtype->oneway,
82      '#description'    => t('Check this if this relationship should only go one way (Example: Fan, Subscriber)'),      '#description'    => t('Check this if this relationship should only go one way (Example: Fan, Subscriber)'),
83    );    );
84      $form['backrelation'] = array(
85        '#type'           => 'checkbox',
86        '#title'          => t('Free Backrealation'),
87        '#default_value'  => $rtype->backrelation,
88        '#description'    => t('...'),
89      );
90    $form['active'] = array(    $form['active'] = array(
91      '#type'           => 'checkbox',      '#type'           => 'checkbox',
92      '#title'          => t('Relationtype is active'),      '#title'          => t('Relationtype is active'),
93      '#default_value'  => $rtid->active,      '#default_value'  => $rtype->active,
94      '#description'    => t('If checked, users can use this relationship'),      '#description'    => t('If checked, users can use this relationship'),
95    );    );
96    $form['submit'] = array(    $form['submit'] = array(
# Line 95  function buddylist_ui_admin_form_edit(&$ Line 99  function buddylist_ui_admin_form_edit(&$
99    );    );
100    
101    // extra for edit process    // extra for edit process
102    if($rtid != NULL ) {    if($rtype != NULL ) {
103      $form['rtid'] = array(      $form['rtid'] = array(
104        '#type'           => 'hidden',        '#type'           => 'hidden',
105        '#default_value'  => $rtid->rtid,        '#default_value'  => $rtype->rtid,
106      );      );
   
     // if relation type comes from module, admin should not rename rtype  
     if($rtid->type == 0) {  
       unset($form['oneway']);  
       unset($form['name']);  
     }  
107    }    }
108    
109    return $form;    return $form;
# Line 116  function buddylist_ui_admin_form_edit(&$ Line 114  function buddylist_ui_admin_form_edit(&$
114   */   */
115  function buddylist_ui_admin_form_edit_submit($form, &$form_state) {  function buddylist_ui_admin_form_edit_submit($form, &$form_state) {
116    $res = new stdClass();    $res = new stdClass();
117    foreach(array('name', 'oneway', 'active', 'rtid') as $key) {    foreach(array('name', 'oneway', 'backrelation', 'active', 'rtid') as $key) {
118      $res->{$key} = $form_state['values'][$key];      $res->{$key} = $form_state['values'][$key];
119    }    }
120    
# Line 124  function buddylist_ui_admin_form_edit_su Line 122  function buddylist_ui_admin_form_edit_su
122      drupal_set_message(t('Relation type has been updated'));      drupal_set_message(t('Relation type has been updated'));
123    else {    else {
124      drupal_set_message(t('Relation type has been saved'));      drupal_set_message(t('Relation type has been saved'));
   
     // 1 means user generated  
     $res->type = 1;  
125    }    }
126    
127    buddylist_api_rtype_save($res);    buddylist_api_rtype_save($res);

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2