Example #1
0
	function delete() {
		$app =  JFactory::getApplication ();
		$db = JFactory::getDBO ();

		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		$cids = JRequest::getVar ( 'cid', array (), 'post', 'array' );

		if (! $cids) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_NO_ATTACHMENTS_SELECTED' ), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		foreach( $cids as $id ) {
			kimport ('kunena.forum.message.attachment.helper');
			$attachment = KunenaForumMessageAttachmentHelper::get($id);
			$attachment->delete();
		}

		$app->enqueueMessage ( JText::_('COM_KUNENA_ATTACHMENTS_DELETED_SUCCESSFULLY') );
		$app->redirect ( KunenaRoute::_($this->baseurl, false) );
	}
 function __construct($catid = null)
 {
     $this->_db = JFactory::getDBO();
     $this->_my = JFactory::getUser();
     $this->_session = KunenaFactory::getSession();
     $this->_config = KunenaFactory::getConfig();
     $this->_isimage = false;
     $this->_isfile = false;
     $me = KunenaUserHelper::getMyself();
     $this->validImageExts = (array) KunenaForumMessageAttachmentHelper::getImageExtensions($catid, $me->userid);
     $this->validFileExts = (array) KunenaForumMessageAttachmentHelper::getFileExtensions($catid, $me->userid);
     $this->setImageResize(intval($this->_config->imagesize) * 1024, intval($this->_config->imagewidth), intval($this->_config->imageheight), intval($this->_config->imagequality));
 }
Example #3
0
	protected function generate() {
		require_once KPATH_SITE.'/lib/kunena.link.class.php';
		if (!isset($this->_shorttype)) {
			$this->_shorttype = $this->isImage($this->filetype) ? 'image' : $this->filetype;
			$this->_shortname = KunenaForumMessageAttachmentHelper::shortenFileName($this->filename);

			$config = KunenaFactory::getConfig();
			$this->_imagelink = null;
			$template = KunenaFactory::getTemplate();
			switch (strtolower ( $this->_shorttype )) {
				case 'image' :
					// Check for thumbnail and if available, use for display
					if (file_exists ( JPATH_ROOT . '/' . $this->folder . '/thumb/' . $this->filename )) {
						$thumb = $this->folder . '/thumb/' . $this->filename;
						$imgsize = '';
					} else {
						$thumb = $this->folder . '/' . $this->filename;
						$imgsize = 'width="' . $config->thumbwidth . 'px" height="' . $config->thumbheight . 'px"';
					}

					$img = '<img title="' . $this->escape ( $this->filename ) . '" ' . $imgsize . ' src="' . JURI::ROOT () . $thumb . '" alt="' . $this->escape ( $this->filename ) . '" />';
					$this->_thumblink = CKunenaLink::GetAttachmentLink ( $this->escape ( $this->folder ), $this->escape ( $this->filename ), $img, $this->escape ( $this->filename ), ($config->lightbox)? 'lightbox[thumb' . intval ( $this->mesid ). ']':'' );
					$img = '<img title="' . $this->escape ( $this->filename ) . '" src="' . JURI::ROOT () . $this->escape ( $this->folder ) . '/' . $this->escape ( $this->filename ) . '" alt="' . $this->escape ( $this->filename ) . '" />';
					$this->_imagelink = CKunenaLink::GetAttachmentLink ( $this->escape ( $this->folder ), $this->escape ( $this->filename ), $img, $this->escape ( $this->filename ), ($config->lightbox)?'lightbox[imagelink' . intval ( $this->mesid ) .']':'' );
					$this->_textLink = CKunenaLink::GetAttachmentLink ( $this->escape ( $this->folder ), $this->escape ( $this->filename ), $this->escape ( $this->_shortname ), $this->escape ( $this->filename ), ($config->lightbox)?'lightbox[simple' . $this->mesid . ']' . ' nofollow':' nofollow' ) . ' (' . number_format ( intval ( $this->size ) / 1024, 0, '', ',' ) . 'KB)';
					break;
				default :
					// Filetype without thumbnail or icon support - use default file icon
					$img = '<img src="' . $template->getImagePath('icons/attach_generic.png') . '" alt="' . JText::_ ( 'COM_KUNENA_ATTACH' ) . '" />';
					$this->_thumblink = CKunenaLink::GetAttachmentLink ( $this->escape ( $this->folder ), $this->escape ( $this->filename ), $img, $this->escape ( $this->filename ), 'nofollow' );
					$this->_textLink = CKunenaLink::GetAttachmentLink ( $this->escape ( $this->folder ), $this->escape ( $this->filename ), $this->escape ( $this->_shortname ), $this->escape ( $this->filename ), 'nofollow' ) . ' (' . number_format ( intval ( $this->size ) / 1024, 0, '', ',' ) . 'KB)';
			}
			$this->_disabled = false;
			if (! KunenaUserHelper::getMyself()->exists()) {
				if ($this->_shorttype == 'image' && ! $config->showimgforguest) {
					$this->_disabled = true;
					$this->_textLink = JText::_ ( 'COM_KUNENA_SHOWIMGFORGUEST_HIDEIMG' );
				}
				if ($this->_shorttype != 'image' && ! $config->showfileforguest) {
					$this->_disabled = true;
					$this->_textLink = JText::_ ( 'COM_KUNENA_SHOWIMGFORGUEST_HIDEFILE' );
				}
				if ($this->_disabled) {
					$this->_thumblink = '<img src="' . $template->getImagePath('icons/attach_generic.png') . '" alt="' . JText::_ ( 'COM_KUNENA_ATTACH' ) . '" />';
					$this->_imagelink = null;
					$this->size = 0;
				}
			}
		}
	}
