Adding api_warn_hosting_contact see BT#8703

1.9.x
Julio Montoya 10 years ago
parent 5445d05059
commit 577c7e7c31
  1. 1
      main/inc/lib/course.lib.php
  2. 36
      main/inc/lib/main_api.lib.php
  3. 8
      main/inc/lib/sessionmanager.lib.php
  4. 9
      main/inc/lib/usermanager.lib.php
  5. 2
      main/install/configuration.dist.php

@ -49,6 +49,7 @@ class CourseManager
) {
$num = self::count_courses();
if ($num >= $_configuration[$access_url_id]['hosting_limit_courses']) {
api_warn_hosting_contact('hosting_limit_courses');
return api_set_failure('PortalCoursesLimitReached');
}
}

@ -7386,3 +7386,39 @@ function api_get_full_setting($variable, $key = null) {
return $setting;
}
/**
* Warns an user that the portal reach certain limit.
* @param string $limitName
*/
function api_warn_hosting_contact($limitName)
{
$hostingParams = api_get_configuration_value(1);
$email = null;
if (!empty($hostingParams)) {
if (isset($hostingParams['hosting_contact_mail'])) {
$email = $hostingParams['hosting_contact_mail'];
}
}
if (!empty($email)) {
$subject = get_lang('HostingWarningReached');
$body = get_lang('Portal').': '.api_get_path(WEB_PATH)." \n ";
$body .= get_lang('Limit').': '.$limitName;
api_mail_html(null, $email, $subject, $body);
}
}
/**
* @param string $variable
* @return bool|mixed
*/
function api_get_configuration_value($variable)
{
global $_configuration;
if (isset($_configuration[$variable])) {
return $_configuration[$variable];
}
return false;
}

@ -85,12 +85,18 @@ class SessionManager
//Check portal limits
$access_url_id = 1;
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
}
if (is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_sessions']) && $_configuration[$access_url_id]['hosting_limit_sessions'] > 0) {
if (is_array($_configuration[$access_url_id]) &&
isset($_configuration[$access_url_id]['hosting_limit_sessions']) &&
$_configuration[$access_url_id]['hosting_limit_sessions'] > 0
) {
$num = self::count_sessions();
if ($num >= $_configuration[$access_url_id]['hosting_limit_sessions']) {
api_warn_hosting_contact('hosting_limit_sessions');
return get_lang('PortalSessionsLimitReached');
}
}

@ -97,6 +97,7 @@ class UserManager
$_configuration[$access_url_id]['hosting_limit_users'] > 0) {
$num = self::get_number_of_users();
if ($num >= $_configuration[$access_url_id]['hosting_limit_users']) {
api_warn_hosting_contact('hosting_limit_users');
return api_set_failure('portal users limit reached');
}
}
@ -4598,8 +4599,8 @@ EOF;
case self::USER_FIELD_TYPE_MOBILE_PHONE_NUMBER:
$form->addElement(
'text',
'extra_'.$field_details[1],
'text',
'extra_'.$field_details[1],
$field_details[3]." (".get_lang('CountryDialCode').")",
array('size' => 40, 'placeholder' => '(xx)xxxxxxxxx')
);
@ -4607,8 +4608,8 @@ EOF;
$form->applyFilter('extra_'.$field_details[1], 'trim');
$form->applyFilter('extra_'.$field_details[1], 'mobile_phone_number_filter');
$form->addRule(
'extra_'.$field_details[1],
get_lang('MobilePhoneNumberWrong'),
'extra_'.$field_details[1],
get_lang('MobilePhoneNumberWrong'),
'mobile_phone_number'
);
if (!$admin_permissions) {

@ -123,6 +123,8 @@ $_configuration[1]['hosting_limit_sessions'] = 0;
// Set a maximum disk space used, in MB (set to 1024 for 1GB, 5120 for 5GB).
// Default (0) = no limit
$_configuration[1]['hosting_limit_disk_space'] = 0;
// Email to warn if limit was reached.
//$_configuration[1]['hosting_contact_mail'] = 'example@example.org';
/**
* Content Delivery Network (CDN) settings. Only use if you need a separate

Loading…
Cancel
Save