'hidden', '#value' => $is_subscribed, ); $form['nid'] = array( '#type' => 'hidden', '#value' => $nid, ); $form['taxonomy']['tags'][_issue_tracker_get_issue_vocabulary_id()] = array( '#type' => 'hidden', '#value' => $tags, ); $form['subscribe'] = array( '#type' => 'submit', '#value' => $is_subscribed ? t('Unsubscribe this issue') : t('Subscribe this issue'), '#prefix' => '
', ); return $form; } /** * Subscription form submit handling */ function issue_subscription_form_submit($form, &$form_state) { global $user; $is_subscribed = $form_state['values']['subscribed']; $node = node_load($form_state['values']['nid']); $issue_id = _issue_id_from_nid($node->nid); if (isset($user->uid) && $user->uid > 0) { $vid = _issue_tracker_get_issue_vocabulary_id(); if ($is_subscribed) { //remove the subscription tag for the logged in user $tags = taxonomy_node_get_terms_by_vocabulary($node, $vid, 'name'); unset($tags['subscribed::'. $user->name]);; $terms['tags'][$vid] = taxonomy_implode_tags($tags); taxonomy_node_save($node, $terms); $result = origo_auth_xmlrpc_session(variable_get('origo_api_internal', ''), 'internal_issue.remove_subscription', (int)variable_get('origo_project_id', 0), (int)$issue_id); } else { $tags = taxonomy_node_get_terms($node); $terms['tags'][$vid] = 'subscribed::'. $user->name; foreach ($tags as $tag) { $terms['tags'][$vid] .= ', '. $tag->name; } taxonomy_node_save($node, $terms); $result = origo_auth_xmlrpc_session(variable_get('origo_api_internal', ''), 'internal_issue.add_subscription', (int)variable_get('origo_project_id', 0), (int)$issue_id); } } }