Example #4
0
 function delete()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $cids = JRequest::getVar('cid', array(), 'post', 'array');
     if (!$cids) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ATTACHMENTS_SELECTED'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     foreach ($cids as $id) {
         $attachment = KunenaForumMessageAttachmentHelper::get($id);
         $attachment->delete();
     }
     $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETED_SUCCESSFULLY'));
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
Example #5
0
 function display($tpl = null)
 {
     $this->setToolbar();
     $this->items = $this->get('Items');
     $this->state = $this->get('state');
     $this->pagination = $this->get('Pagination');
     // Load attachments instances
     $attachments_id = array();
     foreach ($this->items as $item) {
         $attachments_id[] = $item->id;
     }
     $attachments = KunenaForumMessageAttachmentHelper::getById($attachments_id);
     $this->attachments_instance = array();
     foreach ($attachments as $attachment) {
         $object = new stdClass();
         $object->attachment = $attachment;
         $object->message = $attachment->getMessage();
         $path = JPATH_ROOT . '/' . $attachment->folder . '/' . $attachment->filename;
         if ($attachment->isImage($attachment->filetype) && is_file($path)) {
             list($width, $height) = getimagesize($path);
         } else {
             $width = null;
             $height = null;
         }
         $object->width = $width;
         $object->height = $height;
         $this->attachments_instance[] = $object;
     }
     $this->sortFields = $this->getSortFields();
     $this->sortDirectionFields = $this->getSortDirectionFields();
     $this->filterSearch = $this->escape($this->state->get('list.search'));
     $this->filterTitle = $this->escape($this->state->get('filter.title'));
     $this->filterType = $this->escape($this->state->get('filter.type'));
     $this->filterSize = $this->escape($this->state->get('filter.size'));
     $this->filterDimensions = $this->escape($this->state->get('filter.dims'));
     $this->filterUsername = $this->escape($this->state->get('filter.username'));
     $this->filterPost = $this->escape($this->state->get('filter.post'));
     $this->filterActive = $this->escape($this->state->get('filter.active'));
     $this->listOrdering = $this->escape($this->state->get('list.ordering'));
     $this->listDirection = $this->escape($this->state->get('list.direction'));
     return parent::display($tpl);
 }
