本文整理汇总了PHP中task::start方法的典型用法代码示例。如果您正苦于以下问题:PHP task::start方法的具体用法?PHP task::start怎么用?PHP task::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task
的用法示例。
在下文中一共展示了task::start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gallery_shutdown
/**
* At this point, the output has been sent to the browser, so we can take some time
* to run a schedule task.
*/
static function gallery_shutdown()
{
try {
$schedule = ORM::factory("schedule")->where("next_run_datetime", "<=", time())->where("busy", "!=", 1)->order_by("next_run_datetime")->find_all(1);
if ($schedule->count()) {
$schedule = $schedule->current();
$schedule->busy = true;
$schedule->save();
try {
if (empty($schedule->task_id)) {
$task = task::start($schedule->task_callback);
$schedule->task_id = $task->id;
}
$task = task::run($schedule->task_id);
if ($task->done) {
$schedule->next_run_datetime += $schedule->interval;
$schedule->task_id = null;
}
$schedule->busy = false;
$schedule->save();
} catch (Exception $e) {
$schedule->busy = false;
$schedule->save();
throw $e;
}
}
} catch (Exception $e) {
Kohana_Log::add("error", (string) $e);
}
}
示例2: start
/**
* Start a new task
* @param string $task_callback
*/
public function start($task_callback)
{
access::verify_csrf();
$task = task::start($task_callback);
$view = new View("admin_maintenance_task.html");
$view->task = $task;
log::info("tasks", t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor("admin/maintenance", t("maintenance")));
print $view;
}
示例3: update
/**
* boolean update()
* updates a task in database
* @return true on success, else false
* @access public
*/
function update()
{
global $dbInst, $config, $toolInst, $loginInst;
if (!$loginInst->hasAccess("task.update")) {
return false;
}
if (!$this->check()) {
return false;
}
if ($this->id == $this->mountId) {
$toolInst->errorStatus("recursion error: unable to mount task into itself");
return false;
}
if (in_array($this->id, $this->treeId($this->mountId))) {
$toolInst->errorStatus("recursion error: unable to mount task into one of its members");
return false;
}
$query = "update " . $dbInst->config['table_task'] . " set " . "finish = '" . $this->finish . "'," . "plannedhours = '" . $this->plannedHours . "',";
if ($loginInst->hasAccess("task.fixedPrice")) {
$query .= "fixedprice = '" . str_replace(',', '.', $this->fixedPrice) . "',";
}
$query .= "body = '" . $this->body . "'," . "type_id = '" . $this->typeId . "'," . "user_id = '" . $this->userId . "'," . "subject = '" . $this->subject . "'," . "mount_id = '" . $this->mountId . "'," . "status_id = '" . $this->statusId . "'," . "poster_id = '" . $this->posterId . "'," . "project_id = '" . $this->projectId . "'," . "priority_id = '" . $this->priorityId . "' where id = '" . $this->id . "'";
$result = $dbInst->query($query);
$dbInst->status($result[1], "u");
if ($result[1] == 1 || $result[1] == 0) {
// notification mail to manager, if task set to done
if ($result[1] == 1 && $this->isDone()) {
$projectInst = new project($this->projectId);
$this->mail($projectInst->managerId, " --== TASK DONE ==--\n\nused time: " . $toolInst->formatTime($this->getSummary()));
}
// logging
$userInst = new user($this->userId);
$this->logger->info("changed task (" . $this->subject . ") for " . $userInst->name);
if (tool::secureFiles('userfile', 'name') && @file_exists(tool::secureFiles('userfile', 'tmp_name'))) {
// attachment successfully uploaded, we can save it
$attach = new attachment();
$attach->taskId = $this->id;
$attach->insert();
$this->logger->info("added attachment (" . $this->file . ") to task " . $this->subject);
unset($_FILES['userfile']);
}
// process all childs
$childs = $this->childs();
while ($element = current($childs)) {
$child = new task($element);
// we need to update the project id in all child tasks
$child->projectId = $this->projectId;
// task is set to status "done", we should start all child tasks now
if ($this->isDone()) {
$child->start();
$child->mail($child->userId, "There's an automatically started task for you:");
}
$child->update();
next($childs);
}
return true;
}
return false;
}
示例4: start
function start()
{
global $dbInst, $loginInst, $toolInst;
if (!$loginInst->hasAccess("job.start")) {
return false;
}
if (!$this->check()) {
return false;
}
if (isset($this->id)) {
$otherTask = $dbInst->getValue("select task_id from " . $dbInst->config['table_job'] . " where id != '" . $this->id . "' and user_id = '{$loginInst->id}' and stop = '0'");
if ($otherTask) {
$taskInst = new task($otherTask);
$toolInst->errorStatus("theres allready a running job in "" . substr($taskInst->subject, 0, 20) . "..."");
return false;
}
}
// set task to "in progress"
$taskInst = new task($this->taskId);
$taskInst->start();
$taskInst->update();
$query = "insert into " . $dbInst->config['table_job'] . " " . "(task_id,user_id,comment,start,stop,flags) " . "values (" . "'" . $this->taskId . "'," . "'" . $loginInst->id . "'," . "'" . $this->comment . "'," . "'" . $this->start . "'," . "'0'," . "'" . $this->flags . "')";
$result = $dbInst->query($query);
$id = $dbInst->getValue("select distinct last_insert_id() from " . $dbInst->config['table_job']);
$dbInst->status($result[1], "i");
if ($result[1] == 1 || $result[1] == 0) {
return $id;
} else {
return false;
}
}