コード例 #1
0
ファイル: display.php プロジェクト: BillVGN/PortalPRP
	/**
	 * Prepare user attachments list.
	 *
	 * @return void
	 */
	protected function before()
	{
		parent::before();

		$userid = $this->input->getInt('userid');
		$params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');

		$this->template = KunenaFactory::getTemplate();
		$this->me = KunenaUserHelper::getMyself();
		$this->profile = KunenaUserHelper::get($userid);
		$this->attachments = KunenaAttachmentHelper::getByUserid($this->profile, $params);

		// Pre-load messages.
		$messageIds = array();

		foreach ($this->attachments as $attachment)
		{
			$messageIds[] = (int) $attachment->mesid;
		}

		$messages = KunenaForumMessageHelper::getMessages($messageIds, 'none');

		// Pre-load topics.
		$topicIds = array();

		foreach ($messages as $message)
		{
			$topicIds[] = $message->thread;
		}

		KunenaForumTopicHelper::getTopics($topicIds, 'none');

		$this->headerText = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
	}
コード例 #2
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare reply history display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $id = $this->input->getInt('id');
     $this->topic = KunenaForumTopicHelper::get($id);
     $this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, 'DESC');
     $this->replycount = $this->topic->getReplies();
     $this->historycount = count($this->history);
     KunenaAttachmentHelper::getByMessage($this->history);
     $userlist = array();
     foreach ($this->history as $message) {
         $userlist[(int) $message->userid] = (int) $message->userid;
     }
     KunenaUserHelper::loadUsers($userlist);
     // Run events
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'history');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
     // FIXME: need to improve BBCode class on this...
     $this->attachments = KunenaAttachmentHelper::getByMessage($this->history);
     $this->inline_attachments = array();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
コード例 #3
0
ファイル: attachments.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * @throws Exception
  */
 public function delete()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirect(KunenaRoute::_($this->baseurl, false));
         return;
     }
     $cid = JFactory::getApplication()->input->get('cid', array(), 'post', 'array');
     // Array of integers
     Joomla\Utilities\ArrayHelper::toInteger($cid);
     if (!$cid) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ATTACHMENTS_SELECTED'), 'error');
         $this->setRedirect(KunenaRoute::_($this->baseurl, false));
         return;
     }
     foreach ($cid as $id) {
         $attachment = KunenaAttachmentHelper::get($id);
         $message = $attachment->getMessage();
         $attachments = array($attachment->id, 1);
         $attach = array();
         $removeList = array_keys(array_diff_key($attachments, $attach));
         Joomla\Utilities\ArrayHelper::toInteger($removeList);
         $message->removeAttachments($removeList);
         $message->save();
         $topic = $message->getTopic();
         $attachment->delete();
         if ($topic->attachments > 0) {
             $topic->attachments = $topic->attachments - 1;
             $topic->save(false);
         }
     }
     $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETED_SUCCESSFULLY'));
     $this->setRedirect(KunenaRoute::_($this->baseurl, false));
 }
コード例 #4
0
ファイル: display.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Prepare topic reply form.
  *
  * @return void
  *
  * @throws RuntimeException
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid');
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     $quote = $this->input->getBool('quote', false);
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $parent = KunenaForumMessageHelper::get($this->topic->first_post_id);
     } else {
         $parent = KunenaForumMessageHelper::get($mesid);
         $this->topic = $parent->getTopic();
     }
     $this->category = $this->topic->getCategory();
     if ($parent->isAuthorised('reply') && $this->me->canDoCaptcha()) {
         if (JPluginHelper::isEnabled('captcha')) {
             $plugin = JPluginHelper::getPlugin('captcha');
             $params = new JRegistry($plugin[0]->params);
             $captcha_pubkey = $params->get('public_key');
             $catcha_privkey = $params->get('private_key');
             if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
                 JPluginHelper::importPlugin('captcha');
                 $dispatcher = JDispatcher::getInstance();
                 $result = $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
                 $this->captchaEnabled = $result[0];
             }
         } else {
             $this->captchaEnabled = false;
         }
     }
     $parent->tryAuthorise('reply');
     // Run event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     // Can user edit topic icons?
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     list($this->topic, $this->message) = $parent->newReply($saved ? $saved : $quote);
     $this->action = 'post';
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     $this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_BUTTON_MESSAGE_REPLY') . ' ' . $this->topic->subject;
 }