Example #6
0
	function doprune() {
		$app = JFactory::getApplication ();
		if (!JRequest::checkToken()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}
		$category = KunenaForumCategoryHelper::get(JRequest::getInt ( 'prune_forum', 0 ));
		if (!$category->authorise('admin')) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_CHOOSEFORUMTOPRUNE' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}

		// Convert days to seconds for timestamp functions...
		$prune_days = JRequest::getInt ( 'prune_days', 36500 );
		$prune_date = JFactory::getDate()->toUnix() - ($prune_days * 86400);

		$trashdelete = JRequest::getInt( 'trashdelete', 0);

		// Get up to 100 oldest topics to be deleted
		$params = array(
			'orderby'=>'tt.last_post_time ASC',
			'where'=>"AND tt.last_post_time<{$prune_date} AND ordering=0",
		);
		list($count, $topics) = KunenaForumTopicHelper::getLatestTopics($category->id, 0, 100, $params);
		$deleted = 0;
		foreach ( $topics as $topic ) {
			$deleted++;
			if ( $trashdelete ) $topic->delete(false);
			else $topic->trash();
		}
		KunenaUserHelper::recount();
		KunenaForumCategoryHelper::recount();
		KunenaForumMessageAttachmentHelper::cleanup();
		if ( $trashdelete ) $app->enqueueMessage ( "" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNEDELETED') . " {$deleted}/{$count} " . JText::_('COM_KUNENA_PRUNETHREADS') );
		else $app->enqueueMessage ( "" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNETRASHED') . " {$deleted}/{$count} " . JText::_('COM_KUNENA_PRUNETHREADS') );
		$this->setRedirect(KunenaRoute::_($this->baseurl, false));
	}
Example #7
0
 function displayThreadHistory()
 {
     if (!$this->hasThreadHistory()) {
         return;
     }
     $db = JFactory::getDBO();
     $this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, $ordering = 'DESC');
     $this->historycount = count($this->history);
     KunenaForumMessageAttachmentHelper::getByMessage($this->history);
     $userlist = array();
     foreach ($this->history as $message) {
         $userlist[(int) $message->userid] = (int) $message->userid;
     }
     KunenaUserHelper::loadUsers($userlist);
     // Run events
     if (version_compare(JVERSION, '1.6', '>')) {
         // Joomla 1.6+
         $params = new JRegistry();
     } else {
         // Joomla 1.5
         $params = new JParameter('');
     }
     $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');
 }
Example #8
0
	function canManageAttachments () {
		$this->me = KunenaUserHelper::getMyself();
		$this->config = KunenaFactory::getConfig();
		if ( $this->config->show_imgfiles_manage_profile ) {
			$file = null;
			$image = null;

			if ( $this->config->image_upload=='all' && empty($this->config->file_upload)  ) $image = 1;
			elseif (  $this->config->file_upload=='all' && empty($this->config->image_upload) ) $file = 1;
			elseif ( $this->config->image_upload=='all' && $this->config->file_upload=='all' ) { $file = 1; $image = 1; }

			if ( $this->me->userid != 0 ) {
				if ( $this->config->image_upload=='user' && empty($this->config->file_upload)  ) $image = 1;
				elseif (  $this->config->file_upload=='user' && empty($this->config->image_upload) ) $file = 1;
				elseif ( $this->config->image_upload=='user' && $this->config->file_upload=='user' ) { $file = 1; $image = 1; }
			}

			if ( $this->me->isModerator() && ($this->config->image_upload=='moderator' || $this->config->file_upload=='moderator')  ) {
				if (  $this->config->image_upload=='moderator' && empty($this->config->file_upload)  ) $filetype = 'images';
				elseif ( empty($this->config->image_upload) && $this->config->file_upload=='moderator' ) $filetype = 'files';
				elseif ( $this->config->image_upload=='moderator' && $this->config->file_upload=='moderator' ) { $file = 1; $image = 1; }
			}

			if ( $this->me->isAdmin() &&  ($this->config->image_upload=='admin' || $this->config->file_upload=='admin') ) {
				if ( $this->config->image_upload=='admin' && empty($this->config->file_upload)  ) $filetype = 'images';
				elseif ( empty($this->config->image_upload) && $this->config->file_upload=='admin' ) $filetype = 'files';
				elseif ( $this->config->image_upload=='admin' && $this->config->file_upload=='admin' ) { $file = 1; $image = 1; }
			}

			$params = array('file' => $file, 'image' => $image, 'orderby' => 'ASC', 'limit' => '6');
			$this->userattachs = KunenaForumMessageAttachmentHelper::getByUserid($this->me, $params);

			if ($this->userattachs) {
				return true;
			}
		}
		return false;
	}
Example #9
0
	function displayThreadHistory() {
		if (! $this->hasThreadHistory())
			return;

		$db = JFactory::getDBO();
		$this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, $ordering='DESC');
		$this->historycount = count ( $this->history );
		KunenaForumMessageAttachmentHelper::getByMessage($this->history);
		$userlist = array();
		foreach ($this->history as $message) {
			$userlist[(int) $message->userid] = (int) $message->userid;
		}
		KunenaUserHelper::loadUsers($userlist);

		echo $this->loadTemplate ( 'history' );
	}
