function assignTo($userId) { global $dbInst, $loginInst; if (!$loginInst->hasAccess("request.assignTo")) { return false; } $taskInst = new task(); $taskInst->subject = $this->subject; $taskInst->body = $this->body; $taskInst->projectId = $this->projectId; $taskInst->typeId = $this->typeId; $taskInst->priorityId = $this->priorityId; $taskInst->userId = $userId; $taskInst->statusId = TASK_STATUS_REQUEST; $taskInst->posterId = $loginInst->id; $taskInst->attachments = $this->attachments; $taskId = $taskInst->insert(); if (!$taskId) { return false; } // task saved successfully. Now whe can assign the attachments to the task id $taskInst->id = $taskId; while ($element = current($taskInst->attachments)) { $attachment = new attachment($element); $attachment->taskId = $taskId; $attachment->update(); next($taskInst->attachments); } // the attachments are now assigned to the task -> so we should // clean the attachment array in the request instance, to prevent // deleting of the attachments $this->attachments = array(); if ($this->delete()) { return $taskId; } return false; }
## perform action $recordType = "new"; $action = tool::securePost('action'); if ($action == "update") { $taskInst->id = tool::securePost('id'); $taskInst->fill(tool::securePostAll()); if ($taskInst->update()) { $taskInst->clear(); $recordType = "new"; } else { $recordType = "edit"; } } if ($action == "new") { $taskInst->fill(tool::securePostAll()); if ($taskInst->insert()) { $taskInst->clear(); } } if ($action == "search") { if (tool::securePost('lastrecordtype')) { $recordType = tool::securePost('lastrecordtype'); } $taskInst->fill(tool::securePostAll()); $taskInst->id = tool::securePost('id'); } if ($action == "delete") { $taskInst->id = tool::securePost('id'); $taskInst->delete(); } if ($action == "edit") {