Projects management refactoring
This commit is contained in:
@@ -17,15 +17,9 @@ class Action extends Base
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$project = $this->project->getById($project_id);
|
||||
$project = $this->getProject();
|
||||
|
||||
if (! $project) {
|
||||
$this->session->flashError(t('Project not found.'));
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('action_index', array(
|
||||
$this->response->html($this->projectLayout('action_index', array(
|
||||
'values' => array('project_id' => $project['id']),
|
||||
'project' => $project,
|
||||
'actions' => $this->action->getAllByProject($project['id']),
|
||||
@@ -49,18 +43,11 @@ class Action extends Base
|
||||
*/
|
||||
public function params()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$project = $this->project->getById($project_id);
|
||||
|
||||
if (! $project) {
|
||||
$this->session->flashError(t('Project not found.'));
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
$project = $this->getProject();
|
||||
$values = $this->request->getValues();
|
||||
$action = $this->action->load($values['action_name'], $values['project_id']);
|
||||
|
||||
$this->response->html($this->template->layout('action_params', array(
|
||||
$this->response->html($this->projectLayout('action_params', array(
|
||||
'values' => $values,
|
||||
'action_params' => $action->getActionRequiredParameters(),
|
||||
'columns_list' => $this->board->getColumnsList($project['id']),
|
||||
@@ -81,14 +68,7 @@ class Action extends Base
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$project = $this->project->getById($project_id);
|
||||
|
||||
if (! $project) {
|
||||
$this->session->flashError(t('Project not found.'));
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
$project = $this->getProject();
|
||||
$values = $this->request->getValues();
|
||||
|
||||
list($valid,) = $this->action->validateCreation($values);
|
||||
@@ -113,10 +93,13 @@ class Action extends Base
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$this->response->html($this->template->layout('action_remove', array(
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('action_remove', array(
|
||||
'action' => $this->action->getById($this->request->getIntegerParam('action_id')),
|
||||
'available_events' => $this->action->getAvailableEvents(),
|
||||
'available_actions' => $this->action->getAvailableActions(),
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Remove an action')
|
||||
)));
|
||||
|
||||
@@ -211,6 +211,22 @@ abstract class Base
|
||||
return $this->template->layout('task_layout', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common layout for project views
|
||||
*
|
||||
* @access protected
|
||||
* @param string $template Template name
|
||||
* @param array $params Template parameters
|
||||
* @return string
|
||||
*/
|
||||
protected function projectLayout($template, array $params)
|
||||
{
|
||||
$content = $this->template->load($template, $params);
|
||||
$params['project_content_for_layout'] = $content;
|
||||
|
||||
return $this->template->layout('project_layout', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common method to get a task for task views
|
||||
*
|
||||
|
||||
@@ -212,12 +212,8 @@ class Board extends Base
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$project = $this->project->getById($project_id);
|
||||
|
||||
if (! $project) $this->notfound();
|
||||
|
||||
$columns = $this->board->getColumns($project_id);
|
||||
$project = $this->getProject();
|
||||
$columns = $this->board->getColumns($project['id']);
|
||||
$values = array();
|
||||
|
||||
foreach ($columns as $column) {
|
||||
@@ -225,9 +221,9 @@ class Board extends Base
|
||||
$values['task_limit['.$column['id'].']'] = $column['task_limit'] ?: null;
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('board_edit', array(
|
||||
$this->response->html($this->projectLayout('board_edit', array(
|
||||
'errors' => array(),
|
||||
'values' => $values + array('project_id' => $project_id),
|
||||
'values' => $values + array('project_id' => $project['id']),
|
||||
'columns' => $columns,
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
@@ -242,12 +238,8 @@ class Board extends Base
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$project = $this->project->getById($project_id);
|
||||
|
||||
if (! $project) $this->notfound();
|
||||
|
||||
$columns = $this->board->getColumns($project_id);
|
||||
$project = $this->getProject();
|
||||
$columns = $this->board->getColumns($project['id']);
|
||||
$data = $this->request->getValues();
|
||||
$values = $columns_list = array();
|
||||
|
||||
@@ -270,9 +262,9 @@ class Board extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('board_edit', array(
|
||||
$this->response->html($this->projectLayout('board_edit', array(
|
||||
'errors' => $errors,
|
||||
'values' => $values + array('project_id' => $project_id),
|
||||
'values' => $values + array('project_id' => $project['id']),
|
||||
'columns' => $columns,
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
@@ -287,11 +279,7 @@ class Board extends Base
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$project = $this->project->getById($project_id);
|
||||
|
||||
if (! $project) $this->notfound();
|
||||
|
||||
$project = $this->getProject();
|
||||
$columns = $this->board->getColumnsList($project_id);
|
||||
$data = $this->request->getValues();
|
||||
$values = array();
|
||||
@@ -313,7 +301,7 @@ class Board extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('board_edit', array(
|
||||
$this->response->html($this->projectLayout('board_edit', array(
|
||||
'errors' => $errors,
|
||||
'values' => $values + $data,
|
||||
'columns' => $columns,
|
||||
@@ -330,8 +318,11 @@ class Board extends Base
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$this->response->html($this->template->layout('board_remove', array(
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('board_remove', array(
|
||||
'column' => $this->board->getColumn($this->request->getIntegerParam('column_id')),
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Remove a column from a board')
|
||||
)));
|
||||
|
||||
@@ -38,7 +38,7 @@ class Category extends Base
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('category_index', array(
|
||||
$this->response->html($this->projectLayout('category_index', array(
|
||||
'categories' => $this->category->getList($project['id'], false),
|
||||
'values' => array('project_id' => $project['id']),
|
||||
'errors' => array(),
|
||||
@@ -71,7 +71,7 @@ class Category extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('category_index', array(
|
||||
$this->response->html($this->projectLayout('category_index', array(
|
||||
'categories' => $this->category->getList($project['id'], false),
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
@@ -91,7 +91,7 @@ class Category extends Base
|
||||
$project = $this->getProject();
|
||||
$category = $this->getCategory($project['id']);
|
||||
|
||||
$this->response->html($this->template->layout('category_edit', array(
|
||||
$this->response->html($this->projectLayout('category_edit', array(
|
||||
'values' => $category,
|
||||
'errors' => array(),
|
||||
'project' => $project,
|
||||
@@ -123,7 +123,7 @@ class Category extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('category_edit', array(
|
||||
$this->response->html($this->projectLayout('category_edit', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'project' => $project,
|
||||
@@ -142,7 +142,7 @@ class Category extends Base
|
||||
$project = $this->getProject();
|
||||
$category = $this->getCategory($project['id']);
|
||||
|
||||
$this->response->html($this->template->layout('category_remove', array(
|
||||
$this->response->html($this->projectLayout('category_remove', array(
|
||||
'project' => $project,
|
||||
'category' => $category,
|
||||
'menu' => 'projects',
|
||||
|
||||
@@ -13,26 +13,52 @@ use Core\Translator;
|
||||
*/
|
||||
class Project extends Base
|
||||
{
|
||||
/**
|
||||
* List of projects
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$projects = $this->project->getAll($this->acl->isRegularUser());
|
||||
$nb_projects = count($projects);
|
||||
$active_projects = array();
|
||||
$inactive_projects = array();
|
||||
|
||||
/**
|
||||
* Clone Project
|
||||
*
|
||||
* @author Antonio Rabelo
|
||||
* @access public
|
||||
*/
|
||||
public function duplicate()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
foreach ($projects as $project) {
|
||||
if ($project['is_active'] == 1) {
|
||||
$active_projects[] = $project;
|
||||
}
|
||||
else {
|
||||
$inactive_projects[] = $project;
|
||||
}
|
||||
}
|
||||
|
||||
if ($project_id && $this->project->duplicate($project_id)) {
|
||||
$this->session->flash(t('Project cloned successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to clone this project.'));
|
||||
}
|
||||
$this->response->html($this->template->layout('project_index', array(
|
||||
'active_projects' => $active_projects,
|
||||
'inactive_projects' => $inactive_projects,
|
||||
'nb_projects' => $nb_projects,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Projects').' ('.$nb_projects.')'
|
||||
)));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
/**
|
||||
* Show the project information page
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_show', array(
|
||||
'project' => $project,
|
||||
'stats' => $this->project->getStats($project['id']),
|
||||
'menu' => 'projects',
|
||||
'title' => $project['name'],
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Task export
|
||||
@@ -52,7 +78,7 @@ class Project extends Base
|
||||
$this->response->csv($data);
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('project_export', array(
|
||||
$this->response->html($this->projectLayout('project_export', array(
|
||||
'values' => array(
|
||||
'controller' => 'project',
|
||||
'action' => 'export',
|
||||
@@ -67,6 +93,319 @@ class Project extends Base
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Public access management
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function share()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_share', array(
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Public access'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable public access for a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function enablePublic()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->enablePublicAccess($project_id)) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=share&project_id='.$project_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable public access for a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function disablePublic()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->disablePublicAccess($project_id)) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=share&project_id='.$project_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a form to edit a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_edit', array(
|
||||
'errors' => array(),
|
||||
'values' => $project,
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Edit project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and update a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
$values = $this->request->getValues() + array('is_active' => 0);
|
||||
list($valid, $errors) = $this->project->validateModification($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->project->update($values)) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
$this->response->redirect('?controller=project&action=edit&project_id='.$project['id']);
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->projectLayout('project_edit', array(
|
||||
'errors' => $errors,
|
||||
'values' => $values,
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Edit Project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Users list for the selected project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_users', array(
|
||||
'project' => $project,
|
||||
'users' => $this->project->getAllUsers($project['id']),
|
||||
'menu' => 'projects',
|
||||
'title' => t('Edit project access list')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow a specific user for the selected project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function allow()
|
||||
{
|
||||
$values = $this->request->getValues();
|
||||
list($valid,) = $this->project->validateUserAccess($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->project->allowUser($values['project_id'], $values['user_id'])) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke user access
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function revoke()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
|
||||
$values = array(
|
||||
'project_id' => $this->request->getIntegerParam('project_id'),
|
||||
'user_id' => $this->request->getIntegerParam('user_id'),
|
||||
);
|
||||
|
||||
list($valid,) = $this->project->validateUserAccess($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->project->revokeUser($values['project_id'], $values['user_id'])) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirmation dialog before to remove a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function confirmRemove()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_remove', array(
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Remove project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->remove($project_id)) {
|
||||
$this->session->flash(t('Project removed successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to remove this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirmation dialog before to clone a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function confirmDuplicate()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_duplicate', array(
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Clone this project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate a project
|
||||
*
|
||||
* @author Antonio Rabelo
|
||||
* @access public
|
||||
*/
|
||||
public function duplicate()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->duplicate($project_id)) {
|
||||
$this->session->flash(t('Project cloned successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to clone this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirmation dialog before to disable a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function confirmDisable()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_disable', array(
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Project activation')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->disable($project_id)) {
|
||||
$this->session->flash(t('Project disabled successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to disable this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=show&project_id='.$project_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirmation dialog before to enable a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function confirmEnable()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->projectLayout('project_enable', array(
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Project activation')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function enable()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->enable($project_id)) {
|
||||
$this->session->flash(t('Project activated successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to activate this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=show&project_id='.$project_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Task search for a given project
|
||||
*
|
||||
@@ -138,24 +477,6 @@ class Project extends Base
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* List of projects
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$projects = $this->project->getAll(true, $this->acl->isRegularUser());
|
||||
$nb_projects = count($projects);
|
||||
|
||||
$this->response->html($this->template->layout('project_index', array(
|
||||
'projects' => $projects,
|
||||
'nb_projects' => $nb_projects,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Projects').' ('.$nb_projects.')'
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a form to create a new project
|
||||
*
|
||||
@@ -199,192 +520,4 @@ class Project extends Base
|
||||
'title' => t('New Project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a form to edit a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('project_edit', array(
|
||||
'errors' => array(),
|
||||
'values' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Edit project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and update a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$values = $this->request->getValues() + array('is_active' => 0);
|
||||
list($valid, $errors) = $this->project->validateModification($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->project->update($values)) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('project_edit', array(
|
||||
'errors' => $errors,
|
||||
'values' => $values,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Edit Project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirmation dialog before to remove a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('project_remove', array(
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Remove project')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->remove($project_id)) {
|
||||
$this->session->flash(t('Project removed successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to remove this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function enable()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->enable($project_id)) {
|
||||
$this->session->flash(t('Project activated successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to activate this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
|
||||
if ($project_id && $this->project->disable($project_id)) {
|
||||
$this->session->flash(t('Project disabled successfully.'));
|
||||
} else {
|
||||
$this->session->flashError(t('Unable to disable this project.'));
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Users list for the selected project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('project_users', array(
|
||||
'project' => $project,
|
||||
'users' => $this->project->getAllUsers($project['id']),
|
||||
'menu' => 'projects',
|
||||
'title' => t('Edit project access list')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow a specific user for the selected project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function allow()
|
||||
{
|
||||
$values = $this->request->getValues();
|
||||
list($valid,) = $this->project->validateUserAccess($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->project->allowUser($values['project_id'], $values['user_id'])) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke user access
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function revoke()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
|
||||
$values = array(
|
||||
'project_id' => $this->request->getIntegerParam('project_id'),
|
||||
'user_id' => $this->request->getIntegerParam('user_id'),
|
||||
);
|
||||
|
||||
list($valid,) = $this->project->validateUserAccess($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->project->revokeUser($values['project_id'], $values['user_id'])) {
|
||||
$this->session->flash(t('Project updated successfully.'));
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to update this project.'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user