Example #10
0
	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->getTotal();
		KunenaForumMessageAttachmentHelper::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' );
	}
						<td class="kcol-mid"><?php 
        if ($item->authorise('delete')) {
            echo JHtml::_('grid.id', $i, intval($item->id));
        }
        ?>
</td>

						<td align="center" class="kcol-mid"><img src="<?php 
        echo $item->filetype != '' ? JUri::root(true) . '/media/kunena/icons/image.png' : JUri::root(true) . '/media/kunena/icons/file.png';
        ?>
" alt="" title="" /></td>



						<td class="kcol-mid"><?php 
        echo KunenaForumMessageAttachmentHelper::shortenFileName($item->filename, 5, 5);
        ?>
</td>



						<td class="kcol-mid"><?php 
        echo number_format(intval($item->size) / 1024, 0, '', ',') . ' ' . JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT');
        ?>
</td>



						<td class="kcol-mid"><?php 
        echo $this->getTopicLink($message->getTopic(), $message);
        ?>
Example #12
0
	protected function authoriseUpload($user) {
		// Check if attachments are allowed
		if (KunenaForumMessageAttachmentHelper::getExtensions($this, $user) === false) {
			return JText::_ ( 'COM_KUNENA_LIB_CATEGORY_AUTHORISE_FAILED_UPLOAD_NOT_ALLOWED' );
		}
	}
Example #13
0
 function DoAttachment($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCODE_CHECK) {
         return true;
     }
     // 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 '[' . JText::_('COM_KUNENA_FILEATTACH') . ' ' . basename(!empty($params["name"]) ? $params["name"] : trim(strip_tags($content))) . ']';
     }
     $attachments =& $bbcode->parent->attachments;
     $attachment = null;
     if (!empty($default)) {
         $attachment = KunenaForumMessageAttachmentHelper::get($default);
         if (is_object($attachment)) {
             unset($attachments[$attachment->id]);
         }
     } elseif (empty($content)) {
         $attachment = array_shift($attachments);
     } elseif (!empty($attachments)) {
         foreach ($attachments as $att) {
             if ($att->filename == $content) {
                 $attachment = $att;
                 unset($attachments[$att->id]);
                 break;
             }
         }
     }
     if (!$attachment && !empty($bbcode->parent->inline_attachments)) {
         foreach ($bbcode->parent->inline_attachments as $att) {
             if ($att->filename == trim(strip_tags($content))) {
                 $attachment = $att;
                 break;
             }
         }
     }
     if (!is_object($attachment)) {
         return htmlspecialchars($content);
     } elseif ($attachment->exists() && (!$attachment->authorise() || $attachment->disabled)) {
         // Hide between content from non registered users
         $link = $attachment->getTextLink();
         return '<div class="kmsgattach">' . $link . '</div>';
     } elseif ($attachment->exists() && is_file(JPATH_ROOT . "/{$attachment->folder}/{$attachment->filename}")) {
         $bbcode->parent->inline_attachments[$attachment->id] = $attachment;
         // TODO: use absolute / relative url depending on where BBCode is shown
         $link = JUri::root() . "{$attachment->folder}/{$attachment->filename}";
         $image = $attachment->getImageLink();
         if (empty($image)) {
             return "<div class=\"kmsgattach\"><h4>" . JText::_('COM_KUNENA_FILEATTACH') . "</h4>" . JText::_('COM_KUNENA_FILENAME') . " <a href=\"" . $link . "\" target=\"_blank\" rel=\"nofollow\">" . $attachment->filename . "</a><br />" . JText::_('COM_KUNENA_FILESIZE') . ' ' . number_format(intval($attachment->size) / 1024, 0, '', ',') . ' KB' . "</div>";
         } else {
             return "<div class=\"kmsgimage\">{$attachment->getImageLink()}</div>";
         }
     } else {
         return '<div class="kmsgattach"><h4>' . JText::sprintf('COM_KUNENA_ATTACHMENT_DELETED', htmlspecialchars($content)) . '</h4></div>';
     }
 }
