diff --git a/module/block/model.php b/module/block/model.php index 383315585e..fcb3d99bab 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -1072,4 +1072,43 @@ class blockModel extends model { return $this->dao->select('count(estimate) as estimate')->from(TABLE_STORY)->where('id')->in($storyID)->fetch('estimate'); } + + /** + * Get zentao.net data. + * + * @param string $minTime + * @access public + * @return array + */ + public function getZentaoData($minTime = '') + { + return $this->dao->select('type,params')->from(TABLE_BLOCK) + ->where('account')->eq('system') + ->andWhere('vision')->eq('rnd') + ->andWhere('module')->eq('zentao') + ->beginIF($minTime)->andWhere('source')->ge($minTime)->fi() + ->andWhere('type')->in('plugin,patch,publicclass,news') + ->fetchPairs('type'); + } + + /** + * Set zentao data. + * + * @param string $type + * @param string $params + * @access public + * @return void + */ + public function setZentaoData($type = 'patch', $params = '') + { + $data = new stdclass(); + $data->account = 'system'; + $data->vision = 'rnd'; + $data->module = 'zentao'; + $data->type = $type; + $data->source = date('Y-m-d'); + $data->params = json_encode($params); + + $this->dao->replace(TABLE_BLOCK)->data($data)->exec(); + } } diff --git a/module/index/js/index.js b/module/index/js/index.js index 86ab05c19c..591c1b3753 100644 --- a/module/index/js/index.js +++ b/module/index/js/index.js @@ -891,6 +891,9 @@ $(function() { $('#globalSearchInput').click(); }); + + /* Update patch, plugin, news, publicclass from zetao.net. */ + if(isAdminUser) $.get(createLink('admin', 'ajaxSetZentaoData')); }); /* Change the search object according to the module and method. */ diff --git a/module/index/view/index.html.php b/module/index/view/index.html.php index be9093fc00..bb74a7d06c 100644 --- a/module/index/view/index.html.php +++ b/module/index/view/index.html.php @@ -21,6 +21,7 @@ js::set('appsMenuItems', commonModel::getMainNavList($app->rawModule)); js::set('defaultOpen', (isset($open) and !empty($open)) ? $open : ''); js::set('manualText', $lang->manual); js::set('manualUrl', ((!empty($config->isINT)) ? $config->manualUrl['int'] : $config->manualUrl['home']) . '&theme=' . $_COOKIE['theme']); +js::set('isAdminUser', $this->app->user->admin); ?>