mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-03-29 20:33:17 -04:00
Improve code style and PSR-12 compliance (#4204)
* Improve code style and PSR-12 compliance - refactored code formatting to adhere to PSR-12 guidelines - standardized coding conventions across the codebase - added missing framework files and reverted markup changes - reformatted arrays for enhanced readability - updated language files for consistent styling and clarity - minor miscellaneous improvements
This commit is contained in:
@@ -29,8 +29,7 @@ class Module extends Model
|
||||
$builder = $this->db->table('modules');
|
||||
$query = $builder->getWhere(['module_id' => $module_id], 1);
|
||||
|
||||
if($query->getNumRows() == 1) //TODO: ===
|
||||
{
|
||||
if ($query->getNumRows() == 1) { // TODO: ===
|
||||
$row = $query->getRow();
|
||||
|
||||
return lang($row->name_lang_key);
|
||||
@@ -43,13 +42,12 @@ class Module extends Model
|
||||
* @param string $module_id
|
||||
* @return string
|
||||
*/
|
||||
public function get_module_desc(string $module_id): string //TODO: This method doesn't seem to be called in the code. Is it needed? Also, probably should change the name to get_module_description()
|
||||
public function get_module_desc(string $module_id): string // TODO: This method doesn't seem to be called in the code. Is it needed? Also, probably should change the name to get_module_description()
|
||||
{
|
||||
$builder = $this->db->table('modules');
|
||||
$query = $builder->getWhere(['module_id' => $module_id], 1);
|
||||
|
||||
if($query->getNumRows() == 1) //TODO: ===
|
||||
{
|
||||
if ($query->getNumRows() == 1) { // TODO: ===
|
||||
$row = $query->getRow();
|
||||
|
||||
return lang($row->desc_lang_key);
|
||||
@@ -74,9 +72,9 @@ class Module extends Model
|
||||
public function get_all_subpermissions(): ResultInterface
|
||||
{
|
||||
$builder = $this->db->table('permissions');
|
||||
$builder->join('modules AS modules', 'modules.module_id = permissions.module_id'); //TODO: can the table parameter just be modules instead of modules AS modules?
|
||||
$builder->join('modules AS modules', 'modules.module_id = permissions.module_id'); // TODO: can the table parameter just be modules instead of modules AS modules?
|
||||
|
||||
// can't quote the parameters correctly when using different operators..
|
||||
// Can't quote the parameters correctly when using different operators
|
||||
$builder->where('modules.module_id != ', 'permission_id', false);
|
||||
|
||||
return $builder->get();
|
||||
@@ -100,7 +98,7 @@ class Module extends Model
|
||||
public function get_allowed_home_modules(int $person_id): ResultInterface
|
||||
{
|
||||
$menus = ['home', 'both'];
|
||||
$builder = $this->db->table('modules'); //TODO: this is duplicated with the code below... probably refactor a method and just pass through whether home/office modules are needed.
|
||||
$builder = $this->db->table('modules'); // TODO: this is duplicated with the code below... probably refactor a method and just pass through whether home/office modules are needed.
|
||||
$builder->join('permissions', 'permissions.permission_id = modules.module_id');
|
||||
$builder->join('grants', 'permissions.permission_id = grants.permission_id');
|
||||
$builder->where('person_id', $person_id);
|
||||
@@ -118,7 +116,7 @@ class Module extends Model
|
||||
public function get_allowed_office_modules(int $person_id): ResultInterface
|
||||
{
|
||||
$menus = ['office', 'both'];
|
||||
$builder = $this->db->table('modules'); //TODO: Duplicated code
|
||||
$builder = $this->db->table('modules'); // TODO: Duplicated code
|
||||
$builder->join('permissions', 'permissions.permission_id = modules.module_id');
|
||||
$builder->join('grants', 'permissions.permission_id = grants.permission_id');
|
||||
$builder->where('person_id', $person_id);
|
||||
@@ -133,14 +131,11 @@ class Module extends Model
|
||||
* This method is used to set the show the office navigation icon on the home page
|
||||
* which happens when the sort value is greater than zero
|
||||
*/
|
||||
public function set_show_office_group(bool $show_office_group): void //TODO: Should we return the value of update() as a bool for consistency?
|
||||
public function set_show_office_group(bool $show_office_group): void // TODO: Should we return the value of update() as a bool for consistency?
|
||||
{
|
||||
if($show_office_group) //TODO: This should be replaced with ternary notation
|
||||
{
|
||||
if ($show_office_group) { // TODO: This should be replaced with ternary notation
|
||||
$sort = 999;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$sort = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user