Example #1
0
 function view($id = null)
 {
     if (!$id) {
         exit;
     }
     $polid = $this->Session->read('pol');
     $solid = $this->Session->read('sol');
     $this->set('menu_left', $this->Xplico->leftmenuarray(6));
     $this->Nntp_article->recursive = -1;
     $article = $this->Nntp_article->read(null, $id);
     if ($polid != $article['Nntp_article']['pol_id'] || $solid != $article['Nntp_article']['sol_id']) {
         $this->redirect('/users/login');
     }
     $this->Session->write('narticleid', $id);
     $this->set('article', $article);
     /* destroy last tmp dir */
     $tmp_dir = $this->Session->read('mimedir');
     system('rm -rf ' . $tmp_dir);
     /* create dir to put decoded data */
     $tmp_dir = TmpDir();
     $this->Session->write('mimedir', $tmp_dir);
     /* decode mime */
     $mime_parser = new mime_parser_class();
     $mime_parser->mbox = 0;
     // single message file
     $mime_parser->decode_bodies = 1;
     // decde bodies
     $mime_parser->ignore_syntax_errors = 1;
     $mime_parser->extract_addresses = 1;
     $parse_parameters = array('File' => $article['Nntp_article']['mime_path'], 'SaveBody' => $tmp_dir, 'SkipBody' => 1);
     if (!$mime_parser->Decode($parse_parameters, $mime_decoded)) {
     } elseif ($mime_parser->Analyze($mime_decoded[0], $mime_parsed)) {
         /* add 'to' and 'from' string */
         if (isset($mime_parsed['From'])) {
             $mime_parsed['from'] = AddressList($mime_parsed['From']);
         } else {
             $mime_parsed['from'] = '---';
         }
         if (isset($mime_parsed['To'])) {
             $mime_parsed['to'] = AddressList($mime_parsed['To']);
         } else {
             $mime_parsed['to'] = '---';
         }
         $this->set('mailObj', $mime_parsed);
         //print_r($mime_parsed);
         // register visualization
         if (!$article['Nntp_article']['first_visualization_user_id']) {
             $uid = $this->Session->read('userid');
             $article['Nntp_article']['first_visualization_user_id'] = $uid;
             $article['Nntp_article']['viewed_date'] = date("Y-m-d H:i:s");
             $this->Nntp_article->save($article);
         }
     }
 }
Example #2
0
 function view($id = null)
 {
     if (!$id) {
         exit;
     }
     $polid = $this->Session->read('pol');
     $solid = $this->Session->read('sol');
     $this->set('menu_left', $this->Xplico->leftmenuarray(3));
     $this->Email->recursive = -1;
     $email = $this->Email->read(null, $id);
     if ($polid != $email['Email']['pol_id'] || $solid != $email['Email']['sol_id']) {
         $this->redirect('/users/login');
     }
     $this->Session->write('emailid', $id);
     $this->set('email', $email);
     /* destroy last tmp dir */
     $tmp_dir = $this->Session->read('mimedir');
     system('rm -rf ' . $tmp_dir);
     /* create dir to put decoded data */
     $tmp_dir = TmpDir();
     $this->Session->write('mimedir', $tmp_dir);
     /* decode mime */
     $mime_parser = new mime_parser_class();
     $mime_parser->mbox = 0;
     // single message file
     $mime_parser->decode_bodies = 1;
     // decde bodies
     $mime_parser->ignore_syntax_errors = 1;
     $mime_parser->extract_addresses = 0;
     $parse_parameters = array('File' => $email['Email']['mime_path'], 'SaveBody' => $tmp_dir, 'SkipBody' => 1);
     if (!$mime_parser->Decode($parse_parameters, $mime_decoded)) {
     } elseif ($mime_parser->Analyze($mime_decoded[0], $mime_parsed)) {
         /* add 'to' and 'from' string */
         if (isset($mime_parsed['To'])) {
             $mime_parsed['to'] = AddressList($mime_parsed['To']);
         } else {
             $mime_parsed['to'] = '---';
         }
         if (isset($mime_parsed['From'])) {
             $mime_parsed['from'] = AddressList($mime_parsed['From']);
         } else {
             $mime_parsed['from'] = '---';
         }
         $this->set('mailObj', $mime_parsed);
         //print_r($mime_parsed); die();
         // register visualization
         if (!$email['Email']['first_visualization_user_id']) {
             $uid = $this->Session->read('userid');
             $email['Email']['first_visualization_user_id'] = $uid;
             $email['Email']['viewed_date'] = date("Y-m-d H:i:s");
             $this->Email->save($email);
         }
     }
     if (!$id && empty($this->data)) {
         $this->flash(__('Invalid Email', true), array('action' => 'index'));
     }
     if (!empty($this->data)) {
         if ($this->Email->save($this->data)) {
             //                              $this->flash(__('Changes saved succesfully.', true), array('action' => 'view/'.$id));
             //                              $this->flash(__('Changes saved succesfully.', true));
             $this->redirect('/emails/view/' . $id);
         } else {
         }
     }
     if (empty($this->data)) {
         $this->data = $this->Email->read(null, $id);
     }
     $this->set('relevanceoptions', array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '100' => __('Unknown', true)));
 }