コード例 #1
0
ファイル: buildin.php プロジェクト: syjzwjj/quyeba
 function command_update()
 {
     $options = $this->get_options();
     if ($options['sync'] || $options['sync-only']) {
         kernel::single('base_application_manage')->sync();
     } else {
         kernel::single('base_application_manage')->update_local();
     }
     if ($options['sync-only']) {
         return true;
     }
     $args = func_get_args();
     if (!$args) {
         $rows = app::get('base')->model('apps')->getList('app_id', array('installed' => 1));
         foreach ($rows as $r) {
             if ($r['app_id'] == 'base') {
                 continue;
             }
             $args[] = $r['app_id'];
         }
     }
     array_unshift($args, 'base');
     //todo:总是需要先更新base
     $args = array_unique($args);
     if (!$options['ignore-download']) {
         foreach ($args as $app_id) {
             //kernel::single('base_application_manage')->download($app_id,$options['force-download']);  //todo:临时去掉
         }
     }
     if ($options['force-update-db']) {
         base_application_dbtable::$force_update = true;
     }
     if ($options['custom-force-update-db']) {
         if (defined('CUSTOM_CORE_DIR')) {
             foreach (utils::tree(CUSTOM_CORE_DIR) as $k => $v) {
                 if (is_file($v)) {
                     touch($v);
                 }
             }
         }
     }
     if (!$options['download-only']) {
         foreach ($args as $app_id) {
             $appinfo = app::get('base')->model('apps')->getList('*', array('app_id' => $app_id));
             if (version_compare($appinfo[0]['local_ver'], $appinfo[0]['dbver'], '>') || $options['force-update-app']) {
                 app::get($app_id)->runtask('pre_update', array('dbver' => $appinfo[0]['dbver']));
                 kernel::single('base_application_manage')->update_app_content($app_id);
                 app::get($app_id)->runtask('post_update', array('dbver' => $appinfo[0]['dbver']));
                 app::get('base')->model('apps')->update(array('dbver' => $appinfo[0]['local_ver']), array('app_id' => $app_id));
             } else {
                 kernel::single('base_application_manage')->update_app_content($app_id);
             }
             //新更版本等信息
             $app_info = app::get($app_id)->define();
             if (isset($app_info['node_id']) && $app_info['node_id'] == "true" && base_shopnode::node_id($app_id)) {
                 if (base_shopnode::update($app_id)) {
                     kernel::log('Applications info send to center, ok.');
                 }
             }
         }
         kernel::log('Applications database and services is up-to-date, ok.');
     }
 }