Example #14
0
 public function delfile()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     // Array of integers
     JArrayHelper::toInteger($cid);
     if (!empty($cid)) {
         $number = 0;
         foreach ($cid as $id) {
             $attachment = KunenaForumMessageAttachmentHelper::get($id);
             if ($attachment->authorise('delete') && $attachment->delete()) {
                 $number++;
             }
         }
         if ($number > 0) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_ATTACHMENTS_DELETE_SUCCESSFULLY', $number));
             $this->redirectBack();
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_DELETE_FAILED'));
             $this->redirectBack();
         }
     } else {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ATTACHMENTS_NO_ATTACHMENTS_SELECTED'));
         $this->redirectBack();
     }
 }
Example #15
0
	/**
	 * Method to delete the KunenaForumTopic object from the database
	 *
	 * @access	public
	 * @return	boolean	True on success
	 * @since 1.6
	 */
	public function delete($recount = true) {
		if (!$this->exists()) {
			return true;
		}

		// Create the table object
		$table = $this->getTable ();

		$result = $table->delete ( $this->id );
		if (! $result) {
			$this->setError ( $table->getError () );
		}
		$this->_exists = false;

		// 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 ();
			}

			if ($recount) {
				KunenaUserHelper::recount();
				KunenaForumCategoryHelper::recount();
				KunenaForumMessageAttachmentHelper::cleanup();
			}
		}
		return $result;
	}
		<div class="kbody">
			<form action="<?php echo KunenaRoute::_('index.php?option=com_kunena') ?>" method="post" name="adminForm">
				<input type="hidden" name="view" value="user" />
				<input type="hidden" name="task" value="delfile" />
				<input type="hidden" name="boxchecked" value="0" />
				<?php echo JHTML::_( 'form.token' ); ?>

				<ul>
				<?php
				if ( empty($this->items) ):
					 echo '<li>'.JText::_('COM_KUNENA_USER_NO_ATTACHMENTS').'</li>';
					else:
				$i=0;
				$y=1;
				foreach ($this->items as $file) :
					$instance = KunenaForumMessageAttachmentHelper::get($file->id);

					$evenodd = $i % 2;

					if ($evenodd == 0)	$usrl_class="row1";
					else $usrl_class="row2"; ?>

					<li class="kposts-row">
						<table summary="List of all forum categories with posts and replies of each">
							<tbody>
								<tr>
									<td class="kposts-topic">
										<h3><?php echo $y; ?></h3>
									</td>
									<td class="ktopic-icon"><?php echo JHTML::_('grid.id', $i, intval($file->id)) ?></td>
									<td class="kpost-topic">
