Example #1
0
								?>
								<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->doc_id) . '&limitstart=' . $limitStart . '&resetfilter=1' . '#comment-item-' . $item->id); ?>">
									<?php echo $item->document_title; ?></a>
							<?php
							}
							elseif ($item->level > 1)
							{
								$parentCommentObject = JUDownloadFrontHelperComment::getCommentObject($item->parent_id, 'cm.id, cm.title');
								$limitStart          = $documentModel->getLimitStartForComment($parentCommentObject->id);
								?>
								<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->doc_id)); ?>">
									<?php echo $item->document_title; ?>
								</a>
								<span> / </span>
								<a target="_blank"
								   href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->doc_id) . '&limitstart=' . $limitStart . '&resetfilter=1' . '#comment-item-' . $parentCommentObject->id); ?>">
									<?php echo $parentCommentObject->title; ?>
								</a>
							<?php
							} ?>
						</td>

						<td class="center">
							<?php
							if ($item->user_id > 0)
							{
								$userComment = JFactory::getUser($item->user_id);
								echo $userComment->get('name');
							}
							else
							{
Example #2
0
	protected function _setBreadcrumb()
	{
		$categoryId = JUDownloadFrontHelperCategory::getMainCategoryId($this->item->id);

		$app          = JFactory::getApplication();
		$pathway      = $app->getPathway();
		$pathwayArray = array();
		if ($categoryId)
		{
			$pathwayArray = JUDownloadFrontHelperBreadcrumb::getBreadcrumbCategory($categoryId);
		}
		else
		{
			$pathwayArray[] = JUDownloadFrontHelperBreadcrumb::getRootPathway();
		}

		$linkDocument   = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id));
		$pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem($this->item->title, $linkDocument);

		if ($this->_layout == 'changelogs')
		{
			$pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem('CHANGELOGS');
		}
		elseif ($this->_layout == 'versions')
		{
			$pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem('VERSIONS');
		}
		elseif ($this->_layout == 'print')
		{
			$pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem('PRINT');

			$document = JFactory::getDocument();
			$document->setMetaData('robots', 'noindex, nofollow');
		}

		$pathway->setPathway($pathwayArray);
	}
Example #3
0
								}
							}
							?>
							<a href="<?php echo JRoute::_('index.php?option=com_judownload&task=modpendingcomment.edit&id=' . $item->id); ?>">
								<?php echo $item->title; ?>
							</a>
						</td>
						<td>
							<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->doc_id)); ?>">
								<?php echo $item->document_title; ?></a>
							<?php if ($item->level > 1)
							{
								?>
								<span class="divider"> > </span>
								<a target="_blank"
								   href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->doc_id)) . "#comment-item-" . $item->parent_id; ?>">
									<?php echo $item->parent_title; ?></a>
							<?php
							} ?>
						</td>
						<td>
							<?php
							if ($item->user_id > 0)
							{
								$userComment = JFactory::getUser($item->user_id);
								echo $userComment->get('name');
							}
							else
							{
								echo $item->guest_name;
							}