コード例 #5
0
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $this->_db->setQuery($query, $limitstart, $limit);
     $ids = $this->_db->loadColumn();
     $results = KunenaAttachmentHelper::getById($ids);
     $userids = array();
     $mesids = array();
     foreach ($results as $result) {
         $userids[$result->userid] = $result->userid;
         $mesids[$result->mesid] = $result->mesid;
     }
     KunenaUserHelper::loadUsers($userids);
     KunenaForumMessageHelper::getMessages($mesids);
     return $results;
 }
コード例 #6
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare topic edit form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->catid = $this->input->getInt('catid');
     $mesid = $this->input->getInt('mesid');
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     $this->message = KunenaForumMessageHelper::get($mesid);
     $this->message->tryAuthorise('edit');
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     $this->template->setCategoryIconset($this->topic->getCategory()->iconset);
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     // Run onKunenaPrepare event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     $this->action = 'edit';
     // Get attachments.
     $this->attachments = $this->message->getAttachments();
     // Get poll.
     if ($this->message->parent == 0 && $this->topic->isAuthorised(!$this->topic->poll_id ? 'poll.create' : 'poll.edit')) {
         $this->poll = $this->topic->getPoll();
     }
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($saved) {
         // Update message contents.
         $this->message->edit($saved);
     }
     $this->post_anonymous = isset($saved['anonymous']) ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = isset($saved['subscribe']) ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->modified_reason = isset($saved['modified_reason']) ? $saved['modified_reason'] : '';
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
コード例 #7
0
ファイル: topic.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Method to delete the KunenaForumTopic object from the database.
  *
  * @param bool $recount
  *
  * @return bool	True on success.
  */
 public function delete($recount = true)
 {
     if (!$this->exists()) {
         return true;
     }
     if (!parent::delete()) {
         return false;
     }
     // Clear authentication cache
     $this->_authfcache = $this->_authccache = $this->_authcache = array();
     // NOTE: shadow topic doesn't exist, DO NOT DELETE OR CHANGE ANY EXTERNAL INFORMATION
     if ($this->moved_id == 0) {
         $db = JFactory::getDBO();
         // Delete user topics
         $queries[] = "DELETE FROM #__kunena_user_topics WHERE topic_id={$db->quote($this->id)}";
         // Delete user read
         $queries[] = "DELETE FROM #__kunena_user_read WHERE topic_id={$db->quote($this->id)}";
         // Delete poll (users)
         $queries[] = "DELETE FROM #__kunena_polls_users WHERE pollid={$db->quote($this->poll_id)}";
         // Delete poll (options)
         $queries[] = "DELETE FROM #__kunena_polls_options WHERE pollid={$db->quote($this->poll_id)}";
         // Delete poll
         $queries[] = "DELETE FROM #__kunena_polls WHERE id={$db->quote($this->poll_id)}";
         // Delete thank yous
         $queries[] = "DELETE t FROM #__kunena_thankyou AS t INNER JOIN #__kunena_messages AS m ON m.id=t.postid WHERE m.thread={$db->quote($this->id)}";
         // Delete all messages
         $queries[] = "DELETE m, t FROM #__kunena_messages AS m INNER JOIN #__kunena_messages_text AS t ON m.id=t.mesid WHERE m.thread={$db->quote($this->id)}";
         foreach ($queries as $query) {
             $db->setQuery($query);
             $db->query();
             KunenaError::checkDatabaseError();
         }
         // FIXME: add recount statistics
         if ($recount) {
             KunenaUserHelper::recount();
             KunenaForumCategoryHelper::recount();
             KunenaAttachmentHelper::cleanup();
             KunenaForumMessageThankyouHelper::recount();
         }
     }
     return true;
 }
