Helpers refactoring
This commit is contained in:
@@ -9,51 +9,8 @@ use Pimple\Container;
|
||||
*
|
||||
* @package model
|
||||
* @author Frederic Guillot
|
||||
*
|
||||
* @property \Core\Session $session
|
||||
* @property \Core\Template $template
|
||||
* @property \Model\Acl $acl
|
||||
* @property \Model\Action $action
|
||||
* @property \Model\Authentication $authentication
|
||||
* @property \Model\Board $board
|
||||
* @property \Model\Budget $budget
|
||||
* @property \Model\Category $category
|
||||
* @property \Model\Comment $comment
|
||||
* @property \Model\CommentHistory $commentHistory
|
||||
* @property \Model\Color $color
|
||||
* @property \Model\Config $config
|
||||
* @property \Model\DateParser $dateParser
|
||||
* @property \Model\File $file
|
||||
* @property \Model\Helper $helper
|
||||
* @property \Model\LastLogin $lastLogin
|
||||
* @property \Model\Link $link
|
||||
* @property \Model\Notification $notification
|
||||
* @property \Model\Project $project
|
||||
* @property \Model\ProjectDuplication $projectDuplication
|
||||
* @property \Model\ProjectPermission $projectPermission
|
||||
* @property \Model\Subtask $subtask
|
||||
* @property \Model\SubtaskHistory $subtaskHistory
|
||||
* @property \Model\Swimlane $swimlane
|
||||
* @property \Model\Task $task
|
||||
* @property \Model\TaskCreation $taskCreation
|
||||
* @property \Model\TaskDuplication $taskDuplication
|
||||
* @property \Model\TaskExport $taskExport
|
||||
* @property \Model\TaskFinder $taskFinder
|
||||
* @property \Model\TaskHistory $taskHistory
|
||||
* @property \Model\TaskLink $taskLink
|
||||
* @property \Model\TaskPosition $taskPosition
|
||||
* @property \Model\TaskValidator $taskValidator
|
||||
* @property \Model\Timetable $timetable
|
||||
* @property \Model\TimetableDay $timetableDay
|
||||
* @property \Model\TimetableExtra $timetableExtra
|
||||
* @property \Model\TimetableOff $timetableOff
|
||||
* @property \Model\TimetableWeek $timetableWeek
|
||||
* @property \Model\SubtaskTimeTracking $subtaskTimeTracking
|
||||
* @property \Model\User $user
|
||||
* @property \Model\UserSession $userSession
|
||||
* @property \Model\Webhook $webhook
|
||||
*/
|
||||
abstract class Base
|
||||
abstract class Base extends \Core\Base
|
||||
{
|
||||
/**
|
||||
* Database instance
|
||||
@@ -63,14 +20,6 @@ abstract class Base
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* Container instance
|
||||
*
|
||||
* @access protected
|
||||
* @var \Pimple\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -83,18 +32,6 @@ abstract class Base
|
||||
$this->db = $this->container['db'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load automatically models
|
||||
*
|
||||
* @access public
|
||||
* @param string $name Model name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->container[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a record in the database
|
||||
*
|
||||
@@ -203,7 +140,7 @@ abstract class Base
|
||||
'backgroundColor' => $this->color->getBackgroundColor($task['color_id']),
|
||||
'borderColor' => $this->color->getBorderColor($task['color_id']),
|
||||
'textColor' => 'black',
|
||||
'url' => $this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])),
|
||||
'url' => $this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class SubtaskForecast extends Base
|
||||
'id' => $subtasks[$offset]['id'].'-'.$subtasks[$offset]['task_id'].'-'.$offset,
|
||||
'subtask_id' => $subtasks[$offset]['id'],
|
||||
'title' => t('#%d', $subtasks[$offset]['task_id']).' '.$subtasks[$offset]['title'],
|
||||
'url' => $this->helper->url('task', 'show', array('task_id' => $subtasks[$offset]['task_id'], 'project_id' => $subtasks[$offset]['project_id'])),
|
||||
'url' => $this->helper->url->to('task', 'show', array('task_id' => $subtasks[$offset]['task_id'], 'project_id' => $subtasks[$offset]['project_id'])),
|
||||
'editable' => false,
|
||||
'start' => date('Y-m-d\TH:i:s', $start),
|
||||
);
|
||||
|
||||
@@ -196,7 +196,7 @@ class SubtaskTimeTracking extends Base
|
||||
'backgroundColor' => $this->color->getBackgroundColor($row['color_id']),
|
||||
'borderColor' => $this->color->getBorderColor($row['color_id']),
|
||||
'textColor' => 'black',
|
||||
'url' => $this->helper->url('task', 'show', array('task_id' => $row['task_id'], 'project_id' => $row['project_id'])),
|
||||
'url' => $this->helper->url->to('task', 'show', array('task_id' => $row['task_id'], 'project_id' => $row['project_id'])),
|
||||
'editable' => false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ class TaskFilter extends Base
|
||||
$vEvent->setModified($dateModif);
|
||||
$vEvent->setUseTimezone(true);
|
||||
$vEvent->setSummary(t('#%d', $task['id']).' '.$task['title']);
|
||||
$vEvent->setUrl($this->helper->getCurrentBaseUrl().$this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
$vEvent->setUrl($this->helper->url->base().$this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
|
||||
if (! empty($task['creator_id'])) {
|
||||
$vEvent->setOrganizer('MAILTO:'.($task['creator_email'] ?: $task['creator_username'].'@kanboard.local'));
|
||||
|
||||
@@ -85,17 +85,6 @@ class UserSession extends Base
|
||||
return isset($this->session['user']['id']) ? (int) $this->session['user']['id'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given user_id is the connected user
|
||||
*
|
||||
* @param integer $user_id User id
|
||||
* @return boolean
|
||||
*/
|
||||
public function isCurrentUser($user_id)
|
||||
{
|
||||
return $this->getId() == $user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is the user is connected
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user