示例#1
0
 /**
  * @param array $nav_array
  * @param bool $check_show
  * @return array
  */
 static function check_nav_perm($nav_array, $check_show = true)
 {
     foreach ($nav_array as $_k => $_nav) {
         if ($check_show && isset($_nav['show']) && $_nav['show'] === false) {
             unset($nav_array[$_k]);
             continue;
         }
         if (isset($_nav['perm'])) {
             if (!Module_Account_User::has_perms($_nav['perm'])) {
                 unset($nav_array[$_k]);
                 continue;
             }
         }
         if (isset($_nav['children'])) {
             if (empty($_nav['children'])) {
                 unset($nav_array[$_k]['children']);
                 continue;
             }
             $c_nav = self::check_nav_perm($_nav['children']);
             $count = 0;
             foreach ($c_nav as $_n) {
                 $_n !== null && $count++;
             }
             if ($count == 0) {
                 unset($nav_array[$_k]);
                 continue;
             } elseif ($count == 1) {
                 $nav_array[$_k] = reset($c_nav);
                 $nav_array[$_k]['name'] = $_nav['name'];
             } else {
                 $nav_array[$_k]['children'] = $c_nav;
             }
         }
     }
     return $nav_array;
 }
示例#2
0
 static function task_list_action()
 {
     $task_id = Lib_Request::get_int('task_id');
     $ap_name = Lib_Request::get_var('ap_name');
     $ap_name = trim($ap_name);
     $src_id = Lib_Request::get_var('sub_src');
     $src_id = trim($src_id);
     $status = Lib_Request::get_int('status');
     $time_begin = Lib_Request::get_var('time_begin');
     $time_begin = trim($time_begin);
     $time_end = Lib_Request::get_var('time_end');
     $time_end = trim($time_end);
     $cond = [];
     $search_vars = [];
     $ap_cond = [];
     if (!empty($task_id)) {
         $cond = ['_id' => $task_id];
         $search_vars = ['task_id' => $task_id];
     } else {
         if (strpos($src_id, ',')) {
             $src_ids = explode(',', $src_id);
             $int_src_ids = [];
             foreach ($src_ids as $k => $v) {
                 $int_src_ids[] = intval($v);
             }
             $cond['src_id'] = ['$in' => array_merge($src_ids, $int_src_ids)];
         } elseif (!empty($src_id)) {
             $cond['src_id'] = ['$in' => [$src_id, intval($src_id)]];
         }
         if (!empty($status)) {
             $cond['status'] = $status;
             $search_vars['status'] = $status;
         }
         if (!empty($time_begin) || !empty($time_end)) {
             $time_cond = [];
             if (!empty($time_begin)) {
                 $time_begin = strtotime($time_begin);
                 $time_cond['$gt'] = $time_begin;
             }
             if (!empty($time_end)) {
                 $time_end = strtotime($time_end);
                 $time_cond['$lte'] = $time_end;
             }
             if ($time_begin >= $time_end) {
                 unset($time_cond['$lte']);
             }
             if (!empty($time_cond)) {
                 $cond['create_time'] = $time_cond;
             }
         }
     }
     if (!Module_Account_User::has_perms([Module_Account_Perm::PERM_AP_ADMIN])) {
         $ap_cond['interface_people'] = new MongoRegex("/" . Module_Account_User::get_current_user() . "/");
     }
     if (!empty($ap_name)) {
         $ap_cond = ['ap_name' => new MongoRegex("/" . $ap_name . "/")];
     }
     if (!empty($ap_cond)) {
         $search_vars['ap_name'] = $ap_name;
         $ap_ids = [];
         $int_ap_ids = [];
         $model = new Model_AccessPoint();
         $ap_infos = $model->get_all($ap_cond);
         if ($ap_infos['errno'] == Const_Err_Base::ERR_OK) {
             foreach ($ap_infos['data'] as $k => $ap) {
                 $ap_ids[] = $ap['ap_id'];
                 $int_ap_ids[] = intval($ap['ap_id']);
             }
         }
         $cond['ap_id'] = ['$in' => array_merge($ap_ids, $int_ap_ids)];
     }
     $model_task = new Model_Task();
     $total_num = $model_task->get_tasks_count($cond);
     $current_page = Lib_Request::get_int('page');
     //当前页码,必须
     $total_size = isset($total_num['data']) ? intval($total_num['data']) : 0;
     //总记录数,必须
     $page_size = 15;
     //每页条数,必须
     $skip = ($current_page - 1) * $page_size;
     //跳过记录,必须
     $skip = $skip < 0 ? 0 : $skip;
     $mode = 2;
     //页码模式,决定页码个数,默认1
     $tasks = $model_task->get_all($cond, $page_size, $skip);
     if ($tasks['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($tasks));
         $tasks = [];
         Lib_Request::flash('未获取到任务信息');
     }
     $tasks = $tasks['data'];
     $ap_infos = [];
     $ap_model = new Model_AccessPoint();
     foreach ($tasks as $_k => $_t) {
         $ap_info = $ap_model->get_ap_by_id($_t['ap_id']);
         $ap_info['ap_id'] = $_t['ap_id'];
         if ($ap_info['errno'] !== Const_Err_Base::ERR_OK) {
             Lib_Log::error(Lib_Helper::format_err_struct($ap_info));
             Lib_Request::flash('获取接入点信息失败');
             Module_HttpRequest_Router::redirect_to('/');
         }
         $ap_info = $ap_info[Const_DataAccess::MREK_DATA];
         $ap_infos[$_t['ap_id']] = $ap_info;
     }
     $source_model = new Model_Source();
     $all_sources = $source_model->get_all();
     $sources = $all_sources[Const_DataAccess::MREK_DATA];
     $all_src_type = [];
     foreach ($all_sources['data'] as $k => $v) {
         if (!in_array($v['src_type'], $all_src_type)) {
             $all_src_type[] = $v['src_type'];
         }
     }
     asort($all_src_type);
     $task_status_list = Module_ControlCentre_Main::$task_status_list;
     $pages = Module_View_Template::get_pages_html($current_page, $total_size, $page_size, $mode);
     Module_Page_Main::render('control_centre/task_list', ['ap_info' => $ap_infos, 'tasks' => $tasks, 'sources' => $sources, 'pages' => $pages, 'all_src_type' => $all_src_type, 'status_list' => $task_status_list, 'search_vars' => $search_vars]);
 }
示例#3
0
文件: main.php 项目: vincenttone/daf
 /**
  * @param int $ap_id
  * @param int $mode
  * @param array $options
  * @param string $php_script
  * @return array
  */
 static function exec_task($ap_id, $mode = Module_FlowManager_Main::RUN_MODE_CALLBACK, $options = ['meta' => true], $php_script = 'tools/access_point.php')
 {
     if (empty($ap_id)) {
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_ID_NOT_SET, '没有获取到接入点ID');
     }
     if (php_sapi_name() != 'cli') {
         Lib_Log::info("Run task, user [%s], Ap id:[%d]", [Module_Account_User::get_current_user(), $ap_id]);
     }
     if (Da\Sys_App::run_mode() == DA_RUN_MODE_PRO && $mode == Module_FlowManager_Main::RUN_MODE_CALLBACK && !isset($options['without_ct'])) {
         return Module_ScheduledTask_Main::run_ap_task($ap_id);
     } else {
         self::exec_task_by_cli($ap_id, $mode, $options, $php_script);
     }
     return Lib_Helper::get_return_struct(['msg' => '运行成功']);
 }
示例#4
0
文件: main.php 项目: vincenttone/daf
 /**
  * @param string $template
  * @param array $var
  */
 static function render($template, $var = [])
 {
     $global_var = ['title' => '数据接入 - Data Access', 'user' => Module_Account_User::current_user_info()];
     if (Da\Sys_Config::config('app/base')['run_mode'] == DA_RUN_MODE_PRE) {
         $global_var['title'] = '预接入系统 - Data Access';
     } else {
         if (Da\Sys_Config::config('app/base')['run_mode'] == DA_RUN_MODE_DEV) {
             $global_var['title'] = '开发接入系统 - Data Access';
         }
     }
     $template_array = ['header' => ['common/header', $global_var], 'nav' => ['common/nav', $global_var], 'message_board' => ['common/message_board'], 'crumb' => ['common/crumb'], 'page' => [$template, $var], 'footer' => ['common/footer', $global_var]];
     Module_View_Main::view()->m_render($template_array, 'common/base_page');
 }