Added 'calendar_view' setting in models (#182).

This commit is contained in:
Alex Tselegidis 2016-07-17 12:49:27 +02:00
parent f083aa7e49
commit 9c82805b83
3 changed files with 50 additions and 27 deletions

View file

@ -12,7 +12,7 @@
* ---------------------------------------------------------------------------- */
/**
* Admins_Model Class
* Admins Model Class
*
* Handles the database actions for admin users management.
*
@ -233,6 +233,13 @@ class Admins_Model extends CI_Model {
}
}
// Validate calendar view mode.
if (isset($admin['settings']['calendar_view']) && ($admin['settings']['calendar_view'] !== CALENDAR_VIEW_DEFAULT
|| $admin['settings']['calendar_view'] !== CALENDAR_VIEW_TABLE)) {
throw new Exception('The calendar view setting must be either "' . CALENDAR_VIEW_DEFAULT
. '" or "' . CALENDAR_VIEW_TABLE . '", given: ' . $admin['settings']['calendar_view']);
}
// When inserting a record the email address must be unique.
$admin_id = (isset($admin['id'])) ? $admin['id'] : '';

View file

@ -39,7 +39,8 @@
* 'google_token'
* 'google_calendar'
* 'sync_past_days'
* 'sync_future_days'
* 'sync_future_days',
* 'calendar_view'
*
* @package Models
*/
@ -264,6 +265,13 @@ class Providers_Model extends CI_Model {
}
}
// Validate calendar view mode.
if (isset($provider['settings']['calendar_view']) && ($provider['settings']['calendar_view'] !== CALENDAR_VIEW_DEFAULT
|| $provider['settings']['calendar_view'] !== CALENDAR_VIEW_TABLE)) {
throw new Exception('The calendar view setting must be either "' . CALENDAR_VIEW_DEFAULT
. '" or "' . CALENDAR_VIEW_TABLE . '", given: ' . $provider['settings']['calendar_view']);
}
// When inserting a record the email address must be unique.
$provider_id = (isset($provider['id'])) ? $provider['id'] : '';
@ -350,9 +358,10 @@ class Providers_Model extends CI_Model {
* @param string $field_name The field name of the value to be returned.
* @param numeric $provider_id Record id of the value to be returned.
* @return string Returns the selected record value from the database.
*
* @throws Exception When the $field_name argument is not a valid string.
* @throws Exception When the $admin_id is not a valid numeric.
* @throws Exception When the admin record does not exist in the database.
* @throws Exception When the $provider_id is not a valid numeric.
* @throws Exception When the provider record does not exist in the database.
* @throws Exception When the selected field value is not present on database.
*/
public function get_value($field_name, $provider_id) {
@ -364,7 +373,7 @@ class Providers_Model extends CI_Model {
throw new Exception('$field_name argument is not a string: ' . $field_name);
}
// Check whether the admin record exists in database.
// Check whether the provider record exists in database.
$result = $this->db->get_where('ea_users', array('id' => $provider_id));
if ($result->num_rows() == 0) {
throw new Exception('The record with the $provider_id argument does not exist in '

View file

@ -231,6 +231,13 @@ class Secretaries_Model extends CI_Model {
}
}
// Validate calendar view mode.
if (isset($secretary['settings']['calendar_view']) && ($secretary['settings']['calendar_view'] !== CALENDAR_VIEW_DEFAULT
|| $secretary['settings']['calendar_view'] !== CALENDAR_VIEW_TABLE)) {
throw new Exception('The calendar view setting must be either "' . CALENDAR_VIEW_DEFAULT
. '" or "' . CALENDAR_VIEW_TABLE . '", given: ' . $secretary['settings']['calendar_view']);
}
// When inserting a record the email address must be unique.
$secretary_id = (isset($secretary['id'])) ? $secretary['id'] : '';