You are here

function _votingapi_update_set in Voting API 5

File

./votingapi_actions.module, line 313

Code

function _votingapi_update_set($set) {
  $sql = "UPDATE {votingapi_action_set} SET ";
  $sql .= "name = '%s', parent = %d, content_type = '%s', source = '%s', description = '%s', condition_mask = '%s', ";
  $sql .= "required = %d, weight = %d ";
  $sql .= "WHERE vasid = %d";
  db_query($sql, $set['name'], $set['parent'], $set['content_type'], $set['source'], $set['description'], $set['condition_mask'], $set['required'], $set['weight'], $set['vasid']);
  if (is_array($set['conditions'])) {
    foreach ($set['conditions'] as $condition) {
      if (isset($condition['vacid'])) {
        _votingapi_update_condition($condition);
      }
      else {
        _votingapi_insert_condition($condition);
      }
    }
  }
  db_query("DELETE FROM {votingapi_action} WHERE vasid = %d", $set['vasid']);
  if (is_array($set['actions'])) {
    foreach ($set['actions'] as $action) {
      db_query("INSERT INTO {votingapi_action} (parent_name, aid) VALUES ('%s', %d)", $name, $set['vasid']);
    }
  }
  if (is_array($set['sets'])) {
    foreach ($set['sets'] as $subset) {
      if (isset($subset['vasid'])) {
        _votingapi_update_set($subset);
      }
      else {
        _votingapi_insert_set($subset);
      }
    }
  }
  if (is_array($set['deleted_sets'])) {
    foreach ($set['deleted_sets'] as $subset) {
      _votingapi_delete_set($subset);
    }
  }
}