コード例 #8
0
ファイル: topic.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Upload files with AJAX.
  *
  * @throws RuntimeException
  */
 public function upload()
 {
     // Only support JSON requests.
     if ($this->input->getWord('format', 'html') != 'json') {
         throw new RuntimeException(JText::_('Bad Request'), 400);
     }
     $upload = KunenaUpload::getInstance();
     // We are converting all exceptions into JSON.
     try {
         if (!JSession::checkToken('request')) {
             throw new RuntimeException(JText::_('Forbidden'), 403);
         }
         $me = KunenaUserHelper::getMyself();
         $catid = $this->input->getInt('catid', 0);
         $mesid = $this->input->getInt('mesid', 0);
         if ($mesid) {
             $message = KunenaForumMessageHelper::get($mesid);
             $message->tryAuthorise('attachment.create');
             $category = $message->getCategory();
         } else {
             $category = KunenaForumCategoryHelper::get($catid);
             // TODO: Some room for improvements in here... (maybe ask user to pick up category first)
             if ($category->id) {
                 if (stripos($this->input->getString('mime'), 'image/') !== false) {
                     $category->tryAuthorise('topic.post.attachment.createimage');
                 } else {
                     $category->tryAuthorise('topic.post.attachment.createfile');
                 }
             }
         }
         $caption = $this->input->getString('caption');
         $options = array('filename' => $this->input->getString('filename'), 'size' => $this->input->getInt('size'), 'mime' => $this->input->getString('mime'), 'hash' => $this->input->getString('hash'), 'chunkStart' => $this->input->getInt('chunkStart', 0), 'chunkEnd' => $this->input->getInt('chunkEnd', 0));
         // Upload!
         $upload->addExtensions(KunenaAttachmentHelper::getExtensions($category->id, $me->userid));
         $response = (object) $upload->ajaxUpload($options);
         if (!empty($response->completed)) {
             // We have it all, lets create the attachment.
             $uploadFile = $upload->getProtectedFile();
             list($basename, $extension) = $upload->splitFilename();
             $attachment = new KunenaAttachment();
             $attachment->bind(array('mesid' => 0, 'userid' => (int) $me->userid, 'protected' => null, 'hash' => $response->hash, 'size' => $response->size, 'folder' => null, 'filetype' => $response->mime, 'filename' => null, 'filename_real' => $response->filename, 'caption' => $caption));
             // Resize image if needed.
             if ($attachment->isImage()) {
                 $imageInfo = KunenaImage::getImageFileProperties($uploadFile);
                 $config = KunenaConfig::getInstance();
                 if ($imageInfo->width > $config->imagewidth || $imageInfo->height > $config->imageheight) {
                     // Calculate quality for both JPG and PNG.
                     $quality = $config->imagequality;
                     if ($quality < 1 || $quality > 100) {
                         $quality = 70;
                     }
                     if ($imageInfo->type == IMAGETYPE_PNG) {
                         $quality = intval(($quality - 1) / 10);
                     }
                     $image = new KunenaImage($uploadFile);
                     $image = $image->resize($config->imagewidth, $config->imageheight, false);
                     $options = array('quality' => $quality);
                     $image->toFile($uploadFile, $imageInfo->type, $options);
                     unset($image);
                     $attachment->hash = md5_file($uploadFile);
                     $attachment->size = filesize($uploadFile);
                 }
             }
             $attachment->saveFile($uploadFile, $basename, $extension, true);
             // Set id and override response variables just in case if attachment was modified.
             $response->id = $attachment->id;
             $response->hash = $attachment->hash;
             $response->size = $attachment->size;
             $response->mime = $attachment->filetype;
             $response->filename = $attachment->filename_real;
         }
     } catch (Exception $response) {
         $upload->cleanup();
         // Use the exception as the response.
     }
     header('Content-type: application/json');
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     while (@ob_end_clean()) {
     }
     echo $upload->ajaxResponse($response);
     jexit();
 }
コード例 #9
0
ファイル: message.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * @param  bool|array  $ids
  * @param  string      $action
  *
  * @return KunenaAttachment[]
  */
 public function getAttachments($ids = false, $action = 'read')
 {
     if ($ids === false) {
         $attachments = KunenaAttachmentHelper::getByMessage($this->id, $action);
     } else {
         $attachments = KunenaAttachmentHelper::getById($ids, $action);
         foreach ($attachments as $id => $attachment) {
             if ($attachment->mesid && $attachment->mesid != $this->id) {
                 unset($attachments[$id]);
             }
         }
     }
     return $attachments;
 }
コード例 #10
0
ファイル: category.php プロジェクト: densem-2013/exikom
 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  */
 protected function authoriseUpload(KunenaUser $user)
 {
     // Check if attachments are allowed
     if (KunenaAttachmentHelper::getExtensions($this, $user) === false) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_LIB_CATEGORY_AUTHORISE_FAILED_UPLOAD_NOT_ALLOWED'), 403);
     }
     return null;
 }
