* add comment to action model.

+ add login and logout action.
This commit is contained in:
wangchunsheng
2010-04-09 09:43:35 +00:00
parent e4cb3c9e9a
commit c9622737f4
4 changed files with 38 additions and 6 deletions
+7
View File
@@ -21,6 +21,7 @@
* @version $Id$
* @link http://www.zentao.cn
*/
/* 用来描述操作历史记录。*/
$lang->action->desc->common = '$date, <strong>$action</strong> by <strong>$actor</strong>';
$lang->action->desc->extra = '$date, <strong>$action</strong> as <strong>$extra</strong> by <strong>$actor</strong>';
$lang->action->desc->opened = '$date, 由 <strong>$actor</strong> 创建。';
@@ -34,6 +35,7 @@ $lang->action->desc->confirmed = '$date, 由 <strong>$actor</strong> 确认需
$lang->action->desc->diff1 = '修改了 <strong><i>%s</i></strong>,旧值为 "%s",新值为 "%s"。<br />';
$lang->action->desc->diff2 = '修改了 <strong><i>%s</i></strong>,区别为:<blockquote>%s</blockquote>';
/* 用来显示动态信息。*/
$lang->action->label->opened = '创建了';
$lang->action->label->changed = '变更了';
$lang->action->label->edited = '编辑了';
@@ -44,8 +46,13 @@ $lang->action->label->resolved = '解决了';
$lang->action->label->reviewed = '评审了';
$lang->action->label->moved = '移动了';
$lang->action->label->confirmed = '确认了需求,';
$lang->action->label->login = '登录系统';
$lang->action->label->logout = "退出登录";
/* 用来生成相应对象的链接。*/
$lang->action->label->story = '需求|story|view|storyID=%s';
$lang->action->label->task = '任务|task|view|taskID=%s';
$lang->action->label->bug = 'Bug|bug|view|bugID=%s';
$lang->action->label->case = '用例|testcase|view|caseID=%s';
$lang->action->label->space = ' ';
+21 -1
View File
@@ -75,11 +75,16 @@ class actionModel extends model
}
}
/* 打印action标题。*/
/* 打印action标题,显示在每一个对象的详情界面。*/
public function printAction($action)
{
$objectType = $action->objectType;
$actionType = strtolower($action->action);
/**
* 判断使用哪一种描述。如果该模块有对应的描述,则取之,然后则取action模块中对应的方法的描述。
* 如果还没有,则判断当前action是否有extra信息,如果有,则取action模块的extra描述,最后使用通用的描述。
*/
if(isset($this->lang->$objectType->action->$actionType))
{
$desc = $this->lang->$objectType->action->$actionType;
@@ -93,9 +98,12 @@ class actionModel extends model
$desc = $action->extra ? $this->lang->action->desc->extra : $this->lang->action->desc->common;
}
/* 循环替换desc中对应的标签。*/
foreach($action as $key => $value)
{
if($key == 'history') continue;
/* desc可能是数组,也有可能是一个字符串。*/
if(is_array($desc))
{
if($key == 'extra') continue;
@@ -106,6 +114,8 @@ class actionModel extends model
$desc = str_replace('$' . $key, $value, $desc);
}
}
/* 如果desc是数组,再处理extra变量。例子参考bug模块的语言设置。*/
if(is_array($desc))
{
$extra = strtolower($action->extra);
@@ -136,6 +146,16 @@ class actionModel extends model
$action->date = date(DT_MONTHTIME2, strtotime($action->date));
$action->actionLabel = isset($this->lang->action->label->$actionType) ? $this->lang->action->label->$actionType : $action->action;
$action->objectLabel = isset($this->lang->action->label->$objectType) ? $this->lang->action->label->$objectType : $objectType;
/* 处理login和logout动作。*/
if($actionType == 'login' or $actionType == 'logout')
{
$action->objectLink = '';
$action->objectLabel = '';
continue;
}
/* 其他的动作生成相应的链接。*/
if(strpos($action->objectLabel, '|') !== false)
{
list($objectLabel, $moduleName, $methodName, $vars) = explode('|', $action->objectLabel);
+1 -1
View File
@@ -27,4 +27,4 @@ $lang->index->common = '首页';
$lang->index->index = '首页';
$lang->index->ping = '接口:同步session';
$lang->index->latest = '最新动态';
$lang->index->action = '%s, %s <i>%s</i> %s <strong>%s</strong>';
$lang->index->action = '%s, %s <i>%s</i> %s <strong>%s</strong>。';
+9 -4
View File
@@ -291,12 +291,16 @@ class user extends control
/* 用户提交了登陆信息,则检查用户的身份。*/
if(!empty($_POST))
{
$user = $this->user->identify($_POST['account'], $_POST['password']);
$user = $this->user->identify($this->post->account, $this->post->password);
if($user)
{
$user->rights = $this->user->authorize($_POST['account']);
$_SESSION['user'] = $user;
$this->app->user = $_SESSION['user'];
/* 对用户进行授权,并登记session。*/
$user->rights = $this->user->authorize($this->post->account);
$this->session->set('user', $user);
$this->app->user = $this->session->user;
/* 记录登录记录。*/
$this->loadModel('action')->create('user', $user->id, 'login');
/* POST变量中设置了referer信息,且非user/login.html, 非user/deny.html,并且包含当前系统的域名。*/
if(isset($_POST['referer']) and
@@ -350,6 +354,7 @@ class user extends control
*/
public function logout($referer = 0)
{
$this->loadModel('action')->create('user', $this->app->user->id, 'logout');
session_destroy();
$vars = !empty($referer) ? "referer=$referer" : '';
$this->locate($this->createLink('user', 'login', $vars));