Example #17
0
	function DoAttachment($bbcode, $action, $name, $default, $params, $content) {
		if ($action == BBCODE_CHECK)
			return true;

		if (! is_object ( $bbcode->parent ) && ! isset ( $bbcode->parent->attachments )) {
			return '[Attachment]'; // TODO
		}
		$attachments = &$bbcode->parent->attachments;
		$attachment = null;
		if (! empty ( $default )) {
			$attachment = KunenaForumMessageAttachmentHelper::get ($default);
			if (is_object ( $attachment )) {
				unset ( $attachments [$attachment->id] );
			}
		} elseif (empty ( $content )) {
			$attachment = array_shift ( $attachments );
		} elseif (!empty ( $attachments )) {
			foreach ( $attachments as $att ) {
				if ($att->filename == $content) {
					$attachment = $att;
					unset ( $attachments [$att->id] );
					break;
				}
			}
		}
		if (! $attachment && ! empty ( $bbcode->parent->inline_attachments )) {
			foreach ( $bbcode->parent->inline_attachments as $att ) {
				if ($att->filename == trim($bbcode->UnHTMLEncode(strip_tags($content)))) {
					$attachment = $att;
					break;
				}
			}
		}

		if (is_object ( $attachment ) && ! empty ( $attachment->disabled )) {
			// Hide between content from non registered users
			return '<div class="kmsgattach">' . $attachment->textLink . '</div>';
		} else {
			if (is_object ( $attachment ) && is_file ( JPATH_ROOT . "/{$attachment->folder}/{$attachment->filename}" )) {
				$bbcode->parent->inline_attachments [$attachment->id] = $attachment;
				$link = JURI::base () . "{$attachment->folder}/{$attachment->filename}";
				$image = $attachment->getImageLink();
				if (empty ( $image )) {
					return "<div class=\"kmsgattach\"><h4>" . JText::_ ( 'COM_KUNENA_FILEATTACH' ) . "</h4>" . JText::_ ( 'COM_KUNENA_FILENAME' ) . " <a href=\"" . $link . "\" target=\"_blank\" rel=\"nofollow\">" . $attachment->filename . "</a><br />" . JText::_ ( 'COM_KUNENA_FILESIZE' ) . ' ' . number_format ( intval ( $attachment->size ) / 1024, 0, '', ',' ) . ' KB' . "</div>";
				} else {
					return "<div class=\"kmsgimage\">{$attachment->getImageLink()}</div>";
				}
			} else {
				return '<div class="kmsgattach"><h4>' . JText::sprintf ( 'COM_KUNENA_ATTACHMENT_DELETED', $content ) . '</h4></div>';
			}
		}
	}
Example #18
0
					</tr>
				</tfoot>
		<?php
			$k = 0;
			$i = 0;
			$n = count($this->items);
			foreach($this->items as $id=>$attachment) {
				$instance = KunenaForumMessageAttachmentHelper::get($attachment->id);
				$message = $instance->getMessage();
				$path = JPATH_ROOT.'/'.$attachment->folder.'/'.$attachment->filename;
				if ( $instance->isImage($attachment->filetype) && is_file($path)) list($width, $height) =	getimagesize( $path );
		?>
			<tr <?php echo 'class = "row' . $k . '"';?>>
				<td class="right"><?php echo $i + $this->navigation->limitstart + 1; ?></td>
				<td><?php echo JHTML::_('grid.id', $i, intval($attachment->id)) ?></td>
				<td class="left" width="70%"><?php echo $instance->getThumbnailLink() . ' ' . KunenaForumMessageAttachmentHelper::shortenFileName($attachment->filename, 10, 15) ?></td>
				<td class="center"><?php echo intval($attachment->id); ?></td>
				<td class="center"><?php echo $attachment->filetype; ?></td>
				<td class="center"><?php echo number_format ( intval ( $attachment->size ) / 1024, 0, '', ',' ) . ' KB'; ?></td>
				<td class="center"><?php echo isset($width) && isset($height) ? $width . ' x ' . $height  : '' ?></td>
				<td class="center"><?php echo $message->name; ?></td>
				<td class="center"><?php echo $message->subject; ?></td>
			</tr>
				<?php
				$i++;
				$k = 1 - $k;
				}
				?>
		</table>

		<input type="hidden" name="option" value="com_kunena" />
Example #19
0
 function canManageAttachments()
 {
     if ($this->config->show_imgfiles_manage_profile) {
         $params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');
         $this->userattachs = KunenaForumMessageAttachmentHelper::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;
 }
Example #20
0
	function displayAttachments() {
		kimport('kunena.forum.message.attachment.helper');
		$this->me = KunenaFactory::getUser ();
		$params = array('filetype' => '', 'orderby' => 'ASC', 'limit' => '6');
		$this->items = KunenaForumMessageAttachmentHelper::getByUserid($this->me, $params);

		$this->title = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');

		echo $this->loadTemplate('attachments');
	}
Example #21
0
 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
         KunenaForumMessageAttachmentHelper::getByMessage($this->messages);
     }
     return $this->messages;
 }
