* Code for task #86270.
This commit is contained in:
@@ -52,6 +52,7 @@ $config->action->objectNameFields['dataview'] = 'name';
|
||||
$config->action->objectNameFields['zahost'] = 'name';
|
||||
$config->action->objectNameFields['zanode'] = 'name';
|
||||
$config->action->objectNameFields['privpackage'] = 'name';
|
||||
$config->action->objectNameFields['privlang'] = 'name';
|
||||
|
||||
$config->action->commonImgSize = 870;
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ $lang->action->objectTypes['patch'] = 'Patch';
|
||||
$lang->action->objectTypes['repo'] = 'Repo';
|
||||
$lang->action->objectTypes['dataview'] = 'Data View';
|
||||
$lang->action->objectTypes['privpackage'] = 'Priv Package';
|
||||
$lang->action->objectTypes['privlang'] = 'Priv';
|
||||
|
||||
/* Used to describe operation history. */
|
||||
$lang->action->desc = new stdclass();
|
||||
|
||||
@@ -157,6 +157,7 @@ $lang->action->objectTypes['patch'] = 'Patch';
|
||||
$lang->action->objectTypes['repo'] = 'Repo';
|
||||
$lang->action->objectTypes['dataview'] = 'Data View';
|
||||
$lang->action->objectTypes['privpackage'] = 'Priv Package';
|
||||
$lang->action->objectTypes['privlang'] = 'Priv';
|
||||
|
||||
/* Used to describe operation history. */
|
||||
$lang->action->desc = new stdclass();
|
||||
|
||||
@@ -157,6 +157,7 @@ $lang->action->objectTypes['patch'] = 'Patch';
|
||||
$lang->action->objectTypes['repo'] = 'Repo';
|
||||
$lang->action->objectTypes['dataview'] = 'Data View';
|
||||
$lang->action->objectTypes['privpackage'] = 'Priv Package';
|
||||
$lang->action->objectTypes['privlang'] = 'Priv';
|
||||
|
||||
/* Used to describe operation history. */
|
||||
$lang->action->desc = new stdclass();
|
||||
|
||||
@@ -157,6 +157,7 @@ $lang->action->objectTypes['patch'] = '补丁';
|
||||
$lang->action->objectTypes['repo'] = '代码库';
|
||||
$lang->action->objectTypes['dataview'] = '中间表';
|
||||
$lang->action->objectTypes['privpackage'] = '权限包';
|
||||
$lang->action->objectTypes['privlang'] = '权限';
|
||||
|
||||
/* 用来描述操作历史记录。*/
|
||||
$lang->action->desc = new stdclass();
|
||||
|
||||
@@ -1392,7 +1392,6 @@ class actionModel extends model
|
||||
{
|
||||
$objectName = array();
|
||||
$relatedProject = array();
|
||||
|
||||
if(strpos(",{$this->config->action->needGetProjectType},", ",{$objectType},") !== false)
|
||||
{
|
||||
$objectInfo = $this->dao->select("id, project, $field AS name")->from($table)->where('id')->in($objectIdList)->fetchAll();
|
||||
@@ -1448,11 +1447,15 @@ class actionModel extends model
|
||||
$objectName = $this->dao->select("id,name")->from(TABLE_BRANCH)->where('id')->in($objectIdList)->fetchPairs();
|
||||
if(in_array(BRANCH_MAIN, $objectIdList)) $objectName[BRANCH_MAIN] = $this->lang->branch->main;
|
||||
}
|
||||
else
|
||||
elseif($objectType == 'privlang')
|
||||
{
|
||||
$objectName = $this->dao->select("priv AS id, $field AS name")->from($table)->where('priv')->in($objectIdList)->fetchPairs();
|
||||
}
|
||||
else
|
||||
{
|
||||
$objectName = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIdList)->fetchPairs();
|
||||
}
|
||||
|
||||
|
||||
$objectNames[$objectType] = $objectName;
|
||||
$relatedProjects[$objectType] = $relatedProject;
|
||||
}
|
||||
|
||||
+29
-26
@@ -584,41 +584,44 @@ class group extends control
|
||||
}
|
||||
}
|
||||
/**
|
||||
* edit priv
|
||||
*
|
||||
* edit priv
|
||||
* @param int $privID
|
||||
* @access public
|
||||
* @return void
|
||||
*
|
||||
*
|
||||
**/
|
||||
public function editPriv($privID)
|
||||
{
|
||||
$privID = intval($privID);
|
||||
$currentLang = $this->app->clientLang ? : 'zh-cn';
|
||||
$priv = $this->group->getPrivInfo($privID,$currentLang);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$responseResult = "success";
|
||||
$responseMeessage = $this->lang->saveSuccess;
|
||||
$locate = "parent";
|
||||
$this->group->updatePrivLang($privID,$currentLang);
|
||||
if(dao::isError())
|
||||
$privID = intval($privID);
|
||||
$currentLang = $this->app->clientLang ? : 'zh-cn';
|
||||
$priv = $this->group->getPrivInfo($privID, $currentLang);
|
||||
|
||||
if(!$priv)
|
||||
{
|
||||
return print(js::alert($this->lang->group->noneProject));
|
||||
}
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$responseResult = "fail";
|
||||
$responseMessage = dao::getError();
|
||||
$locate = "";
|
||||
$responseResult = "success";
|
||||
$responseMeessage = $this->lang->saveSuccess;
|
||||
$locate = "parent";
|
||||
$this->group->updatePrivLang($privID, $currentLang);
|
||||
|
||||
$actionID = $this->loadModel('action')->create('privlang', $privID, 'Edited');
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
$responseResult = "fail";
|
||||
$responseMessage = dao::getError();
|
||||
$locate = "";
|
||||
}
|
||||
|
||||
$this->send(array('result' => $responseResult, 'message' => $responseMessage, 'locate' => $locate));
|
||||
}
|
||||
$this->send(array('result'=>$responseResult,'message'=>$responseMessage,'locate'=>$locate));
|
||||
}
|
||||
|
||||
$this->view->modulePackage = $this->group->getModuleAndPackageTree();
|
||||
|
||||
if($priv)
|
||||
{
|
||||
$this->view->priv = $priv;
|
||||
$this->display();
|
||||
}
|
||||
$this->view->modulePackage = $this->group->getModuleAndPackageTree();
|
||||
$this->view->priv = $priv;
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
+33
-56
@@ -1150,93 +1150,70 @@ class groupModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* get a priv
|
||||
*
|
||||
* @param int $privID
|
||||
* @return object
|
||||
*
|
||||
**/
|
||||
public function getPrivInfo($priv,$lang)
|
||||
{
|
||||
$privInfo = $this->dao->select("t1.priv,t1.name,t1.desc,t2.module,t2.package")->from(TABLE_PRIVLANG . ' t1')
|
||||
->leftJoin(TABLE_PRIV . ' t2')
|
||||
$privInfo = $this->dao->select("t1.priv,t1.name,t1.desc,t2.module,t2.package")->from(TABLE_PRIVLANG)->alias('t1')
|
||||
->leftJoin(TABLE_PRIV )->alias('t2')
|
||||
->on("t1.priv = t2.id")
|
||||
->where('t1.priv')
|
||||
->eq($priv)
|
||||
->andWHere('t1.lang')
|
||||
->eq($lang)
|
||||
->fetch();
|
||||
if($privInfo)
|
||||
{
|
||||
$privInfo->module = $privInfo->package ? $privInfo->module . ',' . $privInfo->package : $privInfo->module;
|
||||
}
|
||||
return $privInfo;
|
||||
->where('t1.priv')->eq($priv)
|
||||
->andWHere('t1.lang')->eq($lang)
|
||||
->fetch();
|
||||
|
||||
if($privInfo) $privInfo->module = $privInfo->package ? $privInfo->module . ',' . $privInfo->package : $privInfo->module;
|
||||
|
||||
return $privInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get prvi package tree
|
||||
*
|
||||
* get a prvi package tree
|
||||
*
|
||||
* @param void
|
||||
* @return array
|
||||
*
|
||||
**/
|
||||
public function getModuleAndPackageTree()
|
||||
{
|
||||
$modules = $this->getMenuModules(null,true);
|
||||
|
||||
$this->loadModel('setting');
|
||||
$tree = [];
|
||||
|
||||
$views = empty($viewName) ? $this->setting->getItem("owner=system&module=priv&key=views") : $viewName;
|
||||
if(empty($views)) return array();
|
||||
$views = explode(',', $views);
|
||||
|
||||
$tree = [];
|
||||
foreach($views as $viewIndex => $view)
|
||||
foreach($modules as $module => $moduleName)
|
||||
{
|
||||
$viewModules = $this->setting->getItem("owner=system&module=priv&key={$view}Modules");
|
||||
if(empty($viewModules)) continue;
|
||||
|
||||
$viewModules = explode(',', $viewModules);
|
||||
foreach($viewModules as $moduleIndex => $module)
|
||||
{
|
||||
$this->app->loadLang($module);
|
||||
|
||||
$tree[$module] = $this->lang->{$module}->common;;
|
||||
$packages = $this->getPrivPackagesByModule($module);
|
||||
foreach($packages as $packageID => $package)
|
||||
{
|
||||
$tree[$module. ',' . $packageID] = $this->lang->{$module}->common .'/'. $package->name;
|
||||
}
|
||||
$tree[$module] = $moduleName;
|
||||
$packages = $this->getPrivPackagesByModule($module);
|
||||
foreach($packages as $packageID => $package)
|
||||
{
|
||||
$tree[$module . ',' . $packageID] = $moduleName . '/' . $package->name;
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
|
||||
return $tree;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* update a Priv Info
|
||||
* update Priv Info
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
public function updatePrivLang($privID,$lang)
|
||||
public function updatePrivLang($privID, $lang)
|
||||
{
|
||||
$data = fixer::input('post')->remove('module')->get();
|
||||
$this->dao->update(TABLE_PRIVLANG)->data($data)->where('priv')->eq($privID)->andWhere('lang')->eq($lang)->exec();
|
||||
$this->dao->update(TABLE_PRIVLANG)->data($data)->where('priv')->eq($privID)->andWhere('lang')->eq($lang)->exec();
|
||||
|
||||
$data = fixer::input('post')->remove('name,desc')->get();
|
||||
if($data->module)
|
||||
{
|
||||
$update = [];
|
||||
$module = explode(",",$data->module);
|
||||
$update['module'] = $module[0];
|
||||
$update['package'] = 0;
|
||||
if(count($module) > 1) $update['package'] = $module[1];
|
||||
$this->dao->update(TABLE_PRIV)->data($update)->where('id')->eq($privID)->exec();
|
||||
}
|
||||
$data = fixer::input('post')->remove('name, desc')->get();
|
||||
if($data->module)
|
||||
{
|
||||
$update = [];
|
||||
$module = explode(",",$data->module);
|
||||
$update['module'] = $module[0];
|
||||
$update['package'] = 0;
|
||||
if(count($module) > 1) $update['package'] = $module[1];
|
||||
|
||||
$this->dao->update(TABLE_PRIV)->data($update)->where('id')->eq($privID)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
public function buildPrivSearchForm($queryID, $actionURL)
|
||||
|
||||
Reference in New Issue
Block a user