You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only mandatory configuration for the module is selecting a CB list to show the users from. all other settings have default options which you can change.
@@ -27,3 +27,9 @@ The only mandatory configuration for the module is selecting a CB list to show t
27
27
### rule examples;
28
28
A basic set of rules will be created when creating the module.
29
29
When creating custom tags make sure the tags that you are using within always have a value. For example see the avatar rule and show_avatar rule.
30
+
31
+
You can also show fields only to specific usergroups.
32
+
For existing databace fields like cb_example you can also create a rule to set autorisation on by creatign the following rule:
$additional_names .= " UNION SELECT '". strtolower($value->tag_name). "' AS name, 'custom' as type";
48
+
$additional_names .= " UNION SELECT '". strtolower($value->tag_name). "' AS name, 'rule' as type ";
173
49
174
-
$i++;
50
+
$i++;
175
51
}
176
-
52
+
177
53
178
54
// get all the fields that could possibly be part of template to be replaced to get us something to loop through. Also add id and user_id as fields.
179
55
$db = JFactory::getDbo();
180
-
$query = "SELECT name, type FROM #__comprofiler_fields WHERE (#__comprofiler_fields.table = '#__users' OR #__comprofiler_fields.table = '#__comprofiler') and name not in ('password','params')
181
-
UNION SELECT 'id' AS name, '' as type
182
-
UNION SELECT 'user_id' AS name, '' as type ";
56
+
$query = "SELECT fields.name, fields.type FROM #__comprofiler_fields as fields
57
+
WHERE (fields.table = '#__users' OR fields.table = '#__comprofiler') and name not in ('password','params')
58
+
UNION SELECT 'id' AS name, 'id' as type
59
+
UNION SELECT 'user_id' AS name, 'id' as type ";
183
60
// add additional names created in the parameters
184
61
$query .= $additional_names ;
185
62
// retrieve fields from type images as first. this way other tags in the htmlcode then from the image will also be replaced without additional while loop
186
-
$query .= " order by FIELD(type,'image') desc";
63
+
$query .= " order by FIELD(type,'image') desc";
187
64
$db->setQuery($query);
188
65
$fields = $db->loadAssocList();
189
-
190
-
// create an one row array with paramtofind to use for the while check
191
-
$search_paramtofind = array ();
192
-
foreach ($fieldsas$field) {
193
-
$search_paramtofind[] = "[".$field['name']."]";
194
-
}
195
66
196
-
197
-
198
67
199
68
$result=''; //reset result
200
69
// Get the parameters
@@ -259,17 +128,15 @@ public static function getData( $params )
$query = "select * from #__users inner join #__comprofiler on #__users.id = #__comprofiler.user_id WHERE #__users.id =".$user_id;
158
+
// echo $query;
159
+
$db->setQuery($query);
160
+
$person = $db->loadAssoc();
161
+
162
+
$after_str = $before_str;
163
+
164
+
165
+
// The while will only run multiple times if you have complex rules like using [canvas] in your avatar htmlcode.
166
+
// With this while loop we are certain that all paramtofind will be replaced.
167
+
$i=0;
168
+
while (/*(str_replace($search_paramtofind, '', $after_str) !== $after_str) and*/$i<>4){
169
+
$i++; // safety count to stop the loop if the user created one. While will run expected once or twice to replace everything.
170
+
171
+
172
+
foreach ($fieldsas$field) { //for every field that may be in the before_str
173
+
$paramtofind = "[".$field['name']."]";
174
+
$fieldtouse = $field['name'];
175
+
$fieldtype = $field['type'];
176
+
177
+
178
+
/*set value to insert for normal fields*/
179
+
$datatoinsert = null;
180
+
181
+
//check if the fieldtouse exist (or is null)
182
+
if (isset($person[$fieldtouse]) ) {
183
+
$datatoinsert = $person[$fieldtouse];
184
+
}
185
+
186
+
187
+
/*set value to insert for images */
188
+
// if it is an image check the approved and create full url
189
+
//if there is an '[fieldname]approved' column it is an image. By checking the exsting of the column instead of type 'image' it will also be aplied to rules with the same name.
190
+
$show = true;
191
+
if (isset($person[$fieldtouse.'approved']) ) {
192
+
193
+
if ( $person[$fieldtouse.'approved']==0or (empty($datatoinsert)) ) {
194
+
$datatoinsert = 'no image available';
195
+
} else {
196
+
//url to the default canvas images are incorrect in stored in the database
if ( empty($rules[$rule_id]['accesslevel']) orarray_sum(array_count_values(array_intersect($user_accesslevels, $rules[$rule_id]['accesslevel'])))>0 ) { // if not set show the data
246
+
$autorised = true;
247
+
}
248
+
249
+
if ($autorised == true) {
250
+
// check if (data is not empty or that it is a rule tag created) and incase of an image tag if there is an image to show.
0 commit comments