MAX_MESSAGE_LENGTH) { $message = MessagesHandler::get_message(8002); $error = true; } if (!$error) { if (empty($subject)) { $subject = '[none]'; } $login_names = explode(",", $_POST['to']); $found = array();//user id of all the valid login names $valid_recipients = array(); //login name of all the valid login names. $invalid_recipients = array();//names of all the invalid recipients. foreach ($login_names as $login_name) { try { $User = new User(); $User->load($login_name); $valid_recipients['id'][] = $User->user_id; $valid_recipients['name'][] = $User->login_name; } catch (PAException $e) { $invalid_recipients[] = $login_name; } } $message = null; if (count($valid_recipients)) { Message::add_message($login_uid, $valid_recipients['id'], $valid_recipients['name'], $subject, $body); $message = 'Message sent successfully to '.implode(",", $valid_recipients['name']).'
'; } if (count($invalid_recipients)) { //some of the recipients are invalid. So displaying the error message for them. $message .= 'Message sending failed for '.implode(",", $invalid_recipients).' as user(s) doesn\'t exists'; $error = true; } else { // message sent successfully to all the recipients. Redirecting user to inbox. header("Location: $base_url/mymessage.php?msg=message_sent"); exit; } } } } /** * Function : setup_module() * Purpose : call back function to set up variables * used in PageRenderer class * To see how it is used see api/PageRenderer/PageRenderer.php * @param $column - string - contains left, middle, right * position of the block module * @param $moduleName - string - contains name of the block module * @param $obj - object - object reference of the block module * @return type string - returns skip means skip the block module * returns rendered html code of block module */ function setup_module($column, $moduleName, $obj) { global $action, $login_uid, $page_uid; switch ($column) { case 'middle': if (!empty($_POST['mid'])) { $obj->mid = $_POST['mid']; } $obj->action = $action; $obj->uid = $login_uid; if (!empty($page_uid)) { $obj->page_uid = $page_uid; } break; } $obj->mode = PUB; } //renders the modules on the page $page = new PageRenderer("setup_module", PAGE_ADDMESSAGE, "Compose", "container_one_column.tpl", 'header.tpl', PRI, HOMEPAGE, $network_info); /*$css_path = $current_theme_path.'/layout.css'; $page->add_header_css($css_path); $css_path = $current_theme_path.'/network_skin.css'; $page->add_header_css($css_path); $css_path = $current_theme_path.'/edit_skin.css'; $page->add_header_css($css_path);*/ // Currently using the CSS from the live site, due to some problem in merging local and server CSS. $css_path = $current_theme_path.'/layout.css'; $page->add_header_css($css_path); $css_path = $current_theme_path.'/network_skin.css'; $page->add_header_css($css_path); $css_path = $current_theme_path.'/edit_skin.css'; $page->add_header_css($css_path); if ($error) { $msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl"); $msg_tpl->set('message', $message); $page->add_module("middle", "top", $msg_tpl->fetch()); } echo $page->render(); ?>