Skip to content

Commit

Permalink
Add warning about actions not being namespaced.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Feb 21, 2024
1 parent 849c3ea commit 8a5afb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 6 additions & 5 deletions ProcessAdminActions.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function getModuleInfo() {
'title' => 'Admin Actions',
'summary' => 'Control panel for running various admin actions',
'author' => 'Adrian Jones',
'version' => '0.9.1',
'version' => '0.9.2',
'singular' => true,
'autoload' => false,
'icon' => 'wrench',
Expand Down Expand Up @@ -312,7 +312,7 @@ private function buildSelectForm() {
$this->wire('session')->redirect($this->wire('config')->urls->admin . "module/edit?name=" . $this . "&install=1");
}
elseif($this->wire('input')->get->installed) {
$this->wire()->warning($this->wire('input')->get->installed . " new " . _n('action was', 'actions were', $this->wire('input')->get->installed) . " installed. If you need to adjust role access and menu status, visit please visit the <a href='".$this->wire('config')->urls->admin . 'module/edit?name=' . $this . "'>module config settings</a>.", Notice::allowMarkup);
$this->wire()->warning($this->wire('input')->get->installed . " new " . _n('action was', 'actions were', $this->wire('input')->get->installed) . " installed. If you need to adjust role access and menu status, visit please visit the <a href='".$this->wire('config')->urls->admin . 'module/edit?name=' . $this . "'>module config settings</a>.", Notice::allowMarkup | Notice::noGroup);
}

if(isset($this->data['site'])) ksort($this->data['site']);
Expand Down Expand Up @@ -526,12 +526,13 @@ private function includeAndInstantiate($actionName) {
// silly dance to force the file to be recompiled and reload page to get the new version
$this->wire('cache')->delete('FileCompiler__'.md5($actionPath));
touch($actionPath);
$this->wire('cache')->save('AdminActions__'.$actionName, $this->wire('cache')->get('AdminActions__'.$actionName) + 1);
$this->wire('cache')->save('AdminActions__'.$actionName, $this->wire('cache')->get('AdminActions__'.$actionName) + 1, WireCache::expireNever);
if($this->wire('cache')->get('AdminActions__'.$actionName) < 2) {
$this->wire('session')->redirect($this->wire('input')->url(true));
}
$actionPath = $this->wire('files')->compile($actionPath);
$nsClass = '\\' . $actionName;
if($this->wire('user')->isSuperuser()) $this->wire()->warning('You have actions without the ProcessWire namespace. They have been compiled for you, but please consider properly namespacing them.', Notice::noGroup);
}
else {
$nsClass = $ns . '\\' . $actionName;
Expand Down Expand Up @@ -789,10 +790,10 @@ public function getModuleConfigInputfields(array $data) {
$this->getAllActions();
if($this->wire('input')->get->install !== 1 && isset($this->data['core'])) {
$this->newActionsAvailable = $this->newActionsAvailable();
if($this->newActionsAvailable) $this->wire()->warning("There are new actions available (highlighted in orange) - please adjust approved roles and menu status, and click Submit to save.");
if($this->newActionsAvailable) $this->wire()->warning("There are new actions available (highlighted in orange) - please adjust approved roles and menu status, and click Submit to save.", Notice::noGroup);
}
else {
$this->wire()->warning("Please check the roles and menu status for all the actions and adjust to your needs.");
$this->wire()->warning("Please check the roles and menu status for all the actions and adjust to your needs.", Notice::noGroup);
}

if(!array_key_exists('dbBackup', $data)) {
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ This is the entire contents needed in a file named AdminActionsMySharedAction.mo
Once this module is installed on a site, AdminActions will detect it and allow users to configure and use it like any other action.

```
<?php namespace ProcessWire;
class AdminActionsMySharedAction extends WireData implements Module {
public static function getModuleInfo() {
Expand All @@ -107,6 +109,8 @@ A good example of an installable action is @Toutouwai's [Unordered List to Pages
A new action file can be as simple as this:

```
<?php namespace ProcessWire;
class UnpublishAboutPage extends ProcessAdminActions {
protected function executeAction() {
Expand All @@ -129,6 +133,8 @@ As you can see there are only a few lines needed to wrap the actual API call, so
Obviously that example action is not very useful. Here is another more useful one that is included with the module. It includes $description, $notes, and $author variables which are used in the module table selector interface. It also makes use of the defineOptions() method which builds the input fields used to gather the required options before running the action.

```
<?php namespace ProcessWire;
class DeleteUnusedFields extends ProcessAdminActions {
protected $description = 'Deletes fields that are not used by any templates.';
Expand Down Expand Up @@ -240,4 +246,3 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

(See included LICENSE file for full license text.)

0 comments on commit 8a5afb8

Please sign in to comment.