* Fix bug #32593.
This commit is contained in:
+20
-14
@@ -57,13 +57,17 @@ class admin extends control
|
||||
$langNotCN = common::checkNotCN();
|
||||
$dateUsed = $this->admin->genDateUsed();
|
||||
|
||||
$zentaoData = $this->admin->getZentaoData();
|
||||
$hasInternet = $zentaoData->hasData;
|
||||
|
||||
$this->view->title = $this->lang->admin->common;
|
||||
$this->view->position[] = $this->lang->admin->index;
|
||||
$this->view->plugins = $this->admin->getExtensionsByAPI('plugin');
|
||||
$this->view->patches = $this->admin->getExtensionsByAPI('patch');
|
||||
$this->view->plugins = $zentaoData->plugins;
|
||||
$this->view->patches = $zentaoData->patches;
|
||||
$this->view->dateUsed = $dateUsed;
|
||||
$this->view->dynamics = array();
|
||||
$this->view->publicClass = array();
|
||||
$this->view->hasInternet = $hasInternet;
|
||||
$this->view->dynamics = $zentaoData->news;
|
||||
$this->view->publicClass = $zentaoData->publicclass;
|
||||
$this->view->langNotCN = $langNotCN;
|
||||
$this->display();
|
||||
}
|
||||
@@ -74,23 +78,25 @@ class admin extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetZentaoData()
|
||||
public function ajaxSetZentaoData()
|
||||
{
|
||||
$hasInternet = $this->admin->checkInternet();
|
||||
$langNotCN = common::checkNotCN();
|
||||
|
||||
$data['result'] = $hasInternet ? 'success' : 'fail';
|
||||
$data['data'] = new stdClass();
|
||||
|
||||
if($hasInternet)
|
||||
{
|
||||
$data['data']->plugins = $this->admin->getExtensionsByAPI('plugin', $langNotCN ? 5 : 6, true);
|
||||
$data['data']->patches = $this->admin->getExtensionsByAPI('patch', 5, true);
|
||||
$data['data']->dynamics = !$langNotCN ? $this->admin->getDynamicsByAPI(3) : array();
|
||||
$data['data']->publicClass = !$langNotCN ? $this->admin->getPublicClassByAPI(3) : array();
|
||||
$nextWeek = date('Y-m-d', strtotime('-7 days'));
|
||||
$zentaoData = $this->loadModel('block')->getZentaoData($nextWeek);
|
||||
|
||||
if(empty($zentaoData))
|
||||
{
|
||||
$this->admin->setExtensionsByAPI('plugin', 6);
|
||||
$this->admin->setExtensionsByAPI('patch', 5);
|
||||
$this->admin->setDynamicsByAPI(3);
|
||||
$this->admin->setPublicClassByAPI(3);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->send($data);
|
||||
return $this->send(array('result' => 'success'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,4 +10,6 @@ $(function()
|
||||
{
|
||||
window.open($(this).data('link'));
|
||||
});
|
||||
|
||||
if(!hasInternet) $.get(createLink('admin', 'ajaxSetZentaoData'));
|
||||
});
|
||||
|
||||
+83
-49
@@ -506,7 +506,7 @@ class adminModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extensions from zentao.net.
|
||||
* Set extensions from zentao.net.
|
||||
*
|
||||
* @param string $type plugin|patch
|
||||
* @param int $limit
|
||||
@@ -514,44 +514,22 @@ class adminModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionsByAPI($type = 'plugin', $limit = 6, $hasInternet = false)
|
||||
public function setExtensionsByAPI($type = 'plugin', $limit = 5)
|
||||
{
|
||||
if($hasInternet)
|
||||
$searchType = $type == 'plugin' ? 'byModule,offcial' : 'byModule';
|
||||
$param = $type == 'plugin' ? '' : 'MTIxOA==';
|
||||
$extensions = $this->loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit);
|
||||
$extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array();
|
||||
$plugins = array();
|
||||
foreach($extensions as $extension)
|
||||
{
|
||||
$searchType = $type == 'plugin' ? 'byModule,offcial' : 'byModule';
|
||||
$param = $type == 'plugin' ? '' : 'MTIxOA==';
|
||||
$extensions = $this->loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit);
|
||||
$extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array();
|
||||
$plugins = array();
|
||||
foreach($extensions as $extension)
|
||||
{
|
||||
if($type == 'patch' and !isset($extension->compatibleRelease)) continue;
|
||||
if($type == 'patch' and !isset($extension->compatibleRelease)) continue;
|
||||
|
||||
$extension->viewLink = str_replace(array('info', 'client'), '', $extension->viewLink);
|
||||
$plugins[] = $extension;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[27],
|
||||
$this->config->admin->plugins[26],
|
||||
$this->config->admin->plugins[30]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[198],
|
||||
$this->config->admin->plugins[194],
|
||||
$this->config->admin->plugins[203]
|
||||
);
|
||||
}
|
||||
$extension->viewLink = str_replace(array('info', 'client'), '', $extension->viewLink);
|
||||
$plugins[] = $extension;
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
return $this->loadModel('block')->setZentaoData($type, $plugins);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -575,13 +553,13 @@ class adminModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get public class from zentao.net.
|
||||
* Set public class from zentao.net.
|
||||
*
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
public function getPublicClassByAPI($limit = 2)
|
||||
public function setPublicClassByAPI($limit = 3)
|
||||
{
|
||||
$apiURL = $this->config->admin->videoAPIURL;
|
||||
$data = $this->fetchAPI($apiURL);
|
||||
@@ -599,24 +577,25 @@ class adminModel extends model
|
||||
$publicClass[$index]->viewLink = $this->config->admin->apiRoot . '/publicclass/' . ($course->alias ? "{$course->alias}-" : '') . "{$course->id}.html";
|
||||
$index ++;
|
||||
}
|
||||
return $publicClass;
|
||||
|
||||
return $this->loadModel('block')->setZentaoData('publicclass', $publicClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dynamics by API.
|
||||
* Set dynamics by API.
|
||||
*
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
public function getDynamicsByAPI($limit = 2)
|
||||
public function setDynamicsByAPI($limit = 2)
|
||||
{
|
||||
$apiURL = $this->config->admin->downloadAPIURL;
|
||||
$data = $this->fetchAPI($apiURL);
|
||||
$articles = $data->articles;
|
||||
|
||||
$index = 1;
|
||||
$downloads = array();
|
||||
$index = 1;
|
||||
$news = array();
|
||||
foreach($articles as $article)
|
||||
{
|
||||
if($index > $limit) break;
|
||||
@@ -625,14 +604,15 @@ class adminModel extends model
|
||||
if(!isset($this->lang->admin->$tagKey)) break;
|
||||
if(!preg_match("/{$this->lang->admin->$tagKey}\d/", $article->title)) continue;
|
||||
|
||||
$downloads[$index] = new stdClass();
|
||||
$downloads[$index]->id = $article->id;
|
||||
$downloads[$index]->title = $article->title;
|
||||
$downloads[$index]->addedDate = $article->addedDate;
|
||||
$downloads[$index]->link = $this->config->admin->apiRoot . "/download/{$article->alias}-{$article->id}.html";
|
||||
$news[$index] = new stdClass();
|
||||
$news[$index]->id = $article->id;
|
||||
$news[$index]->title = $article->title;
|
||||
$news[$index]->addedDate = $article->addedDate;
|
||||
$news[$index]->link = $this->config->admin->apiRoot . "/download/{$article->alias}-{$article->id}.html";
|
||||
$index ++;
|
||||
}
|
||||
return $downloads;
|
||||
|
||||
return $this->loadModel('block')->setZentaoData('news', $news);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,4 +654,58 @@ class adminModel extends model
|
||||
|
||||
return helper::getDateInterval($firstUseDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zentao.net data.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getZentaoData()
|
||||
{
|
||||
$zentaoData = $this->loadModel('block')->getZentaoData();
|
||||
|
||||
$data = new stdclass();
|
||||
$data->hasData = true;
|
||||
|
||||
$news = array();
|
||||
$publicclass = array();
|
||||
$plugins = array();
|
||||
$patches = array();
|
||||
if(empty($zentaoData))
|
||||
{
|
||||
$data->hasData = false;
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[27],
|
||||
$this->config->admin->plugins[26],
|
||||
$this->config->admin->plugins[30]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[198],
|
||||
$this->config->admin->plugins[194],
|
||||
$this->config->admin->plugins[203]
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$news = json_decode($zentaoData['news']);
|
||||
$publicclass = json_decode($zentaoData['publicclass']);
|
||||
$plugins = json_decode($zentaoData['plugin']);
|
||||
$patches = json_decode($zentaoData['patch']);
|
||||
if(common::checkNotCN()) array_pop($plugins);
|
||||
}
|
||||
|
||||
$data->news = $news;
|
||||
$data->publicclass = $publicclass;
|
||||
$data->plugins = $plugins;
|
||||
$data->patches = $patches;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('hasInternet', false);?>
|
||||
<?php js::set('hasInternet', $hasInternet);?>
|
||||
<div id='mainContent' class='main-content admin'>
|
||||
<div class="main <?php if(!$hasInternet) echo 'without-internet';?>">
|
||||
<div class="settings panel">
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
?>
|
||||
<style>
|
||||
#versionTitle {margin: 8px 3px 0px 0px; background-image: url(<?php echo $config->webRoot . 'theme/default/images/main/version-upgrade.svg';?>);}
|
||||
|
||||
Reference in New Issue
Block a user