-
Notifications
You must be signed in to change notification settings - Fork 19
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
Showing
901 changed files
with
68,966 additions
and
28,074 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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace MintHCM\Api\Controllers\Module; | ||
|
||
use Psr\Http\Message\ServerRequestInterface as Request; | ||
use Slim\Exception\HttpForbiddenException; | ||
use Slim\Exception\HttpNotFoundException; | ||
use Slim\Psr7\Response; | ||
use Slim\Routing\RouteContext; | ||
use Slim\Exception\HttpBadRequestException; | ||
|
||
class ListMassActionsController | ||
{ | ||
public function __invoke(Request $request, Response $response, array $args): Response | ||
{ | ||
$action = $request->getAttribute('action'); | ||
$ids = $request->getAttribute('ids'); | ||
|
||
$routeContext = RouteContext::fromRequest($request); | ||
$route = $routeContext->getRoute(); | ||
$module = explode('/', $route->getPattern())[1] ?? ''; | ||
|
||
if (empty($module) || empty($action) || empty($ids)) { | ||
throw new HttpBadRequestException($request); | ||
} | ||
|
||
$mass_action_class = 'MintHCM\\Data\\MassActions\\Actions\\' . $action; | ||
if (!class_exists($mass_action_class)) { | ||
throw new HttpNotFoundException($request); | ||
} | ||
|
||
$mass_action = new $mass_action_class($module, $ids); | ||
|
||
if (!$mass_action->hasAccess()) { | ||
throw new HttpForbiddenException($request); | ||
} | ||
|
||
$result = $mass_action->execute(); | ||
|
||
$response->getBody()->write(json_encode($result)); | ||
return $response; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace MintHCM\Data\MassActions\Actions; | ||
|
||
use MintHCM\Data\MassActions\MassAction; | ||
|
||
class Delete extends MassAction | ||
{ | ||
const ICON = 'mdi-delete'; | ||
const LABEL = 'LBL_DELETE'; | ||
|
||
public function execute() | ||
{ | ||
$result = [ | ||
'success' => false, | ||
'beans_access' => false, | ||
]; | ||
|
||
if (!$this->hasAccess()) { | ||
return $result; | ||
} | ||
|
||
$beans = $this->getBeans(); | ||
|
||
chdir('../legacy'); | ||
foreach ($beans as $bean) { | ||
if (!$bean->ACLAccess('delete')) { | ||
return $result; | ||
} | ||
} | ||
|
||
$result['beans_access'] = true; | ||
|
||
foreach ($beans as $bean) { | ||
$bean->mark_deleted($bean->id); | ||
} | ||
chdir('../api'); | ||
|
||
$result['success'] = true; | ||
return $result; | ||
} | ||
|
||
public function hasAccess() | ||
{ | ||
chdir('../legacy'); | ||
$has_access = \ACLController::checkAccess($this->module_name, 'delete', true); | ||
chdir('../api'); | ||
return $has_access; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace MintHCM\Data\MassActions\Actions; | ||
|
||
use MintHCM\Data\MassActions\MassAction; | ||
|
||
class Export extends MassAction | ||
{ | ||
const ICON = 'mdi-export'; | ||
const LABEL = 'LBL_EXPORT'; | ||
|
||
public function execute() | ||
{ | ||
throw new \Exception('Export is implemented in legacy code.'); | ||
} | ||
|
||
public function hasAccess() | ||
{ | ||
chdir('../legacy'); | ||
$has_access = \ACLController::checkAccess($this->module_name, 'export', true); | ||
chdir('../api'); | ||
return $has_access; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace MintHCM\Data\MassActions\Actions; | ||
|
||
use MintHCM\Data\MassActions\MassAction; | ||
|
||
class Merge extends MassAction | ||
{ | ||
const ICON = 'mdi-merge'; | ||
const LABEL = 'LBL_MERGE_DUPLICATES'; | ||
|
||
public function execute() | ||
{ | ||
throw new \Exception('Merge is implemented in legacy code.'); | ||
} | ||
|
||
public function hasAccess() | ||
{ | ||
chdir('../legacy'); | ||
global $dictionary; | ||
$has_access = ( | ||
!empty($dictionary[$this->module_name]['duplicate_merge']) | ||
&& \ACLController::checkAccess($this->module_name, 'edit', true) | ||
&& \ACLController::checkAccess($this->module_name, 'delete', true) | ||
); | ||
chdir('../api'); | ||
return $has_access; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace MintHCM\Data\MassActions; | ||
|
||
abstract class MassAction | ||
{ | ||
const ICON = ''; | ||
const LABEL = ''; | ||
|
||
protected $module_name; | ||
protected $ids; | ||
|
||
public function __construct($module_name, $ids) | ||
{ | ||
$this->module_name = $module_name; | ||
$this->ids = $ids; | ||
} | ||
|
||
public abstract function execute(); | ||
public abstract function hasAccess(); | ||
|
||
public function getFrontendData() | ||
{ | ||
return [ | ||
'icon' => static::ICON, | ||
'label' => static::LABEL, | ||
'action' => (new \ReflectionClass($this))->getShortName(), | ||
]; | ||
} | ||
|
||
protected function getBeans() | ||
{ | ||
if (empty($this->ids)) { | ||
return []; | ||
} | ||
chdir('../legacy'); | ||
$seed = \BeanFactory::getBean($this->module_name); | ||
$db = \DBManagerFactory::getInstance(); | ||
$beans = $seed->get_full_list('', "{$seed->table_name}.id IN ({$db->implodeQuoted($this->ids)})"); | ||
chdir('../api'); | ||
return $beans ?? []; | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.