Changeset 1762

Show
Ignore:
Timestamp:
10/17/07 22:58:01 (11 months ago)
Author:
cfriesen
Message:

Refresh interval in the feed properties.

Location:
trunk/gregarius
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/admin/channels.php

    r1748 r1762  
    489489            // Delete properties 
    490490            deleteProperty($id,'rss.input.allowupdates'); 
     491             
     492            deleteProperty($id,'rss.config.refreshinterval'); 
    491493 
    492494            // Invalidate cache 
     
    647649        $old_priv = ($_POST['old_priv'] == '1'); 
    648650 
    649  
    650651        // Feed Properties 
    651652        $prop_rss_input_allowupdates = rss_real_escape_string($_POST['prop_rss_input_allowupdates']); 
     
    655656            setProperty($cid, 'rss.input.allowupdates' , 'feed', ($prop_rss_input_allowupdates == 1)); 
    656657        } 
    657  
     658         
     659        deleteProperty($cid, 'rss.config.refreshinterval'); 
     660         
     661        $rss_config_refreshinterval = rss_real_escape_string($_POST['rss_config_refreshinterval']); 
     662        if($rss_config_refreshinterval > 60) { 
     663                    setProperty($cid, 'rss.config.refreshinterval', 'feed', $rss_config_refreshinterval);    
     664                }         
    658665 
    659666        if ($priv != $old_priv) { 
     
    905912    if(!empty($daterefreshed)) { 
    906913        echo "<p><label>" . __('Added') . ": " . date("M-d-Y H:i", strtotime($dateadded)) . "</label></p>" 
    907         ."<p><label>" . __('Last Update') . ": ".date("M-d-Y H:i", strtotime($daterefreshed))."</label></p>\n"; 
     914        ."<p><label>" . __('Last Update') . ": ".date("M-d-Y H:i", strtotime($daterefreshed))." (Age: " . round(((time() - strtotime($daterefreshed))/60)) . " minutes)</label></p>\n"; 
    908915    } else { 
    909916        echo "<p><label>" . __('Added') . ": " . date("M-d-Y H:i", strtotime($dateadded)) . "</label></p>" 
     
    10391046 
    10401047    ."</p>\n"; 
     1048     
     1049    echo "<p>" 
     1050    ."<span style=\"float:left;\">Refresh Interval (minutes): </span>" 
     1051    ."&nbsp;" 
     1052    ."</p>"; 
     1053     
     1054    $rss_config_refreshinterval_default_current = getProperty($cid, 'rss.config.refreshinterval'); 
     1055     
     1056    echo "<p id=\"rss_config_refreshinterval_options\">" 
     1057    ."<input type=\"text\" id=\"rss_config_refreshinterval\" name=\"rss_config_refreshinterval\" value=\"" . (true == empty($rss_config_refreshinterval_default_current) ? 60 : $rss_config_refreshinterval_default_current) . "\">" 
     1058    ."</p>"; 
    10411059    echo "</fieldset>\n"; 
    10421060 
    10431061 
    1044     echo "<p style=\"clear:both; padding: 1em 0\"><input type=\"submit\" name=\"action_\" value=\"". __('Submit Changes') ."\" /></p>"; 
     1062        echo "<p style=\"clear:both; padding: 1em 0\"><input type=\"submit\" name=\"action_\" value=\"". __('Submit Changes') ."\" /></p>"; 
    10451063 
    10461064    echo "</form></div>\n"; 
  • trunk/gregarius/extlib/rss_dbcache.inc

    r1534 r1762  
    109109        } 
    110110 
    111         $res = rss_query("select UNIX_TIMESTAMP(daterefreshed) as ts, refreshinterval from " . getTable("channels") 
     111        $res = rss_query("select UNIX_TIMESTAMP(daterefreshed) as ts from " . getTable("channels") 
    112112                         . " where id=$cid"); 
    113113        if ( ! $res ) { 
     
    116116        } 
    117117 
    118         list($dateRefreshed, $refreshInterval) = rss_fetch_row($res); 
    119  
    120         // Lets hope that the web server and sql server have their clocks in sync 
     118        list($dateRefreshed) = rss_fetch_row($res); 
     119        $refreshInterval = getProperty($cid, 'rss.config.refreshinterval'); 
     120        if(true == empty($refreshInterval)) { 
     121            $refreshInterval = 60; 
     122        } 
     123         
     124          // Lets hope that the web server and sql server have their clocks in sync 
    121125        $age = time() - $dateRefreshed; 
     126         
    122127        if (!$refreshInterval || ($refreshInterval < 10)) { 
    123128            // We should change the Gregarius UA if we allow refreshInterval to be small 
  • trunk/gregarius/schema.php

    r1725 r1762  
    144144            // date feed was last refreshed, added in 0.5.3 
    145145            rss_query('alter table ' .getTable('channels') .' add column daterefreshed datetime null default 1'); 
    146             if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 
    147                 $updated++; 
    148                 rss_error("updated schema for table " . getTable('channels'), RSS_ERROR_NOTICE); 
    149             } else { 
    150                 rss_error("Failed updating schema for table " . getTable('channels') 
    151                 .": " . rss_sql_error_message(), RSS_ERROR_ERROR 
    152                 ); 
    153             } 
    154         // break; - fallthrough allowed on purpose because these are added at the same time 
    155         case 'c.refreshinterval': 
    156         case 'refreshinterval': 
    157             // refresh interval of a feed (in minutes), added in 0.5.3 
    158             rss_query('alter table ' .getTable('channels') .' add column refreshinterval int(16) not null default 60'); 
    159146            if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 
    160147                $updated++; 
  • trunk/gregarius/util.php

    r1730 r1762  
    456456        $np = "0"; 
    457457    } 
    458  
     458             
    459459    // Here we go! 
    460460    //error_reporting(E_ALL); 
     
    463463    error_reporting($old_level); 
    464464 
    465  
    466465    if ($rss) { 
    467466        if ($title_) { 
     
    484483            $siteurl = ""; 
    485484        } 
     485 
     486                $refreshinterval = 0; 
     487                if(is_object($rss) && array_key_exists('syn', $rss->channel)) { 
     488                        $syn = $rss->channel['syn']; 
     489 
     490                        if(array_key_exists('updateperiod', $syn)) { 
     491                                if("hourly" == $syn['updateperiod']) { 
     492                                        if(array_key_exists('updatefrequency', $syn)) { 
     493                                                $refreshinterval = 60 * $syn['updatefrequency']; 
     494                                        } 
     495                                } 
     496                        } 
     497                } 
    486498 
    487499        if ($descr_) { 
     
    546558                __exp__submitTag($newid,$tags,"'channel'"); 
    547559            } 
     560             
     561            if(false == empty($refreshinterval)) { 
     562                setProperty($newid, 'rss.config.refreshinterval', $refreshinterval); 
     563                        } 
    548564 
    549565            return array ($newid, "");