Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated code style for calendar namespace #2327

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 53 additions & 48 deletions app/Domain/Calendar/Controllers/AddEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,70 @@
*
*/

namespace Leantime\Domain\Calendar\Controllers {
namespace Leantime\Domain\Calendar\Controllers;

use Leantime\Core\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Domain\Calendar\Services\Calendar;
use Symfony\Component\HttpFoundation\Response;
use Leantime\Core\Frontcontroller;
use Leantime\Core\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Domain\Calendar\Services\Calendar;
use Symfony\Component\HttpFoundation\Response;
use Leantime\Core\Frontcontroller;

/**
*
*/
class AddEvent extends Controller
{
private Calendar $calendarService;

/**
* init - initialize private variables
*
* @param Calendar $calendarService
* @return void
*/
class AddEvent extends Controller
public function init(Calendar $calendarService): void
{
private Calendar $calendarService;
$this->calendarService = $calendarService;
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]);
}

/**
* init - initialize private variables
*/
public function init(Calendar $calendarService)
{
$this->calendarService = $calendarService;
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]);
}
/**
* @param array $params
*
* @return Response
*/
public function get(array $params): Response
{
$values = array(
'description' => '',
'dateFrom' => '',
'dateTo' => '',
'allDay' => '',
);

/**
* @return Response
* @throws \Exception
*/
public function get(): Response
{
$values = array(
'description' => '',
'dateFrom' => '',
'dateTo' => '',
'allDay' => '',
);
$this->tpl->assign('values', $values);
return $this->tpl->displayPartial('calendar.addEvent');
}

$this->tpl->assign('values', $values);
return $this->tpl->displayPartial('calendar.addEvent');
}
/**
* @param array $params
*
* @return Response
*/
public function post(array $params): Response
{
$result = $this->calendarService->addEvent($params);

/**
* @param $params
* @return Response
* @throws \Exception
*/
public function post($params): Response
{
$result = $this->calendarService->addEvent($params);
if (is_numeric($result) === true) {
$this->tpl->setNotification('notification.event_created_successfully', 'success');

if (is_numeric($result) === true) {
$this->tpl->setNotification('notification.event_created_successfully', 'success');
return Frontcontroller::redirect(BASE_URL . "/calendar/editEvent/" . $result);
} else {
$this->tpl->setNotification('notification.please_enter_title', 'error');
$this->tpl->assign('values', $params);
return $this->tpl->displayPartial('calendar.addEvent');
}
return Frontcontroller::redirect(BASE_URL . "/calendar/editEvent/" . $result);
} else {
$this->tpl->setNotification('notification.please_enter_title', 'error');
$this->tpl->assign('values', $params);

return $this->tpl->displayPartial('calendar.addEvent');
}
}
}
104 changes: 57 additions & 47 deletions app/Domain/Calendar/Controllers/DelEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,76 @@
*
*/

namespace Leantime\Domain\Calendar\Controllers {
namespace Leantime\Domain\Calendar\Controllers;

use Leantime\Core\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Calendar\Services\Calendar as CalendarService;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Core\Frontcontroller;
use Leantime\Core\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Calendar\Services\Calendar as CalendarService;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Core\Frontcontroller;
use Symfony\Component\HttpFoundation\Response;

/**
*
*/
class DelEvent extends Controller
{
private CalendarService $calendarService;

/**
* init - initialize private variables
*
* @param CalendarService $calendarService
*
* @return void
*/
class DelEvent extends Controller
public function init(CalendarService $calendarService): void
{
private CalendarService $calendarService;
$this->calendarService = $calendarService;
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]);
}

/**
* init - initialize private variables
*/
public function init(CalendarService $calendarService)
{
$this->calendarService = $calendarService;
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]);
}
/**
* retrieves delete calendar event page data
*
* @access public
*
* @param array $params
*
* @return Response
*/
public function get(array $params): Response
{
return $this->tpl->displayPartial('calendar.delEvent');
}

