function _user_relationship_blocks_form in User Relationships 6
Same name and namespace in other branches
- 5.2 plugins/user_relationship_blocks/user_relationship_blocks.module \_user_relationship_blocks_form()
helper function user_relationship_blocks_block delegates to when $op == 'configure'
1 call to _user_relationship_blocks_form()
- user_relationship_blocks_block in user_relationship_blocks/
user_relationship_blocks.module - Implementation for hook_block
File
- user_relationship_blocks/
user_relationship_blocks.module, line 139 - User Relationship Blocks implementation @author Jeff Smick (creator) @author Alex Karshakevich (maintainer) http://drupal.org/user/183217
Code
function _user_relationship_blocks_form($block, $rtid, $extra, $bid) {
// No form needed for the pending block so don't even bother
if ($block == 'pending') {
return;
}
// need this file. it has the validator in it
include_once drupal_get_path('module', 'user_relationships_ui') . '/user_relationships_ui.admin_actions.inc';
//current block settings
$settings = _user_relationship_blocks_settings($bid);
if ($block != 'actions') {
if ($rtid == UR_BLOCK_ALL_TYPES) {
$relationship_name = t('All');
}
else {
$type = user_relationships_type_load($rtid);
$relationship_name = ur_tt("user_relationships:rtid:{$rtid}:name", $type->name);
}
$form['size'] = array(
'#type' => 'textfield',
'#size' => 4,
'#weight' => 1,
'#required' => TRUE,
'#title' => t('Number of relationships to display in block'),
'#description' => t('Enter the maximum number of relationships to display in this block.'),
'#default_value' => $settings->size,
'#validate' => array(
'user_relationships_ui_setting_validation' => array(
array(
'is_positive' => array(
'size' => t('Number of relationships to display must be an integer greater than 0.'),
),
),
),
),
);
$user_identifier = $block == UR_BLOCK_MY ? t('currently logged in user') : t('author whose node is being viewed');
$msg = t("NOTE: This block displays @relationship_name relationships of the @user_identifier.", array(
'@relationship_name' => ur_tt("user_relationships:rtid:{$rtid}:name", $relationship_name),
'@user_identifier' => $user_identifier,
));
if ($extra) {
$relation = $extra == 'you_to_them' ? t('requester') : t('requestee');
$msg .= "\n" . t("Because this relationship is one-way this block will show relationships where the @user_identifier is the @relation", array(
'@user_identifier' => $user_identifier,
'@relation' => $relation,
));
}
$sort_var = "{$var}_sort";
$form['sort'] = array(
'#type' => 'radios',
'#title' => t('Which relationships should be displayed'),
'#options' => array(
'newest' => t('Newest'),
'oldest' => t('Oldest'),
'random' => t('Random'),
),
'#default_value' => $settings->sort,
'#required' => TRUE,
'#weight' => 3,
'#suffix' => $msg,
);
}
$form['bid'] = array(
'#type' => 'hidden',
'#value' => $bid,
);
$form['get_account'] = array(
'#type' => 'textarea',
'#size' => 4,
'#weight' => 1,
// '#required' => TRUE,
'#title' => t('Return uid of the target user'),
'#description' => t("(EXPERT ONLY) Enter a php snippet, surrounded by %php_snippet, which returns a numeric user id you want to work on. By default, for user pages, it is the user being viewed. For nodes or blogs, it is the node author. Clear the field to restore this default.", array(
'%php_snippet' => '<?php ?>',
)),
'#default_value' => $settings->get_account,
);
return $form;
}