push.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_app_class('admin','admin',0);
  4. pc_base::load_sys_class('push_factory', '', 0);
  5. //权限判断,根据栏目里面的权限设置检查
  6. if((isset($_GET['catid']) || isset($_POST['catid'])) && $_SESSION['roleid'] != 1) {
  7. $catid = isset($_GET['catid']) ? intval($_GET['catid']) : intval($_POST['catid']);
  8. $this->priv_db = pc_base::load_model('category_priv_model');
  9. $priv_datas = $this->priv_db->get_one(array('catid'=>$catid,'is_admin'=>1,'action'=>'push'));
  10. if(!$priv_datas['catid']) showmessage(L('permission_to_operate'),'blank');
  11. }
  12. class push extends admin {
  13. public function __construct() {
  14. parent::__construct();
  15. $this->siteid = $this->get_siteid();
  16. $module = (isset($_GET['module']) && !empty($_GET['module'])) ? $_GET['module'] : 'admin';
  17. if (in_array($module, array('admin', 'special','content'))) {
  18. $this->push = push_factory::get_instance()->get_api($module);
  19. } else {
  20. showmessage(L('not_exists_push'), 'blank');
  21. }
  22. }
  23. /**
  24. * 推送选择界面
  25. */
  26. public function init() {
  27. if ($_POST['dosubmit']) {
  28. $c = pc_base::load_model('content_model');
  29. $c->set_model($_POST['modelid']);
  30. $info = array();
  31. $ids = explode('|', $_POST['id']);
  32. if(is_array($ids)) {
  33. foreach($ids as $id) {
  34. $info[$id] = $c->get_content($_POST['catid'], $id);
  35. }
  36. }
  37. $_GET['add_action'] = $_GET['add_action'] ? $_GET['add_action'] : $_GET['action'];
  38. $this->push->{$_GET['add_action']}($info, $_POST);
  39. showmessage(L('success'), '', '', 'push');
  40. } else {
  41. pc_base::load_app_func('global', 'template');
  42. if (method_exists($this->push, $_GET['action'])) {
  43. $html = $this->push->{$_GET['action']}(array('modelid'=>$_GET['modelid'], 'catid'=>$_GET['catid']));
  44. $tpl = isset($_GET['tpl']) ? 'push_to_category' : 'push_list';
  45. include $this->admin_tpl($tpl);
  46. } else {
  47. showmessage('CLASS METHOD NO EXISTS!', 'blank');
  48. }
  49. }
  50. }
  51. public function public_ajax_get() {
  52. if (method_exists($this->push, $_GET['action'])) {
  53. $html = $this->push->{$_GET['action']}($_GET['html']);
  54. echo $html;
  55. } else {
  56. echo 'CLASS METHOD NO EXISTS!';
  57. }
  58. }
  59. }
  60. ?>