Example #4
0
<?php
if (is_array($this->items) && count($this->items))
{
	foreach ($this->items AS $i => $item)
	{
		$this->item = $item;
		$fields = JUDownloadFrontHelperField::getFields($item, null);
		?>
		<tr>
		<td class="center">
			<input type="checkbox" class="judl-cb" name="cid[]" value="<?php echo $item->id; ?>"
			       id="judl-cb-<?php echo $i; ?>"/>
		</td>
		<td class="title">
			<div class="title-wrapper">
				<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->id)); ?>"
				   title="<?php echo $item->title; ?>">
					<?php echo $item->title; ?>
				</a>
				<?php
				if ($item->label_unpublished)
				{
					?>
					<span class="label label-unpublished"><?php echo JText::_('COM_JUDOWNLOAD_UNPUBLISHED'); ?></span>
				<?php
				}

				if ($item->label_pending)
				{
					?>
					<span class="label label-pending"><?php echo JText::_('COM_JUDOWNLOAD_PENDING'); ?></span>
Example #5
0
defined('_JEXEC') or die('Restricted access');

$this->setAttribute("src", $icon_src, "output");
$this->setAttribute("alt", $this->doc->title, "output");
$this->setAttribute("title", $this->doc->title, "output");

if ($isDetailsView)
{
	if ($this->params->get("details_view_set_icon_dimension", 1))
	{
		$this->setAttribute("style", 'display: block; max-width:' . $this->params->get("details_view_icon_width", 100) . 'px; max-height:' . $this->params->get("details_view_icon_height", 100) . 'px;', "output");
	}

	$html = '<img ' . $this->getAttribute(null, null, "output") . ' />';
	echo $html;
}
else
{
	$html = '<a href="' . JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->doc->id)) . '">';
	if ($this->params->get("list_view_set_icon_dimension", 1))
	{
		$this->setAttribute("style", 'display: block; max-width:' . $this->params->get("details_view_icon_width", 100) . 'px; max-height:' . $this->params->get("details_view_icon_height", 100) . 'px;', "output");
	}

	$html .= '<img ' . $this->getAttribute(null, null, "output") . ' />';
	$html .= '</a>';

	echo $html;
}

?>
Example #6
0
	public function updateComment()
	{
		
		JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));

		
		$user  = JFactory::getUser();
		$model = $this->getModel();

		
		$app            = JFactory::getApplication();
		$data           = $app->input->getArray($_POST);
		$documentId     = $data['doc_id'];
		$commentId      = $data['comment_id'];
		$canEditComment = JUDownloadFrontHelperPermission::canEditComment($commentId);
		$redirectUrl    = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($documentId) . '#comment-item-' . $commentId);

		if (!$canEditComment)
		{
			$this->setMessage(JText::_('COM_JUDOWNLOAD_UPDATE_COMMENT_ERROR'));
			$this->setRedirect($redirectUrl);

			return false;
		}
		$params = JUDownloadHelper::getParams(null, $documentId);

		
		$ratingValue = $this->validateCriteria($data);
		if ($ratingValue)
		{
			$data = array_merge($data, $ratingValue);
		}
		else
		{
			$this->setMessage(JText::_('COM_JUDOWNLOAD_UPDATE_COMMENT_ERROR'));
			$this->setRedirect($redirectUrl);

			return false;
		}

		JUDownloadHelper::obCleanData();
		if ($model->updateComment($data, $params))
		{
			
			$logData = array(
				'user_id'   => $user->id,
				'event'     => 'comment.edit',
				'item_id'   => $commentId,
				'doc_id'    => $documentId,
				'value'     => 0,
				'reference' => '',
			);
			JUDownloadFrontHelperLog::addLog($logData);
			$this->setMessage(JText::_('COM_JUDOWNLOAD_UPDATE_COMMENT_SUCCESSFULLY'));
			$this->setRedirect($redirectUrl);

			return true;
		}
		else
		{
			$this->setMessage(JText::_('COM_JUDOWNLOAD_UPDATE_COMMENT_ERROR'));
			$this->setRedirect($redirectUrl);

			return false;
		}
	}
