| |
|
1 |
# Copyright (C) 2005 Cognovis |
| |
|
2 |
# This file is part of dotLRN. |
| |
|
3 |
# dotLRN is free software; you can redistribute it and/or modify it under the |
| |
|
4 |
# terms of the GNU General Public License as published by the Free Software |
| |
|
5 |
# Foundation; either version 2 of the License, or (at your option) any later |
| |
|
6 |
# version. |
| |
|
7 |
# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY |
| |
|
8 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| |
|
9 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| |
|
10 |
# details. |
| |
|
11 |
|
| |
|
12 |
ad_library { |
| |
|
13 |
|
| |
|
14 |
the dotlrn applet for Contacts |
| |
|
15 |
|
| |
|
16 |
@author Bjoern Kiesbye (kiesbye@theservice.de) |
| |
|
17 |
@version $Id$ |
| |
|
18 |
} |
| |
|
19 |
|
| |
|
20 |
namespace eval dotlrn_contacts {} |
| |
|
21 |
|
| |
|
22 |
ad_proc -public dotlrn_contacts::package_key { |
| |
|
23 |
} { |
| |
|
24 |
What package does this applet deal with? |
| |
|
25 |
} { |
| |
|
26 |
return "contacts" |
| |
|
27 |
} |
| |
|
28 |
|
| |
|
29 |
ad_proc -public dotlrn_contacts::my_package_key { |
| |
|
30 |
} { |
| |
|
31 |
What's my package key? |
| |
|
32 |
} { |
| |
|
33 |
return "dotlrn-contacts" |
| |
|
34 |
} |
| |
|
35 |
|
| |
|
36 |
ad_proc -public dotlrn_contacts::applet_key { |
| |
|
37 |
} { |
| |
|
38 |
What's my applet key? |
| |
|
39 |
} { |
| |
|
40 |
return "dotlrn_contacts" |
| |
|
41 |
} |
| |
|
42 |
|
| |
|
43 |
ad_proc -public dotlrn_contacts::get_pretty_name { |
| |
|
44 |
} { |
| |
|
45 |
} { |
| |
|
46 |
return "Contacts" |
| |
|
47 |
} |
| |
|
48 |
|
| |
|
49 |
ad_proc -public dotlrn_contacts::add_applet { |
| |
|
50 |
} { |
| |
|
51 |
Called for one time init - must be repeatable! |
| |
|
52 |
@return new pkg_id or 0 on failure |
| |
|
53 |
} { |
| |
|
54 |
|
| |
|
55 |
# Contacts Package is Singleton and is required to install |
| |
|
56 |
# this package, so just add the applet to dotlrn. And mount the |
| |
|
57 |
# Contacts Package under the dotlrn_url so users are able to |
| |
|
58 |
# to access Contacts from My Space. |
| |
|
59 |
|
| |
|
60 |
set package_id [apm_package_id_from_key contacts] |
| |
|
61 |
|
| |
|
62 |
if {![dotlrn::is_package_mounted -package_key contacts]} { |
| |
|
63 |
Aset com_url [dotlrn::get_url] |
| |
|
64 |
|
| |
|
65 |
array set node_info [site_node::get_from_url -url $com_url -exact] |
| |
|
66 |
set parent_id $node_info(node_id) |
| |
|
67 |
|
| |
|
68 |
db_transaction { |
| |
|
69 |
set node_id [site_node::new \ |
| |
|
70 |
-name contacts \ |
| |
|
71 |
-parent_id $parent_id \ |
| |
|
72 |
-directory_p "t" \ |
| |
|
73 |
-pattern_p "t" \ |
| |
|
74 |
] |
| |
|
75 |
} |
| |
|
76 |
|
| |
|
77 |
site_node::mount -node_id $node_id -object_id $package_id |
| |
|
78 |
} |
| |
|
79 |
|
| |
|
80 |
dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [my_package_key] |
| |
|
81 |
|
| |
|
82 |
} |
| |
|
83 |
|
| |
|
84 |
ad_proc -public dotlrn_contacts::remove_applet { |
| |
|
85 |
} { |
| |
|
86 |
One-time destroy for when the entire applet is removed from dotlrn. |
| |
|
87 |
} { |
| |
|
88 |
ad_return_complaint 1 "[applet_key] remove_applet not implimented!" |
| |
|
89 |
} |
| |
|
90 |
|
| |
|
91 |
|
| |
|
92 |
ad_proc -public dotlrn_contacts::add_applet_to_community { |
| |
|
93 |
community_id |
| |
|
94 |
} { |
| |
|
95 |
Add the contact applet to a specific dotlrn community |
| |
|
96 |
|
| |
|
97 |
@params community_id |
| |
|
98 |
} { |
| |
|
99 |
|
| |
|
100 |
set package_id [apm_package_id_from_key contacts] |
| |
|
101 |
set portal_id [dotlrn_community::get_portal_id \ |
| |
|
102 |
-community_id $community_id \ |
| |
|
103 |
] |
| |
|
104 |
|
| |
|
105 |
# Add the Portlet to this community |
| |
|
106 |
contacts_portlet::add_self_to_page -portal_id $portal_id -package_id $package_id |
| |
|
107 |
|
| |
|
108 |
# Add this community to contacts |
| |
|
109 |
db_dml insert_map { |
| |
|
110 |
insert into contact_groups |
| |
|
111 |
(group_id,default_p,package_id) |
| |
|
112 |
values |
| |
|
113 |
(:community_id, 'f' ,:package_id) |
| |
|
114 |
} |
| |
|
115 |
|
| |
|
116 |
# this should return the package_id |
| |
|
117 |
return $package_id |
| |
|
118 |
} |
| |
|
119 |
|
| |
|
120 |
ad_proc -public dotlrn_contacts::remove_applet_from_community { |
| |
|
121 |
community_id |
| |
|
122 |
} { |
| |
|
123 |
remove the applet from the community |
| |
|
124 |
} { |
| |
|
125 |
ad_return_complaint 1 "[applet_key] remove_applet_from_community not implimented!" |
| |
|
126 |
} |
| |
|
127 |
|
| |
|
128 |
ad_proc -public dotlrn_contacts::add_user { |
| |
|
129 |
user_id |
| |
|
130 |
} { |
| |
|
131 |
Called once when a user is added as a dotlrn user. |
| |
|
132 |
} { |
| |
|
133 |
} |
| |
|
134 |
|
| |
|
135 |
ad_proc -public dotlrn_contacts::remove_user { |
| |
|
136 |
user_id |
| |
|
137 |
} { |
| |
|
138 |
Remove a user from dotlrn |
| |
|
139 |
} { |
| |
|
140 |
|
| |
|
141 |
# Not yet implemented. |
| |
|
142 |
} |
| |
|
143 |
|
| |
|
144 |
ad_proc -public dotlrn_contacts::add_user_to_community { |
| |
|
145 |
community_id |
| |
|
146 |
user_id |
| |
|
147 |
} { |
| |
|
148 |
Add a user to a community |
| |
|
149 |
} { |
| |
|
150 |
|
| |
|
151 |
|
| |
|
152 |
set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]] |
| |
|
153 |
set portal_id [dotlrn::get_portal_id -user_id $user_id] |
| |
|
154 |
|
| |
|
155 |
|
| |
|
156 |
contacts_portlet::add_self_to_page \ |
| |
|
157 |
-portal_id $portal_id \ |
| |
|
158 |
-package_id $package_id] \ |
| |
|
159 |
-param_action append |
| |
|
160 |
|
| |
|
161 |
|
| |
|
162 |
} |
| |
|
163 |
|
| |
|
164 |
ad_proc -public dotlrn_contacts::remove_user_from_community { |
| |
|
165 |
community_id |
| |
|
166 |
user_id |
| |
|
167 |
} { |
| |
|
168 |
Remove a user from a community |
| |
|
169 |
} { |
| |
|
170 |
} |
| |
|
171 |
|
| |
|
172 |
ad_proc -public dotlrn_contacts::add_portlet { |
| |
|
173 |
portal_id |
| |
|
174 |
} { |
| |
|
175 |
Add Portlet to the Portal |
| |
|
176 |
|
| |
|
177 |
@param portal_id |
| |
|
178 |
} { |
| |
|
179 |
|
| |
|
180 |
contacts_portlet::add_self_to_page -portal_id $portal_id -package_id 0 |
| |
|
181 |
|
| |
|
182 |
} |
| |
|
183 |
|
| |
|
184 |
ad_proc -public dotlrn_contacts::remove_portlet { |
| |
|
185 |
portal_id |
| |
|
186 |
args |
| |
|
187 |
} { |
| |
|
188 |
A helper proc to remove the underlying portlet from the given portal. |
| |
|
189 |
This is alot simpler than add_portlet. |
| |
|
190 |
|
| |
|
191 |
@param portal_id |
| |
|
192 |
@param args An ns_set with the project_manager_id. |
| |
|
193 |
} { |
| |
|
194 |
contacts_portlet::remove_self_from_page \ |
| |
|
195 |
-portal_id $portal_id |
| |
|
196 |
} |
| |
|
197 |
|
| |
|
198 |
ad_proc -public dotlrn_contacts::clone { |
| |
|
199 |
old_community_id |
| |
|
200 |
new_community_id |
| |
|
201 |
} { |
| |
|
202 |
Clone this applet's content from the old community to the new one |
| |
|
203 |
} { |
| |
|
204 |
} |
| |
|
205 |
|
| |
|
206 |
ad_proc -public dotlrn_contacts::change_event_handler { |
| |
|
207 |
community_id |
| |
|
208 |
event |
| |
|
209 |
old_value |
| |
|
210 |
new_value |
| |
|
211 |
} { |
| |
|
212 |
listens for the following events: rename |
| |
|
213 |
} { |
| |
|
214 |
switch $event { |
| |
|
215 |
rename { |
| |
|
216 |
|
| |
|
217 |
handle_rename -community_id $community_id -old_value\ |
| |
|
218 |
$old_value -new_value $new_value |
| |
|
219 |
} |
| |
|
220 |
} |
| |
|
221 |
} |
| |
|
222 |
|
| |
|
223 |
ad_proc -private dotlrn_contacts::handle_rename { |
| |
|
224 |
{-community_id:required} |
| |
|
225 |
{-old_value:required} |
| |
|
226 |
{-new_value:required} |
| |
|
227 |
} { |
| |
|
228 |
When a dotlrn community is renamed |
| |
|
229 |
} { |
| |
|
230 |
|
| |
|
231 |
} |
| |
|
232 |
|
| |
|
233 |
|
| |
|
234 |
ad_proc -private dotlrn_contacts::upgrade { |
| |
|
235 |
{-from_version_name:required } |
| |
|
236 |
{-to_version_name:required } |
| |
|
237 |
} { |
| |
|
238 |
Procedures to upgrade dotlrn-contacts |
| |
|
239 |
|
| |
|
240 |
@author Miguel Marin (miguelmarin@viaro.net) |
| |
|
241 |
@author Viaro Networks www.viaro.net |
| |
|
242 |
} { |
| |
|
243 |
apm_upgrade_logic \ |
| |
|
244 |
-from_version_name $from_version_name \ |
| |
|
245 |
-to_version_name $to_version_name \ |
| |
|
246 |
-spec { |
| |
|
247 |
0.1d 0.1d1 { |
| |
|
248 |
# We are going to add contacts portlet to the |
| |
|
249 |
# templates |
| |
|
250 |
|
| |
|
251 |
db_foreach get_portal_templates { } { |
| |
|
252 |
contacts_portlet::add_self_to_page \ |
| |
|
253 |
-portal_id $portal_id \ |
| |
|
254 |
-package_id 0 |
| |
|
255 |
} |
| |
|
256 |
} |
| |
|
257 |
} |
| |
|
258 |
} |
| |
|
259 |
|