Code added to have an active logbook and code to set it all up

这个提交包含在:
Peter Goodhall 2021-09-07 18:07:48 +01:00
父节点 56e7827fe7
当前提交 ce1d7a5351
共有 7 个文件被更改,包括 50 次插入5 次删除

查看文件

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 73;
$config['migration_version'] = 74;
/*
|--------------------------------------------------------------------------

查看文件

@ -96,6 +96,14 @@ class Logbooks extends CI_Controller {
}
}
public function set_active($id) {
$this->load->model('logbooks_model');
$this->logbooks_model->set_logbook_active($id);
$this->user_model->update_session($this->session->userdata('user_id'));
redirect('logbooks');
}
public function delete($id) {
$this->load->model('logbooks_model');
$this->logbooks_model->delete($id);

查看文件

@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
* This migration creates a table called options which will hold global options needed within cloudlog
* removing the need for lots of configuration files.
*/
class Migration_add_active_station_logbook_to_user_table extends CI_Migration {
public function up()
{
$fields = array(
'active_station_logbook int(11)',
);
$this->dbforge->add_column('users', $fields);
}
public function down()
{
$this->dbforge->drop_column('users', 'active_station_logbook');
}
}

查看文件

@ -45,6 +45,15 @@ class Logbooks_model extends CI_Model {
$this->db->update('station_logbooks', $data);
}
function set_logbook_active($id) {
$data = array(
'active_station_logbook' => xss_clean($id),
);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->update('users', $data);
}
function logbook($id) {
// Clean ID
$clean_id = $this->security->xss_clean($id);

查看文件

@ -283,6 +283,7 @@ class User_Model extends CI_Model {
'user_column3' => isset($u->row()->user_column3) ? $u->row()->user_column3: 'RSTR',
'user_column4' => isset($u->row()->user_column4) ? $u->row()->user_column4: 'Band',
'user_column5' => isset($u->row()->user_column5) ? $u->row()->user_column5: 'Country',
'active_station_logbook' => $u->row()->active_station_logbook,
);
$this->session->set_userdata($userdata);

查看文件

@ -45,7 +45,7 @@
<label for="StationLocationsSelect">Select Available Station Locations</label>
<select name="SelectedStationLocations[]" class="form-control" id="StationLocationsSelect" multiple aria-describedby="StationLocationSelectHelp">
<?php foreach ($station_locations_list->result() as $row) { ?>
<option value="<?php echo $row->station_id;?>" <?php if (in_array($row->station_id, $station_locations_array)) { echo "selected"; } ?>><?php echo $row->station_profile_name;?> (Callsign: <?php echo $row->station_callsign;?> DXCC: <?php echo $row->station_country;?>)</option>
<option value="<?php echo $row->station_id;?>" <?php if ($station_locations_array != FALSE && in_array($row->station_id, $station_locations_array)) { echo "selected"; } ?>><?php echo $row->station_profile_name;?> (Callsign: <?php echo $row->station_callsign;?> DXCC: <?php echo $row->station_country;?>)</option>
<?php } ?>
</select>
<small id="StationLocationSelectHelp" class="form-text text-muted">Hold down the Ctrl (windows) or Command (Mac) button to select multiple options.</small>

查看文件

@ -37,10 +37,12 @@
</td>
<td>
<a href="<?php echo site_url('logbooks/edit')."/".$row->logbook_id; ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i> Edit</a>
</td>
<?php if($this->session->userdata('active_station_logbook') != $row->logbook_id) { ?>
<a href="<?php echo site_url('logbooks/set_active')."/".$row->logbook_id; ?>" class="btn btn-outline-primary btn-sm">Set as Active Logbook</a>
<?php } ?>
<a href="<?php echo site_url('logbooks/edit')."/".$row->logbook_id; ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i> Edit</a>
<td>
<a href="<?php echo site_url('Logbooks/delete')."/".$row->logbook_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete station profile <?php echo $row->logbook_name; ?> this will delete all QSOs within this station logbook?');"><i class="fas fa-trash-alt"></i> Delete Station Logbook</a>
</td>
</tr>