protected function execute($arguments = array(), $options = array())
 {
     new sfDatabaseManager($this->configuration);
     if (!opConfig::get('op_calendar_google_data_api_auto_update', false)) {
         throw new sfException('This task is not allowed. Please allow from "pc_backend.php/opCalendarPlugin" setting.');
     }
     $crons = opCalendarPluginToolkit::getAllGoogleCalendarCronConfig();
     if (!count($crons)) {
         $this->logSection('end', 'No cron data');
         return true;
     }
     $this->opCalendarOAuth = opCalendarOAuth::getInstance();
     $this->logSection('prepared', 'start update');
     foreach ($crons as $cron) {
         $this->updateMemberSchedule($cron, (int) $options['interval']);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     sfContext::createInstance($this->createConfiguration($options['application'], $options['env']), $options['application']);
     if (!Doctrine_Core::getTable('SnsConfig')->get('op_calendar_google_data_api_auto_update', false)) {
         throw new sfException("This task is not allowed. \nPlease allow from 'pc_backend.php/opCalendarPlugin' setting.");
     }
     $crons = opCalendarPluginToolkit::getAllGoogleCalendarCronConfig();
     if (!count($crons)) {
         $this->logSection('end', 'No cron data');
         exit;
     }
     $this->consumer = new OAuthConsumer(opConfig::get('op_calendar_google_data_api_key', 'anonymous'), opConfig::get('op_calendar_google_data_api_secret', 'anonymous'));
     $this->logSection('prepared', 'start update');
     foreach ($crons as $cron) {
         $member = Doctrine_Core::getTable('Member')->find($cron['member_id']);
         if (!$member) {
             continue;
         }
         $cron_config = unserialize($cron['serial']);
         foreach ($cron_config['src'] as $src) {
             $this->logSection('start', 'update member_id: ' . $cron['member_id'] . "\nscope: " . $src);
             $result = $this->getContents($src, $cron);
             if (!$result) {
                 continue;
             }
             if (opCalendarPluginToolkit::insertSchedules($result->toArray(), $cron_config['public_flag'], true, $member)) {
                 $this->logSection('end', 'updated success member_id: ' . $cron['member_id'] . "\nscope: " . $src);
             } else {
                 $this->logSection('end', 'updated failed member_id: ' . $cron['member_id'] . "\nscope: " . $src);
             }
             if ($options['interval']) {
                 $this->logSection('sleep', 'set interval: ' . $options['interval'] . ' second');
                 sleep((int) $options['interval']);
             }
         }
     }
 }