public function settingsAction() { // Get navigation $this->view->navigation = $this->getNavigation(); // Make form $this->view->form = $form = new Core_Form_Admin_Tasks_Settings(); // Get settings $current = Engine_Api::_()->getApi('settings', 'core')->core_tasks; // Don't allow cron mode on windows if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $form->addError('Cronjob triggering of tasks is not currently supported on Windows.'); if ($current['mode'] == 'cron') { if (extension_loaded('curl')) { Engine_Api::_()->getApi('settings', 'core')->core_tasks_mode = $current['mode'] = 'curl'; } else { Engine_Api::_()->getApi('settings', 'core')->core_tasks_mode = $current['mode'] = 'socket'; } } } // Make sure it's not set to curl if they don't have it if (!extension_loaded('curl') && $current['mode'] == 'curl') { Engine_Api::_()->getApi('settings', 'core')->core_tasks_mode = $current['mode'] = 'socket'; } // Populate form $form->populate($current); /* // Add description $form->getElement('mode') ->setDescription('test') ->getDecorator('Description') ->setOption('placement', 'append') ; * */ if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) { $values = $form->getValues(); if ($values['mode'] == 'cron') { $values['pid'] = ''; } Engine_Api::_()->getApi('settings', 'core')->core_tasks = $values; $current = array_merge($current, $values); } if ($current['mode'] == 'cron') { $minutes = ceil($current['interval'] / 60); $executeUrl = (_ENGINE_SSL ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $this->view->url(array('controller' => 'utility', 'action' => 'tasks'), 'default', true) . '?' . http_build_query(array('key' => $current['key'])); $logFile = APPLICATION_PATH . '/temporary/log/tasks.log'; $commandTemplate = 'echo Cron Execute Result: $(wget -O - %1$s) >> %2$s 2>&1'; $command = sprintf($commandTemplate, $executeUrl, $logFile); $form->getDecorator('Description')->setOption('escape', false); $form->addNotice($this->view->translate(array('Please set the following command to run in crontab about every %1$s minute: <br />"%2$s"', 'Please set the following command to run in crontab about every %1$s minutes: <br />"%2$s"', $minutes), $minutes, $command)); } }