function _salesforce_cron_run in Salesforce Suite 5
run a logged cron item
2 calls to _salesforce_cron_run()
- salesforce_cron in ./
salesforce.module - Implementation of hook_cron().
- salesforce_log_run_page in ./
salesforce.module - run a logged cron task
File
- ./
salesforce.module, line 474 - Original Creator, Maintainer & Developer: Steve McKenzie (http://drupal.org/user/45890) Drupal and Salesforce.com (mainly only working with contacts / leads but can be extended to do anything the salesforce API version 6 can do) Current…
Code
function _salesforce_cron_run($row) {
if (is_numeric($row)) {
$result = db_query("SELECT sid, type, type_id, message, timestamp, status, data FROM {salesforce_log} WHERE status = 1 AND sid = %d ORDER BY timestamp DESC", $row);
if (db_num_rows($result) > 0) {
$row = db_fetch_object($result);
}
else {
return false;
}
unset($result);
}
switch ($row->type) {
case 'lead_insert':
case 'lead_update':
$result = salesforce_lead(str_replace('lead_', '', $row->type), user_load(array(
'uid' => $row->type_id,
)));
break;
case 'contact_insert':
case 'contact_update':
$result = salesforce_contact(str_replace('contact_', '', $row->type), user_load(array(
'uid' => $row->type_id,
)));
break;
case 'event_insert':
// TODO: why do i have to do this? why doesn't it like the object?
$event = (array) unserialize($row->data);
$result = salesforce_event('insert', $event['values']['Subject'], $event['values']['Description'], user_load(array(
'uid' => $row->type_id,
)));
break;
default:
$result = array(
'error' => 'NO_METHOD_PROVIDED',
);
break;
}
// remove it from the cron runs if it went through
if (!$result['error'] || $result['error'] == 'NO_METHOD_PROVIDED') {
_salesforce_log_manage($row->sid);
watchdog('salesforce', t('removed log entry %sid', array(
'%sid' => l($row->sid, 'admin/salesforce'),
)));
if ($result['error'] == 'NO_METHOD_PROVIDED') {
db_query("UPDATE {salesforce_logs} l SET l.message = l.message + ' - (%s)' WHERE sid = %d", $result['error'], $row->sid);
if (user_access('administer salesforce')) {
drupal_set_message(t('the logged task with the message "%message" was disabled because it has no methods provided in the module. Please post this issue as a bug.', array(
'%message' => $row->message,
)));
}
}
return true;
}
}