コード例 #11
0
ファイル: bbcode.php プロジェクト: Weley/Saviors-web
 function DoAttachment($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCODE_CHECK) {
         return true;
     }
     $attachments = null;
     if ($bbcode->parent instanceof KunenaForumMessage) {
         $attachments = $bbcode->parent->getAttachments();
     } elseif (is_object($bbcode->parent) && isset($bbcode->parent->attachments)) {
         $attachments =& $bbcode->parent->attachments;
     }
     /** @var KunenaAttachment $att */
     /** @var KunenaAttachment $attachment */
     $attachment = null;
     if (!empty($default)) {
         $attachment = KunenaAttachmentHelper::get($default);
         unset($attachments[$attachment->id]);
     } elseif (empty($content)) {
         $attachment = array_shift($attachments);
     } elseif (!empty($attachments)) {
         foreach ($attachments as $att) {
             if ($att->getFilename() == $content) {
                 $attachment = $att;
                 unset($attachments[$att->id]);
                 break;
             }
         }
     }
     // Display tag in activity streams etc..
     if (!isset($attachments) || !empty($bbcode->parent->forceMinimal)) {
         if ($attachment->isImage()) {
             $hide = KunenaFactory::getConfig()->showimgforguest == 0 && JFactory::getUser()->id == 0;
             if (!$hide) {
                 return "<div class=\"kmsgimage\">{$attachment->getImageLink()}</div>";
             }
         } else {
             $hide = KunenaFactory::getConfig()->showfileforguest == 0 && JFactory::getUser()->id == 0;
             if (!$hide) {
                 return "<div class=\"kmsgattach\"><h4>" . JText::_('COM_KUNENA_FILEATTACH') . "</h4>" . JText::_('COM_KUNENA_FILENAME') . " <a href=\"" . $attachment->getUrl() . "\" target=\"_blank\" rel=\"nofollow\">" . $attachment->filename . "</a><br />" . JText::_('COM_KUNENA_FILESIZE') . ' ' . number_format(intval($attachment->size) / 1024, 0, '', ',') . ' KB' . "</div>";
             }
         }
     }
     if (!$attachment && !empty($bbcode->parent->inline_attachments)) {
         foreach ($bbcode->parent->inline_attachments as $att) {
             if ($att->getFilename() == trim(strip_tags($content))) {
                 $attachment = $att;
                 break;
             }
         }
     }
     if (!$attachment) {
         return $bbcode->HTMLEncode($content);
     }
     return $this->renderAttachment($attachment, $bbcode);
 }
コード例 #12
0
ファイル: bbcode.php プロジェクト: Jougito/DynWeb
 function DoAttachment($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCODE_CHECK) {
         return true;
     }
     $attachments = null;
     if ($bbcode->parent instanceof KunenaForumMessage) {
         $attachments = $bbcode->parent->getAttachments();
     } elseif (is_object($bbcode->parent) && isset($bbcode->parent->attachments)) {
         $attachments =& $bbcode->parent->attachments;
     }
     // Display tag in activity streams etc..
     if (!isset($attachments) || !empty($bbcode->parent->forceMinimal)) {
         $filename = basename(trim(strip_tags($content)));
         return '[' . JText::_('COM_KUNENA_FILEATTACH') . ' ' . basename(!empty($params["name"]) ? $params["name"] : $filename) . ']';
     }
     /** @var KunenaAttachment $att */
     /** @var KunenaAttachment $attachment */
     $attachment = null;
     if (!empty($default)) {
         $attachment = KunenaAttachmentHelper::get($default);
         unset($attachments[$attachment->id]);
     } elseif (empty($content)) {
         $attachment = array_shift($attachments);
     } elseif (!empty($attachments)) {
         foreach ($attachments as $att) {
             if ($att->getFilename() == $content) {
                 $attachment = $att;
                 unset($attachments[$att->id]);
                 break;
             }
         }
     }
     // Display tag in activity streams etc..
     if (!empty($bbcode->parent->forceMinimal) || !is_object($bbcode->parent) && !isset($bbcode->parent->attachments)) {
         $filename = basename(trim(strip_tags($content)));
         return $attachment->getThumbnailLink();
     }
     if (!$attachment && !empty($bbcode->parent->inline_attachments)) {
         foreach ($bbcode->parent->inline_attachments as $att) {
             if ($att->getFilename() == trim(strip_tags($content))) {
                 $attachment = $att;
                 break;
             }
         }
     }
     if (!$attachment) {
         return $bbcode->HTMLEncode($content);
     }
     return $this->renderAttachment($attachment, $bbcode);
 }