/**
* retrieves delete calendar event page data
*
* @access public
*
*/
public function get()
{
return $this->tpl->displayPartial('calendar.delEvent');
}
/**
* sets, creates, and updates edit calendar event page data
*
* @access public
*
* @param array $params
*
* @return Response
*/
public function post(array $params): Response
{

/**
* sets, creates, and updates edit calendar event page data
*
* @access public
*
*/
public function post($params)
{
if (isset($_GET['id']) === false) {
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
}

if (isset($_GET['id']) === false) {
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
}
$id = (int) $_GET['id'];
$result = $this->calendarService->delEvent($id);

$id = (int)$_GET['id'];
if (is_numeric($result) === true) {
$this->tpl->setNotification('notification.event_removed_successfully', 'success');

$result = $this->calendarService->delEvent($id);
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
} else {
$this->tpl->setNotification('notification.could_not_delete_event', 'error');

if (is_numeric($result) === true) {
$this->tpl->setNotification('notification.event_removed_successfully', 'success');
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
} else {
$this->tpl->setNotification('notification.could_not_delete_event', 'error');
return $this->tpl->displayPartial('calendar.delEvent');
}
return $this->tpl->displayPartial('calendar.delEvent');
}
}

}
103 changes: 57 additions & 46 deletions app/Domain/Calendar/Controllers/DelExternalCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,77 @@
*
*/

namespace Leantime\Domain\Calendar\Controllers {
namespace Leantime\Domain\Calendar\Controllers;

use Leantime\Core\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Calendar\Services\Calendar as CalendarService;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Core\Frontcontroller;
use Leantime\Core\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Calendar\Services\Calendar as CalendarService;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Core\Frontcontroller;
use Symfony\Component\HttpFoundation\Response;

/**
*
*/
class DelExternalCalendar extends Controller
{
private CalendarService $calendarService;

/**
* init - initialize private variables
*
* @param CalendarService $calendarService
*
* @return void
*/
class DelExternalCalendar extends Controller
public function init(CalendarService $calendarService): void
{
private CalendarService $calendarService;
$this->calendarService = $calendarService;
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]);
}

/**
* init - initialize private variables
*/
public function init(CalendarService $calendarService)
{
$this->calendarService = $calendarService;
Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]);
}
/**
* retrieves delete calendar event page data
*
* @access public
*
* @param array $params
*
* @return Response
*/
public function get(array $params): Response
{
return $this->tpl->displayPartial('calendar.delExternalCal');
}

/**
* retrieves delete calendar event page data
*
* @access public
*
*/
public function get()
{
return $this->tpl->displayPartial('calendar.delExternalCal');
/**
* sets, creates, and updates edit calendar event page data
*
* @access public
*
* @param array $params
*
* @return Response
*/
public function post(array $params): Response
{

if (isset($_GET['id']) === false) {
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
}

/**
* sets, creates, and updates edit calendar event page data
*
* @access public
*
*/
public function post($params)
{
$id = (int)$_GET['id'];

if (isset($_GET['id']) === false) {
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
}
$result = $this->calendarService->deleteGCal($id);

$id = (int)$_GET['id'];
if ($result === true) {
$this->tpl->setNotification('notification.calendar_removed_successfully', 'success');

$result = $this->calendarService->deleteGCal($id);
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
} else {
$this->tpl->setNotification('notification.could_not_delete_calendar', 'error');

if ($result === true) {
$this->tpl->setNotification('notification.calendar_removed_successfully', 'success');
return Frontcontroller::redirect(BASE_URL . "/calendar/showMyCalendar/");
} else {
$this->tpl->setNotification('notification.could_not_delete_calendar', 'error');
return $this->tpl->displayPartial('calendar.delEvent');
}
return $this->tpl->displayPartial('calendar.delEvent');
}
}

}
Loading
Loading