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

Diff of /contributions/modules/send/send.module

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

revision 1.49, Tue May 26 15:09:52 2009 UTC revision 1.50, Fri Aug 7 01:00:03 2009 UTC
# Line 26  function send_menu() { Line 26  function send_menu() {
26   * Load callback for send_profiles.   * Load callback for send_profiles.
27   */   */
28  function send_profile_load($name) {  function send_profile_load($name) {
29    $profiles = send_profiles(FALSE);    if (is_object($name)) $name = $name->name;
30      $profiles = send_profiles();
31    return $profiles[$name];    return $profiles[$name];
32  }  }
33    
# Line 77  function send_access($profile = NULL, $n Line 78  function send_access($profile = NULL, $n
78   * Implementation of hook_perm().   * Implementation of hook_perm().
79   */   */
80  function send_perm() {  function send_perm() {
81    return array('administer send', 'send nodes', 'view send statistics');    return array('administer send', 'view send statistics');
82  }  }
83    
84  /**  /**
# Line 90  function send_elements() { Line 91  function send_elements() {
91    $defaults = array(    $defaults = array(
92      '#input' => TRUE,      '#input' => TRUE,
93      '#process' => array('send_process'),      '#process' => array('send_process'),
94        '#theme' => 'send_element',
95        '#tree' => TRUE,
96      //'#after_build' => array('send_set_value'),      //'#after_build' => array('send_set_value'),
97    );    );
98    
99    return array(    return array(
100      'send' => $defaults,      'send' => array(
101          '#input' => TRUE,
102          '#tree' => TRUE,
103          '#process' => array('send_process'),
104          // TODO will validate/submit work here?
105         ),
106      'send_contact' => $defaults,      'send_contact' => $defaults,
107      'send_user' => $defaults,      'send_user' => $defaults,
108      'send_multiple' => $defaults,      'send_multiple' => $defaults,
# Line 137  return; Line 145  return;
145  }  }
146    
147  /**  /**
  * Implementation of hook_nodeapi().  
  */  
 function send_nodeapi(&$node, $op) {  
   switch ($op) {  
     case 'insert':  
     case 'update':  
       if (_send_node_enabled($node)) {  
         module_load_include('inc', 'send', 'includes/send.admin');  
         return _send_settings_submit($op, (array)$node);  
       }  
       return;  
     case 'delete':  
       return db_query("DELETE FROM {send_setting} WHERE nid = %d", $node->nid);  
   }  
 }  
   
 /**  
148   * Implementation of hook_user().   * Implementation of hook_user().
149   */   */
150  function send_user($op, &$edit, &$user) {  function send_user($op, &$edit, &$user) {
# Line 173  function send_user($op, &$edit, &$user) Line 164  function send_user($op, &$edit, &$user)
164    }    }
165  }  }
166    
 /**  
  * Implementation of hook_form_alter().  
  */  
 function send_form_alter(&$form, &$form_state, $form_id) {  
   switch ($form['#id']) {  
   
     case 'node-type-form':  
       module_load_include('inc', 'send', 'includes/send.admin');  
       $form = _send_nodetype_form($form);  
       return;  
   
     case 'node-form':  
       if (_send_node_enabled($form['#node'])) {  
         module_load_include('inc', 'send', 'includes/send.admin');  
         $form = _send_node_form($form);  
       }  
       return;  
   }  
   return;  
 }  
   
 /**  
  * Implementation of hook_link().  
  */  
 function send_link($type, $node = NULL) {  
   if (!$node) return;  
   $links = array();  
   
   foreach (send_profiles() as $m => $name) {  
     if (variable_get("{$m}_{$node->type}", 0) && module_invoke($m, 'send', 'access', $m)) {  
       if (variable_get("{$m}_{$node->type}_pernode", 0)) {  
         module_load_include('inc', 'send', 'includes/send.admin');  
         $linktext = send_value('linktext', $m, $node->type, $node);  
       }  
       else {  
         $linktext = variable_get("{$m}_{$node->type}_linktext", '');  
       }  
       if ($linktext != '<none>') {  
         $links[$m] = array(  
           'title' => t($linktext),  
           'href'  => "send/{$m}/{$node->nid}",  
           'attributes' =>  array("class" => 'send-link send-'. $m)  
         );  
       }  
     }  
   }  
   return $links;  
 }  
   
 /**  
  * Helper function to determine if send settings are enabled for a node.  
  */  
 function _send_node_enabled($node, $module = 'send') {  
   $type = $node->type;  
   
   // Not enabled at all.  
   if (!variable_get('send_'. $type, 0)) return FALSE;  
   
   // Enabled for all nodes of this type.  
   if (variable_get('send_'. $type .'_pernode', FALSE)) return TRUE;  
   
   // TODO not returning enabled/pernode setting  
   // TODO not valid for other send modules?  
 }  
   
167  function send_profiles($list_only = TRUE) {  function send_profiles($list_only = TRUE) {
168    static $profiles;    static $profiles;
169    if (!$profiles) {    if (!$profiles) {
# Line 245  function send_profiles($list_only = TRUE Line 171  function send_profiles($list_only = TRUE
171      foreach ($profiles as $name => $info) $profiles[$name]['name'] = $name;      foreach ($profiles as $name => $info) $profiles[$name]['name'] = $name;
172    }    }
173    
174    if ($list_only) {    return $profiles;
175    }
176    
177    function send_profile_names() {
178      static $list;
179      if (!isset($list)) {
180      $list = array();      $list = array();
181      foreach ($profiles as $name => $info) {      foreach (send_profiles() as $name => $info) {
182        $list[$name] = $info['title'];        $list[$name] = $info['title'];
183      }      }
     return $list;  
184    }    }
185      return $list;
   return $profiles;  
186  }  }
187    
188  /**  /**

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.2