security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -14,12 +14,15 @@ $plugin = array(
|
||||
'title' => t('String'),
|
||||
'description' => t('A context that is just a string.'),
|
||||
'context' => 'ctools_context_create_string',
|
||||
'edit form' => 'ctools_context_string_settings_form',
|
||||
'defaults' => '',
|
||||
'keyword' => 'string',
|
||||
'no ui' => FALSE,
|
||||
'context name' => 'string',
|
||||
'convert list' => array(
|
||||
'raw' => t('Raw string'),
|
||||
'html_safe' => t('HTML-safe string'),
|
||||
'uppercase_words_html_safe' => t('Uppercase words HTML-safe string'),
|
||||
),
|
||||
'convert' => 'ctools_context_string_convert',
|
||||
'placeholder form' => array(
|
||||
@@ -44,7 +47,8 @@ function ctools_context_create_string($empty, $data = NULL, $conf = FALSE) {
|
||||
}
|
||||
|
||||
if ($data !== FALSE ) {
|
||||
$context->data = $data;
|
||||
// Support the array storage from the settings form but also handle direct input from arguments.
|
||||
$context->data = is_array($data) ? $data['string'] : $data;
|
||||
$context->title = ($conf) ? check_plain($data['identifier']) : check_plain($data);
|
||||
return $context;
|
||||
}
|
||||
@@ -59,6 +63,28 @@ function ctools_context_string_convert($context, $type) {
|
||||
return $context->data;
|
||||
case 'html_safe':
|
||||
return check_plain($context->data);
|
||||
case 'uppercase_words_html_safe':
|
||||
return ucwords(str_replace('-', ' ', check_plain($context->data)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* String settings form.
|
||||
*/
|
||||
function ctools_context_string_settings_form($form, &$form_state) {
|
||||
$conf = &$form_state['conf'];
|
||||
|
||||
$form['string'] = array(
|
||||
'#title' => t('Enter the string'),
|
||||
'#type' => 'textfield',
|
||||
'#maxlength' => 512,
|
||||
'#weight' => -10,
|
||||
'#default_value' => $conf['string'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function ctools_context_string_settings_form_submit($form, &$form_state) {
|
||||
$form_state['conf']['string'] = $form_state['values']['string'];
|
||||
}
|
||||
|
@@ -51,8 +51,9 @@ function ctools_context_token_convert_list() {
|
||||
function ctools_context_token_convert($context, $token) {
|
||||
$tokens = token_info();
|
||||
list($type, $token) = explode(':', $token, 2);
|
||||
$parts = explode(':', $token, 2);
|
||||
$real_type = isset($tokens['types'][$type]['type']) ? $tokens['types'][$type]['type'] : $type;
|
||||
if (isset($tokens['tokens'][$real_type][$token])) {
|
||||
if (isset($tokens['tokens'][$real_type][$parts[0]])) {
|
||||
$values = token_generate($type, array($token => $token));
|
||||
if (isset($values[$token])) {
|
||||
return $values[$token];
|
||||
|
@@ -88,7 +88,7 @@ function ctools_context_user_settings_form($form, &$form_state) {
|
||||
if (!empty($conf['uid'])) {
|
||||
$info = user_load($conf['uid']);
|
||||
if ($info) {
|
||||
$form['user']['#description'] = t('Currently set to !link', array('!link' => theme('username', $info)));
|
||||
$form['user']['#description'] = t('Currently set to !link', array('!link' => theme('username', array('account' => $info))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ function ctools_context_user_edit_form_settings_form($form, &$form_state) {
|
||||
);
|
||||
|
||||
if (!empty($conf['uid'])) {
|
||||
$info = db_query('SELECT * FROM {user} WHERE uid = :uid', array(':uid' => $conf['uid']))->fetchObject();
|
||||
$info = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => $conf['uid']))->fetchObject();
|
||||
if ($info) {
|
||||
$link = l(t("'%name' [user id %uid]", array('%name' => $info->name, '%uid' => $info->uid)), "user/$info->uid", array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
|
||||
$form['user']['#description'] = t('Currently set to !link', array('!link' => $link));
|
||||
@@ -154,10 +154,10 @@ function ctools_context_user_edit_form_settings_form_validate($form, &$form_stat
|
||||
$uid = $preg_matches[1];
|
||||
}
|
||||
if (is_numeric($uid)) {
|
||||
$user = db_query('SELECT uid FROM {user} WHEREuid = :uid', array(':uid' => $uid))->fetchObject();
|
||||
$user = db_query('SELECT uid FROM {users} WHERE uid = :uid', array(':uid' => $uid))->fetchObject();
|
||||
}
|
||||
else {
|
||||
$user = db_query('SELECT uid FROM {user} WHERE LOWER(name) = LOWER(:name)', array(':name' => $uid))->fetchObject();
|
||||
$user = db_query('SELECT uid FROM {users} WHERE LOWER(name) = LOWER(:name)', array(':name' => $uid))->fetchObject();
|
||||
}
|
||||
|
||||
form_set_value($form['uid'], $user->uid, $form_state);
|
||||
|
Reference in New Issue
Block a user