home_task.php
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_task.php 27146 2012-01-06 09:34:49Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_G['disabledwidthauto'] = 0;
require_once libfile('function/spacecp');
if(!$_G['setting']['taskon'] && $_G['adminid'] != 1) {
showmessage('task_close');
}
require_once libfile('class/task');
$tasklib = & task::instance();
$_G['mnid'] = 'mn_common';
$id = intval($_GET['id']);
$do = empty($_GET['do']) ? '' : $_GET['do'];
if(empty($_G['uid'])) {
showmessage('to_login', null, array(), array('showmsg' => true, 'login' => 1));
}
$navtitle = lang('core', 'title_task');
if(empty($do)) {
$_GET['item'] = empty($_GET['item']) ? 'new' : $_GET['item'];
$actives = array($_GET['item'] => ' class="a"');
$tasklist = $tasklib->tasklist($_GET['item']);
$listdata = $tasklib->listdata;
if($_GET['item'] == 'doing' && empty($tasklist)) {
dsetcookie('taskdoing_'.$_G['uid']);
}
} elseif($do == 'view' && $id) {
cleartaskstatus();
$allowapply = $tasklib->view($id);
$task = & $tasklib->task;
$taskvars = & $tasklib->taskvars;
} elseif($do == 'apply' && $id) {
if(!$_G['uid']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
$result = $tasklib->apply($id);
if($result === -1) {
showmessage('task_relatedtask', 'home.php?mod=task&do=view&id='.$tasklib->task['relatedtaskid']);
} elseif($result === -2) {
showmessage('task_grouplimit', 'home.php?mod=task&item=new');
} elseif($result === -3) {
showmessage('task_duplicate', 'home.php?mod=task&item=new');
} elseif($result === -4) {
showmessage('task_nextperiod', 'home.php?mod=task&item=new');
} else {
dsetcookie('taskdoing_'.$_G['uid'], 1, 7776000);
showmessage('task_applied', 'home.php?mod=task&do=view&id='.$id);
}
} elseif($do == 'delete' && $id) {
$result = $tasklib->delete($id);
showmessage('task_deleted', 'home.php?mod=task&item=doing');
} elseif($do == 'draw' && $id) {
if(!$_G['uid']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
$result = $tasklib->draw($id);
if($result === -1) {
showmessage('task_up_to_limit', 'home.php?mod=task', array('tasklimits' => $tasklib->task['tasklimits']));
} elseif($result === -2) {
showmessage('task_failed', 'home.php?mod=task&item=failed');
} elseif($result === -3) {
showmessage($tasklib->messagevalues['msg'], 'home.php?mod=task&do=view&id='.$id, $tasklib->messagevalues['values']);
} else {
cleartaskstatus();
showmessage('task_completed', 'home.php?mod=task&item=done');
}
} elseif($do == 'giveup' && $id) {
$tasklib->giveup($id);
showmessage('task_giveup', 'home.php?mod=task&item=view&id='.$id);
} elseif($do == 'parter' && $id) {
$parterlist = $tasklib->parter($id);
include template('home/space_task_parter');
dexit();
} else {
showmessage('undefined_action');
}
include template('home/space_task');
function cleartaskstatus() {
global $_G;
if(!C::t('common_mytask')->count($_G['uid'], false, 0)) {
dsetcookie('taskdoing_'.$_G['uid']);
}
}
?>