Ignore:
Timestamp:
03/19/10 04:09:05 (3 years ago)
Author:
shibuya246
Message:

[branch 1.2] fix for update cron hook, included install default cron jobs, after checking for admin_settings

File:
1 edited

Legend:

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

    r1339 r1351  
    4444        $hook = "cron_hotaru_version"; 
    4545        $this->cron_schedule_event($h, $timestamp, $recurrence, $hook); 
     46 
     47        if (SYS_FEEDBACK == 'true') { 
     48            $hook = "cron_hotaru_feedback"; 
     49            $this->cron_schedule_event($h, $timestamp, $recurrence, $hook); 
     50        } 
    4651    }   
    4752 
     
    377382    } 
    378383 
     384    public function cron_hotaru_feedback($h) { 
     385        $query_vals = array( 
     386            'api_key' => '', 
     387            'format' => 'json', 
     388            'method' => 'hotaru.systemFeedback.add', 
     389            'version' => $h->version 
     390        ); 
     391 
     392       $info = $this->sendApiRequest($h, $query_vals); 
     393         
     394    } 
     395 
    379396    public function cron_hotaru_version($h) { 
    380397        $query_vals = array( 
     
    384401        ); 
    385402 
     403         $info = $this->sendApiRequest($h, $query_vals); 
     404        
     405        // save the updated version number to the local db so we can display it on the admin panel until it gets updated.         
     406         if (isset($info['version'])) 
     407             $h->updateSetting('hotaru_latest_version', serialize($info), 'cron'); 
     408    } 
     409 
     410    public function sendApiRequest($h, $query_vals) { 
     411 
    386412        // Generate the POST string 
    387413        $ret = ''; 
     
    398424        $response = curl_exec($ch); 
    399425        curl_close ($ch); 
    400         
    401         $info = json_decode($response, true); 
    402         
    403         // save the updated version number to the local db so we can display it on the admin panel until it gets updated.         
    404          if (isset($info['version'])) 
    405              $h->updateSetting('hotaru_latest_version', serialize($info), 'cron'); 
    406     } 
     426 
     427       return json_decode($response, true); 
     428    } 
     429 
    407430 
    408431    public function checkrunCron($h) { 
     
    444467    { 
    445468        $h->vars['cron_settings'] = $h->getSerializedSettings(); 
    446  
    447         $timestamp = $cron_data['timestamp']; 
    448         $recurrence = $cron_data['recurrence']; 
    449         $hook = $cron_data['hook']; 
    450         $args = $cron_data['args']; 
    451         $id = $cron_data['args']['id']; 
     469         
     470        $timestamp = (isset($cron_data['timestamp'])) ? $cron_data['timestamp'] : array(); 
     471        $recurrence = (isset($cron_data['recurrence'])) ? $cron_data['recurrence'] : array(); 
     472        $hook = (isset($cron_data['hook'])) ? $cron_data['hook'] : array(); 
     473        $args = (isset($cron_data['args'])) ? $cron_data['args'] : array(); 
    452474        $cron_exists = false; 
    453475 
    454          // check whether already have existing event for this job 
     476        // check whether already have existing event for this job 
    455477        //  match against hook and args. note args must match 
    456478        $current_crons = $this->_get_cron_array($h); 
    457479        foreach ($current_crons as $current_timestamp => $current_cronhooks) { 
    458480          foreach ($current_cronhooks as $current_hook => $current_keys) { 
    459             if ($current_hook == $hook && $current_keys = $args) { 
     481             if ($current_hook == $hook) { 
     482               foreach ($current_keys as $current_md5 => $current_job) { 
     483              //print_r( $current_job["args"]); print "   **    "; print_r($args); 
     484            if ($current_job["args"] == $args) { 
    460485                $this->cron_schedule_event($h, $timestamp, $recurrence, $hook, $args); 
    461486                $this->cron_unschedule_event($h, $current_timestamp, $current_hook, $args); 
    462487                $cron_exists = true; 
    463             } 
     488            }}} 
    464489          } 
    465490        } 
     
    471496    {         
    472497        //load current cron jobs from memory space 
    473         $h->vars['cron_settings'] = $h->getSerializedSettings(); 
    474          
    475         $hook = $cron_data['hook']; 
    476         $args = $cron_data['args']; 
     498        $h->vars['cron_settings'] = $h->getSerializedSettings();         
     499        
     500        $hook = (isset($cron_data['hook'])) ? $cron_data['hook'] : array(); 
     501        $args = (isset($cron_data['args'])) ? $cron_data['args'] : array(); 
    477502 
    478503        $current_crons = $this->_get_cron_array($h); 
     
    495520        $h->vars['cron_settings'] = $h->getSerializedSettings(); 
    496521 
    497         $hook = $cron_data['hook']; 
     522        $hook = (isset($cron_data['hook'])) ? $cron_data['hook'] : array(); 
    498523        $flush_count = 0; 
    499524 
Note: See TracChangeset for help on using the changeset viewer.