|
<?php |
|
|
|
namespace Kanboard\Model; |
|
|
|
use Kanboard\Core\Base; |
|
use PicoDb\Table; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectActivityModel extends Base |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
const TABLE = 'project_activities'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function createEvent($project_id, $task_id, $creator_id, $event_name, array $data) |
|
{ |
|
return $this->db->table(self::TABLE)->insert(array( |
|
'project_id' => $project_id, |
|
'task_id' => $task_id, |
|
'creator_id' => $creator_id, |
|
'event_name' => $event_name, |
|
'date_creation' => time(), |
|
'data' => json_encode($data), |
|
)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getQuery() |
|
{ |
|
return $this |
|
->db |
|
->table(ProjectActivityModel::TABLE) |
|
->columns( |
|
ProjectActivityModel::TABLE.'.*', |
|
'uc.username AS author_username', |
|
'uc.name AS author_name', |
|
'uc.email', |
|
'uc.avatar_path' |
|
) |
|
->join(TaskModel::TABLE, 'id', 'task_id') |
|
->join(ProjectModel::TABLE, 'id', 'project_id') |
|
->left(UserModel::TABLE, 'uc', 'id', ProjectActivityModel::TABLE, 'creator_id'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function cleanup($ts) |
|
{ |
|
$this->db->table(self::TABLE)->lt('date_creation', $ts)->remove(); |
|
} |
|
} |
|
|