* code for task #2529.
This commit is contained in:
+128
-30
@@ -17,11 +17,11 @@ class block extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($moduleName = '', $methodName = '')
|
||||
{
|
||||
parent::__construct();
|
||||
$this->blockModule = strpos($this->server->http_referer, common::getSysURL()) === 0 ? $this->session->blockModule : '';
|
||||
if($this->methodName != 'admin' and empty($this->blockModule) and !$this->loadModel('sso')->checkKey()) die('');
|
||||
parent::__construct($moduleName, $methodName);
|
||||
$this->selfCall = strpos($this->server->http_referer, common::getSysURL()) === 0 || $this->session->blockModule;
|
||||
if($this->methodName != 'admin' and !$this->selfCall and !$this->loadModel('sso')->checkKey()) die('');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,23 +40,31 @@ class block extends control
|
||||
|
||||
if(!$index) $index = $this->block->getLastKey($module) + 1;
|
||||
|
||||
$modules = $this->lang->block->moduleList;
|
||||
foreach($modules as $moduleKey => $moduleName)
|
||||
if($module == 'my')
|
||||
{
|
||||
if($moduleKey == 'todo') continue;
|
||||
if(in_array($moduleKey, $this->app->user->rights['acls'])) unset($modules[$moduleKey]);
|
||||
if(!common::hasPriv($moduleKey, 'index')) unset($modules[$moduleKey]);
|
||||
$modules = $this->lang->block->moduleList;
|
||||
foreach($modules as $moduleKey => $moduleName)
|
||||
{
|
||||
if($moduleKey == 'todo') continue;
|
||||
if(in_array($moduleKey, $this->app->user->rights['acls'])) unset($modules[$moduleKey]);
|
||||
if(!common::hasPriv($moduleKey, 'index')) unset($modules[$moduleKey]);
|
||||
}
|
||||
|
||||
$modules['dynamic'] = $this->lang->block->dynamic;
|
||||
$modules['html'] = 'HTML';
|
||||
$modules = array('' => '') + $modules;
|
||||
|
||||
$hiddenBlocks = $this->block->getHiddenBlocks();
|
||||
foreach($hiddenBlocks as $block) $modules['hiddenBlock' . $block->id] = $block->title;
|
||||
$this->view->modules = $modules;
|
||||
}
|
||||
elseif(isset($this->lang->block->moduleList[$module]))
|
||||
{
|
||||
$this->get->set('mode', 'getblocklist');
|
||||
$this->view->blocks = $this->fetch('block', 'main', "module=$module&index=$index");
|
||||
}
|
||||
|
||||
$modules['dynamic'] = $this->lang->block->dynamic;
|
||||
$modules['html'] = 'HTML';
|
||||
$modules = array('' => '') + $modules;
|
||||
|
||||
$hiddenBlocks = $this->block->getHiddenBlocks();
|
||||
foreach($hiddenBlocks as $block) $modules['hiddenBlock' . $block->id] = $block->title;
|
||||
|
||||
$this->view->block = $this->block->getBlock($index);
|
||||
$this->view->modules = $modules;
|
||||
$this->view->index = $index;
|
||||
$this->view->title = $title;
|
||||
$this->display();
|
||||
@@ -76,7 +84,7 @@ class block extends control
|
||||
if($_POST)
|
||||
{
|
||||
$source = isset($this->lang->block->moduleList[$type]) ? $type : '';
|
||||
$this->block->save($index, $source, $this->blockModule, $blockID);
|
||||
$this->block->save($index, $source, $this->session->blockModule, $blockID);
|
||||
if(dao::isError()) die(js::error(dao::geterror()));
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
@@ -126,7 +134,7 @@ class block extends control
|
||||
*
|
||||
* @param string $oldOrder
|
||||
* @param string $newOrder
|
||||
* @param string $app
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -148,6 +156,91 @@ class block extends control
|
||||
$this->send(array('result' => 'success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display dashboard for app.
|
||||
*
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function dashboard($module)
|
||||
{
|
||||
$blocks = $this->block->getBlockList($module);
|
||||
$inited = empty($this->config->$module->common->blockInited) ? '' : $this->config->$module->common->blockInited;
|
||||
|
||||
/* Init block when vist index first. */
|
||||
if(empty($blocks) and !($inited and $inited->app == $module and $inited->value))
|
||||
{
|
||||
if($this->block->initBlock($module)) die(js::reload());
|
||||
}
|
||||
|
||||
foreach($blocks as $block)
|
||||
{
|
||||
$params = json_decode($block->params);
|
||||
$blockID = $block->block;
|
||||
|
||||
$block->blockLink = $this->createLink('block', 'printBlock', "index=$block->order&module=$block->module");
|
||||
$block->moreLink = '';
|
||||
if(isset($this->lang->block->modules[$module]->moreLinkList->{$blockID}))
|
||||
{
|
||||
list($moduleName, $method, $vars) = explode('|', sprintf($this->lang->block->modules[$module]->moreLinkList->{$blockID}, $params->type));
|
||||
$block->moreLink = $this->createLink($moduleName, $method, $vars);
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->blocks = $blocks;
|
||||
$this->view->module = $module;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* latest dynamic.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function dynamic()
|
||||
{
|
||||
$this->view->actions = $this->loadModel('action')->getDynamic('all', 'today');
|
||||
$this->view->users = $this->loadModel('user')->getPairs();
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print block.
|
||||
*
|
||||
* @param int $index
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function printBlock($index, $module = 'my')
|
||||
{
|
||||
$block = $this->block->getBlock($index, $module);
|
||||
|
||||
if(empty($block)) return false;
|
||||
|
||||
$html = '';
|
||||
if($block->block == 'html')
|
||||
{
|
||||
$html = "<div class='article-content'>" . htmlspecialchars_decode($block->params->html) .'</div>';
|
||||
}
|
||||
elseif($block->source != '')
|
||||
{
|
||||
$this->get->set('mode', 'getblockdata');
|
||||
$this->get->set('module', $block->module);
|
||||
$this->get->set('source', $block->source);
|
||||
$this->get->set('blockid', $block->block);
|
||||
$this->get->set('param',base64_encode(json_encode($block->params)));
|
||||
$html = $this->fetch('block', 'main');
|
||||
}
|
||||
elseif($block->block == 'dynamic')
|
||||
{
|
||||
$html = $this->fetch('block', 'dynamic');
|
||||
}
|
||||
|
||||
die($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function.
|
||||
*
|
||||
@@ -156,7 +249,7 @@ class block extends control
|
||||
*/
|
||||
public function main($module = '', $index = 0)
|
||||
{
|
||||
if(empty($this->blockModule))
|
||||
if(!$this->selfCall)
|
||||
{
|
||||
$lang = $this->get->lang;
|
||||
$this->app->setClientLang($lang);
|
||||
@@ -168,7 +261,7 @@ class block extends control
|
||||
if($mode == 'getblocklist')
|
||||
{
|
||||
$blocks = $this->block->getAvailableBlocks($module);
|
||||
if($this->blockModule)
|
||||
if($this->selfCall)
|
||||
{
|
||||
$blocks = json_decode($blocks, true);
|
||||
$blockPairs = array('' => '') + $blocks;
|
||||
@@ -192,19 +285,22 @@ class block extends control
|
||||
|
||||
$params = $this->get->param;
|
||||
$params = json_decode(base64_decode($params));
|
||||
$sso = base64_decode($this->get->sso);
|
||||
|
||||
$this->app->user = $this->dao->select('*')->from(TABLE_USER)->where('ranzhi')->eq($params->account)->fetch();
|
||||
if(empty($this->app->user))
|
||||
if(!$this->selfCall)
|
||||
{
|
||||
$this->app->user = new stdclass();
|
||||
$this->app->user->account = 'guest';
|
||||
$this->app->user = $this->dao->select('*')->from(TABLE_USER)->where('ranzhi')->eq($params->account)->fetch();
|
||||
if(empty($this->app->user))
|
||||
{
|
||||
$this->app->user = new stdclass();
|
||||
$this->app->user->account = 'guest';
|
||||
}
|
||||
|
||||
$sso = base64_decode($this->get->sso);
|
||||
$this->view->sso = $sso;
|
||||
$this->view->sign = strpos($sso, '&') === false ? '?' : '&';
|
||||
}
|
||||
|
||||
$this->viewType = (isset($params->viewType) and $params->viewType == 'json') ? 'json' : 'html';
|
||||
$this->params = $params;
|
||||
$this->view->sso = $sso;
|
||||
$this->view->sign = strpos($sso, '&') === false ? '?' : '&';
|
||||
$this->view->code = $this->get->blockid;
|
||||
|
||||
$func = 'print' . ucfirst($code) . 'Block';
|
||||
@@ -314,7 +410,9 @@ class block extends control
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = pager::init(0, $this->params->num, 1);
|
||||
$this->view->stories = $this->loadModel('story')->getUserStories($this->app->user->account, $this->params->type, $this->params->orderBy, $this->viewType != 'json' ? $pager : '');
|
||||
$this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('my', 'story', "type={$this->params->type}"));
|
||||
|
||||
$listLink = $this->createLink('my', 'story', "type={$this->params->type}");
|
||||
$this->view->listLink = !isset($this->view->sso) ? $listLink : $this->view->sso . $this->view->sign . 'referer=' . base64_encode($listLink);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
body {background: #fafafa;}
|
||||
|
||||
.page-content {margin-top: -19px; border-top: 1px solid #3280fc;}
|
||||
|
||||
.dashboard {position: relative; padding-top: 25px; z-index: 1030}
|
||||
.dashboard .row {margin: 0 auto;}
|
||||
.dashboard .panel-actions {margin-top: 0; margin-right: 0;}
|
||||
.dashboard-actions {position: absolute; top: -35px; right: 100px}
|
||||
.dashboard-actions .btn {padding: 5px 12px}
|
||||
.dashboard .table tr[data-url] td {cursor: pointer;}
|
||||
.dashboard .panel-heading {height: 30px}
|
||||
@@ -18,7 +18,7 @@ function getBlocks(moduleID)
|
||||
getRssAndHtmlParams('html', moduleID.replace('hiddenBlock', ''));
|
||||
return true;
|
||||
}
|
||||
if(moduleID == 'html' || moduleID == 'modules' || moduleID == 'dynamic')
|
||||
if(moduleID == 'html' || moduleID == 'dynamic')
|
||||
{
|
||||
getRssAndHtmlParams(moduleID);
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
$(function()
|
||||
{
|
||||
$('#dashboard').dashboard(
|
||||
{
|
||||
height : 240,
|
||||
draggable : true,
|
||||
shadowType : false,
|
||||
afterOrdered : sortBlocks,
|
||||
afterPanelRemoved : deleteBlock,
|
||||
sensitive : true,
|
||||
panelRemovingTip : config.confirmRemoveBlock
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Delete block.
|
||||
*
|
||||
* @param int $index
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function deleteBlock(index)
|
||||
{
|
||||
$.getJSON(createLink('block', 'delete', 'index=' + index + '&module=' + module), function(data)
|
||||
{
|
||||
if(data.result != 'success')
|
||||
{
|
||||
alert(data.message);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort blocks.
|
||||
*
|
||||
* @param object $orders format is {'block2' : 1, 'block1' : 2, oldOrder : newOrder}
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function sortBlocks(orders)
|
||||
{
|
||||
var oldOrder = new Array();
|
||||
var newOrder = new Array();
|
||||
for(i in orders)
|
||||
{
|
||||
oldOrder.push(i.replace('block', ''));
|
||||
newOrder.push(orders[i]);
|
||||
}
|
||||
|
||||
$.getJSON(createLink('block', 'sort', 'oldOrder=' + oldOrder.join(',') + '&newOrder=' + newOrder.join(',') + '&module=' + module), function(data)
|
||||
{
|
||||
|
||||
if(data.result != 'success') return false;
|
||||
|
||||
$('#dashboard .panel').each(function()
|
||||
{
|
||||
var index = $(this).data('order');
|
||||
/* Update new index for block id edit and delete. */
|
||||
$(this).attr('id', 'block' + index).attr('data-id', index).data('url', createLink('block', 'printBlock', 'index=' + index));
|
||||
$(this).find('.panel-actions .edit-block').attr('href', createLink('block', 'admin', 'index=' + index));
|
||||
});
|
||||
|
||||
$.zui.messager.success(config.ordersSaved);
|
||||
});
|
||||
}
|
||||
@@ -203,6 +203,7 @@ $lang->block->typeList->story['reviewedBy'] = '由我评审';
|
||||
$lang->block->typeList->story['closedBy'] = '由我关闭';
|
||||
|
||||
$lang->block->typeList->product['noclosed'] = '未关闭';
|
||||
$lang->block->typeList->product['closed'] = '已关闭';
|
||||
$lang->block->typeList->product['all'] = '全部';
|
||||
|
||||
$lang->block->typeList->project['undone'] = '未完成';
|
||||
@@ -212,3 +213,16 @@ $lang->block->typeList->project['all'] = '全部';
|
||||
$lang->block->typeList->testtask['wait'] = '待测版本';
|
||||
$lang->block->typeList->testtask['done'] = '已测版本';
|
||||
$lang->block->typeList->testtask['all'] = '全部';
|
||||
|
||||
$lang->block->modules['product']->moreLinkList = new stdclass();
|
||||
$lang->block->modules['product']->moreLinkList->list = 'product|all|product=&status=%s';
|
||||
$lang->block->modules['product']->moreLinkList->story = 'my|story|type=%s';
|
||||
$lang->block->modules['project']->moreLinkList = new stdclass();
|
||||
$lang->block->modules['project']->moreLinkList->list = 'project|all|project=&status=%s';
|
||||
$lang->block->modules['project']->moreLinkList->task = 'my|task|type=%s';
|
||||
$lang->block->modules['qa']->moreLinkList = new stdclass();
|
||||
$lang->block->modules['qa']->moreLinkList->bug = 'my|bug|type=%s';
|
||||
$lang->block->modules['qa']->moreLinkList->case = 'my|testcase|type=%s';
|
||||
$lang->block->modules['qa']->moreLinkList->testtask = 'my|testtask|type=%s';
|
||||
$lang->block->modules['todo']->moreLinkList = new stdclass();
|
||||
$lang->block->modules['todo']->moreLinkList->list = 'my|todo|type=all';
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.lite.html.php';?>
|
||||
<table class='table table-form'>
|
||||
<tr><th class='w-100px'></th><td></td></tr>
|
||||
<?php if(!empty($modules)):?>
|
||||
<tr>
|
||||
<th class='w-100px'><?php echo $lang->block->lblModule; ?></th>
|
||||
<?php
|
||||
@@ -20,8 +22,9 @@
|
||||
?>
|
||||
<td><?php echo html::select('modules', $modules, $moduleID, "class='form-control'")?></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<?php endif;?>
|
||||
<tr><?php if(!empty($blocks)) echo $blocks;?></tr>
|
||||
</table>
|
||||
<div id='blockParam'></div>
|
||||
<div id='blockParam'><?php if(!empty($blocks)) echo $blocks;?></div>
|
||||
<?php js::set('index', $index)?>
|
||||
<?php include '../../common/view/footer.lite.html.php';?>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* The dashboard view file of block module of RanZhi.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yidong Wang <yidong@cnezsoft.com>
|
||||
* @package block
|
||||
* @version $Id$
|
||||
* @link http://www.ranzhico.com
|
||||
*/
|
||||
if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}
|
||||
$webRoot = $config->webRoot;
|
||||
$jsRoot = $webRoot . "js/";
|
||||
$themeRoot = $webRoot . "theme/";
|
||||
if(isset($pageCSS)) css::internal($pageCSS);
|
||||
?>
|
||||
<div class='dashboard dashboard-draggable' id='dashboard' data-confirm-remove-block='<?php echo $lang->block->confirmRemoveBlock;?>'>
|
||||
<div class='row'>
|
||||
<?php foreach($blocks as $index => $block):?>
|
||||
<div class='col-sm-6 col-md-<?php echo $block->grid;?>'>
|
||||
<div class='panel <?php if(isset($block->params->color)) echo 'panel-' . $block->params->color;?>' id='block<?php echo $index?>' data-id='<?php echo $index?>' data-name='<?php echo $block->title?>' data-url='<?php echo $block->blockLink?>'>
|
||||
<div class='panel-heading'>
|
||||
<div class='panel-actions'>
|
||||
<?php if(isset($block->moreLink)) echo html::a($block->moreLink, $lang->more . "<i class='icon-double-angle-right'></i>", "class='app-btn'");?>
|
||||
<button class='btn btn-mini refresh-panel'><i class='icon-repeat'></i></button>
|
||||
<div class='dropdown'>
|
||||
<button class='btn btn-mini' data-toggle='dropdown'><span class='caret'></span></button>
|
||||
<ul class='dropdown-menu pull-right'>
|
||||
<li><a data-toggle='modal' href="<?php echo $this->createLink("block", "admin", "index=$index&module=$module"); ?>" class='edit-block' data-title='<?php echo $block->title; ?>' data-icon='icon-pencil'><i class='icon-pencil'></i> <?php echo $lang->edit; ?></a></li>
|
||||
<li><a href='javascript:;' class='remove-panel'><i class='icon-remove'></i> <?php echo $lang->delete; ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo $block->title;?>
|
||||
</div>
|
||||
<div class='panel-body no-padding'></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
<div class='dashboard-actions'><a class='btn btn-primary' href='<?php echo $this->createLink("block", "admin", "index=0&module=$module"); ?>' data-toggle='modal'><i class='icon-plus'></i> <?php echo $lang->block->createBlock?></a></div>
|
||||
</div>
|
||||
<script>
|
||||
config.ordersSaved = '<?php echo $lang->block->ordersSaved; ?>';
|
||||
config.confirmRemoveBlock = '<?php echo $lang->block->confirmRemoveBlock; ?>';
|
||||
var module = '<?php echo $module?>';
|
||||
</script>
|
||||
<?php if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
|
||||
<?php
|
||||
if(isset($pageJS)) js::execute($pageJS);
|
||||
|
||||
/* Load hook files for current page. */
|
||||
$extPath = dirname(dirname(dirname(realpath($viewFile)))) . '/common/ext/view/';
|
||||
$extHookRule = $extPath . 'footer.*.hook.php';
|
||||
$extHookFiles = glob($extHookRule);
|
||||
if($extHookFiles) foreach($extHookFiles as $extHookFile) include $extHookFile;
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<table class='table table-condensed table-hover table-striped table-borderless table-fixed'>
|
||||
<?php
|
||||
foreach($actions as $action)
|
||||
{
|
||||
$user = isset($users[$action->actor]) ? $users[$action->actor] : $action->actor;
|
||||
if($action->action == 'login' or $action->action == 'logout') $action->objectName = $action->objectLabel = '';
|
||||
echo "<tr><td class='nobr' width='100%'>";
|
||||
printf($lang->block->dynamicInfo, $action->date, $user, $action->actionLabel, $action->objectLabel, $action->objectLink, $action->objectName);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
@@ -22,8 +22,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach($stories as $story):?>
|
||||
<?php $appid = isset($_GET['entry']) ? "class='app-btn' data-id='{$this->get->entry}'" : ''?>
|
||||
<tr data-url='<?php echo $sso . $sign . 'referer=' . base64_encode($this->createLink('story', 'view', "storyID={$story->id}")); ?>' <?php echo $appid?>>
|
||||
<?php
|
||||
$appid = isset($_GET['entry']) ? "class='app-btn' data-id='{$this->get->entry}'" : '';
|
||||
$viewLink = $this->createLink('story', 'view', "storyID={$story->id}");
|
||||
?>
|
||||
<tr data-url='<?php echo empty($sso) ? $viewLink : $sso . $sign . 'referer=' . base64_encode($viewLink); ?>' <?php echo $appid?>>
|
||||
<td><?php echo $story->id;?></td>
|
||||
<td><?php echo zget($lang->story->priList, $story->pri, $story->pri)?></td>
|
||||
<td title='<?php echo $story->title?>'><?php echo $story->title?></td>
|
||||
|
||||
@@ -59,7 +59,11 @@ class productModel extends model
|
||||
*/
|
||||
public function select($products, $productID, $currentModule, $currentMethod, $extra = '', $branch = 0)
|
||||
{
|
||||
if(!$productID) return;
|
||||
if(!$productID)
|
||||
{
|
||||
unset($this->lang->product->menu->branch);
|
||||
return;
|
||||
}
|
||||
|
||||
setCookie("lastProduct", $productID, $this->config->cookieLife, $this->config->webRoot);
|
||||
setCookie("lastBranch", "$productID-$branch", $this->config->cookieLife, $this->config->webRoot);
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php echo $this->fetch('block', 'dashboard', 'module=product');?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user