update links
This commit is contained in:
parent
9047a96f1a
commit
ea20afe57f
117
admin.php
117
admin.php
@ -23,53 +23,6 @@ try {
|
||||
$page = $_GET['page'] ?? 'dashboard';
|
||||
$action = $_GET['action'] ?? '';
|
||||
|
||||
// Handle Profile Update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $page === 'profile') {
|
||||
$name = $_POST['name'] ?? '';
|
||||
$description = $_POST['description'] ?? '';
|
||||
|
||||
$logo_path = get_platform_profile()['logo_path'] ?? '';
|
||||
$favicon_path = get_platform_profile()['favicon_path'] ?? '';
|
||||
|
||||
$upload_dir = __DIR__ . '/assets/images/uploads/';
|
||||
if (!is_dir($upload_dir)) {
|
||||
mkdir($upload_dir, 0777, true);
|
||||
}
|
||||
|
||||
if (!empty($_FILES['logo']['tmp_name'])) {
|
||||
$filename = 'logo_' . time() . '_' . basename($_FILES['logo']['name']);
|
||||
$target = $upload_dir . $filename;
|
||||
if (move_uploaded_file($_FILES['logo']['tmp_name'], $target)) {
|
||||
$logo_path = 'assets/images/uploads/' . $filename;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_FILES['favicon']['tmp_name'])) {
|
||||
$filename = 'favicon_' . time() . '_' . basename($_FILES['favicon']['name']);
|
||||
$target = $upload_dir . $filename;
|
||||
if (move_uploaded_file($_FILES['favicon']['tmp_name'], $target)) {
|
||||
$favicon_path = 'assets/images/uploads/' . $filename;
|
||||
}
|
||||
}
|
||||
|
||||
$ctr_no = $_POST['ctr_no'] ?? '';
|
||||
$telephone_no = $_POST['telephone_no'] ?? '';
|
||||
$email_id = $_POST['email_id'] ?? '';
|
||||
|
||||
$stmt = db()->prepare("UPDATE platform_profile SET name = :name, description = :description, logo_path = :logo, favicon_path = :favicon, ctr_no = :ctr_no, telephone_no = :telephone_no, email_id = :email_id WHERE id = 1");
|
||||
$stmt->execute([
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'logo' => $logo_path,
|
||||
'favicon' => $favicon_path,
|
||||
'ctr_no' => $ctr_no,
|
||||
'telephone_no' => $telephone_no,
|
||||
'email_id' => $email_id
|
||||
]);
|
||||
|
||||
header('Location: ' . app_url('admin.php', ['page' => 'profile', 'saved' => 1]));
|
||||
exit;
|
||||
}
|
||||
|
||||
$metrics = subscription_metrics();
|
||||
$recent = fetch_recent_subscriptions();
|
||||
@ -109,7 +62,9 @@ render_head(
|
||||
<span class="fw-medium"><?= h(t('Admin', 'المدير')) ?></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow-sm">
|
||||
<?php if (has_permission('profile', 'view')): ?>
|
||||
<li><a class="dropdown-item" href="<?= h(app_url('admin.php', ['page' => 'profile'])) ?>"><?= h(t('Platform Profile', 'ملف المنصة')) ?></a></li>
|
||||
<?php endif; ?>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="<?= h(app_url('index.php')) ?>"><?= h(t('View Site', 'عرض الموقع')) ?></a></li>
|
||||
<li><a class="dropdown-item text-danger" href="<?= h(app_url('logout.php')) ?>"><?= h(t('Logout', 'تسجيل خروج')) ?></a></li>
|
||||
@ -212,6 +167,7 @@ render_head(
|
||||
|
||||
<div class="collapse <?= in_array($page, ['profile', 'integrations', 'landing', 'users', 'roles']) ? 'show' : '' ?>" id="settingsCollapse">
|
||||
<ul class="nav flex-column ms-3 mb-2">
|
||||
<?php if (has_permission('profile', 'view')): ?>
|
||||
<li class="nav-item mb-1 mt-2">
|
||||
<a href="<?= h(app_url('admin.php', ['page' => 'profile'])) ?>" class="nav-link <?= $page === 'profile' ? 'active' : 'link-dark' ?> d-flex align-items-center gap-2" <?= $page === 'profile' ? 'style="background-color: var(--accent); color: white; border-radius: 6px;"' : '' ?>>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-badge" viewBox="0 0 16 16">
|
||||
@ -221,6 +177,7 @@ render_head(
|
||||
<?= h(t('Platform Profile', 'ملف المنصة')) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item mb-1">
|
||||
<a href="<?= h(app_url('admin.php', ['page' => 'integrations'])) ?>" class="nav-link <?= $page === 'integrations' ? 'active' : 'link-dark' ?> d-flex align-items-center gap-2" <?= $page === 'integrations' ? 'style="background-color: var(--accent); color: white; border-radius: 6px;"' : '' ?> >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plug" viewBox="0 0 16 16">
|
||||
@ -324,70 +281,8 @@ render_head(
|
||||
</div>
|
||||
|
||||
<?php elseif ($page === 'profile'): ?>
|
||||
<?php if (get_logged_in_user()['role'] !== 'admin' || !empty(get_logged_in_user()['role_id'])) die('Access Denied'); ?>
|
||||
<?php $prof = get_platform_profile(); ?>
|
||||
<div class="section-header mb-4">
|
||||
<div>
|
||||
<span class="eyebrow"><?= h(t('Settings', 'الإعدادات')) ?></span>
|
||||
<h1 class="section-title mb-2"><?= h(t('Platform Profile', 'ملف المنصة')) ?></h1>
|
||||
<p class="text-secondary mb-0"><?= h(t('Update your platforms name, description, logo, and favicon.', 'قم بتحديث اسم منصتك ووصفها وشعارها والأيقونة المفضلة.')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!empty($_GET['saved'])): ?>
|
||||
<div class="alert alert-success"><?= h(t('Profile updated successfully.', 'تم تحديث الملف بنجاح.')) ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="panel-card" style="max-width: 600px;">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= h(t('Platform Name', 'اسم المنصة')) ?></label>
|
||||
<input type="text" name="name" class="form-control" value="<?= h($prof['name'] ?? '') ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= h(t('Description', 'الوصف')) ?></label>
|
||||
<textarea name="description" class="form-control" rows="3"><?= h($prof['description'] ?? '') ?></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= h(t('Logo', 'الشعار')) ?></label>
|
||||
<?php if (!empty($prof['logo_path'])): ?>
|
||||
<div class="mb-2">
|
||||
<img src="<?= h(asset_url($prof['logo_path'])) ?>" alt="Logo" style="height: 60px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff;">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="logo" class="form-control" accept="image/*">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label"><?= h(t('Favicon', 'الأيقونة المفضلة')) ?></label>
|
||||
<?php if (!empty($prof['favicon_path'])): ?>
|
||||
<div class="mb-2">
|
||||
<img src="<?= h(asset_url($prof['favicon_path'])) ?>" alt="Favicon" style="height: 32px; border: 1px solid var(--border); border-radius: 4px; padding: 2px; background: #fff;">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="favicon" class="form-control" accept="image/x-icon,image/png,image/jpeg,image/svg+xml">
|
||||
</div>
|
||||
|
||||
<h5 class="mb-3 mt-4"><?= h(t('Contact Information', 'معلومات الاتصال')) ?></h5>
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label"><?= h(t('Email', 'البريد الإلكتروني')) ?></label>
|
||||
<input type="email" name="email_id" class="form-control" value="<?= h($prof['email_id'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label"><?= h(t('Phone Number', 'رقم الهاتف')) ?></label>
|
||||
<input type="text" name="telephone_no" class="form-control" value="<?= h($prof['telephone_no'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label"><?= h(t('Commercial Registration No.', 'رقم السجل التجاري')) ?></label>
|
||||
<input type="text" name="ctr_no" class="form-control" value="<?= h($prof['ctr_no'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary" style="background-color: var(--accent); border-color: var(--accent);">
|
||||
<?= h(t('Save Changes', 'حفظ التغييرات')) ?>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php elseif ($page === 'plans'): ?>
|
||||
<?php require_once __DIR__ . '/admin_profile.php'; ?>
|
||||
<?php elseif ($page === 'plans'): ?>
|
||||
<?php require_once __DIR__ . '/admin_plans.php'; ?>
|
||||
<?php elseif ($page === 'courses'): ?>
|
||||
<?php require_once __DIR__ . '/admin_courses.php'; ?>
|
||||
|
||||
119
admin_profile.php
Normal file
119
admin_profile.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
// admin_profile.php
|
||||
require_once __DIR__ . '/includes/app.php';
|
||||
require_once __DIR__ . '/includes/auth.php';
|
||||
|
||||
require_permission('profile', 'view');
|
||||
|
||||
// Handle Profile Update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['name'])) {
|
||||
require_permission('profile', 'edit');
|
||||
|
||||
$name = $_POST['name'] ?? '';
|
||||
$description = $_POST['description'] ?? '';
|
||||
|
||||
$logo_path = get_platform_profile()['logo_path'] ?? '';
|
||||
$favicon_path = get_platform_profile()['favicon_path'] ?? '';
|
||||
|
||||
$upload_dir = __DIR__ . '/assets/images/uploads/';
|
||||
if (!is_dir($upload_dir)) {
|
||||
mkdir($upload_dir, 0777, true);
|
||||
}
|
||||
|
||||
if (!empty($_FILES['logo']['tmp_name'])) {
|
||||
$filename = 'logo_' . time() . '_' . basename($_FILES['logo']['name']);
|
||||
$target = $upload_dir . $filename;
|
||||
if (move_uploaded_file($_FILES['logo']['tmp_name'], $target)) {
|
||||
$logo_path = 'assets/images/uploads/' . $filename;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_FILES['favicon']['tmp_name'])) {
|
||||
$filename = 'favicon_' . time() . '_' . basename($_FILES['favicon']['name']);
|
||||
$target = $upload_dir . $filename;
|
||||
if (move_uploaded_file($_FILES['favicon']['tmp_name'], $target)) {
|
||||
$favicon_path = 'assets/images/uploads/' . $filename;
|
||||
}
|
||||
}
|
||||
|
||||
$ctr_no = $_POST['ctr_no'] ?? '';
|
||||
$telephone_no = $_POST['telephone_no'] ?? '';
|
||||
$email_id = $_POST['email_id'] ?? '';
|
||||
|
||||
$stmt = db()->prepare("UPDATE platform_profile SET name = :name, description = :description, logo_path = :logo, favicon_path = :favicon, ctr_no = :ctr_no, telephone_no = :telephone_no, email_id = :email_id WHERE id = 1");
|
||||
$stmt->execute([
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'logo' => $logo_path,
|
||||
'favicon' => $favicon_path,
|
||||
'ctr_no' => $ctr_no,
|
||||
'telephone_no' => $telephone_no,
|
||||
'email_id' => $email_id
|
||||
]);
|
||||
|
||||
header('Location: ' . app_url('admin.php', ['page' => 'profile', 'saved' => 1]));
|
||||
exit;
|
||||
}
|
||||
|
||||
$prof = get_platform_profile();
|
||||
?>
|
||||
<div class="section-header mb-4">
|
||||
<div>
|
||||
<span class="eyebrow"><?= h(t('Settings', 'الإعدادات')) ?></span>
|
||||
<h1 class="section-title mb-2"><?= h(t('Platform Profile', 'ملف المنصة')) ?></h1>
|
||||
<p class="text-secondary mb-0"><?= h(t('Update your platforms name, description, logo, and favicon.', 'قم بتحديث اسم منصتك ووصفها وشعارها والأيقونة المفضلة.')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!empty($_GET['saved'])): ?>
|
||||
<div class="alert alert-success"><?= h(t('Profile updated successfully.', 'تم تحديث الملف بنجاح.')) ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="panel-card" style="max-width: 600px;">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= h(t('Platform Name', 'اسم المنصة')) ?></label>
|
||||
<input type="text" name="name" class="form-control" value="<?= h($prof['name'] ?? '') ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= h(t('Description', 'الوصف')) ?></label>
|
||||
<textarea name="description" class="form-control" rows="3"><?= h($prof['description'] ?? '') ?></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= h(t('Logo', 'الشعار')) ?></label>
|
||||
<?php if (!empty($prof['logo_path'])): ?>
|
||||
<div class="mb-2">
|
||||
<img src="<?= h(asset_url($prof['logo_path'])) ?>" alt="Logo" style="height: 60px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff;">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="logo" class="form-control" accept="image/*">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label"><?= h(t('Favicon', 'الأيقونة المفضلة')) ?></label>
|
||||
<?php if (!empty($prof['favicon_path'])): ?>
|
||||
<div class="mb-2">
|
||||
<img src="<?= h(asset_url($prof['favicon_path'])) ?>" alt="Favicon" style="height: 32px; border: 1px solid var(--border); border-radius: 4px; padding: 2px; background: #fff;">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="favicon" class="form-control" accept="image/x-icon,image/png,image/jpeg,image/svg+xml">
|
||||
</div>
|
||||
|
||||
<h5 class="mb-3 mt-4"><?= h(t('Contact Information', 'معلومات الاتصال')) ?></h5>
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label"><?= h(t('Email', 'البريد الإلكتروني')) ?></label>
|
||||
<input type="email" name="email_id" class="form-control" value="<?= h($prof['email_id'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label"><?= h(t('Phone Number', 'رقم الهاتف')) ?></label>
|
||||
<input type="text" name="telephone_no" class="form-control" value="<?= h($prof['telephone_no'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label"><?= h(t('Commercial Registration No.', 'رقم السجل التجاري')) ?></label>
|
||||
<input type="text" name="ctr_no" class="form-control" value="<?= h($prof['ctr_no'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary" style="background-color: var(--accent); border-color: var(--accent);">
|
||||
<?= h(t('Save Changes', 'حفظ التغييرات')) ?>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -28,6 +28,7 @@ $pages = [
|
||||
'roles' => t('Role Groups', 'مجموعات الصلاحيات'),
|
||||
'integrations' => t('Integrations', 'عمليات الربط'),
|
||||
'landing' => t('Landing Page', 'الصفحة الرئيسية'),
|
||||
'profile' => t('Platform Profile', 'ملف المنصة'),
|
||||
];
|
||||
|
||||
$action = $_GET['action'] ?? 'list';
|
||||
|
||||
@ -621,15 +621,29 @@ if (!empty($prof['favicon_path'])):
|
||||
|
||||
function nav_items(): array
|
||||
{
|
||||
return [
|
||||
$items = [
|
||||
'index.php' => t('Home', 'الرئيسية'),
|
||||
'catalog.php' => t('Subjects', 'المواد'),
|
||||
'courses.php' => t('Courses', 'الدورات'),
|
||||
'pricing.php' => t('Plans', 'الخطط'),
|
||||
'dashboard.php' => t('Student', 'الطالب'),
|
||||
'teacher.php' => t('Teacher', 'المعلم'),
|
||||
'admin.php' => t('Admin', 'الإدارة'),
|
||||
];
|
||||
|
||||
if (!empty($_SESSION['user_id'])) {
|
||||
$stmt = db()->prepare("SELECT role FROM users WHERE id = ?");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if ($user) {
|
||||
if ($user['role'] === 'student') {
|
||||
$items['dashboard.php'] = t('Student', 'الطالب');
|
||||
} elseif ($user['role'] === 'teacher') {
|
||||
$items['teacher.php'] = t('Teacher', 'المعلم');
|
||||
} elseif ($user['role'] === 'admin') {
|
||||
$items['admin.php'] = t('Admin', 'الإدارة');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function render_nav(string $active = ''): void
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user