diff --git a/module/admin/config.php b/module/admin/config.php index 858e34106c..0a9ddb1c0f 100755 --- a/module/admin/config.php +++ b/module/admin/config.php @@ -23,3 +23,35 @@ $config->admin->menuModuleGroup['model']['custom|required'] = array('project', $config->admin->menuModuleGroup['feature']['custom|set'] = array('todo', 'feedback', 'user', 'block', 'story', 'task', 'bug', 'testcase', 'testtask', 'feedback', 'user'); $config->admin->menuModuleGroup['feature']['custom|required'] = array('bug', 'doc', 'product', 'story', 'productplan', 'release', 'task', 'bug', 'testcase', 'testsuite', 'testtask', 'testreport', 'caselib', 'doc', 'feedback', 'user'); $config->admin->menuModuleGroup['template']['custom|set'] = array('baseline'); + +$config->admin->plugIns[203] = new stdClass(); +$config->admin->plugIns[203]->name = '人力资源日历'; +$config->admin->plugIns[203]->desc = '禅道人力资源日历插件可以帮助项目管理者查看不同维度下的消耗工时、未完成工作量、并行工作量及负载率,同时组织维度待处理状态下实现了模拟负载的功能,帮助管理者详细了解成员的工作负载情况,更好的进行项目人力资源调度。'; +$config->admin->plugIns[203]->viewLink = 'https://www.zentao.net/extension-viewExt-203.html'; + +$config->admin->plugIns[198] = new stdClass(); +$config->admin->plugIns[198]->name = '需求池插件'; +$config->admin->plugIns[198]->desc = '本插件为禅道需求池管理插件,包括:创建需求池 需求池权限管理 收集需求并向需求池录入需求 记录需求提出人信息 评审需求 拆分用户需求、研发需求 需求跟踪矩阵'; +$config->admin->plugIns[198]->viewLink = 'https://www.zentao.net/extension-viewExt-198.html'; + +$config->admin->plugIns[27] = new stdClass(); +$config->admin->plugIns[27]->name = 'Excel导出/导入'; +$config->admin->plugIns[27]->desc = '安装该插件可以支持Excel导出和任务、需求、Bug、用例导入功能。更新提示:新增任务、需求、Bug的excel导入功能。'; +$config->admin->plugIns[27]->viewLink = 'https://www.zentao.net/extension-viewExt-27.html'; + +$config->admin->plugIns[26] = new stdClass(); +$config->admin->plugIns[26]->name = '甘特图'; +$config->admin->plugIns[26]->desc = '禅道甘特图插件 运用此插件可以查看甘特图,维护任务关系。'; +$config->admin->plugIns[26]->viewLink = 'https://www.zentao.net/extension-viewExt-26.html'; + +$config->admin->plugIns[30] = new stdClass(); +$config->admin->plugIns[30]->name = '日志日历'; +$config->admin->plugIns[30]->desc = '运用此插件可以实现工作日志的添加、编辑、查看、删除、导出等功能,方便用户管理工作日志。'; +$config->admin->plugIns[30]->viewLink = 'https://www.zentao.net/extension-viewExt-30.html'; + +//$config->admin->plugIns[] = new stdClass(); +//$config->admin->plugIns[]->name = ''; +//$config->admin->plugIns[]->desc = ''; +//$config->admin->plugIns[]->viewLink = 'https://www.zentao.net/extension-viewExt-203.html'; + +$config->admin->apiRoot = 'https://www.zentao.net/'; diff --git a/module/admin/control.php b/module/admin/control.php index f05ab4299d..52e29309a3 100755 --- a/module/admin/control.php +++ b/module/admin/control.php @@ -34,11 +34,25 @@ class admin extends control $this->loadModel('misc'); - $extensions = $this->loadModel('extension')->getExtensionsByAPI('byUpdatedTime', '', 0, 6); + /* Check internet. */ + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, 'https://api.zentao.net/extension-apiGetExtensions.json'); + curl_setopt($curl, CURLOPT_TIMEOUT_MS, 1000); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 1000); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); + $connected = (bool)curl_exec($curl); + curl_close($curl); - $this->view->title = $this->lang->admin->common; - $this->view->position[] = $this->lang->admin->index; - $this->view->extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array(); + $clientLang = $this->app->getClientLang(); + + $this->view->title = $this->lang->admin->common; + $this->view->position[] = $this->lang->admin->index; + $this->view->extensions = $this->admin->getExtensionsByAPI('extension', 6, $connected); + $this->view->hasInternet = $connected; + $this->view->publicClass = ($connected and strpos($clientLang, 'zh') === 0) ? $this->admin->getPublicClassByAPI() : array(); + $this->view->clientLang = $clientLang; $this->display(); } diff --git a/module/admin/model.php b/module/admin/model.php index bff5a3bc9d..bab50d297b 100755 --- a/module/admin/model.php +++ b/module/admin/model.php @@ -13,6 +13,11 @@ loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit); + $extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array(); + } + else + { + if($this->config->edition == 'open') + { + $extensions = array( + $this->config->admin->plugIns[27], + $this->config->admin->plugIns[26], + $this->config->admin->plugIns[30] + ); + } + else + { + $extensions = array( + $this->config->admin->plugIns[198], + $this->config->admin->plugIns[203] + ); + } + } + + return $extensions; + } + + /** + * Fetch data from an api. + * + * @param string $url + * @access public + * @return mixed + */ + public function fetchAPI($url) + { + $version = $this->loadModel('upgrade')->getOpenVersion(str_replace('.', '_', $this->config->version)); + $version = str_replace('_', '.', $version); + + $url .= (strpos($url, '?') === false ? '?' : '&') . 'lang=' . str_replace('-', '_', $this->app->getClientLang()) . '&managerVersion=' . self::EXT_MANAGER_VERSION . '&zentaoVersion=' . $version; + $result = json_decode(preg_replace('/[[:cntrl:]]/mu', '', common::http($url))); + + if(!isset($result->status)) return false; + if($result->status != 'success') return false; + if(isset($result->data)) return json_decode($result->data); + } + + /** + * Get public class from zentao.net. + * + * @param int $limit + * @access public + * @return void + */ + public function getPublicClassByAPI($limit = 2) + { + $apiURL = $this->config->admin->apiRoot . "publicclass.json"; + $data = $this->fetchAPI($apiURL); + $courses = $data->videos; + + $index = 1; + $publicClass = array(); + foreach($courses as $course) + { + if($index > $limit) return $publicClass; + + $publicClass[$index] = new stdClass(); + $publicClass[$index]->name = $course->title; + $publicClass[$index]->image = $this->config->admin->apiRoot . $course->image->list[0]->smallURL; + $publicClass[$index]->viewLink = $this->config->admin->apiRoot . "{$course->alias}-{$course->id}.html"; + $index++; + } + return $publicClass; + } } diff --git a/module/admin/view/index.html.php b/module/admin/view/index.html.php index 650d5840d9..921593cb0a 100755 --- a/module/admin/view/index.html.php +++ b/module/admin/view/index.html.php @@ -11,6 +11,7 @@ */ ?> +