801. File Comparison Report

Produced on Mon May 12 13:07:10 2008 UTC. This report uses XHTML and CSS2, and is best viewed with a reasonably standards compliant browser such as the latest version of Firefox or Internet Explorer. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

801.1 Files compared

# Location File Last Modified
1 Mon May 12 13:07:10 2008 UTC
2 Dolphin-v.6.1.0 pedit.php Sat Apr 26 08:19:18 2008 UTC

801.2 Comparison summary

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

801.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

801.4 Active regular expressions

No regular expressions were active.

801.5 Comparison detail

    1   <?php
    2  
    3   require_on ce( './inc /header.in c.php' );
    4   require_on ce( BX_DIR ECTORY_PAT H_INC      . 'admin.i nc.php' );
    5   require_on ce( BX_DIR ECTORY_PAT H_INC      . 'db.inc. php' );
    6   require_on ce( BX_DIR ECTORY_PAT H_INC      . 'match.i nc.php' );
    7   require_on ce( BX_DIR ECTORY_PAT H_CLASSES  . 'BxDolPr ofileField s.php' );
    8   require_on ce( BX_DIR ECTORY_PAT H_CLASSES  . 'BxDolPr ofilesCont roller.php ' );
    9   require_on ce( BX_DIR ECTORY_PAT H_ROOT     . "templat es/tmpl_{$ tmpl}/scri pts/BxTemp lFormView. php" );
    10  
    11   $_page['na me_index']  = 25;
    12   $_page['cs s_name']    = 'pedit. css';
    13   //$_page[' extra_js']    = '<scr ipt type=" text/javas cript" lan guage="Jav aScript" s rc="' . $s ite['plugi ns'] . 'jq uery/jquer y.js"></sc ript>';
    14   $_page['ex tra_js']   .= '<scrip t type="te xt/javascr ipt" langu age="JavaS cript" src ="' . $sit e['plugins '] . 'jque ry/ui.date picker.js" ></script> ';
    15   $_page['ex tra_js']   .= '<scrip t type="te xt/javascr ipt" langu age="JavaS cript" src ="' . $sit e['plugins '] . 'jque ry/jquery. form.js">< /script>';
    16   $_page['ex tra_js']   .= '<scrip t type="te xt/javascr ipt" langu age="JavaS cript" src ="inc/js/p edit.js">< /script>';
    17  
    18   //init dat epicker
    19   $iMinAge   = (int)get Param( 'se arch_start _age' );
    20   $iMaxAge   = (int)get Param( 'se arch_end_a ge'   );
    21   $iCurYear  = (int)dat e('Y');
    22   $iMinYear  = $iCurYea r - $iMaxA ge - 1;
    23   $iMaxYear  = $iCurYea r - $iMinA ge;
    24  
    25   $sDatepick erInit = $ oTemplConf ig -> cust omize['joi n']['datep ickerInit' ];
    26  
    27   $sDatepick erInit = s tr_replace ( '{min_ye ar}', $iMi nYear, $sD atepickerI nit );
    28   $sDatepick erInit = s tr_replace ( '{max_ye ar}', $iMa xYear, $sD atepickerI nit );
    29  
    30   $_page['ex tra_js']   .= '
    31       <scrip t type="te xt/javascr ipt" langu age="JavaS cript">
    32           $(  document  ).ready( f unction(){
    33                ' . $sDa tepickerIn it . '
    34           }  );
    35       </scri pt>';
    36  
    37   check_logg ed();
    38  
    39   //$_page[' header'] =  _t( "_JOI N_H" );
    40   //$_page[' header_tex t'] = _t(  "_JOIN_H"  );
    41  
    42  
    43  
    44   $oEditProc  = new BxD olPEditPro cessor();
    45  
    46   $_ni = $_p age['name_ index'];
    47   $_page_con t[$_ni]['p age_main_c ode'] = $o EditProc - > process( );
    48  
    49  
    50   PageCode() ;
    51  
    52  
    53  
    54   class BxDo lPEditProc essor {
    55       var $i ProfileID;  // id of  profile wh ich will b e edited
    56       var $i Area = 0;   // 2=owne r, 3=admin , 4=modera tor
    57       var $b Couple = f alse; // i f we editi tng couple  profile
    58       var $a CoupleMutu alFields;  // couple  mutual fie lds
    59       
    60       var $o PC;         // object  of profil es control ler
    61       var $o PF;         // object  of profil e fields
    62       
    63       var $a Blocks;     // blocks  of page ( with items )
    64       var $a Items;      // all it ems within  blocks
    65       
    66       var $a Profiles;   // array  with profi les (coupl e) data
    67       var $a Values;     // values
    68       var $a OldValues;  // values  before sa ve
    69       var $a Errors;     // genera ted errors
    70       
    71       var $b AjaxMode;   // if the  script wa s called v ia ajax
    72       
    73       functi on BxDolPE ditProcess or() {
    74           gl obal $logg ed;
    75           
    76           $t his -> aPr ofiles = a rray( 0 =>  array(),  1 => array () ); // d ouble arra ys (for co uples)
    77           $t his -> aVa lues   = a rray( 0 =>  array(),  1 => array () );
    78           $t his -> aEr rors   = a rray( 0 =>  array(),  1 => array () );
    79           
    80           $t his -> iPr ofileID =  (int)$_REQ UEST['ID'] ;
    81           
    82           //  basic che cks
    83           if ( $logged[ 'member']  ) {
    84                $iMember ID = (int) $_COOKIE[' memberID'] ;
    85                if( !$th is -> iPro fileID ) {
    86                    //if  profile i d is not s et by requ est, edit  own profil e
    87                    $thi s -> iProf ileID = $i MemberID;
    88                    $thi s -> iArea  = 2;
    89                } else {
    90                    // c heck if th is member  is owner
    91                    if(  $this -> i ProfileID  == $iMembe rID )
    92                         $this -> i Area = 2;
    93                }
    94           }  elseif( $l ogged['adm in'] )
    95                $this ->  iArea = 3 ;
    96           el seif( $log ged['moder ator'] )
    97                $this ->  iArea = 4 ;
    98           
    99           
    100           $t his -> bAj axMode = (  isset( $_ SERVER['HT TP_X_REQUE STED_WITH' ] ) and $_ SERVER['HT TP_X_REQUE STED_WITH' ] == 'XMLH ttpRequest ' );
    101       }
    102       
    103       functi on process () {
    104           if ( !$this - > iProfile ID )
    105                return _ t( '_Profi le not spe cified' );
    106           
    107           if ( !$this - > iArea )
    108                return _ t( '_You c annot edit  this prof ile' );
    109           
    110           /*  @var $thi s->oPC BxD olProfiles Controller  */
    111           $t his -> oPC  = new BxD olProfiles Controller ();
    112           
    113           // get profil e info arr ay
    114           $t his -> aPr ofiles[0]  = $this ->  oPC -> ge tProfileIn fo( $this  -> iProfil eID );
    115           if ( !$this - > aProfile s[0] )
    116                return _ t( '_Profi le not fou nd' );
    117           
    118           if ( $this ->  aProfiles [0]['Coupl e'] ) { //  load coup le profile
    119                $this ->  aProfiles [1] = $thi s -> oPC - > getProfi leInfo( $t his -> aPr ofiles[0][ 'Couple']  );
    120                
    121                if( !$th is -> aPro files[1] )
    122                    retu rn _t( '_C ouple prof ile not fo und' );
    123                
    124                $this ->  bCouple =  true; //c ouple enab led
    125           }
    126           
    127           /*  @var $thi s->oPF BxD olProfileF ields */
    128           $t his -> oPF  = new BxD olProfileF ields( $th is -> iAre a );
    129           if ( !$this - > oPF -> a Area )
    130                return ' Profile Fi elds cache  not loade d. Cannot  continue.' ;
    131           
    132           $t his -> aCo upleMutual Fields = $ this -> oP F -> getCo upleMutual Fields();
    133           
    134           // collect bl ocks
    135           $t his -> aBl ocks = $th is -> oPF  -> aArea;
    136           
    137           // collect it ems
    138           $t his -> aIt ems = arra y();
    139           fo reach ($th is -> aBlo cks as $aB lock) {
    140                foreach(  $aBlock[' Items'] as  $iItemID  => $aItem  )
    141                    $thi s -> aItem s[$iItemID ] = $aItem ;
    142           }
    143           
    144           $t his -> aVa lues[0] =  $this -> o PF -> getV aluesFromP rofile( $t his -> aPr ofiles[0]  ); // set  default va lues
    145           if ( $this ->  bCouple )
    146                $this ->  aValues[1 ] = $this  -> oPF ->  getValuesF romProfile ( $this ->  aProfiles [1] ); //  set defaul t values
    147           
    148           $t his -> aOl dValues =  $this -> a Values;
    149           
    150           $s StatusText  = '';
    151           if ( isset($_ POST['do_s ubmit']) )  {
    152                $this ->  oPF -> pr ocessPostV alues( $th is -> bCou ple, $this  -> aValue s, $this - > aErrors,  0, $this  -> iProfil eID );
    153                
    154                if( empt y( $this - > aErrors[ 0] ) and e mpty( $thi s -> aErro rs[1] ) an d !$this - > bAjaxMod e ) { // d o not save  in ajax m ode
    155                    $thi s -> saveP rofile();
    156                    $sSt atusText =  '_Save pr ofile succ essful';
    157  
    158                    repa rseObjTags ( 'profile ', $this-> iProfileID  );
    159                }
    160           }
    161           
    162           if ( $this ->  bAjaxMode  ) {
    163                //print_ r( $_POST  );
    164                $this ->  showError sJson();
    165                exit;
    166           }  else {
    167                ob_start ();
    168                $this ->  showEditF orm( $sSta tusText );
    169                return o b_get_clea n();
    170           }
    171       }
    172       
    173       functi on showErr orsJson()  {
    174           he ader('Cont ent-Type:t ext/javasc ript');
    175           
    176           ec ho $this - > oPF -> g enJsonErro rs( $this  -> aErrors , $this ->  bCouple ) ;
    177       }
    178       
    179       functi on showEdi tForm( $sS tatusText  ) {
    180           // echoDbg( $ this -> aV alues );ex it;
    181           
    182           $a FormAttrs  = array(
    183                'id' =>  'edit_form ',
    184                'onsubmi t' => 'ret urn valida teEditForm (this);'
    185           );
    186           
    187           $a TableAttrs  = array(
    188                'id' =>  'edit_form _table',
    189                'action'  => $_SERV ER['PHP_SE LF']
    190           );
    191           
    192           $a FormParams  = array(
    193                'hidden'  => array(  'ID' => $ this -> iP rofileID,  'do_submit ' => '1' )
    194           );
    195           
    196           $a TableParam s = array(
    197                'double'          = > $this ->  bCouple,
    198                'second_ enabled' = > $this ->  bCouple
    199           );
    200           
    201           $a TableParam s['headers ']     = a rray( '',  _t( '_Firs t Person'  ), _t( '_S econd Pers on' ) );
    202           $a TableParam s['headers _add'] = ' class="hea der form_s econd_col" ' . ( $thi s -> bCoup le ? '' :  ' style="d isplay: no ne;"' );
    203           
    204           $a Buttons =  array(
    205                array(
    206                    'typ e' => 'sub mit',
    207                    'val ue' => _t(  '_Save' ) ,
    208                    'cla ss' => 'in put_submit '
    209                )
    210           );
    211           
    212           /*  @var $oFo rm BxTempl FormView * /
    213           $o Form = new  BxTemplFo rmView( 'e dit_form'  );
    214           $o Form -> be gin( $aFor mAttrs, $a TableAttrs , $aFormPa rams, $aTa bleParams  );
    215           
    216           fo reach( $th is -> aBlo cks as $aB lock ) {
    217                $oForm - > beginBlo ck( _t( $a Block['Cap tion'] ) ) ;
    218                
    219                foreach(  $aBlock[' Items'] as  $aItem )  {
    220                    
    221                    $aCo l0 = array ();
    222                    
    223                    $aCo l0['Type']       = $a Item['Type '];
    224                    $aCo l0['Name']       = (  $aItem['Ty pe'] == 's ystem' ) ?  $aItem['N ame'] : (  $aItem['Na me'] . '[0 ]' );
    225                    $aCo l0['Mandat ory'] = $a Item['Type '] == 'pas s' ? false  : $aItem[ 'Mandatory '];
    226                    $aCo l0['Contro l']   = $a Item['Cont rol'];
    227                    $aCo l0['Values ']    = $a Item['Valu es'];
    228                    $aCo l0['UseLKe y']   = $a Item['UseL Key'];
    229                    
    230                    $aCo l0['Captio n']   = _t ( $aItem[' Caption']  );
    231                    $aCo l0['Desc']       = _t ( $aItem[' Desc'] );
    232                    if(  $aCol0['De sc'] == $a Item['Desc '] )
    233                         $aCol0['De sc'] = '';
    234                    
    235                    // s et value
    236                    if(  isset( $th is -> aVal ues[0][ $a Item['Name '] ] ) )
    237                         $aCol0['Va lue']   =  $this -> a Values[0][  $aItem['N ame'] ];
    238                    else if ( $aIte m['Name']  == 'Couple ' )
    239                         $aCol0['Va lue'] = $t his -> bCo uple;
    240                    
    241                    // s et error
    242                    if(  isset( $th is -> aErr ors[0][ $a Item['Name '] ] ) )
    243                         $aCol0['Er ror']   =  $this -> a Errors[0][  $aItem['N ame'] ];
    244                    
    245                    // c heck secon d person's  field
    246                    if(  $this -> b Couple and  !in_array ( $aItem[' Name'], $t his -> aCo upleMutual Fields ) )  {
    247                         $aCol1 = a rray();
    248                        
    249                         $aCol1['Ty pe']    =  $aItem['Ty pe'];
    250                         $aCol1['Na me']    =  $aItem['Na me'] . '[1 ]';
    251                         $aCol1['Co ntrol'] =  $aItem['Co ntrol'];
    252                         $aCol1['Va lues']  =  $aItem['Va lues'];
    253                         $aCol1['Us eLKey'] =  $aItem['Us eLKey'];
    254                        
    255                         // set val ue
    256                         if( isset(  $this ->  aValues[1] [ $aItem[' Name'] ] )  )
    257                             $aCol1 ['Value']    = $this  -> aValues [1][ $aIte m['Name']  ];
    258                        
    259                         // set err or
    260                         if( isset(  $this ->  aErrors[1] [ $aItem[' Name'] ] )  )
    261                             $aCol1 ['Error']    = $this  -> aValues [1][ $aIte m['Name']  ];
    262                        
    263                         //echoDbg(  $aCol0 );
    264                         $oForm ->  addRow( $a Col0, $aCo l1 );
    265                    } el se
    266                         $oForm ->  addRow( $a Col0 );
    267                } 
    268                
    269                $oForm - > endBlock ();
    270           }
    271           
    272           $o Form -> en d( $aButto ns );
    273           
    274           if ( $sStatus Text )
    275                echo '<d iv class=" notice_tex t">' . _t( $sStatusTe xt) . "</d iv>";
    276           
    277           ec ho $oForm  -> getCode ();
    278       }
    279       
    280       functi on savePro file() {
    281           $a Diff = $th is -> getD iffValues( 0);
    282           $a Upd = $thi s -> oPF - > getProfi leFromValu es( $aDiff  );
    283           
    284           $a Upd['DateL astEdit']  = date( 'Y -m-d H:i:s ' );
    285           if ( !getPara m('autoApp roval_ifPr ofile') &&  $this ->  iArea == 2  )
    286                $aUpd['S tatus'] =  'Approval' ;
    287  
    288           $t his -> oPC  -> update Profile( $ this -> iP rofileID,  $aUpd );
    289           
    290           cl earProfile MatchCache ( $this ->  iProfileI D );
    291           
    292           if ( $this ->  bCouple )  {
    293                $aDiff =  $this ->  getDiffVal ues(1);
    294                $aUpd =  $this -> o PF -> getP rofileFrom Values( $a Diff );
    295  
    296                $aUpd['D ateLastEdi t'] = date ( 'Y-m-d H :i:s' );
    297                if( !get Param('aut oApproval_ ifProfile' ) && $this  -> iArea  == 2 )
    298                    $aUp d['Status' ] = 'Appro val';
    299  
    300                $this ->  oPC -> up dateProfil e( $this - > aProfile s[0]['Coup le'], $aUp d );
    301                
    302                clearPro fileMatchC ache( $thi s -> aProf iles[0]['C ouple'] );
    303           }
    304       }
    305       
    306       functi on getDiff Values($iI nd) {
    307           $a Old = $thi s -> aOldV alues[$iIn d];
    308           $a New = $thi s -> aValu es[$iInd];
    309           
    310           $a Diff = arr ay();
    311           fo reach( $aN ew as $sNa me => $mNe w ){
    312                $mOld =  $aOld[$sNa me];
    313                
    314                if( is_a rray($mNew ) ) {
    315                    if(  count($mNe w) == coun t($mOld) )  {
    316                         //compare  each value
    317                         $mOldS = $ mOld;
    318                         $mNewS = $ mNew;
    319                         sort( $mOl dS ); //so rt them fo r correct  comparison
    320                         sort( $mNe wS );
    321                        
    322                         foreach( $ mNewS as $ iKey => $s Val )
    323                             if( $m NewS[$iKey ] != $mOld [$iKey] )  {
    324                                 $a Diff[$sNam e] = $mNew ; //found  difference
    325                                 br eak;
    326                             }
    327                    } el se
    328                         $aDiff[$sN ame] = $mN ew;
    329                } else {
    330                    if(  $mNew != $ mOld )
    331                         $aDiff[$sN ame] = $mN ew;
    332                }
    333           }
    334           
    335           re turn $aDif f;
    336       }
    337       
    338   }