1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* GCcollab onboarding |
4
|
|
|
* |
5
|
|
|
* Welcome Module |
6
|
|
|
* Profile Module |
7
|
|
|
* Groups Module |
8
|
|
|
* |
9
|
|
|
* Provides more info on the wire via popup |
10
|
|
|
* |
11
|
|
|
* @version 1.0 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
elgg_register_event_handler('init', 'system', 'onboard_ME_collab'); |
16
|
|
|
|
17
|
|
|
function onboard_ME_collab() { |
18
|
|
|
elgg_register_library('elgg:onboarding', elgg_get_plugins_path() . 'gc_onboard_collab/lib/functions.php'); |
19
|
|
|
|
20
|
|
|
elgg_register_action("onboard/update-profile", elgg_get_plugins_path() . "/gc_onboard_collab/actions/update-profile.php"); |
21
|
|
|
|
22
|
|
|
elgg_register_page_handler('profileonboard', 'profileonboard_collab_page_handler'); |
23
|
|
|
elgg_register_page_handler('groupsonboard', 'groupsonboard_collab_page_handler'); |
24
|
|
|
elgg_register_page_handler('tutorials', 'tutorials_page_handler'); |
25
|
|
|
elgg_register_page_handler('updateorg','updateorg_collab_page_handler'); |
26
|
|
|
|
27
|
|
|
//views for intro profile onboarding |
28
|
|
|
elgg_register_ajax_view('welcome-steps/stepOne'); |
29
|
|
|
elgg_register_ajax_view('welcome-steps/stepTwo'); |
30
|
|
|
elgg_register_ajax_view('welcome-steps/stepThree'); |
31
|
|
|
elgg_register_ajax_view('welcome-steps/stepFour'); |
32
|
|
|
elgg_register_ajax_view('welcome-steps/stepFive'); |
33
|
|
|
elgg_register_ajax_view('welcome-steps/stepSix'); |
34
|
|
|
|
35
|
|
|
elgg_extend_view('contactform/form', 'onboard/module_links'); |
36
|
|
|
elgg_extend_view('page/elements/navbar', 'page/elements/update_banner'); |
37
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function profileonboard_collab_page_handler(){ |
41
|
|
|
@include (dirname ( __FILE__ ) . "/pages/onboard-profile.php"); |
|
|
|
|
42
|
|
|
return true; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function groupsonboard_collab_page_handler(){ |
46
|
|
|
@include (dirname ( __FILE__ ) . "/pages/onboard-groups.php"); |
|
|
|
|
47
|
|
|
return true; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function tutorials_page_handler(){ |
51
|
|
|
@include (dirname ( __FILE__ ) . "/pages/tutorials.php"); |
|
|
|
|
52
|
|
|
return true; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
function updateorg_collab_page_handler(){ |
56
|
|
|
@include (dirname (__FILE__). "/pages/update-org.php"); |
|
|
|
|
57
|
|
|
return true; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/* |
61
|
|
|
* get_my_profile_strength_collab |
62
|
|
|
* |
63
|
|
|
* Gets the profile strength of the logged in user as an INT value. |
64
|
|
|
* |
65
|
|
|
* @author Ethan Wallace |
66
|
|
|
* @return [INT] [<Profile strength percent>] |
|
|
|
|
67
|
|
|
*/ |
68
|
|
|
function get_my_profile_strength_collab(){ |
69
|
|
|
|
70
|
|
|
$userEnt = elgg_get_logged_in_user_entity(); |
71
|
|
|
|
72
|
|
|
//avatar |
73
|
|
View Code Duplication |
if($userEnt->getIconURL() != elgg_get_site_url() . '_graphics/icons/user/defaultmedium.gif'){ |
74
|
|
|
$avIcon = '<i class="fa fa-check text-primary"></i>'; |
75
|
|
|
$avTotal = 100; |
76
|
|
|
}else{ |
77
|
|
|
$avIcon = '<i class="fa fa-exclamation-triangle text-danger"></i>'; |
78
|
|
|
$avTotal = 0; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
//About me |
82
|
|
View Code Duplication |
if($userEnt->description){ |
83
|
|
|
$aboutIcon = '<i class="fa fa-check text-primary"></i>'; |
84
|
|
|
$aboutTotal = 100; |
85
|
|
|
}else{ |
86
|
|
|
$aboutIcon = '<i class="fa fa-exclamation-triangle text-danger"></i>'; |
87
|
|
|
$aboutTotal = 0; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
//basic profile |
91
|
|
|
$basicCount = 0; |
92
|
|
|
|
93
|
|
View Code Duplication |
if($userEnt->university || $userEnt->college || $userEnt->highschool || $userEnt->federal || $userEnt->ministry || $userEnt->municipal || $userEnt->international || $userEnt->ngo || $userEnt->community || $userEnt->business || $userEnt->media || $userEnt->retired || $userEnt->other){ |
94
|
|
|
$basicCount += 20; |
95
|
|
|
} |
96
|
|
|
if($userEnt->job){ |
97
|
|
|
$basicCount += 20; |
98
|
|
|
} |
99
|
|
|
if($userEnt->location || $userEnt->addressString || $userEnt->addressStringFr){ |
100
|
|
|
$basicCount += 20; |
101
|
|
|
} |
102
|
|
|
if($userEnt->email){ |
103
|
|
|
$basicCount += 20; |
104
|
|
|
} |
105
|
|
|
if($userEnt->phone || $userEnt->mobile){ |
106
|
|
|
$basicCount += 20; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
//education |
110
|
|
|
if(count($userEnt->education) >= 1){ |
111
|
|
|
$eduCount = 100; |
112
|
|
|
} else { |
113
|
|
|
$eduCount = 0; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
//work experience |
117
|
|
|
if(count($userEnt->work) >= 1){ |
118
|
|
|
$workCount = 100; |
119
|
|
|
} else { |
120
|
|
|
$workCount = 0; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
//skills |
124
|
|
View Code Duplication |
if(count($userEnt->gc_skills) >= 3){ |
125
|
|
|
$skillCount = 100; |
126
|
|
|
} else { |
127
|
|
|
$skillCount = round(count($userEnt->gc_skills)/3*100); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
//overall total |
131
|
|
|
$complete = round(($skillCount + $workCount + $eduCount + $basicCount + $aboutTotal + $avTotal)/6); |
132
|
|
|
|
133
|
|
|
//set up profile strength metadata |
134
|
|
|
$userEnt->profilestrength = $complete; |
135
|
|
|
|
136
|
|
|
return $userEnt->profilestrength; |
137
|
|
|
} |
138
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: