'link_codes', 'title' => t('Link codes'), 'enabled' => TRUE, 'weight' => 0 ); return $info; } /** * Implementation of hook_share_tab(). */ function link_codes_share_tab($op, $args, $node = NULL) { switch ($op) { case 'load': if ($codes = db_result(db_query("SELECT codes FROM {share_link_codes} WHERE `share_id` = %d", $args->share_id))) { $codes = unserialize($codes); return array('codes' => $codes); } break; case 'settings': $defaults = ($args->codes) ? array_values($args->codes) : array('direct', 'html'); $form['link_codes_type'] = array( '#type' => 'checkboxes', '#title' => t('Types'), '#description' => t('Provide generated link code(s) that point to the node.'), '#default_value' => array_filter($defaults, 'share_array_values'), '#options' => array('direct' => t('Direct URL'), 'html' => t('HTML code'), 'forum' => t('Forum code')) ); return $form; case 'validate': $codes = array_filter($args['link_codes_type'], 'share_array_values'); if (empty($codes)) { form_set_error('link_codes_type', t('At least one link code type has to be enabled.')); } break; case 'insert': db_query("INSERT INTO {share_link_codes} (`share_id`, `codes`) VALUES (%d, '%s')", $args['share_id'], serialize($args['link_codes_type'])); break; case 'update': db_query("UPDATE {share_link_codes} SET `codes` = '%s' WHERE `share_id` = %d", serialize($args['link_codes_type']), $args['share_id']); break; case 'process': $output = ''; foreach ($args->codes as $code) { if ($code) { $output.= link_codes_generate($code, $node); } } return $output; } } /******************************************************************************* * Callback Functions, Forms, and Tables ******************************************************************************/ function link_codes_generate($op, $node) { $alias = drupal_get_path_alias('node/'.$node->nid); switch ($op) { case "direct": return '
'; case "html": return ''; case "forum": return ''; } } /******************************************************************************* * Module and Helper Functions ******************************************************************************/