18 require_once SQ_SYSTEM_ROOT.
'/core/attributes/parameter_map/parameter_map.inc';
41 parent::__construct($assetid);
55 public static function getInterface($settings, $prefix, $write_access=FALSE)
64 $user_group_to_join = isset($settings[
'user_group_to_join']) ? $settings[
'user_group_to_join'] :
'';
66 asset_finder($prefix.
'[user_group_to_join]', $user_group_to_join, $type_codes);
67 }
else if (!empty($user_group_to_join)) {
68 $user_group_asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($user_group_to_join);
69 if (!empty($user_group_asset_info[$user_group_to_join])) {
70 echo
'<b>'.$user_group_asset_info[$user_group_to_join][
'name'].
' (#'.$user_group_to_join.
')</b>';
73 $user_group_input = ob_get_clean();
77 $keyword_target_groupid = isset($settings[
'keyword_target_groupid']) ? $settings[
'keyword_target_groupid'] :
'';
79 text_box($prefix.
'[keyword_target_groupid]', $keyword_target_groupid, 30);
81 echo htmlspecialchars($keyword_target_groupid);
83 $keyword_target_groupid_input = ob_get_clean();
86 $output = translate(
'trigger_join_user_for_session', $user_group_input, $keyword_target_groupid_input);
106 $settings[
'user_group_to_join'] = isset($request_data[
'user_group_to_join'][
'assetid']) ? $request_data[
'user_group_to_join'][
'assetid'] : NULL;
107 $settings[
'keyword_target_groupid'] = isset($request_data[
'keyword_target_groupid']) ? $request_data[
'keyword_target_groupid'] :
'';
124 public static function execute($settings, &$state)
127 $value = @$settings[
'user_group_to_join'];
131 $value = @$settings[
'keyword_target_groupid'];
132 if (!empty($value)) {
134 replace_global_keywords($value);
137 $keywords = retrieve_keywords_replacements($value);
138 $replacements = Array();
139 foreach ($keywords as $keyword) {
140 $replacements[$keyword] = $state[
'asset']->getKeywordReplacement($keyword);
142 replace_keywords($value, $replacements);
145 if (!is_numeric($value))
return FALSE;
146 $user_group = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($value);
147 if (!$user_group || !$user_group instanceof
User_Group)
return FALSE;
155 $current_user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($GLOBALS[
'SQ_SYSTEM']->user->id);
156 if (!$current_user || !$current_user instanceof
User) {
161 $current_groups = $current_user->getUserGroups();
165 if (!in_array($value, $_SESSION[
'sq_effective_user_groups'][$GLOBALS[
'SQ_SYSTEM']->user->id])) {
166 $_SESSION[
'sq_effective_user_groups'][$GLOBALS[
'SQ_SYSTEM']->user->id][] = $value;
170 'group_joined' => $value,