mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add role filter to bulk message
This commit is contained in:
@@ -85,7 +85,7 @@ class ExamResource extends Resource
|
||||
|
||||
Forms\Components\Section::make(__('label.exam.section_time'))->schema([
|
||||
Forms\Components\DateTimePicker::make('begin')->label(__('label.begin')),
|
||||
Forms\Components\DateTimePicker::make('end')->label(__('label.begin')),
|
||||
Forms\Components\DateTimePicker::make('end')->label(__('label.end')),
|
||||
Forms\Components\TextInput::make('duration')
|
||||
->integer()
|
||||
->columnSpan(['sm' => 2])
|
||||
@@ -118,7 +118,7 @@ class ExamResource extends Resource
|
||||
Tables\Columns\TextColumn::make('name')->searchable()->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('indexFormatted')->label(__('label.exam.index_formatted'))->html(),
|
||||
Tables\Columns\TextColumn::make('begin')->label(__('label.begin')),
|
||||
Tables\Columns\TextColumn::make('end')->label(__('label.begin')),
|
||||
Tables\Columns\TextColumn::make('end')->label(__('label.end')),
|
||||
Tables\Columns\TextColumn::make('durationText')->label(__('label.duration')),
|
||||
Tables\Columns\TextColumn::make('filterFormatted')->label(__('label.exam.filter_formatted'))->html(),
|
||||
Tables\Columns\BooleanColumn::make('is_discovered')->label(__('label.exam.is_discovered')),
|
||||
|
||||
@@ -64,7 +64,7 @@ $classes = array_chunk(\App\Models\User::$classes, 4, true);
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php do_action('increment_bulk_form_filters') ?>
|
||||
<?php do_action('form_role_filter', 'Add to Role') ?>
|
||||
<tr><td class="rowhead" valign="top">Subject </td><td class="rowfollow"><input type=text name=subject size=82></td></tr>
|
||||
<tr><td class="rowhead" valign="top">Reason </td><td class="rowfollow"><textarea name=msg cols=80 rows=5><?php echo $body ?? ''?></textarea></td></tr>
|
||||
<tr>
|
||||
|
||||
@@ -24,35 +24,43 @@ if ($_GET["returnto"] || $_SERVER["HTTP_REFERER"])
|
||||
<?php
|
||||
if ($_GET["sent"] == 1) {
|
||||
?>
|
||||
<tr><td colspan=2><font color=red><b>The message has ben sent.</font></b></tr></td>
|
||||
<tr><td colspan=2><font color=red><b>The message has ben sent.</b></font></td></tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><b>Send to:</b><br />
|
||||
<table style="border: 0" width="100%" cellpadding="0" cellspacing="0">
|
||||
<?php
|
||||
foreach ($classes as $chunk) {
|
||||
printf('<tr>');
|
||||
foreach ($chunk as $class => $info) {
|
||||
printf('<td style="border: 0"><label><input type="checkbox" name="clases[]" value="%s" />%s</label></td>', $class, $info['text']);
|
||||
}
|
||||
printf('</tr>');
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</td>
|
||||
<td><b>Send to class:</b></td>
|
||||
<td>
|
||||
<table style="border: 0" width="100%" cellpadding="0" cellspacing="0">
|
||||
<?php
|
||||
foreach ($classes as $chunk) {
|
||||
printf('<tr>');
|
||||
foreach ($chunk as $class => $info) {
|
||||
printf('<td style="border: 0"><label><input type="checkbox" name="classes[]" value="%s" />%s</label></td>', $class, $info['text']);
|
||||
}
|
||||
printf('</tr>');
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>Subject <input type=text name=subject size=75></tr></td>
|
||||
<tr><td><textarea name=msg cols=80 rows=15><?php echo $body?></textarea></td></tr>
|
||||
<?php do_action('form_role_filter', 'Send to Role:') ?>
|
||||
<tr>
|
||||
<td colspan=1><div align="center"><b>Sender: </b>
|
||||
<td class="rowhead">Subject</td>
|
||||
<td> <input type=text name=subject size=75></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="rowhead">Message</td>
|
||||
<td><textarea name=msg cols=80 rows=15><?php echo $body?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2><div align="center"><b>Sender: </b>
|
||||
<?php echo $CURUSER['username']?>
|
||||
<input name="sender" type="radio" value="self" checked>
|
||||
System
|
||||
<input name="sender" type="radio" value="system">
|
||||
</div></td></tr>
|
||||
<tr><td colspan=1 align=center><input type=submit value="Send!" class=btn></td></tr>
|
||||
<tr><td colspan=2 align=center><input type=submit value="Send!" class=btn></td></tr>
|
||||
</table>
|
||||
<input type=hidden name=receiver value=<?php echo $receiver?>>
|
||||
</form>
|
||||
|
||||
@@ -37,7 +37,7 @@ $conditions = [];
|
||||
if (!empty($_POST['classes'])) {
|
||||
$conditions[] = "class IN (" . implode(', ', $_POST['classes']) . ")";
|
||||
}
|
||||
$conditions = apply_filter("increment_bulk_query_conditions", $conditions, $_POST);
|
||||
$conditions = apply_filter("role_query_conditions", $conditions, $_POST);
|
||||
if (empty($conditions)) {
|
||||
stderr("Error","No valid filter");
|
||||
}
|
||||
|
||||
@@ -28,11 +28,19 @@ $subject = trim($_POST['subject']);
|
||||
$size = 10000;
|
||||
$page = 1;
|
||||
set_time_limit(300);
|
||||
$classStr = implode(",", $updateset);
|
||||
$conditions = [];
|
||||
if (!empty($_POST['classes'])) {
|
||||
$conditions[] = "class IN (" . implode(', ', $_POST['classes']) . ")";
|
||||
}
|
||||
$conditions = apply_filter("role_query_conditions", $conditions, $_POST);
|
||||
if (empty($conditions)) {
|
||||
stderr("Error","No valid filter");
|
||||
}
|
||||
$whereStr = implode(' OR ', $conditions);
|
||||
while (true) {
|
||||
$msgValues = [];
|
||||
$offset = ($page - 1) * $size;
|
||||
$query = sql_query("SELECT id FROM users WHERE class IN ($classStr) and `enabled` = 'yes' and `status` = 'confirmed' limit $offset, $size");
|
||||
$query = sql_query("SELECT id FROM users WHERE ($whereStr) and `enabled` = 'yes' and `status` = 'confirmed' limit $offset, $size");
|
||||
while($dat=mysql_fetch_assoc($query))
|
||||
{
|
||||
$msgValues[] = sprintf('(%s, %s, %s, %s, %s)', $sender_id, $dat['id'], $dt, sqlesc($subject), sqlesc($msg));
|
||||
|
||||
Reference in New Issue
Block a user