224. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/25/2018 9:22:54 AM Central 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.

224.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\ZIP\DSM-cif\Webmail\application\controllers Settings.php Tue May 22 12:03:50 2018 UTC
2 C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Webmail\application\controllers Settings.php Tue May 22 22:14:46 2018 UTC

224.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 724
Changed 1 2
Inserted 0 0
Removed 0 0

224.3 Comparison options

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

224.4 Active regular expressions

No regular expressions were active.

224.5 Comparison detail

  1   <?php if (  ! defined ('BASEPATH ')) exit(' No direct  script acc ess allowe d');
  2  
  3   /**
  4   * @package  direct-pr oject-inno vation-ini tiative
  5   * @subpack age contro llers
  6   */ /** */
  7  
  8   require_on ce APPPATH .'controll ers/restri cted_contr oller.php' ;
  9  
  10  
  11   /**
  12   * @package  direct-pr oject-inno vation-ini tiative
  13   * @subpack age contro llers
  14   */
  15   class Sett ings exten ds Restric ted_contro ller {  
  16           pu blic $help _video;
  17           
  18           pu blic funct ion __cons truct(){
  19                    pare nt::__cons truct();
  20                    requ ire_librar y('video') ;
  21                    $thi s->load->l ibrary('au dit');
  22                    
  23                    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() ); }
  24                    
  25           }
  26           
  27           pu blic funct ion ajax_t imezone_li st($countr y = NULL)  {
  28                    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
  29                    echo  $this->js on->encode ($this->ti mezone_opt ions_for_c ountry($co untry));
  30           }
  31           
  32           pu blic funct ion index( ){        
  33                    requ ire_librar y('form_ma rkup_gener ator/user_ form_marku p_generato r');
  34                    $mar kup_genera tor = new  User_form_ markup_gen erator($th is->user);                  
  35                    
  36                    if(e mpty($_POS T) && !$ma rkup_gener ator->load _saved_val ues() && $ this->api- >http_stat us != 200) {
  37                             $this- >session-> set_error_ message('Y ou have no t granted  this appli cation per mission to  manage yo ur account  informati on.');
  38                             redire ct('settin gs/applica tion');
  39                             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                     
  40                    }
  41                    
  42                    if(! empty($_PO ST)){
  43                             $marku p_generato r->set_val ues_from_p ost();
  44                             if(!$m arkup_gene rator->val idates()){
  45                                      $error_m essage = ' <strong>We  need you  to make a  few change s to this  form.</str ong>&nbsp; &nbsp;'.ul _if_multip le($markup _generator ->validati on_message s);
  46                             }elsei f(!$markup _generator ->save_val ues()){      
  47                                      $error_m essage = $ this->lang ->line('er ror_generi c');
  48                             }else{
  49                                      $success _message =  '<strong> Success!</ strong>&nb sp;&nbsp;Y our accoun t settings  have been  updated.' ;
  50                                      $markup_ generator- >load_save d_values() ;                  
  51                             }
  52                    }
  53                                                       
  54                    $tit le = PORTA L_TITLE_PR EFIX . 'Ac count Sett ings';
  55                    $thi s->load->v iew('setti ngs/index' , compact( 'markup_ge nerator',' title', 'e rror_messa ge', 'succ ess_messag e'));
  56           }
  57           
  58           pu blic funct ion notifi cations(){         
  59                    $dat a = $this- >get_user_ db_info();
  60                             
  61                    $dat a["title"]  = PORTAL_ TITLE_PREF IX . "User  Settings" ;
  62                    //pa ss group m ailbox inf o if there  is any
  63                    $gro up_mailbox es = $this ->session- >userdata( 'group_mai lboxes');
  64                    if(i s_array($g roup_mailb oxes)) { $ data['grou p_mailboxe s'] = $gro up_mailbox es; }
  65                    //pa ss persona l mailbox  hidden dat a
  66                    $dat a['hide_pe rsonal_mai lbox'] = F ALSE;
  67                    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; }
  68                    //lo ad view
  69                    $thi s->load->v iew("setti ngs/notifi cations",$ data);
  70           }
  71           
  72           
  73           pu blic funct ion applic ation() {
  74                    $tit le = PORTA L_TITLE_PR EFIX . ' A pplication  Settings' ;
  75                    $cou ntries = $ this->loca le->get_co untries();
  76                    
  77                    if(! empty($_PO ST)){
  78                             $count ry = $this ->input->p ost('count ry', TRUE) ;
  79                             $timez one = $thi s->input-> post('time zone', TRU E);
  80                             
  81                             if(!ar ray_key_ex ists($coun try, $coun tries) ||  !array_key _exists($t imezone, $ this->time zone_optio ns_for_cou ntry($coun try))){
  82                                      unset($c ountry, $t imezone);
  83                             }elsei f($this->d b->update( 'users', a rray('user _locale' = > serializ e(compact( 'country',  'timezone '))), arra y('user_id ' => $this ->user->id ))){
  84                                      $this->s ession->se t_success_ message('L ocale sett ings succe ssfully up dated.');
  85                                      redirect ('settings /applicati on');        
  86                             }
  87                             
  88                             $error _message =  $this->la ng->line(' error_gene ric');
  89                    }
  90                    
  91                    if(! isset($cou ntry)) $co untry = $t his->user- >country;
  92                    if(! isset($tim ezone)) $t imezone =  $this->use r->timezon e;
  93                    $tim ezone_opti ons = $thi s->timezon e_options_ for_countr y($country );
  94                    
  95                    $thi s->load->v iew('setti ngs/applic ation', co mpact('tit le', 'erro r_message' , 'countri es', 'coun try', 'tim ezone', 't imezone_op tions'));
  96           }
  97           
  98           
  99           pu blic funct ion automa tic_replie s(){
  100                    requ ire_model( 'automatic _reply');
  101                    $dat a = array( );
  102                    
  103                    //if  the form  hasn't bee n submitte d yet, set  it up
  104                    if(e mpty($_POS T)){               
  105                             $reply  = Automat ic_reply:: find_one(  array('mai lbox' =>$t his->user- >username)  );
  106                             if(Aut omatic_rep ly::is_an_ entity($re ply)){
  107                                      $data =  array_merg e($data, $ reply->val ues(array( 'content',  'start_at ', 'end_at ')));
  108                                      $data['s end_automa tic_replie s'] = true ;
  109                                      $data['s end_within _time_peri od'] = (!e mpty($data ['start_at ']) && !em pty($data[ 'end_at']) );
  110                             }
  111                             
  112                             if(emp ty($data[' start_at'] ))
  113                                      $data['s tart_at']  = now();
  114                             if(emp ty($data[' end_at']))
  115                                      $data['e nd_at'] =  strtotime( 'tomorrow' );
  116                                      
  117                             $data[ 'start_dat e'] = date ("D m/d/Y" , $data['s tart_at']) ;
  118                             
  119                             
  120                             //modi fy time to  round dow n in half  hour incre ments.
  121                             $start _hour = da te("H", $d ata['start _at']);
  122                             $start _minutes =  date("i",  $data['st art_at']);
  123                             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
  124                                      $start_m inutes = ' 00';
  125                             }elsei f($start_m inutes >=  30){
  126                                      $start_m inutes = ' 30';
  127                             }
  128  
  129                             $data[ 'start_tim e'] = $sta rt_hour.': '.$start_m inutes;
  130  
  131                             
  132                             $data[ 'end_date' ] = date(" D m/d/Y",  $data['end _at']);
  133                             $data[ 'end_time' ] = (empty ($data['en d_at'])) ?  '' : date ("H:i", $d ata['end_a t']);                
  134                    }els e{ 
  135                             //if t he form ha s been sub mitted, va lidate and  save
  136                             
  137                             $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);
  138                             
  139                             //SET  UP FORM VA LIDATION
  140                             $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');
  141                             $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' );
  142                             
  143                             if(emp ty($form_d ata['send_ automatic_ replies']) ){
  144                                      $form_da ta['conten t'] = '';  //diregard  any value  for conte nt if we'r e not send ing automa tic replie s
  145                             }else{
  146                                      $this->f orm_valida tion->set_ rules('con tent', 'Me ssage Body ', 'requir ed|visible _content_r equired',
  147                                                                                                                     array( 'visible_c ontent_req uired' =>  'The {fiel d} is requ ired.'));
  148                                      
  149                                      if(empty ($form_dat a['send_wi thin_time_ period']))  {
  150                                               $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
  151                                      }else{
  152                                              
  153                                               $time_opti ons = $thi s->options _for_time_ dropdown() ;
  154                                              
  155                                               $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).' ]', 
  156                                                                                                                       arra y('date_ma tches_form at' => 'Th e {field}  must be a  date forma tted MM/DD /YYYY.',
  157                                                                                                                                       'date_is_g reater_tha n' => 'The  {field} c annot be i n the past .'));
  158                                                                                                                                      
  159                                               $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. '));                                                                                                                    
  160                                                                                                                                      
  161                                               $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'].']'
  162                                                                                                                       arra y('date_ma tches_form at' => 'Th e {field}  must be a  date forma tted MM/DD /YYYY.',
  163                                                                                                                                       'date_is_g reater_tha n_or_equal _to' => 'T he Start D ate must b e before t he {field} .'));   
  164                                                                                                                                      
  165                                               $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.'));                                                                                                                                                                     
  166                                      }
  167                                      
  168                             }
  169                             
  170                             //SAVE  THE DATA  IF IT'S VA LID   
  171                             $data[ 'validatio n_errors']  = array() ;
  172                             if($th is->form_v alidation- >run() ==  true) {
  173                                      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']) ){
  174                                               $data['val idation_er rors'][] =  'The End  Date must  be after t he Start D ate.';
  175                                      }else{
  176                                               require_mo del('autom atic_reply ');
  177                                               $reply = A utomatic_r eply::find _one( arra y('mailbox ' => $this ->user->us ername) );
  178                                              
  179                                               if(empty($ form_data[ 'send_auto matic_repl ies']) &&  Automatic_ reply::is_ an_entity( $reply)){
  180                                                       Au tomatic_re ply::delet e($reply-> id);
  181                                               }elseif(!e mpty($form _data['sen d_automati c_replies' ])){
  182                                                       if (!Automati c_reply::i s_an_entit y($reply))  $reply =  new Automa tic_reply( );
  183                                                       $r eply->cont ent = $for m_data['co ntent'];
  184                                                       
  185                                                       $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);
  186                                                       $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);
  187                             
  188                    #TOD O - WE SHO ULD DISPLA YING A MES SAGE TELLI NG THE USE R WHETHER  OR NOT SAV E WAS SUCC ESSFUL.                                         
  189                                                       $s uccess = $ reply->sav e();               
  190                                               }
  191                                      
  192                                               redirect(' settings/a utomatic_r eplies');
  193                                      }
  194                             }
  195           
  196                             $data  = array_me rge($data,  $form_dat a);
  197                             $data[ 'validatio n_errors']  = array_m erge(explo de("\n", t rim(valida tion_error s())), $da ta['valida tion_error s']);
  198                    }
  199                    
  200                    $dat a['title']  = PORTAL_ TITLE_PREF IX . ' Aut omatic Rep ly (Out of  Office) S ettings';               
  201                    $dat a['time_op tions'] =  $this->opt ions_for_t ime_dropdo wn();
  202                    $thi s->load->v iew('setti ngs/automa tic_replie s',$data);
  203           }
  204           
  205  
  206           
  207           pu blic funct ion update _notificat ions() {
  208                    $thi s->load->d atabase();
  209                    
  210                    $thi s->form_va lidation-> set_rules( "ext_mail" ,"External  Email","r equired|ca llback_va_ email","xs s_clean");
  211                    if($ this->form _validatio n->run() = = true) {
  212                             $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")));
  213                             if($ge t_user_id)  { 
  214                                      if($get_ user_id->n um_rows()  == 1) { 
  215                                               $row = $ge t_user_id- >row_array ();
  216                                               $user_id =  $row["use r_id"];
  217                                      }
  218                             }
  219                             if(iss et($user_i d)) {
  220                                      $ext_mai l = $this- >input->po st("ext_ma il",TRUE);
  221                                      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))) {
  222                                               $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));
  223                                      }
  224                                      else if( array_key_ exists('no tify',$thi s->input-> post(NULL, TRUE))) {
  225                                               $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));
  226                                      }
  227                                      else if( array_key_ exists('gr oup_notify ',$this->i nput->post (NULL,TRUE ))) {
  228                                               $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));
  229                                      }
  230                                      else {
  231                                               $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));
  232                                      }
  233                                      
  234                                      //if we  reach this  point pre sumably it  was succe ssful
  235                                      $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 ")));
  236                                      if($get_ actor_id)  {
  237                                               $actor_id_ row = $get _actor_id- >row_array ();
  238                                               $actor_id  = $actor_i d_row["use r_id"];
  239                                               $target_id  = $actor_ id;
  240                                               $this->loa d->library ("audit");
  241                                               $this->aud it->log_ev ent("edit" ,array($ta rget_id,$a ctor_id,"U pdate user  informati on",date(' U')));
  242                                      }
  243                                      $this->s ession->se t_success_ message('S ettings su ccessfully  updated.' );
  244                                      redirect ('settings /notificat ions');
  245                             }
  246                             else {
  247                                      $this->s ession->se t_error_me ssage('Fai led to upd ate settin gs.');
  248                                      redirect ('settings /notificat ions');
  249                             }
  250                    }
  251                    else  {
  252                             $ext_m ail_error  = (strlen( form_error ('ext_mail ')) > 0) ?  form_erro r('ext_mai l') : null ;
  253                             $valid ation_erro rs = array ('ext_mail '=>$ext_ma il_error);
  254                             $this- >session-> set_flashd ata('valid ation_erro rs',$valid ation_erro rs);
  255                             redire ct('settin gs/notific ations');
  256                    }
  257           }
  258           
  259           pr otected fu nction che ck_date($s tart, $end ){
  260                    $dat es = array ();       
  261                    if(( $st=strtot ime($start )) == TRUE ){ $dates[ 'start'] =  $st; }
  262                    else { $dates[' start'] =  null; }
  263                    if(( $en=strtot ime($end))  == TRUE){  $dates['e nd'] = $en ; }
  264                    else  { $dates[ 'end'] = n ull; }
  265                    retu rn $dates;
  266           }
  267           
  268  
  269           
  270           pr otected fu nction get _user_db_i nfo() {
  271                    $use r = User:: find_from_ session();
  272                    if(! User::is_a n_entity($ user)) ret urn false;
  273                    
  274                    $dat a = array( 'ext_mail'  => $user- >user_mail ,
  275                                                 'notify'  => $user- >user_ext_ notify_fla g,
  276                                                 'group_n otify' =>  $user->use r_ext_grou p_notify_f lag);
  277                    
  278                    //pa ss group m ailbox inf o if there  is any
  279                    $gro up_mailbox es = $this ->session- >userdata( 'group_mai lboxes');
  280                    if(i s_array($g roup_mailb oxes)) { $ data['grou p_mailboxe s'] = $gro up_mailbox es; }
  281                    
  282                    //pa ss persona l mailbox  hidden dat a
  283                    $dat a['hide_pe rsonal_mai lbox'] = F ALSE;
  284                    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; }
  285                    
  286                    retu rn $data;
  287           }
  288           
  289           pr otected fu nction tim ezone_opti ons_for_co untry($cou ntry){
  290                    if(! $this->is- >nonempty_ string($co untry)) re turn $this ->error->s hould_be_a _nonempty_ string($co untry);
  291                    $tim ezones = D ateTimeZon e::listIde ntifiers(D ateTimeZon e::PER_COU NTRY, $cou ntry);
  292                    $tim ezone_opti ons = arra y();
  293                    fore ach($timez ones as $t imezone) {
  294                             $timez one_obj =  new DateTi meZone($ti mezone);
  295                             $offse t = $timez one_obj->g etOffset(n ew DateTim e('now', n ew DateTim eZone('GMT '))) / 360 0;                 
  296                             $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);
  297                    }
  298                    
  299                    uaso rt($timezo ne_options , array('S ettings',  'timezone_ cmp')); // sort timez one array
  300                    
  301                    retu rn $timezo ne_options ;
  302           }        
  303           
  304           pr otected fu nction opt ions_for_t ime_dropdo wn(){
  305                    $tim e_options  = array();
  306                    
  307                    $sta rt = new D ateTime;
  308                    $sta rt->setTim e(0, 0, 0) ;
  309                    
  310                    $end  = clone $ start;
  311                    $end ->modify(' +24 hour') ;
  312  
  313                    whil e ($start  <= $end) {
  314                             $time_ options[$s tart->form at('H:i')]  = $start- >format('g :i a');
  315                             $start ->modify(' +30 minute ');
  316                    }        
  317                    
  318                    retu rn $time_o ptions;
  319           }
  320           
  321           pr otected fu nction tim ezone_cmp( $a, $b) {
  322                    $off set_a = su bstr($a, s trpos($a,  'GMT ') +  4);
  323                    $off set_a = su bstr($offs et_a, 0, s trpos($off set_a, ':' ));
  324           
  325                    $off set_b = su bstr($b, s trpos($b,  'GMT ') +  4);
  326                    $off set_b = su bstr($offs et_b, 0, s trpos($off set_b, ':' ));
  327                    
  328                    if($ offset_a >  $offset_b ) return - 1; 
  329                    if($ offset_a <  $offset_b ) return 1
  330                    
  331                    //wi thin an of fset, show  alphabeti cal order
  332                    $tim ezones = a rray($a, $ b);
  333                    sort ($timezone s);
  334                    if(c urrent($ti mezones) = = $a) retu rn -1;
  335                    retu rn 1;
  336           }
  337  
  338           // 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
  339           pu blic funct ion va_ema il($email)  {
  340                    $val id = (preg _match("/^ ([a-z0-9\' \+_\-]+)(\ .[a-z0-9\' \+_\-]+)*@ +((.*(\.va \.gov))|va \.gov)$/ix ", $email) ) ? TRUE :  FALSE;
  341                    
  342                    if($ valid) { r eturn TRUE ; }
  343                     $this->for m_validati on->set_me ssage('va_ email', 'T he %s fiel d must con tain a val id  DNS       email addr ess.');
  344                    retu rn FALSE;
  345           }
  346  
  347           pr otected fu nction get _facilitie s(){
  348                    $fac ilities =  array();
  349                    $api _result =  $this->api _model->we bservice_c all('/admi n/faciliti es/format/ json','GET ');
  350                    if($ api_result ->http_sta tus === 20 0){
  351                             foreac h($api_res ult->respo nse->facil ities as $ facility){
  352                                      $facilit ies[$facil ity->id] =  $facility ->name;
  353                             }
  354                    }
  355                    retu rn $facili ties;
  356           }
  357           
  358   }
  359  
  360   /* End of  file setti ngs.php */
  361   /* Locatio n: ./appli cation/con trollers/s ettings.ph p */
  362  
  363   ?>