Changeset 712192
- Timestamp:
- 05/13/2013 05:20:54 AM (13 years ago)
- Location:
- soldpress/branches/0.9.5A
- Files:
-
- 3 edited
-
adapter.php (modified) (10 diffs)
-
settings.php (modified) (7 diffs)
-
soldpress.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
soldpress/branches/0.9.5A/adapter.php
r712036 r712192 105 105 } 106 106 107 public function sync_residentialproperty($crit, $culture) 108 { 107 public function sync_residentialproperty($crit) 108 { 109 109 110 $this->WriteLog('Sync Start'); 110 111 global $wpdb; … … 112 113 $syncenabled = get_option("sc-sync-enabled",true); 113 114 if($syncenabled != true){ 114 $this->WriteLog('Sync Disabled'); 115 return; 116 } 117 118 //Get Time 119 //Get Culture 120 115 $this->WriteLog('Sync Disabled'); 116 return; 117 } 118 121 119 update_option( 'sc-status', true ); 122 update_option( 'sc-sync-start',time() ); 123 update_option( 'sc-sync-end','' ); 124 125 if($culture =='') 126 { 127 $culture = "en-CA"; 128 } 120 update_option( 'sc-soldpress_listing_sync-start',time() ); 121 update_option( 'sc-soldpress_listing_sync-end','' ); 122 123 $culture = get_option("sc-language","en-CA"); 129 124 130 125 $this->WriteLog('service->Search' . $crit); … … 133 128 $properties = $this->service->Search("Property","Property",$crit,array("Limit" => '100',"Culture" => $culture)); 134 129 $this->WriteLog('Retrieved Results'); 135 130 $total = count($properties); 131 $this->WriteLog("Retrieved Results Total" .$total ); 132 136 133 //Get Disconnect Array of Current Posts 137 134 $posts_array = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'sp_property'"); 135 138 136 //Reset Data 139 $total = count($properties);140 137 $count = 0; 141 138 $user_id = get_current_user_id(); … … 143 140 foreach ($properties as &$rets) { 144 141 145 if($this->loginURL == http://sample.data.crea.ca/Login.svc/Login){ 142 //If sample data set we are only going to insert Vancouver Listing. 143 144 if($this->loginURL == "http://sample.data.crea.ca/Login.svc/Login"){ 146 145 if($rets['City'] != "Vancouver"){ 147 return;146 continue; 148 147 } 149 148 } … … 161 160 } 162 161 162 $postdate = DateTime::createFromFormat("d/m/Y H:i:s A", $rets['ModificationTimestamp']); 163 $this->WriteLog($postdate->format('Y-m-d') . " " . $postdate->getTimestamp()); 164 //it's false if an error occurs) but you should also definitely check DateTime::getLastErrors(); 163 165 $title = $rets['UnparsedAddress'] .' (' . $rets['ListingId'] .')'; 164 166 $content = ""; … … 170 172 $post->post_content = ""; 171 173 $post->post_name = $ListingKey; 172 $post->post_date = $ rets['ModificationTimestamp'];174 $post->post_date = $postdate->format('Y-m-d H:i:s'); 173 175 174 176 wp_update_post($post); … … 203 205 'post_type' => 'sp_property', 204 206 'post_name' => $ListingKey, 205 'post_date' => $ rets['ModificationTimestamp']207 'post_date' => $postdate->format('Y-m-d H:i:s') 206 208 ); 207 209 208 $post_id = wp_insert_post( $post, $wp_error); 209 210 if($post_id == 0){ 211 $this->WriteLog('Insert Post' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of ' . $total . "Error:" . $wp_error . 'User:' . $user_id); 212 //$this->WriteLog($wpdb->last_error); 210 $post_id = wp_insert_post( $post, true); 211 212 if (is_wp_error($post_id)) { 213 $this->WriteLog(' Insert Post - Error' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of '. 'User:' . $user_id); 214 $errors = $post_id->get_error_messages(); 215 foreach ($errors as $error) { 216 $this->WriteLog( var_dump($error)); 217 } 213 218 } 214 219 else 215 220 { 216 217 221 $this->WriteLog('Insert Post' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of ' . $total); 218 222 … … 232 236 $this->WriteLog('End Sync'); 233 237 234 update_option( 'sc-s ync-end',time() );238 update_option( 'sc-soldpress_listing_sync-end',time() ); 235 239 update_option( 'sc-status', false ); 236 240 … … 240 244 public function sync_pictures() 241 245 { 246 242 247 global $wpdb; 243 248 $wpdb->query("set wait_timeout = 1200"); 244 249 $this->WriteLog('Begin Picture Sync'); 250 251 update_option( 'sc-soldpress_photo_sync-start-status', true ); 252 update_option( 'sc-soldpress_photo_sync-start',time() ); 253 update_option( 'sc-soldpress_photo_sync-end','' ); 245 254 //TODO:// we should be able to speed this up by only joining to the key 246 255 $posts_array = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'sp_property'"); … … 269 278 } 270 279 280 update_option( 'sc-soldpress_photo_sync-end',time() ); 281 update_option( 'sc-soldpress_photo_sync-start-status', false ); 271 282 $this->WriteLog('End Picture Sync'); 272 283 } -
soldpress/branches/0.9.5A/settings.php
r712036 r712192 87 87 <tr valign="top"> 88 88 <th scope="row">Last Update</th> 89 <td><?php echo date('r', get_option('sc-lastupdate' ))?></td>89 <td><?php echo get_option('sc-lastupdate' )->format('Y-m-d'); ?></td> 90 90 </tr> 91 91 </table> … … 112 112 <thead> 113 113 <tr class="thead"> 114 <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries"></th>114 <th>Job</th> 115 115 <th>Time</th> 116 <th>Function</th>117 116 <th>Schedule</th> 118 117 <th>Interval</th> 119 <th>Options</th> 118 <th>Last Start</th> 119 <th>Last End</th> 120 120 </tr> 121 121 </thead> 122 122 <tfoot> 123 123 <tr class="thead"> 124 <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries"></th>125 <th> Function</th>124 125 <th>Job</th> 126 126 <th>Time</th> 127 127 <th>Schedule</th> … … 132 132 </tfoot> 133 133 <tbody> 134 <tr class="entry-row alternate"> 135 <th scope="row" class="check-column"><input type="checkbox" name="schedules[]" class="entries" value="1"></th> 136 <td>soldpress_listing_sync 137 <div class="row-actions" style="margin:0; padding:0;"> 138 <a href="/wp-admin/admin.php?page=pluginbuddy_backupbuddy-scheduling&edit=1">Edit this schedule</a> 139 </div> 140 </td> 141 <td style="white-space: nowrap;">daily</td> 142 <td style="white-space: nowrap;">86400</td> 143 <td>Mar 30, 2013 6:27PM</td> 144 <td>Mar 30, 2013 6:27PM</td> 145 <td>Run Now</td> 146 </tr> 147 <tr class="entry-row alternate"> 148 <th scope="row" class="check-column"><input type="checkbox" name="schedules[]" class="entries" value="1"></th> 149 <td>soldpress_photo_sync 150 <div class="row-actions" style="margin:0; padding:0;"> 151 <a href="/wp-admin/admin.php?page=pluginbuddy_backupbuddy-scheduling&edit=1">Edit this schedule</a> 152 </div> 153 </td> 154 <td style="white-space: nowrap;">hourly</td> 155 <td style="white-space: nowrap;">3600</td> 156 <td>Mar 30, 2013 6:27PM</td> 157 <td>Mar 30, 2013 6:27PM</td> 158 <td>Run Now</td> 159 </tr> 134 135 <?php $time_slots = _get_cron_array(); 136 137 $tr_class = ""; 138 foreach ($time_slots as $key => $jobs) { 139 foreach ($jobs as $job => $value) { 140 if($job == 'soldpress_photo_sync' || $job == 'soldpress_listing_sync'){ 141 echo '<tr>'; 142 // echo '<th scope="row" class="check-column"><input type="checkbox" name="schedules[]" class="entries" value="1"></th>'; 143 echo '<td><strong>'.$job.'</strong><div class="row-actions" style="margin:0; padding:0;"><a href="/wp-admin/admin.php?page=pluginbuddy_backupbuddy-scheduling&edit=1">Run Now</a> | <a href="/wp-admin/admin.php?page=pluginbuddy_backupbuddy-scheduling&edit=1">Disable</a></div></td>'; 144 145 echo '<td>'.date("r", $key).'</td>'; 146 $schedule = $value[key($value)]; 147 echo '<td>'.(isset($schedule["schedule"]) ? $schedule["schedule"] : "").'</td>'; 148 echo '<td class="aright">'.(isset($schedule["interval"]) ? $schedule["interval"] : "").'</td>'; 149 echo '<td class="aright">'. Date('r',get_option('sc-'.$job.'-start' )) ; 150 echo '</td>'; 151 echo '<td class="aright">'. Date('r',get_option('sc-'.$job.'-end' )) ; 152 echo '</td>'; 153 echo '</tr>'; 154 if ($tr_class == "") 155 $tr_class = "entry-row alternate "; 156 else 157 $tr_class = "entry-row"; 158 } 159 } 160 } 161 ?> 160 162 </tbody> 161 163 </table> … … 169 171 170 172 <?php if( $active_tab == 'debug_options' ) { ?> 173 <a href="/wp-content/uploads/soldpress/soldpress-log.txt">debug log</a> 171 174 <div class = "postbox"> 172 175 <div class = "handlediv"> … … 199 202 <?php } ?> 200 203 201 <img src="<?php echo plugins_url( 'images/soldpress.jpg' , __FILE__ );?>" > 202 <br> 203 © 2013 Sanskript Solution, Inc.</div> 204 <div>© 2013 Sanskript Solution, Inc.</div> 204 205 205 206 … … 212 213 function admin_footer() { 213 214 $plugin_data = get_plugin_data( __FILE__ ); 214 printf('%1$s ' . __("plugin", 'soldpress') .' | ' . __("Version", 'soldpress') . ' %2$s | '. __('by', 'soldpress') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); 215 printf('%1$s ' . __("plugin", 'SoldPress') .' | ' . __("Version", 'SoldPress') . ' %2$s | '. __('by', 'SoldPress') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); 216 printf('%1$s ' . __("plugin", 'soldpress') .' | ' . __("Version", 'soldpress') . ' %2$s | '. __('by', 'soldpress') . ' %3$s<br />', "SoldPress", "0.5A", "Replace"); 215 217 } 216 218 //$date = new DateTime(); 217 219 //echo $date->getTimestamp(); 220 //We Do The Get Before 221 if (isset($_GET["spa"])) { 222 $sp_action = $_GET["spa"]; 223 if ($sp_action != '') { 224 switch ($$sp_action) { 225 case "unsevt": 226 227 // wp_redirect(remove_query_arg(array('time', 'job', 'spa', 'key'), stripslashes($_SERVER['REQUEST_URI']))); 228 exit(); 229 break; 230 case "runevt": 231 $job = $_GET['job']; 232 do_action($job); 233 wp_redirect(remove_query_arg(array('job', 'spa'), stripslashes($_SERVER['REQUEST_URI']))); 234 exit(); 235 break; 236 } 237 } 238 239 } 218 240 219 241 if (isset($_POST["test_connection"])) { … … 228 250 if (isset($_POST["sync"])) { 229 251 230 soldpress_listintgs();252 do_action('soldpress_listing_sync'); 231 253 } 232 254 233 255 if (isset($_POST["delete"])) { 234 $mycustomposts = get_posts( array( 'post_type' => ' property', 'numberposts' => 500) );256 $mycustomposts = get_posts( array( 'post_type' => 'sp_property', 'numberposts' => 500) ); 235 257 foreach( $mycustomposts as $mypost ) { 236 258 echo $mypost->ID; -
soldpress/branches/0.9.5A/soldpress.php
r712036 r712192 81 81 if($adapter->connect()) 82 82 { 83 return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z" ,"");84 //return $adapter-> sync_residentialproperty("LastUpdated=" . $date->format('Y-m-d') ,"");83 return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z"); 84 //return $adapter-> sync_residentialproperty("LastUpdated=" . $date->format('Y-m-d')); 85 85 } 86 86
Note: See TracChangeset
for help on using the changeset viewer.