Skip to content

Commit

Permalink
Updated documentation to reflect compatibility with Moodle 4.1 and PH…
Browse files Browse the repository at this point in the history
…P 8.0.
  • Loading branch information
michael-milette committed Dec 11, 2022
1 parent 80dede7 commit 576f0cf
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 36 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ All notable changes to this project will be documented in this file.
- Field value will be converted to clickable link if it is a URL.
### Updated
- Fix-66: Select multiple fields now work corretly.
- Compatible with PHP 5.6 to 8.0.
- Compatible with Moodle up to v4.1.

## [1.2.2] - 2022-04-25

### Updated
- Removed db directory as this plugin does not use any tables.
- .gitignore
Expand Down
38 changes: 11 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
Contributing
----------------------------------
-------------------

1. File an issue to notify the maintainers about what you're working on.
1. File an issue to notify the maintainers about what you are working on.
2. Fork the repo, develop and test your code changes, add docs.
3. Make sure that your commit messages clearly describe the changes.
4. Send a pull request.

File an Issue
-------------------

Use the issue tracker to start the discussion. It is possible that someone
else is already working on your idea, your approach is not quite right, or that
the functionality exists already. The ticket you file in the issue tracker will
be used to hash that all out.
Use the issue tracker to start the discussion. It is possible that someone else is already working on your idea, your approach is not quite right, or that the functionality exists already. The ticket you file in the issue tracker will be used to hash that all out.

Keep in mind that the maintainers get final say on whether new features will be
integrated into the project.
Keep in mind that the maintainers get final say on whether new features will be integrated into the project.

Style Guides
-------------------
1. Write in UTF-8 in PHP 5.6, 7.0, 7.1 and 7.2.
1. Write in UTF-8 in PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 and 8.0.
2. Follow the official[Moodle Coding Style Guide](https://docs.moodle.org/dev/Coding_style).
3. Fully test your code with Moodle **Debug Messages** setting set to
**DEVELOPER: extra Moodle debug messages for developers** and
**Display debug messages** setting checked.
Ensure that there are no errors or warnings at all.
4. Test your code using the [Moodle Code Checker](https://moodle.org/plugins/local_codechecker)
and [Moodle PHPdoc check](https://moodle.org/plugins/local_moodlecheck) plugins.
Ensure that there are no errors or warnings at all.
3. Fully test your code with Moodle **Debug Messages** setting set to **DEVELOPER: extra Moodle debug messages for developers** and **Display debug messages** setting checked. Ensure that there are no errors or warnings at all.
4. Test your code using the [Moodle Code Checker](https://moodle.org/plugins/local_codechecker) and [Moodle PHPdoc check](https://moodle.org/plugins/local_moodlecheck) plugins. Ensure that there are no errors or warnings at all.
5. Look at the existing style and adhere accordingly.

Fork the Repository
-------------------

Be sure to add the relevant tests before making the pull request. The
documentation will be updated automatically when we merge to `master`,
but you should also build the documentation yourself and make sure it is
readable.
Be sure to add the relevant tests before making the pull request. The documentation will be updated automatically when we merge to the **master** branch, but you should also build the documentation yourself and make sure it is readable.

Make a Pull Request
---------------------
-------------------

Once you have made all your changes, tests, and updated the documentation,
make a pull request to move everything back into the main branch of the
`repository`. Be sure to reference the original issue in the pull request.
Expect some back-and-forth with regards to style and compliance of these
rules.
Once you have made all your changes, tests, and updated the documentation, make a pull request to move everything back into the main branch of the **repository**. Be sure to reference the original issue in the pull request. Expect some back-and-forth with regards to style and compliance of these rules.

Versioning
---------------------
-------------------
We use [SemVer](http://semver.org/) for versioning.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Local Contact Form plugin for Moodle
====================================
![PHP](https://img.shields.io/badge/PHP-v5.6%20%2F%20v7.0%20%2F%20v7.1%20%2F%207.2%20%2F%207.3%20%2F%207.4-blue.svg)
![Moodle](https://img.shields.io/badge/Moodle-v3.0%20to%20v4.0-orange.svg)
![PHP](https://img.shields.io/badge/PHP-v5.6%20%2F%20v7.0%20%2F%20v7.1%20%2F%207.2%20%2F%207.3%20%2F%207.4%20%2F%208.0-blue.svg)
![Moodle](https://img.shields.io/badge/Moodle-v3.0%20to%20v4.1-orange.svg)
[![GitHub Issues](https://img.shields.io/github/issues/michael-milette/moodle-local_contact.svg)](https://github.com/michael-milette/moodle-local_contact/issues)
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg)](#contributing)
[![License](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](#license)
Expand Down
14 changes: 10 additions & 4 deletions classes/local_contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,15 @@ public function sendmessage($email, $name, $sendconfirmationemail = false) {

$htmlmessage = '';

function filterempty($value){
$value = trim($value);
return ($value !== NULL && $value !== FALSE && $value !== "");
/**
* Callback function for array_filter.
*
* @param string $string Text to be chekced.
* @return boolean true if string is not empty, otherwise false.
*/
function filterempty($string) {
$string = trim($string);
return ($string !== null && $string !== false && $string !== '');
}

foreach ($_POST as $key => $value) {
Expand All @@ -285,7 +291,7 @@ function filterempty($value){
// Make custom alterations.
case 'message': // Message field - use translated value from language file.
$key = $fieldmessage;
case strpos($value, "\n") !== FALSE: // Field contains linefeeds.
case strpos($value, "\n") !== false: // Field contains linefeeds.
case $fieldmessage: // Message field.
// Strip out excessive empty lines.
$value = preg_replace('/\n(\s*\n){2,}/', "\n\n", $value);
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// If we require user to be logged in.
if (!empty(get_config('local_contact', 'loginrequired'))) {
// Log them in and then redirect them back to the form.
if (!isloggedin() or isguestuser()) {
if (!isloggedin() || isguestuser()) {
// Set message that session has timed out.
$SESSION->has_timed_out = 1;
require_login();
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
$settings->add($setting);

// Override and disable ReCAPTCHA, if the private and public keys are setup in Moodle.
if (!empty($CFG->recaptchaprivatekey) AND !empty($CFG->recaptchapublickey)) {
if (!empty($CFG->recaptchaprivatekey) && !empty($CFG->recaptchapublickey)) {
// Information on using recaptcha with Contact Form.
$name = 'local_contact/recapchainfo';
$title = get_string('recapchainfo', 'local_contact');
Expand Down

0 comments on commit 576f0cf

Please sign in to comment.