function civicrm_cron_admin_settings in CiviCRM Cron 7
Same name and namespace in other branches
- 6 civicrm_cron.module \civicrm_cron_admin_settings()
- 7.2 civicrm_cron.module \civicrm_cron_admin_settings()
Builds the civicrm_cron admininstration settings form.
1 string reference to 'civicrm_cron_admin_settings'
- civicrm_cron_menu in ./
civicrm_cron.module - Implementation of hook_menu().
File
- ./
civicrm_cron.module, line 28 - CiviCRM Cron Module
Code
function civicrm_cron_admin_settings($form, &$form_state) {
$form = array();
if (!civicrm_initialize()) {
drupal_set_message(t('Failed to initialize CiviCRM'));
return;
}
$cron_values['name'] = variable_get('civicrm_cron_username', NULL);
$cron_values['pass'] = variable_get('civicrm_cron_password', NULL);
$cron_values['key'] = variable_get('civicrm_cron_sitekey', CIVICRM_SITE_KEY);
$url = civicrm_cron_get_url($cron_values);
if ($url) {
$result = drupal_http_request($url);
//look for the CiviCRM error in response... successful processing returns nothing
if ($result->data) {
drupal_set_message('Attempted to use the following URL to process CiviCRM\'s cron: ' . $url . ' <br /> CiviCRM Error: ' . $result->data, 'warning');
}
else {
drupal_set_message(t('CiviCRM Cron Successfully Run'));
}
}
//http://wiki.civicrm.org/confluence/display/CRMDOC41/Command-line+Script+Configuration
$form['civicrm_cron_username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => $cron_values['name'],
'#description' => t('CiviCRM runs cron as a specific user. This user should have MINIMAL permissions since the password will be saved in the database and seen in the logs.'),
);
$form['civicrm_cron_password'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#default_value' => $cron_values['pass'],
'#description' => t('The password for user defined above.'),
);
$form['civicrm_cron_sitekey'] = array(
'#type' => 'textfield',
'#title' => t('Sitekey'),
'#default_value' => $cron_values['key'],
'#description' => t('Must match the sitekey found in the civicrm-settings.php file.'),
);
return system_settings_form($form);
}