+ add the feature of private.

+ add the feature of 'not set date'.
This commit is contained in:
wangchunsheng
2009-11-02 03:11:06 +00:00
parent 7185554704
commit e59e2f54ed
6 changed files with 82 additions and 89 deletions

View File

@@ -66,6 +66,10 @@ class todo extends control
die(js::locate($this->createLink('my', 'todo', "date=$_POST[date]"), 'parent'));
}
/* 获取todo信息判断是否是私人事务。*/
$todo = $this->todo->findById($todoID);
if($todo->private and $this->app->user->account != $todo->account) die('private');
$header['title'] = $this->lang->my->common . $this->lang->colon . $this->lang->todo->edit;
$position[] = $this->lang->todo->edit;
@@ -73,7 +77,7 @@ class todo extends control
$this->assign('position', $position);
$this->assign('dates', $this->todo->buildDateList(0, 3));
$this->assign('times', $this->todo->buildTimeList());
$this->assign('todo', $this->todo->findById($todoID));
$this->assign('todo', $todo);
$this->display();
}

View File

@@ -34,6 +34,7 @@ $lang->todo->browse = "浏览TODO";
$lang->todo->confirmDelete = "您确定要删除这个todo吗";
$lang->todo->successMarked = "成功切换状态!";
$lang->todo->thisIsPrivate = '这是一条私人事务。:)';
$lang->todo->lblDisableDate = '暂时不设定时间';
$lang->todo->id = '编号';
@@ -46,6 +47,7 @@ $lang->todo->pri = '优先级';
$lang->todo->name = '名称';
$lang->todo->status = '状态';
$lang->todo->desc = '描述';
$lang->todo->private = '私人事务';
$lang->todo->week = '星期';
$lang->todo->today = '今天';

View File

@@ -33,10 +33,12 @@ class todoModel extends model
->add('idvalue', 0)
->stripTags('type, name')
->specialChars('desc')
->cleanInt('date, pri, begin, end')
->cleanInt('date, pri, begin, end, private')
->setIF($this->post->type != 'custom', 'name', '')
->setIF($this->post->type == 'bug', 'idvalue', $this->post->bug)
->setIF($this->post->type == 'task', 'idvalue', $this->post->task)
->setIF($this->post->begin == false, 'begin', '2400')
->setIF($this->post->end == false, 'end', '2400')
->remove('bug, task')
->get();
$this->dao->insert(TABLE_TODO)->data($todo)->autoCheck()->checkIF($todo->type == 'custom', 'name', 'notempty')->exec();
@@ -47,9 +49,11 @@ class todoModel extends model
{
$todo = fixer::input('post')
->stripTags('type, name')
->cleanInt('date, pri, begin, end')
->cleanInt('date, pri, begin, end, private')
->specialChars('desc')
->setIF($this->post->type != 'custom', 'name', '')
->setIF($this->post->begin == false, 'begin', '2400')
->setIF($this->post->end == false, 'end', '2400')
->get();
$this->dao->update(TABLE_TODO)->data($todo)->autoCheck()->checkIF($todo->type == 'custom', 'name', 'notempty')->where('id')->eq($todoID)->exec();
}
@@ -92,6 +96,9 @@ class todoModel extends model
if($todo->type == 'bug') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_BUG)->fetch('title');
$todo->begin = $this->fdaoatTime($todo->begin);
$todo->end = $this->fdaoatTime($todo->end);
/* 如果是私人事务,且当前用户非本人,更改标题。*/
if($todo->private and $this->app->user->account != $todo->account) $todo->name = $this->lang->todo->thisIsPrivate;
$todos[] = $todo;
}
return $todos;
@@ -175,7 +182,7 @@ class todoModel extends model
/* 格式化时间显示。*/
public function fdaoatTime($time)
{
if(strlen($time) != 4) return '';
if(strlen($time) != 4 or $time == '2400') return '';
return substr($time, 0, 2) . ':' . substr($time, 2, 2);
}
}

View File

@@ -55,6 +55,10 @@
<input type='checkbox' onclick='switchDateFeature(this);'><?php echo $lang->todo->lblDisableDate;?>
</td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->private;?></th>
<td><input type='checkbox' name='private' id='private' value='1'></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
<?php echo html::submitButton() . html::resetButton();?>
@@ -63,50 +67,4 @@
</table>
</form>
</div>
<script language='Javascript'>
account='<?php echo $app->user->account;?>';
customHtml = $('#nameBox').html();
function loadList(type)
{
if(type == 'bug')
{
link = createLink('bug', 'ajaxGetUserBugs', 'account=' + account);
}
else if(type == 'task')
{
link = createLink('task', 'ajaxGetUserTasks', 'account=' + account);
}
if(type == 'bug' || type == 'task')
{
$('#nameBox').load(link);
}
else if(type == 'custom')
{
$('#nameBox').html(customHtml);
}
}
function selectNext()
{
endIndex = $("#begin ").get(0).selectedIndex + 2;
$("#end ").get(0).selectedIndex = endIndex;
}
function switchDateFeature(switcher)
{
if(switcher.checked)
{
$('#begin').attr('disabled','disabled');
$('#end').attr('disabled','disabled');
}
else
{
$('#begin').removeAttr('disabled');
$('#end').removeAttr('disabled');
}
}
selectNext();
</script>
<?php include '../../common/footer.html.php';?>
<?php include './footer.html.php';?>

