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; $valid_recipients['fname'][] = $User->first_name; $valid_recipients['email'][] = $User->email; } 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); for ($counter = 0; $counter < count($valid_recipients); $counter++) { $params = array( 'first_name_sender' => $_SESSION['user']['first_name'], 'first_name_recipient' =>$valid_recipients['fname'][$counter], 'sender_id' => $login_uid, 'recipient_id' => $valid_recipients['id'][$counter], 'recipient_email' => $valid_recipients['email'][$counter] ); auto_email_notification('msg_waiting', $params); } $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); uihelper_set_user_heading($page); uihelper_error_msg($message); echo $page->render(); ?>