| 9 |
* brashquido (http://drupal.org/user/49838) |
* brashquido (http://drupal.org/user/49838) |
| 10 |
* by AjK (http://drupal.org/user/39030) |
* by AjK (http://drupal.org/user/39030) |
| 11 |
* June 2006 |
* June 2006 |
| 12 |
|
* |
| 13 |
|
* v6.x-dev written by matt_b |
| 14 |
*/ |
*/ |
| 15 |
|
|
| 16 |
if(!defined("_AUTHORSHIP_DEBUG")) { |
if(!defined("_AUTHORSHIP_DEBUG")) { |
| 21 |
/** |
/** |
| 22 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 23 |
*/ |
*/ |
| 24 |
function authorship_help($section) { |
function authorship_help($path, $arg) { |
| 25 |
switch ($section) { |
switch ($path) { |
| 26 |
case 'admin/modules#description': |
case 'admin/modules#description': |
| 27 |
return t('Node authorship extention module.'); |
return t('Node authorship extention module.'); |
| 28 |
} |
} |
| 45 |
/** |
/** |
| 46 |
* Implementation of hook_form_alter() |
* Implementation of hook_form_alter() |
| 47 |
*/ |
*/ |
| 48 |
function authorship_form_alter($form_id, &$form) { |
function authorship_form_alter(&$form, &$form_state, $form_id) { |
| 49 |
global $user; |
global $user; |
| 50 |
|
|
| 51 |
_authorship_debug("authorship_form_alter(" . $form['#node']->nid . ")"); |
_authorship_debug("authorship_form_alter(" . $form['#node']->nid . ")"); |
| 80 |
'#title' => t('Authorship display setting'), |
'#title' => t('Authorship display setting'), |
| 81 |
'#default_value' => $form['#node']->authorship, |
'#default_value' => $form['#node']->authorship, |
| 82 |
'#weight' => 9, |
'#weight' => 9, |
| 83 |
'#description' => t('The name to display as the submitter. '. |
'#description' => t('The name to display as the author. '. |
| 84 |
'Leave blank for normal operation') |
'Leave blank for normal operation') |
| 85 |
); |
); |
| 86 |
} |
} |
| 104 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 105 |
'#title' => t('Authorship display setting'), |
'#title' => t('Authorship display setting'), |
| 106 |
'#default_value' => $authorship, |
'#default_value' => $authorship, |
| 107 |
'#description' => t('The name to display as the submitter. '. |
'#description' => t('The name to display as the author. '. |
| 108 |
'Leave blank for normal operation') |
'Leave blank for normal operation') |
| 109 |
); |
); |
| 110 |
} |
} |
| 167 |
case 'update index': |
case 'update index': |
| 168 |
return db_result(db_query("SELECT authorship FROM {node_authorship} WHERE nid = %d", $node->nid)); |
return db_result(db_query("SELECT authorship FROM {node_authorship} WHERE nid = %d", $node->nid)); |
| 169 |
break; |
break; |
| 170 |
|
case 'search result': |
| 171 |
|
if ($node->authorship) return array('user' => $node->authorship); |
| 172 |
|
break; |
| 173 |
|
|
| 174 |
} // end switch |
} // end switch |
| 175 |
} |
} |
| 212 |
} |
} |
| 213 |
/* }}} */ |
/* }}} */ |
| 214 |
|
|
| 215 |
|
/** |
| 216 |
|
* Implement hook_views_api(). |
| 217 |
|
*/ |
| 218 |
|
function authorship_views_api() { |
| 219 |
|
return array( |
| 220 |
|
'api' => 2.0, |
| 221 |
|
); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
/*=========================*/ |
/*=========================*/ |
| 225 |
/* Helper functions follow */ |
/* Helper functions follow */ |
| 226 |
/*=========================*/ |
/*=========================*/ |
| 268 |
} |
} |
| 269 |
/* }}} */ |
/* }}} */ |
| 270 |
|
|
|
/** |
|
|
* Implementation of hook_views_tables() |
|
|
* (see Views module) |
|
|
*/ |
|
|
function authorship_views_tables() { |
|
|
$tables['node_authorship'] = array( |
|
|
'join' => array( |
|
|
'left' => array( |
|
|
'table' => 'node', |
|
|
'field' => 'nid', |
|
|
), |
|
|
'right' => array( |
|
|
'field' => 'nid', |
|
|
), |
|
|
), |
|
|
'fields' => array( |
|
|
'authorship' => array( |
|
|
'name' => t('Node: Authorship'), |
|
|
'sortable' => true, |
|
|
'help' => t('Display the authorship display setting for the node.'), |
|
|
), |
|
|
), |
|
|
'sorts' => array( |
|
|
'authorship' => array( |
|
|
'name' => t('Node: Authorship'), |
|
|
'help' => t('Sort by the node authorship, alphabetically'), |
|
|
), |
|
|
), |
|
|
'filters' => array( |
|
|
'authorship' => array( |
|
|
'name' => t('Node: Authorship'), |
|
|
'operator' => 'views_handler_operator_like', |
|
|
'handler' => 'views_handler_filter_like', |
|
|
'help' => t('Sort by the node authorship, alphabetically'), |
|
|
), |
|
|
), |
|
|
); |
|
|
return $tables; |
|
|
} |
|
| 271 |
|
|