Exemplo n.º 1
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $this->view->page_num = $page = $this->getRequest()->getRequest('page', 1);
     $this->view->filter_username = $request->getQuery('filter_username');
     $this->view->filter_email = $request->getQuery('filter_email');
     $this->view->filter_bulletin_subscribe = $request->getQuery('filter_bulletin_subscribe');
     $url = '';
     if ($this->view->filter_username) {
         $url .= '&filter_username='******'&filter_email=' . $this->view->filter_email;
     }
     if ($this->view->filter_bulletin_subscribe) {
         $url .= '&filter_bulletin_subscribe=' . $this->view->filter_bulletin_subscribe;
     }
     $data = array('start' => $page * JO_Registry::get('admin_limit') - JO_Registry::get('admin_limit'), 'limit' => JO_Registry::get('admin_limit'), 'filter_username' => $this->view->filter_username, 'filter_email' => $this->view->filter_email, 'filter_bulletin_subscribe' => $this->view->filter_bulletin_subscribe);
     $this->view->categories = Model_Bulletinemails::getEmails($data);
     $total_records = Model_Bulletinemails::getTotalEmails($data);
     $this->view->total_pages = ceil($total_records / JO_Registry::get('admin_limit'));
     $this->view->total_rows = $total_records;
     $pagination = new Model_Pagination();
     $pagination->setLimit(JO_Registry::get('admin_limit'));
     $pagination->setPage($page);
     $pagination->setTotal($total_records);
     $pagination->setUrl($this->getRequest()->getModule() . '/categories/?page={page}' . $url);
     $this->view->pagination = $pagination->render();
 }
Exemplo n.º 2
0
 public static function createBulletin($data)
 {
     $db = JO_Db::getDefaultAdapter();
     $db->insert('bulletin', array('name' => $data['name'], 'text' => $data['text'], 'datetime' => new JO_Db_Expr('NOW()'), 'send_to' => $data['send_to'], 'send_id' => 0));
     $id = $db->lastInsertId();
     $emails = Model_Bulletinemails::getEmails(array('filter_bulletin_subscribe' => 'true'));
     $domain = JO_Request::getInstance()->getDomain();
     $send_to = 0;
     if ($emails) {
         foreach ($emails as $email) {
             $not_template = Model_Notificationtemplates::get('bulletin_email');
             $mail = new JO_Mail();
             if (JO_Registry::get('mail_smtp')) {
                 $mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password'));
             }
             $mail->setFrom('no-reply@' . $domain);
             $mail->setSubject("[" . $domain . "] " . $data['name']);
             if ($not_template) {
                 $html = html_entity_decode($not_template['template'], ENT_QUOTES, 'utf-8');
                 $html = str_replace('{FIRSTNAME}', $email['firstname'], $html);
                 $html = str_replace('{LASTNAME}', $email['lastname'], $html);
                 $html = str_replace('{MESSAGE}', html_entity_decode($data['text'], ENT_QUOTES, 'utf-8'), $html);
             } else {
                 $html = html_entity_decode($data['text'], ENT_QUOTES, 'utf-8');
             }
             $mail->setHTML($html);
             $result = $mail->send(array($email['email']), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail');
             if ($result) {
                 $send_to++;
             }
             unset($mail);
         }
     }
     $db->update('bulletin', array('readed' => $send_to), array('id = ?' => $id));
     return $id;
 }