-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4e0b11
commit a2fd8f8
Showing
7 changed files
with
438 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,69 @@ | ||
<?php | ||
|
||
/** | ||
* Controller / Delete Canvas | ||
* delCanvas class - Generic canvas controller / Delete Canvas | ||
*/ | ||
|
||
|
||
namespace Leantime\Domain\Goalcanvas\Controllers { | ||
|
||
// use AWS\CRT\HTTP\Response; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
use Leantime\Core\Controller; | ||
use Leantime\Domain\Auth\Models\Roles; | ||
use Leantime\Domain\Auth\Services\Auth; | ||
use Illuminate\Support\Str; | ||
use Leantime\Core\Frontcontroller; | ||
|
||
/** | ||
* | ||
*/ | ||
class DelCanvas extends \Leantime\Domain\Canvas\Controllers\DelCanvas | ||
class DelCanvas extends Controller | ||
{ | ||
/** | ||
* Constant that must be redefined | ||
*/ | ||
protected const CANVAS_NAME = 'goal'; | ||
|
||
public function get($params):Response | ||
private mixed $canvasRepo; | ||
|
||
/** | ||
* init - initialize private variables | ||
*/ | ||
public function init() | ||
{ | ||
$canvasName = Str::studly(static::CANVAS_NAME) . 'canvas'; | ||
$repoName = app()->getNamespace() . "Domain\\$canvasName\\Repositories\\$canvasName"; | ||
$this->canvasRepo = app()->make($repoName); | ||
} | ||
|
||
/** | ||
* run - display template and edit data | ||
* | ||
* @access public | ||
*/ | ||
public function run() | ||
{ | ||
$id = filter_var($params['id'] ?? '', FILTER_SANITIZE_NUMBER_INT); | ||
$this->tpl->assign('id', $id); | ||
|
||
return $this->tpl->displayPartial('goalcanvas.delCanvas'); | ||
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]); | ||
|
||
if (isset($_POST['del']) && isset($_GET['id'])) { | ||
$id = (int)($_GET['id']); | ||
$this->canvasRepo->deleteCanvas($id); | ||
|
||
$allCanvas = $this->canvasRepo->getAllCanvas(session("currentProject")); | ||
session(["current' . strtoupper(static::CANVAS_NAME) . 'Canvas" => $allCanvas[0]['id'] ?? -1]); | ||
|
||
$this->tpl->setNotification($this->language->__('notification.board_deleted'), 'success', strtoupper(static::CANVAS_NAME) . 'canvas_deleted'); | ||
|
||
$allCanvas = $this->canvasRepo->getAllCanvas(session("currentProject")); | ||
|
||
//Create default canvas. | ||
if (!$allCanvas || count($allCanvas) == 0) { | ||
return Frontcontroller::redirect(BASE_URL . '/strategy/showBoards'); | ||
} else { | ||
return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas/showCanvas'); | ||
} | ||
} | ||
|
||
return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.delCanvas'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,57 @@ | ||
<?php | ||
|
||
/** | ||
* Controller / Delete Canvas Item | ||
* delCanvasItem class - Generic canvas controller / Delete Canvas Item | ||
*/ | ||
|
||
namespace Leantime\Domain\Goalcanvas\Controllers { | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
use Leantime\Core\Controller; | ||
use Leantime\Domain\Auth\Models\Roles; | ||
use Leantime\Domain\Auth\Services\Auth; | ||
use Illuminate\Support\Str; | ||
use Leantime\Core\Frontcontroller; | ||
|
||
/** | ||
* | ||
*/ | ||
class DelCanvasItem extends \Leantime\Domain\Canvas\Controllers\DelCanvasItem | ||
class DelCanvasItem extends Controller | ||
{ | ||
/** | ||
* Constant that must be redefined | ||
*/ | ||
protected const CANVAS_NAME = 'goal'; | ||
public function get($params):Response | ||
{ | ||
$id = filter_var($params['id'] ?? '', FILTER_SANITIZE_NUMBER_INT); | ||
$this->tpl->assign('id', $id); | ||
|
||
return $this->tpl->displayPartial('goalcanvas.delCanvasItem'); | ||
private mixed $canvasRepo; | ||
|
||
/** | ||
* init - initialize private variables | ||
*/ | ||
public function init() | ||
{ | ||
$canvasName ='goalcanvas'; | ||
$repoName = app()->getNamespace() . "Domain\\goalcanvas\\Repositories\\goalcanvas"; | ||
$this->canvasRepo = app()->make($repoName); | ||
} | ||
|
||
} | ||
/** | ||
* run - display template and edit data | ||
* | ||
* @access public | ||
*/ | ||
public function run() | ||
{ | ||
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]); | ||
|
||
if (isset($_POST['del']) && isset($_GET['id'])) { | ||
$id = (int)($_GET['id']); | ||
$this->canvasRepo->delCanvasItem($id); | ||
|
||
$this->tpl->setNotification($this->language->__('notification.element_deleted'), 'success', strtoupper(static::CANVAS_NAME) . 'canvasitem_deleted'); | ||
return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas/showCanvas'); | ||
} | ||
|
||
return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.delCanvasItem'); | ||
} | ||
} | ||
} |
Oops, something went wrong.