Example #1
0
 /**
  * Control settings for the updater
  *
  * This method controls the update interval setting for the application.
  */
 public function actionUpdaterSettings()
 {
     $admin =& Yii::app()->settings;
     // Save new updater cron settings in crontab
     $cf = new CronForm();
     $cf->jobs = array('app_update' => array('cmd' => Yii::app()->basePath . DIRECTORY_SEPARATOR . 'yiic update app --lock=1 &>/dev/null', 'desc' => Yii::t('admin', 'Automatic software updates cron job')));
     if (isset($_POST['Admin'])) {
         $admin->setAttributes($_POST['Admin']);
         foreach (array('unique_id', 'edition') as $var) {
             if (isset($_POST['unique_id'])) {
                 $admin->{$var} = $_POST[$var];
             }
         }
         if ($admin->save()) {
             if (isset($_POST['cron'])) {
                 // Save new updater cron settings in crontab
                 $cf->save($_POST);
             } else {
                 // Delete remaining jobs
                 $cf->save(array());
             }
             $this->redirect('updaterSettings');
         }
     }
     foreach ($cf->jobs as $tag => $attributes) {
         $commands[$tag] = $attributes['cmd'];
     }
     if (isset($_POST['cron'])) {
         // Save new updater cron settings in crontab
         $cf->save($_POST);
     }
     $this->render('updaterSettings', array('model' => $admin, 'displayCmds' => $commands));
 }