You are here

function sms_actions_command_save in SMS Framework 7

Same name and namespace in other branches
  1. 6.2 modules/sms_actions/sms_actions.module \sms_actions_command_save()
  2. 6 modules/sms_actions/sms_actions.module \sms_actions_command_save()

Saves a command.

3 calls to sms_actions_command_save()
SmsActionWebTest::testSmsActionsActionsIntegration in modules/sms_actions/sms_actions.test
Tests integration with the actions module.
SmsActionWebTest::testSmsActionsTriggersIntegration in modules/sms_actions/sms_actions.test
Tests integration with the trigger module.
sms_actions_edit_command_form_submit in modules/sms_actions/sms_actions.module
Submit handler for sms_actions_edit_command_form().

File

modules/sms_actions/sms_actions.module, line 363
Provides a "Send SMS" action and the ability to define custom triggers for incoming messages.

Code

function sms_actions_command_save($command) {
  $commands = sms_actions_get_commands();
  $existing_discriminator = !empty($command->old_discriminator) ? $command->old_discriminator : $command->discriminator;
  if (array_key_exists($existing_discriminator, $commands)) {
    db_query("UPDATE {trigger_assignments} SET hook = '%s' WHERE hook = '%s'", array(
      'sms_actions_' . $command->discriminator,
      'sms_actions_' . $existing_discriminator,
    ));
  }
  unset($commands[$existing_discriminator]);
  $commands[$command->discriminator] = $command;
  variable_set('sms_actions_commands', $commands);
}