mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Frontend logic for ClubMemberPlus
This commit is contained in:
@@ -10,7 +10,7 @@ class adif extends CI_Controller {
|
||||
$this->load->helper(array('form', 'url'));
|
||||
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2) || !clubaccess_check(9)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
||||
if(!$this->user_model->authorize(2) || !clubaccess_check(6)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
||||
}
|
||||
|
||||
public function test() {
|
||||
@@ -242,10 +242,18 @@ class adif extends CI_Controller {
|
||||
$record['contest_id'] = $contest;
|
||||
}
|
||||
|
||||
//handle club operator
|
||||
if ($club_operator != '') {
|
||||
$record['operator'] = strtoupper($club_operator);
|
||||
//handle club operator based on permission level
|
||||
$user_permission_level = $this->session->userdata('cd_p_level');
|
||||
if ($user_permission_level >= 9) {
|
||||
// Club Officer: Allow operator override
|
||||
if ($club_operator != '') {
|
||||
$record['operator'] = strtoupper($club_operator);
|
||||
}
|
||||
} elseif ($user_permission_level == 6) {
|
||||
// ClubMemberPlus: Force operator to current user, ignore input
|
||||
$record['operator'] = strtoupper($this->session->userdata('operator_callsign'));
|
||||
}
|
||||
// Note: Regular Club Member (Level 3) should not reach here due to constructor permission check
|
||||
|
||||
//check if contest_id exists in record and extract all found contest_ids
|
||||
if(array_key_exists('contest_id', $record)){
|
||||
|
||||
@@ -21,6 +21,7 @@ class Club extends CI_Controller
|
||||
|
||||
$this->permissions = [
|
||||
9 => __("Club Officer"),
|
||||
6 => __("Club Member Plus"),
|
||||
3 => __("Club Member"),
|
||||
];
|
||||
}
|
||||
@@ -118,9 +119,9 @@ class Club extends CI_Controller
|
||||
$this->session->set_flashdata('error', __("Invalid Club ID!"));
|
||||
redirect('dashboard');
|
||||
}
|
||||
if(!$this->user_model->authorize(99) && !$this->club_model->club_authorize(9, $club_id)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
if(!$this->user_model->authorize(99) && !$this->club_model->club_authorize(9, $club_id) && !$this->club_model->club_authorize(6, $club_id)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
$this->club_model->alter_member($club_id, $user_id, $p_level);
|
||||
@@ -147,9 +148,9 @@ class Club extends CI_Controller
|
||||
$this->session->set_flashdata('error', __("Invalid Club ID!"));
|
||||
redirect('dashboard');
|
||||
}
|
||||
if(!$this->user_model->authorize(99) && !$this->club_model->club_authorize(9, $club_id)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
if(!$this->user_model->authorize(99) && !$this->club_model->club_authorize(9, $club_id) && !$this->club_model->club_authorize(6, $club_id)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
if ($this->club_model->delete_member($club_id, $user_id)) {
|
||||
|
||||
@@ -30,9 +30,18 @@ if (!function_exists('clubaccess_check')) {
|
||||
// check if the QSO belongs to the user
|
||||
$CI->load->model('logbook_model');
|
||||
$qso = $CI->logbook_model->get_qso($qso_id)->row();
|
||||
if ($qso->COL_OPERATOR == $CI->session->userdata('operator_callsign') || $CI->session->userdata('cd_p_level') >= 9) {
|
||||
$user_level = $CI->session->userdata('cd_p_level');
|
||||
$operator_callsign = $CI->session->userdata('operator_callsign');
|
||||
|
||||
// Enhanced logic for ClubMemberPlus (Level 6)
|
||||
if ($user_level >= 9) {
|
||||
// Officers can access any QSO
|
||||
return true;
|
||||
} elseif ($user_level >= 6) {
|
||||
// ClubMemberPlus and regular members can only access their own QSOs
|
||||
return $qso->COL_OPERATOR == $operator_callsign;
|
||||
} else {
|
||||
// Lower levels (shouldn't reach here for ADIF access)
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -237,6 +237,8 @@
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<?php if ($member->p_level == 3) { ?>
|
||||
<span class="badge bg-info"><?php echo $permissions[3]; ?></span>
|
||||
<?php } else if ($member->p_level == 6) { ?>
|
||||
<span class="badge bg-success"><?php echo $permissions[6]; ?></span>
|
||||
<?php } else if ($member->p_level == 9) { ?>
|
||||
<span class="badge bg-warning"><?php echo $permissions[9]; ?></span>
|
||||
<?php } ?>
|
||||
@@ -277,6 +279,7 @@
|
||||
<td>
|
||||
<select class="form-select" id="permission" name="permission" required>
|
||||
<option value="3" <?php if ($member->p_level == 3) { echo 'selected'; } ?>><?php echo $permissions[3]; ?></option>
|
||||
<option value="6" <?php if ($member->p_level == 6) { echo 'selected'; } ?>><?php echo $permissions[6]; ?></option>
|
||||
<option value="9" <?php if ($member->p_level == 9) { echo 'selected'; } ?>><?php echo $permissions[9]; ?></option>
|
||||
</select>
|
||||
<div class="mt-2 form-check d-flex justify-content-end text-muted">
|
||||
|
||||
@@ -464,7 +464,9 @@
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<?php } if (clubaccess_check(6) || clubaccess_check(9)) { ?> <!-- Club Access Check -->
|
||||
<li><a class="dropdown-item" href="<?php echo site_url('adif'); ?>" title="Amateur Data Interchange Format (ADIF) import / export"><i class="fas fa-sync"></i> <?= __("ADIF Import / Export"); ?></a></li>
|
||||
<?php } if (clubaccess_check(9)) { ?> <!-- Club Access Check -->
|
||||
|
||||
<li><a class="dropdown-item dropdown-toggle dropdown-toggle-submenu" data-bs-toggle="dropdown"><i class="fas fa-sync"></i> <?= __("Other Export Options"); ?></a>
|
||||
<ul class="submenu submenu-left dropdown-menu">
|
||||
|
||||
Reference in New Issue
Block a user