28 lines
1.5 KiB
Python
28 lines
1.5 KiB
Python
import re
|
|
|
|
with open('approved_school.php', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Hide "archive cycle" form in approved_school.php
|
|
archive_form = r"""(<form method="post" class="d-inline">\s*<input type="hidden" name="cycle_action" value="archive_cycle">.*?<\/form>)"""
|
|
content = re.sub(archive_form, r'<?php if (is_super_admin()): ?>\1<?php endif; ?>', content, flags=re.DOTALL)
|
|
|
|
# Hide col-lg-4 containing cycles switcher and start new cycle form
|
|
col_lg_4_cycles = r"""(<div class="col-lg-4">\s*<div class="app-card sidebar-card mb-4">\s*<div class="section-title mb-3">كل دورات المركز.*?</div>\s*</div>)"""
|
|
content = re.sub(col_lg_4_cycles, r'<?php if (is_super_admin()): ?>\n\1\n<?php endif; ?>', content, flags=re.DOTALL)
|
|
|
|
# Adjust col-lg-8 to be conditionally 12
|
|
content = re.sub(r'<div class="col-lg-8">', r'<div class="<?= is_super_admin() ? \'col-lg-8\' : \'col-lg-12\' ?>">', content)
|
|
|
|
# Check POST handler for cycles in approved_school.php
|
|
post_handler = r"if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cycle_action'])) {"
|
|
post_handler_new = r"""if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cycle_action'])) {
|
|
if (!is_super_admin()) {
|
|
set_flash('error', 'عذراً، الإدارة الكاملة للدورات متاحة للمشرف العام فقط.');
|
|
header('Location: approved_school.php?id=' . $application['id']);
|
|
exit;
|
|
}"""
|
|
content = content.replace(post_handler, post_handler_new)
|
|
|
|
with open('approved_school.php', 'w', encoding='utf-8') as f:
|
|
f.write(content) |