dbType == 'oci8') { echo "
"; echo "

".$mod_strings['ERR_NOT_FOR_ORACLE']."

"; echo "
"; sugar_die(''); } if ($db->dbType == 'mssql') { echo "
"; echo "

".$mod_strings['ERR_NOT_FOR_MSSQL']."

"; echo "
"; sugar_die(''); } $display = ''; if(empty($db)) { $db = DBManagerFactory::getInstance(); } // check if this fix has been applied already $qDone = "SELECT * FROM versions WHERE name = 'DST Fix'"; $rDone = $db->query($qDone); $rowsDone = $db->getRowCount($rDone); if($rowsDone > 0) { $done = true; } else { $done = false; } // some inits: $disabled = 'DISABLED'; $confirmed = 'false'; // apply the fix if(!empty($_REQUEST['confirmed']) && $_REQUEST['confirmed'] == true) { // blowaway vCal server cache $qvCal = "TRUNCATE vcals"; $rvCal = $db->query($qvCal); // disable refresh double-ups $rDblCheck = $db->query($qDone); $rowsDblCheck = $db->getRowCount($rDblCheck); if($rowsDblCheck < 1) { // majed's sql generation $tables = array( 'calls'=>array( 'date_start'=>'time_start', ), 'meetings'=>array( 'date_start'=>'time_start', ), 'tasks'=>array( 'date_due'=>'time_due', ), 'project_task'=>array( 'date_due'=>'time_due', ), 'email_marketing'=>array( 'date_start'=>'time_start', ), 'emailman'=>array( 'send_date_time'=>'datetime', ) ); $zone = $_REQUEST['server_timezone']; $startyear = 2004; $maxyear = 2014; $date_modified = $timedate->nowDb(); $display = ''; foreach($tables as $table_name =>$table) { //$display .= ''. $table_name . '
'; $year = $startyear; for($year = $startyear; $year <= $maxyear; $year++) { $range = $timedate->getDSTRange($year,$timezones[$zone]); $startDateTime = explode(' ',$range['start']); $endDateTime = explode(' ',$range['end']); if($range) { if( strtotime($range['start']) < strtotime($range['end'])) { foreach($table as $date=>$time) { $interval='PLUSMINUS INTERVAL 3600 second'; if($time != 'datetime'){ if ( ( $db->dbType == 'mysql' ) or ( $db->dbType == 'oci8' ) ) { $field = "CONCAT($table_name.$date,' ', $table_name.$time)"; } if ( $db->dbType == 'mssql' ) { $field = "$table_name.$date + ' ' + $table_name.$time"; } $updateBase= "UPDATE $table_name SET date_modified='$date_modified', $table_name.$date=LEFT($field $interval,10),"; $updateBase .= " $table_name.$time=RIGHT($field $interval,8)"; }else{ $field = "$table_name.$date"; $updateBase = "UPDATE $table_name SET date_modified='$date_modified', $table_name.$date = $table_name.$date $interval"; } //BEGIN DATE MODIFIED IN DST WITH DATE OUT DST $update = str_replace('PLUSMINUS', '+', $updateBase); $queryInDST = $update ." WHERE $table_name.date_modified >= '{$range['start']}' AND $table_name.date_modified < '{$range['end']}' AND ( $field < '{$range['start']}' OR $field >= '{$range['end']}' )"; $result = $db->query($queryInDST); $count = $db->getAffectedRowCount(); //$display .= "$year - Records updated with date modified in DST with date out of DST: $count
"; //BEGIN DATE MODIFIED OUT DST WITH DATE IN DST $update = str_replace('PLUSMINUS', '-', $updateBase); $queryOutDST = $update ." WHERE ( $table_name.date_modified < '{$range['start']}' OR $table_name.date_modified >= '{$range['end']}' ) AND $field >= '{$range['start']}' AND $field < '{$range['end']}' "; $result = $db->query($queryOutDST); $count = $db->getAffectedRowCount(); //$display .= "$year - Records updated with date modified out of DST with date in DST: $count
"; } }else{ foreach($table as $date=>$time){ $interval='PLUSMINUS INTERVAL 3600 second'; if($time != 'datetime'){ if ( ( $this->db->dbType == 'mysql' ) or ( $this->db->dbType == 'oci8' ) ) { $field = "CONCAT($table_name.$date,' ', $table_name.$time)"; } if ( $this->db->dbType == 'mssql' ) { $field = "$table_name.$date + ' ' + $table_name.$time"; } $updateBase= "UPDATE $table_name SET $table_name.$date=LEFT($field $interval,10),"; $updateBase .= " $table_name.$time=RIGHT($field $interval,8)"; }else{ $field = "$table_name.$date"; $updateBase = "UPDATE $table_name SET $table_name.$date = $table_name.$date $interval"; } //BEGIN DATE MODIFIED IN DST WITH DATE OUT OF DST $update = str_replace('PLUSMINUS', '+', $updateBase); $queryInDST = $update ." WHERE ($table_name.date_modified >= '{$range['start']}' OR $table_name.date_modified < '{$range['end']}' ) AND $field < '{$range['start']}' AND $field >= '{$range['end']}'"; $result = $db->query($queryInDST); $count = $db->getAffectedRowCount(); //$display .= "$year - Records updated with date modified in DST with date out of DST: $count
"; //BEGIN DATE MODIFIED OUT DST WITH DATE IN DST $update = str_replace('PLUSMINUS', '-', $updateBase); $queryOutDST = $update ." WHERE ($table_name.date_modified < '{$range['start']}' AND $table_name.date_modified >= '{$range['end']}' ) AND ($field >= '{$range['start']}' OR $field < '{$range['end']}' )"; } $result = $db->query($queryOutDST); $count = $db->getAffectedRowCount(); //$display .= "$year - Records updated with date modified out of DST with date in DST: $count
"; } } } // end outer forloop }// end foreach loop } $display .= "
".$mod_strings['LBL_DST_FIX_DONE_DESC'].""; } elseif(!$done) { // show primary screen $disabled = ""; $confirmed = 'true'; require_once('include/timezone/timezones.php'); global $timezones; $timezoneOptions = ''; ksort($timezones); if(!isset($defaultServerZone)){ $defaultServerZone = TimeDate::guessTimezone(0); } foreach($timezones as $key => $value) { if(!empty($value['dstOffset'])) { $dst = " (+DST)"; } else { $dst = ""; } if($key == $defaultServerZone){ $selected = 'selected'; }else{ $selected = ''; } $gmtOffset = ($value['gmtOffset'] / 60); if(!strstr($gmtOffset,'-')) { $gmtOffset = "+".$gmtOffset; } $timezoneOptions .= ""; } // descriptions and assumptions $display = " ".$mod_strings['LBL_DST_FIX_TARGET']." ".$mod_strings['LBL_APPLY_DST_FIX_DESC']." ".$mod_strings['LBL_DST_BEFORE']." ".$mod_strings['LBL_DST_BEFORE_DESC']." ".$mod_strings['LBL_DST_FIX_CONFIRM']." ".$mod_strings['LBL_DST_FIX_CONFIRM_DESC']."
".$mod_strings['LBL_DST_CURRENT_SERVER_TIME']." ".$timedate->to_display_time($timedate->nowDb(), true, false)."
".$mod_strings['LBL_DST_CURRENT_SERVER_TIME_ZONE']." ".date("T")."
".$mod_strings['LBL_DST_CURRENT_SERVER_TIME_ZONE_LOCALE']."
"; } else { // fix has been applied - don't want to allow a 2nd pass $display = $mod_strings['LBL_DST_FIX_DONE_DESC']; $disabled = 'DISABLED'; $confirmed = 'false'; } if(!empty($_POST['upgrade'])){ // enter row in versions table $qDst = "INSERT INTO versions VALUES ('".create_guid()."', 0, '".$timedate->nowDB()."', '".$timedate->nowDB()."', '".$current_user->id."', '".$current_user->id."', 'DST Fix', '3.5.1b', '3.5.1b')"; $qRes = $db->query($qDst); // record server's time zone locale for future upgrades $qSTZ = "INSERT INTO config VALUES ('Update', 'server_timezone', '".$_REQUEST['server_timezone']."')"; $rSTZ = $db->query($qSTZ); if(empty($_REQUEST['confirmed']) || $_REQUEST['confirmed'] == 'false') { $display = $mod_strings['LBL_DST_FIX_DONE_DESC']; $disabled = 'DISABLED'; $confirmed = 'false'; } unset($_SESSION['GMTO']); } echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_APPLY_DST_FIX']), true); if(empty($disabled)){ ?>

Step 1:


' onclick='document.location.href="index.php?module=Administration&action=updateTimezonePrefs"'>

Step 2:"; } ?>
"; }else{ echo ""; } ?>