コード例 #13
0
ファイル: topic.php プロジェクト: giabmf11/Kunena-Forum
 public function getMessages()
 {
     if ($this->messages === false) {
         $layout = $this->getState('layout');
         $threaded = $layout == 'indented' || $layout == 'threaded';
         $this->messages = KunenaForumMessageHelper::getMessagesByTopic($this->getState('item.id'), $this->getState('list.start'), $this->getState('list.limit'), $this->getState('list.direction'), $this->getState('hold'), $threaded);
         // Get thankyous for all messages in the page
         $thankyous = KunenaForumMessageThankyouHelper::getByMessage($this->messages);
         // First collect ids and users
         $userlist = array();
         $this->threaded = array();
         $location = $this->getState('list.start');
         foreach ($this->messages as $message) {
             $message->replynum = ++$location;
             if ($threaded) {
                 // Threaded ordering
                 if (isset($this->messages[$message->parent])) {
                     $this->threaded[$message->parent][] = $message->id;
                 } else {
                     $this->threaded[0][] = $message->id;
                 }
             }
             $userlist[intval($message->userid)] = intval($message->userid);
             $userlist[intval($message->modified_by)] = intval($message->modified_by);
             $thankyou_list = $thankyous[$message->id]->getList();
             $message->thankyou = array();
             if (!empty($thankyou_list)) {
                 $message->thankyou = $thankyou_list;
             }
         }
         if (!isset($this->messages[$this->getState('item.mesid')]) && !empty($this->messages)) {
             $this->setState('item.mesid', reset($this->messages)->id);
         }
         if ($threaded) {
             if (!isset($this->messages[$this->topic->first_post_id])) {
                 $this->messages = $this->getThreadedOrdering(0, array('edge'));
             } else {
                 $this->messages = $this->getThreadedOrdering();
             }
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         KunenaUserHelper::loadUsers($userlist);
         // Get attachments
         KunenaAttachmentHelper::getByMessage($this->messages);
     }
     return $this->messages;
 }
コード例 #14
0
ファイル: view.html.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * @return bool
  */
 function canManageAttachments()
 {
     if ($this->config->show_imgfiles_manage_profile) {
         $params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');
         $this->userattachs = KunenaAttachmentHelper::getByUserid($this->profile, $params);
         if ($this->userattachs) {
             if ($this->me->isModerator() || $this->profile->userid == $this->me->userid) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     return false;
 }
コード例 #15
0
ファイル: display.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Prepare topic creation form.
  *
  * @return bool
  *
  * @throws RuntimeException
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid', 0);
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     $categories = KunenaForumCategoryHelper::getCategories();
     $arrayanynomousbox = array();
     $arraypollcatid = array();
     foreach ($categories as $category) {
         if (!$category->isSection() && $category->allow_anonymous) {
             $arrayanynomousbox[] = '"' . $category->id . '":' . $category->post_anonymous;
         }
         if (!$category->isSection() && $category->allow_polls) {
             $arraypollcatid[] = '"' . $category->id . '":1';
         }
     }
     $arrayanynomousbox = implode(',', $arrayanynomousbox);
     $arraypollcatid = implode(',', $arraypollcatid);
     // FIXME: We need to proxy this...
     $this->document = JFactory::getDocument();
     $this->document->addScriptDeclaration('var arrayanynomousbox={' . $arrayanynomousbox . '}');
     $this->document->addScriptDeclaration('var pollcategoriesid = {' . $arraypollcatid . '};');
     $this->category = KunenaForumCategoryHelper::get($catid);
     list($this->topic, $this->message) = $this->category->newTopic($saved);
     $this->template->setCategoryIconset($this->topic->getCategory()->iconset);
     // Get topic icons if they are enabled.
     if ($this->config->topicicons) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : 0, $this->topic->getCategory()->iconset);
     }
     if ($this->topic->isAuthorised('create') && $this->me->canDoCaptcha()) {
         if (JPluginHelper::isEnabled('captcha')) {
             $plugin = JPluginHelper::getPlugin('captcha');
             $params = new JRegistry($plugin[0]->params);
             $captcha_pubkey = $params->get('public_key');
             $catcha_privkey = $params->get('private_key');
             if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
                 JPluginHelper::importPlugin('captcha');
                 $dispatcher = JDispatcher::getInstance();
                 $result = $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
                 $this->captchaEnabled = $result[0];
             }
         }
     } else {
         $this->captchaEnabled = false;
     }
     if (!$this->topic->category_id) {
         throw new KunenaExceptionAuthorise(JText::sprintf('COM_KUNENA_POST_NEW_TOPIC_NO_PERMISSIONS', $this->topic->getError()), $this->me->exists() ? 403 : 401);
     }
     $options = array();
     $selected = $this->topic->category_id;
     if ($this->config->pickup_category) {
         $options[] = JHtml::_('select.option', '', JText::_('COM_KUNENA_SELECT_CATEGORY'), 'value', 'text');
         $selected = 0;
     }
     if ($saved) {
         $selected = $saved['catid'];
     }
     $cat_params = array('ordering' => 'ordering', 'toplevel' => 0, 'sections' => 0, 'direction' => 1, 'hide_lonely' => 1, 'action' => 'topic.create');
     $this->selectcatlist = JHtml::_('kunenaforum.categorylist', 'catid', $catid, $options, $cat_params, 'class="form-control inputbox required"', 'value', 'text', $selected, 'postcatid');
     $this->action = 'post';
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($arraypollcatid) {
         $this->poll = $this->topic->getPoll();
     }
     $this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_NEW_TOPIC');
     return true;
 }
