Пример #1
0
 function check_for_new_mail()
 {
     if (!isset($this->carrot_param['email_user']) || !$this->carrot_param['email_user']) {
         throw new Exception('Email user not defined');
     }
     $account_id = $GLOBALS['phpgw']->accounts->name2id($this->carrot_param['email_user']);
     $GLOBALS['phpgw_info']['user']['account_id'] = $account_id;
     $GLOBALS['phpgw']->preferences->account_id = $account_id;
     $pref = $GLOBALS['phpgw']->preferences->read();
     $GLOBALS['phpgw_info']['user']['preferences']['felamimail'] = isset($pref['felamimail']) ? $pref['felamimail'] : '';
     $boPreferences = CreateObject('felamimail.bopreferences');
     $boPreferences->setProfileActive(true, 2);
     //2 for selected user
     $bofelamimail = CreateObject('felamimail.bofelamimail');
     $connectionStatus = $bofelamimail->openConnection();
     $headers = $bofelamimail->getHeaders('INBOX', 1, $maxMessages = 15, $sort = 0, $_reverse = 1, $_filter = array('string' => '', 'type' => 'quick', 'status' => 'unseen'));
     $sms = array();
     $j = 0;
     if (isset($headers['header']) && is_array($headers['header'])) {
         foreach ($headers['header'] as $header) {
             if (!$header['seen']) {
                 $sms[$j]['uid'] = $header['uid'];
                 $sms[$j]['message'] = utf8_encode($header['subject']);
                 $bodyParts = $bofelamimail->getMessageBody($header['uid']);
                 $sms[$j]['message'] .= "\n";
                 for ($i = 0; $i < count($bodyParts); $i++) {
                     $sms[$j]['message'] .= utf8_encode($bodyParts[$i]['body']) . "\n";
                 }
                 $sms[$j]['message'] = substr($sms[$j]['message'], 0, 160);
                 $j++;
             }
         }
     }
     foreach ($sms as $entry) {
         $sms_datetime = $entry[''];
         $sms_sender = $entry[''];
         $target_code = $entry[''];
         $message = $entry['message'];
         if (!parent::setsmsincomingaction($sms_datetime, $sms_sender, $target_code, $message)) {
             $bofelamimail->flagMessages($_flag = 'unread', array($entry['uid']));
         }
     }
     if ($connectionStatus == 'true') {
         $bofelamimail->closeConnection();
     }
 }
Пример #2
0
 function gw_set_incoming_action()
 {
     $strip_code = isset($this->pswin_param['strip_code']) && $this->pswin_param['strip_code'] ? $this->pswin_param['strip_code'] : '';
     $test_receive = false;
     if ($test_receive) {
         $this->test_receive();
     }
     $sql = 'SELECT * FROM phpgw_sms_received_data WHERE status = 0 AND type = \'sms\'';
     $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
     $messages = array();
     while ($GLOBALS['phpgw']->db->next_record()) {
         $messages[] = array('id' => $GLOBALS['phpgw']->db->f('id'), 'type' => $GLOBALS['phpgw']->db->f('type'), 'entry_date' => $GLOBALS['phpgw']->db->f('entry_date'), 'data' => unserialize($GLOBALS['phpgw']->db->f('data', true)));
     }
     //			_debug_array($messages);
     foreach ($messages as $entry) {
         $message = $entry['data']->m->Text;
         if ($strip_code && stripos($message, "{$strip_code} ") === 0) {
             $strip_code = strtolower($strip_code);
             $strip_code_len = strlen($strip_code);
             $message_len = strlen($message);
             $message = trim(substr($message, $strip_code_len));
         }
         //			_debug_array($message);
         $array_target_code = explode(' ', $message);
         $target_code = strtoupper(trim($array_target_code[0]));
         $message = $array_target_code[1];
         for ($i = 2; $i < count($array_target_code); $i++) {
             $message .= " {$array_target_code[$i]}";
         }
         $sms_datetime = date($GLOBALS['phpgw']->db->datetime_format(), $entry['entry_date']);
         $sms_sender = $entry['data']->m->SenderNumber;
         if (parent::setsmsincomingaction($sms_datetime, $sms_sender, $target_code, $message)) {
             $sql = 'UPDATE phpgw_sms_received_data SET status = 1 WHERE id =' . (int) $entry['id'];
             //_debug_array($sql);
             $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
         }
     }
     //			die();
 }
Пример #3
0
 function __construct()
 {
     parent::__construct();
     $this->sms_param = $GLOBALS['phpgw_info']['sms_config']['bergen_kommune'];
 }
Пример #4
0
 function __construct()
 {
     parent::__construct();
     $this->gnokii_param['path'] = $GLOBALS['phpgw_info']['sms_config']['gnokii']['gnokii_cfg'];
 }