Example #22
0
	/**
	 * @param bool|array $ids
	 *
	 * @return KunenaForumMessageAttachment[]
	 */
	public function getAttachments($ids=false) {
		if ($ids === false) {
			return KunenaForumMessageAttachmentHelper::getByMessage($this->id);
		} else {
			$attachments = KunenaForumMessageAttachmentHelper::getById($ids);
			foreach ($attachments as $id=>$attachment) if ($attachment->mesid != $this->id) unset($attachments[$id]);
			return $attachments;
		}
	}
Example #23
0
	function delfile() {
		$app = JFactory::getApplication ();
		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->redirectBack ();
		}
		$cids = JRequest::getVar ( 'cid', array (), 'post', 'array' );

		$number = count($cids);

		foreach( $cids as $id ) {
			kimport ('kunena.forum.message.attachment.helper');
			$attachment = KunenaForumMessageAttachmentHelper::get($id);
			$attachment->delete();
		}

		$app->enqueueMessage ( JText::sprintf( 'COM_KUNENA_ATTACHMENTS_DELETE_SUCCESSFULLY', $number) );
		$this->redirectBack ();
	}
Example #24
0
	public function getAttachments($ids=false) {
		if ($ids === false) {
			return KunenaForumMessageAttachmentHelper::getByMessage($this->id);
		} else {
			return KunenaForumMessageAttachmentHelper::getById($ids);
		}
	}
Example #25
0
				<tbody>
				<?php 
$k = $i = 0;
if ($this->pagination->total > 0) {
    foreach ($this->attachments_instance as $attachment) {
        ?>
				<tr <?php 
        echo 'class = "row' . $k . '"';
        ?>
>
					<td><?php 
        echo JHtml::_('grid.id', $i, intval($attachment->attachment->id));
        ?>
</td>
					<td><?php 
        echo $attachment->attachment->getThumbnailLink() . ' ' . KunenaForumMessageAttachmentHelper::shortenFileName($attachment->attachment->filename, 10, 15);
        ?>
</td>
					<td><?php 
        echo $this->escape($attachment->attachment->filetype);
        ?>
</td>
					<td><?php 
        echo number_format(intval($attachment->attachment->size) / 1024, 0, '', ',') . ' KB';
        ?>
</td>
					<td><?php 
        echo isset($attachment->width) && isset($attachment->height) ? $attachment->width . ' x ' . $attachment->height : '';
        ?>
</td>
					<td><?php 
					$i=0;
					$y=1;
					foreach ($this->items as $item) :
						$message = $item->getMessage();
						$evenodd = $i % 2;

						if ($evenodd == 0)	$usrl_class="row1";
						else $usrl_class="row2";
					?>

					<tr class="k<?php echo $usrl_class ;?>">
						<td class="kcol-first"><?php echo $y; ?></td>
						<td class="kcol-mid"><?php if ($item->authorise('delete')) echo JHtml::_('grid.id', $i, intval($item->id)) ?></td>
						<td align="center" class="kcol-mid"><img src="<?php echo $item->filetype != '' ? JUri::root(true).'/media/kunena/icons/image.png' : JUri::root(true).'/media/kunena/icons/file.png'; ?>" alt="" title="" /></td>

						<td class="kcol-mid"><?php echo KunenaForumMessageAttachmentHelper::shortenFileName($item->filename, 5, 5); ?></td>

						<td class="kcol-mid"><?php echo number_format ( intval ( $item->size ) / 1024, 0, '', ',' ) . ' '.JText::_('COM_KUNENA_USER_ATTACHMENT_FILE_WEIGHT'); ?></td>

						<td class="kcol-mid"><?php echo $this->getTopicLink($message->getTopic(), $message); ?></td>

						<td align="center" class="kcol-mid"><?php echo $item->getThumbnailLink() ; ?></td>

						<td align="center" class="kcol-mid">
							<?php if ($item->authorise('delete')) : ?>
							<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','delfile')">
								<img src="<?php echo $this->ktemplate->getImagePath('icons/publish_x.png') ?>" alt="" title="" />
							</a>
							<?php endif ?>
						</td>