1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +02:00

Minor code updates in $modules plus a small documentation update for WireMail

This commit is contained in:
Ryan Cramer
2021-09-17 15:44:17 -04:00
parent 82342089bc
commit f5c3fada32
3 changed files with 14 additions and 12 deletions

View File

@@ -1056,7 +1056,7 @@ function wireClassParents($className, $autoload = true) {
if($ns) $className = $ns . $_className;
}
}
$parents = class_parents(ltrim($className, "\\"), $autoload);
$parents = @class_parents(ltrim($className, "\\"), $autoload);
}
$a = array();
if(is_array($parents)) foreach($parents as $k => $v) {

View File

@@ -416,6 +416,7 @@ class Modules extends WireArray {
if(empty($info['singular'])) continue;
$file = $this->paths[1] . "$moduleName/$moduleName.module.php";
if(!file_exists($file) || !$this->includeModuleFile($file, $moduleName)) continue;
if(!isset($info['namespace'])) $info['namespace'] = '';
$className = $info['namespace'] . $moduleName;
$module = $this->newModule($className, $moduleName);
if($module) parent::set($moduleName, $module);
@@ -1486,7 +1487,7 @@ class Modules extends WireArray {
}
$info = $this->getModuleInfo($module ? $module : $moduleName);
if(empty($info['permission']) && empty($info['permissionMethod'])) return $strict ? false : true;
if(empty($info['permission']) && empty($info['permissionMethod'])) return ($strict ? false : true);
if(is_null($user)) $user = $this->wire('user');
if($user && $user->isSuperuser()) return true;
@@ -1506,7 +1507,8 @@ class Modules extends WireArray {
);
$method = $info['permissionMethod'];
$this->includeModule($moduleName);
return $className::$method($data);
if(method_exists($className, $method)) return $className::$method($data);
return false;
}
return true;

View File

@@ -3,19 +3,17 @@
/**
* ProcessWire WireMail
*
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
* ProcessWire 3.x, Copyright 2021 by Ryan Cramer
* https://processwire.com
*
* #pw-summary A module type that handles sending of email in ProcessWire
* #pw-var $m
* #pw-body =
*
* Below are 3 different ways you can get a new instance of WireMail.
* When possible we recommend using option A or B below.
* Below are 2 different ways you can get a new instance of WireMail.
* ~~~~~
* $m = $mail->new(); // option A
* $m = wireMail(); // option B
* $m = new WireMail(); // option C
* $m = $mail->new(); // option A: use $mail API variable
* $m = wireMail(); // option B: use wireMail() function
* ~~~~~
* Once you have an instance of WireMail (`$m`), you can use it to send email like in these examples below.
* ~~~~~
@@ -23,7 +21,8 @@
* $m->to('user@domain.com')
* ->from('you@company.com')
* ->subject('Message Subject')
* ->body('Message Body')
* ->body('Optional message body in plain text')
* ->bodyHTML('<html><body><p>Optional message body in HTML</p></body></html>')
* ->send();
*
* // separate method call usage
@@ -38,10 +37,11 @@
* $m->from('you@company.com', 'Mary Jane');
*
* // other methods or properties you might set (or get)
* $m->bodyHTML('<html><body><h1>Message Body</h1></body></html>');
* $m->attachment('/path/to/file.ext');
* $m->fromName('Mary Jane');
* $m->toName('John Smith');
* $m->replyTo('somebody@somewhere.com');
* $m->replyToName('Joe Somebody');
* $m->attachment('/path/to/file.ext');
* $m->header('X-Mailer', 'ProcessWire');
* $m->param('-f you@company.com'); // PHP mail() param (envelope from example)
*