Skip to content

Commit

Permalink
Start to namespacing module
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Feb 6, 2024
1 parent e8c2b14 commit 8a8e2a2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ProcessAdminActions.module.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
<?php namespace ProcessWire;

/**
* ProcessWire Admin Actions.
* by Adrian Jones
*
* Copyright (C) 2020 by Adrian Jones
* Copyright (C) 2024 by Adrian Jones
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
*/
Expand All @@ -16,7 +16,7 @@ public static function getModuleInfo() {
'title' => 'Admin Actions',
'summary' => 'Control panel for running various admin actions',
'author' => 'Adrian Jones',
'version' => '0.8.13',
'version' => '0.9.0',
'singular' => true,
'autoload' => false,
'icon' => 'wrench',
Expand Down Expand Up @@ -133,10 +133,11 @@ public function init() {
$this->getActionTypes();

if($this->wire('input')->get->action) {
if(isset($this->actionTypes[$this->wire('input')->get->action]) && count(array_intersect($this->data[$this->actionTypes[$this->wire('input')->get->action]][$this->wire('input')->get->action]['roles'], $this->wire('user')->roles->each("id"))) !== 0) {
require_once $this->getActionPath($this->wire('input')->get->action);
$actionName = $this->wire('input')->get->action;
$this->action = new $actionName;
$actionName = $this->wire('input')->get->action;
if(isset($this->actionTypes[$actionName]) && count(array_intersect($this->data[$this->actionTypes[$actionName]][$actionName]['roles'], $this->wire('user')->roles->each("id"))) !== 0) {
require_once $this->getActionPath($actionName);
$nsClass = 'ProcessWire\\'.$actionName;
$this->action = new $nsClass();
$this->hasPermission = true;
$this->addHookAfter('Process::breadcrumb', $this, 'modifyBreadcrumb');
}
Expand Down Expand Up @@ -544,7 +545,8 @@ private function getActions($folderPath, $instantiate = true) {
$className = $matches[1];
if($instantiate) {
require_once $this->getActionPath($className);
$action = new $className;
$nsClass = 'ProcessWire\\'.$actionName;
$action = new $nsClass();
$this->actions[$actionType][$className]['title'] = $action->title ?: $this->getInfoFieldValues($className, 'title');
$this->actions[$actionType][$className]['description'] = $action->description ?: $this->getInfoFieldValues($className, 'summary');
$this->actions[$actionType][$className]['notes'] = $action->notes ?: $this->getInfoFieldValues($className, 'notes');
Expand Down Expand Up @@ -738,7 +740,8 @@ public function __call($method, $args) {
$actionFilePath = $this->getActionPath($method);
if(!file_exists($actionFilePath)) return parent::__call($method, $args);
require_once $actionFilePath;
$this->action = new $method;
$nsClass = 'ProcessWire\\'.$method;
$this->action = new $nsClass();
$this->action->executeAction($args[0]);
if(array_key_exists('dbBackup', $args[0])) $this->backupDb();
}
Expand Down

0 comments on commit 8a8e2a2

Please sign in to comment.