|
From: OryNider <ory...@us...> - 2007-08-30 03:52:21
|
Update of /cvsroot/mxbb/mx_music In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv451 Modified Files: db_install.php db_upgrade.php music.php Log Message: This will add subcategories :D Index: db_install.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/db_install.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** db_install.php 25 Aug 2007 03:30:26 -0000 1.3 --- db_install.php 30 Aug 2007 03:52:17 -0000 1.4 *************** *** 108,111 **** --- 108,113 ---- $sql[] = "CREATE TABLE ". $mx_table_prefix . "music_cat ( cat_id mediumint(8) UNSIGNED NOT NULL auto_increment, + cat_parent mediumint(8) UNSIGNED NOT NULL DEFAULT '0', + cat_type tinyint NOT NULL DEFAULT '0', cat_title varchar(255) NOT NULL, cat_desc text, Index: music.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/music.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** music.php 1 Aug 2007 23:33:26 -0000 1.2 --- music.php 30 Aug 2007 03:52:17 -0000 1.3 *************** *** 169,176 **** */ $sql = "SELECT c.*, COUNT(s.song_id) AS count FROM ". MUSIC_CAT_TABLE ." AS c LEFT JOIN ". MUSIC_TABLE ." AS s ON c.cat_id = s.song_cat_id ! WHERE cat_id <> 0 GROUP BY cat_id ORDER BY cat_order ASC"; --- 169,195 ---- */ + $cat_id = $_POST['c'] ? $_POST['c'] : ( $_GET['c'] ? $_GET['c'] : 0 ); + $cat_where = "cat_parent = $cat_id"; + + if ($cat_id != 0) + { + $sql = "SELECT cat_id,cat_title + FROM ". MUSIC_CAT_TABLE ." + WHERE cat_id = $cat_id"; + if ( $result = $db->sql_query($sql) ) + { + $row = $db->sql_fetchrow($result); + + $template->assign_vars(array( + 'SUBCAT_NAV' => '-> <a class="nav" href="' . append_sid(this_mo_mxurl("c=" . $row['cat_id'])) . '">' . $row['cat_title'] . '</a>', + ) + ); + } + } + $sql = "SELECT c.*, COUNT(s.song_id) AS count FROM ". MUSIC_CAT_TABLE ." AS c LEFT JOIN ". MUSIC_TABLE ." AS s ON c.cat_id = s.song_cat_id ! WHERE $cat_where GROUP BY cat_id ORDER BY cat_order ASC"; *************** *** 251,343 **** // ------------------------------------------ ! if ($catrows[$i]['count'] == 0) ! { ! // ! // Oh, this category is empty ! // ! $last_song_info = $lang['No_Songs']; ! $u_last_song = ''; ! $last_song_title = ''; ! } ! else ! { ! // ---------------------------- ! // Check Song Approval ! // ---------------------------- ! ! if(($catrows[$i]['cat_approval'] == MUSIC_ADMIN) or ($catrows[$i]['cat_approval'] == MUSIC_MOD)) { ! $song_approval_sql = 'AND s.song_approval = 1'; // song Approval ON } else { ! $song_approval_sql = ''; // song Approval OFF ! } - // ---------------------------- - // OK, we may do a query now... - // ---------------------------- ! $sql = "SELECT s.song_id, s.song_title, s.song_singer, s.song_user_id, s.song_username, s.song_time, s.song_cat_id, u.user_id, u.username ! FROM ". MUSIC_TABLE ." AS s LEFT JOIN ". USERS_TABLE ." AS u ON s.song_user_id = u.user_id ! WHERE s.song_cat_id = '". $catrows[$i]['cat_id'] ."' $song_approval_sql ! ORDER BY s.song_time DESC ! LIMIT 1"; ! if ( !$result = $db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not get last song information', '', __LINE__, __FILE__, $sql); ! } ! $lastrow = $db->sql_fetchrow($result); - // ---------------------------- - // Write the Date - // ---------------------------- ! $last_song_info = create_date($board_config['default_dateformat'], $lastrow['song_time'], $board_config['board_timezone']); ! $last_song_info .= '<br />'; - // ---------------------------- - // Write username of last poster - // ---------------------------- ! if( ($lastrow['user_id'] == MUSIC_GUEST) or ($lastrow['username'] == '') ) ! { ! $last_song_info .= ($lastrow['song_username'] == '') ? $lang['Guest'] : $lastrow['song_username']; ! } ! else ! { ! $last_song_info .= $lang['Poster'] .': <a href="'. append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $lastrow['user_id']) .'">'. $lastrow['username'] .'</a>'; ! } - // ---------------------------- - // Write the last song's title. - // Truncate it if it's too long - // ---------------------------- ! if( !isset($music_config['last_song_title_length']) ) ! { ! $music_config['last_song_title_length'] = 25; ! } ! $lastrow['song_title'] = $lastrow['song_title']; ! if (strlen($lastrow['song_title']) > $music_config['last_song_title_length']) ! { ! $lastrow['song_title'] = substr($lastrow['song_title'], 0, $music_config['last_song_title_length']) . '...'; ! } ! $last_song_info .= '<br />'. $lang['Song_Title'] .': <a href="'; ! $last_song_info .= append_sid(this_mo_mxurl("music_mode=music_page&song_id=". $lastrow['song_id'])) .'">' ; ! $last_song_info .= $lastrow['song_title'] .'</a>'; ! } ! // END of Last Song // ------------------------------------------ --- 270,407 ---- // ------------------------------------------ ! if ($catrows[$i]['cat_type'] == 0) ! { ! if ($catrows[$i]['count'] == 0) { ! // ! // Oh, this category is empty ! // ! $last_song_info = $lang['No_Songs']; ! $u_last_song = ''; ! $last_song_title = ''; } else { ! // ---------------------------- ! // Check Song Approval ! // ---------------------------- + if(($catrows[$i]['cat_approval'] == MUSIC_ADMIN) or ($catrows[$i]['cat_approval'] == MUSIC_MOD)) + { + $song_approval_sql = 'AND s.song_approval = 1'; // song Approval ON + } + else + { + $song_approval_sql = ''; // song Approval OFF + } ! // ---------------------------- ! // OK, we may do a query now... ! // ---------------------------- + $sql = "SELECT s.song_id, s.song_title, s.song_singer, s.song_user_id, s.song_username, s.song_time, s.song_cat_id, u.user_id, u.username + FROM ". MUSIC_TABLE ." AS s LEFT JOIN ". USERS_TABLE ." AS u ON s.song_user_id = u.user_id + WHERE s.song_cat_id = '". $catrows[$i]['cat_id'] ."' $song_approval_sql + ORDER BY s.song_time DESC + LIMIT 1"; + if ( !$result = $db->sql_query($sql) ) + { + mx_message_die(GENERAL_ERROR, 'Could not get last song information', '', __LINE__, __FILE__, $sql); + } + $lastrow = $db->sql_fetchrow($result); ! // ---------------------------- ! // Write the Date ! // ---------------------------- ! $last_song_info = create_date($board_config['default_dateformat'], $lastrow['song_time'], $board_config['board_timezone']); + $last_song_info .= '<br />'; ! // ---------------------------- ! // Write username of last poster ! // ---------------------------- + if( ($lastrow['user_id'] == MUSIC_GUEST) or ($lastrow['username'] == '') ) + { + $last_song_info .= ($lastrow['song_username'] == '') ? $lang['Guest'] : $lastrow['song_username']; + } + else + { + $last_song_info .= $lang['Poster'] .': <a href="'. append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $lastrow['user_id']) .'">'. $lastrow['username'] .'</a>'; + } ! // ---------------------------- ! // Write the last song's title. ! // Truncate it if it's too long ! // ---------------------------- ! if( !isset($music_config['last_song_title_length']) ) ! { ! $music_config['last_song_title_length'] = 25; ! } ! $lastrow['song_title'] = $lastrow['song_title']; ! if (strlen($lastrow['song_title']) > $music_config['last_song_title_length']) ! { ! $lastrow['song_title'] = substr($lastrow['song_title'], 0, $music_config['last_song_title_length']) . '...'; ! } ! $last_song_info .= '<br />'. $lang['Song_Title'] .': <a href="'; ! $last_song_info .= append_sid(this_mo_mxurl("music_mode=music_page&song_id=" . $lastrow['song_id'])) .'">' ; + $last_song_info .= $lastrow['song_title'] .'</a>'; + } + // END of Last Song + } + else + { + // this is a parent category + $sc_sql = "SELECT * + FROM ". MUSIC_CAT_TABLE ." + WHERE cat_parent = " . $catrows[$i]['cat_id'] . " + GROUP BY cat_id + ORDER BY cat_order ASC"; + + if ( !($sc_result = $db->sql_query($sc_sql)) ) + { + mx_message_die(GENERAL_ERROR, 'Could not query sub categories', '', __LINE__, __FILE__, $sql); + } + + $sql_count = "SELECT count(cat_id) as count + FROM ". MUSIC_CAT_TABLE ." + WHERE cat_parent = " . $catrows[$i]['cat_id']; + if ( ($result_count = $db->sql_query($sql_count)) ) + { + $subcat_count = $db->sql_fetchrow($result_count); + $subcat_count = $subcat_count['count'] . " sub catagories"; + } + else + { + $subcat_count = ""; + } + + $subcats = "<br /><span class=\"gensmall\"><b>Sub-catagories:</b><br />"; + while ( $subcatrow = $db->sql_fetchrow($sc_result) ) + { + $subcats .= " - <a class=\"gensmall\" href=\"" . append_sid(this_mo_mxurl("music_mode=music_cat&cat_id=". $subcatrow['cat_id'])) . "\">" . $subcatrow['cat_title'] . "</a><br />"; + } + $subcats .= "</span><br />"; + + $template->assign_block_vars('catrow', array( + 'U_VIEW_CAT' => append_sid(this_mo_mxurl("music_mode=music_index&c=". $catrows[$i]['cat_id'])), + 'CAT_TITLE' => $catrows[$i]['cat_title'], + 'CAT_DESC' => $catrows[$i]['cat_desc'], + 'SONGS' => $subcat_count, + 'SUBCATS' => $subcats, + ) + ); + } // ------------------------------------------ *************** *** 345,358 **** // ------------------------------------------ ! $template->assign_block_vars('catrow', array( ! 'U_VIEW_CAT' => append_sid(this_mo_mxurl("music_mode=music_cat&cat_id=". $catrows[$i]['cat_id'])), ! 'CAT_TITLE' => $catrows[$i]['cat_title'], ! 'CAT_DESC' => $catrows[$i]['cat_desc'], ! 'CAT_VIEWS' => $catrows[$i]['cat_views'], ! 'L_MODERATORS' => $l_moderators, ! 'MODERATORS' => $moderators_list, ! 'SONGS' => $catrows[$i]['count'], ! 'LAST_SONG_INFO' => $last_song_info) ! ); } // END of Categories Index --- 409,425 ---- // ------------------------------------------ ! if ($catrows[$i]['cat_type'] == 0) ! { ! $template->assign_block_vars('catrow', array( ! 'U_VIEW_CAT' => append_sid(this_mo_mxurl("music_mode=music_cat&cat_id=". $catrows[$i]['cat_id'])), ! 'CAT_TITLE' => $catrows[$i]['cat_title'], ! 'CAT_DESC' => $catrows[$i]['cat_desc'], ! 'CAT_VIEWS' => $catrows[$i]['cat_views'], ! 'L_MODERATORS' => $l_moderators, ! 'MODERATORS' => $moderators_list, ! 'SONGS' => $catrows[$i]['count'], ! 'LAST_SONG_INFO' => $last_song_info) ! ); ! } } // END of Categories Index Index: db_upgrade.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/db_upgrade.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** db_upgrade.php 25 Aug 2007 03:30:26 -0000 1.3 --- db_upgrade.php 30 Aug 2007 03:52:17 -0000 1.4 *************** *** 43,46 **** --- 43,47 ---- // $upgrade_206 = 0; + $upgrade_207 = 0; // *************** *** 53,56 **** --- 54,66 ---- } + // + // validate before 2.07 + // + $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "music_config WHERE config_name = 'img_allowed'" ); + if ( $db->sql_numrows( $result ) == 0 ) + { + $upgrade_207 = 1; + } + $message = "<b>Upgrading!</b><br/><br/>"; *************** *** 71,77 **** $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('qt_allowed', '1')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('rm_allowed', '1')"; ! $sql[] = "UPDATE ". $mx_table_prefix ."music_config ! SET config_value = '0.6' ! WHERE config_name = 'music_version'"; $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('max_image_size', '10240')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('max_image_width', '300')"; --- 81,85 ---- $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('qt_allowed', '1')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('rm_allowed', '1')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('max_image_size', '10240')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('max_image_width', '300')"; *************** *** 82,85 **** --- 90,107 ---- $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('index', '5')"; } + + if ( $upgrade_207 == 1 ) + { + $message .= "<b>Upgrading to v. 2.0.7...</b><br/><br/>"; + + $sql[] = "INSERT INTO " . $mx_table_prefix . "music_config VALUES ('img_allowed', '1')"; + + $sql[] = "ALTER TABLE " . $mx_table_prefix . "music_cat ADD cat_parent mediumint(8) UNSIGNED NOT NULL DEFAULT '0' AFTER cat_id"; + $sql[] = "ALTER TABLE " . $mx_table_prefix . "music_cat ADD cat_type tinyint NOT NULL DEFAULT '0' AFTER cat_parent"; + + $sql[] = "UPDATE ". $mx_table_prefix ."music_config + SET config_value = '0.7' + WHERE config_name = 'music_version'"; + } else { |