function groupquotasform_submit(Pieform $form, $values) { global $SESSION; $oldquota = get_field('group', 'quota', 'id', $values['groupid']); $group = new StdClass(); $group->id = $values['groupid']; $group->quota = $values['quota']; update_record('group', $group); if (!empty($values['quota']) && $values['quota'] != $oldquota) { // We need to alert group admins that the group may now be over the threshold $quotanotifylimit = get_config_plugin('artefact', 'file', 'quotanotifylimit'); $sqlwhere = " ((g.quotaused / g.quota) * 100) "; if (is_postgres()) { $sqlwhere = " ((CAST(g.quotaused AS float) / CAST(g.quota AS float)) * 100) "; } if ($groups = get_records_sql_assoc("SELECT g.id, g.name, g.quota, " . $sqlwhere . " AS quotausedpercent FROM {group} g WHERE " . $sqlwhere . " >= ? AND id = ?", array($quotanotifylimit, $values['groupid']))) { require_once get_config('docroot') . 'artefact/file/lib.php'; ArtefactTypeFile::notify_groups_threshold_exceeded($groups); } } $SESSION->add_ok_msg(get_string('groupquotaupdated', 'admin')); redirect(get_config('wwwroot') . 'admin/groups/groups.php'); }
public static function save_config_options($form, $values) { global $USER; $updatingquota = false; $oldquotalimit = get_config_plugin('artefact', 'file', 'quotanotifylimit'); if ($values['updateuserquotas'] && $values['defaultquota']) { set_field('usr', 'quota', $values['defaultquota'], 'deleted', 0); $updatingquota = true; } if ($values['updategroupquotas'] && $values['defaultgroupquota']) { set_field('group', 'quota', $values['defaultgroupquota'], 'deleted', 0); // We need to alert group admins that the group may now be over the threshold that wasn't before $sqlwhere = " ((g.quotaused / g.quota) * 100) "; if (is_postgres()) { $sqlwhere = " ((CAST(g.quotaused AS float) / CAST(g.quota AS float)) * 100) "; } if ($groups = get_records_sql_assoc("SELECT g.id, g.name, g.quota, " . $sqlwhere . " AS quotausedpercent FROM {group} g WHERE " . $sqlwhere . " >= ?", array($values['quotanotifylimit']))) { ArtefactTypeFile::notify_groups_threshold_exceeded($groups); } } set_config_plugin('artefact', 'file', 'defaultquota', $values['defaultquota']); set_config_plugin('artefact', 'file', 'defaultgroupquota', $values['defaultgroupquota']); set_config_plugin('artefact', 'file', 'institutionaloverride', $values['institutionaloverride']); set_config_plugin('artefact', 'file', 'maxquota', $values['maxquota']); set_config_plugin('artefact', 'file', 'maxquotaenabled', $values['maxquotaenabled']); set_config_plugin('artefact', 'file', 'profileiconwidth', $values['profileiconwidth']); set_config_plugin('artefact', 'file', 'profileiconheight', $values['profileiconheight']); set_config_plugin('artefact', 'file', 'uploadagreement', $values['uploadagreement']); set_config_plugin('artefact', 'file', 'usecustomagreement', $values['usecustomagreement']); set_config_plugin('artefact', 'file', 'resizeonuploadenable', $values['resizeonuploadenable']); set_config_plugin('artefact', 'file', 'resizeonuploaduseroption', $values['resizeonuploaduseroption']); set_config_plugin('artefact', 'file', 'resizeonuploadmaxwidth', $values['resizeonuploadmaxwidth']); set_config_plugin('artefact', 'file', 'resizeonuploadmaxheight', $values['resizeonuploadmaxheight']); set_config_plugin('artefact', 'file', 'folderdownloadkeepzipfor', $values['folderdownloadkeepzipfor']); set_config_plugin('artefact', 'file', 'quotanotifylimit', $values['quotanotifylimit']); set_config_plugin('artefact', 'file', 'quotanotifyadmin', $values['quotanotifyadmin']); if ($oldquotalimit != $values['quotanotifylimit'] || $updatingquota) { // We need to alert anyone that may now be over the threshold that wasn't before $sqlwhere = " ((u.quotaused / u.quota) * 100) "; if (is_postgres()) { $sqlwhere = " ((CAST(u.quotaused AS float) / CAST(u.quota AS float)) * 100) "; } if ($users = get_records_sql_assoc("SELECT u.id, u.quota, " . $sqlwhere . " AS quotausedpercent FROM {usr} u WHERE " . $sqlwhere . " >= ?", array($values['quotanotifylimit']))) { $notifyadmin = get_config_plugin('artefact', 'file', 'quotanotifyadmin'); ArtefactTypeFile::notify_users_threshold_exceeded($users, $notifyadmin); } else { if ($users = get_records_sql_assoc("SELECT * FROM {usr} u, {usr_account_preference} uap WHERE " . $sqlwhere . " < ? AND uap.usr = u.id AND uap.field = ? AND uap.value = ?", array($values['quotanotifylimit'], 'quota_exceeded_notified', '1'))) { foreach ($users as $user) { set_account_preference($user->id, 'quota_exceeded_notified', false); } } } } $data = new StdClass(); $data->name = 'uploadcopyright'; $data->content = $values['customagreement']; $data->mtime = db_format_timestamp(time()); $data->mauthor = $USER->get('id'); $data->institution = 'mahara'; if (record_exists('site_content', 'name', $data->name, 'institution', $data->institution)) { update_record('site_content', $data, array('name', 'institution')); } else { $data->ctime = db_format_timestamp(time()); insert_record('site_content', $data); } foreach (PluginArtefactFile::get_artefact_types() as $at) { set_config_plugin('artefact', 'file', 'commentsallowed' . $at, (int) in_array($at, $values['commentdefault'])); } }