Ejemplo n.º 1
0
 $query = $db->simple_select("warningtypes", "*", "tid='" . intval($mybb->input['tid']) . "'");
 $type = $db->fetch_array($query);
 // Does the warning type not exist?
 if (!$type['tid']) {
     flash_message($lang->error_invalid_warning_type, 'error');
     admin_redirect("index.php?module=config/warning");
 }
 if ($mybb->request_method == "post") {
     if (!trim($mybb->input['title'])) {
         $errors[] = $lang->error_missing_type_title;
     }
     if (!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] < 0) {
         $errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
     }
     if (!$errors) {
         $updated_type = array("title" => $db->escape_string($mybb->input['title']), "points" => intval($mybb->input['points']), "expirationtime" => fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period']));
         $db->update_query("warningtypes", $updated_type, "tid='{$type['tid']}'");
         $plugins->run_hooks("admin_config_warning_edit_type_commit");
         // Log admin action
         log_admin_action($type['tid'], $mybb->input['title']);
         flash_message($lang->success_warning_type_updated, 'success');
         admin_redirect("index.php?module=config/warning");
     }
 } else {
     $expiration = fetch_friendly_expiration($type['expirationtime']);
     $mybb->input = array("title" => $type['title'], "points" => $type['points'], "expire_time" => $expiration['time'], "expire_period" => $expiration['period']);
 }
 $page->add_breadcrumb_item($lang->edit_warning_type);
 $page->output_header($lang->warning_types . " - " . $lang->edit_warning_type);
 $sub_tabs['edit_type'] = array('link' => "index.php?module=config/warning&amp;action=edit_type&amp;tid={$type['tid']}", 'title' => $lang->edit_warning_type, 'description' => $lang->edit_warning_type_desc);
 $page->output_nav_tabs($sub_tabs, 'edit_type');
Ejemplo n.º 2
0
     if ($user[$option['update_field']] == 1) {
         // We're revoking the suspension
         $extra_user_updates[$option['update_field']] = 0;
         $extra_user_updates[$option['update_length']] = 0;
     }
     // Skip this option if we haven't selected it
     continue;
 }
 if ($mybb->input[$option['action']]) {
     if (intval($mybb->input[$option['time']]) == 0 && $mybb->input[$option['period']] != "never" && $user[$option['update_field']] != 1) {
         // User has selected a type of ban, but not entered a valid time frame
         $string = $option['action'] . "_error";
         $errors[] = $lang->{$string};
     }
     if (!is_array($errors)) {
         $suspend_length = fetch_time_length(intval($mybb->input[$option['time']]), $mybb->input[$option['period']]);
         if ($user[$option['update_field']] == 1 && ($mybb->input[$option['time']] || $mybb->input[$option['period']] == "never")) {
             // We already have a suspension, but entered a new time
             if ($suspend_length == "-1") {
                 // Permanent ban on action
                 $extra_user_updates[$option['update_length']] = 0;
             } elseif ($suspend_length && $suspend_length != "-1") {
                 // Temporary ban on action
                 $extra_user_updates[$option['update_length']] = TIME_NOW + $suspend_length;
             }
         } elseif (!$user[$option['update_field']]) {
             // New suspension for this user... bad user!
             $extra_user_updates[$option['update_field']] = 1;
             if ($suspend_length == "-1") {
                 $extra_user_updates[$option['update_length']] = 0;
             } else {
Ejemplo n.º 3
0
 $type = $db->fetch_array($query);
 // Does the warning type not exist?
 if (!$type['tid']) {
     flash_message($lang->error_invalid_warning_type, 'error');
     admin_redirect("index.php?module=config-warning");
 }
 $plugins->run_hooks("admin_config_warning_edit_type");
 if ($mybb->request_method == "post") {
     if (!trim($mybb->input['title'])) {
         $errors[] = $lang->error_missing_type_title;
     }
     if (!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] < 0) {
         $errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
     }
     if (!$errors) {
         $updated_type = array("title" => $db->escape_string($mybb->input['title']), "points" => $mybb->get_input('points', MyBB::INPUT_INT), "expirationtime" => fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period']));
         $plugins->run_hooks("admin_config_warning_edit_type_commit");
         $db->update_query("warningtypes", $updated_type, "tid='{$type['tid']}'");
         // Log admin action
         log_admin_action($type['tid'], $mybb->input['title']);
         flash_message($lang->success_warning_type_updated, 'success');
         admin_redirect("index.php?module=config-warning");
     }
 } else {
     $expiration = fetch_friendly_expiration($type['expirationtime']);
     $mybb->input = array_merge($mybb->input, array("title" => $type['title'], "points" => $type['points'], "expire_time" => $expiration['time'], "expire_period" => $expiration['period']));
 }
 $page->add_breadcrumb_item($lang->edit_warning_type);
 $page->output_header($lang->warning_types . " - " . $lang->edit_warning_type);
 $sub_tabs['edit_type'] = array('link' => "index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}", 'title' => $lang->edit_warning_type, 'description' => $lang->edit_warning_type_desc);
 $page->output_nav_tabs($sub_tabs, 'edit_type');