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(get_field('users','name','ident',$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 = run("users:id_to_name",$page_owner);
94 $body .= "<form action=\"".url
. "profile/edit.php?profile_id=".$page_owner."\" method=\"post\" enctype=\"multipart/form-data\">";
95 $body .= "<p>" . gettext("You can import some profile data by uploading a FOAF file here:") . "</p>";
96 $body .=templates_draw(array(
97 'context' => 'databox',
98 'name' => gettext("Upload a FOAF file:"),
99 'column1' => "<input name=\"foaf_file\" id=\"foaf_file\" type=\"file\" />",
100 'column2' => "<input type=\"submit\" value=\"".gettext("Upload") . "\" />"
105 <input type="hidden" name="action" value="profile:foaf:upload" />
106 <input type="hidden" name="profile_id" value="$page_owner" />
110 $body .= "<p>" .gettext("Or you can fill in your profile directly below:") . "</p>";
111 $body .= "<form action=\"".url
. "profile/edit.php?profile_id=".$page_owner."\" method=\"post\">";
113 // Cycle through all defined profile detail fields and display them
115 if (!empty($data['profile:details']) && sizeof($data['profile:details']) > 0) {
117 foreach($data['profile:details'] as $field) {
118 $body .= $this->editfield_display($field);
123 $submitMsg = gettext("Submit details:");
124 $saveProfile = gettext("Save your profile");
130 <input type
="submit" name
="submit" value
="$saveProfile" />
132 <input type
="hidden" name
="action" value
="profile:edit" />
133 <input type
="hidden" name
="profile_id" value
="$page_owner" />
139 $run_result .= $body;
145 function editfield_defaults () {
149 // Initial profile data
151 /* Profile info is of the format:
153 $data['profile:details'][] = array(
155 Short / unique internal name,
157 User instructions for entering data
160 $data['profile:details'][] = array(gettext("Interests"),"interests","keywords",gettext("Separated with commas."));
162 Additions to this data structure will input/output a corresponding FOAF field
164 $data['foaf:profile'][] = array(
165 Short / unique internal name,
166 Corresponding FOAF schema field
167 "collated" or "individual" - whether multiple data elements (eg interests)
168 should be in separate tags ("individual") or
169 in the same tag separated by commas
171 "resource" or "enclosed" - whether the data is an rdf:resource="" attribute
172 or enclosed within the tag
176 $data['foaf:profile'][] = array("interests","foaf:interest");
178 Also present is $data['vcard:profile:adr'][] for VCard ADR elements within the FOAF file
180 $data['vcard:profile:adr'][] = array("streetaddress","vCard:Street","collated");
183 $data['profile:details'][] = array(gettext("Who am I?"),"biography","longtext",gettext("A short introduction for you."));
184 $data['foaf:profile'][] = array("biography","bio:olb","collated","enclosed");
186 $data['profile:details'][] = array(gettext("Brief description"),"minibio","text",gettext("For use in your sidebar profile."));
188 // $data['profile:details'][] = array(gettext("Postal address"),"postaladdress","mediumtext");
189 $data['profile:details'][] = array(gettext("Street address"),"streetaddress","text");
190 $data['vcard:profile:adr'][] = array("streetaddress","vCard:Street","collated","enclosed");
192 $data['profile:details'][] = array(gettext("Town"),"town","keywords");
193 $data['vcard:profile:adr'][] = array("town","vCard:Locality","collated","enclosed");
195 $data['profile:details'][] = array(gettext("State / Region"),"state","keywords");
196 $data['vcard:profile:adr'][] = array("state","vCard:Region","collated","enclosed");
198 $data['profile:details'][] = array(gettext("Postal code"),"postcode","text");
199 $data['vcard:profile:adr'][] = array("postcode","vCard:Pcode","collated","enclosed");
201 $data['profile:details'][] = array(gettext("Country"),"country","keywords");
202 $data['vcard:profile:adr'][] = array("country","vCard:Country","collated","enclosed");
204 $data['profile:details'][] = array(gettext("Email address"),"emailaddress","email");
206 $data['profile:details'][] = array(gettext("Work telephone"),"workphone","text");
207 $data['foaf:profile'][] = array("workphone","foaf:phone","individual","resource");
209 $data['profile:details'][] = array(gettext("Home telephone"),"homephone","text");
210 $data['foaf:profile'][] = array("homephone","foaf:phone","individual","resource");
212 $data['profile:details'][] = array(gettext("Mobile telephone"),"mobphone","text");
213 $data['foaf:profile'][] = array("mobphone","foaf:phone","individual","resource");
215 $data['profile:details'][] = array(gettext("Official website address"),"workweb","web",gettext("The URL to your official website, if you have one."));
216 $data['foaf:profile'][] = array("workweb","foaf:workplaceHomepage","individual","resource");
218 $data['profile:details'][] = array(gettext("Personal website address"),"personalweb","web",gettext("The URL to your personal website, if you have one."));
219 $data['foaf:profile'][] = array("personalweb","foaf:homepage","individual","resource");
221 $data['profile:details'][] = array(gettext("ICQ number"),"icq","icq");
222 $data['foaf:profile'][] = array("icq","foaf:icqChatID","individual","enclosed");
224 $data['profile:details'][] = array(gettext("MSN chat"),"msn","msn");
225 $data['foaf:profile'][] = array("msn","foaf:msnChatID","individual","enclosed");
227 $data['profile:details'][] = array(gettext("AIM screenname"),"aim","aim");
228 $data['foaf:profile'][] = array("aim","foaf:aimChatID","individual","enclosed");
230 $data['profile:details'][] = array(gettext("Skype username"),"skype","skype");
232 $data['profile:details'][] = array(gettext("Jabber username"),"jabber","text");
233 $data['foaf:profile'][] = array("jabber","foaf:jabberChatID","individual","enclosed");
235 $data['profile:details'][] = array(gettext("Interests"),"interests","keywords",gettext("Separated with commas."));
236 $data['foaf:profile'][] = array("interests","foaf:interest","individual","resource");
237 // $data['foaf:profile'][] = array("interests","bio:keywords","collated","enclosed");
239 $data['profile:details'][] = array(gettext("Likes"),"likes","keywords",gettext("Separated with commas."));
240 $data['profile:details'][] = array(gettext("Dislikes"),"dislikes","keywords",gettext("Separated with commas."));
241 $data['profile:details'][] = array(gettext("Occupation"),"occupation","text");
242 $data['profile:details'][] = array(gettext("Industry"),"industry","keywords");
244 $data['profile:details'][] = array(gettext("Company / Institution"),"organisation","text");
245 $data['foaf:profile'][] = array("organisation","foaf:organization","collated","enclosed");
247 $data['profile:details'][] = array(gettext("Job Title"),"jobtitle","text");
248 $data['profile:details'][] = array(gettext("Job Description"),"jobdescription","text");
249 $data['profile:details'][] = array(gettext("I would like to ..."),"goals","keywords",gettext("Separated with commas."));
250 $data['profile:details'][] = array(gettext("Career Goals"),"careergoals","longtext",gettext("Freeform: let colleagues and potential employers know what you'd like to get out of your career."));
251 $data['profile:details'][] = array(gettext("Level of Education"),"educationlevel","text");
252 $data['profile:details'][] = array(gettext("High School"),"highschool","text");
253 $data['profile:details'][] = array(gettext("University / College"),"university","text");
254 $data['profile:details'][] = array(gettext("Degree"),"universitydegree","text");
255 $data['profile:details'][] = array(gettext("Main Skills"),"skills","keywords",gettext("Separated with commas."));
259 // the field parameter seems to be an array of unknown structure...
260 function editfield_display ($field) {
262 // copy array element with default to ''
263 $flabel = !empty($field[0]) ?
$field[0] : '';
264 $fname = !empty($field[1]) ?
$field[1] : '';
265 $ftype = !empty($field[2]) ?
$field[2] : '';
266 $fblurb = !empty($field[3]) ?
$field[3] : '';
274 if (empty($flabel) && empty($fname)) {
278 if (!isset($data['profile:preload'][$flabel])) {
279 if (!$value = get_record('profile_data','name',$fname,'owner',$page_owner)) {
282 $value->access
= $CFG->default_access
;
286 $value->value
= $data['profile:preload'][$fname];
287 $value->access
= $CFG->default_access
;
291 $name = "<label for=\"$fname\"><b>{$flabel}</b>";
292 if (!empty($fblurb)) {
293 $name .= "<br /><i>" . $fblurb . "</i>";
301 $column1 = display_input_field(array("profiledetails[" . $fname . "]",$value->value
,$ftype,$fname,@$value->ident
,$page_owner));
302 $column2 = "<label>". gettext("Access Restriction:") ."<br />";
303 $column2 .= run("display:access_level_select",array("profileaccess[".$fname . "]",$value->access
)) . "</label>";
305 $run_result .=templates_draw(array(
306 'context' => 'databox',
308 'column1' => $column1,
309 'column2' => $column2
317 function field_display ($field, $allvalues) {
323 if (sizeof($field) >= 2) {
325 // $value = get_record('profile_data','name',$field[1],'owner',$this->id);
327 foreach($allvalues as $curvalue) {
328 if ($curvalue->name
== stripslashes($field[1])) {
330 break; // found it, done!
334 if (!isset($value)) {
338 if ((($value->value
!= "" && $value->value
!= "blank"))
339 && run("users:access_level_check", $value->access
)) {
341 $column1 = display_output_field(array($value->value
,$field[2],$field[1],$field[0],$value->ident
));
342 $run_result .=templates_draw(array(
343 'context' => 'databox1',
345 'column1' => $column1
353 function search ($tagtype, $tagvalue) {
355 global $data, $CFG, $db;
360 foreach($data['profile:details'] as $profiletype) {
361 if ($profiletype[1] == $tagtype && $profiletype[2] == "keywords") {
368 $searchline = "tagtype = " . $db->qstr($tagtype) . " AND tag = " . $db->qstr($tagvalue) . "";
369 $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline;
370 $searchline = str_replace("owner","t.owner",$searchline);
371 $tagvalue = stripslashes($tagvalue);
372 if ($result = get_record_sql('SELECT DISTINCT u.* FROM '.$CFG->prefix
.'tags t
373 LEFT JOIN '.$CFG->prefix
.'users u ON u.ident = t.owner
374 WHERE '.$searchline)) {
375 $profilesMsg = gettext("Profiles where");
381 $body .= "'".gettext($tagtype)."' = '".$tagvalue."':";
386 <table
class="userlist">
390 foreach($result as $key => $info) {
392 if (sizeof($tagvalue) > 4) {
395 $friends_username = $info->username
;
396 $friends_name = htmlspecialchars(stripslashes($info->name
), ENT_COMPAT
, 'utf-8');
397 $friends_menu = run("users:infobox:menu",array($info->ident
));
401 <a href
="{$CFG->wwwroot}{$friends_username}/">
402 <img src
="{$CFG->wwwroot}{$friends_username}/icons/{$info->icon}/w/{$width}" alt
="{$friends_name}" border
="0" /></a
><br
/>
403 <span
class="userdetails">
411 $body .= "</tr><tr>";
419 $run_result .= $body;
425 function search_all_tagtypes () {
429 foreach($data['profile:details'] as $profiletype) {
430 if ($profiletype[2] == "keywords") {
431 $data['search:tagtypes'][] = $profiletype[1];
437 function search_all_tagtypes_rss () {
441 foreach($data['profile:details'] as $profiletype) {
442 if ($profiletype[2] == "keywords") {
443 $data['search:tagtypes:rss'][] = $profiletype[1];
449 function search_ecl ($tagtype, $tagvalue) {
451 global $data, $CFG, $db;
456 foreach($data['profile:details'] as $profiletype) {
457 if ($profiletype[1] == $tagtype && $profiletype[2] == "keywords") {
466 $searchline = "tagtype = " . $db->qstr($tagtype) . " AND tag = " . $db->qstr($tagvalue) . "";
467 $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline;
468 $searchline = str_replace("owner", "t.owner", $searchline);
469 $tagvalue = stripslashes($tagvalue);
470 if ($result = get_record_sql('SELECT DISTINCT u.* FROM '.$CFG->prefix
.'tags t
471 LEFT JOIN '.$CFG->prefix
.'users u ON u.ident = t.owner
472 WHERE '.$searchline)) {
473 foreach($result as $key => $info) {
474 $icon = url
. $info->username
. '/icons/'.$post->icon
;
475 $sub_result .= "\t\t\t<item>\n";
476 $sub_result .= "\t\t\t\t<name><![CDATA[" . htmlspecialchars(stripslashes($info->name
), ENT_COMPAT
, 'utf-8') . "]]></name>\n";
477 $sub_result .= "\t\t\t\t<link>" . url
. htmlspecialchars($info->username
, ENT_COMPAT
, 'utf-8') . "</link>\n";
478 $sub_result .= "\t\t\t\t<link>$icon</link>\n";
479 $sub_result .= "\t\t\t</item>\n";
483 if ($sub_result != "") {
485 $run_result .= "\t\t<profiles tagtype=\"".addslashes(htmlspecialchars($tagtype, ENT_COMPAT
, 'utf-8'))."\">\n" . $sub_result . "\t\t</profiles>\n";
493 function search_rss ($tagtype, $tagvalue) {
495 global $data, $CFG, $db;
500 foreach($data['profile:details'] as $profiletype) {
501 if ($profiletype[1] == $tagtype && $profiletype[2] == "keywords") {
508 $searchline = "tagtype = " . $db->qstr($tagtype) . " AND tag = " . $db->qstr($tagvalue) . "";
509 $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline;
510 $searchline = str_replace("owner", "t.owner", $searchline);
511 $tagvalue = stripslashes($tagvalue);
512 if ($result = get_records_sql('SELECT DISTINCT u.* FROM '.$CFG->prefix
.'tags t
513 LEFT JOIN '.$CFG->prefix
.'users u ON u.ident = t.owner
514 WHERE '.$searchline)) {
515 foreach($result as $key => $info) {
516 $run_result .= "\t<item>\n";
517 $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";
518 $run_result .= "\t\t<link>" . url
. htmlspecialchars($info->username
, ENT_COMPAT
, 'utf-8') . "</link>\n";
519 $run_result .= "\t</item>\n";
526 function upload_foaf () {
530 $action = optional_param('action');
531 if (!empty($action) && $action == "profile:foaf:upload" && logged_on
&& run("permissions:check", "profile")) {
532 require_once($CFG->dirroot
.'lib/uploadlib.php');
533 $um = new upload_manager('foaf_file',false,true,0,true);
534 $dir = $CFG->dataroot
. 'tmp/foaf/';
535 if (!$um->process_file_uploads($dir)) {
536 $messages[] = gettext("There was an error uploading the file. Possibly the file was too large, or the upload was interrupted.");
537 $messages[] = $um->get_errors();
540 $file = $um->get_new_filepath();
541 $foaf = @GetXMLTreeProfile
($file);
543 $data['profile:preload'] = array();
545 if (isset($foaf['RDF:RDF'][0]['PERSON'][0]) && !isset($foaf['RDF:RDF'][0]['FOAF:PERSON'][0])) {
546 $foaf['RDF:RDF'][0]['FOAF:PERSON'][0] = $foaf['RDF:RDF'][0]['PERSON'][0];
549 if (isset($foaf['RDF:RDF'][0]['FOAF:PERSON'][0])) {
551 $foaf = $foaf['RDF:RDF'][0]['FOAF:PERSON'][0];
553 if (!empty($data['foaf:profile']) && sizeof($data['foaf:profile']) > 0) {
554 foreach($data['foaf:profile'] as $foaf_element) {
556 $profile_value = addslashes($foaf_element[0]);
557 $foaf_name = $foaf_element[1];
558 $individual = $foaf_element[2];
559 $resource = $foaf_element[3];
560 if (isset($foaf[strtoupper($foaf_name)])) {
561 $values = $foaf[strtoupper($foaf_name)];
562 foreach($values as $value) {
564 if (trim($value['VALUE']) != "") {
565 $thisvalue = trim($value['VALUE']);
566 } else if (isset($value['ATTRIBUTES']['DC:TITLE']) && trim($value['ATTRIBUTES']['DC:TITLE'] != "")){
567 $thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
568 } else if (isset($value['ATTRIBUTES']['RDF:RESOURCE']) && trim($value['ATTRIBUTES']['RDF:RESOURCE'] != "")) {
569 $thisvalue = trim($value['ATTRIBUTES']['RDF:RESOURCE']);
571 if ($thisvalue != "") {
572 if (!isset($data['profile:preload'][$profile_value])) {
573 $data['profile:preload'][$profile_value] = $thisvalue;
575 $data['profile:preload'][$profile_value] .= ", " . $thisvalue;
582 if (!empty($foaf['VCARD:ADR']) && sizeof($foaf['VCARD:ADR']) > 0) {
583 if (!empty($data['vcard:profile:adr']) && sizeof($data['vcard:profile:adr']) > 0) {
585 $foaf = $foaf['VCARD:ADR'][0];
587 foreach($data['vcard:profile:adr'] as $foaf_element) {
588 $profile_value = addslashes($foaf_element[0]);
589 $foaf_name = $foaf_element[1];
590 $individual = $foaf_element[2];
591 $resource = $foaf_element[3];
592 if (isset($foaf[strtoupper($foaf_name)])) {
593 $values = $foaf[strtoupper($foaf_name)];
594 foreach($values as $value) {
596 if (trim($value['VALUE']) != "") {
597 $thisvalue = trim($value['VALUE']);
598 } else if (isset($value['ATTRIBUTES']['DC:TITLE']) && trim($value['ATTRIBUTES']['DC:TITLE'] != "")){
599 $thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
600 } else if (isset($value['ATTRIBUTES']['RDF:RESOURCE']) && trim($value['ATTRIBUTES']['RDF:RESOURECE'] != "")) {
601 $thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
603 if ($thisvalue != "") {
604 if (!isset($data['profile:preload'][$profile_value])) {
605 $data['profile:preload'][$profile_value] = $thisvalue;
607 $data['profile:preload'][$profile_value] .= ", " . $thisvalue;
616 $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.");
620 $messages[] = gettext("Error: supplied file did not appear to be a FOAF file.");
633 // Cycle through all defined profile detail fields and display them
635 if (!empty($data['profile:details']) && sizeof($data['profile:details']) > 0) {
637 if ($allvalues = get_records('profile_data','owner',$this->id
)) {
638 foreach($data['profile:details'] as $field) {
639 // $field is an array, with the name
640 // of the field in $field[0]
641 $run_result .= $this->field_display($field,$allvalues);
649 function generate_foaf_fields ($user_id) {
653 // If $data['foaf:profile'] is set and has elements in it ...
655 $user_id = (int) $user_id;
658 $where = run("users:access_level_sql_where",$_SESSION['userid']);
660 if (!empty($data['foaf:profile']) && sizeof($data['foaf:profile']) > 0) {
662 foreach($data['foaf:profile'] as $foaf_element) {
668 $profile_value = addslashes($foaf_element[0]);
669 $foaf_name = $foaf_element[1];
670 $individual = $foaf_element[2];
671 $resource = $foaf_element[3];
672 foreach($data['profile:details'] as $profile_element) {
673 if ($profile_element[1] == $profile_value) {
674 $value_type = $profile_element[2];
678 if ($value_type != "keywords") {
679 $result = get_records_select('profile_data',"name = '$profile_value' AND ($where) AND owner = ".$user_id,'','ident,value');
681 $result = get_records_select('tags',"tagtype = '$profile_value' and ($where) AND owner = $user_id",'','ident,tag AS value');
683 if (is_array($result)) {
684 if ($individual == "individual") {
685 foreach($result as $element) {
686 if (trim($element->value
) != "") {
687 $value = stripslashes($element->value
);
688 if ($resource == "resource") {
689 $enclosure = "\t\t<" . $foaf_name . " ";
690 if ($value_type == "keywords") {
691 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
692 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
694 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
696 $foaf_elements .= $enclosure;
698 $enclosure = "\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars(($value), ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
699 $foaf_elements .= $enclosure;
704 foreach($result as $element) {
705 if (trim($element->value
) != "") {
709 $value .= stripslashes($element->value
);
711 if ($resource == "resource") {
712 $enclosure = "\t\t<" . $foaf_name . " ";
713 if ($value_type == "keywords") {
714 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
715 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
717 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
720 $enclosure = "\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars(($value), ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
723 $foaf_elements .= $enclosure;
731 $run_result .= $foaf_elements;
735 function generate_vcard_adr_fields ($user_id) {
739 // If $data['vcard:profile:adr'] is set and has elements in it ...
741 $user_id = (int)$user_id;
744 $where = run("users:access_level_sql_where",$_SESSION['userid']);
746 if (!empty($data['vcard:profile:adr']) && sizeof($data['vcard:profile:adr']) > 0) {
748 foreach($data['vcard:profile:adr'] as $foaf_element) {
754 $profile_value = addslashes($foaf_element[0]);
755 $foaf_name = $foaf_element[1];
756 $individual = $foaf_element[2];
757 $resource = $foaf_element[3];
758 foreach($data['profile:details'] as $profile_element) {
759 if ($profile_element[1] == $profile_value) {
760 $value_type = $profile_element[2];
764 if ($value_type != "keywords") {
765 $result = get_records_select('profile_data',"name = '$profile_value' AND ($where) AND owner = ".$user_id,'','ident,value');
767 $result = get_records_select('tags',"tagtype = '$profile_value' and ($where) AND owner = $user_id",'','ident,tag AS value');
769 if (is_array($result)) {
770 if ($individual == "individual") {
771 foreach($result as $element) {
772 if (trim($element->value
) != "") {
773 $value = stripslashes($element->value
);
774 if ($resource == "resource") {
775 $enclosure = "\t\t\t<" . $foaf_name . " ";
776 if ($value_type == "keywords") {
777 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
778 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
780 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
782 $foaf_elements .= $enclosure;
784 $enclosure = "\t\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
785 $foaf_elements .= $enclosure;
790 foreach($result as $element) {
791 if (trim($element->value
) != "") {
795 $value .= stripslashes($element->value
);
797 if ($resource == "resource") {
798 $enclosure = "\t\t\t<" . $foaf_name . " ";
799 if ($value_type == "keywords") {
800 $enclosure .= "dc:title=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" ";
801 $enclosure .= "rdf:resource=\"" . url
. "tag/".urlencode($value)."\" />\n";
803 $enclosure .= "rdf:resource=\"" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "\" />\n";
806 $enclosure = "\t\t\t<" . $foaf_name . "><![CDATA[" . htmlspecialchars($value, ENT_COMPAT
, 'utf-8') . "]]></" . $foaf_name . ">\n";
809 $foaf_elements .= $enclosure;
817 $run_result .= $foaf_elements;
821 function groups_delete ($group_id) {
824 // When an access group is deleted, revert all profile items restricted to that group to private
825 $group_id = (int)$group_id;
827 if (!empty($group_id) && logged_on
) {
828 // Create 'private' access string for current user
829 $access = "user" . $_SESSION['userid'];
831 // Update profile_data table, setting access to $access
832 // where the owner is the current user and access = 'group$group_id'
833 return set_field('profile_data','access',$access,'access','group'.$group_id,'owner',$USER->ident
);
842 // ELGG Profile system
846 // Initialisation for the search function
847 $function['search:init'][] = path
. "units/profile/function_init.php";
848 $function['search:init'][] = path
. "units/profile/function_editfield_defaults.php";
849 $function['search:all:tagtypes'][] = path
. "units/profile/function_search_all_tagtypes.php";
850 $function['search:all:tagtypes:rss'][] = path
. "units/profile/function_search_all_tagtypes_rss.php";
852 // Function to search through profiles
853 $function['search:display_results'][] = path
. "units/profile/function_search.php";
854 $function['search:display_results:rss'][] = path
. "units/profile/function_search_rss.php";
856 // Functions to view and edit individual profile fields
857 $function['profile:editfield:display'][] = path
. "units/profile/function_editfield_display.php";
858 $function['profile:field:display'][] = path
. "units/profile/function_field_display.php";
860 // Function to view all profile fields
861 $function['profile:view'][] = path
. "units/profile/function_view.php";
863 // Function to display user's name
864 $function['profile:display:name'][] = path
. "units/profile/function_display_name.php";
866 $function['profile:user:info'][] = path
. "units/profile/profile_user_info.php";
869 $function['content:profile:edit'][] = path
. "units/profile/content_edit.php";
871 // Establish permissions
872 $function['permissions:check'][] = path
. "units/profile/permissions_check.php";
875 $function['foaf:generate:fields'][] = path
. "units/profile/generate_foaf_fields.php";
876 $function['vcard:generate:fields:adr'][] = path
. "units/profile/generate_vcard_adr_fields.php";
878 // Actions to perform when an access group is deleted
879 $function['groups:delete'][] = path
. "units/profile/groups_delete.php";
886 function permissions_check ($object) {
888 if ($object === "profile" && $page_owner == $_SESSION['userid']) {
894 function profile_user_info () {
899 // If this is someone else's portfolio, display the user's icon
900 $run_result = "<div class=\"box_user\">";
902 $info = get_record('users','ident',$page_owner);
904 if (!$tagline = get_field_sql('SELECT value FROM '.$CFG->prefix
.'profile_data
905 WHERE owner = '.$page_owner." AND name = 'minibio'
906 AND (".run("users:access_level_sql_where",$USER->ident
).")")) {
910 $icon = "<img alt=\"\" src=\"".url
.$info->username
.'icons/'.$info->icon
.'/w/67" />';
911 $name = stripslashes($info->name
);
912 $url = url
. $info->username
. "/";
914 $body =templates_draw(array(
915 'context' => 'ownerbox',
917 'profileurl' => $url,
919 'tagline' => $tagline,
921 'usermenu' => run("users:infobox:menu:text",array($page_owner))
925 if ($page_owner != -1) {
926 if ($page_owner != $_SESSION['userid']) {
927 $title = gettext("Profile Owner");
929 $title = gettext("You");
933 $run_result .=templates_draw(array(
934 'context' => 'contentholder',
941 $run_result .= "</div>";
946 } // End Class ElggProfile