-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from WisdmLabs/dev
Dev to master for v2.1.0
- Loading branch information
Showing
27 changed files
with
152 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,28 @@ | |
* @author Yogesh Shirsath | ||
*/ | ||
|
||
namespace block_edwiser_site_monitor; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->libdir . '/externallib.php'); | ||
require_once($CFG->dirroot . '/blocks/edwiser_site_monitor/classes/utility.php'); | ||
|
||
use block_edwiser_site_monitor_usage as esmusage; | ||
use block_edwiser_site_monitor_plugins as esmplugins; | ||
use block_edwiser_site_monitor_utility as esmutility; | ||
use external_function_parameters; | ||
use external_single_structure; | ||
use external_value; | ||
use context_system; | ||
use external_api; | ||
use moodle_url; | ||
use stdClass; | ||
|
||
/** | ||
* This class implements services for block_edwiser_site_monitor | ||
* | ||
* @copyright 2019 WisdmLabs <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class block_edwiser_site_monitor_externallib extends external_api { | ||
class externallib extends external_api { | ||
|
||
/** | ||
* Describes the parameters for get blocks function | ||
|
@@ -54,7 +61,9 @@ public static function get_live_status_parameters() { | |
* @return array | ||
*/ | ||
public static function get_live_status() { | ||
$usage = esmusage::get_instance(); | ||
self::validate_context(context_system::instance()); | ||
utility::edwiser_site_monitor_log_usage(); | ||
$usage = usage::get_instance(); | ||
return array( | ||
"cpu" => $usage->get_cpu_usage(), | ||
"memory" => $usage->get_memory_usage(), | ||
|
@@ -99,6 +108,9 @@ public static function get_last_24_hours_usage_parameters() { | |
*/ | ||
public static function get_last_24_hours_usage($timestamp) { | ||
global $DB; | ||
self::validate_context(context_system::instance()); | ||
utility::edwiser_site_monitor_log_usage(); | ||
|
||
if ($timestamp == 0) { | ||
$timestamp = strtotime(date('d-m-Y', time())); | ||
} | ||
|
@@ -155,8 +167,8 @@ public static function get_plugins_update_parameters() { | |
*/ | ||
public static function get_plugins_update() { | ||
global $PAGE; | ||
$PAGE->set_context(context_system::instance()); | ||
$plugins = new esmplugins(); | ||
self::validate_context(context_system::instance()); | ||
$plugins = new plugins(); | ||
$time = time(); | ||
return array( | ||
'lasttimefetched' => get_string('checkforupdateslast', 'core_plugin', date('d F Y, h:i A e', $time)), | ||
|
@@ -209,14 +221,15 @@ public static function send_contactus_email_parameters() { | |
* @return array status, header and message | ||
*/ | ||
public static function send_contactus_email($firstname, $lastname, $email, $subject, $message) { | ||
self::validate_context(context_system::instance()); | ||
$admin = get_admin(); | ||
$admin->email = $email; | ||
$admin->firstname = $firstname; | ||
$admin->lastname = $lastname; | ||
$support = new stdClass; | ||
$support->id = -99; | ||
$support->email = ESM_SUPPORT_EMAIL; | ||
$status = esmutility::edwiser_site_monitor_send_email( | ||
$status = utility::edwiser_site_monitor_send_email( | ||
$admin, | ||
$support, | ||
$subject, | ||
|
@@ -230,7 +243,7 @@ public static function send_contactus_email($firstname, $lastname, $email, $subj | |
)); | ||
$admin->firstname = 'Edwiser'; | ||
$admin->lastname = ''; | ||
$status &= esmutility::edwiser_site_monitor_send_email( | ||
$status &= utility::edwiser_site_monitor_send_email( | ||
$admin, | ||
$admin, | ||
$subject, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
* @author Yogesh Shirsath | ||
*/ | ||
|
||
namespace block_edwiser_site_monitor; | ||
|
||
defined('MOODLE_INTERNAL') || die; | ||
|
||
/** | ||
|
@@ -31,7 +33,7 @@ | |
* @copyright 2019 WisdmLabs <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class block_edwiser_site_monitor_notifications { | ||
class notifications { | ||
|
||
/** | ||
* Check whether post is notified before | ||
|
@@ -85,10 +87,10 @@ private function notify($admin, $subject, $message, $url, $urlname = '') { | |
public function check() { | ||
global $DB; | ||
$admin = get_admin(); | ||
if (!block_edwiser_site_monitor_utility::edwiser_site_monitor_notification_allowed($admin)) { | ||
if (!utility::edwiser_site_monitor_notification_allowed($admin)) { | ||
return false; | ||
} | ||
$posts = block_edwiser_site_monitor_utility::get_edwiser_news(); | ||
$posts = utility::get_edwiser_news(); | ||
if (empty($posts)) { | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.