| |
1158 |
1158 |
{-output "list"} |
| |
1159 |
1159 |
{-all:boolean} |
| |
1160 |
1160 |
{-no_member_count:boolean} |
| |
1161 |
1161 |
{-package_id ""} |
| |
1162 |
1162 |
{-party_id ""} |
| |
1163 |
1163 |
{-include_dotlrn_p "0"} |
| |
1164 |
1164 |
} { |
| |
1165 |
1165 |
Return the groups that are mapped in contacts |
| |
1166 |
1166 |
@param indent_with What should we indent the group name with |
| |
1167 |
1167 |
@privilege_required Required privilege the user has to have on this group |
| |
1168 |
1168 |
@output Format in which to output the groups. A tcl list of lists is standard |
| |
1169 |
1169 |
@party_id If the privilege is write we need to check if the user is maybe writing on himself. Then he should have permission. |
| |
1170 |
1170 |
} { |
| |
1171 |
1171 |
if { $package_id eq "" } { |
| |
1172 |
1172 |
set package_id [ad_conn package_id] |
| |
1173 |
1173 |
} |
| |
1174 |
1174 |
|
| |
1175 |
1175 |
set user_id [ad_conn user_id] |
| |
1176 |
1176 |
set group_list [list] |
| |
1177 |
1177 |
foreach one_group [contact::groups_list -package_id $package_id -include_dotlrn_p $include_dotlrn_p] { |
| |
1178 |
|
util_unlist $one_group group_id group_name member_count component_count mapped_p default_p user_change_p dotlrn_community_p notifications_p |
| |
|
1178 |
util_unlist $one_group group_id group_name member_count component_count mapped_p default_p user_change_p dotlrn_community_p |
| |
1179 |
1179 |
if {$user_change_p eq ""} { |
| |
1180 |
1180 |
set user_change_p 0 |
| |
1181 |
1181 |
} |
| |
1182 |
1182 |
# We check if the group has the required privilege |
| |
1183 |
1183 |
# specified on privilege_required switch, if not then |
| |
1184 |
1184 |
# we just simple continue with the next one |
| |
1185 |
1185 |
if { ![permission::permission_p -object_id $group_id -party_id $user_id -privilege $privilege_required] } { |
| |
1186 |
1186 |
if { $privilege_required eq "write" && $user_change_p} { |
| |
1187 |
1187 |
# Check if the user is editing himself |
| |
1188 |
1188 |
if {![string eq $party_id $user_id]} { |
| |
1189 |
1189 |
continue |
| |
1190 |
1190 |
} |
| |
1191 |
1191 |
} else { |
| |
1192 |
1192 |
continue |
| |
1193 |
1193 |
} |
| |
1194 |
1194 |
} |
| |
1195 |
1195 |
if { $mapped_p || $all_p} { |
| |
1196 |
1196 |
# we localize twice because for some reason some localized keys references another localized key |
| |
1197 |
|
lappend group_list [list [lang::util::localize [lang::util::localize $group_name]] $group_id $member_count "1" $mapped_p $default_p $user_change_p $dotlrn_community_p $notifications_p] |
| |
|
1197 |
lappend group_list [list [lang::util::localize [lang::util::localize $group_name]] $group_id $member_count "1" $mapped_p $default_p $user_change_p $dotlrn_community_p] |
| |
1198 |
1198 |
if { $component_count > 0 && ( $expand == "all" || $expand == $group_id ) } { |
| |
1199 |
1199 |
db_foreach get_components {} { |
| |
1200 |
1200 |
if { $mapped_p || $all_p} { |
| |
1201 |
|
lappend group_list [list "$indent_with[lang::util::localize [lang::util::localize $group_name]]" $group_id $member_count "2" $mapped_p $default_p $user_change_p $dotlrn_community_p $notifications_p] |
| |
|
1201 |
lappend group_list [list "$indent_with[lang::util::localize [lang::util::localize $group_name]]" $group_id $member_count "2" $mapped_p $default_p $user_change_p $dotlrn_community_p] |
| |
1202 |
1202 |
} |
| |
1203 |
1203 |
} |
| |
1204 |
1204 |
} |
| |
1205 |
1205 |
} |
| |
1206 |
1206 |
} |
| |
1207 |
1207 |
|
| |
1208 |
1208 |
switch $output { |
| |
1209 |
1209 |
list { |
| |
1210 |
1210 |
ns_log notice "last $group_list" |
| |
1211 |
1211 |
set list_output [list] |
| |
1212 |
1212 |
foreach group $group_list { |
| |
1213 |
1213 |
if {$no_member_count_p} { |
| |
1214 |
1214 |
lappend list_output [list [lindex $group 0] [lindex $group 1]] |
| |
1215 |
1215 |
} else { |
| |
1216 |
1216 |
lappend list_output [list [lindex $group 0] [lindex $group 1] [lindex $group 2]] |
| |
1217 |
1217 |
} |
| |
1218 |
1218 |
} |
| |
1219 |
1219 |
return $list_output |
| |
1220 |
1220 |
} |
| |
1221 |
1221 |
ad_form { |