/[drupal]/contributions/modules/audio/contrib/playlist/audio_playlist.module
ViewVC logotype

Diff of /contributions/modules/audio/contrib/playlist/audio_playlist.module

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

revision 1.4 by drewish, Fri Aug 3 02:41:13 2007 UTC revision 1.5 by drewish, Sun May 25 17:21:27 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: audio_playlist.module,v 1.3 2007/05/26 21:29:09 zirafa Exp $  // $Id: audio_playlist.module,v 1.4 2007/08/03 02:41:13 drewish Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 10  Line 10 
10  /**  /**
11   * Implementation of hook_help().   * Implementation of hook_help().
12   */   */
13  function audio_playlist_help($section) {  function audio_playlist_help($section, $arg) {
14    switch ($section) {    switch ($section) {
15      case 'admin/help#audio_playlist':      case 'admin/help#audio_playlist':
16        return t('This module provides a quick method of adding audio files to other nodes (that allow audio attachments).');        return t('This module provides a quick method of adding audio files to other nodes (that allow audio attachments).');
# Line 31  function audio_playlist_link($type, $nod Line 31  function audio_playlist_link($type, $nod
31        $links['audio_playlist_add_link'] = array(        $links['audio_playlist_add_link'] = array(
32           'title' => t('Add to playlist'),           'title' => t('Add to playlist'),
33           'href' => "audio_playlist/$node->nid",           'href' => "audio_playlist/$node->nid",
34           'query' => 'destination='.$_GET['q'],           'query' => 'destination='. $_GET['q'],
35           'attributes' => array('title' => t('Add to playlist')),           'attributes' => array('title' => t('Add to playlist')),
36        );        );
37      }      }
# Line 47  function audio_playlist_perm() { Line 47  function audio_playlist_perm() {
47    return array(    return array(
48      'attach audio to own playlists',      'attach audio to own playlists',
49      'attach audio to any playlist',      'attach audio to any playlist',
50      );    );
51  }  }
52    
53  /**  /**
54   * Implementation of hook_menu().   * Implementation of hook_menu().
55   */   */
56  function audio_playlist_menu($may_cache) {  function audio_playlist_menu() {
   global $user;  
57    $items = array();    $items = array();
58    
59    if ($may_cache) {    $items['audio_playlist/%node'] = array(
60      $items[] = array(      'title' => 'Add audio file to a playlist',
61        'path' => 'audio_playlist',      'page callback' => 'drupal_get_form',
62        'title' => t('Add audio file to a playlist'),      'page arguments' => array('audio_playlist_add_form', 1),
63        'type' => MENU_CALLBACK,      'access arguments' => array('attach audio to own playlists', 'attach audio to any playlist'),
64        'access' => user_access('attach audio to own playlists') || user_access('attach audio to any playlist'),      'type' => MENU_CALLBACK,
65        'callback' => 'audio_playlist_add_page',    );
     );  
   }  
66    
67    return $items;    return $items;
68  }  }
69    
70  function audio_playlist_add_page() {  function audio_playlist_add_form($node = NULL) {
71    return drupal_get_form('audio_playlist_add_form');    $url = l(t('audio attachments enabled'), 'admin/content/types');
 }  
   
 function audio_playlist_add_form() {  
   $url = l(t("audio attachments enabled"), "admin/content/types");  
72    // make sure things are properly setup    // make sure things are properly setup
73    if (!audio_playlist_get_playlist_types()) {    if (!audio_playlist_get_playlist_types()) {
74      drupal_set_message("At least one content type must have $url for playlists to work.");      drupal_set_message("At least one content type must have $url for playlists to work.");
# Line 90  function audio_playlist_add_form() { Line 83  function audio_playlist_add_form() {
83          '#type' => 'hidden',          '#type' => 'hidden',
84          '#value' => arg(1)          '#value' => arg(1)
85          );          );
86        $form['audio_playlist']['aid_name'] = array (        $form['audio_playlist']['aid_name'] = array(
87          '#type' => 'item',          '#type' => 'item',
88          '#title' => t("Audio file"),          '#title' => t("Audio file"),
89          '#value' => $node->title,          '#value' => $node->title,
90        );        );
91      } else {      }
92        else {
93        drupal_set_message("Sorry, but only audio files can be added to a playlist.");        drupal_set_message("Sorry, but only audio files can be added to a playlist.");
94      }      }
95    }    }
# Line 116  function audio_playlist_add_form() { Line 110  function audio_playlist_add_form() {
110      '#description' => t('Select which playlists you want to add this file to.'),      '#description' => t('Select which playlists you want to add this file to.'),
111    );    );
112    
113    $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));    $form['submit'] = array('#type' => 'submit', '#value' => t('Add to playlist'));
114    
115    return $form;    return $form;
116  }  }
117    
118  function audio_playlist_add_form_submit($form_id, $form_values) {  function audio_playlist_add_form_submit($form, &$form_state) {
119    if ($form_values['aid'] != 0) {    if ($form_state['values']['aid'] != 0) {
120      foreach ($form_values['playlists'] as $nid => $checked) {      foreach ($form_state['values']['playlists'] as $nid => $checked) {
121        if ($checked) {        if ($checked) {
122          audio_attach_add_child($nid, $form_values['aid']);          audio_attach_add_child($nid, $form_state['values']['aid']);
123        }        }
124      }      }
125      drupal_set_message("Added to playlist.");      drupal_set_message("Added to playlist.");
# Line 154  function audio_playlist_get_playlist_nod Line 149  function audio_playlist_get_playlist_nod
149    $sql .= "ORDER BY n.sticky DESC, n.title ASC";    $sql .= "ORDER BY n.sticky DESC, n.title ASC";
150    $rows = array();    $rows = array();
151    $result = db_query(db_rewrite_sql($sql));    $result = db_query(db_rewrite_sql($sql));
   if (db_num_rows($result) == 0) {  
       return array();  
   }  
   
152    while ($row = db_fetch_object($result)) {    while ($row = db_fetch_object($result)) {
153      $node = node_load($row->nid);      $node = node_load($row->nid);
154      $rows[$node->nid] = $node->title ."<small> " . l("(i)", 'node/'. $node->nid, array("target" => "_blank")) ."</small>";      $rows[$node->nid] = $node->title ."<small> " . l("(i)", 'node/'. $node->nid, array("target" => "_blank")) ."</small>";

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

  ViewVC Help
Powered by ViewVC 1.1.3