Просмотр файла admin/admin_album_cat.php

Размер файла: 18.59Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. define('IN_PHPBB', true);
  7.  
  8. if( !empty($setmodules) )
  9. {
  10. $filename = basename(__FILE__);
  11. $module['Photo_Album']['Categories'] = $filename;
  12. return;
  13. }
  14.  
  15. $phpbb_root_path = '../';
  16. require($phpbb_root_path . 'extension.inc');
  17. require('./pagestart.' . $phpEx);
  18. require($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main_album.' . $phpEx);
  19. require($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin_album.' . $phpEx);
  20.  
  21. function reorder_cat()
  22. {
  23. global $db;
  24.  
  25. $sql = "SELECT cat_id, cat_order
  26. FROM ". ALBUM_CAT_TABLE ."
  27. WHERE cat_id <> 0
  28. ORDER BY cat_order ASC";
  29. if( !$result = $db->sql_query($sql) )
  30. {
  31. message_die(GENERAL_ERROR, 'Could not get list of Categories', '', __LINE__, __FILE__, $sql);
  32. }
  33.  
  34. $i = 10;
  35.  
  36. while( $row = $db->sql_fetchrow($result) )
  37. {
  38. $sql = "UPDATE ". ALBUM_CAT_TABLE ."
  39. SET cat_order = $i
  40. WHERE cat_id = ". $row['cat_id'];
  41. if( !$db->sql_query($sql) )
  42. {
  43. message_die(GENERAL_ERROR, 'Could not update order fields', '', __LINE__, __FILE__, $sql);
  44. }
  45. $i += 10;
  46. }
  47. }
  48.  
  49. if( !isset($HTTP_POST_VARS['mode']) )
  50. {
  51. if( !isset($HTTP_GET_VARS['action']) )
  52. {
  53. $template->set_filenames(array(
  54. 'body' => 'admin/album_cat_body.tpl')
  55. );
  56.  
  57. $template->assign_vars(array(
  58. 'L_ALBUM_CAT_TITLE' => $lang['Album_Categories_Title'],
  59. 'L_ALBUM_CAT_EXPLAIN' => $lang['Album_Categories_Explain'],
  60. 'S_ALBUM_ACTION' => append_sid("admin_album_cat.$phpEx"),
  61. 'L_MOVE_UP' => $lang['Move_up'],
  62. 'L_MOVE_DOWN' => $lang['Move_down'],
  63. 'L_EDIT' => $lang['Edit'],
  64. 'L_DELETE' => $lang['Delete'],
  65. 'S_MODE' => 'new',
  66. 'L_CREATE_CATEGORY' => $lang['Create_category'])
  67. );
  68.  
  69. $sql = "SELECT *
  70. FROM ". ALBUM_CAT_TABLE ."
  71. ORDER BY cat_order ASC";
  72. if(!$result = $db->sql_query($sql))
  73. {
  74. message_die(GENERAL_ERROR, 'Could not query Album Categories information', '', __LINE__, __FILE__, $sql);
  75. }
  76. while ($row = $db->sql_fetchrow($result))
  77. {
  78. $catrow[] = $row;
  79. }
  80.  
  81. for( $i = 0; $i < count($catrow); $i++ )
  82. {
  83. $template->assign_block_vars('catrow', array(
  84. 'COLOR' => ($i % 2) ? 'row_hard' : 'row_easy',
  85. 'TITLE' => $catrow[$i]['cat_title'],
  86. 'DESC' => $catrow[$i]['cat_desc'],
  87. 'S_MOVE_UP' => append_sid("admin_album_cat.$phpEx?action=move&amp;move=-15&amp;cat_id=" . $catrow[$i]['cat_id']),
  88. 'S_MOVE_DOWN' => append_sid("admin_album_cat.$phpEx?action=move&amp;move=15&amp;cat_id=" . $catrow[$i]['cat_id']),
  89. 'S_EDIT_ACTION' => append_sid("admin_album_cat.$phpEx?action=edit&amp;cat_id=" . $catrow[$i]['cat_id']),
  90. 'S_DELETE_ACTION' => append_sid("admin_album_cat.$phpEx?action=delete&amp;cat_id=" . $catrow[$i]['cat_id'])
  91. )
  92. );
  93. }
  94.  
  95. $template->pparse('body');
  96.  
  97. include('./page_footer_admin.'.$phpEx);
  98. }
  99. else
  100. {
  101. if( $HTTP_GET_VARS['action'] == 'edit' )
  102. {
  103. $cat_id = intval($HTTP_GET_VARS['cat_id']);
  104.  
  105. $sql = "SELECT *
  106. FROM ". ALBUM_CAT_TABLE ."
  107. WHERE cat_id = '$cat_id'";
  108. if(!$result = $db->sql_query($sql))
  109. {
  110. message_die(GENERAL_ERROR, 'Could not query Album Categories information', '', __LINE__, __FILE__, $sql);
  111. }
  112. if( $db->sql_numrows($result) == 0 )
  113. {
  114. message_die(GENERAL_ERROR, 'The requested category is not existed');
  115. }
  116. $catrow = $db->sql_fetchrow($result);
  117.  
  118. $template->set_filenames(array(
  119. 'body' => 'admin/album_cat_new_body.tpl')
  120. );
  121.  
  122. $template->assign_vars(array(
  123. 'L_ALBUM_CAT_TITLE' => $lang['Album_Categories_Title'],
  124. 'L_ALBUM_CAT_EXPLAIN' => $lang['Album_Categories_Explain'],
  125. 'S_ALBUM_ACTION' => append_sid("admin_album_cat.$phpEx?cat_id=$cat_id"),
  126. 'L_CAT_TITLE' => $lang['Category_Title'],
  127. 'L_CAT_DESC' => $lang['Category_Desc'],
  128. 'L_CAT_PERMISSIONS' => $lang['Category_Permissions'],
  129. 'L_VIEW_LEVEL' => $lang['View_level'],
  130. 'L_UPLOAD_LEVEL' => $lang['Upload_level'],
  131. 'L_RATE_LEVEL' => $lang['Rate_level'],
  132. 'L_COMMENT_LEVEL' => $lang['Comment_level'],
  133. 'L_EDIT_LEVEL' => $lang['Edit_level'],
  134. 'L_DELETE_LEVEL' => $lang['Delete_level'],
  135. 'L_PICS_APPROVAL' => $lang['Pics_Approval'],
  136. 'L_GUEST' => $lang['Forum_ALL'],
  137. 'L_REG' => $lang['Forum_REG'],
  138. 'L_PRIVATE' => $lang['Forum_PRIVATE'],
  139. 'L_MOD' => $lang['Forum_MOD'],
  140. 'L_ADMIN' => $lang['Forum_ADMIN'],
  141.  
  142. 'L_DISABLED' => $lang['Disabled'],
  143.  
  144. 'S_CAT_TITLE' => $catrow['cat_title'],
  145. 'S_CAT_DESC' => $catrow['cat_desc'],
  146.  
  147. 'VIEW_GUEST' => ($catrow['cat_view_level'] == ALBUM_GUEST) ? 'selected="selected"' : '',
  148. 'VIEW_REG' => ($catrow['cat_view_level'] == ALBUM_USER) ? 'selected="selected"' : '',
  149. 'VIEW_PRIVATE' => ($catrow['cat_view_level'] == ALBUM_PRIVATE) ? 'selected="selected"' : '',
  150. 'VIEW_MOD' => ($catrow['cat_view_level'] == ALBUM_MOD) ? 'selected="selected"' : '',
  151. 'VIEW_ADMIN' => ($catrow['cat_view_level'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  152.  
  153. 'UPLOAD_GUEST' => ($catrow['cat_upload_level'] == ALBUM_GUEST) ? 'selected="selected"' : '',
  154. 'UPLOAD_REG' => ($catrow['cat_upload_level'] == ALBUM_USER) ? 'selected="selected"' : '',
  155. 'UPLOAD_PRIVATE' => ($catrow['cat_upload_level'] == ALBUM_PRIVATE) ? 'selected="selected"' : '',
  156. 'UPLOAD_MOD' => ($catrow['cat_upload_level'] == ALBUM_MOD) ? 'selected="selected"' : '',
  157. 'UPLOAD_ADMIN' => ($catrow['cat_upload_level'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  158.  
  159. 'RATE_GUEST' => ($catrow['cat_rate_level'] == ALBUM_GUEST) ? 'selected="selected"' : '',
  160. 'RATE_REG' => ($catrow['cat_rate_level'] == ALBUM_USER) ? 'selected="selected"' : '',
  161. 'RATE_PRIVATE' => ($catrow['cat_rate_level'] == ALBUM_PRIVATE) ? 'selected="selected"' : '',
  162. 'RATE_MOD' => ($catrow['cat_rate_level'] == ALBUM_MOD) ? 'selected="selected"' : '',
  163. 'RATE_ADMIN' => ($catrow['cat_rate_level'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  164.  
  165. 'COMMENT_GUEST' => ($catrow['cat_comment_level'] == ALBUM_GUEST) ? 'selected="selected"' : '',
  166. 'COMMENT_REG' => ($catrow['cat_comment_level'] == ALBUM_USER) ? 'selected="selected"' : '',
  167. 'COMMENT_PRIVATE' => ($catrow['cat_comment_level'] == ALBUM_PRIVATE) ? 'selected="selected"' : '',
  168. 'COMMENT_MOD' => ($catrow['cat_comment_level'] == ALBUM_MOD) ? 'selected="selected"' : '',
  169. 'COMMENT_ADMIN' => ($catrow['cat_comment_level'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  170.  
  171. 'EDIT_REG' => ($catrow['cat_edit_level'] == ALBUM_USER) ? 'selected="selected"' : '',
  172. 'EDIT_PRIVATE' => ($catrow['cat_edit_level'] == ALBUM_PRIVATE) ? 'selected="selected"' : '',
  173. 'EDIT_MOD' => ($catrow['cat_edit_level'] == ALBUM_MOD) ? 'selected="selected"' : '',
  174. 'EDIT_ADMIN' => ($catrow['cat_edit_level'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  175.  
  176. 'DELETE_REG' => ($catrow['cat_delete_level'] == ALBUM_USER) ? 'selected="selected"' : '',
  177. 'DELETE_PRIVATE' => ($catrow['cat_delete_level'] == ALBUM_PRIVATE) ? 'selected="selected"' : '',
  178. 'DELETE_MOD' => ($catrow['cat_delete_level'] == ALBUM_MOD) ? 'selected="selected"' : '',
  179. 'DELETE_ADMIN' => ($catrow['cat_delete_level'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  180.  
  181. 'APPROVAL_DISABLED' => ($catrow['cat_approval'] == ALBUM_USER) ? 'selected="selected"' : '',
  182. 'APPROVAL_MOD' => ($catrow['cat_approval'] == ALBUM_MOD) ? 'selected="selected"' : '',
  183. 'APPROVAL_ADMIN' => ($catrow['cat_approval'] == ALBUM_ADMIN) ? 'selected="selected"' : '',
  184.  
  185. 'S_MODE' => 'edit',
  186.  
  187. 'S_GUEST' => ALBUM_GUEST,
  188. 'S_USER' => ALBUM_USER,
  189. 'S_PRIVATE' => ALBUM_PRIVATE,
  190. 'S_MOD' => ALBUM_MOD,
  191. 'S_ADMIN' => ALBUM_ADMIN,
  192.  
  193. 'L_PANEL_TITLE' => $lang['Edit_Category'])
  194. );
  195.  
  196. $template->pparse('body');
  197.  
  198. include('./page_footer_admin.'.$phpEx);
  199. }
  200. else if( $HTTP_GET_VARS['action'] == 'delete' )
  201. {
  202. $cat_id = intval($HTTP_GET_VARS['cat_id']);
  203.  
  204. $sql = "SELECT cat_id, cat_title, cat_order
  205. FROM ". ALBUM_CAT_TABLE ."
  206. ORDER BY cat_order ASC";
  207. if(!$result = $db->sql_query($sql))
  208. {
  209. message_die(GENERAL_ERROR, 'Could not query Album Categories information', '', __LINE__, __FILE__, $sql);
  210. }
  211.  
  212. $cat_found = FALSE;
  213. while( $row = $db->sql_fetchrow($result) )
  214. {
  215. if( $row['cat_id'] == $cat_id )
  216. {
  217. $thiscat = $row;
  218. $cat_found = TRUE;
  219. }
  220. else
  221. {
  222. $catrow[] = $row;
  223. }
  224. }
  225. if( $cat_found == FALSE )
  226. {
  227. message_die(GENERAL_ERROR, 'The requested category is not existed');
  228. }
  229.  
  230. $select_to = '<select name="target"><option value="0">'. $lang['Delete_all_pics'] .'</option>';
  231. for ($i = 0; $i < count($catrow); $i++)
  232. {
  233. $select_to .= '<option value="'. $catrow[$i]['cat_id'] .'">'. $catrow[$i]['cat_title'] .'</option>';
  234. }
  235. $select_to .= '</select>';
  236.  
  237. $template->set_filenames(array(
  238. 'body' => 'admin/album_cat_delete_body.tpl')
  239. );
  240.  
  241. $template->assign_vars(array(
  242. 'S_ALBUM_ACTION' => append_sid("admin_album_cat.$phpEx?cat_id=$cat_id"),
  243. 'L_CAT_DELETE' => $lang['Delete_Category'],
  244. 'L_CAT_DELETE_EXPLAIN' => $lang['Delete_Category_Explain'],
  245. 'L_CAT_TITLE' => $lang['Category_Title'],
  246. 'S_CAT_TITLE' => $thiscat['cat_title'],
  247. 'L_MOVE_CONTENTS' => $lang['Move_contents'],
  248. 'L_MOVE_DELETE' => $lang['Move_and_Delete'],
  249. 'S_SELECT_TO' => $select_to)
  250. );
  251.  
  252. $template->pparse('body');
  253.  
  254. include('./page_footer_admin.'.$phpEx);
  255. }
  256. else if( $HTTP_GET_VARS['action'] == 'move' )
  257. {
  258. $cat_id = intval($HTTP_GET_VARS['cat_id']);
  259. $move = intval($HTTP_GET_VARS['move']);
  260.  
  261. $sql = "UPDATE ". ALBUM_CAT_TABLE ."
  262. SET cat_order = cat_order + $move
  263. WHERE cat_id = $cat_id";
  264. if( !$result = $db->sql_query($sql) )
  265. {
  266. message_die(GENERAL_ERROR, 'Could not change category order', '', __LINE__, __FILE__, $sql);
  267. }
  268.  
  269. reorder_cat();
  270.  
  271. $message = $lang['Category_changed_order'] . "<br /><br />" . sprintf($lang['Click_return_album_category'], "<a href=\"" . append_sid("admin_album_cat.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
  272.  
  273. message_die(GENERAL_MESSAGE, $message);
  274. }
  275. }
  276. }
  277. else
  278. {
  279. if( $HTTP_POST_VARS['mode'] == 'new' )
  280. {
  281. if( !isset($HTTP_POST_VARS['cat_title']) )
  282. {
  283. $template->set_filenames(array(
  284. 'body' => 'admin/album_cat_new_body.tpl')
  285. );
  286.  
  287. $template->assign_vars(array(
  288. 'L_ALBUM_CAT_TITLE' => $lang['Album_Categories_Title'],
  289. 'L_ALBUM_CAT_EXPLAIN' => $lang['Album_Categories_Explain'],
  290. 'S_ALBUM_ACTION' => append_sid("admin_album_cat.$phpEx"),
  291. 'L_CAT_TITLE' => $lang['Category_Title'],
  292. 'L_CAT_DESC' => $lang['Category_Desc'],
  293. 'L_CAT_PERMISSIONS' => $lang['Category_Permissions'],
  294. 'L_VIEW_LEVEL' => $lang['View_level'],
  295. 'L_UPLOAD_LEVEL' => $lang['Upload_level'],
  296. 'L_RATE_LEVEL' => $lang['Rate_level'],
  297. 'L_COMMENT_LEVEL' => $lang['Comment_level'],
  298. 'L_EDIT_LEVEL' => $lang['Edit_level'],
  299. 'L_DELETE_LEVEL' => $lang['Delete_level'],
  300. 'L_PICS_APPROVAL' => $lang['Pics_Approval'],
  301. 'L_GUEST' => $lang['Forum_ALL'],
  302. 'L_REG' => $lang['Forum_REG'],
  303. 'L_PRIVATE' => $lang['Forum_PRIVATE'],
  304. 'L_MOD' => $lang['Forum_MOD'],
  305. 'L_ADMIN' => $lang['Forum_ADMIN'],
  306.  
  307. 'L_DISABLED' => $lang['Disabled'],
  308.  
  309. 'VIEW_GUEST' => 'selected="selected"',
  310. 'UPLOAD_REG' => 'selected="selected"',
  311. 'RATE_REG' => 'selected="selected"',
  312. 'COMMENT_REG' => 'selected="selected"',
  313. 'EDIT_REG' => 'selected="selected"',
  314. 'DELETE_MOD' => 'selected="selected"',
  315. 'APPROVAL_DISABLED' => 'selected="selected"',
  316.  
  317. 'S_MODE' => 'new',
  318.  
  319. 'S_GUEST' => ALBUM_GUEST,
  320. 'S_USER' => ALBUM_USER,
  321. 'S_PRIVATE' => ALBUM_PRIVATE,
  322. 'S_MOD' => ALBUM_MOD,
  323. 'S_ADMIN' => ALBUM_ADMIN,
  324.  
  325. 'L_PANEL_TITLE' => $lang['Create_category'])
  326. );
  327.  
  328. $template->pparse('body');
  329.  
  330. include('./page_footer_admin.'.$phpEx);
  331. }
  332. else
  333. {
  334. $cat_title = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['cat_title'])));
  335. $cat_desc = str_replace("\'", "''", trim($HTTP_POST_VARS['cat_desc']));
  336. $view_level = intval($HTTP_POST_VARS['cat_view_level']);
  337. $upload_level = intval($HTTP_POST_VARS['cat_upload_level']);
  338. $rate_level = intval($HTTP_POST_VARS['cat_rate_level']);
  339. $comment_level = intval($HTTP_POST_VARS['cat_comment_level']);
  340. $edit_level = intval($HTTP_POST_VARS['cat_edit_level']);
  341. $delete_level = intval($HTTP_POST_VARS['cat_delete_level']);
  342. $cat_approval = intval($HTTP_POST_VARS['cat_approval']);
  343.  
  344. $sql = "SELECT cat_order FROM ". ALBUM_CAT_TABLE ."
  345. ORDER BY cat_order DESC
  346. LIMIT 1";
  347. if(!$result = $db->sql_query($sql))
  348. {
  349. message_die(GENERAL_ERROR, 'Could not query Album Categories information', '', __LINE__, __FILE__, $sql);
  350. }
  351. $row = $db->sql_fetchrow($result);
  352. $last_order = $row['cat_order'];
  353. $cat_order = $last_order + 10;
  354.  
  355. $sql = "INSERT INTO ". ALBUM_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)
  356. VALUES ('$cat_title', '$cat_desc', '$cat_order', '$view_level', '$upload_level', '$rate_level', '$comment_level', '$edit_level', '$delete_level', '$cat_approval')";
  357. if(!$result = $db->sql_query($sql))
  358. {
  359. message_die(GENERAL_ERROR, 'Could not create new Album Category', '', __LINE__, __FILE__, $sql);
  360. }
  361.  
  362. $message = $lang['New_category_created'] . "<br /><br />" . sprintf($lang['Click_return_album_category'], "<a href=\"" . append_sid("admin_album_cat.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
  363.  
  364. message_die(GENERAL_MESSAGE, $message);
  365. }
  366. }
  367. else if( $HTTP_POST_VARS['mode'] == 'edit' )
  368. {
  369. $cat_id = intval($HTTP_GET_VARS['cat_id']);
  370. $cat_title = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['cat_title'])));
  371. $cat_desc = str_replace("\'", "''", trim($HTTP_POST_VARS['cat_desc']));
  372. $view_level = intval($HTTP_POST_VARS['cat_view_level']);
  373. $upload_level = intval($HTTP_POST_VARS['cat_upload_level']);
  374. $rate_level = intval($HTTP_POST_VARS['cat_rate_level']);
  375. $comment_level = intval($HTTP_POST_VARS['cat_comment_level']);
  376. $edit_level = intval($HTTP_POST_VARS['cat_edit_level']);
  377. $delete_level = intval($HTTP_POST_VARS['cat_delete_level']);
  378. $cat_approval = intval($HTTP_POST_VARS['cat_approval']);
  379.  
  380. $sql = "UPDATE ". ALBUM_CAT_TABLE ."
  381. SET cat_title = '$cat_title', cat_desc = '$cat_desc', cat_view_level = '$view_level', cat_upload_level = '$upload_level', cat_rate_level = '$rate_level', cat_comment_level = '$comment_level', cat_edit_level = '$edit_level', cat_delete_level = '$delete_level', cat_approval = '$cat_approval'
  382. WHERE cat_id = '$cat_id'";
  383. if(!$result = $db->sql_query($sql))
  384. {
  385. message_die(GENERAL_ERROR, 'Could not update this Album Category', '', __LINE__, __FILE__, $sql);
  386. }
  387.  
  388. $message = $lang['Category_updated'] . "<br /><br />" . sprintf($lang['Click_return_album_category'], "<a href=\"" . append_sid("admin_album_cat.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
  389.  
  390. message_die(GENERAL_MESSAGE, $message);
  391. }
  392. else if( $HTTP_POST_VARS['mode'] == 'delete' )
  393. {
  394. $cat_id = intval($HTTP_GET_VARS['cat_id']);
  395. $target = intval($HTTP_POST_VARS['target']);
  396.  
  397. if( $target == 0 ) // Delete All
  398. {
  399. $sql = "SELECT pic_id, pic_filename, pic_thumbnail, pic_cat_id
  400. FROM ". ALBUM_TABLE ."
  401. WHERE pic_cat_id = '$cat_id'";
  402. if(!$result = $db->sql_query($sql))
  403. {
  404. message_die(GENERAL_ERROR, 'Could not query Album information', '', __LINE__, __FILE__, $sql);
  405. }
  406. $picrow = array();
  407. while( $row = $db ->sql_fetchrow($result) )
  408. {
  409. $picrow[] = $row;
  410. $pic_id_row[] = $row['pic_id'];
  411. }
  412.  
  413. if( count($picrow) != 0 ) // if this category is not empty
  414. {
  415. for ($i = 0; $i < count($picrow); $i++)
  416. {
  417. @unlink('../' . ALBUM_CACHE_PATH . $picrow[$i]['pic_thumbnail']);
  418.  
  419. @unlink('../' . ALBUM_UPLOAD_PATH . $picrow[$i]['pic_filename']);
  420. }
  421.  
  422. $pic_id_sql = '(' . implode(',', $pic_id_row) . ')';
  423.  
  424. $sql = "DELETE FROM ". ALBUM_RATE_TABLE ."
  425. WHERE rate_pic_id IN ". $pic_id_sql;
  426. if(!$result = $db->sql_query($sql))
  427. {
  428. message_die(GENERAL_ERROR, 'Could not delete Ratings information', '', __LINE__, __FILE__, $sql);
  429. }
  430.  
  431. $sql = "DELETE FROM ". ALBUM_COMMENT_TABLE ."
  432. WHERE comment_pic_id IN ". $pic_id_sql;
  433. if(!$result = $db->sql_query($sql))
  434. {
  435. message_die(GENERAL_ERROR, 'Could not delete Comments information', '', __LINE__, __FILE__, $sql);
  436. }
  437.  
  438. $sql = "DELETE FROM ". ALBUM_TABLE ."
  439. WHERE pic_cat_id = '$cat_id'";
  440. if(!$result = $db->sql_query($sql))
  441. {
  442. message_die(GENERAL_ERROR, 'Could not delete pic entries in the DB', '', __LINE__, __FILE__, $sql);
  443. }
  444. }
  445.  
  446. $sql = "DELETE FROM ". ALBUM_CAT_TABLE ."
  447. WHERE cat_id = '$cat_id'";
  448. if(!$result = $db->sql_query($sql))
  449. {
  450. message_die(GENERAL_ERROR, 'Could not delete this Category', '', __LINE__, __FILE__, $sql);
  451. }
  452.  
  453. reorder_cat();
  454. $message = $lang['Category_deleted'] . "<br /><br />" . sprintf($lang['Click_return_album_category'], "<a href=\"" . append_sid("admin_album_cat.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
  455.  
  456. message_die(GENERAL_MESSAGE, $message);
  457. }
  458. else
  459. {
  460. $sql = "UPDATE ". ALBUM_TABLE ."
  461. SET pic_cat_id = '$target'
  462. WHERE pic_cat_id = '$cat_id'";
  463. if(!$result = $db->sql_query($sql))
  464. {
  465. message_die(GENERAL_ERROR, 'Could not update this Category content', '', __LINE__, __FILE__, $sql);
  466. }
  467.  
  468. $sql = "DELETE FROM ". ALBUM_CAT_TABLE ."
  469. WHERE cat_id = '$cat_id'";
  470. if(!$result = $db->sql_query($sql))
  471. {
  472. message_die(GENERAL_ERROR, 'Could not delete this Category', '', __LINE__, __FILE__, $sql);
  473. }
  474.  
  475. reorder_cat();
  476. $message = $lang['Category_deleted'] . "<br /><br />" . sprintf($lang['Click_return_album_category'], "<a href=\"" . append_sid("admin_album_cat.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
  477.  
  478. message_die(GENERAL_MESSAGE, $message);
  479. }
  480. }
  481. }
  482.  
  483. ?>