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

Размер файла: 6.11Kb
  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']['Permissions'] = $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. if( !isset($HTTP_POST_VARS['submit']) )
  22. {
  23. $sql = "SELECT cat_id, cat_title, cat_order
  24. FROM ". ALBUM_CAT_TABLE ."
  25. ORDER BY cat_order ASC";
  26. if( !$result = $db->sql_query($sql) )
  27. {
  28. message_die(GENERAL_ERROR, 'Could not get Category list', '', __LINE__, __FILE__, $sql);
  29. }
  30.  
  31. while( $row = $db->sql_fetchrow($result) )
  32. {
  33. $catrows[] = $row;
  34. }
  35.  
  36. for ($i = 0; $i < count($catrows); $i++)
  37. {
  38. $template->assign_block_vars('catrow', array(
  39. 'CAT_ID' => $catrows[$i]['cat_id'],
  40. 'CAT_TITLE' => $catrows[$i]['cat_title'])
  41. );
  42. }
  43.  
  44. $template->set_filenames(array(
  45. 'body' => 'admin/album_cat_select_body.tpl')
  46. );
  47.  
  48. $template->assign_vars(array(
  49. 'L_ALBUM_AUTH_TITLE' => $lang['Album_Auth_Title'],
  50. 'L_ALBUM_AUTH_EXPLAIN' => $lang['Album_Auth_Explain'],
  51. 'L_SELECT_CAT' => $lang['Select_a_Category'],
  52. 'S_ALBUM_ACTION' => append_sid("admin_album_auth.$phpEx"),
  53. 'L_LOOK_UP_CAT' => $lang['Look_up_Category'])
  54. );
  55.  
  56. $template->pparse('body');
  57.  
  58. include('./page_footer_admin.'.$phpEx);
  59. }
  60. else
  61. {
  62. if( !isset($HTTP_GET_VARS['cat_id']) )
  63. {
  64. $cat_id = intval($HTTP_POST_VARS['cat_id']);
  65.  
  66. $template->set_filenames(array(
  67. 'body' => 'admin/album_auth_body.tpl')
  68. );
  69.  
  70. $template->assign_vars(array(
  71. 'L_ALBUM_AUTH_TITLE' => $lang['Album_Auth_Title'],
  72. 'L_ALBUM_AUTH_EXPLAIN' => $lang['Album_Auth_Explain'],
  73. 'L_SUBMIT' => $lang['Submit'],
  74. 'L_RESET' => $lang['Reset'],
  75.  
  76. 'L_GROUPS' => $lang['Usergroups'],
  77.  
  78. 'L_VIEW' => $lang['View'],
  79. 'L_UPLOAD' => $lang['Upload'],
  80. 'L_RATE' => $lang['Rate'],
  81. 'L_COMMENT' => $lang['Comment'],
  82. 'L_EDIT' => $lang['Edit'],
  83. 'L_DELETE' => $lang['Delete'],
  84.  
  85. 'L_IS_MODERATOR' => $lang['Is_Moderator'],
  86. 'S_ALBUM_ACTION' => append_sid("admin_album_auth.$phpEx?cat_id=$cat_id"),
  87. )
  88. );
  89.  
  90. $sql = "SELECT group_id, group_name
  91. FROM " . GROUPS_TABLE . "
  92. WHERE group_single_user <> " . TRUE ."
  93. ORDER BY group_name ASC";
  94. if ( !($result = $db->sql_query($sql)) )
  95. {
  96. message_die(GENERAL_ERROR, 'Could not get group list', '', __LINE__, __FILE__, $sql);
  97. }
  98.  
  99. while( $row = $db->sql_fetchrow($result) )
  100. {
  101. $groupdata[] = $row;
  102. }
  103.  
  104. $sql = "SELECT cat_id, cat_title, cat_view_groups, cat_upload_groups, cat_rate_groups, cat_comment_groups, cat_edit_groups, cat_delete_groups, cat_moderator_groups
  105. FROM ". ALBUM_CAT_TABLE ."
  106. WHERE cat_id = '$cat_id'";
  107. if( !$result = $db->sql_query($sql) )
  108. {
  109. message_die(GENERAL_ERROR, 'Could not get Category information', '', __LINE__, __FILE__, $sql);
  110. }
  111.  
  112. $thiscat = $db->sql_fetchrow($result);
  113.  
  114. $view_groups = @explode(',', $thiscat['cat_view_groups']);
  115. $upload_groups = @explode(',', $thiscat['cat_upload_groups']);
  116. $rate_groups = @explode(',', $thiscat['cat_rate_groups']);
  117. $comment_groups = @explode(',', $thiscat['cat_comment_groups']);
  118. $edit_groups = @explode(',', $thiscat['cat_edit_groups']);
  119. $delete_groups = @explode(',', $thiscat['cat_delete_groups']);
  120.  
  121. $moderator_groups = @explode(',', $thiscat['cat_moderator_groups']);
  122.  
  123. for ($i = 0; $i < count($groupdata); $i++)
  124. {
  125. $template->assign_block_vars('grouprow', array(
  126. 'GROUP_ID' => $groupdata[$i]['group_id'],
  127. 'GROUP_NAME' => $groupdata[$i]['group_name'],
  128.  
  129. 'VIEW_CHECKED' => (in_array($groupdata[$i]['group_id'], $view_groups)) ? 'checked="checked"' : '',
  130.  
  131. 'UPLOAD_CHECKED' => (in_array($groupdata[$i]['group_id'], $upload_groups)) ? 'checked="checked"' : '',
  132.  
  133. 'RATE_CHECKED' => (in_array($groupdata[$i]['group_id'], $rate_groups)) ? 'checked="checked"' : '',
  134.  
  135. 'COMMENT_CHECKED' => (in_array($groupdata[$i]['group_id'], $comment_groups)) ? 'checked="checked"' : '',
  136.  
  137. 'EDIT_CHECKED' => (in_array($groupdata[$i]['group_id'], $edit_groups)) ? 'checked="checked"' : '',
  138.  
  139. 'DELETE_CHECKED' => (in_array($groupdata[$i]['group_id'], $delete_groups)) ? 'checked="checked"' : '',
  140.  
  141. 'MODERATOR_CHECKED' => (in_array($groupdata[$i]['group_id'], $moderator_groups)) ? 'checked="checked"' : '')
  142. );
  143. }
  144.  
  145. $template->pparse('body');
  146.  
  147. include('./page_footer_admin.'.$phpEx);
  148. }
  149. else
  150. {
  151. $cat_id = intval($HTTP_GET_VARS['cat_id']);
  152.  
  153. $view_groups = @implode(',', $HTTP_POST_VARS['view']);
  154. $upload_groups = @implode(',', $HTTP_POST_VARS['upload']);
  155. $rate_groups = @implode(',', $HTTP_POST_VARS['rate']);
  156. $comment_groups = @implode(',', $HTTP_POST_VARS['comment']);
  157. $edit_groups = @implode(',', $HTTP_POST_VARS['edit']);
  158. $delete_groups = @implode(',', $HTTP_POST_VARS['delete']);
  159.  
  160. $moderator_groups = @implode(',', $HTTP_POST_VARS['moderator']);
  161.  
  162. $sql = "UPDATE ". ALBUM_CAT_TABLE ."
  163. SET cat_view_groups = '$view_groups', cat_upload_groups = '$upload_groups', cat_rate_groups = '$rate_groups', cat_comment_groups = '$comment_groups', cat_edit_groups = '$edit_groups', cat_delete_groups = '$delete_groups', cat_moderator_groups = '$moderator_groups'
  164. WHERE cat_id = '$cat_id'";
  165. if ( !$result = $db->sql_query($sql) )
  166. {
  167. message_die(GENERAL_ERROR, 'Could not update Album config table', '', __LINE__, __FILE__, $sql);
  168. }
  169.  
  170. $message = $lang['Album_Auth_successfully'] . '<br /><br />' . sprintf($lang['Click_return_album_auth'], '<a href="' . append_sid("admin_album_auth.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
  171.  
  172. message_die(GENERAL_MESSAGE, $message);
  173. }
  174. }
  175.  
  176. ?>