Variable.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\admin\controller\vbot;
  3. use app\common\controller\Backend;
  4. /**
  5. * 变量管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Variable extends Backend
  10. {
  11. /**
  12. * vbotVariable模型对象
  13. * @var \app\admin\model\vbotVariable
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\VbotVariable;
  20. $this->view->assign("valueSourceList", $this->model->getValueSourceList());
  21. }
  22. /*
  23. * 获取变量值-用于管理员测试
  24. */
  25. public function view_variable($ids = null)
  26. {
  27. $row = $this->model->get($ids);
  28. if (!$row) {
  29. $this->error(__('No Results were found'));
  30. }
  31. $adminIds = $this->getDataLimitAdminIds();
  32. if (is_array($adminIds)) {
  33. if (!in_array($row[$this->dataLimitField], $adminIds)) {
  34. $this->error(__('You have no permission'));
  35. }
  36. }
  37. $VbotLib = new \addons\vbot\library\VbotLib();
  38. $row->variable_value = $VbotLib->get_variable_value($row->toArray());
  39. $this->success(null, null, $row);
  40. }
  41. }