diff --git a/application/controllers/Welcome.php b/application/controllers/Welcome.php index abf6882a..0e0be63e 100644 --- a/application/controllers/Welcome.php +++ b/application/controllers/Welcome.php @@ -21,6 +21,14 @@ class Welcome extends CI_Controller { $this->load->model('logbooks_model'); $data['NumberOfStationLogbooks'] = $this->logbooks_model->CountAllStationLogbooks(); + // load api model + $this->load->model('api_model'); + $data['NumberOfAPIKeys'] = $this->api_model->CountKeysWithNoUserID(); + + // load note model + $this->load->model('note'); + $data['NumberOfNotes'] = $this->note->CountAllNotes(); + // load views $this->load->view('interface_assets/mini_header', $data); $this->load->view('welcome/index'); @@ -52,4 +60,30 @@ class Welcome extends CI_Controller { echo "Error Creating Default Logbook during Migration. See Logs for further information"; } } + + public function claimnotes() { + try { + // load model Stations and call function ClaimAllStationLocations + $this->load->model('note'); + $this->note->ClaimAllNotes(); + + echo "Notes all claimed"; + } catch (Exception $e) { + log_message('error', 'Error claiming notes during Migration. '.$e->getMessage()); + echo "Error claiming notes during Migration. See Logs for further information"; + } + } + + public function claimapikeys() { + try { + // load model Stations and call function ClaimAllStationLocations + $this->load->model('api_model'); + $this->api_model->ClaimAllAPIKeys(); + + echo "All API Keys claimed"; + } catch (Exception $e) { + log_message('error', 'Error claiming API Keys during Migration. '.$e->getMessage()); + echo "Error claiming API Keys during Migration. See Logs for further information"; + } + } } \ No newline at end of file diff --git a/application/models/Api_model.php b/application/models/Api_model.php index 435869b3..fd8812ce 100644 --- a/application/models/Api_model.php +++ b/application/models/Api_model.php @@ -14,6 +14,25 @@ class API_Model extends CI_Model { return $this->db->get('api'); } + function CountKeysWithNoUserID() { + $this->db->where('user_id !=', NULL); + return $this->db->count_all('api'); + } + + function ClaimAllAPIKeys($id = NULL) { + // if $id is empty then use session user_id + if (empty($id)) { + // Get the first USER ID from user table in the database + $id = $this->db->get("users")->row()->user_id; + } + + $data = array( + 'user_id' => $id, + ); + + $this->db->update('api', $data); + } + function key_description($key) { $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('key', $key); diff --git a/application/models/Note.php b/application/models/Note.php index 0390bd15..816d904c 100644 --- a/application/models/Note.php +++ b/application/models/Note.php @@ -41,6 +41,27 @@ class Note extends CI_Model { return $this->db->get('notes'); } + function ClaimAllNotes($id = NULL) { + // if $id is empty then use session user_id + if (empty($id)) { + // Get the first USER ID from user table in the database + $id = $this->db->get("users")->row()->user_id; + } + + $data = array( + 'user_id' => $id, + ); + + $this->db->update('notes', $data); + } + + function CountAllNotes() { + // count all notes + // where user_id is not NULL + $this->db->where('user_id !=', NULL); + return $this->db->count_all('notes'); + } + } ?> diff --git a/application/views/welcome/index.php b/application/views/welcome/index.php index 73dcf880..31a95880 100644 --- a/application/views/welcome/index.php +++ b/application/views/welcome/index.php @@ -59,10 +59,10 @@ # Update the Cloudlog installation every day at midnight
- 0 0 * * * /bin/bash -c "/cloudlog.sh"
+ 0 0 * * * /bin/bash -c "Full-Path-To-Bash-Script/cloudlog.sh"

# Upload QSOs to Club Log (ignore cron job if this integration is not required)
- 0 */6 * * * curl --silent /clublog/upload/ &>/dev/null
+ 0 */6 * * * curl --silent /clublog/upload/username-with-clublog-login &>/dev/null

# Upload QSOs to LoTW if certs have been provided every hour.
0 */1 * * * curl --silent /lotw/lotw_upload &>/dev/null
@@ -90,7 +90,7 @@
- +
Assign ALL Station Locations to this username
@@ -102,7 +102,7 @@
- +
Create Station Logbooks
@@ -115,6 +115,30 @@
+ +
+
Claim Notes
+
+

Looks like you have some notes saved, we need to assign them to your username.

+ +
+
+ +
+ + + +
+
Claim API Keys
+
+

Looks like you have some API Keys, we need to assign them to your username else they will stop working.

+ +
+
+ +
+ +
Update Country Files