function subscriptions_taxa_form_submit in Subscriptions 5
File
- ./
subscriptions.module, line 1248
Code
function subscriptions_taxa_form_submit($form_id, $form_values) {
$orgstate = unserialize($form_values['orgstate']);
foreach ($form_values as $n => $v) {
if (substr($n, 0, 4) == 'subs') {
$taxid = substr($n, 4);
// parse taxid out of sub name
foreach ($orgstate as $orgsub) {
// if tid matched, and submitted value is different from original value
if ($taxid == $orgsub[0] && $v != $orgsub[3]) {
if ($v == 0) {
// if unchecked
db_query('DELETE FROM {subscriptions} WHERE sid = %d AND uid = %d AND stype = \'%s\'', $taxid, $orgsub[1], 'taxa');
drupal_set_message(t('Your subscription was deactivated.'));
}
else {
// if checked
$strqry = 'INSERT INTO {subscriptions} ( sid, uid , stype ) VALUES (\'%d\', \'%d\', \'%s\')';
db_query($strqry, $taxid, $orgsub[1], 'taxa');
drupal_set_message(t('Your subscription was activated.'));
}
}
}
}
}
}