public function send_new_user_notification() { // Set a random invitation code for resetting password $this->invite_code = $this->generate_invite_code(); $this->save(); // Email the user the reset url $maildata = array('invite_code' => $this->invite_code, 'name' => $this->first_name, 'reset_url' => tenant_url("/auth/reset/{$this->invite_code}", $this->tenant_id)); return openvbx_mail($this->email, 'Welcome aboard', 'welcome-user', $maildata); }
public function send_iphone_guide() { $user = VBX_user::get(array('id' => $this->user_id)); $this->data = array('error' => false, 'message' => 'OK'); openvbx_mail($user->email, "iPhone installation Guide", 'iphone-guide', array('email' => $user->email)); echo json_encode($this->data); }
function notify_message($message) { $ci =& get_instance(); $ci->load->model('vbx_user'); $ci->load->model('vbx_group'); $ci->load->model('vbx_incoming_numbers'); $recording_host = $ci->settings->get('recording_host', VBX_PARENT_TENANT); $vm_url = $message->content_url; if (!empty($recording_host) && trim($recording_host) != '') { $vm_url = str_replace('api.twilio.com', trim($recording_host), $vm_url); } $message->content_url = $vm_url; $users = array(); $notify = array(); if ($message->owner_type == 'user') { $user = VBX_User::get($message->owner_id); if (!empty($user->email)) { $notify[] = $user->email; } } $group_users = array(); if ($message->owner_type == 'group') { $user_ids = $ci->vbx_group->get_user_ids($message->owner_id); $group = $ci->vbx_group->get_by_id($message->owner_id); $owner = $group->name; } else { if ($message->owner_type == 'user') { $user_ids = array($message->owner_id); $owner = 'Personal'; } } $notification_setting = 'email_notifications_' . $message->type; $email_notify = $ci->vbx_settings->get($notification_setting, $ci->tenant->id); // check the incoming number's capabilities and don't even try to send // an SMS notification if the number is not allowed to send SMS messages $incoming_number = VBX_Incoming_numbers::get(array('phone_number' => normalize_phone_to_E164($message->called))); if (!empty($incoming_number) && $incoming_number->capabilities->sms == 1) { $sms_notify = true; } if ($email_notify || $sms_notify) { foreach ($user_ids as $user_id) { $user = VBX_User::get($user_id); $ci->load->model('vbx_device'); $ci->load->model('vbx_sms_message'); $numbers = VBX_Device::search(array('user_id' => $user_id)); $message_type = 'Voicemail'; if ($message->type == 'sms') { $message_type = 'SMS'; $owner = ''; } if ($email_notify) { $email_subject = "New {$owner} {$message_type} Notification - {$message->caller}"; openvbx_mail($user->email, $email_subject, 'message', compact('message')); } if ($sms_notify) { foreach ($numbers as $number) { if ($number->value && $number->sms) { try { $ci->vbx_sms_message->send_message($message->called, $number->value, $this->tiny_notification_message($message)); } catch (VBX_Sms_messageException $e) { log_message('error', 'unable to send sms alert, reason: ' . $e->getMessage()); } } } } // if ($sms_notify) } } // if ($email_notify || $sms_notify) }
function set_password() { $ci =& get_instance(); $ci->load->helper('email'); $password = random_str(); $this->password = self::salt_encrypt($password); try { $result = $this->save(); // $message = "Your new password is $password\n\n" . tenant_url('', $this->tenant_id); $maildata = array('password' => $password, 'tenant_url' => tenant_url('', $this->tenant_id)); openvbx_mail($this->email, 'Your new password', 'password-reset', $maildata); } catch (Exception $e) { error_log($e->getMessage()); return false; } return $result; }
function set_password() { $ci =& get_instance(); $ci->load->helper('email'); $password = random_str(); $this->password = self::salt_encrypt($password); try { $result = $this->save(); $message = "Your new password is {$password}\n\n" . tenant_url('', $this->tenant_id); openvbx_mail($this->email, 'OpenVBX Password', $message); } catch (Exception $e) { error_log($e->getMessage()); return false; } return $result; }
function notify_message($message, $notify = false) { error_log("Notify message: " . ($notify ? 'true' : 'false')); if ($notify === false) { return; } $ci =& get_instance(); $ci->load->model('vbx_user'); $ci->load->model('vbx_group'); $recording_host = $ci->settings->get('recording_host', VBX_PARENT_TENANT); $vm_url = $message->content_url; if (trim($recording_host) != '') { $vm_url = str_replace('api.twilio.com', trim($recording_host), $vm_url); } $message->content_url = $vm_url; $users = array(); if ($message->owner_type == 'user') { $user = VBX_User::get($message->owner_id); if (!empty($user->email)) { $notify[] = $user->email; } } $group_users = array(); if ($message->owner_type == 'group') { $user_ids = $ci->vbx_group->get_user_ids($message->owner_id); $group = $ci->vbx_group->get_by_id($message->owner_id); $owner = $group->name; } else { if ($message->owner_type == 'user') { $user_ids = array($message->owner_id); $owner = 'Personal'; } } foreach ($user_ids as $user_id) { $user = VBX_User::get($user_id); $ci->load->model('vbx_device'); $ci->load->model('vbx_sms_message'); $numbers = VBX_Device::search(array('user_id' => $user_id)); $message_type = 'Voicemail'; if ($message->type == 'sms') { $message_type = 'SMS'; $owner = ''; } if ($message->type == 'voice') { openvbx_mail($user->email, "New {$owner} {$message_type} Notification - {$message->caller}", 'message', compact('message')); error_log("message queued for {$user->email}"); } foreach ($numbers as $number) { error_log($number->value); error_log(var_export($number->values, true)); if ($number->value && $number->sms) { try { $ci->vbx_sms_message->send_message($message->called, $number->value, $this->tiny_notification_message($message)); error_log("sms queued for {$number->value}"); } catch (Sms_messageException $e) { error_log("unable to send sms alert, reason: " . $e->getMessage()); } } } } }
public function send_new_user_notification() { /* Set a random invitation code for resetting password */ $this->invite_code = substr(self::salt_encrypt(mt_rand()), 0, 20); $this->save(); /* Email the user the reset url */ $maildata = array('invite_code' => $this->invite_code, 'name' => $this->first_name, 'reset_url' => tenant_url("/auth/reset/{$this->invite_code}", $this->tenant_id)); openvbx_mail($this->email, 'Welcome aboard', 'welcome-user', $maildata); }