PageRenderTime 107ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/adm/admin_pa_catauth.php

http://github.com/MightyGorgon/icy_phoenix
PHP | 200 lines | 141 code | 36 blank | 23 comment | 14 complexity | bdf3e58d3f65356b133cd2c048b8775c MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package Icy Phoenix
  5. * @version $Id$
  6. * @copyright (c) 2008 Icy Phoenix
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. *
  12. * @Extra credits for this file
  13. * Todd - (todd@phparena.net) - (http://www.phparena.net)
  14. *
  15. */
  16. define('IN_ICYPHOENIX', true);
  17. if(!empty($setmodules))
  18. {
  19. $filename = basename(__FILE__);
  20. $module['2000_Downloads']['160_Permissions'] = $filename;
  21. return;
  22. }
  23. if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './../');
  24. if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
  25. $no_page_header = true;
  26. require('pagestart.' . PHP_EXT);
  27. include(IP_ROOT_PATH . 'includes/pafiledb_common.' . PHP_EXT);
  28. $pafiledb->init();
  29. $cat_auth_fields = array('auth_view', 'auth_read', 'auth_view_file', 'auth_edit_file', 'auth_delete_file', 'auth_upload', 'auth_download', 'auth_rate', 'auth_email', 'auth_view_comment', 'auth_post_comment', 'auth_edit_comment', 'auth_delete_comment');
  30. $field_names = array(
  31. 'auth_view' => $lang['View'],
  32. 'auth_read' => $lang['Read'],
  33. 'auth_view_file' => $lang['View_file'],
  34. // MX Addon
  35. 'auth_edit_file' => $lang['Edit_file'],
  36. 'auth_delete_file' => $lang['Delete_file'],
  37. // End
  38. 'auth_upload' => $lang['Upload'],
  39. 'auth_download' => $lang['Download_file'],
  40. 'auth_rate' => $lang['Rate'],
  41. 'auth_email' => $lang['Email'],
  42. 'auth_view_comment' => $lang['View_comment'],
  43. 'auth_post_comment' => $lang['Post_comment'],
  44. 'auth_edit_comment' => $lang['Edit_comment'],
  45. 'auth_delete_comment' => $lang['Delete_comment']
  46. );
  47. $cat_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
  48. $cat_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
  49. $cat_parent = request_var('cat_parent', 0);
  50. $cat_id = request_var('cat_id', 0);
  51. if(!empty($cat_id))
  52. {
  53. $cat_sql = "AND cat_id = $cat_id";
  54. }
  55. else
  56. {
  57. unset($cat_id);
  58. $cat_sql = '';
  59. }
  60. // Start program proper
  61. if(isset($_POST['submit']))
  62. {
  63. $temp_sql = array();
  64. for($i = 0; $i < sizeof($cat_auth_fields); $i++)
  65. {
  66. foreach($_POST[$cat_auth_fields[$i]] as $temp_cat_id => $value)
  67. {
  68. $temp_sql[$temp_cat_id] .= (($temp_sql[$temp_cat_id] != '') ? ', ' : '') .$cat_auth_fields[$i] . ' = ' . $value;
  69. }
  70. }
  71. $sql = array();
  72. foreach($temp_sql as $temp_cat_id => $update_sql)
  73. {
  74. $sql[] = "UPDATE " . PA_CATEGORY_TABLE . "
  75. SET $update_sql WHERE cat_id = $temp_cat_id";
  76. }
  77. unset($temp_sql);
  78. if (is_array($sql) && (sizeof($sql) > 0))
  79. {
  80. foreach($sql as $do_sql)
  81. {
  82. $db->sql_query($do_sql);
  83. }
  84. }
  85. $message = $lang['Category_auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_catauth'], '<a href="' . append_sid("admin_pa_catauth." . PHP_EXT) . '">', "</a>");
  86. message_die(GENERAL_MESSAGE, $message);
  87. }
  88. // End of submit
  89. // Output the authorization details if an id was specified
  90. $template->set_filenames(array('body' => ADM_TPL . 'pa_auth_cat_body.tpl'));
  91. $permissions_menu = array(
  92. append_sid('admin_pa_catauth.' . PHP_EXT) => $lang['Cat_Permissions'],
  93. append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=user') => $lang['User_Permissions'],
  94. append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=group') => $lang['Group_Permissions'],
  95. append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=glob_user') => $lang['User_Global_Permissions'],
  96. append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=glob_group') => $lang['Group_Global_Permissions']
  97. );
  98. foreach($permissions_menu as $url => $l_name)
  99. {
  100. $template->assign_block_vars('pertype', array(
  101. 'U_NAME' => $url,
  102. 'L_NAME' => $l_name)
  103. );
  104. }
  105. //
  106. // Output values of individual
  107. // fields
  108. //
  109. for($j = 0; $j < sizeof($cat_auth_fields); $j++)
  110. {
  111. $cell_title = $field_names[$cat_auth_fields[$j]];
  112. $template->assign_block_vars('cat_auth_titles', array(
  113. 'CELL_TITLE' => $cell_title
  114. )
  115. );
  116. }
  117. if(empty($cat_id))
  118. {
  119. admin_display_cat_auth($cat_parent);
  120. $cat_name = '';
  121. }
  122. elseif(!empty($cat_id))
  123. {
  124. $template->assign_block_vars('cat_row', array(
  125. 'CATEGORY_NAME' => $pafiledb->cat_rowset[$cat_id]['cat_name'],
  126. 'IS_HIGHER_CAT' => ($pafiledb->cat_rowset[$cat_id]) ? false : true,
  127. 'U_CAT' => append_sid('admin_pa_catauth.' . PHP_EXT . "?cat_parent={$pafiledb->cat_rowset[$cat_id]['cat_parent']}")
  128. )
  129. );
  130. for($j = 0; $j < sizeof($cat_auth_fields); $j++)
  131. {
  132. $custom_auth[$j] = '&nbsp;<select name="' . $cat_auth_fields[$j] . '[' . $cat_id . ']' . '">';
  133. for($k = 0; $k < sizeof($cat_auth_levels); $k++)
  134. {
  135. $selected = ($pafiledb->cat_rowset[$cat_id][$cat_auth_fields[$j]] == $cat_auth_const[$k]) ? ' selected="selected"' : '';
  136. $custom_auth[$j] .= '<option value="' . $cat_auth_const[$k] . '"' . $selected . '>' . $lang['Category_' . $cat_auth_levels[$k]] . '</option>';
  137. }
  138. $custom_auth[$j] .= '</select>&nbsp;';
  139. $template->assign_block_vars('cat_row.cat_auth_data', array(
  140. 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j]
  141. )
  142. );
  143. }
  144. $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $cat_id . '" />';
  145. $cat_name = $pafiledb->cat_rowset[$cat_id]['cat_name'];
  146. }
  147. $s_column_span = sizeof($cat_auth_fields) + 2;
  148. $template->assign_vars(array(
  149. 'CATEGORY_NAME' => $cat_name,
  150. 'L_CATEGORY' => $lang['Category'],
  151. 'L_AUTH_TITLE' => $lang['Auth_Control_Category'],
  152. 'L_AUTH_EXPLAIN' => $lang['Category_auth_explain'],
  153. 'L_SUBMIT' => $lang['Submit'],
  154. 'L_RESET' => $lang['Reset'],
  155. 'S_CATAUTH_ACTION' => append_sid('admin_pa_catauth.' . PHP_EXT),
  156. 'S_COLUMN_SPAN' => $s_column_span,
  157. 'S_HIDDEN_FIELDS' => $s_hidden_fields
  158. )
  159. );
  160. include(IP_ROOT_PATH . ADM . '/page_header_admin.' . PHP_EXT);
  161. $template->display('body');
  162. $pafiledb->_pafiledb();
  163. include(IP_ROOT_PATH . ADM . '/page_footer_admin.' . PHP_EXT);
  164. ?>