function setup_module($column, $module, $obj) { /* in this module we have to set user_id , group_id, as well as netwrok_id */ global $type, $group_data, $is_member, $msg, $show_view; $obj->type = $type; $obj->show_view = $show_view; switch ($module) { case 'ImagesMediaGalleryModule': case 'AudiosMediaGalleryModule': case 'VideosMediaGalleryModule': if ($group_data->reg_type == REG_INVITE && $is_member == NOT_A_MEMBER) { $msg = MessagesHandler::get_message(9005); return "skip"; } break; } }
function initializeModule($request_method, $request_data) { global $error_msg; $error = false; $msg = array(); $form_data = NULL; $edit = false; $message = NULL; // check permissions! $user_may = false; $user_may = PermissionsHandler::can_user(PA::$login_uid, array('permissions' => 'manage_ads')); // check for manageads of group permissions if (!empty($_REQUEST['gid']) && !$user_may) { // we do this checl only if the user is not already permitted to manage ads $gp_access = PermissionsHandler::can_group_user(PA::$login_uid, $_REQUEST['gid'], array('permissions' => 'manage_ads')); $user_may = $gp_access; } if (!$user_may) { $error_msg = __("You do not have permission to manage Ads."); return "skip"; } // paging if (!empty($request_data['page'])) { $this->Paging["page"] = (int) $request_data['page']; } if (!empty($request_data['action']) && $request_data['action'] == 'edit' && !empty($request_data['ad_id'])) { $edit = TRUE; $res = Advertisement::get($params = NULL, $condition = array('ad_id' => (int) $request_data['ad_id'])); if (!empty($res)) { $form_data['ad_id'] = $res[0]->ad_id; $form_data['ad_image'] = $res[0]->ad_image; $form_data['ad_script'] = $res[0]->ad_script; $form_data['ad_url'] = $res[0]->url; $form_data['ad_title'] = $res[0]->title; $form_data['ad_description'] = $res[0]->description; $form_data['ad_page_id'] = $res[0]->page_id; $form_data['orientation'] = $res[0]->orientation; $form_data['created'] = $res[0]->created; } } else { if (!empty($request_data['action']) && $request_data['action'] == 'delete' && !empty($request_data['ad_id'])) { if (!empty($request_data['ad_id'])) { try { Advertisement::delete((int) $request_data['ad_id']); $error_msg = 19013; } catch (CNException $e) { $msg[] = $e->message; } } } else { if (!empty($request_data['action']) && !empty($request_data['ad_id'])) { $update = false; switch ($request_data['action']) { case 'disable': $field_value = DELETED; $msg_id = 19010; $update = true; break; case 'enable': $field_value = ACTIVE; $msg_id = 19011; $update = true; break; } if ($update) { $update_fields = array('is_active' => $field_value); $condition = array('ad_id' => $request_data['ad_id']); try { Advertisement::update($update_fields, $condition); $error_msg = $msg_id; } catch (CNException $e) { $msg[] = $e->message; } } } } } $advertisement = new Advertisement(); if (!$error && $request_method == 'POST' && $request_data['btn_apply_name']) { // if page is submitted if (!empty($request_data['ad_id'])) { $advertisement->ad_id = $request_data['ad_id']; $advertisement->created = $request_data['created']; $msg_id = 19007; } else { $msg_id = 19008; $advertisement->created = time(); } if (!empty($_FILES['ad_image']['name'])) { $filename = $_FILES['ad_image']['name']; $uploadfile = PA::$upload_path . basename($filename); $myUploadobj = new FileUploader(); $file = $myUploadobj->upload_file(PA::$upload_path, 'ad_image', TRUE, TRUE, 'image'); $advertisement->ad_image = $form_data['ad_image'] = $file; if ($file == FALSE) { $error = TRUE; $msg[] = $myUploadobj->error; } } else { if (!empty($request_data['ad_id'])) { $advertisement->ad_image = $request_data['edit_image']; } } if (empty($request_data['ad_url']) && empty($request_data['ad_script'])) { $error = TRUE; $msg[] = MessagesHandler::get_message(19012); } if (!empty($request_data['ad_url'])) { // if url is given then validate $request_data['ad_url'] = Validation::validate_url($request_data['ad_url']); if (!Validation::isValidURL($request_data['ad_url'])) { $error = TRUE; $msg[] = MessagesHandler::get_message(19009); } } $advertisement->user_id = PA::$login_uid; $advertisement->url = $form_data['ad_url'] = $request_data['ad_url']; $advertisement->ad_script = $form_data['ad_script'] = $request_data['ad_script']; $advertisement->title = $form_data['ad_title'] = $request_data['ad_title']; $advertisement->description = $form_data['ad_description'] = $request_data['ad_description']; $advertisement->page_id = $form_data['ad_page_id'] = $request_data['ad_page_id']; $advertisement->orientation = $form_data['orientation'] = $request_data['x_loc'] . ',' . $request_data['y_loc']; $advertisement->changed = time(); $advertisement->is_active = ACTIVE; if (!empty($_REQUEST['gid'])) { $advertisement->group_id = (int) $_REQUEST['gid']; } if (!$error) { try { $ad_id = $advertisement->save(); if (!empty($file)) { Storage::link($file, array("role" => "ad", "ad" => $ad_id)); } $error_msg = $msg_id; } catch (CNException $e) { $error_msg = $e->message; } } else { $error_msg = implode("<br/>", $msg); } } $this->form_data = $form_data; $this->edit = $edit; $this->message = $message; }
<?php $login_required = FALSE; $use_theme = 'Beta'; //TODO : Remove this when new UI is completely implemented. include "includes/page.php"; require_once "{$path_prefix}/ext/StaticPage/StaticPage.php"; $msg = array(); $page = !empty($_GET['caption']) ? $_GET['caption'] : NULL; $static_page = StaticPage::get(array('url' => $page)); if (empty($static_page)) { $msg[] = MessagesHandler::get_message(12009); } function setup_module($column, $module, $obj) { global $static_page; switch ($module) { case 'StaticPageDisplayModule': if (!empty($msg)) { return 'skip'; } $obj->text = $static_page[0]->page_text; break; } } $page = new PageRenderer("setup_module", PAGE_STATIC_PAGE_DISPLAY, "Static Pages", "container_two_column.tpl", "header_user.tpl", NULL, PRI, $network_info); if (!empty($msg)) { for ($counter = 0; $counter < count($msg); $counter++) { $message .= $msg[$counter] . "<br>"; } }
//.. end of edit // If we have come this far it means it is not edit and we have to create post //save post normally if ($_POST['route_to_pa_home'] == 1) { $display_on_homepage = DISPLAY_ON_HOMEPAGE; //its zero } else { $display_on_homepage = NO_DISPLAY_ON_HOMEPAGE; //This will not show up on homepage - flag has opposite values } $post_saved = BlogPost::save_blogpost(0, $login_uid, $_POST["blog_title"], $_POST["description"], NULL, $terms, -1, 1, $display_on_homepage); $permalink_cid = $post_saved['cid']; if ($extra['network_content_moderation'] == NET_YES && $network_info->owner_id != $user->user_id) { Network::moderate_network_content(-1, $permalink_cid); // -1 for contents; not a part of any collection $error_msg = "&err=" . urlencode(MessagesHandler::get_message(1004)); } $content_author_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"'); $network_owner_name = User::map_ids_to_logins($network_info->owner_id); $params['cid'] = $permalink_cid; $params['first_name'] = $user->first_name; $params['user_id'] = $user->user_id; $params['user_image'] = $content_author_image; $params['content_title'] = $_POST["blog_title"]; $params['network_name'] = $network_info->name; $params['content_url'] = PA::$url . '/' . FILE_CONTENT . '?cid=' . $permalink_cid; $params['content_moderation_url'] = PA::$url . '/' . FILE_NETWORK_MANAGE_CONTENT; $params['config_site_name'] = $config_site_name; $params['network_owner_name'] = $network_owner_name[$network_info->owner_id]; auto_email_notification('content_posted', $params); if ($_POST['route_to_pa_home'] == 1) {
function _error_msg($msg) { // for accessing the Page-Render variable global $page, $global_form_error; if (empty($msg) && empty($global_form_error)) return; $error = $global_form_error; unset($global_form_error); if (!empty($error)) { $msg = $error; } if (is_numeric($msg)) { $msg_obj = new MessagesHandler(); $msg = $msg_obj->get_message($msg); } ?> <div class="error"> <?=$msg?> </div> <? } ?>
if ($v1 == 1 && $v2 == 0) { $r = NET_EMAIL; } else { if ($v1 == 0 && $v2 == 1) { $r = NET_MSG; } } } } return $r; } $page = new PageRenderer("setup_module", PAGE_EMAIL_NOTIFICATION, "Email Notification", 'container_two_column.tpl', 'header.tpl', PRI, HOMEPAGE, $network_info); // if any message code is set then fetch that message if (is_int($error_msg)) { $msg_obj = new MessagesHandler(); $error_msg = $msg_obj->get_message((int) $error_msg); } else { // else text message is set $error_msg = !empty($error_msg) ? $error_msg : $permission_denied_msg; } if (!empty($error_msg)) { $msg_tpl =& new Template(CURRENT_THEME_FSPATH . "/display_message.tpl"); $msg_tpl->set('message', $error_msg); $m = $msg_tpl->fetch(); $page->add_module("middle", "top", $m); } $page->html_body_attributes = 'class="no_second_tier network_config"'; $css_array = get_network_css(); if (is_array($css_array)) { foreach ($css_array as $key => $value) { $page->add_header_css($value);
$cache_id = 'in_relation_private_' . $delete_id; CachedTemplate::invalidate_cache($cache_id); $cache_id = 'in_relation_public_' . $delete_id; CachedTemplate::invalidate_cache($cache_id); header("Location: user.php?uid={$delete_id}&delete=1"); } $is_error = FALSE; $edit = FALSE; $uid = $_SESSION['user']['id']; if (empty($_GET['uid'])) { $is_error = TRUE; } $relation_uid = $_GET['uid']; $message = NULL; if ($relation_uid == $uid) { $message = MessagesHandler::get_message(1050); $is_error = TRUE; } // TODO: Need to get entry of uid, relation_uid from table, not all the relation of uid //getting relations of logged in user $all_relations = Relation::get_all_relations((int) $uid); $relationship_level = 2; //default relation level id is 2 for friend $in_family = false; foreach ($all_relations as $relation) { if ($relation_uid == $relation['user_id']) { $relationship_level = $relation['relation_type_id']; $in_family = $relation['in_family']; $status = $relation['status']; if ($status == PENDING) { $extra = unserialize($network_info->extra);
$subject = $_POST['subject']; $message = $_POST['email_message']; // say $container_html is '/default_email_container.tpl' $container_html = 'default_email_container.tpl'; $email_container =& new Template($path_prefix . '/web/Themes/Beta/email_container/' . $container_html); $email_container->set('subject', $subject); $email_container->set('message', $message); $preview_msg = $email_container->fetch(); } } } function setup_module($column, $module, $obj) { global $subject, $message, $configurable_variables, $preview_msg; switch ($module) { case 'ConfigureEmailModule': $obj->subject = $subject; $obj->message = $message; $obj->configurable_variables = $configurable_variables; $obj->preview_msg = $preview_msg; break; } } $page = new PageRenderer("setup_module", PAGE_CONFIGURE_EMAIL, "Configure Email", "container_two_column.tpl", "header.tpl", NULL, PRI, $network_info); if (!empty($_GET['msg'])) { $msg[] = MessagesHandler::get_message($_GET['msg']); uihelper_error_msg($msg); } uihelper_get_network_style($page); $page->html_body_attributes = 'class="no_second_tier network_config"'; echo $page->render();
if (trim($_POST[$key]) == '') { $error = TRUE; $msg .= $value['caption'] . ' cant be empty<br>'; } else { $form_data['extra']['relationship_options'][$key]['value'] = $_POST[$key]; } } // save if (!$error) { $network = new Network(); $extra = $form_data['extra']; $data = array('network_id' => $network_info->network_id, 'extra' => serialize($extra), 'changed' => time()); $network->set_params($data); try { $nid = $network->save(); $msg = MessagesHandler::get_message(7012); } catch (PAException $e) { $error = TRUE; $msg = "{$e->message}"; } } } function setup_module($column, $module, $obj) { global $form_data, $error, $configure_permission, $network_info, $msg; if (!$configure_permission) { return 'skip'; } $obj->tpl_to_load = "relation_settings"; $obj->control_type = "relations"; $obj->form_data = $form_data;
} // Check for valid-invalid email addresses end // Action for valid-invalid email addresses start if (empty($friend_email) && empty($friend_user_name)) { // if email field is left empty $msg[] = MessagesHandler::get_message(6001); $error = TRUE; } else { if (!empty($friend_email) && !empty($friend_user_name)) { $msg = array(); $msg[] = MessagesHandler::get_message(7026); $error = TRUE; } elseif ($self_invite || sizeof($invalid) > 0) { // if self invitation is made if ($self_invite) { $msg[] = MessagesHandler::get_message(6002); } if (!empty($invalid)) { // if invalid email addresses are supplied $invalid_cnt = count($invalid); $invalid_msg = ''; for ($counter = 0; $counter < $invalid_cnt; $counter++) { if (!empty($invalid[$counter])) { $invalid_msg .= $invalid[$counter] . ', '; } } if (!empty($invalid_msg)) { $invalid_msg = substr($invalid_msg, 0, -2); $msg[] = "Invitation could not be sent to following email addresses- " . $invalid_msg; } }
throw $e; } } $page = new PageRenderer("setup_module", PAGE_MODULE_SELECTOR, "Module Selector", 'container_two_column.tpl', 'header.tpl', PRI, HOMEPAGE, $network_info); function setup_module($column, $module, $obj) { global $module_settings, $configure_permission, $page_id; if (!$configure_permission) { return 'skip'; } $obj->module_settings = $module_settings; $obj->page_id = $page_id; } if (is_int($msg)) { $msg_obj = new MessagesHandler(); $msg = $msg_obj->get_message((int) $msg); switch ($page_id) { case PAGE_HOMEPAGE: $redirect_url = "{$base_url}/homepage.php"; break; case PAGE_USER_PUBLIC: $redirect_url = "{$base_url}/user_blog.php"; break; case PAGE_GROUPS_HOME: $redirect_url = "{$base_url}/groups_home.php"; break; case PAGE_NETWORKS_HOME: $redirect_url = "{$base_url}/networks_home.php"; break; } $msg .= "<a href ={$redirect_url}>Click here</a> to view the result";
} $obj->Paging["page"] = $paging["page"]; $obj->Paging["show"] = 10; $obj->network_info = PA::$network_info; $obj->super_user_and_mothership = $super_user_and_mothership; break; } } $page = new PageRenderer("setup_module", PAGE_NETWORK_MODERATE_USERS, "Moderate Registered Users", 'container_two_column.tpl', 'header.tpl', PUB, HOMEPAGE, PA::$network_info); if (!empty($_GET['msg'])) { $message = $_GET['msg']; } if (!empty($message) && is_int($message)) { require_once 'web/languages/english/MessagesHandler.php'; $msg_obj = new MessagesHandler(); $message = $msg_obj->get_message($message); } if (!empty($message)) { $msg_tpl = new Template(CURRENT_THEME_FSPATH . "/display_message.tpl"); $msg_tpl->set('message', $message); $m = $msg_tpl->fetch(); $page->add_module("middle", "top", $m); } $page->html_body_attributes = 'class="no_second_tier network_config"'; $css_array = get_network_css(); if (is_array($css_array)) { foreach ($css_array as $key => $value) { $page->add_header_css($value); } } $css_data = inline_css_style();
function initializeModule($request_method, $request_data) { // echo "<pre>" . print_r($request_data, 1) . "</pre>"; if (!empty($request_data['show_msg'])) { $this->error_msg = $request_data['show_msg']; } // echo "Message is: " . $this->error_msg . "<br />"; if (empty($this->error_msg)) { return 'skip'; } if (!empty($request_data['redirect_url'])) { $this->redirect_url = urldecode($request_data['redirect_url']); } if (!empty($request_data['redirect_delay'])) { $this->redirect_delay = $request_data['redirect_delay']; } if (!empty($request_data['msg_type'])) { if (in_array($request_data['msg_type'], $this->msg_types)) { $this->type = $request_data['msg_type']; } else { $this->type = 'error'; } } switch ($this->type) { case 'info': $this->window_title = __('Information'); $this->title = ''; break; case 'error': $this->window_title = __('Error details'); break; case 'confirm': $this->window_title = __('Please confirm action'); $this->title = ''; break; case 'warning': $this->window_title = __('Warning!'); $this->title = ''; break; default: if (!empty($request_data['window_title'])) { $this->window_title = $request_data['window_title']; } break; } if (is_numeric($this->error_msg)) { $msg_obj = new MessagesHandler(); $this->error_msg = $msg_obj->get_message($this->error_msg); } else { $this->error_msg = urldecode($this->error_msg); } if (!empty($this->redirect_url)) { $js = "<script type=\"text/javascript\">\n\r\n var redirect_url='" . $this->redirect_url . "';\n\r"; if ($this->redirect_delay > 0) { $js .= "var redirect_delay='" . $this->redirect_delay . "';\n\r"; } $js .= "</script>"; $this->renderer->add_header_html($js); } $template_name = "show_" . $this->type . "_message.tpl"; $this->set_inner_template($template_name); $this->inner_HTML = $this->generate_inner_html(array('error_msg' => $this->error_msg, 'type' => $this->type, 'window_title' => $this->window_title, 'redirect_url' => $this->redirect_url, 'redirect_delay' => $this->redirect_delay)); }
return 'skip'; } $obj->mode = PRI; break; } } $page = new PageRenderer("setup_module", PAGE_LOGIN, "Login page", "container_three_column.php", "header.php", PUB, HOMEPAGE, PA::$network_info); // added by Zoran Hron: JQuery validation & AJAX file upload -- $page->add_header_html(js_includes('jquery.validate.js')); $page->add_header_html(js_includes('jquery.metadata.js')); $page->add_header_html(js_includes('ajaxfileupload.js')); $page->add_header_html(js_includes('user_registration.js')); // ------------------------------------------------------------ $page->add_header_html(js_includes('common.js')); $page->add_header_html(js_includes('login.js')); if (isset($_GET['msg_id'])) { $msg = MessagesHandler::get_message($_GET['msg_id']); } if (isset($msg)) { $msg_tpl = new Template(CURRENT_THEME_FSPATH . "/display_message.php"); $msg_tpl->set('message', $msg); $page->add_module("middle", "top", $msg_tpl->fetch()); } if (isset($page_settings['body_attributes'])) { $page->html_body_attributes = $page_settings['body_attributes']; } else { $page->html_body_attributes .= 'class="hold-transition skin-blue sidebar-collapse sidebar-mini"'; } $page->header->set('render_text_array', $render_text_array); uihelper_get_network_style(); echo $page->render();
} if (!empty($created_album_id)) { // add the content to created album $res = save_post(NULL, $created_album_id, TRUE); if ($res['msg']) { $succ_msg = $res['msg']; } add_tags_to_content($res['content_id'], $tag_string); } route_to_outputthis($permalink_title, $permalink_body); //redirect to group if user has come from group's page //redirect to permalink if ($_GET['ccid']) { $loc = $base_url . '/group.php?gid=' . $_GET['ccid'] . $save_res; } else { $msg = "&err=" . urlencode(MessagesHandler::get_message($succ_msg)); $loc = $base_url . '/content.php?cid=' . $permalink_cid . $msg; } header("location:{$loc}"); exit; } //.. end of $_POST['publish'] function save_post($cid = NULL, $ccid = NULL, $is_album = FALSE, $display_on = 1) { global $user, $network_info; $extra = unserialize($network_info->extra); $micro_content_post = new SBMicroContent(); $micro_content_post->set_mc_type($_REQUEST['sb_mc_type']); $content = $micro_content_post->format_structured_content(); $micro_content_post->body = $content; $micro_content_post->author_id = $_SESSION['user']['id'];
function uihelper_error_msg($msg) { // for accessing the Page-Render variable global $page, $global_form_error; if (empty($msg) && empty($global_form_error)) { return; } // Here we check for error message from action.php $error = $global_form_error; unset($global_form_error); if (!empty($error)) { $msg = $error; } if (is_numeric($msg)) { $msg_obj = new MessagesHandler(); $msg = $msg_obj->get_message($msg); } $msg_tpl = new Template(CURRENT_THEME_FSPATH . "/display_message.php"); $msg_tpl->set('message', $msg); $page->add_module("middle", "top", $msg_tpl->fetch()); }
} else { $obj->sort_by = 'U.created'; $obj->direction = 'DESC'; } $obj->Paging["page"] = $paging["page"]; $obj->Paging["show"] = 10; $obj->network_info = PA::$network_info; $obj->super_user_and_mothership = $super_user_and_mothership; break; } } $page = new PageRenderer("setup_module", PAGE_NETWORK_MANAGE_USERS, "Manage Registered User", 'container_two_column.tpl', 'header.php', PUB, HOMEPAGE, PA::$network_info); if (@$_GET['msg']) { require_once 'web/languages/english/MessagesHandler.php'; $msg_obj = new MessagesHandler(); $message = $msg_obj->get_message($_GET['msg']); } if (@$message) { $msg_tpl = new Template(CURRENT_THEME_FSPATH . "/display_message.tpl"); $msg_tpl->set('message', $message); $m = $msg_tpl->fetch(); $page->add_module("middle", "top", $m); } $page->html_body_attributes = 'class="hold-transition skin-blue sidebar-collapse sidebar-mini"'; $css_array = get_network_css(); if (is_array($css_array)) { foreach ($css_array as $key => $value) { $page->add_header_css($value); } } $page->add_header_html(js_includes('roles.js'));
$title = User::get_login_name_from_id($uid)." - "; } else { $title = ""; } $title .= "Media Gallery - $network_info->name"; // fetching the data from the Constants.php and Rendering the data of the page // at present we are setting the value of setting data $page = new PageRenderer("setup_module", PAGE_MEDIA_GALLERY, $title, "container_one_column_media_gallery.tpl", "header_user.tpl", PUB, NULL, $network_info, null, $setting_data); /* To avoding javascript select value function alert */ if(!isset($_GET['msg_rep'])) { if (!empty($msg) || !empty($_GET['msg_id'])) { $msg_obj = new MessagesHandler(); $msg_id = ($_GET['msg_id']) ? $_GET['msg_id']: $msg; $dynamic_msg = ($msg_id == 2007)?substr ($type,0,5):NULL; $msg = $msg_obj->get_message($msg_id,$dynamic_msg); if ($msg) { $msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl"); $msg_tpl->set('message', $msg); $page->add_module("middle", "top", $msg_tpl->fetch()); } } } // Jtip is shown when user watching the image media if ($type == 'Images') { $parameter = js_includes('jtip.js'); $page->add_header_html($parameter); $css = $current_theme_path.'/jtip.css'; $page->add_header_css($css); } // if user is not log in as well as not viewing any user page
public function handlePOST_GroupInvitationSubmit($request_data) { if (isset($request_data['submit'])) { filter_all_post($request_data); $gid = $request_data['groups']; $self_invite = FALSE; $error = FALSE; // check if groups are there if (empty($gid)) { $error = TRUE; $msg[] = __("Please select a group"); } if (empty($error) && !empty($request_data['email_user_name'])) { // if login name are supplied $friend_user_name = trim($request_data['email_user_name']); $friend_user_name_array = explode(',', $friend_user_name); $cnt_usr_name = count($friend_user_name_array); for ($counter = 0; $counter < $cnt_usr_name; $counter++) { try { $user_obj = new User(); $user_obj->load(trim($friend_user_name_array[$counter])); if ($user_obj->email == PA::$login_user->email) { $self_invite = TRUE; //you can not invite your self } else { $valid_user_login_names[] = $user_obj->login_name; $valid_usr_name_email[] = $user_obj->email; } } catch (PAException $e) { if (!empty($friend_user_name_array[$counter])) { $invalid_login_msg .= $friend_user_name_array[$counter] . ', '; } } } // end for if (!empty($invalid_login_msg)) { $invalid_login_msg = substr($invalid_login_msg, 0, -2); $msg[] = sprintf(__('Invitation could not be sent to following login names- %s'), $invalid_login_msg); } } // end if : if user names are supplied. $invalid = null; if (empty($error) && !empty($request_data['email_id'])) { // if email ids are supplied $friend_email = trim($request_data['email_id']); $friend_email_array = explode(',', $friend_email); $cnt_email = count($friend_email_array); // Check for valid-invalid email addresses start for ($counter = 0; $counter < $cnt_email; $counter++) { $email_validation = Validation::validate_email(trim($friend_email_array[$counter])); if ($email_validation == '0') { $invalid[] = trim($friend_email_array[$counter]); } else { if ($friend_email_array[$counter] == PA::$login_user->email) { $self_invite = TRUE; } else { $valid_user_first_emails[] = $friend_email_array[$counter]; $valid_email[] = trim($friend_email_array[$counter]); } } } } // Check for valid-invalid email addresses end // Action for valid-invalid email addresses start if (empty($friend_email) && empty($friend_user_name)) { // if email field is left empty $msg[] = MessagesHandler::get_message(6001); $error = TRUE; } else { if (!empty($friend_email) && !empty($friend_user_name)) { $msg = array(); $msg[] = MessagesHandler::get_message(7026); $error = TRUE; } else { if (!empty($self_invite) || sizeof($invalid) > 0) { // if self invitation is made if (!empty($self_invite)) { $msg[] = MessagesHandler::get_message(6002); } if (!empty($invalid)) { // if invalid email addresses are supplied $invalid_cnt = count($invalid); $invalid_msg = ''; for ($counter = 0; $counter < $invalid_cnt; $counter++) { if (!empty($invalid[$counter])) { $invalid_msg .= $invalid[$counter] . ', '; } } if (!empty($invalid_msg)) { $invalid_msg = substr($invalid_msg, 0, -2); $msg[] = sprintf(__('Invitation could not be sent to following email addresses- %s'), $invalid_msg); } } } } } if (empty($error)) { // At this point invitation could be made if (!empty($valid_email) && !empty($valid_usr_name_email)) { $valid_email = array_merge($valid_email, $valid_usr_name_email); $valid_user_first_emails = array_merge($valid_user_first_emails, $valid_user_login_names); } else { if (!empty($valid_usr_name_email)) { $valid_email = $valid_usr_name_email; $valid_user_first_emails = $valid_user_login_names; } } if (!empty($valid_email)) { $valid_cnt = count($valid_email); $invitation_message = nl2br($request_data['message']); for ($counter = 0; $counter < $valid_cnt; $counter++) { $group = new Group(); $group->load((int) $gid); $inv = new Invitation(); $inv->user_id = PA::$login_uid; $inv->username = PA::$login_user->login_name; // for invitation not for any group invitation collection id is -1 $inv->inv_collection_id = $gid; $inv->inv_group_name = $group->title; $inv->inv_status = INVITATION_PENDING; $auth_token = get_invitation_token(LONG_EXPIRES, $valid_email[$counter]); $token = '&token=' . $auth_token; $link_desc = wordwrap(PA::$url . '/' . FILE_REGISTER . "?GInvID={$inv->inv_id}", 120, "<br>", 1); $inv->register_url = "<a href=\"" . PA::$url . '/' . FILE_REGISTER . "?GInvID={$inv->inv_id}\">{$link_desc}</a>"; $acc_link_desc = wordwrap(PA::$url . "/" . FILE_LOGIN . "?action=accept&GInvID={$inv->inv_id}{$token}", 120, "<br>", 1); $inv->accept_url = "<a href=\"" . PA::$url . "/" . FILE_LOGIN . "?action=accept&GInvID={$inv->inv_id}{$token}\">{$acc_link_desc}</a>"; $inv->inv_user_id = null; $inv->inv_user_first_name = $valid_user_first_emails[$counter]; $inv->inv_email = $valid_email[$counter]; $inv->inv_summary = sprintf(__("Invitation from %s %s to join %s"), PA::$login_user->first_name, PA::$login_user->last_name, $inv->inv_group_name); $inv->inv_message = !empty($invitation_message) ? $invitation_message : null; $save_error = false; try { $inv->send(); } catch (PAException $e) { $save_msg = "{$e->message}"; $save_error = true; } if ($save_error == true) { $msg[] = sprintf(__('Sorry: you are unable to invite a friend. Reason: %s'), $sav_msg); } else { // invitation has been sent, now send email $user_type = Group::get_user_type(PA::$login_uid, $gid); if ($user_type == OWNER) { $mail_type = 'invite_group'; $requester = $group; } else { if ($user_type == MEMBER) { $mail_type = 'invite_group_by_member'; $requester = PA::$login_user; } } PAMail::send($mail_type, $inv->inv_email, $requester, $inv); $succ_msg .= $valid_user_first_emails[$counter] . ', '; if ($counter == $valid_cnt - 1) { $succ_msg = substr($succ_msg, 0, -2); //$msg_1[] = "Invitation has been sent successfully to -" . $succ_msg; } } } // end for : invitation to multiple email } } } //..do invite if (!empty($msg)) { $msg = array_reverse($msg); $message = NULL; for ($counter = 0; $counter < count($msg); $counter++) { $message .= $msg[$counter] . "<br />"; } } $msg_array = array(); $msg_array['failure_msg'] = $message; $msg_array['success_msg'] = 6004; $redirect_url = PA::$url . PA_ROUTE_GROUP; if (!empty($request_data['groups'])) { $query_str = "gid=" . $request_data['groups']; } set_web_variables($msg_array, $redirect_url, $query_str); }