/** * get recipients of reminding email for specific activity * @param string $id * @param string $module * @return array */ protected function getRecipients($id, $module = "Meetings") { global $db; // require_once('custom/sms/sms.php'); // $sms = new sms(); require_once "modules/Administration/izeno_smsPhone/sms_enzyme.php"; $e = new sms_enzyme('Users'); $sms_field = $e->get_custom_phone_field(); switch ($module) { case "Meetings": $field_part = "meeting"; break; case "Calls": $field_part = "call"; break; default: return array(); } $phones = array(); // fetch users $query = "SELECT user_id FROM {$field_part}s_users WHERE {$field_part}_id = '{$id}' AND accept_status != 'decline' AND deleted = 0\n "; $re = $db->query($query); while ($row = $db->fetchByAssoc($re)) { $user = new User(); $user->retrieve($row['user_id']); $arr = array('type' => 'Users', 'name' => $user->full_name, 'number' => $user->phone_mobile, 'id' => $user->id); $phones[] = $arr; } return $phones; }
foreach ($_REQUEST as $k => $v) { fputs($fp, "[" . $stamp . "]" . $k . " => " . $v . "\n"); } fclose($fp); echo "received"; # # # # # # # # # END LOG TO FILE # # # # # # # # # # # # # # # # # # LOG TO DB # # # # # # # # # global $current_user; $current_user->retrieve(1); require_once "custom/sms/sms.php"; $sms = new sms(); $sms->retrieve_settings(); require_once "modules/sugartalk_SMS/sugartalk_SMS.php"; $sugartalk_SMS = new sugartalk_SMS(); require_once "modules/Administration/sugartalk_smsPhone/sms_enzyme.php"; $e = new sms_enzyme(); $result = $e->parse_sms_macro($msg); if ($result['code'] != '') { # recreate $e and retrieve the module's id $e = new sms_enzyme($result['module']); include_once $e->mod_bean_files; $object = new $e->module_sing(); $where_array = array($result['field'] => $result['code']); $object->retrieve_by_string_fields($where_array); $parent_id = $object->id; $parent_type = $result['module']; $assigned_user_id = $object->assigned_user_id; # 2010-Oct-7: exclusive for case if ($result['module'] == 'Cases') { $case_status = $GLOBALS["app_list_strings"]["case_status_dom"]; foreach ($case_status as $k => $v) {
$phone_number = $sugartalk_SMS->phone_number; $msg = $sugartalk_SMS->description; $pid = $sugartalk_SMS->id; // uses $pid to store the record id $ptype = $sugartalk_SMS->parent_type; // not really needed but may be later $pname = $sugartalk_SMS->name; // not really needed but may be later $onclick = "resend_sms();"; $send_to_multi = '0'; } else { $mod_key_sing = $GLOBALS["beanList"][$_GET['ptype']]; $mod_bean_files = $GLOBALS["beanFiles"][$mod_key_sing]; # retrieve configured SMS phone field for the active module require_once "modules/Administration/sugartalk_smsPhone/sms_enzyme.php"; $e = new sms_enzyme($_GET['ptype']); $sms_field = $e->get_custom_phone_field(); $msg = ""; $pid = $_GET['pid']; $pids = explode(",", $pid); $ptype = $_GET['ptype']; $pname = isset($_GET['pname']) ? $_GET['pname'] : ""; $phone_number = $_GET['num']; $onclick = "send_sms();"; $send_to_multi = $_GET['num'] == 'multi' ? '1' : '0'; } include_once "modules/Administration/sugartalk_smsPhone/sms_editor.php"; break; case "template": if (isset($_GET['id'])) { $et = new EmailTemplate();
/** * Display the actions link * * @param string $id link id attribute, defaults to 'actions_link' * @return string HTML source */ protected function buildActionsLink($id = 'actions_link', $location = 'top') { global $app_strings; $closeText = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']); $moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png'); $menuItems = array(); // compose sms message # tracy: this is for SMS sending to multi recipients require_once "modules/Administration/sugartalk_smsPhone/sms_enzyme.php"; $e = new sms_enzyme($_REQUEST['module']); if (isset($_REQUEST['module'])) { $object = $e->module_sing == 'aCase' ? 'Case' : $e->module_sing; if (in_array($object, $e->get_modules_with_sms())) { require_once "./modules/Administration/sugartalk_smsPhone/smsPhone.js.php"; $onclick = "if (sugarListView.get_checks_count()>0) openAjaxPopupForMulti('mass[]','{$_REQUEST['module']}',''); " . "else alert('Please select at least 1 recipient'); return false;"; $menuItems[] = "<a href='#' style='width: 150px;' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"{$onclick}\">Отправить SMS</a>"; } } // delete if (ACLController::checkAccess($this->seed->module_dir, 'delete', true) && $this->delete) { $menuItems[] = $this->buildDeleteLink($location); } // compose email if ($this->email) { $menuItems[] = $this->buildComposeEmailLink($this->data['pageData']['offsets']['total'], $location); } // mass update $mass = $this->getMassUpdate(); $mass->setSugarBean($this->seed); if (ACLController::checkAccess($this->seed->module_dir, 'edit', true) && ACLController::checkAccess($this->seed->module_dir, 'massupdate', true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus()) { $menuItems[] = $this->buildMassUpdateLink($location); } // merge if ($this->mailMerge) { $menuItems[] = $this->buildMergeLink(null, $location); } if ($this->mergeduplicates) { $menuItems[] = $this->buildMergeDuplicatesLink($location); } // add to target list if ($this->targetList && ACLController::checkAccess('ProspectLists', 'edit', true)) { $menuItems[] = $this->buildTargetList($location); } // export if (ACLController::checkAccess($this->seed->module_dir, 'export', true) && $this->export) { $menuItems[] = $this->buildExportLink($location); } foreach ($this->actionsMenuExtraItems as $item) { $menuItems[] = $item; } $link = array('class' => 'clickMenu selectActions fancymenu', 'id' => 'selectActions', 'name' => 'selectActions', 'buttons' => $menuItems, 'flat' => false); return $link; }
function sendSMS($save_emails = 1, $testmode = false) { require_once 'custom/sms/sms.php'; require_once 'modules/Administration/sugartalk_smsPhone/sms_enzyme.php'; $sms = new sms(); $sms->retrieve_settings(); global $beanList, $beanFiles, $sugar_config; global $mod_strings; $mod_strings = return_module_language($sugar_config['default_language'], 'EmailMan'); if (!isset($beanList[$this->related_type])) { return false; } $class = $beanList[$this->related_type]; if (!class_exists($class)) { require_once $beanFiles[$class]; } if (!class_exists('SMS')) { } $module = new $class(); // tracy: the module $module->retrieve($this->related_id); // tracy: person's id $mod = array_search($class, $beanList); # tracy: use the selected phone field else use the default phone_mobile (esp for Users) $phone_number = ""; if ($mod == "Users") { $phone_number = $module->phone_mobile; } elseif (!empty($mod)) { $e = new sms_enzyme($mod); $phone_field = $e->get_custom_phone_field(); if (!empty($phone_field)) { $phone_number = $module->{$phone_field}; } } $phone_number = preg_replace('/[^0-9]/', '', $phone_number); $this->test = $testmode; # tracy: invalid if there's no number if (empty($phone_number) or $phone_number == '') { $this->set_as_sent($phone_number, true, null, 'SMS', 'invalid email'); $GLOBALS['log']->debug('Phone number was empty. Emailman id = ' . $this->id); } # tracy: check if phone number is in the suppression list if (isset($this->restricted_phone_numbers) && isset($this->restricted_phone_numbers[$phone_number])) { if ($this->restricted_phone_numbers[$phone_number] == 1) { $this->set_as_sent($phone_number, true, null, 'SMS', 'blocked'); $GLOBALS['log']->debug('Phone number is in the suppression list by phone number. Emailman id = ' . $this->id); return true; } } //fetch email marketing. if (empty($this->current_emailmarketing) or !isset($this->current_emailmarketing)) { if (!class_exists('EmailMarketing')) { } $this->current_emailmarketing = new EmailMarketing(); } if (empty($this->current_emailmarketing->id) or $this->current_emailmarketing->id !== $this->marketing_id) { $this->current_emailmarketing->retrieve($this->marketing_id); $this->newmessage = true; } //fetch email template associated with the marketing message. if (empty($this->current_emailtemplate) or $this->current_emailtemplate->id != $this->current_emailmarketing->template_id) { if (!class_exists('EmailTemplate')) { } $this->current_emailtemplate = new EmailTemplate(); $this->current_emailtemplate->retrieve($this->current_emailmarketing->template_id); } $sms_message = isset($this->current_emailtemplate->body) ? $this->current_emailtemplate->body : ''; //parse and replace bean variables in sms_message $template_data = $this->current_emailtemplate->parse_email_template(array('body' => $sms_message), 'Contacts', $module, $macro_nv); // what if user chose other accounts or user? hmm //replace sms_message with clean message $sms_message = $template_data['body']; # tracy: do not send sms if msg is empty if ($sms_message == '') { $this->set_as_sent($phone_number, true, null, 'SMS', 'send error'); $GLOBALS['log']->debug('Message was empty. Emailman id = ' . $this->id); return false; } // fetch campaign details.. if (empty($this->current_campaign)) { if (!class_exists('Campaign')) { } $this->current_campaign = new Campaign(); } //refetch strings in case they have been changed by creation of email templates or other beans. $mod_strings = return_module_language($sugar_config['default_language'], 'EmailMan'); # get the parent info $sms->parent_type = $module->object_name == 'Case' ? 'Cases' : array_search($module->object_name, $beanList); $sms->parent_id = $module->id; if (isset($sms->params) && !empty($sms->params)) { $sms->pname = $module->name; $res = $sms->send_message($phone_number, $sms_message); # tracy: this handles the error response from the api if ($sms->response_text == "SENT" || $res == "SENT") { $this->set_as_sent($phone_number, true, null, 'SMS', 'targeted'); $GLOBALS['log']->debug('Message sent to {$phone_number}. Emailman id = ' . $this->id); return true; } else { $this->set_as_sent($phone_number, true, null, 'SMS', 'send error'); $GLOBALS['log']->fatal('API Error: {$sms->response_text}. Emailman id = ' . $this->id); return false; } } else { $this->set_as_sent($phone_number, true, null, 'SMS', 'send error'); $GLOBALS['log']->fatal('SMS Config Error: There was no provider configured for this service. Emailman id = ' . $this->id); return false; } }