modules.ctrl.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. error_reporting(0);
  8. load()->model('module');
  9. $dos = array('list');
  10. if (!in_array($do, array('list', 'check_receive'))) {
  11. exit('Access Denied');
  12. }
  13. if ($do == 'check_receive') {
  14. $module_name = trim($_GPC['module_name']);
  15. $module_obj = WeUtility::createModuleReceiver($module_name);
  16. if (!empty($module_obj)) {
  17. $module_obj->uniacid = $_W['uniacid'];
  18. $module_obj->acid = $_W['acid'];
  19. $module_obj->message = array(
  20. 'event' => 'subscribe'
  21. );
  22. if(method_exists($module_obj, 'receive')) {
  23. $module_obj->receive();
  24. return iajax(0, '');
  25. }
  26. }
  27. return iajax(1, '');
  28. }
  29. if($do == 'list') {
  30. global $_W;
  31. if (!empty($_COOKIE['special_reply_type'])) {
  32. $enable_modules = array();
  33. $_W['account']['modules'] = uni_modules();
  34. foreach($_W['account']['modules'] as $m) {
  35. if(is_array($_W['account']['modules'][$m['name']]['handles']) && in_array($_COOKIE['special_reply_type'], $_W['account']['modules'][$m['name']]['handles'])) {
  36. $enable_modules[$m['name']] = $m;
  37. if (file_exists(IA_ROOT. "/addons/". $m['name']. "/icon-custom.jpg")) {
  38. $enable_modules[$m['name']]['icon'] = tomedia(IA_ROOT. "/addons/". $m['name']. "/icon-custom.jpg");
  39. } else {
  40. $enable_modules[$m['name']]['icon'] = tomedia(IA_ROOT. "/addons/". $m['name']. "/icon.jpg");
  41. }
  42. }
  43. }
  44. setcookie('special_reply_type', '', time()-3600);
  45. } else {
  46. $installedmodulelist = uni_modules();
  47. foreach ($installedmodulelist as $k => $value) {
  48. $installedmodulelist[$k]['official'] = empty($value['issystem']) && (strexists($value['author'], 'WeEngine Team') || strexists($value['author'], '微擎团队'));
  49. }
  50. foreach($installedmodulelist as $name => $module) {
  51. if($module['issystem']) {
  52. $path = '/framework/builtin/' . $module['name'];
  53. } else {
  54. $path = '../addons/' . $module['name'];
  55. }
  56. $cion = $path . '/icon-custom.jpg';
  57. if(!file_exists($cion)) {
  58. $cion = $path . '/icon.jpg';
  59. if(!file_exists($cion)) {
  60. $cion = './resource/images/nopic-small.jpg';
  61. }
  62. }
  63. $module['icon'] = $cion;
  64. if($module['enabled'] == 1) {
  65. $enable_modules[$name] = $module;
  66. } else {
  67. $unenable_modules[$name] = $module;
  68. }
  69. }
  70. }
  71. $pindex = max(1, intval($_GPC['page']));
  72. $psize = 21;
  73. $current_module_list = array_slice($enable_modules, ($pindex - 1) * $psize, $psize);
  74. $result = array(
  75. 'items' => $current_module_list,
  76. 'pager' => pagination(count($enable_modules), $pindex, $psize, '', array('before' => '2', 'after' => '3', 'ajaxcallback'=>'null')),
  77. );
  78. iajax(0, $result);
  79. }