public function Send($users, $data = false, $templatetype = false, $subject = false, $message = false)
 {
     $nt = NotifyTemplate::getInstance();
     //$ntdata = $nt->FetchData($templateid);
     $us = UserSettings::getInstance();
     $setting = Settings::getInstance();
     $nm = NotificationModule::getInstance();
     $user = User::getInstance();
     $lang = Lang::getInstance();
     for ($i = 0; $i < count($users); $i++) {
         $usersettings = $us->Get($users[$i]['id']);
         if (@$usersettings[$templatetype] != "0") {
             if (is_numeric($usersettings['language'])) {
                 $langdata = $lang->FetchData($usersettings['language']);
                 $langcode = $langdata['code'];
             } else {
                 $langcode = $setting->Get('system.lang.default');
             }
             if (strlen($langcode) != 2) {
                 throw new Exception("Lang code not found or in wrong format");
             }
             if (is_array($data) && $templatetype != '' && $templatetype != false) {
                 if (!is_numeric($templateid = $nt->GetID($templatetype, 'type', "`langcode` = '" . $langcode . "'")) && !is_numeric($templateid = $nt->GetID($templatetype, 'type', "`langcode` = 'en'"))) {
                     throw new Exception("Notify Template not found with type " . $templatetype . " and language " . $langcode);
                 }
                 $ntdata = $nt->FetchData($templateid);
                 if (!is_array($ntdata)) {
                     continue;
                 }
                 $message = $this->prepare_template($ntdata['text'], $data);
             } elseif (is_string($subject) && is_string($message)) {
                 $ntdata['subject'] = $subject;
             } else {
                 throw new Exception("Wrong parameters specified");
             }
             if (is_numeric($usersettings['notifymodule']) && is_string($usersettings['notifyaddress'])) {
                 $moduleid = $usersettings['notifymodule'];
                 $address = $usersettings['notifyaddress'];
             } else {
                 $userdata = $user->FetchData($users[$i]['id']);
                 $moduleid = $setting->Get('system.notifymodule.default');
                 $address = $userdata['email'];
             }
             if (strlen($address) < 2 || !is_numeric($moduleid)) {
                 continue;
             }
             if ($nm->Send($moduleid, $address, $ntdata['subject'], $message)) {
                 $status = 'Done';
             } else {
                 $status = 'Fail';
             }
             $this->Create(array('userid' => $users[$i]['id'], 'moduleid' => $moduleid, 'subject' => $ntdata['subject'], 'text' => $message, 'address' => $address, 'status' => $status));
         } else {
             return true;
         }
     }
     return true;
 }
 public function GetLang4User($userid)
 {
     if (!is_numeric($userid)) {
         throw new Exception("User ID is not numeric");
     }
     $usersettings = UserSettings::getInstance();
     $userlang = $usersettings->Get($userid, 'language');
     $userlang = $userlang['language'];
     if (!preg_match('/[a-z]{2}/i', $userlang)) {
         $settings = Settings::getInstance();
         $userlang = $settings->Get('system.lang.default');
     }
     return $userlang;
 }
 public static function UserPersonalSettings()
 {
     $xtpl = self::$xtpl;
     $nm = NotificationModule::getInstance();
     $lang = Lang::getInstance();
     $setting = Settings::getInstance();
     $usrstg = UserSettings::getInstance();
     $curr = Currency::getInstance();
     $xtpl->assign('SETCURR', 'current');
     $xtpl->assign('SYSTEMCURRSETT', 'current');
     $nms = $nm->GetButch();
     $langs = $lang->GetButch();
     $currs = $curr->GetButch();
     if ($usersettings = $usrstg->Get(self::$userid)) {
         $xtpl->assign('NOTIFYADDRESS', $usersettings['notifyaddress']);
         if ($usersettings['usernewinvoice'] == "1") {
             $xtpl->assign('NEWINVSEL', 'checked="checked"');
         }
         if ($usersettings['userneworder'] == "1") {
             $xtpl->assign('NEWORDSEL', 'checked="checked"');
         }
         if ($usersettings['usernewticket'] == "1") {
             $xtpl->assign('NEWTCSEL', 'checked="checked"');
         }
         if ($usersettings['usernewticketreply'] == "1") {
             $xtpl->assign('NEWTRSEL', 'checked="checked"');
         }
     }
     for ($i = 0; $i < count($nms); $i++) {
         if ($nms[$i]['id'] == @$usersettings['notifymodule'] || $nms[$i]['id'] == $setting->Get('system.notifymodule.default')) {
             $xtpl->assign('DEFAULT', 'selected="selected"');
         } else {
             $xtpl->assign('DEFAULT', '');
         }
         $xtpl->assign('NM', $nms[$i]);
         $xtpl->parse('main.personalsettings.ntlist');
     }
     for ($i = 0; $i < count($langs); $i++) {
         if ($langs[$i]['code'] == @$usersettings['language'] || $langs[$i]['code'] == $setting->Get('system.lang.default')) {
             $xtpl->assign('DEFAULT', 'selected="selected"');
         } else {
             $xtpl->assign('DEFAULT', '');
         }
         //var_dump($langs[$i]);
         $xtpl->assign('LNG', $langs[$i]);
         $xtpl->parse('main.personalsettings.langlist');
     }
     for ($i = 0; $i < count($currs); $i++) {
         if ($currs[$i]['name'] == @$usersettings['currency'] || $currs[$i]['name'] == $setting->Get('system.currency')) {
             $xtpl->assign('DEFAULT', 'selected="selected"');
         } else {
             $xtpl->assign('DEFAULT', '');
         }
         $xtpl->assign('CURR', $currs[$i]);
         $xtpl->parse('main.personalsettings.currlist');
     }
     $xtpl->parse('main.personalsettings');
     $xtpl->parse('main');
     $xtpl->out('main');
 }
Beispiel #4
0
     $order = Order::getInstance();
     $orderid = $order->Create($userinstance->GetID(), $_POST['pkgid'], 'new', '', '', '', '', $_POST['cycle']);
     Page::UserOrderPlaced($orderid);
     break;
 case 'addticket':
     $tc = TicketChange::getInstance();
     $tid = $tc->NewTicket($_POST['subject'], $_POST['message'], $_POST['depid'], $userinstance->GetID(), $userinstance->GetID());
     Page::UserViewTicket($tid);
     break;
 case 'addticketreply':
     $tc = TicketChange::getInstance();
     $tc->ReplyTicket($_POST['message'], $_POST['ticketid'], $userinstance->GetID());
     Page::UserViewTicket($_POST['ticketid']);
     break;
 case 'updatepersonalsettings':
     $us = UserSettings::getInstance();
     $us->Set(Page::$userid, 'notifymodule', $_POST['notifymodule']);
     $us->Set(Page::$userid, 'language', $_POST['language']);
     $us->Set(Page::$userid, 'currency', $_POST['currency']);
     $us->Set(Page::$userid, 'notifyaddress', $_POST['notifyaddress']);
     if ($_POST['usernewinvoice']) {
         $us->Set(Page::$userid, 'usernewinvoice', 1);
     } else {
         $us->Set(Page::$userid, 'usernewinvoice', 0);
     }
     if ($_POST['userneworder']) {
         $us->Set(Page::$userid, 'userneworder', 1);
     } else {
         $us->Set(Page::$userid, 'userneworder', 0);
     }
     if ($_POST['usernewticket']) {