| |
182 |
182 |
delete a person |
| |
183 |
183 |
} { |
| |
184 |
184 |
db_exec_plsql delete_person {} |
| |
185 |
185 |
} |
| |
186 |
186 |
|
| |
187 |
187 |
ad_proc -public person::get { |
| |
188 |
188 |
{-person_id:required} |
| |
189 |
189 |
} { |
| |
190 |
190 |
get info for a person as a tcl array in list form |
| |
191 |
191 |
} { |
| |
192 |
192 |
db_1row get_person {} |
| |
193 |
193 |
|
| |
194 |
194 |
set person(person_id) $person_id |
| |
195 |
195 |
set person(first_names) $first_names |
| |
196 |
196 |
set person(last_name) $last_name |
| |
197 |
197 |
|
| |
198 |
198 |
return [array get person] |
| |
199 |
199 |
} |
| |
200 |
200 |
|
| |
201 |
201 |
ad_proc -public person::name { |
| |
202 |
|
{-person_id:required} |
| |
|
202 |
{-person_id ""} |
| |
|
203 |
{-email ""} |
| |
203 |
204 |
} { |
| |
204 |
205 |
get the name of a person. Cached. |
| |
205 |
206 |
} { |
| |
206 |
|
return [util_memoize [list person::name_not_cached -person_id $person_id]] |
| |
|
207 |
if {$person_id eq "" && $email eq ""} { |
| |
|
208 |
error "You need to provide either person_id or email" |
| |
|
209 |
} elseif {![string eq "" $person_id] && ![string eq "" $email]} { |
| |
|
210 |
error "Only provide provide person_id OR email, not both" |
| |
|
211 |
} else { |
| |
|
212 |
return [util_memoize [list person::name_not_cached -person_id $person_id -email $email]] |
| |
207 |
213 |
} |
| |
|
214 |
} |
| |
208 |
215 |
|
| |
209 |
216 |
ad_proc -public person::name_flush { |
| |
210 |
217 |
{-person_id:required} |
| |
211 |
218 |
} { |
| |
212 |
219 |
Flush the person::name cache. |
| |
213 |
220 |
} { |
| |
214 |
221 |
util_memoize_flush [list person::name_not_cached -person_id $person_id] |
| |
215 |
222 |
acs_user::flush_cache -user_id $person_id |
| |
216 |
223 |
} |
| |
217 |
224 |
|
| |
218 |
225 |
ad_proc -public person::name_not_cached { |
| |
219 |
|
{-person_id:required} |
| |
|
226 |
{-person_id ""} |
| |
|
227 |
{-email ""} |
| |
220 |
228 |
} { |
| |
221 |
229 |
get the name of a person |
| |
222 |
230 |
} { |
| |
|
231 |
if {$email eq ""} { |
| |
223 |
232 |
db_1row get_person_name {} |
| |
|
233 |
} else { |
| |
|
234 |
# As the old functionality returned an error, but I want an empty string for e-mail |
| |
|
235 |
# Therefore for emails we use db_string |
| |
|
236 |
set person_name [db_string get_person_name {} -default ""] |
| |
|
237 |
} |
| |
224 |
238 |
return $person_name |
| |
225 |
239 |
} |
| |
226 |
240 |
|
| |
227 |
241 |
ad_proc -public person::update { |
| |
228 |
242 |
{-person_id:required} |
| |
229 |
243 |
{-first_names:required} |
| |
230 |
244 |
{-last_name:required} |
| |
231 |
245 |
} { |
| |
232 |
246 |
update the name of a person |
| |
233 |
247 |
} { |
| |
234 |
248 |
db_dml update_person {} |
| |
235 |
249 |
db_dml update_object_title {} |
| |
236 |
250 |
name_flush -person_id $person_id |
| |
237 |
251 |
} |
| |
238 |
252 |
|
| |
239 |
253 |
ad_proc -public person::get_bio { |
| |
240 |
254 |
{-person_id {}} |
| |
241 |
255 |
{-exists_var {}} |
| |
242 |
256 |
} { |
| |
243 |
257 |
Get the value of the user's bio(graphy) field. |
|
| |
639 |
653 |
lappend cols "$var = :$var" |
| |
640 |
654 |
} |
| |
641 |
655 |
} |
| |
642 |
656 |
db_dml party_update {} |
| |
643 |
657 |
if {[info exists email]} { |
| |
644 |
658 |
db_dml object_title_update {} |
| |
645 |
659 |
} |
| |
646 |
660 |
acs_user::flush_cache -user_id $party_id |
| |
647 |
661 |
} |
| |
648 |
662 |
|
| |
649 |
663 |
ad_proc -public party::get_by_email { |
| |
650 |
664 |
{-email:required} |
| |
651 |
665 |
} { |
| |
652 |
666 |
Return the party_id of the party with the given email. |
| |
653 |
667 |
Uses a lowercase comparison as we don't allow for parties |
| |
654 |
668 |
to have emails that only differ in case. |
| |
655 |
669 |
Returns empty string if no party found. |
| |
656 |
670 |
|
| |
657 |
671 |
@return party_id |
| |
658 |
672 |
} { |
| |
659 |
|
return [db_string select_party_id {*SQL*} -default ""] |
| |
|
673 |
# return [db_string select_party_id {*SQL*} -default ""] |
| |
|
674 |
|
| |
|
675 |
# The following query is identical in the result as the one above |
| |
|
676 |
# It just takes into account that some applications (like contacts) make email not unique |
| |
|
677 |
# Instead of overwriting this procedure in those packages, I changed it here, as the functionality |
| |
|
678 |
# is unchanged. |
| |
|
679 |
return [lindex [db_list select_party_id {}] 0] |
| |
660 |
680 |
} |
| |
661 |
681 |
|
| |
662 |
682 |
ad_proc -public party::approved_members { |
| |
663 |
683 |
{-party_id:required} |
| |
664 |
684 |
{-object_type ""} |
| |
665 |
685 |
} { |
| |
666 |
686 |
Get a list of approved members of the given party. |
| |
667 |
687 |
|
| |
668 |
688 |
@param party_id The id of the party to get members for |
| |
669 |
689 |
@param object_type Restrict to only members of this object type. For example, |
| |
670 |
690 |
if you are only interested in users, set to "user". |
| |
671 |
691 |
|
| |
672 |
692 |
@author Peter Marklund |
| |
673 |
693 |
} { |
| |
674 |
694 |
if { ![empty_string_p $object_type] } { |
| |
675 |
695 |
set from_clause ", acs_objects ao" |
| |
676 |
696 |
set where_clause "and pamm.member_id = ao.object_id |
| |
677 |
697 |
and ao.object_type = :object_type" |
| |
678 |
698 |
} |
| |
679 |
699 |
|