コード例 #16
0
ファイル: textlink.php プロジェクト: BillVGN/PortalPRP
<?php
/**
 * Kunena Component
 *
 * @package     Kunena.Template.Crypsis
 * @subpackage  BBCode
 *
 * @copyright   (C) 2008 - 2016 Kunena Team. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link        https://www.kunena.org
 **/
defined('_JEXEC') or die ();

/** @var KunenaAttachment $attachment */
$attachment = $this->attachment;

$config = KunenaConfig::getInstance();

$attributesLink = $attachment->isImage() && $config->lightbox ? ' class="fancybox-button" rel="fancybox-button"' : '';
?>

<a class="btn btn-small" rel="popover" data-placement="bottom" data-trigger="hover" target="_blank" data-content="Filesize: <?php echo number_format($attachment->size / 1024, 0, '', ',') . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT'); ?>
" data-original-title="<?php echo $attachment->getShortName(); ?>" href="<?php echo $attachment->getUrl(); ?>" title="<?php echo KunenaAttachmentHelper::shortenFileName($attachment->getFilename(), 0, 26); ?>">
	<i class="icon icon-info"></i>
</a>
コード例 #17
0
ファイル: image.php プロジェクト: BillVGN/PortalPRP
<?php
/**
 * Kunena Component
* @package Kunena.Template.Crypsis
* @subpackage BBCode
*
* @copyright (C) 2008 - 2016 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined ( '_JEXEC' ) or die ();

/** @var KunenaAttachment $attachment */
$attachment = $this->attachment;

if (!$attachment->isImage()) return;

$config = KunenaConfig::getInstance();

$attributesLink = $config->lightbox ? ' rel="lightbox[imagelink' . $attachment->mesid . ']"' : '';
$attributesImg = ' style="max-height:' . (int) $config->imageheight . 'px;"';
?>

<a href="<?php echo $attachment->getUrl(); ?>" title="<?php echo KunenaAttachmentHelper::shortenFileName($attachment->getFilename(), 0,7); ?>"<?php echo $attributesLink; ?>>
	<img src="<?php echo $attachment->getUrl(); ?>"<?php echo $attributesImg; ?> alt="" />
</a>
コード例 #18
0
ファイル: default.php プロジェクト: Ruud68/Kunena-Forum
	<?php 
if ($url) {
    ?>

	<?php 
    echo JText::_('COM_KUNENA_FILENAME');
    ?>
	<a href="<?php 
    echo $url;
    ?>
" title="<?php 
    echo $this->escape($filename);
    ?>
">
		<?php 
    echo $this->escape(KunenaAttachmentHelper::shortenFilename($filename));
    ?>
	</a>

	<br />

	<?php 
    echo JText::_('COM_KUNENA_FILESIZE') . number_format($size / 1024, 0, '', ',') . ' ' . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT');
    ?>

	<?php 
}
?>
</div>
コード例 #19
0
ファイル: view.html.php プロジェクト: Jougito/DynWeb
 function displayThreadHistory()
 {
     if (!$this->hasThreadHistory()) {
         return;
     }
     $this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, $ordering = 'DESC');
     $this->historycount = count($this->history);
     $this->replycount = $this->topic->getReplies();
     KunenaAttachmentHelper::getByMessage($this->history);
     $userlist = array();
     foreach ($this->history as $message) {
         $userlist[(int) $message->userid] = (int) $message->userid;
     }
     KunenaUserHelper::loadUsers($userlist);
     // Run events
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'history');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
     echo $this->loadTemplateFile('history');
 }
