diff --git plugins/contexts/user.inc plugins/contexts/user.inc index bc738d0..7bdbc4c 100644 --- plugins/contexts/user.inc +++ plugins/contexts/user.inc @@ -18,7 +18,7 @@ function ctools_user_ctools_contexts() { 'settings form' => 'ctools_context_user_settings_form', 'settings form validate' => 'ctools_context_user_settings_form_validate', 'keyword' => 'user', - 'no ui' => TRUE, + 'defaults' => array('uid' => '', 'current' => 0), 'context name' => 'user', 'convert list' => array( 'uid' => t('User ID'), @@ -41,7 +41,13 @@ function ctools_context_create_user($empty, $data = NULL, $conf = FALSE) { } if ($conf) { - $data = user_load(array('uid' => $data['uid'])); + if ($data['current'] == 1) { + global $user; + $data = &$user; + } + else { + $data = user_load(array('uid' => $data['uid'])); + } } if (!empty($data)) { @@ -54,6 +60,14 @@ function ctools_context_create_user($empty, $data = NULL, $conf = FALSE) { function ctools_context_user_settings_form($conf) { $form = array(); + $warning = t('Note: because you add this context using context form instead of assigning to an argument, it will contain current user object.'); + $form['description'] = array( + '#value' => ''. $warning .'
', + ); + $form['current'] = array( + '#type' => 'hidden', + '#default_value' => 1, + ); return $form; }