Changeset 1363


Ignore:
Timestamp:
03/20/10 12:19:33 (3 years ago)
Author:
shibuya246
Message:

[branch 1.2] updates prior to release

Location:
branches/1.2/content/plugins/autoreader
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/content/plugins/autoreader/autoreader.php

    r1334 r1363  
    77 * class: Autoreader 
    88 * type: autoreader 
    9  * hooks: install_plugin, admin_header_include, admin_plugin_settings, admin_sidebar_plugin_settings, admin_plugin_dropdown_menu, autoreader_runcron 
     9 * hooks: install_plugin, admin_plugin_settings, admin_sidebar_plugin_settings, autoreader_runcron, admin_theme_index_top 
    1010 * 
    1111 * PHP version 5 
     
    5151 
    5252 
    53  
    54  
    55     /** 
    56      * Install or Upgrade 
    57      */ 
    58     public function install_plugin($h) 
    59     { 
    60         // ************ 
    61         // PERMISSIONS 
    62         // ************ 
    63  
    64         // ************ 
    65         // SETTINGS 
    66         // ************ 
    67         // Get settings from database if they exist... 
    68          $autoreader_settings = $h->getSerializedSettings(); 
    69         if (!isset($autoreader_settings['wpo_log'])) { $autoreader_settings['wpo_log'] = true; } 
    70         if (!isset($autoreader_settings['wpo_log_stdout'])) { $autoreader_settings['wpo_log_stdout'] = false; } 
    71         if (!isset($autoreader_settings['wpo_unixcron'])) { $autoreader_settings['wpo_unixcron'] = false; }        
    72         if (!isset($autoreader_settings['wpo_cacheimage'])) { $autoreader_settings['wpo_cacheimage'] = 0; } 
    73         if (!isset($autoreader_settings['wpo_croncode'])) { $autoreader_settings['wpo_croncode'] = substr(md5(time()), 0, 8); } 
    74         if (!isset($autoreader_settings['wpo_cachepath'])) { $autoreader_settings['wpo_cachepath'] = 'cache'; } 
    75         if (!isset($autoreader_settings['wpo_help'])) { $autoreader_settings['wpo_help'] = false; } 
    76         if (!isset($autoreader_settings['wpo_premium'])) { $autoreader_settings['wpo_premium'] = false; } 
    77  
    78         $h->updateSetting('autoreader_settings', serialize($autoreader_settings)); 
    79  
    80         $this->activate($h); 
    81     } 
    82  
    83  
    84      /** 
    85      * Constructor for autoreader 
    86      */ 
    87     public function autoreader($h) 
    88     { 
    89           $autoreader_settings = $h->getSerializedSettings('autoreader'); 
    90  
    91          // Table names init 
     53     public function admin_theme_index_top($h) { 
     54         print "top"; 
     55         if ($h->cage->get->testAlnumLines('plugin')  == 'autoreader') { 
     56             print "here"; 
     57            $h->vars['autoreader_settings'] = $h->getSerializedSettings('autoreader'); 
     58            print_r( $h->vars['autoreader_settings'] ); 
     59 
     60                     // Table names init 
    9261         $this->db = array( 
    9362          'campaign'            =>  DB_PREFIX . 'autoreader_campaign', 
     
    9968        ); 
    10069 
    101         $this->pluginpath = BASEURL . 'plugins/autoreader'; 
    102        // $this->cachepath = BASEURL . get_option('wpo_cachepath'); 
     70        $this->pluginpath = PLUGINS . '/autoreader/'; 
     71        $this->cachepath = $this->pluginpath . $h->vars['autoreader_settings']['wpo_cachepath']; 
    10372 
    10473        # Cron command / url 
    105         $this->cron_url = $this->pluginpath . '/cron.php?code=' .   $autoreader_settings['wpo_croncode']; 
     74        $this->cron_url = $this->pluginpath . '/cron.php?code=' .   $h->vars['autoreader_settings']['wpo_croncode']; 
    10675        $this->cron_command = '*/20 * * * * '. $this->getCommand() . ' ' . $this->cron_url; 
     76 
     77 
     78 
     79         } 
     80     } 
     81 
     82    /** 
     83     * Install or Upgrade 
     84     */ 
     85    public function install_plugin($h) 
     86    { 
     87        // ************ 
     88        // PERMISSIONS 
     89        // ************ 
     90 
     91        // ************ 
     92        // SETTINGS 
     93        // ************ 
     94        // Get settings from database if they exist... 
     95         $autoreader_settings = $h->getSerializedSettings(); 
     96        if (!isset($autoreader_settings['wpo_log'])) { $autoreader_settings['wpo_log'] = true; } 
     97        if (!isset($autoreader_settings['wpo_log_stdout'])) { $autoreader_settings['wpo_log_stdout'] = false; } 
     98        if (!isset($autoreader_settings['wpo_unixcron'])) { $autoreader_settings['wpo_unixcron'] = false; }        
     99        if (!isset($autoreader_settings['wpo_cacheimages'])) { $autoreader_settings['wpo_cacheimages'] = 0; } 
     100        if (!isset($autoreader_settings['wpo_croncode'])) { $autoreader_settings['wpo_croncode'] = substr(md5(time()), 0, 8); } 
     101        if (!isset($autoreader_settings['wpo_cachepath'])) { $autoreader_settings['wpo_cachepath'] = 'cache'; } 
     102        if (!isset($autoreader_settings['wpo_help'])) { $autoreader_settings['wpo_help'] = false; } 
     103        if (!isset($autoreader_settings['wpo_premium'])) { $autoreader_settings['wpo_premium'] = false; } 
     104 
     105        $h->updateSetting('autoreader_settings', serialize($autoreader_settings)); 
     106 
     107        $this->activate($h); 
    107108    } 
     109 
    108110 
    109111 
     
    120122    {         
    121123        # autoreader_campaign 
    122         $exists = $h->db->table_exists($this->db['campaign']); 
    123         if (!$exists) { 
    124             $h->db->query ( "CREATE TABLE" . $this->db['campaign'] . " ( 
     124        $exists = $h->db->table_exists(str_replace(DB_PREFIX, "", $this->db['campaign'])); 
     125        if (!$exists) { 
     126            $h->db->query ( "CREATE TABLE " . $this->db['campaign'] . " ( 
    125127                                id int(11) unsigned NOT NULL auto_increment, 
    126128                                title varchar(255) NOT NULL default '', 
     
    147149 
    148150                # autoreader_campaign_category 
    149         $exists = $h->db->table_exists($this->db['campaign_category']); 
     151        $exists = $h->db->table_exists( str_replace(DB_PREFIX, "", $this->db['campaign_category'])); 
    150152        if (!$exists) { 
    151153            $h->db->query ( "CREATE TABLE " . $this->db['campaign_category'] . " ( 
     
    159161 
    160162        # autoreader_campaign_feed 
    161         $exists = $h->db->table_exists($this->db['campaign_feed']); 
     163        $exists = $h->db->table_exists(str_replace(DB_PREFIX, "", $this->db['campaign_feed'])); 
    162164        if (!$exists) { 
    163165            $h->db->query ( "CREATE TABLE " . $this->db['campaign_feed'] . " ( 
     
    178180 
    179181        # autoreader_campaign_post 
    180         $exists = $h->db->table_exists($this->db['campaign_post']); 
     182        $exists = $h->db->table_exists(str_replace(DB_PREFIX, "", $this->db['campaign_post'])); 
    181183        if (!$exists) { 
    182184            $h->db->query ( "CREATE TABLE " . $this->db['campaign_post'] . " ( 
     
    192194 
    193195         # autoreader_campaign_word 
    194          $exists = $h->db->table_exists($this->db['campaign_word']); 
     196         $exists = $h->db->table_exists(str_replace(DB_PREFIX, "", $this->db['campaign_word'])); 
    195197         if (!$exists) { 
    196198            $h->db->query ( "CREATE TABLE " . $this->db['campaign_word'] . " ( 
     
    208210 
    209211          # autoreader_log 
    210           $exists = $h->db->table_exists($this->db['log']); 
     212          $exists = $h->db->table_exists(str_replace(DB_PREFIX, "", $this->db['log'])); 
    211213          if (!$exists) { 
    212214            $h->db->query ( "CREATE TABLE " . $this->db['log'] . " ( 
     
    263265    /** 
    264266    * Checks that autoreader tables exist 
    265     * 
     267    *  
    266268    * 
    267269    */ 
     
    279281   public function autoreader_runcron($h, $args) { 
    280282    $cid = $args['id']; 
    281     //print_r ($args); 
    282283 
    283284    $this->forcefetched = $this->processCampaign($h,$cid); 
    284285} 
    285  
    286  
    287        
    288  
     286      
    289287 
    290288 } 
  • branches/1.2/content/plugins/autoreader/autoreader_settings.php

    r1334 r1363  
    9090     */ 
    9191    public function getOptionSettings($h, $options = null) 
    92     {         
    93         if ($h->cage->post->testAlpha('action') == "save" ) {            
     92    { 
     93        $autoreader_settings = $h->getSerializedSettings('autoreader'); 
     94 
     95        if ($h->cage->post->testAlpha('action') == "save" ) {                      
     96            $autoreader_settings['wpo_log'] = $h->cage->post->keyExists('option_logging'); 
     97            $autoreader_settings['wpo_log_stdout'] =  $h->cage->post->keyExists('option_log_stdout'); 
     98            $autoreader_settings['wpo_unixcron'] =  $h->cage->post->keyExists('option_unixcron'); 
     99            $autoreader_settings['wpo_croncode'] =  $h->cage->post->keyExists('option_croncode'); 
     100            $autoreader_settings['wpo_cacheimages'] = $h->cage->post->keyExists('option_caching'); 
     101            $autoreader_settings['wpo_cachepath'] = $h->cage->post->testPage('option_cachepath');               
     102 
     103            $h->updateSetting('autoreader_settings', serialize($autoreader_settings),'autoreader'); 
    94104            $array = array('saved' => 'true'); 
    95             $autoreader_settings['wpo_log'] = $h->cage->post->testAlnumLines('option_logging'); 
    96             $autoreader_settings['wpo_log_stdout'] =  $h->cage->post->testAlnumLines('option_log_stdout'); 
    97             $autoreader_settings['wpo_unixcron'] =  $h->cage->post->testAlnumLines('option_unixcron'); 
    98             $autoreader_settings['wpo_croncode'] =  $h->cage->post->testAlnumLines('option_croncode'); 
    99             $autoreader_settings['wpo_cacheimage'] = $h->cage->post->testAlnumLines('option_cachimage'); 
    100             $autoreader_settings['wpo_cachepath'] = $h->cage->post->testAlnumLines('option_cachepath'); 
    101  
    102             $h->updateSetting('autoreader_settings', serialize($autoreader_settings)); 
    103105        } 
    104         else {  
    105             $autoreader_settings = $h->getSerializedSettings('autoreader'); 
     106        else {              
    106107            $array = $autoreader_settings;            
    107108       } 
     
    310311 
    311312    // Reset count and lasactive 
    312     $wpdb->query(WPOTools::updateQuery($this->db['campaign'], array( 
     313    $h->db->query(WPOTools::updateQuery($this->db['campaign'], array( 
    313314      'count' => 0, 
    314315      'lastactive' => 0 
     
    318319    foreach($this->getCampaignFeeds($h, $id) as $feed) 
    319320    { 
    320       $wpdb->query(WPOTools::updateQuery($this->db['campaign_feed'], array( 
     321      $h->db->query(WPOTools::updateQuery($this->db['campaign_feed'], array( 
    321322        'count' => 0, 
    322323        'lastactive' => 0, 
     
    325326    } 
    326327 
    327     //delete any cron jobs for this campaign ? 
     328    //no need to delete cron jobs here 
    328329 
    329330    $arr = array('id'=> $id); 
     
    465466   * @return  integer   Number of processed items 
    466467   */ 
    467   function processCampaign($h, &$campaign) 
     468  function processCampaign($h, $campaign) 
    468469  { 
    469470    @set_time_limit(0); 
     
    473474    $campaign = is_numeric($campaign) ? $this->getCampaignById($h,$campaign) : $campaign; 
    474475 
    475     // Log 
    476     $this->log($h, 'Processing campaign ' . $campaign->title . ' (ID: ' . $campaign->id . ')'); 
    477  
    478     // Get feeds 
    479     $count = 0; 
    480     $feeds = $this->getCampaignFeeds($h, $campaign->id); 
    481  
    482     foreach($feeds as $feed) 
    483         $count += $this->processFeed($h, $campaign, $feed); 
    484  
    485     $h->db->query(WPOTools::updateQuery($this->db['campaign'], array( 
    486       'count' => $campaign->count + $count, 
    487       'lastactive' => current_time('mysql', true) 
    488     ), "id = {$campaign->id}")); 
    489  
    490     return $count; 
     476    if ($campaign) { 
     477 
     478        // Log 
     479        $this->log($h, 'Processing campaign ' . $campaign->title . ' (ID: ' . $campaign->id . ')'); 
     480 
     481        // Get feeds 
     482        $count = 0; 
     483        $feeds = $this->getCampaignFeeds($h, $campaign->id); 
     484 
     485        foreach($feeds as $feed) 
     486            $count += $this->processFeed($h, $campaign, $feed); 
     487 
     488        $h->db->query(WPOTools::updateQuery($this->db['campaign'], array( 
     489          'count' => $campaign->count + $count, 
     490          'lastactive' => current_time('mysql', true) 
     491        ), "id = {$campaign->id}")); 
     492 
     493        return $count; 
     494 
     495    } 
    491496  } 
    492497 
     
    592597      $date = null;*/ 
    593598 
    594            if($campaign->feeddate) 
     599   if($campaign->feeddate) 
    595600         $date = $item->get_date('U'); 
    596601    else 
     
    604609    $root=$_SERVER['HTTP_HOST']; 
    605610 
    606     // $posturl=file_get_contents("http://$root/wp-content/plugins/wp-o-matic/original_url.php?blog=$permalink"); 
     611    // $posturl=file_get_contents("/original_url.php?blog=$permalink"); 
    607612    // $posturl = $this->get_sourceurl($permalink); 
    608 $posturl =  $permalink; 
     613    $posturl =  $permalink; 
    609614 
    610615 
     
    617622   
    618623   
    619         //tags 
     624    //tags 
    620625    $post_tags=$item->get_categories(); 
    621626 
     
    663668  function isDuplicate($h, &$campaign, &$feed, &$item) 
    664669  { 
    665     $hash = $this->getItemHash($item); 
    666     $row = $h->db->get_row("SELECT * FROM {$this->db['campaign_post']} " 
    667                           . "WHERE campaign_id = {$campaign->id} AND feed_id = {$feed->id} AND hash = '$hash' "); 
     670    $row = $h->urlExists($item->get_permalink()); 
     671    //$hash = $this->getItemHash($item); 
     672    //$row = $h->db->get_row("SELECT * FROM {$this->db['campaign_post']} " 
     673    //                      . "WHERE campaign_id = {$campaign->id} AND feed_id = {$feed->id} AND hash = '$hash' "); 
    668674    return !! $row; 
    669675  } 
     
    671677 
    672678 /** 
    673    * Writes a post to blog 
     679   * Submit a post to db 
    674680   * 
    675681   * 
     
    687693  function insertPost($h, $title, $content, $timestamp = null, $category = null, $tags= null, $status = 'pending', $authorid = null, $allowpings = true, $comment_status = 'open', $meta = array()) 
    688694  { 
    689     $date = ($timestamp) ? gmdate('Y-m-d H:i:s', $timestamp + (get_option('gmt_offset') * 3600)) : null; 
     695    $date = $timestamp; 
     696    //$date = ($timestamp) ? gmdate('Y-m-d H:i:s', $timestamp + (get_option('gmt_offset') * 3600)) : null; 
    690697 
    691698    $h->post = new Post(); 
     
    694701    $h->post->url = make_url_friendly($title); 
    695702    $h->post->content = $content; 
     703    $h->post->date = $date; 
    696704    $h->post->type = 'news'; 
    697     $h->post->category = ""; 
     705    $h->post->category =  $category[0]; 
    698706    $h->post->tags = $tags; 
    699     $h->post->author = $h->currentUser->id; 
     707    $h->post->origUrl = $meta["wpo_sourcepermalink"]; 
     708    $h->post->domain = get_domain($meta["wpo_sourcepermalink"]); 
     709    $h->post->author = $authorid; 
    700710    $h->post->status = $status; 
    701711 
     
    719729*/ 
    720730        $postid = $h->post->vars['last_insert_id']; 
    721  
    722                 return $postid; 
     731        return $postid; 
    723732  } 
    724733 
     
    737746 
    738747 
    739  
    740  
    741  
    742  
    743  
    744  
    745  
    746  
    747  
    748  
    749  
    750748/** 
    751749   * Checks submitted campaign edit form for errors 
     
    755753   */ 
    756754  function adminCampaignRequest($h) 
    757   { 
     755  {  
    758756    $data_active = $h->cage->post->testAlnumLines('campaign_active'); 
    759757    $data_template = $h->cage->post->testAlnumLines('campaign_templatechk'); 
     
    767765    $this->campaign_data = $this->campaign_structure; 
    768766    $this->campaign_data['main'] = array( 
    769         'title'         => $h->cage->post->testAlnumLines('campaign_title'), 
    770         'active'        => (isset( $data_active)), 
     767        'title'         => $h->cage->post->getHtmLawed('campaign_title'), 
     768        'active'        => $h->cage->post->keyExists('campaign_active'), 
    771769        'slug'          => $h->cage->post->testAlnumLines('campaign_slug'), 
    772         'template'      => (isset($data_template)) 
     770        'template'      => ($h->cage->post->keyExists('campaign_template')) 
    773771                            ? $data = $h->cage->post->testAlnumLines('campaign_template') : null, 
    774         'frequency'     => intval($h->cage->post->testInt('campaign_frequency_d')) * 86400 
    775                           + intval($h->cage->post->testInt('campaign_frequency_h')) * 3600 
    776                           + intval($h->cage->post->testInt('campaign_frequency_m')) * 60,        
    777         'cacheimages'   => (int) isset( $data_cacheimages), 
    778         'feeddate'      => (int) isset( $data_feeddate), 
     772        'frequency'     =>  $h->cage->post->testInt('campaign_frequency_d') * 86400 
     773                          + $h->cage->post->testInt('campaign_frequency_h') //* 3600 
     774                          + $h->cage->post->testInt('campaign_frequency_m') * 60,        
     775        'cacheimages'   => $h->cage->post->keyExists( 'campaign_cacheimages'), 
     776        'feeddate'      => $h->cage->post->keyExists( 'campaign_feeddate'), 
    779777        'posttype'      => $h->cage->post->testAlpha('campaign_posttype'), 
    780778        'author'        => $h->cage->post->testAlpha('campaign_author'), 
    781         'comment_status' => $h->cage->post->testAlpha('campaign_commentstatus'), 
    782         'allowpings'    => (int) isset($data_allowpings), 
    783         'dopingbacks'   => (int) isset( $data_dopingbacks), 
    784         'max'           => intval($h->cage->post->testInt('campaign_max')), 
    785         'linktosource'  => (int) isset($data_linktosource) 
     779        'comment_status'=> $h->cage->post->testAlpha('campaign_commentstatus'), 
     780        'allowpings'    => $h->cage->post->keyExists('campaign_allowpings'), 
     781        'dopingbacks'   => $h->cage->post->keyExists('campaign_dopingbacks'), 
     782        'max'           => $h->cage->post->testInt('campaign_max'), 
     783        'linktosource'  => $h->cage->post->keyExists('campaign_linktosource') 
    786784    ); 
    787785 
     
    793791    { 
    794792      $feed = trim($feed); 
    795  
    796793      if(!empty($feed)) 
    797794      { 
     
    804801 
    805802    // Existing feeds to delete 
    806     if(isset($data['campaign_feed']['delete'])) 
    807     { 
     803    if($h->cage->post->keyExists('/campaign_feed/delete')) 
     804    {         
    808805      $this->campaign_data['feeds']['delete'] = array(); 
    809  
    810       foreach($data['campaign_feed']['delete'] as $feedid => $yes) 
    811         $this->campaign_data['feeds']['delete'][] = intval($feedid); 
     806      foreach($h->cage->post->getRaw('/campaign_feed/delete') as $feedid => $yes) 
     807        $this->campaign_data['feeds']['delete'][] = intval($feedid);       
    812808    } 
    813809 
    814810    // Existing feeds. 
    815     if(isset($data['id'])) 
     811    if($h->cage->post->keyExists('campaign_edit')) 
    816812    { 
    817813      $this->campaign_data['feeds']['edit'] = array(); 
    818       foreach($this->getCampaignFeeds(intval($data['id'])) as $feed) 
     814      foreach($this->getCampaignFeeds($h,intval($h->cage->post->testInt('campaign_edit'))) as $feed) 
    819815        $this->campaign_data['feeds']['edit'][$feed->id] = $feed->url; 
    820816    } 
    821  
     817            
    822818    // Categories 
    823     if(isset($data['campaign_categories'])) 
    824     { 
    825       foreach($data['campaign_categories'] as $category) 
    826       { 
    827         $id = intval($category); 
    828         $this->campaign_data['categories'][] = $category; 
    829       } 
     819    if($h->cage->post->keyExists('campaign_categories') ) 
     820    { 
     821       foreach($h->cage->post->keyExists('campaign_categories') as $key => $value) { 
     822        $this->campaign_data['categories'][] = $value; 
     823     } 
    830824    } 
    831825 
    832826    # New categories 
    833     if(isset($data['campaign_newcat'])) 
    834     { 
    835       foreach($data['campaign_newcat'] as $k => $on) 
    836       { 
    837         $catname = $data['campaign_newcatname'][$k]; 
     827    if($h->cage->post->keyExists('campaign_newcat') ) 
     828    { 
     829      foreach($h->cage->post->keyExists('campaign_newcat') as $k => $on) 
     830      { 
     831        $catname = $on; 
    838832        if(!empty($catname)) 
    839833        { 
     
    847841 
    848842   // Rewrites 
    849     if(isset($data['campaign_word_origin'])) 
    850     { 
    851       foreach($data['campaign_word_origin'] as $id => $origin_data) 
     843    if($h->cage->post->keyExists('campaign_word_origin') ) 
     844    { 
     845      foreach($h->cage->post->keyExists('campaign_word_origin') as $id => $origin_data) 
    852846      { 
    853847        $rewrite = isset($data['campaign_word_option_rewrite']) 
     
    882876    } 
    883877 
    884     $errors = array('basic' => array(), 'feeds' => array(), 'categories' => array(), 
     878    $errors = array('errors'=>0, 'basic' => array(), 'feeds' => array(), 'categories' => array(), 
    885879                    'rewrite' => array(), 'options' => array()); 
     880    $this->errno = 0; 
    886881 
    887882    # Main 
     
    942937 
    943938    # Options 
    944 //    if(! get_userdatabylogin($this->campaign_data['main']['author'])) 
    945 //    { 
    946 //      $errors['options'][] = __('Author username not found', 'wpomatic'); 
    947 //      $this->errno++; 
    948 //    } 
     939    //Allow blank username as code will allocate currentuser when writing to sql db 
     940    //if(! $h->getUserIdFromName($this->campaign_data['main']['author'])) 
     941    //{ 
     942    //  $errors['options'][] = 'Author username not found'; 
     943    //  $this->errno++; 
     944    //} 
    949945 
    950946    if(! $this->campaign_data['main']['frequency']) 
     
    960956    } 
    961957 
    962     if($this->campaign_data['main']['cacheimages'] && !is_writable($this->cachepath)) 
    963     { 
    964       $errors['options'][] = 'Cache path (in <a href="' . $this->adminurl . '&s=options">Options</a>) must be writable before enabling image caching.'; 
     958    //print "cacheimages: " . $this->campaign_data['main']['cacheimages']; 
     959    if($this->campaign_data['main']['cacheimages'] && !is_writable( $this->cachepath)) 
     960    { 
     961      $errors['options'][] = 'Cache path must be present and writable before enabling image caching.'; 
    965962      $this->errno++; 
    966963    } 
    967964 
     965    $errors['errors'] = $this->errno; 
    968966    $this->errors = $errors; 
    969     return $errors; 
    970     //print_r ( $this->errors); 
     967     
     968    return json_encode($errors); 
     969     
    971970    //exit; 
    972971  } 
     
    10151014    } 
    10161015 
    1017     # All 
     1016    # All    
    10181017    foreach($this->campaign_data['categories'] as $category) 
    10191018    { 
    10201019      // Insert 
    1021       $wpdb->query(WPOTools::insertQuery($this->db['campaign_category'], 
     1020      $h->db->query(WPOTools::insertQuery($this->db['campaign_category'], 
    10221021        array('category_id' => $category, 
    10231022              'campaign_id' => $id) 
     
    10371036    { 
    10381037      foreach($this->campaign_data['feeds']['delete'] as $feed) 
    1039         $wpdb->query("DELETE FROM {$this->db['campaign_feed']} WHERE id = $feed "); 
     1038        $h->db->query("DELETE FROM {$this->db['campaign_feed']} WHERE id = $feed "); 
    10401039    } 
    10411040 
     
    10431042    foreach($this->campaign_data['rewrites'] as $rewrite) 
    10441043    { 
    1045       $wpdb->query(WPOTools::insertQuery($this->db['campaign_word'], 
     1044       $h->db->query(WPOTools::insertQuery($this->db['campaign_word'], 
    10461045        array('word' => $rewrite['origin']['search'], 
    10471046              'regex' => $rewrite['origin']['regex'], 
     
    10561055    $main = $this->campaign_data['main']; 
    10571056 
    1058     // Fetch author id 
    1059     $main['authorid'] = $h->getUserIdFromName($this->campaign_data['main']['author']); 
     1057    //Test author name 
     1058    $authorname =  $this->campaign_data['main']['author']; 
     1059    $userid = $h->getUserIdFromName($authorname); 
     1060    if ($userid) { $main['authorid'] =$userid;  } else { $main['authorid'] = $h->currentUser->id;  } 
    10601061    unset($main['author']); 
    10611062 
     
    10641065    $h->db->query($query); 
    10651066 
    1066    //get data ready to pass to cron plugin 
    1067    $timestamp = time(); 
    1068    switch ($this->campaign_data['main']['frequency']) { 
    1069        case 43200 : $recurrence = "twicedaily"; break; 
    1070        case 86400 : $recurrence = "daily"; break; 
    1071        case 302400 : $recurrence = "weekly"; break; 
    1072        default : $recurrence = "hourly"; break; 
     1067   if ($this->campaign_data['main']['active']) { 
     1068       //get data ready to pass to cron plugin 
     1069       $timestamp = time(); 
     1070       switch ($this->campaign_data['main']['frequency']) { 
     1071           case 43200 : $recurrence = "twicedaily"; break; 
     1072           case 86400 : $recurrence = "daily"; break; 
     1073           case 302400 : $recurrence = "weekly"; break; 
     1074           default : $recurrence = "hourly"; break; 
     1075       } 
     1076       $hook = "autoreader_runcron"; 
     1077       $args = array('id'=> $id); 
     1078       $cron_data = array('timestamp'=>$timestamp, 'recurrence'=>$recurrence, 'hook'=>$hook, 'args'=>$args); 
     1079       $h->pluginHook('cron_update_job', 'cron', $cron_data); 
    10731080   } 
    1074    $hook = "autoreader_runcron"; 
    1075    $args = array('id'=> $id); 
    1076    $cron_data = array('timestamp'=>$timestamp, 'recurrence'=>$recurrence, 'hook'=>$hook, 'args'=>$args); 
    1077    $h->pluginHook('cron_update_job', 'cron', $cron_data);   
     1081   else 
     1082   { 
     1083       $hook = "autoreader_runcron"; 
     1084       $args = array('id'=> $id); 
     1085       $cron_data = array('hook'=>$hook, 'args'=>$args); 
     1086       $h->pluginHook('cron_delete_job', 'cron', $cron_data); 
     1087   } 
    10781088 
    10791089   // campaign_frequency_d 
     
    11621172 
    11631173    // Caching 
    1164     if ($campaign->cacheimages)   // set override here for all campaigns  get_option('wpo_cacheimages') 
     1174    if ($h->vars['autoreader_settings']['cacheimages'] || $campaign->cacheimages)   // set override here for all campaigns  get_option('wpo_cacheimages') 
    11651175    { 
    11661176      $images = WPOTools::parseImages($content); 
     
    12541264    { 
    12551265      file_put_contents($cachepath . '/' . $filename, $contents); 
    1256       return $this->pluginpath . '/' . get_option('wpo_cachepath') . '/' . $filename; 
     1266      return $this->pluginpath . '/' . $h->vars['autoreader_settings']['wpo_cachepath'] . '/' . $filename; 
    12571267    } 
    12581268 
     
    13231333      { 
    13241334        $campaign_data['main'] = array_merge($campaign_data['main'], $campaign); 
    1325 //        $userdata = get_userdata($campaign_data['main']['authorid']); 
    1326 //        $campaign_data['main']['author'] = $userdata->user_login; 
     1335        $userdata = $h->getUserNameFromId($campaign_data['main']['authorid']); 
     1336        $campaign_data['main']['author'] = $userdata; 
    13271337      } 
    13281338 
     
    13321342        $categories = $h->db->get_results("SELECT * FROM {$this->db['campaign_category']} WHERE campaign_id = $id"); 
    13331343        if ($categories) { 
    1334         foreach($categories as $category) 
    1335           $campaign_data['categories'][] = $category->category_id; 
    1336         } else { 
    1337             } 
     1344            foreach($categories as $category) 
     1345              $campaign_data['categories'][] = $category->category_id; 
     1346        } 
    13381347      } 
    13391348 
  • branches/1.2/content/plugins/autoreader/templates/autoreader_add.php

    r1334 r1363  
    1616            break; 
    1717        case "save" :            
    18             $arSettings->adminCampaignRequest($h); 
    19             if ( $h->cage->post->keyExists('campaign_edit') ) { 
    20                 $cid = $h->cage->post->getInt('campaign_edit');                 
    21                 $arSettings->adminProcessEdit($h,$cid); 
     18            $errors = $arSettings->adminCampaignRequest($h); 
     19            print $errors; 
     20            $arr_errors = json_decode($errors);            
     21            if ($arr_errors->errors == 0) { 
     22                if ( $h->cage->post->keyExists('campaign_edit') ) { 
     23                    $cid = $h->cage->post->getInt('campaign_edit'); 
     24                    $arSettings->adminProcessEdit($h,$cid); 
     25                } 
     26                else {      
     27                    $arSettings->adminProcessAdd($h); 
     28                } 
    2229            } 
    23             else {                
    24                 $arSettings->adminProcessAdd($h); 
    25             }; 
    2630            exit;  // this is an ajax return call, so we don't want any html echoing to the screen 
     31        case "tools_delete" : 
     32            $cid = $h->cage->post->getInt('id'); 
     33        print $cid; 
     34            //$errors = $arSettings->toolsdelete($h); 
     35            //print $errors; 
     36            exit; 
    2737        case "test_feed" :            
    2838            $data = $h->cage->post->testUri('url');             
     
    6272        <li><input type="submit" name="edit_submit" value="Submit" id="edit_submit" /></li> 
    6373      </ul> 
    64  
     74        <div id="error_message"></div> 
    6575      <div id="admin_plugin_tabs"> 
    6676      <ul class="tabs"> 
     
    101111        <!-- Feeds section --> 
    102112        <div class="section" id="section_feeds"> 
    103           <p>Please fill in at least one feed. If you\'re not sure about the exact feed url, just type in the domain name, and the feed will be autodetected</p> 
     113          <p>Please fill in at least one feed. If you are not sure about the exact feed url, just type in the domain name, and the feed will be autodetected</p> 
    104114 
    105115          <div id="edit_feed"> 
     
    137147        <!-- Categories section --> 
    138148        <div class="section" id="section_categories"> 
    139           <p>These are the categories where the posts will be created once they're fetched from the feeds.</p> 
     149          <p>These are the categories where the posts will be created once they are fetched from the feeds.</p> 
    140150          <p>Please select one.</p> 
    141151 
    142152          <ul id="categories"> 
    143153            <?php $arSettings->adminEditCategories($h, $data) ?> 
     154 
     155            <?php if(isset($data['categories']['new'])): ?> 
     156              <?php foreach($data['categories']['new'] as $i => $catname): ?> 
     157              <li> 
     158                <?php echo checkbox_tag('campaign_newcat[]', 1, true, 'id=campaign_newcat_' . $i) ?> 
     159                <?php echo input_tag('campaign_newcatname[]', $catname, 'class=input_text id=campaign_newcatname_' . $i) ?> 
     160              </li> 
     161              <?php endforeach ?> 
     162            <?php endif ?> 
    144163          </ul> 
    145164 
     165         
    146166           <?php if ($autoreader_settings['wpo_premium']) { ?> 
    147167                <a href="#quick_add" id="quick_add">Quick add</a> 
     
    151171        <!-- Rewrite section --> 
    152172        <div class="section" id="section_rewrite"> 
     173        <?php if ($autoreader_settings['wpo_help']) { ?> 
    153174          <p>Want to transform a word into another? Or link a specific word to some website? 
    154 <?php // echo '<a href=' . $arSettings->helpurl . '" class="help_link">Read more</a>' ?></p> 
     175            <?php // echo '<a href=' . $arSettings->helpurl . '" class="help_link">Read more</a>' ?></p> 
    155176 
    156177          <ul id="edit_words"> 
     
    203224          </ul> 
    204225 
    205            <?php if ($autoreader_settings['wpo_premium']) { ?> 
     226            
    206227                <a href="#add_word" id="add_word">Add more</a> 
    207            <?php } ?> 
     228           <?php } else { 
     229               echo "This section is being worked on and will be added in a future release of this plugin."; 
     230           }?> 
     231                 
    208232        </div> 
    209233 
     
    213237          <div class="section_warn"> 
    214238            <img src="<?php echo $arSettings->tplpath ?>/images/icon_alert.gif" alt="Warning" class="icon" /> 
    215             <h3>Remember that</h3> 
     239            <h3>Note</h3> 
    216240            <p>Changing these options only affects the creation of posts after the next time feeds are parsed.</p> 
    217241            <p>If you need to edit existing posts, you can do so by using the options under the Tools tab</p> 
     
    263287             <?php } ?> 
    264288 
    265              <select name="campaign_frequency_h"> 
    266               <option value="1">hourly</option> 
    267               <option value="12">twice daily</option> 
    268               <option value="24">daily</option> 
    269               <option value="84">weekly</option> 
    270             </select> 
    271  
    272             <p class="note">How often should feeds be checked? </p> 
    273           </div> 
    274  
    275           <?php if ($autoreader_settings['wpo_premium']) { ?> 
     289             <?php echo select_tag('campaign_frequency_h', 
     290                        options_for_select( 
     291                          array('3600' => 'hourly', 
     292                                '43200' => 'twice daily', 
     293                                '86400' => 'daily', 
     294                                '302400' => 'weekly' 
     295                                ), _data_value($data['main'], 'frequency', '1'))) ?> 
     296                 
     297 
     298            <p class="note">How often should this feed be checked? </p> 
     299          </div> 
     300 
     301           <?php if (!$autoreader_settings['wpo_premium']) { ?> 
    276302              <div class="checkbox"> 
    277303                <?php echo label_for('campaign_cacheimages', 'Cache images') ?> 
    278304                <? // need to install timthumb folder to get the following working  ?> 
    279                 <?php  echo checkbox_tag('campaign_cacheimages', 1, _data_value($data['main'], 'cacheimages', is_writable($arSettings->cachepath))) ?> 
     305                <?php  echo checkbox_tag('campaign_cacheimages', 1, _data_value($data['main'], 'cacheimages', is_writable($autoreader_settings['wpo_cachepath']))) ?> 
    280306                <p class="note">Images will be stored in your server, instead of hotlinking from the original site. 
    281                     <a href="helpurl image_caching" class="help_link">More</a></p> 
    282               </div> 
    283           <?php } ?> 
     307                     <?php if ($autoreader_settings['wpo_help']) { ?><a href="helpurl image_caching" class="help_link">More</a><?php } ?></p> 
     308              </div> 
     309           <?php } ?> 
    284310 
    285311          <div class="checkbox"> 
     
    309335          <div class="text"> 
    310336            <?php echo label_for('campaign_author', 'Author:') ?> 
     337            <?php echo input_tag('campaign_author', _data_value($data['main'], 'author')) ?> 
    311338 <?php // echo select_tag('campaign_author', options_for_select($author_usernames, _data_value($data['main'], 'author', 'admin'))) ?> 
    312             <p class="note">The created posts will be assigned to admin.</p> 
     339            <p class="note">If blank, the created posts will be assigned to the current user.</p> 
    313340          </div> 
    314341 
     
    319346          </div> 
    320347 
    321           <div class="checkbox"> 
    322             <?php echo label_for('campaign_linktosource', 'Post title links to source?') ?> 
    323             <?php echo checkbox_tag('campaign_linktosource', 1, _data_value($data['main'], 'linktosource', false)) ?> 
    324           </div> 
     348          <?php if ($autoreader_settings['wpo_premium']) { ?> 
     349              <div class="checkbox"> 
     350                <?php echo label_for('campaign_linktosource', 'Post title links to source?') ?> 
     351                <?php echo checkbox_tag('campaign_linktosource', 1, _data_value($data['main'], 'linktosource', false)) ?> 
     352              </div> 
     353          <?php } ?> 
    325354 
    326355          <?php if ($autoreader_settings['wpo_premium']) { ?> 
     
    341370        </div> 
    342371 
    343          <?php if ($autoreader_settings['wpo_premium']) { ?> 
    344         <?php if($action == 'edit'): ?> 
     372          
     373        <?php if($action == 'edit'): ?>        
    345374        <!-- Tools --> 
    346375        <div class="section" id="section_tools"> 
     376            <?php if (!$autoreader_settings['wpo_premium']) { ?> 
    347377          <div class="buttons"> 
    348378            <h3>Posts action</h3> 
    349379            <p class="note">The selected action applies to all the posts created by this campaign</p> 
    350  
    351380            <ul> 
    352381              <li> 
     382                 <div class="text"> 
     383                    Check hotaru Cron to confirm running of this campaign. <a href="/admin_index.php?page=plugin_settings&plugin=cron">check now</a> 
     384                 </div> 
     385              </li> 
     386              <li> 
     387                 
     388                <label class="main">Delete posts from database:</label> 
    353389                <div class="btn"> 
    354390                  <input type="submit" name="tool_removeall" value="Remove all" /> 
    355391                </div> 
     392                
    356393              </li> 
    357394              <li> 
    358395                <div class="radio"> 
    359396                  <label class="main">Change status to:</label> 
    360  
    361                   <input type="radio" name="campaign_tool_changetype" value="new" id="changetype_new" checked="checked" /> <label for="changetype_new">New</label> 
    362                   <input type="radio" name="campaign_tool_changetype" value="private" id="changetype_private" /> <label for="changetype_private">Private</label> 
    363                   <input type="radio" name="campaign_tool_changetype" value="draft" id="changetype_draft" /> <label for="changetype_draft">Draft</label> 
    364                   <input type="submit" name="tool_changetype" value="Change" /> 
     397                  <input type="radio" name="campaign_tool_changetype" value="new" id="changetype_new" checked="checked" /> <label for="changetype_new">Published (New)</label> 
     398                  <input type="radio" name="campaign_tool_changetype" value="private" id="changetype_pending" /> <label for="changetype_pending">Pending</label> 
     399                 <input type="submit" name="tool_changetype" value="Change" /> 
    365400                </div> 
    366401              </li> 
    367402              <li> 
    368403                <div class="text"> 
    369                   <label for="campaign_tool_changeauthor">Change author username to:</label> 
    370                   <?php echo select_tag('campaign_tool_changeauthor', options_for_select($author_usernames, _data_value($data['main'], 'author', 'admin'))) ?> 
    371  
     404                  <?php echo label_for('campaign_tool_changeauthor', 'Change author username to:') ?> 
     405                  <?php echo input_tag('campaign_tool_changeauthor', _data_value($data['main'], 'author')) ?> 
    372406                  <input type="submit" name="tool_changeauthor" value="Change" /> 
     407                  <p class="note">If blank, the created posts will be assigned to the current user.</p> 
    373408                </div> 
    374               </li> 
     409              </li>              
    375410            </ul> 
    376411          </div> 
     
    383418          </div> 
    384419          --> 
     420           <?php } ?> 
    385421        </div> 
    386422        <?php endif; ?> 
    387         <?php } ?> 
     423        
    388424      </div> 
    389425 
     
    439475            data: formdata, 
    440476            beforeSend: function () { 
    441                             $('#edit_buttons').append('<img src="' + BASEURL + "content/admin_themes/" + ADMIN_THEME + 'images/ajax-loader.gif' + '"/>');                            
     477                            $('#error_message').html('<img src="' + BASEURL + "content/admin_themes/" + ADMIN_THEME + 'images/ajax-loader.gif' + '"/>'); 
    442478                    }, 
    443479            error:      function(XMLHttpRequest, textStatus, errorThrown) { 
    444                             //widget.html('ERROR'); 
     480                             $('#error_message').html('There was an error with the data'); 
    445481            }, 
    446482            success: function(data, textStatus) { // success means it returned some form of json code to us. may be code with custom error msg 
    447                     if (data.error === true) { 
     483                    $error_message = ""; 
     484                    if (data.errors > 0) { 
     485                         $error_mesage = 'There are a total of ' + data.errors + " problems to fix<br/>"; 
     486                         if (data.basic.length > 0) { $error_message += 'Basic: ' + data.basic + "<br/>";  } 
     487                         if (data.feeds.length > 0) { $error_message += 'Feeds ' + data.feeds + "<br/>";  } 
     488                         if (data.categories.length >0) { $error_message += 'Categories: ' + data.categories + "<br/>";  } 
     489                         if (data.rewrite.length > 0) { $error_message += 'Rewrite ' + data.rewrite + "<br/>";  } 
     490                         if (data.options.length > 0) { $error_message += 'Options: ' + data.options + "<br/>";  } 
    448491                    } 
    449492                    else 
     
    453496                        if(data.enabled == 'true') { img_src = "active.png"; } else { img_src = "inactive.png"; } 
    454497                        $('#edit_buttons').html('<img src="' + BASEURL + "content/admin_themes/" + ADMIN_THEME + 'images/' + img_src + '"/>'); 
     498                        $error_message += "Your changes have been saved." 
    455499                    } 
     500                    $('#error_message').html($error_message); 
    456501                    //$('#return_message').html(data.message).addClass(data.color); 
    457502                    //$('#return_message').html(data.message).addClass('message'); 
     
    516561          };          
    517562          feed.addClass('load input_text'); 
    518                 }; 
    519  
     563    }; 
     564 
     565    $('#tool_removeall').click(function(){ 
     566            event.preventDefault(); 
     567            var answer = confirm('You are about to delete all the posts for this campaign from the database. This action can not be reversed. Delete ? '+jQuery(this).attr('title')); 
     568            if (answer) { 
     569                var campaign_id = ('#campaign_edit').val(); 
     570                alert(campaign_id); 
     571                var formdata = 'action=tools_delete&id=' + campaign_id; 
     572                var sendurl = BASEURL + 'admin_index.php?page=plugin_settings&plugin=autoreader&alt_template=autoreader_add'; 
     573 
     574                 $.ajax( 
     575                    { 
     576                    type: 'post', 
     577                    url: sendurl, 
     578                    data: formdata, 
     579                    error:      function(XMLHttpRequest, textStatus, errorThrown) { 
     580                                    $('#error_message').html('There was an error with the data'); 
     581                    }, 
     582                    success: function(data, textStatus) { // success means it returned some form of json code to us. may be code with custom error msg 
     583                            if (data.error === true) { 
     584                            } 
     585                            else 
     586                            { 
     587                                $('#error_message').html('___ records were deleted'); 
     588                            } 
     589                    }, 
     590                    dataType: "json" 
     591                }); 
     592            } 
     593            return false; 
     594    }); 
    520595 
    521596    function update_feeds() {           
  • branches/1.2/content/plugins/autoreader/templates/autoreader_dashboard.php

    r1334 r1363  
    7676          <li> 
    7777            <span class="details"><?php echo WPOTools::timezoneMysql('F j, g:i a', $campaign->lastactive) ?></span> 
    78             <a href="<?php echo $this->adminurl ?>&amp;s=list&amp;id=<?php echo $campaign->id ?>"><?php echo $campaign->title ?></a></li> 
     78            <a href="/admin_index.php?page=plugin_settings&plugin=autoreader"><?php echo $campaign->title ?></a></li> 
    7979          <?php endforeach; ?> 
    8080        </ol> 
     
    8989        <li> 
    9090          <span class="details"><?php echo $campaign->count ?></span> 
    91           <a href="<?php echo $this->adminurl ?>&amp;s=list&amp;id=<?php echo $campaign->id ?>"><?php echo $campaign->title ?></a></li> 
     91          <a href="/admin_index.php?page=plugin_settings&plugin=autoreader"><?php echo $campaign->title ?></a></li> 
    9292        <?php endforeach; ?> 
    9393      </ol> 
  • branches/1.2/content/plugins/autoreader/templates/autoreader_options.php

    r1334 r1363  
    1010            echo json_encode($autoreader_settings); 
    1111            exit; 
    12      default : 
    13          $autoreader_settings = $arSettings->getOptionSettings($h); 
     12        case "flush": 
     13            $hook = "autoreader_runcron";             
     14            $cron_data = array('hook'=>$hook); 
     15            $h->pluginHook('cron_flush_hook', 'cron', $cron_data); 
     16            exit; 
     17        default : 
     18            $autoreader_settings = $arSettings->getOptionSettings($h); 
    1419 
    1520    } 
     
    4752           <?php } ?> 
    4853 
    49           <p class="note"><?php echo 'Cron is set up to handle fetching.'; ?> <?php if ($autoreader_settings['wpo_help']) { ?><a href="<?php echo $arSettings->helpurl ?>cron" class="help_link"><?php echo 'More'; ?></a><?php } ?></p> 
     54          <p class="note"><?php echo 'Cron is set up to handle fetching if you are familiar with manually setting cron jobs on your server.'; ?> <?php if ($autoreader_settings['wpo_help']) { ?><a href="<?php echo $arSettings->helpurl ?>cron" class="help_link"><?php echo 'More'; ?></a><?php } ?></p> 
     55          <p class="note">For those not familiar with cron jobs or for shared servers where you cannot access them, you may install the "cron" plugin for hotaru which emulates the function of server cron jobs. This is recommended for most users.</p> 
    5056        </li> 
    5157 
     
    6470              <p class="note"><?php echo 'With this option enabled, Autoreader will attempt to show you logs creation in real time when manual fetching is used.'; ?> <a href="<?php echo $this->helpurl ?>logging" class="help_link"><?php echo 'More'; ?></a></p> 
    6571            </li> 
    66  
     72        <?php } ?> 
     73             
    6774            <li> 
    6875              <?php echo label_for('option_caching','Cache images') ?> 
    69               <?php echo checkbox_tag('option_caching', 1,$autoreader_settings['wpo_cacheimage']) ?> 
     76              <?php echo checkbox_tag('option_caching', 1,$autoreader_settings['wpo_cacheimages']) ?> 
    7077 
    71               <p class="note"><?php echo 'This option overrides all campaign-specific settings'; ?> <a href="<?php echo $this->helpurl ?>image_caching" class="help_link"><?php echo 'More'; ?></a></p> 
     78              <p class="note"><?php echo 'This option overrides any campaign specific image settings'; ?> <?php if ($autoreader_settings['wpo_premium']) { ?><a href="<?php echo $this->helpurl ?>image_caching" class="help_link"><?php echo 'More'; ?></a><?php } ?></p> 
    7279            </li> 
    7380 
     
    7683              <?php echo input_tag('option_cachepath', $autoreader_settings['wpo_cachepath']) ?> 
    7784 
    78               <p class="note"><?php echo 'The path <span id="cachepath">'. PLUGINS . 'Autoreader/<span id="cachepath_input">' . $autoreader_settings['wpo_cachepath'] . '</span></span> must exist, be writable by the server and accessible through browser.'; ?></p> 
     85              <p class="note"><?php echo 'The path <span id="cachepath">'. PLUGINS . 'autoreader/<span id="cachepath_input">' . $autoreader_settings['wpo_cachepath'] . '</span></span> must exist, be writable by the server and accessible through browser.'; ?></p> 
    7986            </li> 
    80         <?php } ?> 
     87        
     88 
     89            <li> 
     90                <a href='#' id="flush_cron">Clear</a> all cron jobs listed for "autoreader" in the hotaru "cron" plugin.<div id ="flush_cron_message"></div> 
     91            </li> 
     92 
     93 
    8194      </ul> 
    8295 
     
    89102<script type='text/javascript'> 
    90103    jQuery('document').ready(function($) { 
     104 
     105        $("#flush_cron").click(function() {  
     106         var answer = confirm('Are you sure you want to remove all current cron jobs for autoreader from cron plugin? Existing posts submitted will not be lost and campaign data will not be altered.'); 
     107            if (answer) { 
     108                var formdata = 'action=flush'; 
     109                var sendurl = BASEURL + 'admin_index.php?page=plugin_settings&plugin=autoreader&alt_template=autoreader_options'; 
     110 
     111            $.ajax( 
     112                { 
     113                type: 'post', 
     114                url: sendurl, 
     115                data: formdata, 
     116                beforeSend: function () { 
     117                                $('#flush_cron_message').html('<img src="' + BASEURL + "content/admin_themes/" + ADMIN_THEME + 'images/ajax-loader.gif' + '"/>'); 
     118                        }, 
     119                error:  function(XMLHttpRequest, textStatus, errorThrown) { 
     120                                $('#flush_cron_message').html('An error occured.'); 
     121                }, 
     122                success: function(data, textStatus) { // success means it returned some form of json code to us. may be code with custom error msg 
     123                        if (data.error === true) { 
     124                        } 
     125                        else 
     126                        { 
     127                            $('#flush_cron_message').html(data.count + ' jobs flushed from the cron.'); 
     128                        } 
     129                }, 
     130                dataType: "json" 
     131            }); 
     132        } 
     133        return false; 
     134       }); 
     135        
    91136 
    92137        $("#edit_submit").click(function(event) { 
Note: See TracChangeset for help on using the changeset viewer.