Add logbook setting for public search
这个提交包含在:
父节点
dc1742f5ff
当前提交
e2ef6c2b20
共有 8 个文件被更改,包括 91 次插入 和 7 次删除
|
|
@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
|
||||||
| be upgraded / downgraded to.
|
| be upgraded / downgraded to.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['migration_version'] = 128;
|
$config['migration_version'] = 129;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,12 @@ class Logbooks extends CI_Controller {
|
||||||
$this->load->view('logbooks/components/publicSlugInputValidation', $data);
|
$this->load->view('logbooks/components/publicSlugInputValidation', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save_publicsearch() {
|
||||||
|
$this->load->model('logbooks_model');
|
||||||
|
$returndata = $this->logbooks_model->save_public_search($this->input->post('public_search'), $this->input->post('logbook_id'));
|
||||||
|
echo "<div class=\"alert alert-success\" role=\"alert\">Public Search Setttings Saved</div>";
|
||||||
|
}
|
||||||
|
|
||||||
public function save_publicslug() {
|
public function save_publicslug() {
|
||||||
$this->load->model('logbooks_model');
|
$this->load->model('logbooks_model');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -456,6 +456,16 @@ class Visitor extends CI_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function public_search_enabled($slug) {
|
||||||
|
$this->load->model('Logbooks_model');
|
||||||
|
$logbook_id = $this->Logbooks_model->public_slug_exists_logbook_id($slug);
|
||||||
|
if ($this->Logbooks_model->public_search_enabled($logbook_id) == 1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function search() {
|
public function search() {
|
||||||
$slug = $this->security->xss_clean($this->uri->segment(3));
|
$slug = $this->security->xss_clean($this->uri->segment(3));
|
||||||
$callsign = $this->security->xss_clean($this->uri->segment(4));
|
$callsign = $this->security->xss_clean($this->uri->segment(4));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This adds an option to enable public search per logbook
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Migration_add_public_search_option extends CI_Migration {
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (!$this->db->field_exists('public_search', 'station_logbooks')) {
|
||||||
|
$fields = array(
|
||||||
|
'public_search integer DEFAULT 0 AFTER public_slug',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->dbforge->add_column('station_logbooks', $fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
if ($this->db->field_exists('public_search', 'logbooks')) {
|
||||||
|
$this->dbforge->drop_column('logbooks', 'public_search');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -210,6 +210,16 @@ class Logbooks_model extends CI_Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function save_public_search($public_search, $logbook_id) {
|
||||||
|
$data = array(
|
||||||
|
'public_search' => xss_clean($public_search),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
|
$this->db->where('logbook_id', xss_clean($logbook_id));
|
||||||
|
$this->db->update('station_logbooks', $data);
|
||||||
|
}
|
||||||
|
|
||||||
function save_public_slug($public_slug, $logbook_id) {
|
function save_public_slug($public_slug, $logbook_id) {
|
||||||
$data = array(
|
$data = array(
|
||||||
'public_slug' => xss_clean($public_slug),
|
'public_slug' => xss_clean($public_slug),
|
||||||
|
|
@ -322,5 +332,14 @@ class Logbooks_model extends CI_Model {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function public_search_enabled($logbook_id) {
|
||||||
|
$this->db->select('public_search');
|
||||||
|
$this->db->where('logbook_id', $logbook_id);
|
||||||
|
|
||||||
|
$query = $this->db->get('station_logbooks');
|
||||||
|
|
||||||
|
return $query->result_array()[0]['public_search'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,18 @@
|
||||||
Visit Public Page <a href="<?php echo site_url('visitor'); ?>/<?php echo $station_logbook_details->public_slug; ?>" target="_blank"><?php echo site_url('visitor'); ?>/<?php echo $station_logbook_details->public_slug; ?></a>
|
Visit Public Page <a href="<?php echo site_url('visitor'); ?>/<?php echo $station_logbook_details->public_slug; ?>" target="_blank"><?php echo site_url('visitor'); ?>/<?php echo $station_logbook_details->public_slug; ?></a>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<form style="display: inline;">
|
||||||
|
<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>">
|
||||||
|
<p>Enabling public search function offers a search input box on the public logbook page accessed via public slug. Search only covers this logbook.</p>
|
||||||
|
<label for="public_search">Public search enabled</label>
|
||||||
|
<select class="custom-select" id="public_search" name="public_search" hx-post="<?php echo site_url('logbooks/save_publicsearch/'); ?>" hx-target="#publicSearchForm" hx-trigger="change">
|
||||||
|
<option value="1" <?php if ($station_logbook_details->public_search == 1) { echo " selected =\"selected\""; } ?>><?php echo lang('general_word_yes'); ?></option>
|
||||||
|
<option value="0" <?php if ($station_logbook_details->public_search == 0) { echo " selected =\"selected\""; } ?>><?php echo lang('general_word_no'); ?></option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
<p>
|
||||||
|
<div id="publicSearchForm">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
<th scope="col">Edit</th>
|
<th scope="col">Edit</th>
|
||||||
<th scope="col">Delete</th>
|
<th scope="col">Delete</th>
|
||||||
<th scope="col">Link</th>
|
<th scope="col">Link</th>
|
||||||
|
<th scope="col">Public Search</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -65,6 +66,13 @@
|
||||||
<a target="_blank" href="<?php echo site_url('visitor')."/".$row->public_slug; ?>" class="btn btn-outline-primary btn-sm" ><i class="fas fa-globe" title="View Public Page for <?php echo $row->logbook_name;?> Logbook"></i> </a>
|
<a target="_blank" href="<?php echo site_url('visitor')."/".$row->public_slug; ?>" class="btn btn-outline-primary btn-sm" ><i class="fas fa-globe" title="View Public Page for <?php echo $row->logbook_name;?> Logbook"></i> </a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php if ($row->public_search == 1) {
|
||||||
|
echo "<span class=\"badge badge-success\">Enabled</span>";
|
||||||
|
} else {
|
||||||
|
echo "<span class=\"badge badge-dark\">Disabled</span>";
|
||||||
|
} ?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -73,13 +73,14 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div style="paddling-left: 0.5rem; padding-right: 0.5rem"></div>
|
<div style="paddling-left: 0.5rem; padding-right: 0.5rem"></div>
|
||||||
<?php if($this->optionslib->get_option('global_search') != "false" || $this->session->userdata('user_type') >= 2) { ?>
|
<?php $this->CI =& get_instance();
|
||||||
<form method="post" action="" class="form-inline">
|
if ($this->CI->public_search_enabled($slug) || $this->session->userdata('user_type') >= 2) { ?>
|
||||||
<input class="form-control mr-sm-2" id="callsign" type="search" name="callsign" placeholder="<?php echo lang('menu_search_text'); ?>" aria-label="Search">
|
<form method="post" action="" class="form-inline">
|
||||||
|
<input class="form-control mr-sm-2" id="callsign" type="search" name="callsign" placeholder="<?php echo lang('menu_search_text'); ?>" aria-label="Search">
|
||||||
|
|
||||||
<button onclick="publicSearchButtonPress()" class="btn btn-outline-success my-2 my-sm-0" type="submit"><i class="fas fa-search"></i> <?php echo lang('menu_search_button'); ?></button>
|
<button onclick="publicSearchButtonPress()" class="btn btn-outline-success my-2 my-sm-0" type="submit"><i class="fas fa-search"></i> <?php echo lang('menu_search_button'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用