diff --git a/application/models/Options_model.php b/application/models/Options_model.php index 717c0a78..56c847b7 100644 --- a/application/models/Options_model.php +++ b/application/models/Options_model.php @@ -2,7 +2,7 @@ /* Class: Options_model - This model handles all database interactions for the options table + This model handles all database interactions for the options table used for global settings within cloudlog. */ @@ -12,7 +12,7 @@ class Options_model extends CI_Model { { parent::__construct(); } - + // Returns all options that are autoload yes function get_autoloads() { $this->db->where('autoload', "yes"); @@ -25,7 +25,11 @@ class Options_model extends CI_Model { $query = $this->db->get('options'); $row = $query->row(); - return $row->option_value; + if (isset($row->option_value)) { + return $row->option_value; + } + + return null; } /* @@ -50,7 +54,7 @@ class Options_model extends CI_Model { 'option_value' => $option_value, 'autoload' => $autoload, ); - + // Save to database $this->db->insert('options', $data); @@ -70,25 +74,25 @@ class Options_model extends CI_Model { $this->db->where('option_name', $option_name); $query = $this->db->get('options'); + $data = array( + 'option_name' => $option_name, + 'option_value' => $option_value, + ); + if($query->num_rows() > 0) { // Update the Entry - $data = array( - 'option_name' => $option_name, - 'option_value' => $option_value, - ); - $this->db->where('option_name', $option_name); $this->db->update('options', $data); return TRUE; - } else { + } else { // Save to database $this->db->insert('options', $data); return FALSE; - } + } } } -?> \ No newline at end of file +?> diff --git a/application/models/User_model.php b/application/models/User_model.php index 0652d707..ab368d51 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -276,13 +276,13 @@ class User_Model extends CI_Model { 'user_measurement_base' => $u->row()->user_measurement_base, 'user_date_format' => $u->row()->user_date_format, 'user_stylesheet' => $u->row()->user_stylesheet, - 'user_sota_lookup' => $u->row()->user_sota_lookup, - 'user_show_notes' => $u->row()->user_show_notes, - 'user_column1' => $u->row()->user_column1, - 'user_column2' => $u->row()->user_column2, - 'user_column3' => $u->row()->user_column3, - 'user_column4' => $u->row()->user_column4, - 'user_column5' => $u->row()->user_column5, + 'user_sota_lookup' => isset($u->row()->user_sota_lookup) ? $u->row()->user_sota_lookup : 0, + 'user_show_notes' => isset($u->row()->user_show_notes) ? $u->row()->user_show_notes : 1, + 'user_column1' => isset($u->row()->user_column1) ? $u->row()->user_column1: 'Mode', + 'user_column2' => isset($u->row()->user_column2) ? $u->row()->user_column2: 'RSTS', + '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', ); $this->session->set_userdata($userdata);