コード例 #20
0
ファイル: display.php プロジェクト: anawu2006/PeerLearning
 /**
  * Display attachment.
  *
  * @return void
  *
  * @throws RuntimeException
  * @throws KunenaExceptionAuthorise
  */
 public function display()
 {
     KunenaFactory::loadLanguage('com_kunena');
     $format = $this->input->getWord('format', 'html');
     $id = $this->input->getInt('id', 0);
     $thumb = $this->input->getBool('thumb', false);
     $download = $this->input->getBool('download', false);
     // Run before executing action.
     $this->before();
     if ($format != 'raw' || !$id) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     } elseif ($this->config->board_offline && !$this->me->isAdmin()) {
         // Forum is offline.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 503);
     } elseif ($this->config->regonly && !$this->me->exists()) {
         // Forum is for registered users only.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_LOGIN_NOTIFICATION'), 403);
     }
     $attachment = KunenaAttachmentHelper::get($id);
     $attachment->tryAuthorise();
     $path = $attachment->getPath($thumb);
     if ($thumb && !$path) {
         $path = $attachment->getPath(false);
     }
     if (!$path) {
         // File doesn't exist.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     if (headers_sent()) {
         throw new KunenaExceptionAuthorise('HTTP headers were already sent. Sending attachment failed.', 500);
     }
     // Close all output buffers, just in case.
     while (@ob_end_clean()) {
     }
     // Handle 304 Not Modified
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
         if ($etag == $attachment->hash) {
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT', true, 304);
             // Give fast response.
             flush();
             $this->app->close();
         }
     }
     // Set file headers.
     header('ETag: ' . $attachment->hash);
     header('Pragma: public');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
     if (!$download && $attachment->isImage()) {
         // By default display images inline.
         $guest = new KunenaUser();
         // If guests can access the image, we allow it to be cached for an hour.
         if ($attachment->isAuthorised('read', $guest)) {
             $maxage = 60 * 60;
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $maxage) . ' GMT');
             header('Cache-Control: maxage=' . $maxage);
         } else {
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         }
         header('Content-type: ' . $attachment->filetype);
         header('Content-Disposition: inline; filename="' . $attachment->getFilename(false) . '"');
     } else {
         // Otherwise force file download.
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Content-Description: File Transfer');
         header('Content-Type: application/force-download');
         header('Content-Type: application/octet-stream');
         header('Content-Type: application/download');
         header('Content-Disposition: attachment; filename="' . $attachment->getFilename(false) . '"');
     }
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . filesize($path));
     flush();
     // Output the file contents.
     @readfile($path);
     flush();
     $this->app->close();
 }
コード例 #21
0
ファイル: textlink.php プロジェクト: r-ahmadi/Kunena-Forum
 *
 * @package     Kunena.Template.Crypsis
 * @subpackage  BBCode
 *
 * @copyright   (C) 2008 - 2015 Kunena Team. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link        http://www.kunena.org
 **/
defined('_JEXEC') or die;
/** @var KunenaAttachment $attachment */
$attachment = $this->attachment;
$config = KunenaConfig::getInstance();
$attributesLink = $attachment->isImage() && $config->lightbox ? ' class="fancybox-button" rel="fancybox-button"' : '';
?>

<a class="btn btn-small" rel="popover" data-placement="bottom" data-trigger="hover" data-content="Filesize: <?php 
echo number_format($attachment->size / 1024, 0, '', ',') . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT');
?>
" data-original-title="<?php 
echo $attachment->getShortName();
?>
" href="<?php 
echo $attachment->getUrl();
?>
" title="<?php 
echo KunenaAttachmentHelper::shortenFileName($attachment->getFilename(), 0, 26);
?>
">
	<i class="icon icon-info"></i>
</a>
コード例 #22
0
ファイル: user.php プロジェクト: giabmf11/Kunena-Forum
 public function delfile()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirectBack();
         return;
     }
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     // Array of integers
     JArrayHelper::toInteger($cid);
     if (!empty($cid)) {
         $number = 0;
         foreach ($cid as $id) {
             $attachment = KunenaAttachmentHelper::get($id);
             $message = $attachment->getMessage();
             $attachments = array($attachment->id, 1);
             $attach = array();
             $removeList = array_keys(array_diff_key($attachments, $attach));
             JArrayHelper::toInteger($removeList);
             $message->removeAttachments($removeList);
             $topic = $message->getTopic();
             if ($attachment->isAuthorised('delete') && $attachment->delete()) {
                 $message->save();
                 if ($topic->attachments > 0) {
                     $topic->attachments = $topic->attachments - 1;
                     $topic->save(false);
                 }
                 $number++;
             }
         }
         if ($number > 0) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_ATTACHMENTS_DELETE_SUCCESSFULLY', $number));
             $this->setRedirectBack();
             return;
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETE_FAILED'));
             $this->setRedirectBack();
             return;
         }
     }
     $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_NO_ATTACHMENTS_SELECTED'));
     $this->setRedirectBack();
 }
