Index: openid_ax.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid_ax/openid_ax.module,v retrieving revision 1.8 diff -u -p -r1.8 openid_ax.module --- openid_ax.module 10 Aug 2008 18:33:57 -0000 1.8 +++ openid_ax.module 10 Oct 2008 20:29:36 -0000 @@ -6,7 +6,7 @@ */ /** - * Implementation ofhook_menu() + * Implementation of hook_menu() */ function openid_ax_menu() { $items['openid/ax'] = array( @@ -15,60 +15,148 @@ function openid_ax_menu() { 'type' => MENU_CALLBACK, 'file' => 'openid_ax.pages.inc', 'access callback' => TRUE - ); + ); $items['openid/ax/continue'] = array( 'title' => 'OpenID Attribute Exchange', 'page callback' => 'openid_ax_continue', 'access callback' => TRUE, 'type' => MENU_CALLBACK, 'file' => 'openid_ax.pages.inc' - ); + ); $items['openid/ax/send'] = array( 'title' => 'OpenID Attribute Exchange', 'page callback' => 'openid_ax_send', 'access callback' => TRUE, 'type' => MENU_CALLBACK, 'file' => 'openid_ax.pages.inc' - ); + ); $items['user/%user/persona'] = array( 'title' => 'OpenID AX Personas', - 'page callback' => 'openid_ax_persona', - 'access callback' => TRUE, - 'type' => MENU_LOCAL_TASK, - 'file' => 'openid_ax.pages.inc' - ); - $items['user/%user/persona/create'] = array( - 'title' => 'Create OpenID AX Personas', - 'page callback' => 'openid_ax_create_persona', - 'access callback' => TRUE, + 'page callback' => 'openid_ax_manage_personas', + 'page arguments' => array(1), + 'access callback' => 'openid_ax_access_check', + 'access arguments' => array(1), 'type' => MENU_LOCAL_TASK, - 'file' => 'openid_ax.pages.inc' - ); + 'file' => 'openid_ax.pages.inc', + ); $items['user/%user/persona/manage'] = array( - 'title' => 'Manage OpenID AX Personas', + 'title' => 'Manage Personas', 'page callback' => 'openid_ax_manage_personas', - 'access callback' => TRUE, + 'page arguments' => array(1), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'file' => 'openid_ax.pages.inc', + 'weight' => 0, + ); + $items['user/%user/persona/create'] = array( + 'title' => 'Create Personas', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('openid_ax_new_persona_form', 1), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), 'type' => MENU_LOCAL_TASK, - 'file' => 'openid_ax.pages.inc' - ); + 'file' => 'openid_ax.pages.inc', + 'weight' => 5, + ); + $items['user/%user/persona/copy'] = array( + 'title' => 'Copy Personas', + 'page callback' => 'openid_ax_copy_personas', + 'page arguments' => array(1), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'file' => 'openid_ax.pages.inc', + 'weight' => 7, + ); + $items['user/%user/persona/copy/%'] = array( + 'title' => '', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('openid_ax_copy_persona_form', 1, 4), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'file' => 'openid_ax.pages.inc', + 'weight' => 20, + ); + $items['user/%user/persona/edit'] = array( + 'title' => '', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('openid_ax_persona_form', 1), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'file' => 'openid_ax.pages.inc', + 'weight' => 20, + ); $items['user/%user/persona/rename'] = array( - 'title' => 'Rename OpenID AX Personas', - 'page callback' => 'openid_ax_rename_personas', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - 'file' => 'openid_ax.pages.inc' - ); + 'title' => '', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('openid_ax_rename_persona_form', 1), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'file' => 'openid_ax.pages.inc', + 'weight' => 20, + ); $items['user/%user/persona/delete'] = array( - 'title' => 'Delete OpenID AX Personas', + 'title' => '', 'page callback' => 'openid_ax_persona_delete', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - 'file' => 'openid_ax.pages.inc' - ); + 'page arguments' => array(1), + 'access callback' => 'openid_ax_user_check', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'file' => 'openid_ax.pages.inc', + 'weight' => 20, + ); return $items; } /** + * Access check function to make sure only the user or site administrators can view the pages + */ +function openid_ax_access_check($account) { + global $user; + + if (($user->uid && $user->uid == $account->uid) || user_access('administer site configuration')) { + return TRUE; + } + return FALSE; +} + +/** + * User check only allow access to these if it is the user + */ +function openid_ax_user_check($account) { + global $user; + + if ($user->uid == $account->uid) { + return TRUE; + } + return FALSE; +} + +/** + * Return a XRDS for Attribute Exchange service discovery + */ +function openid_ax_xrds($account = NULL) { + $data = array( + 'Type' => array('http://openid.net/srv/ax/1.0'), + ); + + $xrds['openid_ax'] = array( + 'services' => array( + array( + 'priority' => 10, + 'data' => $data + ) + ) + ); + + return $xrds; +} + +/** * Implementation of hook_openid() */ function openid_ax_openid() { @@ -78,4 +166,4 @@ function openid_ax_openid() { $request['openid.ax.type.gender'] = 'http://openid.net/schema/gender'; $request['openid.ax.required'] = 'fname,gender'; return $request; -} \ No newline at end of file +}