echo "<div style='background-color:#fff;padding:10px;text-align:center;'>Вы не настроили SMS шлюз. "; //echo "Нажмите <a href='./index.php?module=Administration&action=smsProvider'>сюда</a>, чтобы настроить шлюз.</div>"; break; } $resp = $sms->balance(); echo $resp; break; case "editor": $sms->retrieve_settings(); if (empty($sms->params['sms_instance_id'])) { echo "<div style='background-color:#fff;padding:10px;text-align:center;'>Вы не настроили SMS шлюз. "; echo "Нажмите <a href='./index.php?module=Administration&action=smsProvider'>сюда</a>, чтобы настроить шлюз.</div>"; break; } if (isset($_GET['rec'])) { $sugartalk_SMS = new sugartalk_SMS(); $sugartalk_SMS->retrieve($_GET['rec']); $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
$stamp = date("Y-m-d H:i:s"); $fp = fopen("sms.log", "a+"); 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') {
function send_batch_message($to_array, $text) { global $current_user; $summary = $this->send_to_multi($to_array, $text); if (empty($summary)) { return 'ERROR'; } # Сохраняем все (отправленные и не отправленные) смс if (sizeof($summary)) { foreach ($summary as $pid => $val) { $sugartalk_SMS = new sugartalk_SMS(); $sugartalk_SMS->provider = 'sugartalk'; $sugartalk_SMS->parent_type = $this->parent_type; $sugartalk_SMS->description = $text; $sugartalk_SMS->api_message = $val[0]; $sugartalk_SMS->parent_id = $pid; $sugartalk_SMS->name = strlen($val[1]) ? $val[1] : "-no name-"; $sugartalk_SMS->name .= " (" . date("Y-m-d") . ")"; $sugartalk_SMS->phone_number = strlen($val[1]) ? $val[1] . " " : "-none-"; $sugartalk_SMS->assigned_user_id = $current_user->id; $sugartalk_SMS->delivery_status = $val[0]; $sugartalk_SMS->save(); } } return $summary; }