@@ -50,94 +50,94 @@ discard block |
||
50 | 50 | */ |
51 | 51 | function text_field_settings($op, $field) { |
52 | 52 | switch ($op) { |
53 | - case 'form': |
|
54 | - $form = array(); |
|
55 | - $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)')); |
|
56 | - $form['text_processing'] = array( |
|
57 | - '#type' => 'radios', |
|
58 | - '#title' => t('Text processing'), |
|
59 | - '#default_value' => is_numeric($field['text_processing']) ? $field['text_processing'] : 0, |
|
60 | - '#options' => $options, |
|
61 | - ); |
|
62 | - $form['max_length'] = array( |
|
63 | - '#type' => 'textfield', |
|
64 | - '#title' => t('Maximum length'), |
|
65 | - '#default_value' => is_numeric($field['max_length']) ? $field['max_length'] : '', |
|
66 | - '#required' => FALSE, |
|
67 | - '#element_validate' => array('_element_validate_integer_positive'), |
|
68 | - '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'), |
|
69 | - ); |
|
70 | - $form['allowed_values_fieldset'] = array( |
|
71 | - '#type' => 'fieldset', |
|
72 | - '#title' => t('Allowed values'), |
|
73 | - '#collapsible' => TRUE, |
|
74 | - '#collapsed' => TRUE, |
|
75 | - ); |
|
76 | - $form['allowed_values_fieldset']['allowed_values'] = array( |
|
53 | + case 'form': |
|
54 | + $form = array(); |
|
55 | + $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)')); |
|
56 | + $form['text_processing'] = array( |
|
57 | + '#type' => 'radios', |
|
58 | + '#title' => t('Text processing'), |
|
59 | + '#default_value' => is_numeric($field['text_processing']) ? $field['text_processing'] : 0, |
|
60 | + '#options' => $options, |
|
61 | + ); |
|
62 | + $form['max_length'] = array( |
|
63 | + '#type' => 'textfield', |
|
64 | + '#title' => t('Maximum length'), |
|
65 | + '#default_value' => is_numeric($field['max_length']) ? $field['max_length'] : '', |
|
66 | + '#required' => FALSE, |
|
67 | + '#element_validate' => array('_element_validate_integer_positive'), |
|
68 | + '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'), |
|
69 | + ); |
|
70 | + $form['allowed_values_fieldset'] = array( |
|
71 | + '#type' => 'fieldset', |
|
72 | + '#title' => t('Allowed values'), |
|
73 | + '#collapsible' => TRUE, |
|
74 | + '#collapsed' => TRUE, |
|
75 | + ); |
|
76 | + $form['allowed_values_fieldset']['allowed_values'] = array( |
|
77 | + '#type' => 'textarea', |
|
78 | + '#title' => t('Allowed values list'), |
|
79 | + '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '', |
|
80 | + '#required' => FALSE, |
|
81 | + '#rows' => 10, |
|
82 | + '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())), |
|
83 | + ); |
|
84 | + $form['allowed_values_fieldset']['advanced_options'] = array( |
|
85 | + '#type' => 'fieldset', |
|
86 | + '#title' => t('PHP code'), |
|
87 | + '#collapsible' => TRUE, |
|
88 | + '#collapsed' => empty($field['allowed_values_php']), |
|
89 | + ); |
|
90 | + if (user_access('Use PHP input for field settings (dangerous - grant with care)')) { |
|
91 | + $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array( |
|
77 | 92 | '#type' => 'textarea', |
78 | - '#title' => t('Allowed values list'), |
|
79 | - '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '', |
|
80 | - '#required' => FALSE, |
|
81 | - '#rows' => 10, |
|
82 | - '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())), |
|
93 | + '#title' => t('Code'), |
|
94 | + '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '', |
|
95 | + '#rows' => 6, |
|
96 | + '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include <?php ?> delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'), |
|
83 | 97 | ); |
84 | - $form['allowed_values_fieldset']['advanced_options'] = array( |
|
85 | - '#type' => 'fieldset', |
|
86 | - '#title' => t('PHP code'), |
|
87 | - '#collapsible' => TRUE, |
|
88 | - '#collapsed' => empty($field['allowed_values_php']), |
|
98 | + } |
|
99 | + else { |
|
100 | + $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array( |
|
101 | + '#type' => 'item', |
|
102 | + '#title' => t('Code'), |
|
103 | + '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('<none>'), |
|
104 | + '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'), |
|
89 | 105 | ); |
90 | - if (user_access('Use PHP input for field settings (dangerous - grant with care)')) { |
|
91 | - $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array( |
|
92 | - '#type' => 'textarea', |
|
93 | - '#title' => t('Code'), |
|
94 | - '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '', |
|
95 | - '#rows' => 6, |
|
96 | - '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include <?php ?> delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'), |
|
97 | - ); |
|
98 | - } |
|
99 | - else { |
|
100 | - $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array( |
|
101 | - '#type' => 'item', |
|
102 | - '#title' => t('Code'), |
|
103 | - '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('<none>'), |
|
104 | - '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'), |
|
105 | - ); |
|
106 | - } |
|
107 | - return $form; |
|
108 | - |
|
109 | - case 'save': |
|
110 | - return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_php'); |
|
111 | - |
|
112 | - case 'database columns': |
|
113 | - if (empty($field['max_length']) || $field['max_length'] > 255) { |
|
114 | - $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE); |
|
115 | - } |
|
116 | - else { |
|
117 | - $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE); |
|
118 | - } |
|
119 | - if (!empty($field['text_processing'])) { |
|
120 | - $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'views' => FALSE); |
|
121 | - } |
|
122 | - return $columns; |
|
123 | - |
|
124 | - case 'views data': |
|
125 | - $allowed_values = content_allowed_values($field); |
|
126 | - if (count($allowed_values)) { |
|
127 | - $data = content_views_field_views_data($field); |
|
128 | - $db_info = content_database_info($field); |
|
129 | - $table_alias = content_views_tablename($field); |
|
130 | - |
|
131 | - // Filter: Add a 'many to one' filter. |
|
132 | - $copy = $data[$table_alias][$field['field_name'] .'_value']; |
|
133 | - $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name'])); |
|
134 | - $copy['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
135 | - unset($copy['field'], $copy['argument'], $copy['sort']); |
|
136 | - $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy; |
|
137 | - // Argument : swap the handler to the 'many to one' operator. |
|
138 | - $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one'; |
|
139 | - return $data; |
|
140 | - } |
|
106 | + } |
|
107 | + return $form; |
|
108 | + |
|
109 | + case 'save': |
|
110 | + return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_php'); |
|
111 | + |
|
112 | + case 'database columns': |
|
113 | + if (empty($field['max_length']) || $field['max_length'] > 255) { |
|
114 | + $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE); |
|
115 | + } |
|
116 | + else { |
|
117 | + $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE); |
|
118 | + } |
|
119 | + if (!empty($field['text_processing'])) { |
|
120 | + $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'views' => FALSE); |
|
121 | + } |
|
122 | + return $columns; |
|
123 | + |
|
124 | + case 'views data': |
|
125 | + $allowed_values = content_allowed_values($field); |
|
126 | + if (count($allowed_values)) { |
|
127 | + $data = content_views_field_views_data($field); |
|
128 | + $db_info = content_database_info($field); |
|
129 | + $table_alias = content_views_tablename($field); |
|
130 | + |
|
131 | + // Filter: Add a 'many to one' filter. |
|
132 | + $copy = $data[$table_alias][$field['field_name'] .'_value']; |
|
133 | + $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name'])); |
|
134 | + $copy['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
135 | + unset($copy['field'], $copy['argument'], $copy['sort']); |
|
136 | + $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy; |
|
137 | + // Argument : swap the handler to the 'many to one' operator. |
|
138 | + $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one'; |
|
139 | + return $data; |
|
140 | + } |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -146,34 +146,34 @@ discard block |
||
146 | 146 | */ |
147 | 147 | function text_field($op, &$node, $field, &$items, $teaser, $page) { |
148 | 148 | switch ($op) { |
149 | - case 'validate': |
|
150 | - $allowed_values = content_allowed_values($field); |
|
151 | - if (is_array($items)) { |
|
152 | - foreach ($items as $delta => $item) { |
|
153 | - $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
154 | - if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
155 | - if (!empty($item['value'])) { |
|
156 | - if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) { |
|
157 | - form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label'])))); |
|
158 | - } |
|
159 | - if (!empty($field['max_length']) && drupal_strlen($item['value']) > $field['max_length']) { |
|
160 | - form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array('%name' => $field['widget']['label'], '%max' => $field['max_length']))); |
|
161 | - } |
|
149 | + case 'validate': |
|
150 | + $allowed_values = content_allowed_values($field); |
|
151 | + if (is_array($items)) { |
|
152 | + foreach ($items as $delta => $item) { |
|
153 | + $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
154 | + if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
155 | + if (!empty($item['value'])) { |
|
156 | + if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) { |
|
157 | + form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label'])))); |
|
158 | + } |
|
159 | + if (!empty($field['max_length']) && drupal_strlen($item['value']) > $field['max_length']) { |
|
160 | + form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array('%name' => $field['widget']['label'], '%max' => $field['max_length']))); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | } |
165 | - return $items; |
|
164 | + } |
|
165 | + return $items; |
|
166 | 166 | |
167 | - case 'sanitize': |
|
168 | - foreach ($items as $delta => $item) { |
|
169 | - if (!empty($field['text_processing'])) { |
|
170 | - $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : ''; |
|
171 | - } |
|
172 | - else { |
|
173 | - $text = isset($item['value']) ? check_plain($item['value']) : ''; |
|
174 | - } |
|
175 | - $items[$delta]['safe'] = $text; |
|
167 | + case 'sanitize': |
|
168 | + foreach ($items as $delta => $item) { |
|
169 | + if (!empty($field['text_processing'])) { |
|
170 | + $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : ''; |
|
171 | + } |
|
172 | + else { |
|
173 | + $text = isset($item['value']) ? check_plain($item['value']) : ''; |
|
176 | 174 | } |
175 | + $items[$delta]['safe'] = $text; |
|
176 | + } |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -305,34 +305,34 @@ discard block |
||
305 | 305 | */ |
306 | 306 | function text_widget_settings($op, $widget) { |
307 | 307 | switch ($op) { |
308 | - case 'form': |
|
309 | - $form = array(); |
|
310 | - $rows = (isset($widget['rows']) && is_numeric($widget['rows'])) ? $widget['rows'] : 5; |
|
311 | - $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60; |
|
312 | - if ($widget['type'] == 'text_textfield') { |
|
313 | - $form['rows'] = array('#type' => 'hidden', '#value' => $rows); |
|
314 | - $form['size'] = array( |
|
315 | - '#type' => 'textfield', |
|
316 | - '#title' => t('Size of textfield'), |
|
317 | - '#default_value' => $size, |
|
318 | - '#element_validate' => array('_element_validate_integer_positive'), |
|
319 | - '#required' => TRUE, |
|
320 | - ); |
|
321 | - } |
|
322 | - else { |
|
323 | - $form['rows'] = array( |
|
324 | - '#type' => 'textfield', |
|
325 | - '#title' => t('Rows'), |
|
326 | - '#default_value' => $rows, |
|
327 | - '#element_validate' => array('_element_validate_integer_positive'), |
|
328 | - '#required' => TRUE, |
|
329 | - ); |
|
330 | - $form['size'] = array('#type' => 'hidden', '#value' => $size); |
|
331 | - } |
|
332 | - return $form; |
|
308 | + case 'form': |
|
309 | + $form = array(); |
|
310 | + $rows = (isset($widget['rows']) && is_numeric($widget['rows'])) ? $widget['rows'] : 5; |
|
311 | + $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60; |
|
312 | + if ($widget['type'] == 'text_textfield') { |
|
313 | + $form['rows'] = array('#type' => 'hidden', '#value' => $rows); |
|
314 | + $form['size'] = array( |
|
315 | + '#type' => 'textfield', |
|
316 | + '#title' => t('Size of textfield'), |
|
317 | + '#default_value' => $size, |
|
318 | + '#element_validate' => array('_element_validate_integer_positive'), |
|
319 | + '#required' => TRUE, |
|
320 | + ); |
|
321 | + } |
|
322 | + else { |
|
323 | + $form['rows'] = array( |
|
324 | + '#type' => 'textfield', |
|
325 | + '#title' => t('Rows'), |
|
326 | + '#default_value' => $rows, |
|
327 | + '#element_validate' => array('_element_validate_integer_positive'), |
|
328 | + '#required' => TRUE, |
|
329 | + ); |
|
330 | + $form['size'] = array('#type' => 'hidden', '#value' => $size); |
|
331 | + } |
|
332 | + return $form; |
|
333 | 333 | |
334 | - case 'save': |
|
335 | - return array('rows', 'size'); |
|
334 | + case 'save': |
|
335 | + return array('rows', 'size'); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 |
@@ -70,108 +70,108 @@ discard block |
||
70 | 70 | */ |
71 | 71 | function userreference_field_settings($op, $field) { |
72 | 72 | switch ($op) { |
73 | - case 'form': |
|
74 | - $form = array(); |
|
75 | - $form['referenceable_roles'] = array( |
|
76 | - '#type' => 'checkboxes', |
|
77 | - '#title' => t('User roles that can be referenced'), |
|
78 | - '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(), |
|
79 | - '#options' => user_roles(1), |
|
80 | - ); |
|
81 | - $form['referenceable_status'] = array( |
|
82 | - '#type' => 'radios', |
|
83 | - '#title' => t('User status that can be referenced'), |
|
84 | - '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '', |
|
85 | - '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')), |
|
86 | - ); |
|
87 | - if (module_exists('views')) { |
|
88 | - $views = array('--' => '--'); |
|
89 | - $all_views = views_get_all_views(); |
|
90 | - foreach ($all_views as $view) { |
|
91 | - // Only 'users' views that have fields will work for our purpose. |
|
92 | - if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) { |
|
93 | - if ($view->type == 'Default') { |
|
94 | - $views[t('Default Views')][$view->name] = $view->name; |
|
95 | - } |
|
96 | - else { |
|
97 | - $views[t('Existing Views')][$view->name] = $view->name; |
|
98 | - } |
|
73 | + case 'form': |
|
74 | + $form = array(); |
|
75 | + $form['referenceable_roles'] = array( |
|
76 | + '#type' => 'checkboxes', |
|
77 | + '#title' => t('User roles that can be referenced'), |
|
78 | + '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(), |
|
79 | + '#options' => user_roles(1), |
|
80 | + ); |
|
81 | + $form['referenceable_status'] = array( |
|
82 | + '#type' => 'radios', |
|
83 | + '#title' => t('User status that can be referenced'), |
|
84 | + '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '', |
|
85 | + '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')), |
|
86 | + ); |
|
87 | + if (module_exists('views')) { |
|
88 | + $views = array('--' => '--'); |
|
89 | + $all_views = views_get_all_views(); |
|
90 | + foreach ($all_views as $view) { |
|
91 | + // Only 'users' views that have fields will work for our purpose. |
|
92 | + if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) { |
|
93 | + if ($view->type == 'Default') { |
|
94 | + $views[t('Default Views')][$view->name] = $view->name; |
|
95 | + } |
|
96 | + else { |
|
97 | + $views[t('Existing Views')][$view->name] = $view->name; |
|
99 | 98 | } |
100 | - } |
|
101 | - |
|
102 | - $form['advanced'] = array( |
|
103 | - '#type' => 'fieldset', |
|
104 | - '#title' => t('Advanced - Users that can be referenced (View)'), |
|
105 | - '#collapsible' => TRUE, |
|
106 | - '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--', |
|
107 | - ); |
|
108 | - if (count($views) > 1) { |
|
109 | - $form['advanced']['advanced_view'] = array( |
|
110 | - '#type' => 'select', |
|
111 | - '#title' => t('View used to select the users'), |
|
112 | - '#options' => $views, |
|
113 | - '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--', |
|
114 | - '#description' => t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') . |
|
115 | - t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'), |
|
116 | - ); |
|
117 | - $form['advanced']['advanced_view_args'] = array( |
|
118 | - '#type' => 'textfield', |
|
119 | - '#title' => t('View arguments'), |
|
120 | - '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '', |
|
121 | - '#required' => FALSE, |
|
122 | - '#description' => t('Provide a comma separated list of arguments to pass to the view.'), |
|
123 | - ); |
|
124 | - } |
|
125 | - else { |
|
126 | - $form['advanced']['no_view_help'] = array( |
|
127 | - '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') . |
|
128 | - t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'), |
|
129 | - ); |
|
130 | 99 | } |
131 | 100 | } |
132 | - return $form; |
|
133 | 101 | |
134 | - case 'save': |
|
135 | - $settings = array('referenceable_roles', 'referenceable_status'); |
|
136 | - if (module_exists('views')) { |
|
137 | - $settings[] = 'advanced_view'; |
|
138 | - $settings[] = 'advanced_view_args'; |
|
102 | + $form['advanced'] = array( |
|
103 | + '#type' => 'fieldset', |
|
104 | + '#title' => t('Advanced - Users that can be referenced (View)'), |
|
105 | + '#collapsible' => TRUE, |
|
106 | + '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--', |
|
107 | + ); |
|
108 | + if (count($views) > 1) { |
|
109 | + $form['advanced']['advanced_view'] = array( |
|
110 | + '#type' => 'select', |
|
111 | + '#title' => t('View used to select the users'), |
|
112 | + '#options' => $views, |
|
113 | + '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--', |
|
114 | + '#description' => t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') . |
|
115 | + t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'), |
|
116 | + ); |
|
117 | + $form['advanced']['advanced_view_args'] = array( |
|
118 | + '#type' => 'textfield', |
|
119 | + '#title' => t('View arguments'), |
|
120 | + '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '', |
|
121 | + '#required' => FALSE, |
|
122 | + '#description' => t('Provide a comma separated list of arguments to pass to the view.'), |
|
123 | + ); |
|
124 | + } |
|
125 | + else { |
|
126 | + $form['advanced']['no_view_help'] = array( |
|
127 | + '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') . |
|
128 | + t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'), |
|
129 | + ); |
|
139 | 130 | } |
140 | - return $settings; |
|
131 | + } |
|
132 | + return $form; |
|
141 | 133 | |
142 | - case 'database columns': |
|
143 | - $columns = array( |
|
144 | - 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE), |
|
145 | - ); |
|
146 | - return $columns; |
|
147 | - |
|
148 | - case 'views data': |
|
149 | - $data = content_views_field_views_data($field); |
|
150 | - $db_info = content_database_info($field); |
|
151 | - $table_alias = content_views_tablename($field); |
|
152 | - |
|
153 | - // Filter : swap the handler to the 'in' operator. |
|
154 | - $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
155 | - // Argument: get the user name for summaries. |
|
156 | - // We need to join a new instance of the users table. |
|
157 | - $data["users_$table_alias"]['table']['join']['node'] = array( |
|
158 | - 'table' => 'users', |
|
159 | - 'field' => 'uid', |
|
160 | - 'left_table' => $table_alias, |
|
161 | - 'left_field' => $field['field_name'] .'_uid', |
|
162 | - ); |
|
163 | - $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference'; |
|
164 | - $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias"; |
|
165 | - $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name'; |
|
166 | - // Relationship: Add a relationship for related user. |
|
167 | - $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array( |
|
168 | - 'base' => 'users', |
|
169 | - 'field' => $db_info['columns']['uid']['column'], |
|
170 | - 'handler' => 'content_handler_relationship', |
|
171 | - 'label' => t($field['widget']['label']), |
|
172 | - 'content_field_name' => $field['field_name'], |
|
173 | - ); |
|
174 | - return $data; |
|
134 | + case 'save': |
|
135 | + $settings = array('referenceable_roles', 'referenceable_status'); |
|
136 | + if (module_exists('views')) { |
|
137 | + $settings[] = 'advanced_view'; |
|
138 | + $settings[] = 'advanced_view_args'; |
|
139 | + } |
|
140 | + return $settings; |
|
141 | + |
|
142 | + case 'database columns': |
|
143 | + $columns = array( |
|
144 | + 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE), |
|
145 | + ); |
|
146 | + return $columns; |
|
147 | + |
|
148 | + case 'views data': |
|
149 | + $data = content_views_field_views_data($field); |
|
150 | + $db_info = content_database_info($field); |
|
151 | + $table_alias = content_views_tablename($field); |
|
152 | + |
|
153 | + // Filter : swap the handler to the 'in' operator. |
|
154 | + $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one'; |
|
155 | + // Argument: get the user name for summaries. |
|
156 | + // We need to join a new instance of the users table. |
|
157 | + $data["users_$table_alias"]['table']['join']['node'] = array( |
|
158 | + 'table' => 'users', |
|
159 | + 'field' => 'uid', |
|
160 | + 'left_table' => $table_alias, |
|
161 | + 'left_field' => $field['field_name'] .'_uid', |
|
162 | + ); |
|
163 | + $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference'; |
|
164 | + $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias"; |
|
165 | + $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name'; |
|
166 | + // Relationship: Add a relationship for related user. |
|
167 | + $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array( |
|
168 | + 'base' => 'users', |
|
169 | + 'field' => $db_info['columns']['uid']['column'], |
|
170 | + 'handler' => 'content_handler_relationship', |
|
171 | + 'label' => t($field['widget']['label']), |
|
172 | + 'content_field_name' => $field['field_name'], |
|
173 | + ); |
|
174 | + return $data; |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | } |
@@ -181,35 +181,35 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function userreference_field($op, &$node, $field, &$items, $teaser, $page) { |
183 | 183 | switch ($op) { |
184 | - case 'validate': |
|
185 | - // Extract uids to check. |
|
186 | - $ids = array(); |
|
187 | - foreach ($items as $delta => $item) { |
|
188 | - if (is_array($item) && !empty($item['uid'])) { |
|
189 | - if (is_numeric($item['uid'])) { |
|
190 | - $ids[] = $item['uid']; |
|
191 | - } |
|
192 | - else { |
|
193 | - $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
194 | - if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
195 | - form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label'])))); |
|
196 | - } |
|
184 | + case 'validate': |
|
185 | + // Extract uids to check. |
|
186 | + $ids = array(); |
|
187 | + foreach ($items as $delta => $item) { |
|
188 | + if (is_array($item) && !empty($item['uid'])) { |
|
189 | + if (is_numeric($item['uid'])) { |
|
190 | + $ids[] = $item['uid']; |
|
191 | + } |
|
192 | + else { |
|
193 | + $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
194 | + if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
195 | + form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label'])))); |
|
197 | 196 | } |
198 | 197 | } |
199 | - // Prevent performance hog if there are no ids to check. |
|
200 | - if ($ids) { |
|
201 | - $refs = _userreference_potential_references($field, '', NULL, $ids); |
|
202 | - foreach ($items as $delta => $item) { |
|
203 | - if (is_array($item)) { |
|
204 | - $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
205 | - if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
206 | - if (!empty($item['uid']) && !isset($refs[$item['uid']])) { |
|
207 | - form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label'])))); |
|
208 | - } |
|
198 | + } |
|
199 | + // Prevent performance hog if there are no ids to check. |
|
200 | + if ($ids) { |
|
201 | + $refs = _userreference_potential_references($field, '', NULL, $ids); |
|
202 | + foreach ($items as $delta => $item) { |
|
203 | + if (is_array($item)) { |
|
204 | + $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
|
205 | + if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
|
206 | + if (!empty($item['uid']) && !isset($refs[$item['uid']])) { |
|
207 | + form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label'])))); |
|
209 | 208 | } |
210 | 209 | } |
211 | 210 | } |
212 | - return $items; |
|
211 | + } |
|
212 | + return $items; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
@@ -345,43 +345,43 @@ discard block |
||
345 | 345 | */ |
346 | 346 | function userreference_widget_settings($op, $widget) { |
347 | 347 | switch ($op) { |
348 | - case 'form': |
|
349 | - $form = array(); |
|
350 | - $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains'; |
|
351 | - $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60; |
|
352 | - if ($widget['type'] == 'userreference_autocomplete') { |
|
353 | - $form['autocomplete_match'] = array( |
|
354 | - '#type' => 'select', |
|
355 | - '#title' => t('Autocomplete matching'), |
|
356 | - '#default_value' => $match, |
|
357 | - '#options' => array( |
|
358 | - 'starts_with' => t('Starts with'), |
|
359 | - 'contains' => t('Contains'), |
|
360 | - ), |
|
361 | - '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'), |
|
362 | - ); |
|
363 | - $form['size'] = array( |
|
364 | - '#type' => 'textfield', |
|
365 | - '#title' => t('Size of textfield'), |
|
366 | - '#default_value' => $size, |
|
367 | - '#element_validate' => array('_element_validate_integer_positive'), |
|
368 | - '#required' => TRUE, |
|
369 | - ); |
|
370 | - } |
|
371 | - else { |
|
372 | - $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match); |
|
373 | - $form['size'] = array('#type' => 'hidden', '#value' => $size); |
|
374 | - } |
|
375 | - $form['reverse_link'] = array( |
|
376 | - '#type' => 'checkbox', |
|
377 | - '#title' => t('Reverse link'), |
|
378 | - '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0, |
|
379 | - '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'), |
|
348 | + case 'form': |
|
349 | + $form = array(); |
|
350 | + $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains'; |
|
351 | + $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60; |
|
352 | + if ($widget['type'] == 'userreference_autocomplete') { |
|
353 | + $form['autocomplete_match'] = array( |
|
354 | + '#type' => 'select', |
|
355 | + '#title' => t('Autocomplete matching'), |
|
356 | + '#default_value' => $match, |
|
357 | + '#options' => array( |
|
358 | + 'starts_with' => t('Starts with'), |
|
359 | + 'contains' => t('Contains'), |
|
360 | + ), |
|
361 | + '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'), |
|
380 | 362 | ); |
381 | - return $form; |
|
363 | + $form['size'] = array( |
|
364 | + '#type' => 'textfield', |
|
365 | + '#title' => t('Size of textfield'), |
|
366 | + '#default_value' => $size, |
|
367 | + '#element_validate' => array('_element_validate_integer_positive'), |
|
368 | + '#required' => TRUE, |
|
369 | + ); |
|
370 | + } |
|
371 | + else { |
|
372 | + $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match); |
|
373 | + $form['size'] = array('#type' => 'hidden', '#value' => $size); |
|
374 | + } |
|
375 | + $form['reverse_link'] = array( |
|
376 | + '#type' => 'checkbox', |
|
377 | + '#title' => t('Reverse link'), |
|
378 | + '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0, |
|
379 | + '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'), |
|
380 | + ); |
|
381 | + return $form; |
|
382 | 382 | |
383 | - case 'save': |
|
384 | - return array('autocomplete_match', 'size', 'reverse_link'); |
|
383 | + case 'save': |
|
384 | + return array('autocomplete_match', 'size', 'reverse_link'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
@@ -418,27 +418,27 @@ discard block |
||
418 | 418 | */ |
419 | 419 | function userreference_widget(&$form, &$form_state, $field, $items, $delta = 0) { |
420 | 420 | switch ($field['widget']['type']) { |
421 | - case 'userreference_select': |
|
422 | - $element = array( |
|
423 | - '#type' => 'userreference_select', |
|
424 | - '#default_value' => $items, |
|
425 | - ); |
|
426 | - break; |
|
421 | + case 'userreference_select': |
|
422 | + $element = array( |
|
423 | + '#type' => 'userreference_select', |
|
424 | + '#default_value' => $items, |
|
425 | + ); |
|
426 | + break; |
|
427 | 427 | |
428 | - case 'userreference_buttons': |
|
429 | - $element = array( |
|
430 | - '#type' => 'userreference_buttons', |
|
431 | - '#default_value' => $items, |
|
432 | - ); |
|
433 | - break; |
|
428 | + case 'userreference_buttons': |
|
429 | + $element = array( |
|
430 | + '#type' => 'userreference_buttons', |
|
431 | + '#default_value' => $items, |
|
432 | + ); |
|
433 | + break; |
|
434 | 434 | |
435 | - case 'userreference_autocomplete': |
|
436 | - $element = array( |
|
437 | - '#type' => 'userreference_autocomplete', |
|
438 | - '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL, |
|
439 | - '#value_callback' => 'userreference_autocomplete_value', |
|
440 | - ); |
|
441 | - break; |
|
435 | + case 'userreference_autocomplete': |
|
436 | + $element = array( |
|
437 | + '#type' => 'userreference_autocomplete', |
|
438 | + '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL, |
|
439 | + '#value_callback' => 'userreference_autocomplete_value', |
|
440 | + ); |
|
441 | + break; |
|
442 | 442 | } |
443 | 443 | return $element; |
444 | 444 | } |
@@ -845,67 +845,67 @@ discard block |
||
845 | 845 | */ |
846 | 846 | function userreference_user($type, &$edit, &$account) { |
847 | 847 | switch ($type) { |
848 | - case 'load': |
|
849 | - // Only add links if we are on the user 'view' page. |
|
850 | - if (arg(0) != 'user' || arg(2)) { |
|
851 | - return; |
|
852 | - } |
|
853 | - // find CCK userreference field tables |
|
854 | - // search through them for matching user ids and load those nodes |
|
855 | - $additions = array(); |
|
856 | - $types = content_types(); |
|
857 | - |
|
858 | - // Find the table and columns to search through, if the same |
|
859 | - // table comes up in more than one content type, we only need |
|
860 | - // to search it once. |
|
861 | - $search_tables = array(); |
|
862 | - foreach ($types as $type_name => $type) { |
|
863 | - foreach ($type['fields'] as $field) { |
|
864 | - // Only add tables when reverse link has been selected. |
|
865 | - if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) { |
|
866 | - $db_info = content_database_info($field); |
|
867 | - $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column']; |
|
868 | - } |
|
848 | + case 'load': |
|
849 | + // Only add links if we are on the user 'view' page. |
|
850 | + if (arg(0) != 'user' || arg(2)) { |
|
851 | + return; |
|
852 | + } |
|
853 | + // find CCK userreference field tables |
|
854 | + // search through them for matching user ids and load those nodes |
|
855 | + $additions = array(); |
|
856 | + $types = content_types(); |
|
857 | + |
|
858 | + // Find the table and columns to search through, if the same |
|
859 | + // table comes up in more than one content type, we only need |
|
860 | + // to search it once. |
|
861 | + $search_tables = array(); |
|
862 | + foreach ($types as $type_name => $type) { |
|
863 | + foreach ($type['fields'] as $field) { |
|
864 | + // Only add tables when reverse link has been selected. |
|
865 | + if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) { |
|
866 | + $db_info = content_database_info($field); |
|
867 | + $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column']; |
|
869 | 868 | } |
870 | 869 | } |
871 | - foreach ($search_tables as $table => $columns) { |
|
872 | - foreach ($columns as $column) { |
|
873 | - $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1")); |
|
874 | - while ($data = db_fetch_object($ids)) { |
|
875 | - $additions[$data->type][$data->nid] = $data->title; |
|
876 | - } |
|
870 | + } |
|
871 | + foreach ($search_tables as $table => $columns) { |
|
872 | + foreach ($columns as $column) { |
|
873 | + $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1")); |
|
874 | + while ($data = db_fetch_object($ids)) { |
|
875 | + $additions[$data->type][$data->nid] = $data->title; |
|
877 | 876 | } |
878 | 877 | } |
879 | - $account->userreference = $additions; |
|
880 | - break; |
|
878 | + } |
|
879 | + $account->userreference = $additions; |
|
880 | + break; |
|
881 | 881 | |
882 | - case 'view': |
|
883 | - if (!empty($account->userreference)) { |
|
884 | - $node_types = content_types(); |
|
885 | - $additions = array(); |
|
886 | - $values = array(); |
|
887 | - foreach ($account->userreference as $node_type => $nodes) { |
|
888 | - foreach ($nodes as $nid => $title) { |
|
889 | - $values[$node_type][] = l($title, 'node/'. $nid); |
|
890 | - } |
|
891 | - if (isset($values[$node_type])) { |
|
892 | - $additions[] = array( |
|
893 | - '#type' => 'user_profile_item', |
|
894 | - '#title' => check_plain($node_types[$node_type]['name']), |
|
895 | - '#value' => theme('item_list', $values[$node_type]), |
|
896 | - ); |
|
897 | - } |
|
882 | + case 'view': |
|
883 | + if (!empty($account->userreference)) { |
|
884 | + $node_types = content_types(); |
|
885 | + $additions = array(); |
|
886 | + $values = array(); |
|
887 | + foreach ($account->userreference as $node_type => $nodes) { |
|
888 | + foreach ($nodes as $nid => $title) { |
|
889 | + $values[$node_type][] = l($title, 'node/'. $nid); |
|
898 | 890 | } |
899 | - if ($additions) { |
|
900 | - $account->content['userreference'] = $additions + array( |
|
901 | - '#type' => 'user_profile_category', |
|
902 | - '#attributes' => array('class' => 'user-member'), |
|
903 | - '#title' => t('Related content'), |
|
904 | - '#weight' => 10, |
|
891 | + if (isset($values[$node_type])) { |
|
892 | + $additions[] = array( |
|
893 | + '#type' => 'user_profile_item', |
|
894 | + '#title' => check_plain($node_types[$node_type]['name']), |
|
895 | + '#value' => theme('item_list', $values[$node_type]), |
|
905 | 896 | ); |
906 | 897 | } |
907 | 898 | } |
908 | - break; |
|
899 | + if ($additions) { |
|
900 | + $account->content['userreference'] = $additions + array( |
|
901 | + '#type' => 'user_profile_category', |
|
902 | + '#attributes' => array('class' => 'user-member'), |
|
903 | + '#title' => t('Related content'), |
|
904 | + '#weight' => 10, |
|
905 | + ); |
|
906 | + } |
|
907 | + } |
|
908 | + break; |
|
909 | 909 | } |
910 | 910 | } |
911 | 911 |
@@ -53,15 +53,15 @@ |
||
53 | 53 | $element['hidden_name']['#attributes']['class'] = 'field-name'; |
54 | 54 | // Add target classes for the update selects behavior. |
55 | 55 | switch ($element['#row_type']) { |
56 | - case 'add_new_field': |
|
57 | - $element['type']['#attributes']['class'] = 'content-field-type-select'; |
|
58 | - $element['widget_type']['#attributes']['class'] = 'content-widget-type-select'; |
|
59 | - break; |
|
60 | - case 'add_existing_field': |
|
61 | - $element['field_name']['#attributes']['class'] = 'content-field-select'; |
|
62 | - $element['widget_type']['#attributes']['class'] = 'content-widget-type-select'; |
|
63 | - $element['label']['#attributes']['class'] = 'content-label-textfield'; |
|
64 | - break; |
|
56 | + case 'add_new_field': |
|
57 | + $element['type']['#attributes']['class'] = 'content-field-type-select'; |
|
58 | + $element['widget_type']['#attributes']['class'] = 'content-widget-type-select'; |
|
59 | + break; |
|
60 | + case 'add_existing_field': |
|
61 | + $element['field_name']['#attributes']['class'] = 'content-field-select'; |
|
62 | + $element['widget_type']['#attributes']['class'] = 'content-widget-type-select'; |
|
63 | + $element['label']['#attributes']['class'] = 'content-label-textfield'; |
|
64 | + break; |
|
65 | 65 | } |
66 | 66 | foreach (element_children($element) as $child) { |
67 | 67 | $row->{$child} = drupal_render($element[$child]); |
@@ -15,44 +15,44 @@ |
||
15 | 15 | $values = array(); |
16 | 16 | $types = content_profile_get_types('types'); |
17 | 17 | switch ($type) { |
18 | - case 'user': |
|
19 | - foreach($types as $type_name => $type) { |
|
20 | - if (isset($object)) { |
|
21 | - $profile = content_profile_load($type_name, $object->uid); |
|
22 | - } |
|
23 | - else { |
|
24 | - global $user; |
|
25 | - $profile = content_profile_load($type_name, $user->uid); |
|
26 | - } |
|
27 | - $fields = content_types($type_name); |
|
28 | - foreach ($fields['fields'] as $field_name => $field) { |
|
29 | - if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
|
30 | - $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']); |
|
31 | - $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value']; |
|
32 | - } |
|
18 | + case 'user': |
|
19 | + foreach($types as $type_name => $type) { |
|
20 | + if (isset($object)) { |
|
21 | + $profile = content_profile_load($type_name, $object->uid); |
|
22 | + } |
|
23 | + else { |
|
24 | + global $user; |
|
25 | + $profile = content_profile_load($type_name, $user->uid); |
|
26 | + } |
|
27 | + $fields = content_types($type_name); |
|
28 | + foreach ($fields['fields'] as $field_name => $field) { |
|
29 | + if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
|
30 | + $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']); |
|
31 | + $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value']; |
|
33 | 32 | } |
34 | 33 | } |
35 | - break; |
|
34 | + } |
|
35 | + break; |
|
36 | 36 | |
37 | - case 'flag_friend': |
|
38 | - if(!empty($object)) { |
|
39 | - foreach($types as $type_name => $type) { |
|
40 | - $profile_requestor = content_profile_load($type_name, $object->friend->uid); |
|
41 | - $profile_requestee = content_profile_load($type_name, $object->uid); |
|
37 | + case 'flag_friend': |
|
38 | + if(!empty($object)) { |
|
39 | + foreach($types as $type_name => $type) { |
|
40 | + $profile_requestor = content_profile_load($type_name, $object->friend->uid); |
|
41 | + $profile_requestee = content_profile_load($type_name, $object->uid); |
|
42 | 42 | |
43 | - $fields = content_types($type_name); |
|
44 | - foreach ($fields['fields'] as $field_name => $field) { |
|
45 | - if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
|
46 | - $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']); |
|
47 | - $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value']; |
|
43 | + $fields = content_types($type_name); |
|
44 | + foreach ($fields['fields'] as $field_name => $field) { |
|
45 | + if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
|
46 | + $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']); |
|
47 | + $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value']; |
|
48 | 48 | |
49 | - $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']); |
|
50 | - $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value']; |
|
51 | - } |
|
49 | + $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']); |
|
50 | + $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value']; |
|
52 | 51 | } |
53 | 52 | } |
54 | 53 | } |
55 | - break; |
|
54 | + } |
|
55 | + break; |
|
56 | 56 | } |
57 | 57 | return $values; |
58 | 58 | } |
@@ -234,21 +234,21 @@ discard block |
||
234 | 234 | */ |
235 | 235 | function content_profile_node_type($op, $info) { |
236 | 236 | switch ($op) { |
237 | - case 'delete': |
|
238 | - variable_del('content_profile_use_'. $info->type); |
|
239 | - variable_del('content_profile_'. $info->type); |
|
240 | - break; |
|
241 | - case 'update': |
|
242 | - if (!empty($info->old_type) && $info->old_type != $info->type) { |
|
243 | - if (is_content_profile($info->old_type)) { |
|
244 | - $settings = variable_get('content_profile_'. $info->old_type, array()); |
|
245 | - variable_del('content_profile_use_'. $info->old_type); |
|
246 | - variable_del('content_profile_'. $info->old_type); |
|
247 | - variable_set('content_profile_use_'. $info->type, 1); |
|
248 | - variable_set('content_profile_'. $info->type, $settings); |
|
249 | - } |
|
237 | + case 'delete': |
|
238 | + variable_del('content_profile_use_'. $info->type); |
|
239 | + variable_del('content_profile_'. $info->type); |
|
240 | + break; |
|
241 | + case 'update': |
|
242 | + if (!empty($info->old_type) && $info->old_type != $info->type) { |
|
243 | + if (is_content_profile($info->old_type)) { |
|
244 | + $settings = variable_get('content_profile_'. $info->old_type, array()); |
|
245 | + variable_del('content_profile_use_'. $info->old_type); |
|
246 | + variable_del('content_profile_'. $info->old_type); |
|
247 | + variable_set('content_profile_use_'. $info->type, 1); |
|
248 | + variable_set('content_profile_'. $info->type, $settings); |
|
250 | 249 | } |
251 | - break; |
|
250 | + } |
|
251 | + break; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -292,33 +292,33 @@ discard block |
||
292 | 292 | global $user; |
293 | 293 | |
294 | 294 | switch ($op) { |
295 | - case 'categories': |
|
296 | - $data = array(); |
|
297 | - foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) { |
|
298 | - $data[] = array( |
|
299 | - 'name' => $type, |
|
300 | - 'title' => drupal_ucfirst($type_name), |
|
301 | - 'weight' => content_profile_get_settings($type, 'weight') + 1, |
|
302 | - ); |
|
303 | - } |
|
304 | - return $data; |
|
295 | + case 'categories': |
|
296 | + $data = array(); |
|
297 | + foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) { |
|
298 | + $data[] = array( |
|
299 | + 'name' => $type, |
|
300 | + 'title' => drupal_ucfirst($type_name), |
|
301 | + 'weight' => content_profile_get_settings($type, 'weight') + 1, |
|
302 | + ); |
|
303 | + } |
|
304 | + return $data; |
|
305 | 305 | |
306 | - case 'view': |
|
307 | - $account->content['content_profile'] = content_profile_show_profiles($account->uid); |
|
308 | - break; |
|
306 | + case 'view': |
|
307 | + $account->content['content_profile'] = content_profile_show_profiles($account->uid); |
|
308 | + break; |
|
309 | 309 | |
310 | - case 'delete': |
|
311 | - // Retrieve all profile nodes (in any language) for this user by issueing an SQL query. |
|
312 | - if ($types = content_profile_get_types()) { |
|
313 | - $condition = array_fill(0, count($types), "type = '%s'"); |
|
314 | - $arguments = array_merge(array_keys($types), array($account->uid)); |
|
310 | + case 'delete': |
|
311 | + // Retrieve all profile nodes (in any language) for this user by issueing an SQL query. |
|
312 | + if ($types = content_profile_get_types()) { |
|
313 | + $condition = array_fill(0, count($types), "type = '%s'"); |
|
314 | + $arguments = array_merge(array_keys($types), array($account->uid)); |
|
315 | 315 | |
316 | - $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments); |
|
317 | - while ($node = db_fetch_object($result)) { |
|
318 | - _content_profile_node_delete($node); |
|
319 | - } |
|
316 | + $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments); |
|
317 | + while ($node = db_fetch_object($result)) { |
|
318 | + _content_profile_node_delete($node); |
|
320 | 319 | } |
321 | - break; |
|
320 | + } |
|
321 | + break; |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 |
@@ -55,10 +55,10 @@ |
||
55 | 55 | elseif ($op == 'view') { |
56 | 56 | $block = array(); |
57 | 57 | switch ($delta) { |
58 | - case 0: |
|
59 | - drupal_add_js(drupal_get_path('module', 'mobile_menu_toggle') . '/mobile_menu_toggle.js'); |
|
60 | - $block['content'] = theme('mobile_menu_toggle'); |
|
61 | - break; |
|
58 | + case 0: |
|
59 | + drupal_add_js(drupal_get_path('module', 'mobile_menu_toggle') . '/mobile_menu_toggle.js'); |
|
60 | + $block['content'] = theme('mobile_menu_toggle'); |
|
61 | + break; |
|
62 | 62 | } |
63 | 63 | return $block; |
64 | 64 | } |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | $variables = user_mail_tokens($params['recipient'], $language); |
107 | 107 | $variables = array_merge($variables, _pm_email_notify_token($params['recipient'], $params['message'], $language)); |
108 | 108 | switch ($key) { |
109 | - case 'notice': |
|
110 | - $message['subject'] = t(variable_get('pm_email_notify_subject', 'New private message at !site.'), $variables, $language->language); |
|
111 | - $message['body'] = t(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $variables, $language->language); |
|
112 | - break; |
|
109 | + case 'notice': |
|
110 | + $message['subject'] = t(variable_get('pm_email_notify_subject', 'New private message at !site.'), $variables, $language->language); |
|
111 | + $message['body'] = t(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $variables, $language->language); |
|
112 | + break; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -151,42 +151,42 @@ discard block |
||
151 | 151 | */ |
152 | 152 | function pm_email_notify_user($op, &$edit, &$account, $category = NULL) { |
153 | 153 | switch ($op) { |
154 | - case 'form': |
|
155 | - if ($category == 'account' && privatemsg_user_access('read privatemsg', $account)) { |
|
156 | - $form['enable_pm_mail'] = array( |
|
157 | - '#type' => 'fieldset', |
|
158 | - '#title' => t('Privatemsg e-mail notification'), |
|
159 | - '#collapsible' => TRUE, |
|
160 | - '#collapsed' => FALSE, |
|
161 | - '#weight' => 10, |
|
162 | - ); |
|
163 | - $form['enable_pm_mail']['pm_send_notifications'] = array( |
|
164 | - '#type' => 'checkbox', |
|
165 | - '#title' => t('Receive email notification for incoming private messages'), |
|
166 | - '#default_value' => _pm_email_notify_is_enabled($account->uid), |
|
167 | - ); |
|
168 | - } |
|
169 | - return $form; |
|
154 | + case 'form': |
|
155 | + if ($category == 'account' && privatemsg_user_access('read privatemsg', $account)) { |
|
156 | + $form['enable_pm_mail'] = array( |
|
157 | + '#type' => 'fieldset', |
|
158 | + '#title' => t('Privatemsg e-mail notification'), |
|
159 | + '#collapsible' => TRUE, |
|
160 | + '#collapsed' => FALSE, |
|
161 | + '#weight' => 10, |
|
162 | + ); |
|
163 | + $form['enable_pm_mail']['pm_send_notifications'] = array( |
|
164 | + '#type' => 'checkbox', |
|
165 | + '#title' => t('Receive email notification for incoming private messages'), |
|
166 | + '#default_value' => _pm_email_notify_is_enabled($account->uid), |
|
167 | + ); |
|
168 | + } |
|
169 | + return $form; |
|
170 | 170 | |
171 | - case 'submit': |
|
172 | - if (isset($edit['pm_send_notifications']) && privatemsg_user_access('read privatemsg', $account)) { |
|
173 | - $pm_email_enabled = $edit['pm_send_notifications']; |
|
174 | - unset($edit['pm_send_notifications']); |
|
175 | - // Update database entry with user preference. |
|
176 | - $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid)); |
|
177 | - if ($exists) { |
|
178 | - // If there is an existing entry, update. |
|
179 | - db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid); |
|
180 | - } |
|
181 | - else { |
|
182 | - // If not, create a new one. |
|
183 | - db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid); |
|
184 | - } |
|
185 | - } |
|
186 | - break; |
|
171 | + case 'submit': |
|
172 | + if (isset($edit['pm_send_notifications']) && privatemsg_user_access('read privatemsg', $account)) { |
|
173 | + $pm_email_enabled = $edit['pm_send_notifications']; |
|
174 | + unset($edit['pm_send_notifications']); |
|
175 | + // Update database entry with user preference. |
|
176 | + $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid)); |
|
177 | + if ($exists) { |
|
178 | + // If there is an existing entry, update. |
|
179 | + db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid); |
|
180 | + } |
|
181 | + else { |
|
182 | + // If not, create a new one. |
|
183 | + db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid); |
|
184 | + } |
|
185 | + } |
|
186 | + break; |
|
187 | 187 | |
188 | - case 'delete': |
|
189 | - db_query("DELETE FROM {pm_email_notify} WHERE user_id = %d", $account->uid); |
|
190 | - break; |
|
188 | + case 'delete': |
|
189 | + db_query("DELETE FROM {pm_email_notify} WHERE user_id = %d", $account->uid); |
|
190 | + break; |
|
191 | 191 | } |
192 | 192 | } |
@@ -405,26 +405,26 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | switch ($form_state['values']['op']) { |
408 | - case t('Save filter'): |
|
409 | - $filter = array(); |
|
410 | - if (!empty($form_state['values']['tags'])) { |
|
411 | - $filter['tags'] = $form_state['values']['tags']; |
|
412 | - } |
|
413 | - if (!empty($form_state['values']['author'])) { |
|
414 | - $filter['author'] = $form_state['values']['author']; |
|
415 | - } |
|
416 | - if (!empty($form_state['values']['search'])) { |
|
417 | - $filter['search'] = $form_state['values']['search']; |
|
418 | - } |
|
419 | - $_SESSION['privatemsg_filter'] = $filter; |
|
420 | - break; |
|
421 | - case t('Filter'): |
|
422 | - drupal_goto($_GET['q'], privatemsg_filter_create_get_query($form_state['values'])); |
|
423 | - return; |
|
424 | - break; |
|
425 | - case t('Reset'): |
|
426 | - $_SESSION['privatemsg_filter'] = array(); |
|
427 | - break; |
|
408 | + case t('Save filter'): |
|
409 | + $filter = array(); |
|
410 | + if (!empty($form_state['values']['tags'])) { |
|
411 | + $filter['tags'] = $form_state['values']['tags']; |
|
412 | + } |
|
413 | + if (!empty($form_state['values']['author'])) { |
|
414 | + $filter['author'] = $form_state['values']['author']; |
|
415 | + } |
|
416 | + if (!empty($form_state['values']['search'])) { |
|
417 | + $filter['search'] = $form_state['values']['search']; |
|
418 | + } |
|
419 | + $_SESSION['privatemsg_filter'] = $filter; |
|
420 | + break; |
|
421 | + case t('Filter'): |
|
422 | + drupal_goto($_GET['q'], privatemsg_filter_create_get_query($form_state['values'])); |
|
423 | + return; |
|
424 | + break; |
|
425 | + case t('Reset'): |
|
426 | + $_SESSION['privatemsg_filter'] = array(); |
|
427 | + break; |
|
428 | 428 | } |
429 | 429 | $form_state['redirect'] = $_GET['q']; |
430 | 430 | } |
@@ -899,9 +899,9 @@ discard block |
||
899 | 899 | */ |
900 | 900 | function privatemsg_filter_user($op, &$edit, &$account, $category = NULL) { |
901 | 901 | switch ($op) { |
902 | - case 'delete': |
|
903 | - // Delete tag information of that user. |
|
904 | - db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid); |
|
905 | - break; |
|
902 | + case 'delete': |
|
903 | + // Delete tag information of that user. |
|
904 | + db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid); |
|
905 | + break; |
|
906 | 906 | } |
907 | 907 | } |
@@ -1437,43 +1437,43 @@ discard block |
||
1437 | 1437 | global $user; |
1438 | 1438 | |
1439 | 1439 | switch ($op) { |
1440 | - case 'view': |
|
1441 | - if ($url = privatemsg_get_link(array($account))) { |
|
1442 | - $account->content['privatemsg_send_new_message'] = array( |
|
1443 | - '#type' => 'markup', |
|
1444 | - '#value' => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())), |
|
1445 | - '#weight' => 10, |
|
1446 | - ); |
|
1447 | - } |
|
1448 | - break; |
|
1449 | - case 'login': |
|
1450 | - if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { |
|
1451 | - $count = privatemsg_unread_count(); |
|
1452 | - if ($count) { |
|
1453 | - drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
|
1454 | - } |
|
1440 | + case 'view': |
|
1441 | + if ($url = privatemsg_get_link(array($account))) { |
|
1442 | + $account->content['privatemsg_send_new_message'] = array( |
|
1443 | + '#type' => 'markup', |
|
1444 | + '#value' => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())), |
|
1445 | + '#weight' => 10, |
|
1446 | + ); |
|
1447 | + } |
|
1448 | + break; |
|
1449 | + case 'login': |
|
1450 | + if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { |
|
1451 | + $count = privatemsg_unread_count(); |
|
1452 | + if ($count) { |
|
1453 | + drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
|
1455 | 1454 | } |
1456 | - break; |
|
1457 | - case 'delete': |
|
1455 | + } |
|
1456 | + break; |
|
1457 | + case 'delete': |
|
1458 | 1458 | |
1459 | - // Load all mids of the messages the user wrote. |
|
1460 | - $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid); |
|
1461 | - $mids = array(); |
|
1462 | - while ($row = db_fetch_array($result)) { |
|
1463 | - $mids[] = $row['mid']; |
|
1464 | - } |
|
1459 | + // Load all mids of the messages the user wrote. |
|
1460 | + $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid); |
|
1461 | + $mids = array(); |
|
1462 | + while ($row = db_fetch_array($result)) { |
|
1463 | + $mids[] = $row['mid']; |
|
1464 | + } |
|
1465 | 1465 | |
1466 | - // Delete messages the user wrote. |
|
1467 | - db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid); |
|
1466 | + // Delete messages the user wrote. |
|
1467 | + db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid); |
|
1468 | 1468 | |
1469 | - if (!empty($mids)) { |
|
1470 | - // Delete recipient entries in {pm_index} of the messages the user wrote. |
|
1471 | - db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids); |
|
1472 | - } |
|
1469 | + if (!empty($mids)) { |
|
1470 | + // Delete recipient entries in {pm_index} of the messages the user wrote. |
|
1471 | + db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids); |
|
1472 | + } |
|
1473 | 1473 | |
1474 | - // Delete recipient entries of that user. |
|
1475 | - db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid); |
|
1476 | - break; |
|
1474 | + // Delete recipient entries of that user. |
|
1475 | + db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid); |
|
1476 | + break; |
|
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | |
@@ -1494,12 +1494,12 @@ discard block |
||
1494 | 1494 | elseif ('view' == $op) { |
1495 | 1495 | $block = array(); |
1496 | 1496 | switch ($delta) { |
1497 | - case 'privatemsg-menu': |
|
1498 | - $block = _privatemsg_block_menu(); |
|
1499 | - break; |
|
1500 | - case 'privatemsg-new': |
|
1501 | - $block = _privatemsg_block_new(); |
|
1502 | - break; |
|
1497 | + case 'privatemsg-menu': |
|
1498 | + $block = _privatemsg_block_menu(); |
|
1499 | + break; |
|
1500 | + case 'privatemsg-new': |
|
1501 | + $block = _privatemsg_block_new(); |
|
1502 | + break; |
|
1503 | 1503 | } |
1504 | 1504 | return $block; |
1505 | 1505 | } |