コード例 #23
0
ファイル: attachment.php プロジェクト: densem-2013/exikom
 /**
  * Set attachment file.
  *
  * Copies the attachment into proper location and makes sure that all the unset fields get properly assigned.
  *
  * @param  string  $source     Absolute path to the upcoming attachment.
  * @param  string  $basename   Filename without extension.
  * @param  string  $extension  File extension.
  * @param  bool    $unlink     Whether to delete the original file or not.
  * @param  bool    $overwrite  If not allowed, throw exception if the file exists.
  *
  * @return bool
  * @throws InvalidArgumentException
  * @throws RuntimeException
  *
  * @since  K4.0
  */
 public function saveFile($source, $basename = null, $extension = null, $unlink = false, $overwrite = false)
 {
     if (!is_file($source)) {
         throw new InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . '(): Attachment file not found.');
     }
     // Hash, size and MIME are set during saving, so let's deal with all other variables.
     $this->userid = is_null($this->userid) ? KunenaUserHelper::getMyself() : $this->userid;
     $this->folder = is_null($this->folder) ? "media/kunena/attachments/{$this->userid}" : $this->folder;
     $this->protected = is_null($this->protected) ? (bool) KunenaConfig::getInstance()->attachment_protection : $this->protected;
     if (!$this->filename_real) {
         $this->filename_real = $this->filename;
     }
     if (!$this->filename || $this->filename == $this->filename_real) {
         if (!$basename || !$extension) {
             throw new InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . '(): Parameters $basename or $extension not provided.');
         }
         // Find available filename.
         $this->filename = KunenaAttachmentHelper::getAvailableFilename($this->folder, $basename, $extension, $this->protected);
     }
     // Create target directory if it does not exist.
     if (!KunenaFolder::exists(JPATH_ROOT . "/{$this->folder}") && !KunenaFolder::create(JPATH_ROOT . "/{$this->folder}")) {
         throw new RuntimeException(JText::_('Failed to create attachment directory.'));
     }
     $destination = JPATH_ROOT . "/{$this->folder}/{$this->filename}";
     // Move the file into the final location (if not already in there).
     if ($source != $destination) {
         // Create target directory if it does not exist.
         if (!$overwrite && is_file($destination)) {
             throw new RuntimeException(JText::sprintf('Attachment %s already exists.'), $this->filename_real);
         }
         if ($unlink) {
             @chmod($source, 0644);
         }
         $success = KunenaFile::copy($source, $destination);
         if (!$success) {
             throw new RuntimeException(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_NOT_MOVED', $destination));
         }
         KunenaPath::setPermissions($destination);
         if ($unlink) {
             unlink($source);
         }
     }
     return $this->save();
 }
コード例 #24
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare messages for display.
  *
  * @param   int  $mesid  Selected message Id.
  *
  * @return  void
  */
 protected function prepareMessages($mesid)
 {
     // Get thank yous for all messages in the page
     $thankyous = KunenaForumMessageThankyouHelper::getByMessage($this->messages);
     // First collect ids and users.
     $threaded = $this->layout == 'indented' || $this->layout == 'threaded';
     $userlist = array();
     $this->threaded = array();
     $location = $this->pagination->limitstart;
     foreach ($this->messages as $message) {
         $message->replynum = ++$location;
         if ($threaded) {
             // Threaded ordering
             if (isset($this->messages[$message->parent])) {
                 $this->threaded[$message->parent][] = $message->id;
             } else {
                 $this->threaded[0][] = $message->id;
             }
         }
         $userlist[(int) $message->userid] = (int) $message->userid;
         $userlist[(int) $message->modified_by] = (int) $message->modified_by;
         $thankyou_list = $thankyous[$message->id]->getList();
         $message->thankyou = array();
         if (!empty($thankyou_list)) {
             $message->thankyou = $thankyou_list;
         }
     }
     if (!isset($this->messages[$mesid]) && !empty($this->messages)) {
         $this->message = reset($this->messages);
     }
     if ($threaded) {
         if (!isset($this->messages[$this->topic->first_post_id])) {
             $this->messages = $this->getThreadedOrdering(0, array('edge'));
         } else {
             $this->messages = $this->getThreadedOrdering();
         }
     }
     // Prefetch all users/avatars to avoid user by user queries during template iterations
     KunenaUserHelper::loadUsers($userlist);
     // Prefetch attachments.
     KunenaAttachmentHelper::getByMessage($this->messages);
 }