Example #1
0
 function isAllowed(Account $account, Message $message)
 {
     $user = $message->getAssociatedUser();
     $page = $this->getPage($message);
     $perms = TikiLib::lib('tiki')->get_user_permission_accessor($user, 'wiki page', $page);
     return $perms->view;
 }
Example #2
0
 function execute(Account $account, Message $message)
 {
     $body = $message->getHtmlBody();
     $body = $account->parseBody($body, false);
     $commentslib = TikiLib::lib('comments');
     $message_id = '';
     // By ref
     $threadId = $commentslib->post_new_comment("{$this->type}:{$this->object}", 0, $message->getAssociatedUser(), $message->getSubject(), $body['body'], $message_id, '', 'n', '', '', '', '', '', '', '');
     return true;
 }
Example #3
0
 function createAction(Account $account, Message $message)
 {
     $subject = $message->getSubject();
     foreach ($this->config as $prefix => $factory) {
         if (empty($prefix) || strpos($subject, $prefix) === 0) {
             $subject = trim(substr($subject, strlen($prefix)));
             $message->setSubject($subject);
             return $factory->createAction($account, $message);
         }
     }
     throw new MailInException(tr("Unable to find suitable action."));
 }
Example #4
0
 function getMessages()
 {
     $pop = $this->connect();
     $toDelete = [];
     foreach ($pop as $i => $source) {
         $message = new Message($i, function () use($i, &$toDelete) {
             $toDelete[] = $i;
         });
         $from = $source->from ?: $source->{'return-path'};
         $message->setMessageId(str_replace(['<', '>'], '', $source->{'message-id'}));
         $message->setRawFrom($from);
         $message->setSubject($source->subject);
         $message->setRecipient($source->to);
         $message->setHtmlBody($this->getBody($source, 'text/html'));
         $message->setBody($this->getBody($source, 'text/plain'));
         $this->handleAttachments($message, $source);
         (yield $message);
     }
     // Due to an issue in Zend_Mail_Storage, deletion must be done in reverse order
     $toDelete = array_reverse($toDelete);
     foreach ($toDelete as $i) {
         $pop->removeMessage($i);
     }
     $pop->close();
 }
 function createAction(Account $account, Message $message)
 {
     if (preg_match($this->pattern, $message->getRecipient(), $parts) && isset($parts['DATA'])) {
         $info = \Tiki_Security::get()->decode($parts['DATA']);
         // Not a signed value
         if (!$info) {
             return null;
         }
         $action = $info['a'];
         // Real user part of the signature, no need to rely on the email
         // address.
         if (isset($info['u'])) {
             $message->setAssociatedUser($info['u']);
         }
         if (isset($this->actionMap[$action])) {
             $class = $this->actionMap[$action];
             return new $class(['type' => $info['t'], 'object' => $info['o']]);
         }
     }
 }
Example #6
0
 function execute(Account $account, Message $message)
 {
     $artlib = TikiLib::lib('art');
     $tikilib = TikiLib::lib('tiki');
     $title = $message->getSubject();
     $heading = $message->getBody();
     $topicId = $this->topicId;
     $userm = $message->getAssociatedUser();
     $authorName = $userm;
     $body = '';
     $publishDate = $tikilib->now;
     $cur_time = explode(',', $tikilib->date_format('%Y,%m,%d,%H,%M,%S', $publishDate));
     $expireDate = $tikilib->make_time($cur_time[3], $cur_time[4], $cur_time[5], $cur_time[1], $cur_time[2], $cur_time[0] + 1);
     $subId = 0;
     $type = $this->type;
     $useImage = 'n';
     $image_x = '';
     $image_y = '';
     $imgname = '';
     $imgsize = '';
     $imgtype = '';
     $imgdata = '';
     $topline = '';
     $subtitle = '';
     $linkto = '';
     $image_caption = '';
     $lang = '';
     $rating = 7;
     $isfloat = 'n';
     $subid = $artlib->replace_submission($title, $authorName, $topicId, $useImage, $imgname, $imgsize, $imgtype, $imgdata, $heading, $body, $publishDate, $expireDate, $userm, $subId, $image_x, $image_y, $type, $topline, $subtitle, $linkto, $image_caption, $lang, $rating, $isfloat);
     $perms = TikiLib::lib('tiki')->get_user_permission_accessor($user, 'topic', $this->topicId);
     if ($perms->autoapprove_submission) {
         $artlib->approve_submission($subid);
     }
     return true;
 }
Example #7
0
 function execute(Account $account, Message $message)
 {
     $tikilib = TikiLib::lib('tiki');
     $wikilib = TikiLib::lib('wiki');
     $user = $message->getAssociatedUser();
     $page = $this->getPage($message, true);
     if ($this->canAttach($account, $message) && $account->hasAutoAttach()) {
         foreach ($message->getAttachments() as $att) {
             $link = $this->attachFile($page, $att, $user);
             $message->setLink($att['contentId'], $link);
         }
     }
     if ($this->canAttach($account, $message) && $account->hasInlineAttach() && ($body = $message->getHtmlBody(false))) {
         $body = $this->handleInlineImages($page, $body, $message);
     } else {
         $body = $message->getHtmlBody(false);
     }
     $data = $account->parseBody($body);
     $info = $tikilib->get_page_info($page);
     // Allow sub-classes to play with the data
     $body = $this->handleContent($data, $info);
     if (!$info) {
         if ($route = $this->getRoute($message)) {
             // Use the page structure node, if specified, otherwise link to the rrot of the structure
             if ($route['page_id'] > 0) {
                 $parent_id = $route['page_struct_refid'];
                 // page_ref_id
             } else {
                 $parent_id = $route['page_ref_id'];
             }
             $structName = $route['structName'];
             $structure_id = $route['structure_id'];
             $begin = true;
             $after_ref_id = null;
             $alias = '';
             $options = array();
             $options['hide_toc'] = 'y';
             $options['creator'] = $user;
             $options['creator_msg'] = tra('created from mail-in');
             $options['ip_source'] = '0.0.0.0';
             $structlib = TikiLib::lib('struct');
             $structlib->s_create_page($parent_id, $after_ref_id, $page, $alias, $structure_id, $options);
             $content .= "Page: {$page} has been added to structureId: " . $structure_id . "<br />";
             $tikilib->update_page($page, $body, "Updated from " . $account->getAddress(), $user, $options['ip_source'], '', 0, '', $data['is_html'], '', null, $data['wysiwyg']);
             // Categorize with structure categories
             $categlib = TikiLib::lib('categ');
             $categParent = $categlib->get_object_categories('wiki page', $structName, -1, false);
             foreach ($categParent as $c) {
                 $categoryId = $c['categoryId'];
                 $this->categorize($page, $categoryId, $user);
             }
         } else {
             // No routing
             $tikilib->create_page($page, 0, $body, $tikilib->now, "Created from " . $account->getAddress(), $user, '0.0.0.0', '', '', $data['is_html'], '', $data['wysiwyg']);
         }
         $default = $account->getDefaultCategory();
         if ($default) {
             $this->categorize($page, $default, $user);
         }
     } else {
         // Page exists
         $tikilib->update_page($page, $body, "Updated from " . $account->getAddress(), $user, '0.0.0.0', '', 0, '', $data['is_html'], '', null, $data['wysiwyg']);
     }
     return true;
 }
Example #8
0
 private function log(Source\Message $message, $detail)
 {
     $lib = TikiLib::lib('logs');
     $lib->add_log('mailin', $detail . ' - ' . $message->getSubject(), $message->getAssociatedUser());
 }