Produced by Araxis Merge on 8/16/2019 12:02:04 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Direct_DSM.zip\Direct_DSM\webmail\application\controllers | Settings.php | Tue Aug 13 17:30:08 2019 UTC |
| 2 | Direct_DSM.zip\Direct_DSM\webmail\application\controllers | Settings.php | Fri Aug 16 14:41:25 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 810 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | <?php if ( ! defined ('BASEPATH ')) exit(' No direct script acc ess allowe d'); | |
| 2 | ||
| 3 | require_on ce APPPATH .'controll ers/restri cted_contr oller.php' ; | |
| 4 | ||
| 5 | class Sett ings exten ds Restric ted_contro ller { | |
| 6 | pu blic $help _video; | |
| 7 | ||
| 8 | pu blic funct ion __cons truct(){ | |
| 9 | pare nt::__cons truct(); | |
| 10 | requ ire_librar y('video') ; | |
| 11 | $thi s->load->l ibrary('au dit'); | |
| 12 | ||
| 13 | try{ $this->he lp_video = new Video ('how-to-s et-up-va-d irect'); } catch(Exc eption $e) { $this->e rror->warn ing($e->ge tMessage() ); } | |
| 14 | ||
| 15 | } | |
| 16 | ||
| 17 | pu blic funct ion ajax_t imezone_li st($countr y = NULL) { | |
| 18 | if(! isset($cou ntry)) ret urn; //cou ld replace this with a 404 sin ce country is clearl y required , but that might bre ak the js -- MG 2016 -06-1 | |
| 19 | echo $this->js on->encode ($this->ti mezone_opt ions_for_c ountry($co untry)); | |
| 20 | } | |
| 21 | ||
| 22 | pu blic funct ion index( ){ | |
| 23 | requ ire_librar y('form_ma rkup_gener ator/user_ form_marku p_generato r'); | |
| 24 | $mar kup_genera tor = new User_form_ markup_gen erator($th is->user); | |
| 25 | ||
| 26 | if(e mpty($_POS T) && !$ma rkup_gener ator->load _saved_val ues() && $ this->api- >http_stat us != 200) { | |
| 27 | $this- >session-> set_error_ message('Y ou have no t granted this appli cation per mission to manage yo ur account informati on.'); | |
| 28 | redire ct('settin gs/applica tion'); | |
| 29 | return $this->er ror->warni ng($this-> user->user name.' has not grant ed this ap plication permission to manage account i nformation '); //back up in case the redir ect fails | |
| 30 | } | |
| 31 | ||
| 32 | if(! empty($_PO ST)){ | |
| 33 | $marku p_generato r->set_val ues_from_p ost(); | |
| 34 | if(!$m arkup_gene rator->val idates()){ | |
| 35 | $error_m essage = ' <strong>We need you to make a few change s to this form.</str ong> '.ul _if_multip le($markup _generator ->validati on_message s); | |
| 36 | }elsei f(!$markup _generator ->save_val ues()){ | |
| 37 | $error_m essage = $ this->lang ->line('er ror_generi c'); | |
| 38 | }else{ | |
| 39 | $success _message = '<strong> Success!</ strong>&nb sp; Y our accoun t settings have been updated.' ; | |
| 40 | $markup_ generator- >load_save d_values() ; | |
| 41 | } | |
| 42 | } | |
| 43 | ||
| 44 | $tit le = PORTA L_TITLE_PR EFIX . 'Ac count Sett ings'; | |
| 45 | $thi s->load->v iew('setti ngs/index' , compact( 'markup_ge nerator',' title', 'e rror_messa ge', 'succ ess_messag e')); | |
| 46 | } | |
| 47 | ||
| 48 | pu blic funct ion applic ation() { | |
| 49 | requ ire_librar y('form_ma rkup_gener ator'); | |
| 50 | $mar kup_genera tor = new Form_marku p_generato r(); | |
| 51 | $tit le = PORTA L_TITLE_PR EFIX . 'Ap plication Settings'; | |
| 52 | $cou ntries = $ this->loca le->get_co untries(); | |
| 53 | $err or_message = null; | |
| 54 | $tim ezone_opti ons = arra y(); | |
| 55 | ||
| 56 | ||
| 57 | ||
| 58 | if(! empty($_PO ST)){ | |
| 59 | $count ry = $this ->input->p ost('count ry', TRUE) ; | |
| 60 | $timez one = $thi s->input-> post('time zone', TRU E); | |
| 61 | ||
| 62 | $timez one_option s = array( ); | |
| 63 | if (!e mpty($coun try)) { | |
| 64 | $timezon e_options = $this->t imezone_op tions_for_ country($c ountry); | |
| 65 | } | |
| 66 | ||
| 67 | if( | |
| 68 | !array_k ey_exists( $country, $countries ) | |
| 69 | || !arra y_key_exis ts($timezo ne, $timez one_option s) | |
| 70 | ) { | |
| 71 | ||
| 72 | // inval id country and/or ti mezone | |
| 73 | $country = null; | |
| 74 | $timezon e = null; | |
| 75 | $timezon e_options = array(); | |
| 76 | ||
| 77 | } else { | |
| 78 | $updated = $this-> db->update ( | |
| 79 | 'users', | |
| 80 | array( | |
| 81 | 'u ser_locale ' => seria lize(compa ct('countr y', 'timez one')) | |
| 82 | ), | |
| 83 | array( | |
| 84 | 'u ser_id' => $this->us er->id() | |
| 85 | ) | |
| 86 | ); | |
| 87 | if ($upd ated) { | |
| 88 | $success_m essage = ' <strong>Su ccess!</st rong>  ; Loc ale settin gs success fully upda ted.'; | |
| 89 | }else { | |
| 90 | // somethi ng went wr ong with t he form su bmission | |
| 91 | $error_mes sage = $th is->lang-> line('erro r_generic' ); | |
| 92 | } | |
| 93 | } | |
| 94 | } | |
| 95 | ||
| 96 | if(e mpty($coun try)) { | |
| 97 | $count ry = $this ->user->co untry(); | |
| 98 | } | |
| 99 | if(e mpty($time zone)) { | |
| 100 | $timez one = $thi s->user->t imezone(); | |
| 101 | } | |
| 102 | ||
| 103 | if ( !empty($co untry)) { | |
| 104 | $timez one_option s = $this- >timezone_ options_fo r_country( $country); | |
| 105 | } | |
| 106 | ||
| 107 | $thi s->load->v iew('setti ngs/applic ation', co mpact( | |
| 108 | 'marku p_generato r', | |
| 109 | 'title ', | |
| 110 | 'count ries', | |
| 111 | 'count ry', | |
| 112 | 'timez one', | |
| 113 | 'timez one_option s', | |
| 114 | 'error _message', | |
| 115 | 'succe ss_message ')); | |
| 116 | } | |
| 117 | ||
| 118 | ||
| 119 | pu blic funct ion automa tic_replie s(){ | |
| 120 | requ ire_model( 'automatic _reply'); | |
| 121 | $suc cess_messa ge = null; | |
| 122 | $dat a = array( ); | |
| 123 | ||
| 124 | //if the form hasn't bee n submitte d yet, set it up | |
| 125 | if(e mpty($_POS T)){ | |
| 126 | $reply = Automat ic_reply:: find_one( array('mai lbox' =>$t his->user- >username) ); | |
| 127 | if(Aut omatic_rep ly::is_an_ entity($re ply)){ | |
| 128 | $data = array_merg e($data, $ reply->val ues(array( 'content', 'start_at ', 'end_at '))); | |
| 129 | $data['s end_automa tic_replie s'] = true ; | |
| 130 | $data['s end_within _time_peri od'] = (!e mpty($data ['start_at ']) && !em pty($data[ 'end_at']) ); | |
| 131 | } | |
| 132 | ||
| 133 | if(emp ty($data[' start_at'] )) | |
| 134 | $data['s tart_at'] = now(); | |
| 135 | if(emp ty($data[' end_at'])) | |
| 136 | $data['e nd_at'] = strtotime( 'tomorrow' ); | |
| 137 | ||
| 138 | $data[ 'start_dat e'] = date ("D m/d/Y" , $data['s tart_at']) ; | |
| 139 | ||
| 140 | ||
| 141 | //modi fy time to round dow n in half hour incre ments. | |
| 142 | $start _hour = da te("H", $d ata['start _at']); | |
| 143 | $start _minutes = date("i", $data['st art_at']); | |
| 144 | if($st art_minute s < 30) { //if we're exactly a t the hour , it's fin e to just use that a s the tmie | |
| 145 | $start_m inutes = ' 00'; | |
| 146 | }elsei f($start_m inutes >= 30){ | |
| 147 | $start_m inutes = ' 30'; | |
| 148 | } | |
| 149 | ||
| 150 | $data[ 'start_tim e'] = $sta rt_hour.': '.$start_m inutes; | |
| 151 | ||
| 152 | ||
| 153 | $data[ 'end_date' ] = date(" D m/d/Y", $data['end _at']); | |
| 154 | $data[ 'end_time' ] = (empty ($data['en d_at'])) ? '' : date ("H:i", $d ata['end_a t']); | |
| 155 | }els e{ | |
| 156 | //if t he form ha s been sub mitted, va lidate and save | |
| 157 | ||
| 158 | $form_ data = $th is->input- >post(arra y('send_au tomatic_re plies', 's end_within _time_peri od', 'star t_date', ' start_time ', 'end_da te', 'end_ time', 'co ntent'), T RUE); | |
| 159 | ||
| 160 | //SET UP FORM VA LIDATION | |
| 161 | $this- >form_vali dation->se t_rules('s end_automa tic_replie s','Automa tic Replie s','requir ed|is_natu ral|in_lis t[0,1]|xss _clean'); | |
| 162 | $this- >form_vali dation->se t_rules('s end_within _time_peri od','Time Period', ' is_natural |greater_t han[0]|les s_than[2]| xss_clean' ); | |
| 163 | ||
| 164 | if(emp ty($form_d ata['send_ automatic_ replies']) ){ | |
| 165 | $form_da ta['conten t'] = ''; //diregard any value for conte nt if we'r e not send ing automa tic replie s | |
| 166 | }else{ | |
| 167 | $this->f orm_valida tion->set_ rules('con tent', 'Me ssage Body ', 'requir ed|visible _content_r equired', | |
| 168 | array( 'visible_c ontent_req uired' => 'The {fiel d} is requ ired.')); | |
| 169 | ||
| 170 | if(empty ($form_dat a['send_wi thin_time_ period'])) { | |
| 171 | $form_data ['start_da te'] = $fo rm_data['s tart_time' ] = $form_ data['end_ date'] = $ form_data[ 'end_time' ] = ''; // disregard all time v alues if w e're not s ending wit hin a time period | |
| 172 | }else{ | |
| 173 | ||
| 174 | $time_opti ons = $thi s->options _for_time_ dropdown() ; | |
| 175 | ||
| 176 | $this->for m_validati on->set_ru les('start _date', 'S tart Date' , 'require d|date_mat ches_forma t[D m/d/Y] |date_is_g reater_tha n['.(strto time('toda y') - 1).' ]', | |
| 177 | arra y('date_ma tches_form at' => 'Th e {field} must be a date forma tted MM/DD /YYYY.', | |
| 178 | 'date_is_g reater_tha n' => 'The {field} c annot be i n the past .')); | |
| 179 | ||
| 180 | $this->for m_validati on->set_ru les('start _time', 'S tart Time' , 'require d|in_list[ '.implode( ',', array _keys($tim e_options) ).']', arr ay('in_lis t' => 'The {field} i s invalid. ')); | |
| 181 | ||
| 182 | $this->for m_validati on->set_ru les('end_d ate', 'End Date', 'r equired|da te_matches _format[D m/d/Y]|dat e_is_great er_than_or _equal_to[ '.$form_da ta['start_ date'].']' , | |
| 183 | arra y('date_ma tches_form at' => 'Th e {field} must be a date forma tted MM/DD /YYYY.', | |
| 184 | 'date_is_g reater_tha n_or_equal _to' => 'T he Start D ate must b e before t he {field} .')); | |
| 185 | ||
| 186 | $this->for m_validati on->set_ru les('end_t ime', 'End Time', 'r equired|in _list['.im plode(',', array_key s($time_op tions)).'] ', array(' in_list' = > 'The {fi eld} is in valid.')); | |
| 187 | } | |
| 188 | ||
| 189 | } | |
| 190 | ||
| 191 | //SAVE THE DATA IF IT'S VA LID | |
| 192 | $data[ 'validatio n_errors'] = array() ; | |
| 193 | if($th is->form_v alidation- >run() == true) { | |
| 194 | if(!empt y($form_da ta['send_a utomatic_r eplies']) && !empty( $form_data ['send_wit hin_time_p eriod']) & & strtotim e($form_da ta['start_ date'].' ' .$form_dat a['start_t ime']) >= strtotime( $form_data ['end_date '].' '.$fo rm_data['e nd_time']) ){ | |
| 195 | $data['val idation_er rors'][] = 'The End Date must be after t he Start D ate.'; | |
| 196 | }else{ | |
| 197 | require_mo del('autom atic_reply '); | |
| 198 | $reply = A utomatic_r eply::find _one( arra y('mailbox ' => $this ->user->us ername) ); | |
| 199 | ||
| 200 | if(empty($ form_data[ 'send_auto matic_repl ies']) && Automatic_ reply::is_ an_entity( $reply)){ | |
| 201 | Au tomatic_re ply::delet e($reply-> id); | |
| 202 | }elseif(!e mpty($form _data['sen d_automati c_replies' ])){ | |
| 203 | if (!Automati c_reply::i s_an_entit y($reply)) $reply = new Automa tic_reply( ); | |
| 204 | $r eply->cont ent = $for m_data['co ntent']; | |
| 205 | ||
| 206 | $r eply->star t_at = (!e mpty($form _data['sta rt_date']) ? strtoti me($form_d ata['start _date'].' '.$form_da ta['start_ time']) : NULL); | |
| 207 | $r eply->end_ at = (!emp ty($form_d ata['end_d ate']) ? s trtotime($ form_data[ 'end_date' ].' '.$for m_data['en d_time']) : NULL); | |
| 208 | $s uccess = $ reply->sav e(); | |
| 209 | // For some reason, !$ success is the succe ss conditi on here | |
| 210 | if (!$success ) { | |
| 211 | $dat a['success _message'] = '<stron g>Success! </strong>& nbsp;  ; Automati c Replies successful ly updated .'; | |
| 212 | }e lse { | |
| 213 | $dat a['validat ion_errors '][] = $th is->lang-> line('erro r_generic' ); | |
| 214 | } | |
| 215 | } | |
| 216 | // User do es not wan t to send automatic replies | |
| 217 | if(empty($ form_data[ 'send_auto matic_repl ies'])) { | |
| 218 | $d ata['succe ss_message '] = '<str ong>Succes s!</strong > &nb sp; Automa tic Replie s successf ully updat ed.'; | |
| 219 | } | |
| 220 | } | |
| 221 | } | |
| 222 | ||
| 223 | $data = array_me rge($data, $form_dat a); | |
| 224 | if(!em pty($data[ 'validatio n_errors'] ) ) { | |
| 225 | $data['v alidation_ errors'] = array_mer ge(explode ("\n", tri m(validati on_errors( ))), $data ['validati on_errors' ]); | |
| 226 | } | |
| 227 | } | |
| 228 | ||
| 229 | $dat a['title'] = PORTAL_ TITLE_PREF IX . ' Aut omatic Rep ly (Out of Office) S ettings'; | |
| 230 | $dat a['time_op tions'] = $this->opt ions_for_t ime_dropdo wn(); | |
| 231 | $thi s->load->v iew('setti ngs/automa tic_replie s',$data); | |
| 232 | } | |
| 233 | ||
| 234 | ||
| 235 | ||
| 236 | pu blic funct ion notifi cations() { | |
| 237 | $suc cess_messa ge = null; | |
| 238 | $err or_message = null; | |
| 239 | $dat a = $this- >get_user_ db_info(); | |
| 240 | $thi s->load->d atabase(); | |
| 241 | ||
| 242 | $thi s->form_va lidation-> set_rules( "ext_mail" ,"External Email","r equired|ca llback_va_ email","xs s_clean"); | |
| 243 | if($ this->form _validatio n->run() = = true) { | |
| 244 | $get_u ser_id = $ this->db-> query("SEL ECT user_i d FROM use rs WHERE u ser_name=" . $this-> db->escape ($this->se ssion->use rdata("use rname"))); | |
| 245 | if($ge t_user_id) { | |
| 246 | if($get_ user_id->n um_rows() == 1) { | |
| 247 | $row = $ge t_user_id- >row_array (); | |
| 248 | $user_id = $row["use r_id"]; | |
| 249 | } | |
| 250 | } | |
| 251 | if(iss et($user_i d)) { | |
| 252 | $ext_mai l = $this- >input->po st("ext_ma il",TRUE); | |
| 253 | if(array _key_exist s("notify" ,$this->in put->post( NULL,TRUE) ) && array _key_exist s('group_n otify',$th is->input- >post(NULL ,TRUE))) { | |
| 254 | $this->db- >query("UP DATE users SET user_ mail =" . $this->db- >escape($e xt_mail) . ", user_e xt_notify_ flag=1, us er_ext_gro up_notify_ flag=1 WHE RE user_id =" . $this ->db->esca pe($user_i d)); | |
| 255 | } | |
| 256 | else if( array_key_ exists('no tify',$thi s->input-> post(NULL, TRUE))) { | |
| 257 | $this->db- >query("UP DATE users SET user_ mail =" . $this->db- >escape($e xt_mail) . ", user_e xt_notify_ flag=1, us er_ext_gro up_notify_ flag=0 WHE RE user_id =" . $this ->db->esca pe($user_i d)); | |
| 258 | } | |
| 259 | else if( array_key_ exists('gr oup_notify ',$this->i nput->post (NULL,TRUE ))) { | |
| 260 | $this->db- >query("UP DATE users SET user_ mail =" . $this->db- >escape($e xt_mail) . ", user_e xt_notify_ flag=0, us er_ext_gro up_notify_ flag=1 WHE RE user_id =" . $this ->db->esca pe($user_i d)); | |
| 261 | } | |
| 262 | else { | |
| 263 | $this->db- >query("UP DATE users SET user_ mail =" . $this->db- >escape($e xt_mail) . ", user_e xt_notify_ flag=0, us er_ext_gro up_notify_ flag=0 WHE RE user_id =" . $this ->db->esca pe($user_i d)); | |
| 264 | } | |
| 265 | ||
| 266 | //if we reach this point pre sumably it was succe ssful | |
| 267 | $get_act or_id = $t his->db->q uery("SELE CT user_id FROM user s WHERE us er_deleted _flag = 0 AND user_n ame=" . $t his->db->e scape($thi s->session ->userdata ("username "))); | |
| 268 | if($get_ actor_id) { | |
| 269 | $actor_id_ row = $get _actor_id- >row_array (); | |
| 270 | $actor_id = $actor_i d_row["use r_id"]; | |
| 271 | $target_id = $actor_ id; | |
| 272 | $this->loa d->library ("audit"); | |
| 273 | $this->aud it->log_ev ent("edit" ,array($ta rget_id,$a ctor_id,"U pdate user informati on",date(' U'))); | |
| 274 | } | |
| 275 | $data['e xt_mail']= $ext_mail; | |
| 276 | $data['n otify'] = array_key_ exists('no tify',$thi s->input-> post(NULL, TRUE)); | |
| 277 | $data['g roup_notif y'] = arra y_key_exis ts('group_ notify',$t his->input ->post(NUL L,TRUE)); | |
| 278 | $data['s uccess_mes sage'] = ' <strong>Su ccess!</st rong>  ; No tification settings were succe ssfully up dated.'; | |
| 279 | } | |
| 280 | else { | |
| 281 | $data['e rror_messa ge'] = 'Fa iled to up date setti ngs.'; | |
| 282 | } | |
| 283 | }els e { | |
| 284 | // Val idation fa iled | |
| 285 | $ext_m ail_error = (strlen( form_error ('ext_mail ')) > 0) ? form_erro r('ext_mai l') : null ; | |
| 286 | $valid ation_erro rs = array ('ext_mail '=>$ext_ma il_error); | |
| 287 | if($ex t_mail_err or){ | |
| 288 | foreach( $validatio n_errors a s $e){ | |
| 289 | $data['err or_message '] .= $e; | |
| 290 | } | |
| 291 | } | |
| 292 | } | |
| 293 | //pa ss group m ailbox inf o if there is any | |
| 294 | $gro up_mailbox es = $this ->session- >userdata( 'group_mai lboxes'); | |
| 295 | if(i s_array($g roup_mailb oxes)) { $ data['grou p_mailboxe s'] = $gro up_mailbox es; } | |
| 296 | //pa ss persona l mailbox hidden dat a | |
| 297 | $dat a['hide_pe rsonal_mai lbox'] = F ALSE; | |
| 298 | if(! is_null($t his->sessi on->userda ta('hide_p ersonal_ma ilbox')) & & $this->s ession->us erdata('hi de_persona l_mailbox' ) !== FALS E) { $data ['hide_per sonal_mail box'] = TR UE; } | |
| 299 | $thi s->load->v iew('setti ngs/notifi cations',$ data); | |
| 300 | } | |
| 301 | ||
| 302 | pr otected fu nction che ck_date($s tart, $end ){ | |
| 303 | $dat es = array (); | |
| 304 | if(( $st=strtot ime($start )) == TRUE ){ $dates[ 'start'] = $st; } | |
| 305 | else { $dates[' start'] = null; } | |
| 306 | if(( $en=strtot ime($end)) == TRUE){ $dates['e nd'] = $en ; } | |
| 307 | else { $dates[ 'end'] = n ull; } | |
| 308 | retu rn $dates; | |
| 309 | } | |
| 310 | ||
| 311 | ||
| 312 | ||
| 313 | pr otected fu nction get _user_db_i nfo() { | |
| 314 | $use r = User:: find_from_ session(); | |
| 315 | if(! User::is_a n_entity($ user)) ret urn false; | |
| 316 | ||
| 317 | $dat a = array( 'ext_mail' => $user- >user_mail , | |
| 318 | 'notify' => $user- >user_ext_ notify_fla g, | |
| 319 | 'group_n otify' => $user->use r_ext_grou p_notify_f lag); | |
| 320 | ||
| 321 | //pa ss group m ailbox inf o if there is any | |
| 322 | $gro up_mailbox es = $this ->session- >userdata( 'group_mai lboxes'); | |
| 323 | if(i s_array($g roup_mailb oxes)) { $ data['grou p_mailboxe s'] = $gro up_mailbox es; } | |
| 324 | ||
| 325 | //pa ss persona l mailbox hidden dat a | |
| 326 | $dat a['hide_pe rsonal_mai lbox'] = F ALSE; | |
| 327 | if(! is_null($t his->sessi on->userda ta('hide_p ersonal_ma ilbox')) & & $this->s ession->us erdata('hi de_persona l_mailbox' ) !== FALS E) { $data ['hide_per sonal_mail box'] = TR UE; } | |
| 328 | ||
| 329 | retu rn $data; | |
| 330 | } | |
| 331 | ||
| 332 | pr otected fu nction tim ezone_opti ons_for_co untry($cou ntry){ | |
| 333 | if(! $this->is- >nonempty_ string($co untry)) re turn $this ->error->s hould_be_a _nonempty_ string($co untry); | |
| 334 | $tim ezones = D ateTimeZon e::listIde ntifiers(D ateTimeZon e::PER_COU NTRY, $cou ntry); | |
| 335 | $tim ezone_opti ons = arra y(); | |
| 336 | fore ach($timez ones as $t imezone) { | |
| 337 | $timez one_obj = new DateTi meZone($ti mezone); | |
| 338 | $offse t = $timez one_obj->g etOffset(n ew DateTim e('now', n ew DateTim eZone('GMT '))) / 360 0; | |
| 339 | $timez one_option s[$timezon e] = str_r eplace('_' ,' ',$time zone) . ' ' . '(GMT ' . ($offs et < 0 ? $ offset : ' +'.$offset ) . ':00) '. $this-> locale->ti mezone_abb r_from_nam e($timezon e); | |
| 340 | } | |
| 341 | ||
| 342 | uaso rt($timezo ne_options , array('S ettings', 'timezone_ cmp')); // sort timez one array | |
| 343 | ||
| 344 | retu rn $timezo ne_options ; | |
| 345 | } | |
| 346 | ||
| 347 | pr otected fu nction opt ions_for_t ime_dropdo wn(){ | |
| 348 | $tim e_options = array(); | |
| 349 | ||
| 350 | $sta rt = new D ateTime; | |
| 351 | $sta rt->setTim e(0, 0, 0) ; | |
| 352 | ||
| 353 | $end = clone $ start; | |
| 354 | $end ->modify(' +24 hour') ; | |
| 355 | ||
| 356 | whil e ($start <= $end) { | |
| 357 | $time_ options[$s tart->form at('H:i')] = $start- >format('g :i a'); | |
| 358 | $start ->modify(' +30 minute '); | |
| 359 | } | |
| 360 | ||
| 361 | retu rn $time_o ptions; | |
| 362 | } | |
| 363 | ||
| 364 | pr otected fu nction tim ezone_cmp( $a, $b) { | |
| 365 | $off set_a = su bstr($a, s trpos($a, 'GMT ') + 4); | |
| 366 | $off set_a = su bstr($offs et_a, 0, s trpos($off set_a, ':' )); | |
| 367 | ||
| 368 | $off set_b = su bstr($b, s trpos($b, 'GMT ') + 4); | |
| 369 | $off set_b = su bstr($offs et_b, 0, s trpos($off set_b, ':' )); | |
| 370 | ||
| 371 | if($ offset_a > $offset_b ) return - 1; | |
| 372 | if($ offset_a < $offset_b ) return 1 ; | |
| 373 | ||
| 374 | //wi thin an of fset, show alphabeti cal order | |
| 375 | $tim ezones = a rray($a, $ b); | |
| 376 | sort ($timezone s); | |
| 377 | if(c urrent($ti mezones) = = $a) retu rn -1; | |
| 378 | retu rn 1; | |
| 379 | } | |
| 380 | ||
| 381 | // 2017-06-30 - Myke Ca rter - Apo strophe ad ded to acc ommodate u sers with apostrophe s in their names and /or extern al email a ddresses | |
| 382 | pu blic funct ion va_ema il($email) { | |
| 383 | $val id = (preg _match("/^ ([a-z0-9\' \+_\-]+)(\ .[a-z0-9\' \+_\-]+)*@ +((.*(\.va \.gov))|va \.gov)$/ix ", $email) ) ? TRUE : FALSE; | |
| 384 | ||
| 385 | if($ valid) { r eturn TRUE ; } | |
| 386 | $this->for m_validati on->set_me ssage('va_ email', 'T he %s fiel d must con tain a val id DNS . URL email add ress.'); | |
| 387 | retu rn FALSE; | |
| 388 | } | |
| 389 | ||
| 390 | pr otected fu nction get _facilitie s(){ | |
| 391 | $fac ilities = array(); | |
| 392 | $api _result = $this->api _model->we bservice_c all('/admi n/faciliti es/format/ json','GET '); | |
| 393 | if($ api_result ->http_sta tus === 20 0){ | |
| 394 | foreac h($api_res ult->respo nse->facil ities as $ facility){ | |
| 395 | $facilit ies[$facil ity->id] = $facility ->name; | |
| 396 | } | |
| 397 | } | |
| 398 | retu rn $facili ties; | |
| 399 | } | |
| 400 | ||
| 401 | } | |
| 402 | ||
| 403 | /* End of file setti ngs.php */ | |
| 404 | /* Locatio n: ./appli cation/con trollers/s ettings.ph p */ | |
| 405 | ||
| 406 | ?> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.