Example #7
0
	public function getDisqus($doc_id, $short_name = '')
	{
		if ($short_name == '')
		{
			$params     = JUDownloadHelper::getParams(null, $doc_id);
			$short_name = $params->get('disqus_username', '');
		}

		$documentObj = JUDownloadHelper::getDocumentById($doc_id);
		$documentUrl = JUDownloadHelperRoute::getDocumentRoute($doc_id);
		$script      = "
			var disqus_shortname = '{$short_name}';
			var disqus_identifier = 'id={$doc_id}';
			var disqus_title = '{$documentObj->title}';
			var disqus_url = '{$documentUrl}';
			(function() {
				var dsq		= document.createElement('script');
				dsq.type	= 'text/javascript';
				dsq.async	= true;
				dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
				(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
			})();";
		$document    = JFactory::getDocument();
		$document->addScriptDeclaration($script);
	}
Example #8
0
<?php
/**
 * ------------------------------------------------------------------------
 * JUDownload for Joomla 2.5, 3.x
 * ------------------------------------------------------------------------
 *
 * @copyright      Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved.
 * @license        GNU General Public License version 2 or later; see LICENSE.txt
 * @author         JoomUltra Co., Ltd
 * @website        http://www.joomultra.com
 * @----------------------------------------------------------------------@
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

if (!$isDetailsView)
{
	$this->setAttribute("href", JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->doc_id)), "output");
	echo '<a ' . $this->getAttribute(null, null, "output") . '>' . $value . '</a>';
}
else
{
	echo '<span ' . $this->getAttribute(null, null, "output") . '>' . $value . '</span>';
}

?>
Example #9
0
			<?php
			if (count($this->items) > 0)
			{
				foreach ($this->items AS $key => $value)
				{
					$type = $value->type;
					if ($type == 'document')
					{
						$title   = $value->document_title;
						$linkDoc = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($value->item_id));
					}

					if ($type == 'comment')
					{
						$title   = $value->comment_title;
						$linkDoc = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($value->document_id));
					}

					if ($this->isOwnDashboard)
					{
						$unsubscribeLink = JRoute::_('index.php?option=com_judownload&task=usersubscriptions.unsubscribe&sub_id=' . $value->id
							. '&' . $this->token . '=1');
					}
					?>
					<?php if ($title)
					{
						?>
						<tr>
							<?php
							if ($this->isOwnDashboard)
							{?>
Example #10
0
	public static function getFeed($feedDocuments, &$document)
	{
		$db     = JFactory::getDbo();
		$app    = JFactory::getApplication();
		$params = JUDownloadHelper::getParams();

		$image     = $params->get('rss_thumbnail_source', 'icon');
		$feedEmail = $params->get('rss_email', 'none');
		$siteEmail = $app->get('mailfrom');

		foreach ($feedDocuments AS $doc)
		{
			$title = $doc->title;
			$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');

			$categoryId = JUDownloadFrontHelperCategory::getMainCategoryId($doc->id);
			$category   = JUDownloadFrontHelperCategory::getCategory($categoryId);

			$feedItem        = new JFeedItem();
			$feedItem->title = $title;
			$feedItem->link  = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($doc->id));
			if ($feedEmail != 'none')
			{
				$user             = JFactory::getUser($doc->created_by);
				$feedItem->author = $doc->created_by_alias ? $doc->created_by_alias : $user->name;
				
				if ($feedEmail == 'site')
				{
					$feedItem->authorEmail = $siteEmail;
				}
				elseif ($feedEmail === 'author')
				{
					$feedItem->authorEmail = $doc->email ? $doc->email : $user->email;
				}
			}

			$feedItem->category = $category->title;
			@$date = $doc->publish_up ? date('r', strtotime($doc->publish_up)) : '';
			$feedItem->date        = $date;
			$feedItem->description = "";

			if ($params->get('rss_show_thumbnail', 1))
			{
				
				if ($image == 'icon' && $doc->icon)
				{
					$imageUrl = JUri::root() . JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/", true) . $doc->icon;
				}
				
				else
				{
					$query = "SELECT file_name FROM #__judownload_images WHERE doc_id = " . $doc->id . " ORDER BY ordering ASC LIMIT 1";
					$db->setQuery($query);
					$firstImage = $db->loadResult();
					$imageUrl   = JUri::root() . JUDownloadFrontHelper::getDirectory("document_small_image_directory", "media/com_judownload/images/gallery/small/", true) . $firstImage;
				}
				$feedItem->description = "<img src='" . $imageUrl . "' align=\"" . $params->get('rss_thumbnail_alignment', 'left') . "\" />";
			}
			$feedItem->description .= $doc->introtext;
			$document->addItem($feedItem);
		}
	}
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$totalChangeLogs = count($this->item->changelogs);
//Show the last changelog
$changelogItem = $this->item->changelogs[0];
?>
<div class="changelogs clearfix">
	<h3 class="title">
		<?php echo JText::_('COM_JUDOWNLOAD_CHANGELOGS'); ?>
		<?php
		if ($totalChangeLogs > 1)
		{
			?>
				<span class="see-all">
					<i class="fa fa-chevron-right"></i>
					<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id) . '&layout=changelogs'); ?>" class="">
						<?php
						echo JText::_('COM_JUDOWNLOAD_SEE_COMPLETE_CHANGELOGS');
						?>
					</a>
				</span>
		<?php
		}
		?>
	</h3>

	<div class="changelogs-wrapper">
		<div class="changelog-row">
			<div class="changelog-head">
				<span class="changelog-version"><i
						class="fa fa-info-circle"></i> <?php echo "<span>" . JText::_('COM_JUDOWNLOAD_FIELD_VERSION') . ":</span> " . $changelogItem->version; ?></span>
	public function getOutput($options = array())
	{
		if (!$this->isPublished())
		{
			return "";
		}

		if (!$this->value)
		{
			return "";
		}

		$options = (array) $options;
		
		if ($this->isDetailsView($options))
		{
			if ($this->params->get("show_introtext_in_details_view", 1))
			{
				$description = $this->value;
			}
			else
			{
				$description = $this->doc->fulltext;
			}

			if ($this->params->get("strip_tags_details_view", 0))
			{
				$allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
				$allowable_tags = str_replace(' ', '', $allowable_tags);
				$allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
				$description    = strip_tags($description, $allowable_tags);
			}

			if ($this->params->get("parse_plugin", 0))
			{
				$description = JHtml::_('content.prepare', $description);
			}

			if ($this->params->get("auto_link", 1))
			{
				$trim_long_url     = $this->params->get('trim_long_url', 0);
				$front_portion_url = $this->params->get('front_portion_url', 0);
				$back_portion_url  = $this->params->get('back_portion_url', 0);
				$regex             = "#http(?:s)?:\/\/(?:www\.)?[\.0-9a-z]{1,255}(\.[a-z]{2,4}){1,2}([\/\?][^\s]{1,}){0,}[\/]?#i";
				preg_match_all($regex, $description, $matches);

				$matches = array_unique($matches[0]);

				if (count($matches) > 0)
				{
					foreach ($matches AS $url)
					{
						$shortenUrl = urldecode($url);
						
						if ($trim_long_url > 0 && strlen($shortenUrl) > $trim_long_url)
						{
							if ($front_portion_url > 0 || $back_portion_url > 0)
							{
								$frontStr   = $front_portion_url > 0 ? substr($shortenUrl, 0, $front_portion_url) : "";
								$backStr    = $back_portion_url > 0 ? substr($shortenUrl, (int) (0 - $back_portion_url)) : "";
								$shortenUrl = $frontStr . '...' . $backStr;
							}

							$shortenUrl  = '<a href="' . $url . '">' . $shortenUrl . '</a> ';
							$description = str_replace(trim($url), $shortenUrl, $description);
							$description = JUDownloadFrontHelperString::replaceIgnore(trim($url), $shortenUrl, $description);
						}
						
						else
						{
							$description = JUDownloadFrontHelperString::replaceIgnore($url, '<a href="' . $url . '">' . trim($shortenUrl) . '</a> ', $description);
						}
					}
				}
			}

			if ($this->params->get("nl2br_details_view", 0))
			{
				$description = nl2br($description);
			}
		}
		
		else
		{
			$description = $this->doc->introtext;

			if ($this->params->get("strip_tags_list_view", 1))
			{
				$allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
				$allowable_tags = str_replace(' ', '', $allowable_tags);
				$allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
				$description    = strip_tags($description, $allowable_tags);
			}

			if ($this->params->get("use_html_entities", 0))
			{
				$description = htmlentities($description);
			}

			$isTruncated = false;
			if ($this->params->get("truncate", 1))
			{
				if ($this->params->get("limit_char_in_list_view", 200) < strlen($description))
				{
					$isTruncated = true;
				}

				$description = JUDownloadFrontHelperString::truncateHtml($description, $this->params->get("limit_char_in_list_view", 200));
			}

			if ($this->params->get("parse_plugin", 0))
			{
				$description = JHtml::_('content.prepare', $description);
			}

			if ($this->params->get("show_readmore", 0))
			{
				if ($this->params->get("show_readmore_when", 1) == 2 || ($this->params->get("show_readmore_when", 1) == 1 && $isTruncated))
				{
					$description .= ' <a class="readmore" href="' . JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->doc_id)) . '">' . $this->params->get("readmore_text", 'Read more...') . '</a>';
				}
			}
		}

		$this->setVariable('value', $description);

		return $this->fetch('output.php', __CLASS__);
	}
Example #13
0
			<button id="judl-submit-password" class="btn">
				<i class="fa fa-unlock-alt"></i> <?php echo JText::_("COM_JUDOWNLOAD_UNLOCK"); ?>
			</button>
		</div>
	</div>
<?php
}

// Show download multi files button or external link button or direct error messages
echo $this->loadTemplate('download_multi_button');

if(JUDLPROVERSION && count($this->item->versions) > 1)
{
	?>
	<div class="pull-right">
		<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id) . '&layout=versions'); ?>">
			<span class="btn btn-mini"><?php echo JText::_('COM_JUDOWNLOAD_OLDER_VERSIONS'); ?> <i class="fa fa-angle-right"></i></span>
		</a>
	</div>
<?php
}

// Show modal
if($this->item->params->get('access-download'))
{
	// Show license modal if need to confirm license and has license
	if (isset($this->item->fields['confirm_license']) && $this->item->fields['confirm_license']->value
		&& isset($this->item->fields['license_id']) && $this->item->fields['license_id']->value
	)
	{
		?>
		</form>
	</div>
<?php
}
?>
<input name="min-comment-characters" value="<?php echo $this->min_comment_characters ?>" type="hidden"/>
<input name="max-comment-characters" value="<?php echo $this->max_comment_characters ?>" type="hidden"/>

<?php
if ($this->item->comment->total_comments_no_filter)
{
	?>
	<h3 class="total-comments clearfix"><?php echo JText::plural('COM_JUDOWNLOAD_N_COMMENT', $this->item->comment->total_comments); ?></h3>

	<form name="judl-comment-filter-sort-form" class="comment-filter-sort-form clearfix" method="POST"
	      action="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id)); ?>">
		<div class="filter-sort pull-right">
			<?php
			if ($this->params->get('filter_comment_language', 0))
			{
				?>
				<select name="filter_lang" onchange="this.form.submit()" class="input-medium">
					<?php echo JHtml::_('select.options', $this->langArray, 'value', 'text', $this->list_lang_comment); ?>
				</select>
			<?php
			}

			if($this->params->get('filter_comment_rating', 1))
			{
				?>
				<select name="star_filter" onchange="this.form.submit()" class="input-small">
Example #15
0
	public function download()
	{
		
		JSession::checkToken('request') or die(JText::_('JINVALID_TOKEN'));

		
		$model = $this->getModel();

		
		$model->deleteExpiredTmpFiles();

		
		$app = JFactory::getApplication();
		
		$submittedCategoryId = $app->input->getInt('cat_id', 0);
		$documentIds         = $app->input->get('doc_id', null, null);
		$fileIds             = $app->input->get('file_id', null, null);
		$version             = $app->input->get('version', '', 'string');

		$serverTime      = JFactory::getDate()->toSql();
		$serverTimeStamp = strtotime($serverTime);

		$valuesStoreId = (array) $app->getUserState('com_judownload.download.storeid');

		$params                 = JUDownloadHelper::getParams();
		$noCountingDownloadTime = (int) $params->get('no_counting_download_time', 300);
		
		if ($noCountingDownloadTime > 0)
		{
			if (!empty($valuesStoreId))
			{
				foreach ($valuesStoreId AS $keyStoreId => $valueStoreId)
				{
					if ($serverTimeStamp - $keyStoreId > $noCountingDownloadTime)
					{
						unset($valuesStoreId[$keyStoreId]);
					}
				}
			}

			$app->setUserState('com_judownload.download.storeid', $valuesStoreId);
		}

		
		$dispatcher = JDispatcher::getInstance();
		JPluginHelper::importPlugin('judownload');

		
		if (isset($fileIds))
		{
			
			if (is_array($fileIds))
			{
				
				$fileIdArray = $fileIds;
			}
			else
			{
				
				$fileIdArray = explode(',', $fileIds);
			}

			
			if (count($fileIdArray) > 0)
			{
				
				if (count($fileIdArray) > 1)
				{
					
					$documentId = (int) $documentIds;
					if (!$documentIds)
					{
						$message = JText::_('COM_JUDOWNLOAD_NO_DOCUMENT_DETECTED');
						$this->setRedirect($this->getReturnPage(), $message, 'error');

						return false;
					}

					
					$fileObjectList   = $model->getAllFilesOfDocument($documentId);
					$validFileIdArray = array();
					foreach ($fileObjectList AS $fileObject)
					{
						if (in_array($fileObject->id, $fileIdArray))
						{
							$validFileIdArray[] = $fileObject->id;
						}
					}
				}
				
				else
				{
					$fileObject = $model->getFileObject($fileIdArray[0]);
					$documentId = $fileObject->doc_id;
					if (isset($documentIds))
					{
						$documentIdPost = (int) $documentIds;
						if ($documentIdPost != $documentId)
						{
							$message = JText::_('COM_JUDOWNLOAD_INVALID_DATA');
							$this->setRedirect($this->getReturnPage(), $message, 'error');

							return false;
						}
					}
					$validFileIdArray = $fileIdArray;
					
					$physicalFilePath = $model->getPhysicalFilePath($validFileIdArray[0]);
					$physicalFilePath = JPath::clean($physicalFilePath);
					if (!JFile::exists($physicalFilePath))
					{
						$message = JText::_('COM_JUDOWNLOAD_FILE_DOES_NOT_EXIST');
						$this->setRedirect($this->getReturnPage(), $message, 'error');

						return false;
					}
				}

				
				$canDownloadDocument = $model->canDownloadDocument($documentId);
				if ($canDownloadDocument)
				{
					if (count($validFileIdArray) > 0)
					{
						
						$externalField = new JUDownloadFieldCore_external_link();
						$document      = JUDownloadHelper::getDocumentById($documentId);
						if ($externalField->isPublished() && $document->external_link != '')
						{
							$dispatcher->trigger('onAfterDownloadDocument', array($documentId, array(), 0));

							
							$logData = array(
								'user_id'   => JFactory::getUser()->id,
								'event'     => 'document.download',
								'item_id'   => $documentId,
								'doc_id'    => $documentId,
								'value'     => 0,
								'reference' => 'external'
							);
							JUDownloadFrontHelperLog::addLog($logData);

							
							JUDownloadFrontHelperMail::sendEmailByEvent('document.download', $documentId);

							
							$model->updateDocumentDownloadCounter($documentId);

							
							$this->setRedirect(JRoute::_($document->external_link, false));

							return true;
						}

						if (count($validFileIdArray) > 1)
						{
							$params = JUDownloadHelper::getParams(null, (int) $documentId);
							
							if (!$params->get('allow_zip_file', 1))
							{
								$message = JText::_('COM_JUDOWNLOAD_INVALID_DOWNLOAD_DATA');
								$this->setRedirect($this->getReturnPage(), $message, 'error');

								return false;
							}
						}

						
						foreach ($validFileIdArray AS $validFileId)
						{
							$canDownloadFile = $model->canDownloadFile($validFileId, false);
							if (!$canDownloadFile)
							{
								$fileObject = $model->getFileObject($validFileId);
								$message    = JText::sprintf('COM_JUDOWNLOAD_YOU_CAN_NOT_DOWNLOAD_FILE_X', $fileObject->rename);
								$this->setRedirect($this->getReturnPage(), $message, 'error');

								return false;
							}
						}

						if ($noCountingDownloadTime > 0)
						{
							sort($validFileIdArray);
							$storeID = md5('file' . serialize($validFileIdArray) . $version);
							if (in_array($storeID, $valuesStoreId))
							{
								$generalCheck = true;
							}
							else
							{
								
								$generalCheck = $model->generalCheckDownload();
							}
						}
						else
						{
							$generalCheck = $model->generalCheckDownload();
						}

						if (!$generalCheck)
						{
							$message = $model->getError();
							$this->setRedirect($this->getReturnPage(), $message, 'error');

							return false;
						}

						if ($model->download('file', $validFileIdArray, $documentId, $version) === false)
						{
							$message = $model->getError();
							$this->setRedirect($this->getReturnPage(), $message, 'error');

							return false;
						}

					}
					
					else
					{
						$message = JText::_('COM_JUDOWNLOAD_INVALID_DOWNLOAD_DATA');
						$this->setRedirect($this->getReturnPage(), $message, 'error');

						return false;
					}
				}
				
				else
				{
					$message          = implode("<br/>", $model->getErrors());
					$params           = JUDownloadHelper::getParams(null, $documentId);
					$display_messages = $params->get('show_rule_messages', 'modal');
					if ($display_messages == "redirect")
					{
						$return = $app->input->get('return', null, 'base64');
						$this->setRedirect(JRoute::_('index.php?option=com_judownload&view=downloaderror&return=' . $return, false), $message, 'error');
					}
					else
					{
						$this->setRedirect($this->getReturnPage(), $message, 'error');
					}

					return false;
				}
			}
			
			else
			{
				$message = JText::_('COM_JUDOWNLOAD_NO_FILE_TO_DOWNLOAD');
				$this->setRedirect($this->getReturnPage(), $message, 'error');

				return false;
			}
		}
		
		else
		{
			
			if (is_array($documentIds))
			{
				$documentIdArray = $documentIds;
			}
			else
			{
				$documentIdArray = explode(',', $documentIds);
			}

			if (count($documentIdArray) > 0)
			{
				
				if (count($documentIdArray) > 1)
				{
					$categoryId = $submittedCategoryId;
					
					if (!$categoryId)
					{
						$message = JText::_('COM_JUDOWNLOAD_NO_CATEGORY_DETECTED');
						$this->setRedirect($this->getReturnPage(), $message, 'error');

						return false;
					}

					$params = JUDownloadHelper::getParams(null, $categoryId);
					
					if (!$params->get('allow_download_multi_docs', 0))
					{
						$message = JText::_('COM_JUDOWNLOAD_INVALID_DOWNLOAD_DATA');
						$this->setRedirect($this->getReturnPage(), $message, 'error');

						return false;
					}

					
					$validDocumentIdArray = array();

					
					$documentIdsInCat = $model->getChildDocumentIds($categoryId);

					foreach ($documentIdsInCat AS $documentIdInCat)
					{
						if (in_array($documentIdInCat, $documentIdArray))
						{
							$validDocumentIdArray[] = $documentIdInCat;
						}
					}
				}
				
				else
				{
					$documentId = $documentIdArray[0];
					$categoryId = JUDownloadFrontHelperCategory::getMainCategoryId($documentId);

					$validDocumentIdArray = $documentIdArray;
					$documentIdInCat      = JUDownloadHelper::getDocumentById($documentId);
					$externalField        = new JUDownloadFieldCore_external_link();
					if ($externalField->isPublished() && $documentIdInCat->external_link != '')
					{
						$dispatcher->trigger('onAfterDownloadDocument', array($documentId, array(), 0));

						
						$logData = array(
							'user_id'   => JFactory::getUser()->id,
							'event'     => 'document.download',
							'item_id'   => $documentId,
							'doc_id'    => $documentId,
							'value'     => 0,
							'reference' => 'external'
						);
						JUDownloadFrontHelperLog::addLog($logData);

						
						JUDownloadFrontHelperMail::sendEmailByEvent('document.download', $documentId);

						
						$model->updateDocumentDownloadCounter($documentId);

						
						$this->setRedirect(JRoute::_($documentIdInCat->external_link, false));

						return true;
					}
				}

				if (count($validDocumentIdArray) > 1)
				{
					$params = JUDownloadHelper::getParams($categoryId);
					
					if (!$params->get('allow_zip_file', 1))
					{
						$message = JText::_('COM_JUDOWNLOAD_INVALID_DOWNLOAD_DATA');
						$this->setRedirect($this->getReturnPage(), $message, 'error');

						return false;
					}
				}
				elseif (count($validDocumentIdArray) == 1)
				{
					$filesInDocument = JUDownloadFrontHelperDocument::getFilesByDocumentId((int) $validDocumentIdArray[0]);
					if (count($filesInDocument) > 1)
					{
						if (!$params->get('allow_zip_file', 1))
						{
							$linkFiles = JUDownloadHelperRoute::getDocumentRoute((int) $validDocumentIdArray[0]);
							$linkFiles .= '#judl-files';
							$app->redirect(JRoute::_($linkFiles, false));
						}
					}
				}

				
				foreach ($validDocumentIdArray AS $documentId)
				{
					$canDownloadDocument = $model->canDownloadDocument($documentId);
					if (!$canDownloadDocument)
					{
						$message          = implode("<br/>", $model->getErrors());
						$params           = JUDownloadHelper::getParams(null, $documentId);
						$display_messages = $params->get('show_rule_messages', 'modal');
						if ($display_messages == "redirect")
						{
							$return = $app->input->get('return', null, 'base64');
							$this->setRedirect(JRoute::_('index.php?option=com_judownload&view=downloaderror&return=' . $return, false), $message, 'error');
						}
						else
						{
							$this->setRedirect($this->getReturnPage(), $message, 'error');
						}

						return false;
					}
				}

				
				if ($noCountingDownloadTime > 0)
				{
					sort($validDocumentIdArray);
					$storeID = md5('document' . serialize($validDocumentIdArray) . $version);
					if (in_array($storeID, $valuesStoreId))
					{
						$generalCheck = true;
					}
					else
					{
						
						$generalCheck = $model->generalCheckDownload();
					}
				}
				else
				{
					$generalCheck = $model->generalCheckDownload();
				}

				if (!$generalCheck)
				{
					$message = $model->getError();
					$this->setRedirect($this->getReturnPage(), $message, 'error');

					return false;
				}

				
				if (count($validDocumentIdArray) == 1)
				{
					if (count($filesInDocument) == 1)
					{
						
						if (!$params->get('allow_zip_file', 1))
						{
							$fileObject = $filesInDocument[0];
							$fileId     = $fileObject->id;
							if ($model->download('file', array($fileId), $validDocumentIdArray[0], $version) === false)
							{
								$message = $model->getError();
								$this->setRedirect($this->getReturnPage(), $message, 'error');

								return false;
							}
						}
					}
				}

				if ($model->download('document', $validDocumentIdArray, $categoryId, $version) === false)
				{
					$message = $model->getError();
					$this->setRedirect($this->getReturnPage(), $message, 'error');

					return false;
				}
			}
			
			else
			{
				$message = JText::_('COM_JUDOWNLOAD_NO_DOCUMENT_TO_DOWNLOAD');
				$this->setRedirect($this->getReturnPage(), $message, 'error');

				return false;
			}
		}
	}
							<?php
							} ?>

							<div class="comment-document">
								<i class="fa fa-file-text-o"></i> <?php echo JText::_("COM_JUDOWNLOAD_DOCUMENT"); ?>
								<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($commentObj->doc_id)); ?>">
									<?php echo $commentObj->document_title; ?>
								</a>
							</div>

							<?php if ($commentObj->level > 1)
							{
								?>
								<div class="comment-reply">
									<i class="fa fa-mail-forward"></i> <?php echo JText::_("COM_JUDOWNLOAD_REPLY_COMMENT"); ?>
									<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($commentObj->doc_id) . '#comment-item-' . $commentObj->id); ?>">
										<?php echo $commentObj->parent_title; ?>
									</a>
								</div>
							<?php
							} ?>
						</div>
						<?php
						$commentObj->comment = JUDownloadFrontHelper::BBCode2Html($commentObj->comment);
						$commentObj->comment = JUDownloadFrontHelperComment::parseCommentText($commentObj->comment, $commentObj->doc_id);
						?>
						<div class="comment-content" itemprop="description">
							<?php echo $commentObj->comment; ?>
						</div>
					</div>
				</div>