Plugin Directory

Changeset 712192


Ignore:
Timestamp:
05/13/2013 05:20:54 AM (13 years ago)
Author:
Sanskript
Message:

Fixed issue with post_date now using moddate
Improvements to settings page.

Location:
soldpress/branches/0.9.5A
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soldpress/branches/0.9.5A/adapter.php

    r712036 r712192  
    105105    }
    106106   
    107     public function sync_residentialproperty($crit, $culture)
    108     {   
     107    public function sync_residentialproperty($crit)
     108    {   
     109
    109110        $this->WriteLog('Sync Start');
    110111        global $wpdb;
     
    112113        $syncenabled = get_option("sc-sync-enabled",true);
    113114        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       
    121119        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");
    129124
    130125        $this->WriteLog('service->Search' . $crit);
     
    133128        $properties = $this->service->Search("Property","Property",$crit,array("Limit" => '100',"Culture" => $culture));   
    134129        $this->WriteLog('Retrieved Results');
    135 
     130        $total = count($properties);
     131        $this->WriteLog("Retrieved Results Total" .$total );
     132       
    136133        //Get Disconnect Array of Current Posts
    137134        $posts_array = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'sp_property'");
     135       
    138136        //Reset Data
    139         $total = count($properties);
    140137        $count = 0;
    141138        $user_id = get_current_user_id();
     
    143140        foreach ($properties as &$rets) {
    144141           
    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"){
    146145                if($rets['City'] != "Vancouver"){
    147                     return;
     146                    continue;
    148147                }
    149148            }
     
    161160            }
    162161   
     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();
    163165            $title = $rets['UnparsedAddress'] .' (' . $rets['ListingId'] .')';
    164166            $content = "";
     
    170172                    $post->post_content  = "";
    171173                    $post->post_name = $ListingKey;
    172                     $post->post_date = $rets['ModificationTimestamp'];
     174                    $post->post_date = $postdate->format('Y-m-d H:i:s');
    173175
    174176                    wp_update_post($post);
     
    203205                      'post_type'   => 'sp_property',
    204206                      'post_name' => $ListingKey,
    205                       'post_date' => $rets['ModificationTimestamp']
     207                      'post_date' => $postdate->format('Y-m-d H:i:s')
    206208                );
    207209           
    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                        }
    213218                }
    214219                else
    215220                {
    216 
    217221                    $this->WriteLog('Insert Post' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of ' . $total); 
    218222                                   
     
    232236        $this->WriteLog('End Sync');       
    233237       
    234         update_option( 'sc-sync-end',time() );
     238        update_option( 'sc-soldpress_listing_sync-end',time() );
    235239        update_option( 'sc-status', false );
    236240       
     
    240244    public function sync_pictures()
    241245    {
     246       
    242247        global $wpdb;
    243248        $wpdb->query("set wait_timeout = 1200");
    244249        $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','' );
    245254        //TODO:// we should be able to speed this up by only joining to the key
    246255        $posts_array = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'sp_property'");
     
    269278        }
    270279       
     280        update_option( 'sc-soldpress_photo_sync-end',time() );
     281        update_option( 'sc-soldpress_photo_sync-start-status', false );
    271282        $this->WriteLog('End Picture Sync');   
    272283    }
  • soldpress/branches/0.9.5A/settings.php

    r712036 r712192  
    8787                    <tr valign="top">
    8888                    <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>
    9090                    </tr>
    9191                </table>
     
    112112            <thead>
    113113                <tr class="thead">
    114                     <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries"></th>
     114                    <th>Job</th>
    115115                    <th>Time</th>
    116                     <th>Function</th>
    117116                    <th>Schedule</th>
    118117                    <th>Interval</th>
    119                     <th>Options</th>
     118                    <th>Last Start</th>
     119                    <th>Last End</th>
    120120                </tr>
    121121            </thead>
    122122            <tfoot>
    123123                <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>
    126126                    <th>Time</th>
    127127                    <th>Schedule</th>
     
    132132            </tfoot>
    133133            <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&amp;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&amp;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&amp;edit=1">Run Now</a> | <a href="/wp-admin/admin.php?page=pluginbuddy_backupbuddy-scheduling&amp;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?>
    160162            </tbody>
    161163        </table>
     
    169171   
    170172    <?php if( $active_tab == 'debug_options' ) {  ?>
     173    <a href="/wp-content/uploads/soldpress/soldpress-log.txt">debug log</a>
    171174     <div class = "postbox">
    172175                <div class = "handlediv">
     
    199202    <?php } ?>
    200203
    201     <img src="<?php echo plugins_url( 'images/soldpress.jpg' , __FILE__ );?>" >
    202     <br>
    203     &copy; 2013 Sanskript Solution, Inc.</div>
     204    <div>&copy; 2013 Sanskript Solution, Inc.</div>
    204205
    205206       
     
    212213        function admin_footer() {
    213214            $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");
    215217        }
    216218    //$date = new DateTime();
    217219    //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        }
    218240       
    219241        if (isset($_POST["test_connection"])) { 
     
    228250        if (isset($_POST["sync"])) { 
    229251       
    230              soldpress_listintgs();
     252            do_action('soldpress_listing_sync');
    231253        }
    232254       
    233255        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) );
    235257                foreach( $mycustomposts as $mypost ) {
    236258                    echo $mypost->ID;
  • soldpress/branches/0.9.5A/soldpress.php

    r712036 r712192  
    8181    if($adapter->connect())
    8282    {
    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')); 
    8585    }
    8686   
Note: See TracChangeset for help on using the changeset viewer.