### Eclipse Workspace Patch 1.0 #P Profile Plus Index: profileplus.module =================================================================== RCS file: /cvs/drupal/contributions/modules/profileplus/profileplus.module,v retrieving revision 1.8.2.2 diff -u -r1.8.2.2 profileplus.module --- profileplus.module 28 Apr 2008 04:05:58 -0000 1.8.2.2 +++ profileplus.module 9 Oct 2008 04:49:09 -0000 @@ -31,6 +31,61 @@ /* + * Implementation of hook_block(). + */ +function profileplus_block($op = 'list', $delta = 0){ + if ($op == 'list') { + $blocks[0]['info'] = t('Profile Search form'); + // Not worth caching. + $blocks[0]['cache'] = BLOCK_NO_CACHE; + return $blocks; + } + else if ($op == 'view' && user_access('search user profiles')) { + $block['content'] = drupal_get_form('profile_search_form'); + $block['subject'] = t('Profile Search'); + return $block; +} +} + + +/* + * Implementation of profile_search_form() + */ +function profile_search_form(){ + $forms['profile_search'] = array( + '#title' => t('Profile Search'), + '#type' => t('textfield'), + '#size' => 10, + '#default_value' => '', + ); + $forms['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + + $form['#submit'][] = 'profile_search_form_submit'; + $form['#validate'][] = 'profile_search_form_validate'; + + return $forms; +} + +/* + * Implementation of profile_search_form_submit + */ +function profile_search_form_submit($form, &$form_state){ +$form_state['redirect'] = 'search/profile/'. trim($form_state['values']['profile_search']); +} + +/* + * Implementation of profile_search_form_validate + */ +function profile_search_form_validate($form,&$form_state){ + if($form_state['values']['profile_search'] == '' ){ + form_set_error('profile_search', t('A blank search is not allowed')); + } +} + +/* * Implementation of hook_search() */ function profile_search($op = 'search', $keys = null) {