|
From: OryNider <ory...@us...> - 2007-08-30 03:52:21
|
Update of /cvsroot/mxbb/mx_music/admin In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv451/admin Modified Files: admin_music_cat.php Log Message: This will add subcategories :D Index: admin_music_cat.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/admin/admin_music_cat.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** admin_music_cat.php 1 Aug 2007 23:33:26 -0000 1.2 --- admin_music_cat.php 30 Aug 2007 03:52:17 -0000 1.3 *************** *** 104,107 **** --- 104,108 ---- 'L_DELETE' => $lang['Delete'], 'S_MODE' => 'new', + 'L_CREATE_MUSIC' => $lang['Create_music'], 'L_CREATE_CATEGORY' => $lang['Create_category']) ); *************** *** 109,112 **** --- 110,114 ---- $sql = "SELECT * FROM ". MUSIC_CAT_TABLE ." + WHERE cat_parent = 0 ORDER BY cat_order ASC"; if(!$result = $db->sql_query($sql)) *************** *** 121,128 **** --- 123,145 ---- for( $i = 0; $i < count($catrow); $i++ ) { + if ($catrow[$i]['cat_type'] != 0) + { + $colspan = 1; + $add_sc = "<td class=\"" . (($i % 2) ? 'row1' : 'row2') . "\" align=\"center\">" . + "<form action=\"" . append_sid("admin_music_cat.$phpEx") . "\" method=\"post\"><input type=\"hidden\" value=\"new\" name=\"mode\" /><input type=\"hidden\" value=\"" . $catrow[$i]['cat_id'] . "\" name=\"cat_parent\"><input name=\"submit\" type=\"submit\" value=\"" . $lang['Create_sub_music'] . "\" class=\"liteoption\">" . + "</form></td>"; + } + else + { + $colspan = 2; + $add_sc = ""; + } + $template->assign_block_vars('catrow', array( 'COLOR' => ($i % 2) ? 'row1' : 'row2', 'TITLE' => $catrow[$i]['cat_title'], 'DESC' => $catrow[$i]['cat_desc'], + 'COLSPAN' => $colspan, + 'ADD_SC' => $add_sc, 'S_MOVE_UP' => append_sid("admin_music_cat.$phpEx?action=move&move=-15&cat_id=" . $catrow[$i]['cat_id']), 'S_MOVE_DOWN' => append_sid("admin_music_cat.$phpEx?action=move&move=15&cat_id=" . $catrow[$i]['cat_id']), *************** *** 131,134 **** --- 148,182 ---- ) ); + + if ($catrow[$i]['cat_type'] != 0) + { + // this is a parent category + $sc_sql = "SELECT * + FROM ". MUSIC_CAT_TABLE ." + WHERE cat_parent = " . $catrow[$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__, $sc_sql); + } + + while ($subcatrow = $db->sql_fetchrow($sc_result)) + { + $template->assign_block_vars('catrow', array( + 'COLSPAN' => 2, + 'ADD_SC' => '', + 'COLOR' => ($i % 2) ? 'row1' : 'row2', + 'TITLE' => " " . $subcatrow['cat_title'], + 'DESC' => " " . preg_replace("#\n#", "<br> ", $subcatrow['cat_desc']), + 'S_MOVE_UP' => append_sid("admin_music_cat.$phpEx?action=move&move=-15&cat_parent=" . $catrow[$i]['cat_id'] . "&cat_id=" . $subcatrow['cat_id']), + 'S_MOVE_UP' => append_sid("admin_music_cat.$phpEx?action=move&move=15&cat_parent=" . $catrow[$i]['cat_id'] . "&cat_id=" . $subcatrow['cat_id']), + 'S_EDIT_ACTION' => append_sid("admin_music_cat.$phpEx?action=edit&cat_id=" . $subcatrow['cat_id']), + 'S_DELETE_ACTION' => append_sid("admin_music_cat.$phpEx?action=delete&cat_id=" . $subcatrow['cat_id']) + ) + ); + } + } } *************** *** 316,322 **** } } ! else ! { ! if( $HTTP_POST_VARS['mode'] == 'new' ) { if( !isset($HTTP_POST_VARS['cat_title']) ) --- 364,370 ---- } } ! else ! { ! if(( $HTTP_POST_VARS['mode'] == 'new' ) || ($HTTP_POST_VARS['mode'] == 'newcat')) { if( !isset($HTTP_POST_VARS['cat_title']) ) *************** *** 326,329 **** --- 374,391 ---- ); + if ( !isset($HTTP_POST_VARS['cat_parent']) ) + { + $cat_parent = ""; + } + else + { + $cat_parent = "<input type=\"hidden\" value=\"" . $HTTP_POST_VARS['cat_parent'] . "\" name=\"cat_parent\">"; + } + + if ($HTTP_POST_VARS['mode'] == 'newcat') + { + $cat_type = "<input type=\"hidden\" value=\"1\" name=\"cat_type\">"; + } + $template->assign_vars(array( 'L_MUSIC_CAT_TITLE' => $lang['Music_Categories_Title'], *************** *** 364,367 **** --- 426,432 ---- 'S_ADMIN' => MUSIC_ADMIN, + 'CAT_PARENT' => $cat_parent, + 'CAT_TYPE' => $cat_type, + 'L_PANEL_TITLE' => $lang['Create_category']) ); *************** *** 374,377 **** --- 439,460 ---- { // Get posting variables + + if ( !isset($HTTP_POST_VARS['cat_parent']) ) + { + $cat_parent = 0; + } + else + { + $cat_parent = intval($HTTP_POST_VARS['cat_parent']); + } + if ( !isset($HTTP_POST_VARS['cat_type']) ) + { + $cat_type = 0; + } + else + { + $cat_type = 1; + } + $cat_title = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['cat_title']))); $cat_desc = str_replace("\'", "''", trim($HTTP_POST_VARS['cat_desc'])); *************** *** 397,402 **** // Here we insert a new row into the db ! $sql = "INSERT INTO ". MUSIC_CAT_TABLE ." (cat_title, cat_desc, cat_order, cat_view_level, cat_upload_level, cat_rate_level, cat_comment_level, cat_edit_level, cat_delete_level, cat_approval) ! VALUES ('$cat_title', '$cat_desc', '$cat_order', '$view_level', '$upload_level', '$rate_level', '$comment_level', '$edit_level', '$delete_level', '$cat_approval')"; if(!$result = $db->sql_query($sql)) { --- 480,485 ---- // Here we insert a new row into the db ! $sql = "INSERT INTO ". MUSIC_CAT_TABLE ." (cat_title, cat_desc, cat_order, cat_view_level, cat_upload_level, cat_rate_level, cat_comment_level, cat_edit_level, cat_delete_level, cat_approval, cat_parent, cat_type) ! VALUES ('$cat_title', '$cat_desc', '$cat_order', '$view_level', '$upload_level', '$rate_level', '$comment_level', '$edit_level', '$delete_level', '$cat_approval', $cat_parent, $cat_type)"; if(!$result = $db->sql_query($sql)) { |