1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kanboard_ynh.git synced 2024-09-03 19:36:17 +02:00
kanboard_ynh/sources/app/Model/Task.php

78 lines
1.6 KiB
PHP
Raw Normal View History

2014-07-20 12:26:15 +02:00
<?php
namespace Model;
/**
* Task model
*
* @package model
* @author Frederic Guillot
*/
class Task extends Base
{
/**
* SQL table name
*
* @var string
*/
const TABLE = 'tasks';
/**
* Task status
*
* @var integer
*/
const STATUS_OPEN = 1;
const STATUS_CLOSED = 0;
/**
* Events
*
* @var string
*/
2014-10-22 19:59:09 +02:00
const EVENT_MOVE_COLUMN = 'task.move.column';
const EVENT_MOVE_POSITION = 'task.move.position';
const EVENT_UPDATE = 'task.update';
const EVENT_CREATE = 'task.create';
const EVENT_CLOSE = 'task.close';
const EVENT_OPEN = 'task.open';
const EVENT_CREATE_UPDATE = 'task.create_update';
const EVENT_ASSIGNEE_CHANGE = 'task.assignee_change';
2014-07-20 12:26:15 +02:00
/**
* Remove a task
*
* @access public
* @param integer $task_id Task id
* @return boolean
*/
public function remove($task_id)
{
2014-11-23 20:13:38 +01:00
if (! $this->taskFinder->exists($task_id)) {
2014-10-22 19:59:09 +02:00
return false;
}
$this->file->removeAll($task_id);
2014-07-20 12:26:15 +02:00
return $this->db->table(self::TABLE)->eq('id', $task_id)->remove();
}
/**
2014-11-23 20:13:38 +01:00
* Get a the task id from a text
2014-07-20 12:26:15 +02:00
*
2014-11-23 20:13:38 +01:00
* Example: "Fix bug #1234" will return 1234
2014-10-22 19:59:09 +02:00
*
* @access public
2014-11-23 20:13:38 +01:00
* @param string $message Text
2014-10-22 19:59:09 +02:00
* @return integer
*/
2014-11-23 20:13:38 +01:00
public function getTaskIdFromText($message)
2014-10-22 19:59:09 +02:00
{
2014-11-23 20:13:38 +01:00
if (preg_match('!#(\d+)!i', $message, $matches) && isset($matches[1])) {
return $matches[1];
2014-10-22 19:59:09 +02:00
}
2014-11-23 20:13:38 +01:00
return 0;
2014-10-22 19:59:09 +02:00
}
2014-07-20 12:26:15 +02:00
}