3 Penny note: none of the queries in this file
4 that are get_something_sql or
5 get_something_select can be converted to use
6 prepared statements because they all have $where
7 that has come from some function somewhere...
12 function ElggProfile ($profile_id) {
18 // ELGG profile system initialisation
19 // ID of profile to view / edit
21 if (!empty($profile_id)) {
22 $this->id
= $profile_id;
27 $page_owner = $profile_id;
29 // Profile initialisation
30 // very strange init sequence from the old main() call follows
31 $this->editfield_defaults();
32 // $this->actions(); // not from here --
33 // $this->upload_foaf();
37 function edit_link () {
46 if (run("permissions:check", "profile")) {
48 $editMsg = __gettext("Click here to edit this profile.");
53 <a href="{$CFG->wwwroot}profile/edit.php?profile_id=$page_owner">$editMsg</a>
57 $run_result .= run("profile:edit:link");
63 function display_name () {
68 if (!isset($name_cache[$this->id
]) ||
(time() - $name_cache[$this->id
]->created
> 60)) {
70 $name_cache[$this->id
]->created
= time();
71 $name_cache[$this->id
]->data
= htmlspecialchars(user_info('name',$this->id
), ENT_COMPAT
, 'utf-8');
74 $run_result = $name_cache[$this->id
]->data
;
78 function display_form () {
86 $body = "<p>\n" . __gettext(" This screen allows you to edit your profile. Blank fields will not show up on your profile screen in any view; you can change the access level for each piece of information in order to prevent it from falling into the wrong hands. For example, we strongly recommend you keep your address to yourself or a few trusted parties.") . "</p>\n";
88 if (run("permissions:check", "profile")) {
90 $profile_username = user_info('username', $page_owner);
92 $body .= "<form action=\"".url
. "profile/edit.php?profile_id=".$page_owner."\" method=\"post\" enctype=\"multipart/form-data\">";
93 $body .= "<div class=\"tabber\">";
95 // Cycle through all defined profile detail fields and display them
97 $profilecat = array( );
99 if (!empty($data['profile:details']) && sizeof($data['profile:details']) > 0) {
101 foreach($data['profile:details'] as $field) {
103 if (is_array($field)) {
104 $flabel = !empty($field[0]) ?
$field[0] : '';
105 $fname = !empty($field[1]) ?
$field[1] : '';
106 $ftype = !empty($field[2]) ?
$field[2] : '';
107 $fblurb = !empty($field[3]) ?
$field[3] : '';
108 $fusertype = !empty($field[4]) ?
$field[4] : '';
111 $fcat = __gettext("Main");
112 // Otherwise map things the new way!
114 $flabel = $field->name
;
115 $fname = $field->internal_name
;
116 $ftype = $field->field_type
;
117 $fblurb = $field->description
;
118 $fusertype = $field->user_type
;
119 $finvisible = $field->invisible
;
120 $frequired = $field->required
;
121 if (!empty($field->category
)) {
122 $fcat = $field->category
;
124 $fcat = __gettext("Main");
128 if (!isset($profilecat[$fcat])) {
129 $profilecat[$fcat] = '';
131 $profilecat[$fcat] .= $this->editfield_display($field);
133 if (sizeof($profilecat) > 0) {
134 foreach($profilecat as $cat => $html) {
136 $body .= "<div class=\"tabbertab\" title=\"$cat\">";
145 $submitMsg = __gettext("Submit details:");
146 $saveProfile = __gettext("Save your profile");
154 <input type
="submit" name
="submit" value
="$saveProfile" />
156 <input type
="hidden" name
="action" value
="profile:edit" />
157 <input type
="hidden" name
="profile_id" value
="$page_owner" />
163 $body .= "<p> </p><form action=\"".url
. "profile/edit.php?profile_id=".$page_owner."\" method=\"post\" enctype=\"multipart/form-data\">";
164 $body .= "<p>" . __gettext("You can import some profile data by uploading a FOAF file here:") . "</p>";
165 $body .=templates_draw(array(
166 'context' => 'databox',
167 'name' => __gettext("Upload a FOAF file:"),
168 'column1' => "<input name=\"foaf_file\" id=\"foaf_file\" type=\"file\" />",
169 'column2' => "<input type=\"submit\" value=\"".__gettext("Upload") . "\" />"
174 <input type="hidden" name="action" value="profile:foaf:upload" />
175 <input type="hidden" name="profile_id" value="$page_owner" />
180 $run_result .= $body;
186 function editfield_defaults () {
189 include($CFG->profilelocation
. "profile.config.php");
193 // the field parameter seems to be an array of unknown structure...
194 function editfield_display ($field) {
199 if (!isset($usertype)) {
200 $usertype = user_type($page_owner);
203 // copy array element with default to ''
205 // If we're dealing with the old-style profile fields
206 if (is_array($field)) {
207 $flabel = !empty($field[0]) ?
$field[0] : '';
208 $fname = !empty($field[1]) ?
$field[1] : '';
209 $ftype = !empty($field[2]) ?
$field[2] : '';
210 $fblurb = !empty($field[3]) ?
$field[3] : '';
211 $fusertype = !empty($field[4]) ?
$field[4] : '';
214 // Otherwise map things the new way!
216 $flabel = $field->name
;
217 $fname = $field->internal_name
;
218 $ftype = $field->field_type
;
219 $fblurb = $field->description
;
220 $fusertype = $field->user_type
;
221 $finvisible = $field->invisible
;
222 $frequired = $field->required
;
225 if (!empty($fusertype) && $fusertype != $usertype) {
235 if (empty($flabel) && empty($fname)) {
239 if (!isset($data['profile:preload'][$fname])) {
240 if (!$value = get_record('profile_data','name',$fname,'owner',$page_owner)) {
243 $value->access
= $CFG->default_access
;
247 $value->value
= $data['profile:preload'][$fname];
248 if (!isset($data['profile:preload:access'][$fname])) {
249 $value->access
= $CFG->default_access
;
251 $value->access
= $data['profile:preload:access'][$fname];
256 $value->access
= "PRIVATE";
259 $name = "<label for=\"$fname\"><b>{$flabel}</b>";
260 if (!empty($fblurb)) {
261 $name .= "<br /><i>" . $fblurb . "</i>";
269 $column1 = display_input_field(array("profiledetails[" . $fname . "]",$value->value
,$ftype,$fname,@$value->ident
,$page_owner));
270 $column2 = "<label>". __gettext("Access Restriction:") ."<br />";
271 $column2 .= run("display:access_level_select",array("profileaccess[".$fname . "]",$value->access
)) . "</label>";
273 $run_result .=templates_draw(array(
274 'context' => 'databox',
276 'column1' => $column1,
277 'column2' => $column2
285 function field_display ($field, $allvalues) {
291 // If we're dealing with the old-style profile fields
292 if (is_array($field)) {
293 $flabel = !empty($field[0]) ?
$field[0] : '';
294 $fname = !empty($field[1]) ?
$field[1] : '';
295 $ftype = !empty($field[2]) ?
$field[2] : '';
296 $fblurb = !empty($field[3]) ?
$field[3] : '';
297 $fusertype = !empty($field[4]) ?
$field[4] : '';
298 // Otherwise map things the new way!
300 $flabel = $field->name
;
301 $fname = $field->internal_name
;
302 $ftype = $field->field_type
;
303 $fblurb = $field->description
;
304 $fusertype = $field->user_type
;
305 $finvisible = $field->invisible
;
306 $frequired = $field->required
;
309 //if (sizeof($field) >= 2) {
311 // $value = get_record('profile_data','name',$field[1],'owner',$this->id);
312 if (is_array($allvalues) && !empty($allvalues)) {
313 foreach($allvalues as $curvalue) {
314 if ($curvalue->name
== stripslashes($fname)) {
316 break; // found it, done!
321 if (!isset($value)) {
325 if ((($value->value
!= "" && $value->value
!= "blank" && !$finvisible))
326 && run("users:access_level_check", $value->access
)) {
328 $column1 = display_output_field(array($value->value
,$ftype,$fname,$flabel,$value->ident
));
329 $run_result .=templates_draw(array(
330 'context' => 'databox1',
332 'column1' => $column1
340 function search ($tagtype, $tagvalue) {
342 global $data, $CFG, $db;
347 foreach($data['profile:details'] as $profiletype) {
348 if ($profiletype[1] == $tagtype && $profiletype[2] == "keywords") {
355 $searchline = "tagtype = " . $db->qstr($tagtype) . " AND tag = " . $db->qstr($tagvalue) . "";
356 $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline;
357 $searchline = str_replace("owner","t.owner",$searchline);
358 $tagvalue = stripslashes($tagvalue);
359 if ($result = get_record_sql('SELECT DISTINCT u.* FROM '.$CFG->prefix
.'tags t
360 LEFT JOIN '.$CFG->prefix
.'users u ON u.ident = t.owner
361 WHERE '.$searchline)) {
362 $profilesMsg = __gettext("Profiles where");
368 $body .= "'".__gettext($tagtype)."' = '".$tagvalue."':";
373 <table
class="userlist">
377 foreach($result as $key => $info) {
379 if (sizeof($tagvalue) > 4) {
382 $friends_username = $info->username
;
383 $friends_name = htmlspecialchars(stripslashes($info->name
), ENT_COMPAT
, 'utf-8');
384 $friends_menu = run("users:infobox:menu",array($info->ident
));
388 <a href
="{$CFG->wwwroot}{$friends_username}/">
389 <img src
="{$CFG->wwwroot}_icon/user/{$info->icon}/w/{$width}" alt
="{$friends_name}" border
="0" /></a
><br
/>
390 <span
class="userdetails">
398 $body .= "</tr><tr>";
406 $run_result .= $body;
412 function search_all_tagtypes () {
416 foreach($data['profile:details'] as $profiletype) {
417 if ($profiletype[2] == "keywords") {
418 $data['search:tagtypes'][] = $profiletype[1];
424 function search_all_tagtypes_rss () {
428 foreach($data['profile:details'] as $profiletype) {
429 if ($profiletype[2] == "keywords") {
430 $data['search:tagtypes:rss'][] = $profiletype[1];
436 function search_ecl ($tagtype, $tagvalue) {
438 global $data, $CFG, $db;
443 foreach($data['profile:details'] as $profiletype) {
444 if ($profiletype[1] == $tagtype && $profiletype[2] == "keywords") {
453 $searchline = "tagtype = " . $db->qstr($tagtype) . " AND tag = " . $db->qstr($tagvalue) . "";
454 $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline;
455 $searchline = str_replace("owner", "t.owner", $searchline);
456 $tagvalue = stripslashes($tagvalue);
457 if ($result = get_record_sql('SELECT DISTINCT u.* FROM '.$CFG->prefix
.'tags t
458 LEFT JOIN '.$CFG->prefix
.'users u ON u.ident = t.owner
459 WHERE '.$searchline)) {
460 foreach($result as $key => $info) {
461 $icon = url
. '_icon/user/'.$post->icon
;
462 $sub_result .= "\t\t\t<item>\n";
463 $sub_result .= "\t\t\t\t<name><![CDATA[" . htmlspecialchars(stripslashes($info->name
), ENT_COMPAT
, 'utf-8') . "]]></name>\n";
464 $sub_result .= "\t\t\t\t<link>" . url
. htmlspecialchars($info->username
, ENT_COMPAT
, 'utf-8') . "</link>\n";
465 $sub_result .= "\t\t\t\t<link>$icon</link>\n";
466 $sub_result .= "\t\t\t</item>\n";
470 if ($sub_result != "") {
472 $run_result .= "\t\t<profiles tagtype=\"".addslashes(htmlspecialchars($tagtype, ENT_COMPAT
, 'utf-8'))."\">\n" . $sub_result . "\t\t</profiles>\n";
480 function search_rss ($tagtype, $tagvalue) {
482 global $data, $CFG, $db;
487 foreach($data['profile:details'] as $profiletype) {
488 if ($profiletype[1] == $tagtype && $profiletype[2] == "keywords") {
495 $searchline = "tagtype = " . $db->qstr($tagtype) . " AND tag = " . $db->qstr($tagvalue) . "";
496 $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline;
497 $searchline = str_replace("owner", "t.owner", $searchline);
498 $tagvalue = stripslashes($tagvalue);
499 if ($result = get_records_sql('SELECT DISTINCT u.* FROM '.$CFG->prefix
.'tags t
500 LEFT JOIN '.$CFG->prefix
.'users u ON u.ident = t.owner
501 WHERE '.$searchline)) {
502 foreach($result as $key => $info) {
503 $run_result .= "\t<item>\n";
504 $run_result .= "\t\t<title><![CDATA['" . htmlspecialchars($tagtype, ENT_COMPAT
, 'utf-8') . "' = " . htmlspecialchars($tagvalue, ENT_COMPAT
, 'utf-8') . " :: " . htmlspecialchars(stripslashes($info->name
), ENT_COMPAT
, 'utf-8') . "]]></title>\n";
505 $run_result .= "\t\t<link>" . url
. htmlspecialchars($info->username
, ENT_COMPAT
, 'utf-8') . "</link>\n";
506 $run_result .= "\t</item>\n";
513 function upload_foaf () {
517 $action = optional_param('action');
518 if (!empty($action) && $action == "profile:foaf:upload" && logged_on
&& run("permissions:check", "profile")) {
519 require_once($CFG->dirroot
.'lib/uploadlib.php');
520 $um = new upload_manager('foaf_file',false,true,0,true);
521 $dir = $CFG->dataroot
. 'tmp/foaf/';
522 if (!$um->process_file_uploads($dir)) {
523 $messages[] = __gettext("There was an error uploading the file. Possibly the file was too large, or the upload was interrupted.");
524 $messages[] = $um->get_errors();
527 $file = $um->get_new_filepath();
528 $foaf = @GetXMLTreeProfile
($file);
530 $data['profile:preload'] = array();
532 if (isset($foaf['RDF:RDF'][0]['PERSON'][0]) && !isset($foaf['RDF:RDF'][0]['FOAF:PERSON'][0])) {
533 $foaf['RDF:RDF'][0]['FOAF:PERSON'][0] = $foaf['RDF:RDF'][0]['PERSON'][0];
536 if (isset($foaf['RDF:RDF'][0]['FOAF:PERSON'][0])) {
538 $foaf = $foaf['RDF:RDF'][0]['FOAF:PERSON'][0];
540 if (!empty($data['foaf:profile']) && sizeof($data['foaf:profile']) > 0) {
541 foreach($data['foaf:profile'] as $foaf_element) {
543 $profile_value = addslashes($foaf_element[0]);
544 $foaf_name = $foaf_element[1];
545 $individual = $foaf_element[2];
546 $resource = $foaf_element[3];
547 if (isset($foaf[strtoupper($foaf_name)])) {
548 $values = $foaf[strtoupper($foaf_name)];
549 foreach($values as $value) {
551 if (trim($value['VALUE']) != "") {
552 $thisvalue = trim($value['VALUE']);
553 } else if (isset($value['ATTRIBUTES']['DC:TITLE']) && trim($value['ATTRIBUTES']['DC:TITLE'] != "")){
554 $thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
555 } else if (isset($value['ATTRIBUTES']['RDF:RESOURCE']) && trim($value['ATTRIBUTES']['RDF:RESOURCE'] != "")) {
556 $thisvalue = trim($value['ATTRIBUTES']['RDF:RESOURCE']);
558 if ($thisvalue != "") {
559 if (!isset($data['profile:preload'][$profile_value])) {
560 $data['profile:preload'][$profile_value] = $thisvalue;
562 $data['profile:preload'][$profile_value] .= ", " . $thisvalue;
569 if (!empty($foaf['VCARD:ADR']) && sizeof($foaf['VCARD:ADR']) > 0) {
570 if (!empty($data['vcard:profile:adr']) && sizeof($data['vcard:profile:adr']) > 0) {
572 $foaf = $foaf['VCARD:ADR'][0];
574 foreach($data['vcard:profile:adr'] as $foaf_element) {
575 $profile_value = addslashes($foaf_element[0]);
576 $foaf_name = $foaf_element[1];
577 $individual = $foaf_element[2];
578 $resource = $foaf_element[3];
579 if (isset($foaf[strtoupper($foaf_name)])) {
580 $values = $foaf[strtoupper($foaf_name)];
581 foreach($values as $value) {
583 if (trim($value['VALUE']) != "") {
584 $thisvalue = trim($value['VALUE']);
585 } else if (isset($value['ATTRIBUTES']['DC:TITLE']) && trim($value['ATTRIBUTES']['DC:TITLE'] != "")){
586 $thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
587 } else if (isset($value['ATTRIBUTES']['RDF:RESOURCE']) && trim($value['ATTRIBUTES']['RDF:RESOURECE'] != "")) {
588 $thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
590 if ($thisvalue != "") {
591 if (!isset($data['profile:preload'][$profile_value])) {
592 $data['profile:preload'][$profile_value] = $thisvalue;
594 $data['profile:preload'][$profile_value] .= ", " . $thisvalue;
603 $messages[] = __gettext("Data from your FOAF file has been preloaded. You must click Save at the bottom of the page for the changes to take effect.");
607 $messages[] = __gettext("Error: supplied file did not appear to be a FOAF file.");
621 $usertype = user_type($page_owner);
623 // Cycle through all defined profile detail fields and display them
625 if (!empty($data['profile:details']) && sizeof($data['profile:details']) > 0) {
627 if ($allvalues = get_records('profile_data','owner',$this->id
)) {
628 foreach($data['profile:details'] as $field) {
629 if (is_array($field)) {
630 $flabel = !empty($field[0]) ?
$field[0] : '';
631 $fname = !empty($field[1]) ?
$field[1] : '';
632 $ftype = !empty($field[2]) ?
$field[2] : '';
633 $fblurb = !empty($field[3]) ?
$field[3] : '';
634 $fusertype = !empty($field[4]) ?
$field[4] : '';
637 // Otherwise map things the new way!
639 $flabel = $field->name
;
640 $fname = $field->internal_name
;
641 $ftype = $field->field_type
;
642 $fblurb = $field->description
;
643 $fusertype = $field->user_type
;
644 $finvisible = $field->invisible
;
645 $frequired = $field->required
;
647 if (empty($fusertype) ||
$usertype == $fusertype) {
648 // $field is an array, with the name
649 // of the field in $field[0]
650 $run_result .= $this->field_display($field,$allvalues);
659 function generate_foaf_fields ($user_id) {
663 // If $data['foaf:profile'] is set and has elements in it ...
665 $user_id = (int) $user_id;
668 $where = run("users:access_level_sql_where",$_SESSION['userid']);
670 if (!empty($data['foaf:profile']) && sizeof($data['foaf:profile']) > 0) {
672 foreach($data['foaf:profile'] as $foaf_element) {
678 $profile_value = addslashes($foaf_element[0]);
679 $foaf_name = $foaf_element[1];
680 $individual = $foaf_element[2];
681 $resource = $foaf_element[3];
682 foreach($data['profile:details'] as $profile_element) {
683 if ($profile_element[1] == $profile_value) {
684 $value_type = $profile_element[2];
688 if ($value_type != "keywords") {
689 $result = get_records_select('profile_data',"name = '$profile_value' AND ($where) AND owner = ".$user_id,'','ident,value');
691 $result = get_records_select('tags',"tagtype = '$profile_value' and ($where) AND owner = $user_id",'','ident,tag AS value');
693 if (is_array($result)) {
694 if ($individual == "individual") {
695 foreach($result as $element) {
696 if (trim($element->value
) != "") {
697 $value = stripslashes($element->value
);
698 if ($resource == "resource") {
699 $enclosure = "\t\t<" . $foaf_name . " ";
700 if ($value_type == "keywords") {
701 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
702 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
704 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
706 $foaf_elements .= $enclosure;
708 $enclosure = "\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars(($value), ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
709 $foaf_elements .= $enclosure;
714 foreach($result as $element) {
715 if (trim($element->value
) != "") {
719 $value .= stripslashes($element->value
);
721 if ($resource == "resource") {
722 $enclosure = "\t\t<" . $foaf_name . " ";
723 if ($value_type == "keywords") {
724 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
725 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
727 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
730 $enclosure = "\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars(($value), ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
733 $foaf_elements .= $enclosure;
741 $run_result .= $foaf_elements;
745 function generate_vcard_adr_fields ($user_id) {
749 // If $data['vcard:profile:adr'] is set and has elements in it ...
751 $user_id = (int)$user_id;
754 $where = run("users:access_level_sql_where",$_SESSION['userid']);
756 if (!empty($data['vcard:profile:adr']) && sizeof($data['vcard:profile:adr']) > 0) {
758 foreach($data['vcard:profile:adr'] as $foaf_element) {
764 $profile_value = addslashes($foaf_element[0]);
765 $foaf_name = $foaf_element[1];
766 $individual = $foaf_element[2];
767 $resource = $foaf_element[3];
768 foreach($data['profile:details'] as $profile_element) {
769 if ($profile_element[1] == $profile_value) {
770 $value_type = $profile_element[2];
774 if ($value_type != "keywords") {
775 $result = get_records_select('profile_data',"name = '$profile_value' AND ($where) AND owner = ".$user_id,'','ident,value');
777 $result = get_records_select('tags',"tagtype = '$profile_value' and ($where) AND owner = $user_id",'','ident,tag AS value');
779 if (is_array($result)) {
780 if ($individual == "individual") {
781 foreach($result as $element) {
782 if (trim($element->value
) != "") {
783 $value = stripslashes($element->value
);
784 if ($resource == "resource") {
785 $enclosure = "\t\t\t<" . $foaf_name . " ";
786 if ($value_type == "keywords") {
787 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
788 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
790 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
792 $foaf_elements .= $enclosure;
794 $enclosure = "\t\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
795 $foaf_elements .= $enclosure;
800 foreach($result as $element) {
801 if (trim($element->value
) != "") {
805 $value .= stripslashes($element->value
);
807 if ($resource == "resource") {
808 $enclosure = "\t\t\t<" . $foaf_name . " ";
809 if ($value_type == "keywords") {
810 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
811 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
813 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
816 $enclosure = "\t\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
819 $foaf_elements .= $enclosure;
827 $run_result .= $foaf_elements;
831 function groups_delete ($group_id) {
834 // When an access group is deleted, revert all profile items restricted to that group to private
835 $group_id = (int)$group_id;
837 if (!empty($group_id) && logged_on
) {
838 // Create 'private' access string for current user
839 $access = "user" . $_SESSION['userid'];
841 // Update profile_data table, setting access to $access
842 // where the owner is the current user and access = 'group$group_id'
843 return set_field('profile_data','access',$access,'access','group'.$group_id,'owner',$USER->ident
);
852 // ELGG Profile system
856 // Initialisation for the search function
857 $function['search:init'][] = path
. "units/profile/function_init.php";
858 $function['search:init'][] = path
. "units/profile/function_editfield_defaults.php";
859 $function['search:all:tagtypes'][] = path
. "units/profile/function_search_all_tagtypes.php";
860 $function['search:all:tagtypes:rss'][] = path
. "units/profile/function_search_all_tagtypes_rss.php";
862 // Function to search through profiles
863 $function['search:display_results'][] = path
. "units/profile/function_search.php";
864 $function['search:display_results:rss'][] = path
. "units/profile/function_search_rss.php";
866 // Functions to view and edit individual profile fields
867 $function['profile:editfield:display'][] = path
. "units/profile/function_editfield_display.php";
868 $function['profile:field:display'][] = path
. "units/profile/function_field_display.php";
870 // Function to view all profile fields
871 $function['profile:view'][] = path
. "units/profile/function_view.php";
873 // Function to display user's name
874 $function['profile:display:name'][] = path
. "units/profile/function_display_name.php";
876 $function['profile:user:info'][] = path
. "units/profile/profile_user_info.php";
879 $function['content:profile:edit'][] = path
. "units/profile/content_edit.php";
881 // Establish permissions
882 $function['permissions:check'][] = path
. "units/profile/permissions_check.php";
885 $function['foaf:generate:fields'][] = path
. "units/profile/generate_foaf_fields.php";
886 $function['vcard:generate:fields:adr'][] = path
. "units/profile/generate_vcard_adr_fields.php";
888 // Actions to perform when an access group is deleted
889 $function['groups:delete'][] = path
. "units/profile/groups_delete.php";
896 function permissions_check ($object) {
898 if ($object === "profile" && $page_owner == $_SESSION['userid']) {
904 function profile_user_info () {
909 // If this is someone else's portfolio, display the user's icon
910 $run_result = '<div class="box_user">';
912 $info = get_record('users','ident',$page_owner);
914 if (!$tagline = get_field_sql('SELECT value FROM '.$CFG->prefix
.'profile_data
915 WHERE owner = '.$page_owner." AND name = 'minibio'
916 AND (".run("users:access_level_sql_where",$USER->ident
).")")) {
920 $icon = '<img alt="" src="' . url
. '_icon/user/' . $info->icon
. '/w/67" />';
921 $name = stripslashes($info->name
);
922 $url = url
. $info->username
. "/";
924 $body =templates_draw(array(
925 'context' => 'ownerbox',
927 'profileurl' => $url,
929 'tagline' => $tagline,
931 'usermenu' => run("users:infobox:menu:text",array($page_owner))
935 if ($page_owner != -1) {
936 if ($page_owner != $_SESSION['userid']) {
937 $title = __gettext("Profile Owner");
939 $title = __gettext("You");
943 $run_result .=templates_draw(array(
944 'context' => 'contentholder',
951 $run_result .= "</div>";
956 } // End Class ElggProfile