You are here

function uc_dropdown_attributes_activate in Dropdown Attributes 6

Retrieves the attribute dependencies.

1 string reference to 'uc_dropdown_attributes_activate'
uc_dropdown_attributes_menu in ./uc_dropdown_attributes.module
Implement hook_menu().

File

./uc_dropdown_attributes.module, line 203
Show/hide attributes based on the values of other attributes.

Code

function uc_dropdown_attributes_activate($nid, $aid) {
  $response = new stdClass();
  $response->aid = array();
  $response->parent_aid = $aid;
  $response->nid = $nid;
  $query = 'SELECT aid FROM {uc_dropdown_attributes}
    WHERE nid=%d && parent_aid=%d';
  $result = db_query($query, $nid, $aid);
  while ($item = db_fetch_object($result)) {
    $response->aid[] = $item->aid;
  }
  if (count($response->aid) > 0) {
    $response->status = TRUE;
    drupal_json($response);
    return;
  }
  $pcid = uc_dropdown_attributes_get_type($nid);
  $query = 'SELECT aid FROM {uc_dropdown_classes}
    WHERE pcid=%d && parent_aid=%d';
  $result = db_query($query, $pcid, $aid);
  while ($item = db_fetch_object($result)) {
    $response->aid[] = $item->aid;
  }
  if (count($response->aid) > 0) {
    $response->status = TRUE;
    drupal_json($response);
    return;
  }
  $response->status = FALSE;
  drupal_json($response);
}