| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Exposes API endpoints for Opportunity entities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 	"get.opportunity", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 	"get_opportunity", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 		"guid" => array('type' => 'int', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	"get.opportunities", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	"get_opportunities", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		"limit" => array('type' => 'int', 'required' => false, 'default' => 10), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		"offset" => array('type' => 'int', 'required' => false, 'default' => 0), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		"filters" => array('type' => 'string', 'required' => false, 'default' => ""), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	'Retrieves opportunities based on user id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	"apply.post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	"apply_post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		"message" => array('type' => 'string', 'required' => true, 'default' => ""),		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		"guid" => array('type' => 'int', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	"withdraw.post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	"withdraw_post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		"message" => array('type' => 'string', 'required' => true, 'default' => ""), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		"guid" => array('type' => 'int', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	"accept.post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	"accept_post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		"guid" => array('type' => 'int', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	"accept.post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	"accept_post", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		"guid" => array('type' => 'int', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	"create.opportinities1", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	"create_opportinities1", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		"formData" => array('type' => 'array', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	"create.opportinities2", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	"create_opportinities2", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		"formData" => array('type' => 'array', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | elgg_ws_expose_function( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	"create.opportinities3", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 	"create_opportinities3", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		"user" => array('type' => 'string', 'required' => true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		"formData" => array('type' => 'array', 'required' => true),	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		"lang" => array('type' => 'string', 'required' => false, 'default' => "en") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 	), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 	'Retrieves a opportunity based on user id and opportunity id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	'POST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | function get_opportunity($user, $guid, $lang) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	$entity = get_entity($guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	if (!$entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 		return "Opportunity was not found. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	if (!elgg_instanceof($entity, 'object', 'mission')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 		return "Invalid opportunity. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	$opportunities = elgg_list_entities(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 		'type' => 'object', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		'subtype' => 'mission', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 		'guid' => $guid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	$opportunity = json_decode($opportunities)[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	$opportunity->title = gc_explode_translation($opportunity->title, $lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	$likes = elgg_get_annotations(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 		'guid' => $opportunity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		'annotation_name' => 'likes' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 	$opportunity->likes = count($likes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	$liked = elgg_get_annotations(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 		'guid' => $opportunity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 		'annotation_owner_guid' => $user_entity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		'annotation_name' => 'likes' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	$opportunity->liked = count($liked) > 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	$opportunity->comments = get_entity_comments($opportunity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	$opportunity->userDetails = get_user_block($opportunity->owner_guid, $lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 	$opportunity->description = gc_explode_translation($opportunity->description, $lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	$opportunityObj = get_entity($opportunity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	$opportunity->jobtype = elgg_echo($opportunityObj->job_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	$opportunity->roletype = elgg_echo($opportunityObj->role_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 	//$opportunity->programArea = elgg_echo('missions:program_area') . ": " . elgg_echo($opportunityObj->program_area); //This should work and translate to user lang but doesnt | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 	$opportunity->programArea = elgg_echo($opportunityObj->program_area); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	$opportunity->numOpportunities = $opportunityObj->number; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	$opportunity->idealStart = $opportunityObj->start_date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	$opportunity->idealComplete = $opportunityObj->complete_date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 	$opportunity->deadline = $opportunityObj->deadline; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	$opportunity->oppVirtual = $opportunityObj->remotely; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	$opportunity->oppOnlyIn = $opportunityObj->openess; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 	$opportunity->location = elgg_echo($opportunityObj->location); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	$opportunity->security = elgg_echo($opportunityObj->security); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 	$opportunity->skills = $opportunityObj->key_skills; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 	//$opportunity->participants = $opportunityObj->; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 	//$opportunity->applicants = $opportunityObj->; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	$opportunity->timezone = elgg_echo($opportunityObj->timezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 	$opportunity->timecommitment = $opportunityObj->time_commitment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	$opportunity->department = $opportunityObj->department; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 	$opportunity->state = $opportunityObj->state; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	//Language metadata | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	$unpacked_array = mm_unpack_mission($opportunityObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	$unpacked_language = ''; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 210 |  | View Code Duplication | 	if (! empty($unpacked_array['lwc_english']) || ! empty($unpacked_array['lwc_french'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |   	$unpacked_language .= '<b>' . elgg_echo('missions:written_comprehension') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |   	if (! empty($unpacked_array['lwc_english'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |       $unpacked_language .= '<span name="mission-lwc-english">' . elgg_echo('missions:formatted:english', array($unpacked_array['lwc_english'])) . '</span> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |   	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |   	if (! empty($unpacked_array['lwc_french'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |       $unpacked_language .= '<span name="mission-lwc-french">' . elgg_echo('missions:formatted:french', array($unpacked_array['lwc_french'])) . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |   	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 		$unpacked_language .= '<br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 220 |  | View Code Duplication | 	if (! empty($unpacked_array['lwe_english']) || ! empty($unpacked_array['lwe_french'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		$unpacked_language .= '<b>' . elgg_echo('missions:written_expression') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		if (! empty($unpacked_array['lwe_english'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 	  	$unpacked_language .= '<span name="mission-lwe-english">' . elgg_echo('missions:formatted:english', array($unpacked_array['lwe_english'])) . '</span> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 	 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	  if (! empty($unpacked_array['lwe_french'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 	  	$unpacked_language .= '<span name="mission-lwe-french">' . elgg_echo('missions:formatted:french', array($unpacked_array['lwe_french'])) . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	  } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 	  	$unpacked_language .= '<br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 	} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 230 |  | View Code Duplication | 	if (! empty($unpacked_array['lop_english']) || ! empty($unpacked_array['lop_french'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 		$unpacked_language .= '<b>' . elgg_echo('missions:oral_proficiency') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		if (! empty($unpacked_array['lop_english'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 			$unpacked_language .= '<span name="mission-lop-english">' . elgg_echo('missions:formatted:english', array($unpacked_array['lop_english'])) . '</span> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 		if (! empty($unpacked_array['lop_french'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 			$unpacked_language .= '<span name="mission-lop-french">' . elgg_echo('missions:formatted:french', array($unpacked_array['lop_french'])) . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 		$unpacked_language .= '<br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 	if (empty($unpacked_language)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 		$unpacked_language = '<span name="no-languages">' . elgg_echo('missions:none_required') . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 	$opportunity->languageRequirements = $unpacked_language; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	//scheduling metadata | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 	$unpacked_time = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	if ($opportunityObj->mon_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		$unpacked_time .= '<b>' . elgg_echo('missions:mon') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 	 	$unpacked_time .= $opportunityObj->mon_start . elgg_echo('missions:to') .  $opportunityObj->mon_duration . '<br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 	if ($opportunityObj->tue_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 		$unpacked_time .= '<b>' . elgg_echo('missions:tue') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 		$unpacked_time .= '<span name="mission-tue-start">' . $opportunityObj->tue_start . '</span>' . elgg_echo('missions:to') . '<span name="mission-tue-duration">' . $opportunityObj->tue_duration . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 	if ($opportunityObj->wed_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		$unpacked_time .= '<b>' . elgg_echo('missions:wed') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 		$unpacked_time .=  $opportunityObj->wed_start  . elgg_echo('missions:to') . $opportunityObj->wed_duration . '<br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 	if ($opportunityObj->thu_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 		$unpacked_time .= '<b>' . elgg_echo('missions:thu') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 		$unpacked_time .= '<span name="mission-thu-start">' . $opportunityObj->thu_start . '</span>' . elgg_echo('missions:to') . '<span name="mission-thu-duration">' . $opportunityObj->thu_duration . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 	if ($opportunityObj->fri_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 	  $unpacked_time .= '<b>' . elgg_echo('missions:fri') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 	  $unpacked_time .= '<span name="mission-fri-start">' . $opportunityObj->fri_start . '</span>' . elgg_echo('missions:to') . '<span name="mission-fri-duration">' . $opportunityObj->fri_duration . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 	if ($opportunityObj->sat_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 	  $unpacked_time .= '<b>' . elgg_echo('missions:sat') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 	  $unpacked_time .= '<span name="mission-sat-start">' . $opportunityObj->sat_start . '</span>' . elgg_echo('missions:to') . '<span name="mission-sat-duration">' . $opportunityObj->sat_duration . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 	if ($opportunityObj->sun_start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 	  $unpacked_time .= '<b>' . elgg_echo('missions:sun') . ': </b>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 	  $unpacked_time .= '<span name="mission-sun-start">' . $opportunityObj->sun_start . '</span>' . elgg_echo('missions:to') . '<span name="mission-sun-duration">' . $opportunityObj->sun_duration . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 	if (empty($unpacked_time)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	  $unpacked_time = '<span name="no-times">' . elgg_echo('missions:none_required') . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	$opportunity->schedulingRequirements = $unpacked_time; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 	return $opportunity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | function get_opportunities($user, $limit, $offset, $filters, $lang) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 	$filter_data = json_decode($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 	if (!empty($filter_data)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 		$params = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 			'type' => 'object', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 			'subtype' => 'mission', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 			'limit' => $limit, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 			'offset' => $offset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		if ($filter_data->type) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 			$params['metadata_name'] = 'job_type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 			$params['metadata_value'] = $filter_data->type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 312 |  | View Code Duplication | 		if ($filter_data->name) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 			$db_prefix = elgg_get_config('dbprefix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 			$params['joins'] = array("JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 			$params['wheres'] = array("(oe.title LIKE '%" . $filter_data->name . "%' OR oe.description LIKE '%" . $filter_data->name . "%')"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 		if ($filter_data->mine) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 			$all_opportunities = elgg_list_entities_from_relationship($params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 			$all_opportunities = elgg_list_entities_from_metadata($params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 	} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 		$all_opportunities = elgg_list_entities(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 			'type' => 'object', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 			'subtype' => 'mission', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 			'limit' => $limit, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 			'offset' => $offset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 	$opportunities = json_decode($all_opportunities); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 	foreach ($opportunities as $opportunity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		$opportunityObj = get_entity($opportunity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		$opportunity->title = gc_explode_translation($opportunity->title, $lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		$likes = elgg_get_annotations(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 			'guid' => $opportunity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 			'annotation_name' => 'likes' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 		$opportunity->likes = count($likes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 		$liked = elgg_get_annotations(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 			'guid' => $opportunity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 			'annotation_owner_guid' => $user_entity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 			'annotation_name' => 'likes' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 		if($opportunity->owner_guid != $user_entity->guid){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 			if($opportunityObj->state != 'completed' && $opportunityObj->state != 'cancelled'){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 				$relationship_count = elgg_get_entities_from_relationship(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 					'relationship' => 'mission_accepted', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 					'relationship_guid' => $opportunity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 					'count' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 				));	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 				if($relationship_count < $opportunityObj->number) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 					$opportunity->apply = 'mission_apply'; // user can apply | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 				if(check_entity_relationship($opportunity->guid, 'mission_tentative', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 					//console.log($opportunity->title); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 					$opportunity->apply = 'tentative'; // user can accecpt offer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 				if(check_entity_relationship($opportunity->guid, 'mission_offered', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 					$opportunity->apply = 'offered'; // user can accecpt offer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 				if(check_entity_relationship($opportunity->guid, 'mission_accepted', $user_entity->guid) || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 				check_entity_relationship($opportunity->guid, 'mission_applied', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 					$opportunity->apply = 'withdraw'; // user can accecpt offer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 			}else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 				$opportunity->apply = 'close'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 		$opportunity->liked = count($liked) > 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 		$opportunity->jobtype = elgg_echo($opportunityObj->job_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 		$opportunity->roletype = elgg_echo($opportunityObj->role_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 		$opportunity->deadline = $opportunityObj->deadline; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 		$opportunity->programArea = elgg_echo($opportunityObj->program_area); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 		$opportunity->owner = ($opportunityObj->getOwnerEntity() == $user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		$opportunity->iconURL = $opportunityObj->getIconURL(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 		$opportunity->userDetails = get_user_block($opportunity->owner_guid, $lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		$opportunity->description = clean_text(gc_explode_translation($opportunity->description, $lang)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 		$opportunity->state = $opportunityObj->state; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 	return $opportunities; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | function apply_post($user,$message,$guid, $lang) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 	$entity = get_entity($guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 	if (!$entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		return "Opportunity was not found. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 	if (!elgg_instanceof($entity, 'object', 'mission')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		return "Invalid opportunity. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	// Creates an applied relationship between user and mission if there is no relationship there already. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 	if(!check_entity_relationship($entity->guid, 'mission_accepted', $user_entity->guid) && !check_entity_relationship($entity->guid, 'mission_tentative', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 		add_entity_relationship($entity->guid, 'mission_applied', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 		$message_info = elgg_echo('missions:you_have_applied_to_mission', array($entity->job_title, $entity->name)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		$title_applicant_en = elgg_echo('missions:application_notice_sentence_title', array($user_entity->name, $entity->job_title),'en') ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 		$title_applicant_fr = elgg_echo('missions:application_notice_sentence_title', array($user_entity->name, $entity->job_title),'fr') ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		$content_applicant_en = elgg_echo('missions:application_notice_sentence', 'en') . '<br>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		$content_applicant_fr = elgg_echo('missions:application_notice_sentence', 'fr') . '<br>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 		$content_applicant_en .= '<br>'.elgg_echo('missions:see_full_profile','en') . ': ';  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 		$content_applicant_fr .= '<br>'.elgg_echo('missions:see_full_profile','fr') . ': ';  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 		$content_applicant_en .= '<a href="'.$user_entity->getURL().'">'.$user_entity->username.'<a/><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 		$content_applicant_fr .= '<a href="'.$user_entity->getURL().'">'.$user_entity->username.'<a/><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 		$content_applicant_en .= elgg_echo('missions:see_full_mission','en') . ': ';  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 		$content_applicant_fr .= elgg_echo('missions:see_full_mission','fr') . ': ';  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 		$content_applicant_en .= '<a href="'.$entity->getURL().'">'.$entity->job_title.'<a/><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 		$content_applicant_fr .= '<a href="'.$entity->getURL().'">'.$entity->job_title.'<a/><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 		$content_applicant_en .=  '<br>'.elgg_echo('missions:from_message',array($user_entity->username),'en').'<br><span style="font-style: italic;">'.$message . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 		$content_applicant_fr .=  '<br>'.elgg_echo('missions:from_message',array($user_entity->username),'fr').'<br><span style="font-style: italic;">'.$message . '</span><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		// Lists all educations of the applicant. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 		$education_list = $user_entity->education; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		if(!is_array($education_list)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 			$education_list = array_filter(array($education_list)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 		} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 450 |  | View Code Duplication | 		if(!empty($education_list)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 			foreach ($education_list as $education) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 				$education = get_entity($education); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 				$education_ending_en = date("F", mktime(null, null, null, $education->enddate)) . ', ' . $education->endyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 				$education_ending_fr = $cal_month[$education->enddate] . ', ' . $education->endyear; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 				if ($education->ongoing == 'true') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 					$education_ending_en = 'Present'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 					$education_ending_fr = 'Présent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 				$education_beginning_en = date("F", mktime(null, null, null, $education->startdate)) . ', ' . $education->startyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 				$education_beginning_fr = $cal_month[$education->startdate] . ', ' . $education->startyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 	  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 				// TODO: This section should be in the language files eventually. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 				$content_applicant_en .= '<br><b><font size="4">' . $education->school . ':</font></b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 				$content_applicant_en .=  $education_beginning_en . ' - ' . $education_ending_en . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 				$content_applicant_en .= '<b>' . $education->degree . ':</b> ' . $education->field . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 				$content_applicant_fr .= '<br><b><font size="4">' . $education->school . ':</font></b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 				$content_applicant_fr .=  $education_beginning_fr . ' - ' . $education_ending_fr . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 				$content_applicant_fr .= '<b>' . $education->degree . ':</b> ' . $education->field . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 		//Lists all work experiences of the applicant. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 		$experience_list = $user_entity->work; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 		if(!is_array($experience_list)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 			$experience_list = array_filter(array($experience_list)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 		} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 480 |  | View Code Duplication | 		if(!empty($experience_list)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 			foreach ($experience_list as $experience) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 				$experience = get_entity($experience); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 				$experience_ending_en = date("F", mktime(null, null, null, $experience->enddate)) . ', ' . $experience->endyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 				$experience_ending_fr = $cal_month[$experience->enddate] . ', ' . $experience->endyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 				if ($experience->ongoing == 'true') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 					$experience_ending_en = 'Present'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 					$experience_ending_fr = 'Présent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 				$experience_beginning_en = date("F", mktime(null, null, null, $experience->startdate)) . ', ' . $experience->startyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 				$experience_beginning_fr =  $cal_month[$experience->startdate] . ', ' . $experience->startyear; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 				// TODO: This section should be in the language files eventually. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 				$content_applicant_en .= '<br><b><font size="4">' . $experience->organization . ':</font></b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 				$content_applicant_en .= $experience_beginning_en . ' - ' . $experience_ending_en . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 				$content_applicant_en .= '<b>' . $experience->title . '</b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 				$content_applicant_en .= $experience->responsibilities . "<br><br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 				$content_applicant_fr .= '<br><b><font size="4">' . $experience->organization . ':</font></b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 				$content_applicant_fr .= $experience_beginning_fr . ' - ' . $experience_ending_fr . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 				$content_applicant_fr .= '<b>' . $experience->title . '</b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 				$content_applicant_fr .= $experience->responsibilities . "<br><br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		// Lists all skills of the applicant. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 		$skill_list = $user_entity->gc_skills; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		if(!is_array($skill_list)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 			$skill_list = array_filter(array($skill_list)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		} | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 510 |  | View Code Duplication | 		if(!empty($skill_list)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 			foreach ($skill_list as $skill) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 				$skill = get_entity($skill); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 				$content_applicant_en .= '<b>' . $skill->title . '</b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 				$content_applicant_fr .= '<b>' . $skill->title . '</b>' . "<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 		// Sends the application via email and notification. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 		$content_applicant_en .= elgg_view('output/url', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 				'href' => elgg_get_site_url() . 'missions/mission-offer/' . $entity->guid . '/' . $user_entity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 				'text' => '<br>'.elgg_echo('missions:offer','en') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 		$content_applicant_fr .= elgg_view('output/url', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 				'href' => elgg_get_site_url() . 'missions/mission-offer/' . $entity->guid . '/' . $user_entity->guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 				'text' => '<br>'.elgg_echo('missions:offer','fr') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 		$subject = elgg_echo('missions:application_to','en') . $entity->job_title.' | '.elgg_echo('missions:application_to','fr') . $entity->job_title; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 		mm_notify_user($entity->guid, $user_entity->guid, $subject,$title_applicant_en,$title_applicant_fr, $content_applicant_en, $content_applicant_fr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 	// Opt in applicant if they are not opted in yet. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 	if(!check_if_opted_in($user_entity)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		$user_entity->opt_in_missions = 'gcconnex_profile:opt:yes'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 		$user_entity->save(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 	return $message_info; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | function withdraw_post($user,$message,  $guid, $lang) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 	$entity = get_entity($guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 	if (!$entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 		return "Opportunity was not found. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 	if (!elgg_instanceof($entity, 'object', 'mission')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 		return "Invalid opportunity. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 	// Deletes the tentative relationship between mission and applicant. | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 567 |  | View Code Duplication | if(check_entity_relationship($entity->guid, 'mission_tentative', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 	$message_return = 'missions:declination_has_been_sent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 	remove_entity_relationship($entity->guid, 'mission_tentative', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | if(check_entity_relationship($entity->guid, 'mission_applied', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 	$message_return = 'missions:withdrawal_has_been_sent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 	remove_entity_relationship($entity->guid, 'mission_applied', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 575 |  | View Code Duplication | if(check_entity_relationship($entity->guid, 'mission_offered', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 	$message_return = 'missions:declination_has_been_sent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 	remove_entity_relationship($entity->guid, 'mission_offered', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 579 |  | View Code Duplication | if(check_entity_relationship($entity->guid, 'mission_accepted', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 	$message_return = 'missions:withdrawal_has_been_sent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 	remove_entity_relationship($entity->guid, 'mission_accepted', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |   mm_complete_mission_inprogress_reports($entity, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | $reason = array('workload', 'interest', 'engagement', 'approval'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | if (in_array($message,$reason)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 	$reasonEn = elgg_echo('missions:decline:'.$message,'en'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 	$reasonFr = elgg_echo('missions:decline:'.$message,'fr'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | }else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 	$reasonEn = $message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 	$reasonFr = $message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | $mission_link = '<a href="'.$entity->getURL().'" >'.elgg_get_excerpt($entity->job_title, elgg_get_plugin_setting('mission_job_title_card_cutoff', 'missions')).' </a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | $subject = elgg_echo('missions:applicant_leaves', array($user_entity->name),'en')." | ". elgg_echo('missions:applicant_leaves', array($user_entity->name),'fr'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | $withdrawnEn .= elgg_echo('missions:applicant_leaves_more', array($user_entity->name),'en') . $mission_link . '.' . "\n"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | $withdrawnReasonEn .= elgg_echo('missions:reason_given', array($reasonEn),'en'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | $withdrawnFr .= elgg_echo('missions:applicant_leaves_more', array($user_entity->name),'fr') . $mission_link . '.' . "\n"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | $withdrawnReasonFr .= elgg_echo('missions:reason_given', array($reasonFr),'fr'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | mm_notify_user($entity->guid, $user_entity->guid, $subject, $withdrawnEn, $withdrawnFr,$withdrawnReasonEn ,$withdrawnReasonFr ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 	return elgg_echo($message_return, array($entity->job_title)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | function accept_post($user, $guid, $lang) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 	$entity = get_entity($guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 	if (!$entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 		return "Opportunity was not found. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 	if (!elgg_instanceof($entity, 'object', 'mission')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 		return "Invalid opportunity. Please try a different GUID"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 633 |  | View Code Duplication | 	if(check_entity_relationship($entity->guid, 'mission_offered', $user_entity->guid)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		remove_entity_relationship($entity->guid, 'mission_offered', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 		add_entity_relationship($entity->guid, 'mission_accepted', $user_entity->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 	$mission_link = '<a href="'.$entity->getURL().'">'.$entity->title.'</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 		// notify participant | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 		$subject = elgg_echo('missions:participating_in', array(elgg_get_excerpt($entity->job_title, elgg_get_plugin_setting('mission_job_title_card_cutoff', 'missions'))),'en').' | '.elgg_echo('missions:participating_in', array(elgg_get_excerpt($entity->job_title, elgg_get_plugin_setting('mission_job_title_card_cutoff', 'missions'))),'fr'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 		$message_en = elgg_echo('missions:participating_in_more', array($user_entity->name),'en') . $mission_link . '.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 		$message_fr = elgg_echo('missions:participating_in_more', array($user_entity->name),'fr') . $mission_link . '.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 		mm_notify_user($user_entity->guid, $entity->guid, $subject, '','',$message_en,$message_fr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 		// notify owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 		$subject = elgg_echo( 'missions:participating_in2', array($user_entity->name),'en').' | '.elgg_echo( 'missions:participating_in2', array($user_entity->name),'fr'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 		$message_en = elgg_echo('missions:participating_in2_more', array($user_entity->name),'en') . $mission_link . '.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 		$message_fr = elgg_echo('missions:participating_in2_more', array($user_entity->name),'fr') . $mission_link . '.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 		mm_notify_user($entity->guid, $user_entity->guid, $subject, '','',$message_en,$message_fr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 	return elgg_echo('missions:now_participating_in_mission', array($entity->job_title)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 657 |  |  | function create_opportinities1($user, $formData, $lang) | 
            
                                                                        
                            
            
                                    
            
            
                | 658 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 659 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                        
                            
            
                                    
            
            
                | 660 |  |  | 	if (!$user_entity) { | 
            
                                                                        
                            
            
                                    
            
            
                | 661 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                        
                            
            
                                    
            
            
                | 662 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 663 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                        
                            
            
                                    
            
            
                | 664 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                        
                            
            
                                    
            
            
                | 665 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 666 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 667 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 668 |  |  | 		login($user_entity); | 
            
                                                                        
                            
            
                                    
            
            
                | 669 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 670 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 671 |  |  | 	elgg_make_sticky_form('firstfill'); | 
            
                                                                        
                            
            
                                    
            
            
                | 672 |  |  | 	 | 
            
                                                                        
                            
            
                                    
            
            
                | 673 |  |  | 	$err = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 674 |  |  | 	 | 
            
                                                                        
                            
            
                                    
            
            
                | 675 |  |  | 	$first_form = elgg_get_sticky_values('firstfill'); | 
            
                                                                        
                            
            
                                    
            
            
                | 676 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 677 |  |  | 	$first_form['name'] = $formData["name"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 678 |  |  | 	$first_form['department'] = $formData["departement"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 679 |  |  | 	$first_form['email'] = $formData["email"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 680 |  |  | 	$first_form['phone'] = $formData["phone"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 681 |  |  | 	$first_form['disclaimer'] = $formData["agree"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 682 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 683 |  |  | 	// Error checking function. | 
            
                                                                        
                            
            
                                    
            
            
                | 684 |  |  | 	$err .= mm_first_post_error_check($first_form); | 
            
                                                                        
                            
            
                                    
            
            
                | 685 |  |  | 	if ($err != '') { | 
            
                                                                        
                            
            
                                    
            
            
                | 686 |  |  | 		return('error in first form: '.$err); | 
            
                                                                        
                            
            
                                    
            
            
                | 687 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 688 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 689 |  |  | 	return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 690 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | function create_opportinities2($user, $formData, $lang) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 	elgg_make_sticky_form('secondfill'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 	$_SESSION['mission_duplicating_override_second'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 	$err = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 	$second_form = elgg_get_sticky_values('secondfill'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 	$second_form['job_title'] = $formData["title"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  | 	$second_form['role_type'] = $formData["offert"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 	$second_form['job_type'] = $formData["type"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | 	$second_form['job_area'] = $formData["program"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 	$second_form['number'] = $formData["num_opt"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 	$second_form['start_date'] = $formData["start_date"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 	$second_form['completion_date'] = $formData["completion_date"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 	$second_form['deadline'] = $formData["deadline"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 	$second_form['description'] = $formData["description"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  | 	// Error checking function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 	$err .= mm_second_post_error_check($second_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  | 	if ($err != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 		return('error in second form: '.$err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 	return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | function create_opportinities3($user, $formData,$lang) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | 	if (!$user_entity) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 		return "User was not found. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 	if (!$user_entity instanceof ElggUser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 		return "Invalid user. Please try a different GUID, username, or email address"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 	if (!elgg_is_logged_in()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  | 		login($user_entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | elgg_make_sticky_form('thirdfill'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | $_SESSION['mission_duplicating_override_third'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | $first_form = elgg_get_sticky_values('firstfill'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  | $second_form = elgg_get_sticky_values('secondfill'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | $third_form = elgg_get_sticky_values('thirdfill'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | $err = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  | // Error checking function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | $first_form['name'] = $first_form['formData']["name"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | $first_form['department'] = $first_form['formData']["departement"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | $first_form['email'] = $first_form['formData']["email"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | $first_form['phone'] = $first_form['formData']["phone"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | $first_form['disclaimer'] = $first_form['formData']["agree"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |  $err .= mm_first_post_error_check($first_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |  $second_form['job_title'] = $second_form['formData']["title"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |  $second_form['role_type'] = $second_form['formData']["offert"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |  $second_form['job_type'] = $second_form['formData']["type"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |  $second_form['job_area'] = $second_form['formData']["program"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |  $second_form['number'] = $second_form['formData']["num_opt"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |  $second_form['start_date'] = $second_form['formData']["start_date"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |  $second_form['completion_date'] = $second_form['formData']["completion_date"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |  $second_form['deadline'] = $second_form['formData']["deadline"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |  $second_form['description'] = $second_form['formData']["description"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |  error_log(print_r($second_form,true)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |  $err .= mm_second_post_error_check($second_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |  $third_form['key_skills'] = $third_form['formData']["skills"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |  $third_form['time_commitment'] = $third_form['formData']["hours"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |  $third_form['time_interval'] = $third_form['formData']["repetition"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |  $third_form['timezone'] = $third_form['formData']["timezone"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |  $third_form['mon_start'] = $third_form['formData']["mon_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |  $third_form['mon_duration'] = $third_form['formData']["mon_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |  $third_form['tue_start'] = $third_form['formData']["tue_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |  $third_form['tue_duration'] = $third_form['formData']["tue_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |  $third_form['wed_start'] = $third_form['formData']["wed_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |  $third_form['wed_duration'] = $third_form['formData']["wed_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |  $third_form['thu_start'] = $third_form['formData']["thu_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |  $third_form['thu_duration'] = $third_form['formData']["thu_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |  $third_form['fri_start'] = $third_form['formData']["fri_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |  $third_form['fri_duration'] = $third_form['formData']["fri_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |  $third_form['sat_start'] = $third_form['formData']["sat_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |  $third_form['sat_duration'] = $third_form['formData']["sat_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |  $third_form['sun_start'] = $third_form['formData']["sun_start"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |  $third_form['sun_duration'] = $third_form['formData']["sun_duration"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |  $third_form['remotely'] = $third_form['formData']["remotly"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |  $third_form['location'] = $third_form['formData']["location"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |  $third_form['security'] = $third_form['formData']["security"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |  $err .= mm_third_post_error_check($third_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  | // A specialized function for checking for errors in the time fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | $err .= mm_validate_time_all($third_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |  if($err == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |  	$err .= mm_third_post_special_error_check($third_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |  } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |  if ($err != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 	return $err; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | }else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |     // Creation of an ELGGObject of subtype Mission | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |     $mission = new ElggObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |     $mission->subtype = 'mission'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |     $mission->title = $second_form['job_title']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |     $mission->description = $second_form['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |     $mission->access_id = ACCESS_LOGGED_IN; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |     $mission->owner_guid = elgg_get_logged_in_user_guid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |     // Attaches the form data as metadata to the object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |     $mission->name = $first_form['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |     // If the organization tree is loaded, then the custom dropdown values will be processed and stored. | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 823 |  | View Code Duplication |     if(mo_get_tree_root()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  | 	   	$department_string = mo_get_last_input_node($first_form); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  | 		$department_paths = mo_string_all_ancestors($department_string); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 		$mission->department = $department_string; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 		$mission->department_path_english = $department_paths['english_path']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  | 		$mission->department_path_french = $department_paths['french_path']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |     // If the organization tree is not loaded, then the basic free text entry will be stored. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |     else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |     	$mission->department = $first_form['department']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  | 		$mission->department_path_english = $first_form['department']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 		$mission->department_path_french = $first_form['department']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |     $mission->email = $first_form['email']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |     $mission->phone = $first_form['phone']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |     $accounts = get_user_by_email($first_form['email']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  | //Compare email and username for user with more than one account | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 		foreach ($accounts as $key) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  | 			if($key->name == $first_form['name']){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  | 				$guid_account[] = $key; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 848 |  | View Code Duplication | 		if($guid_account){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 			    $mission->account = array_pop($guid_account)->guid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 		}else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 			    $mission->account = array_pop($accounts)->guid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |     $mission->job_title = $second_form['job_title']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |     $mission->role_type = $second_form['role_type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |     $mission->job_type = $second_form['job_type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  | 	// Stores the value of program area selected unless it is other. | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 859 |  | View Code Duplication |     if($second_form['job_area'] != 'missions:other') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |     	$mission->program_area = $second_form['job_area']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  | 	// When other is selected, the free text entry is stored instead. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |     else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |     	$mission->program_area = $second_form['other_text']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |     $mission->number = $second_form['number']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |     $mission->start_date = $second_form['start_date']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |     $mission->completion_date = $second_form['completion_date']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |     $mission->deadline = $second_form['deadline']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |     $mission->descriptor = $second_form['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  |     $mission->openess = $second_form['openess']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 		//Nick - Adding group and level to the mission meta data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 		if($second_form['group']){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 			$mission->gl_group = $second_form['group']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  | 			$mission->gl_level = $second_form['level']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |     $mission->remotely = $third_form['remotely']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |     $mission->security = $third_form['security']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |     $mission->location = $third_form['location']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |     $mission->time_commitment = $third_form['time_commitment']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |     $mission->time_interval = $third_form['time_interval']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |     $mission->timezone = $third_form['timezone']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |     // Stores the multiple skill fields in a comma separated string. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |     $count = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |     $key_skills = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |     $skill_array = array(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 890 |  | View Code Duplication |     foreach($third_form as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |     	if(!(strpos($key, 'skill') === false) && $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |     		$skill_array[$count] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |     		if($count == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |     			$key_skills .= $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |     		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |     			$key_skills .= ', ' . $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |     		$count++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |     	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |     $mission->key_skills = $key_skills; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |     $mission->english = mm_pack_language($third_form['lwc_english'], $third_form['lwe_english'], $third_form['lop_english'], 'english'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |     $mission->french = mm_pack_language($third_form['lwc_french'], $third_form['lwe_french'], $third_form['lop_french'], 'french'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 	$mission->mon_start = $third_form['mon_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |     $mission->mon_duration = $third_form['mon_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |     $mission->tue_start = $third_form['tue_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |     $mission->tue_duration = $third_form['tue_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |     $mission->wed_start = $third_form['wed_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |     $mission->wed_duration = $third_form['wed_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |     $mission->thu_start = $third_form['thu_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |     $mission->thu_duration = $third_form['thu_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |     $mission->fri_start = $third_form['fri_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |     $mission->fri_duration = $third_form['fri_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |     $mission->sat_start = $third_form['sat_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |     $mission->sat_duration = $third_form['sat_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |     $mission->sun_start = $third_form['sun_start']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |     $mission->sun_duration = $third_form['sun_duration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |     $mission->state = 'posted'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |     $mission->version = elgg_get_plugin_setting('mission_version', 'missions'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |     $mission->time_to_post = time() - $_SESSION['mission_creation_begin_timestamp']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |     // Sends the object and all its metadata to the database | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |     $mission->save(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |     $mission->meta_guid = $mission->guid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |     $mission->save(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |     // Generate an analytics record to track "posted". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |     $analytics_record = new ElggObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |     $analytics_record->subtype = 'mission-posted'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  |     $analytics_record->title = 'Mission Posted Report'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |     $analytics_record->mission_guid = $mission->guid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |     $analytics_record->access_id = ACCESS_LOGGED_IN; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |     $analytics_record->save(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |     // Creates a relationships between the user (manager) and the mission. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |     add_entity_relationship($mission->account, 'mission_posted', $mission->guid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |     // Add to the river so it can be seen on the main page. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |     elgg_create_river_item(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |         'view' => 'river/object/mission/create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |         'action_type' => 'create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |         'subject_guid' => $mission->owner_guid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |         'object_guid' => $mission->getGUID() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |     )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |     if(count($skill_array) == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |     	$message = elgg_echo('missions:succesfully_posted', array($mission->job_title)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |     else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  | 	    if($third_form['hidden_java_state'] == 'noscript') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 	    	// Required action security tokens. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  | 	    	$ts = time(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  | 	    	$token = generate_action_token($ts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  | 	    	set_input('__elgg_ts', $ts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  | 	    	set_input('__elgg_token', $token); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  | 	    	action('missions/post-mission-skill-match'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  | 	    else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  | 		    $_SESSION['mission_skill_match_is_interlude'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  | 		    $message = (elgg_echo('missions:saved_beginning_skill_match', array($key_skills))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  | return $message; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 974 |  |  | 	 | 
            
                                                        
            
                                    
            
            
                | 975 |  |  | } | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: