diff --git a/upload/source/class/class_task.php b/upload/source/class/class_task.php index d25b59aa9c58c01d11927dce168094a416dadaea..c69e70f74eb38b6c3e4abf387d1e97801161cea7 100644 --- a/upload/source/class/class_task.php +++ b/upload/source/class/class_task.php @@ -395,7 +395,7 @@ class task { if($result === TRUE) { - if($this->task['reward']) { + if($this->task['reward'] && C::t('common_mytask')->update_to_success($_G['uid'], $id, $_G['timestamp']) && C::t('common_task')->update_achievers($id, 1)) { $rewards = $this->reward(); $notification = $this->task['reward']; if($this->task['reward'] == 'magic') { @@ -427,9 +427,6 @@ class task { $taskclass->sufprocess($this->task); } - C::t('common_mytask')->update($_G['uid'], $id, array('status' => 1, 'csc' => 100, 'dateline' => $_G['timestamp'])); - C::t('common_task')->update_achievers($id, 1); - if($_G['inajax']) { $this->message('100', $this->task['reward'] ? 'task_reward_'.$this->task['reward'] : 'task_completed', array( 'creditbonus' => $_G['setting']['extcredits'][$this->task['prize']]['title'].' '.$this->task['bonus'].' '.$_G['setting']['extcredits'][$this->task['prize']]['unit'], diff --git a/upload/source/class/table/table_common_mytask.php b/upload/source/class/table/table_common_mytask.php index 0020d17af2328d0dafa7eded37c5df73bd100675..ab82d6af021d134c4cc61ea72559a511e6ce2d35 100644 --- a/upload/source/class/table/table_common_mytask.php +++ b/upload/source/class/table/table_common_mytask.php @@ -64,6 +64,10 @@ class table_common_mytask extends discuz_table return DB::fetch_first("SELECT * FROM %t WHERE uid=%d AND taskid=%d", array($this->_table, $uid, $taskid)); } + public function update_to_success($uid, $taskid, $timestamp) { + return DB::query('UPDATE '.DB::table($this->_table)." SET status = '1', csc = '100', dateline = '".intval($timestamp)."' WHERE taskid = '".intval($taskid)."' AND uid = '".intval($uid)."' AND status != '1'"); + } + } ?> \ No newline at end of file diff --git a/upload/source/class/table/table_common_task.php b/upload/source/class/table/table_common_task.php index 4788cb2012d6bb312875f91838a6cbe464f3c9ae..264887727bc3b38830949e491dde01f0170bddad 100644 --- a/upload/source/class/table/table_common_task.php +++ b/upload/source/class/table/table_common_task.php @@ -49,7 +49,7 @@ class table_common_task extends discuz_table } public function update_achievers($taskid, $v) { - DB::query("UPDATE %t SET achievers=achievers+%s WHERE taskid=%d", array($this->_table, $v, $taskid)); + return DB::query("UPDATE %t SET achievers=achievers+%s WHERE taskid=%d", array($this->_table, $v, $taskid)); } public function update_available() {