/Quản lý website trường trung học phổ thông PHP/lc1/admin/modules/authors/functions.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien · PHP · 195 lines · 160 code · 16 blank · 19 comment · 11 complexity · b6fc52242453f26407227cddd637ce4e MD5 · raw file

  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 1-27-2010 5:25
  7. */
  8. if ( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) or ! defined( 'NV_IS_MODADMIN' ) ) die( 'Stop!!!' );
  9. $allow_func = array(
  10. 'main', 'edit'
  11. );
  12. global $global_config;
  13. if ( defined( "NV_IS_GODADMIN" ) or ( defined( "NV_IS_SPADMIN" ) and $global_config['spadmin_add_admin'] == 1 ) )
  14. {
  15. $submenu['add'] = $lang_module['menuadd'];
  16. $allow_func[] = "add";
  17. $allow_func[] = "suspend";
  18. }
  19. if ( defined( "NV_IS_GODADMIN" ) )
  20. {
  21. $submenu['config'] = $lang_module['config'];
  22. $allow_func[] = "del";
  23. $allow_func[] = "config";
  24. }
  25. if ( $module_name == "authors" )
  26. {
  27. unset( $page_title, $select_options );
  28. $menu_top = array(
  29. "title" => $module_name, "module_file" => "", "custom_title" => $lang_global['mod_authors']
  30. );
  31. define( 'NV_IS_FILE_AUTHORS', true );
  32. /**
  33. * nv_admin_add_result()
  34. *
  35. * @param mixed $result
  36. * @return
  37. */
  38. function nv_admin_add_result ( $result )
  39. {
  40. global $module_name, $lang_global, $lang_module, $page_title, $global_config;
  41. if ( ! defined( 'NV_IS_GODADMIN' ) )
  42. {
  43. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  44. die();
  45. }
  46. //parse content
  47. $xtpl = new XTemplate( "add.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/authors" );
  48. $lev = ( $result['lev'] == 2 ) ? $lang_module['level2'] : $lang_module['level3'];
  49. $contents = array();
  50. $contents['admin_id'] = $result['admin_id'];
  51. $contents['title'] = $lang_module['nv_admin_add_title'];
  52. $contents['info'] = array();
  53. $contents['info']['lev'] = array(
  54. $lang_module['lev'], $lev
  55. );
  56. $contents['info']['modules'] = array(
  57. $lang_module['nv_admin_modules'], $result['modules']
  58. );
  59. $contents['info']['position'] = array(
  60. $lang_module['position'], $result['position']
  61. );
  62. $contents['info']['editor'] = array(
  63. $lang_module['editor'], ( ! empty( $result['editor'] ) ? $result['editor'] : $lang_module['not_use'] )
  64. );
  65. $contents['info']['allow_files_type'] = array(
  66. $lang_module['allow_files_type'], ( ! empty( $result['allow_files_type'] ) ? implode( ", ", $result['allow_files_type'] ) : $lang_global['no'] )
  67. );
  68. $contents['info']['allow_modify_files'] = array(
  69. $lang_module['allow_modify_files'], ( $result['allow_modify_files'] ? $lang_global['yes'] : $lang_global['no'] )
  70. );
  71. $contents['info']['allow_create_subdirectories'] = array(
  72. $lang_module['allow_create_subdirectories'], ( $result['allow_create_subdirectories'] ? $lang_global['yes'] : $lang_global['no'] )
  73. );
  74. $contents['info']['allow_modify_subdirectories'] = array(
  75. $lang_module['allow_modify_subdirectories'], ( $result['allow_modify_subdirectories'] ? $lang_global['yes'] : $lang_global['no'] )
  76. );
  77. $contents['action'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=add";
  78. $contents['go_edit'] = array(
  79. $lang_global['edit'], NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=edit&amp;admin_id=" . $result['admin_id']
  80. );
  81. $contents['go_home'] = array(
  82. $lang_module['main'], NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name
  83. );
  84. $xtpl->assign( 'TITLE', $contents['title'] );
  85. $a = 0;
  86. foreach ( $contents['info'] as $key => $value )
  87. {
  88. if ( ! empty( $value[1] ) )
  89. {
  90. $xtpl->assign( 'CLASS', ( $a % 2 ) ? " class=\"second\"" : "" );
  91. $xtpl->assign( 'VALUE0', $value[0] );
  92. $xtpl->assign( 'VALUE1', $value[1] );
  93. $xtpl->parse( 'add_result.loop' );
  94. $a ++;
  95. }
  96. }
  97. $xtpl->assign( 'ACTION', $contents['action'] );
  98. $xtpl->assign( 'ADM_ID', $contents['admin_id'] );
  99. $xtpl->assign( 'EDIT_HREF', $contents['go_edit'][1] );
  100. $xtpl->assign( 'EDIT', $contents['go_edit'][0] );
  101. $xtpl->assign( 'HOME_HREF', $contents['go_home'][1] );
  102. $xtpl->assign( 'HOME', $contents['go_home'][0] );
  103. $page_title = $lang_module['nv_admin_add_result'];
  104. include ( NV_ROOTDIR . "/includes/header.php" );
  105. $xtpl->parse( 'add_result' );
  106. $contents = $xtpl->text( 'add_result' );
  107. echo nv_admin_theme( $contents );
  108. include ( NV_ROOTDIR . "/includes/footer.php" );
  109. }
  110. /**
  111. * nv_admin_edit_result()
  112. *
  113. * @param mixed $result
  114. * @return
  115. */
  116. function nv_admin_edit_result ( $result )
  117. {
  118. global $lang_module, $lang_global, $page_title, $module_name, $global_config;
  119. $xtpl = new XTemplate( "edit.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/authors" );
  120. $contents = array();
  121. $contents['title'] = sprintf( $lang_module['nv_admin_edit_result_title'], $result['login'] );
  122. $contents['thead'] = array(
  123. $lang_module['field'], $lang_module['old_value'], $lang_module['new_value']
  124. );
  125. $contents['change'] = $result['change'];
  126. $contents['action'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=edit&amp;admin_id=" . $result['admin_id'];
  127. $contents['download'] = $lang_module['nv_admin_add_download'];
  128. $contents['sendmail'] = $lang_module['nv_admin_add_sendmail'];
  129. $contents['go_home'] = array(
  130. $lang_module['main'], NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name
  131. );
  132. $contents['go_edit'] = array(
  133. $lang_global['edit'], NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=edit&amp;admin_id=" . $result['admin_id']
  134. );
  135. $page_title = sprintf( $lang_module['nv_admin_edit_result'], $result['login'] );
  136. $xtpl->assign( 'TITLE', $contents['title'] );
  137. $xtpl->assign( 'THEAD0', $contents['thead'][0] );
  138. $xtpl->assign( 'THEAD1', $contents['thead'][1] );
  139. $xtpl->assign( 'THEAD2', $contents['thead'][2] );
  140. $a = 0;
  141. foreach ( $contents['change'] as $key => $value )
  142. {
  143. $xtpl->assign( 'CLASS', ( $a % 2 ) ? " class=\"second\"" : "" );
  144. $xtpl->assign( 'VALUE0', $value[0] );
  145. $xtpl->assign( 'VALUE1', $value[1] );
  146. $xtpl->assign( 'VALUE2', $value[2] );
  147. $xtpl->parse( 'edit_resuilt.loop' );
  148. $a ++;
  149. }
  150. $xtpl->assign( 'ACTION', $contents['action'] );
  151. foreach ( $contents['change'] as $key => $values )
  152. {
  153. $xtpl->assign( 'KEY', $key );
  154. if ( $key != "password" )
  155. {
  156. $xtpl->assign( 'VALUE1', $values[1] );
  157. $xtpl->parse( 'edit_resuilt.loop1.if' );
  158. }
  159. else
  160. {
  161. $xtpl->assign( 'VALUE2', $values[2] );
  162. $xtpl->parse( 'edit_resuilt.loop1.else' );
  163. }
  164. $xtpl->parse( 'edit_resuilt.loop1' );
  165. }
  166. $xtpl->assign( 'DOWNLOAD', $contents['download'] );
  167. $xtpl->assign( 'SENDMAIL', $contents['sendmail'] );
  168. $xtpl->assign( 'EDIT_NAME', $contents['go_edit'][0] );
  169. $xtpl->assign( 'EDIT_HREF', $contents['go_edit'][1] );
  170. $xtpl->assign( 'HOME_NAME', $contents['go_home'][0] );
  171. $xtpl->assign( 'HOME_HREF', $contents['go_home'][1] );
  172. include ( NV_ROOTDIR . "/includes/header.php" );
  173. $xtpl->parse( 'edit_resuilt' );
  174. $contents = $xtpl->text( 'edit_resuilt' );
  175. echo nv_admin_theme( $contents );
  176. include ( NV_ROOTDIR . "/includes/footer.php" );
  177. }
  178. }
  179. ?>