View File

@@ -36,13 +36,17 @@
<th class='rowhead'><?php echo $lang->todo->type;?></th>
<td><input type='hidden' name='type' value='<?php echo $todo->type;?>' /><?php echo $lang->todo->typeList->{$todo->type};?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->pri;?></th>
<td><?php echo html::select('pri', $lang->todo->priList, $todo->pri, 'class=select-3');?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->name;?></th>
<td><div id='nameBox'><input type='text' name='name' value='<?php echo $todo->name;?>' class='text-3' <?php if($todo->type != 'custom') echo 'readonly';?> /></div></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->pri;?></th>
<td><?php echo html::select('pri', $lang->todo->priList, $todo->pri, 'class=select-3');?></td>
<th class='rowhead'><?php echo $lang->todo->desc;?></th>
<td><textarea name='desc' id='desc' rows='5' class='area-1'><?php echo $todo->desc;?></textarea>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->status;?></th>
@@ -50,12 +54,14 @@
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->beginAndEnd;?></th>
<td><?php echo html::select('begin', $times, $todo->begin, 'onchange=selectNext(); class=select-2') . html::select('end', $times, $todo->end, 'class=select-2');?></td>
<td>
<?php echo html::select('begin', $times, $todo->begin, 'onchange=selectNext(); class=select-2') . html::select('end', $times, $todo->end, 'class=select-2');?>
<input type='checkbox' id='switcher' onclick='switchDateFeature(this);' <?php if($todo->begin == 2400) echo 'checked';?> ><?php echo $lang->todo->lblDisableDate;?>
</td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->todo->desc;?></th>
<td><textarea name='desc' id='desc' rows='5' class='area-1'><?php echo $todo->desc;?></textarea>
<th class='rowhead'><?php echo $lang->todo->private;?></th>
<td><input type='checkbox' name='private' id='private' value='1' <?php if($todo->private) echo 'checked';?>></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
@@ -65,37 +71,7 @@
</table>
</form>
</div>
<?php include './footer.html.php';?>
<script language='Javascript'>
account='<?php echo $app->user->account;?>';
customHtml = $('#nameBox').html();
function loadList(type)
{
if(type == 'bug')
{
link = createLink('bug', 'ajaxGetUserBugs', 'account=' + account);
}
else if(type == 'task')
{
link = createLink('task', 'ajaxGetUserTasks', 'account=' + account);
}
if(type == 'bug' || type == 'task')
{
$('#nameBox').load(link);
$('#desc').attr('readonly', 'readonly');
}
else if(type == 'custom')
{
$('#nameBox').html(customHtml);
$('#desc').removeAttr('readonly');
}
}
function selectNext()
{
endIndex = $("#begin ").get(0).selectedIndex + 2;
$("#end ").get(0).selectedIndex = endIndex;
}
switchDateFeature(document.getElementById('switcher'));
</script>
<?php include '../../common/footer.html.php';?>

View File

@@ -0,0 +1,46 @@
<script language='Javascript'>
account='<?php echo $app->user->account;?>';
customHtml = $('#nameBox').html();
function loadList(type)
{
if(type == 'bug')
{
link = createLink('bug', 'ajaxGetUserBugs', 'account=' + account);
}
else if(type == 'task')
{
link = createLink('task', 'ajaxGetUserTasks', 'account=' + account);
}
if(type == 'bug' || type == 'task')
{
$('#nameBox').load(link);
}
else if(type == 'custom')
{
$('#nameBox').html(customHtml);
}
}
function selectNext()
{
endIndex = $("#begin ").get(0).selectedIndex + 2;
$("#end ").get(0).selectedIndex = endIndex;
}
function switchDateFeature(switcher)
{
if(switcher.checked)
{
$('#begin').attr('disabled','disabled');
$('#end').attr('disabled','disabled');
}
else
{
$('#begin').removeAttr('disabled');
$('#end').removeAttr('disabled');
}
}
selectNext();
</script>
<?php include '../../common/footer.html.php';?>