You are here

function _votingapi_insert_set in Voting API 5

2 calls to _votingapi_insert_set()
votingapi_actions_admin_import_page_submit in ./votingapi_actions_ui.inc
_votingapi_update_set in ./votingapi_actions.module

File

./votingapi_actions.module, line 269

Code

function _votingapi_insert_set($set) {
  $vasid = db_next_id("{votingapi_action_set}_vasid");
  $sql = "INSERT INTO {votingapi_action_set} ";
  $sql .= "(vasid, name, parent, content_type, source, description, condition_mask, required, weight)";
  $sql .= "VALUES (%d, '%s', %d, '%s', '%s', '%s', '%s', %d, %d)";
  db_query($sql, $vasid, $set['name'], $set['parent'], $set['content_type'], $set['source'], $set['description'], $set['condition_mask'], $set['required'], $set['weight']);
  if (is_array($set['conditions'])) {
    foreach ($set['conditions'] as $condition) {
      $condition['vasid'] = $vasid;
      _votingapi_insert_condition($condition);
    }
  }
  if (is_array($set['actions'])) {
    foreach ($set['actions'] as $action) {
      db_query("INSERT INTO {votingapi_action} (vasid, aid) VALUES (%d, '%s')", $vasid, $action);
    }
  }
  if (is_array($set['sets'])) {
    foreach ($set['sets'] as $sname => $subset) {
      $subset['parent_name'] = $name;
      _votingapi_insert_set($sname, $subset);
    }
  }
}