diff options
author | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2006-01-22 19:22:13 +0000 |
---|---|---|
committer | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2006-01-22 19:22:13 +0000 |
commit | 78dcbfaa86f2597e6da3472d2bf896c4219cbd12 (patch) | |
tree | 1471634aadc55667bf92215cd43144113bce9072 | |
parent | ffc63c4c6bd2b100e728f819b75c4df6f550c2a0 (diff) | |
download | video-78dcbfaa86f2597e6da3472d2bf896c4219cbd12.tar.gz video-78dcbfaa86f2597e6da3472d2bf896c4219cbd12.tar.bz2 |
Patch #45892 by Khalid Baheyeldin - kbahey
Added a Random Video Block
-rw-r--r-- | video.module | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/video.module b/video.module index 5b991bb..b6268cd 100644 --- a/video.module +++ b/video.module @@ -862,6 +862,7 @@ function video_block($op = 'list', $delta = 0, $edit = array()) { $blocks[1]['info'] = t('Top videos'); $blocks[2]['info'] = t('Most played videos'); $blocks[3]['info'] = t('Most downloaded'); + $blocks[4]['info'] = t('Random video'); return $blocks; } else if ($op == 'view') { @@ -886,6 +887,11 @@ function video_block($op = 'list', $delta = 0, $edit = array()) { 'subject' => variable_get('video_block_title_3', t('Most downloaded')), 'content' => video_block_list($delta) ); + case 4: + return array( + 'subject' => variable_get('video_block_title_4', t('Random video')), + 'content' => video_block_list($delta) + ); } } else if ($op == 'configure') { @@ -901,6 +907,9 @@ function video_block($op = 'list', $delta = 0, $edit = array()) { break; case 3: $default_title = t('Most downloaded'); + break; + case 4: + $default_title = t('Random video'); } $form['video_block_title'] = array( '#type' => 'textfield', @@ -929,6 +938,7 @@ function video_block($op = 'list', $delta = 0, $edit = array()) { * string HTML content for a block */ function video_block_list($delta = 0) { + $count = variable_get("video_block_limit_$delta", 10); switch ($delta) { case 0: $orderby = 'n.created'; @@ -941,8 +951,13 @@ function video_block_list($delta = 0) { break; case 3: $orderby = 'v.download_counter'; + break; + case 4: + $count = 1; + $orderby = 'RAND()'; + break; } - return node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n, {video} v WHERE n.vid = v.vid AND n.type = 'video' AND n.status = 1 AND n.moderate = 0 ORDER BY $orderby DESC"),0, variable_get("video_block_limit_$delta", 10))); + return node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n, {video} v WHERE n.vid = v.vid AND n.type = 'video' AND n.status = 1 AND n.moderate = 0 ORDER BY $orderby DESC"),0, $count)); } /**************************************************** |