Пример #1
0
	protected function _prepareData()
	{
		
		$this->token = JSession::getFormToken();

		
		$this->session = JFactory::getSession();

		
		$this->item->changelogs = JUDownloadFrontHelper::getChangeLogField($this->item->id);

		
		$this->item->versions = $this->model->getVersions($this->item->id);

		
		$this->item->related_documents = $this->model->getRelatedDocuments($this->item->id);
		if (count($this->item->related_documents))
		{
			foreach ($this->item->related_documents AS $documentRelated)
			{
				$documentRelated->link = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($documentRelated->id));
				$documentRelated->icon = JUDownloadHelper::getDocumentIcon($documentRelated->icon);
			}
		}

		
		$this->item->files               = JUDownloadFrontHelperDocument::getFilesByDocumentId($this->item->id);
		$this->can_download_document     = JUDownloadFrontHelperPermission::canDownloadDocument($this->item->id, false);
		$this->display_download_rule_msg = $this->params->get('show_rule_messages', 'modal');

		
		$additionFields = array();
		if (trim($this->item->external_link))
		{
			$additionFields[] = 'external_link';
		}

		if ($this->item->license_id && $this->item->confirm_license)
		{
			$additionFields[] = 'license_id';
			$additionFields[] = 'confirm_license';
		}

		$this->item->fieldGallery = JUDownloadFrontHelperField::getField('gallery', $this->item);
		$this->item->fields       = JUDownloadFrontHelperField::getFields($this->item, 2, array(), array('gallery'), $additionFields);

		
		$this->item->license = JUDownloadFrontHelper::getLicense($this->item->license_id);

		$user = JFactory::getUser();
		$uri  = JUri::getInstance();
		
		if ($this->item->checked_out > 0 && $this->item->checked_out != $user->get('id'))
		{
			if (JUDownloadFrontHelperPermission::canCheckInDocument($this->item->id))
			{
				$this->item->checkin_link = JRoute::_('index.php?option=com_judownload&task=forms.checkin&id=' . $this->item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri)));
			}
		}
		else
		{
			$this->item->edit_link = JRoute::_('index.php?option=com_judownload&task=form.edit&id=' . $this->item->id . '&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));

			if ($this->item->published == 1)
			{
				$this->item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.unpublish&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));
			}
			else
			{
				$this->item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.publish&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));
			}
		}

		$this->item->delete_link = JRoute::_('index.php?option=com_judownload&task=forms.delete&id=' . $this->item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($this->item->id));

		
		if ($this->item->is_subscriber)
		{
			$this->item->unsubscribe_link = $this->model->getUnsubscribeLink($this->item->id);
		}
		else
		{
			$this->item->subscribe_link = $this->model->getSubscribeLink($this->item->id);
		}

		$this->item->contact_link = JRoute::_(JUDownloadHelperRoute::getContactRoute($this->item->id));

		$this->item->report_link = JRoute::_(JUDownloadHelperRoute::getReportDocumentRoute($this->item->id));

		$this->item->print_link = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id) . '&layout=print&tmpl=component&print=1');

		
		$this->item->comment = new stdClass();
		
		$this->item->comment->total_comments_no_filter = $this->model->getTotalCommentsOfDocument($this->item->id);

		
		$this->root_comment = JUDownloadFrontHelperComment::getRootComment();

		
		$langArray   = JHtml::_('contentlanguage.existing');
		$JAll        = new JObject();
		$JAll->text  = JText::_('JALL');
		$JAll->value = '*';
		array_unshift($langArray, $JAll);
		$this->langArray = $langArray;

		
		$this->item->comment->items = $this->get('Items');
		foreach ($this->item->comment->items AS $comment)
		{
			if (JUDownloadFrontHelperPermission::canCheckInComment($comment->id))
			{
				$uri                    = JUri::getInstance();
				$comment->checkout_link = 'index.php?option=com_judownload&task=modcomments.checkin&cid=' . $comment->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri));
			}
			else
			{
				$comment->checkout_link = '';
			}
		}

		$this->item->comment->pagination = $this->get('Pagination');

		
		$this->item->comment->total_comments = $this->get('Total');

		
		$this->item->comment->parent_id = $this->root_comment->id;

		
		$this->website_field_in_comment_form = $this->params->get('website_field_in_comment_form', 0);
		$this->min_comment_characters        = $this->params->get('min_comment_characters', 20);
		$this->max_comment_characters        = $this->params->get('max_comment_characters', 1000);

		
		$this->allow_vote_comment      = $this->params->get('allow_vote_comment', 1);
		$this->allow_vote_down_comment = $this->params->get('allow_vote_down_comment', 1);

		
		$this->order_comment_name_array = $this->model->getCommentOrderingOptions();

		
		$this->order_comment_dir_array = array(
			'ASC'  => JText::_('COM_JUDOWNLOAD_ASC'),
			'DESC' => JText::_('COM_JUDOWNLOAD_DESC')
		);

		
		$this->total_stars          = $this->params->get('number_rating_stars', 5);
		$this->filter_comment_stars = array('' => JText::_('COM_JUDOWNLOAD_ANY_STAR'));
		for ($i = 0; $i <= $this->total_stars; $i++)
		{

			$score                              = ($i == 0) ? 0 : round((($i - 1) * 10) / $this->total_stars, 5) . ',' . round(($i * 10) / $this->total_stars, 5);
			$this->filter_comment_stars[$score] = JText::plural('COM_JUDOWNLOAD_N_STAR', $i);
		}

		
		if ($this->params->get('filter_comment_language', 0))
		{
			$this->list_lang_comment = $this->escape($this->state->get('list.lang'));
		}
		$this->list_order_comment  = $this->escape($this->state->get('list.ordering'));
		$this->list_dir_comment    = $this->escape($this->state->get('list.direction'));
		$this->filter_comment_star = $this->state->get('list.star_filter', '');

		
		$this->website  = $this->title = $this->email = $this->comment = $this->name = '';
		$this->language = '*';
		$form           = $this->session->get('judownload_commentform_' . $this->item->id, null);
		$this->form     = $form;
		if (!empty($form) && $form['parent_id'] == $this->root_comment->id)
		{
			$this->title    = $form['title'];
			$this->name     = $form['guest_name'];
			$this->email    = $form['guest_email'];
			$this->comment  = $form['comment'];
			$this->website  = (isset($form['website'])) ? $form['website'] : '';
			$this->language = $form['comment_language'];
		}
	}
Пример #2
0
	public function getItem()
	{
		$params = $this->getState('params');

		
		$documentId = (int) $this->getState('document.id');
		
		if (!$documentId)
		{
			JError::raiseError(404, JText::_('COM_JUDOWNLOAD_DOCUMENT_NOT_FOUND'));

			return false;
		}

		
		$user = JFactory::getUser();
		
		$db = JFactory::getDbo();
		
		$query = $db->getQuery(true);
		$query->select('d.*, c.id AS cat_id');
		$query->from('#__judownload_documents AS d');

		$query->join('', '#__judownload_documents_xref AS dxref ON d.id = dxref.doc_id AND dxref.main=1');
		$query->join('', '#__judownload_categories AS c ON c.id = dxref.cat_id');

		
		$query->select('(SELECT COUNT(*) FROM #__judownload_files AS f WHERE f.doc_id = d.id AND f.published = 1) AS total_files');

		
		$query->select('(SELECT COUNT(*) FROM #__judownload_comments AS cm WHERE cm.doc_id = d.id AND cm.approved = 1 AND cm.published = 1) AS total_comments');

		
		$query->select('(SELECT COUNT(*) FROM #__judownload_subscriptions AS sub WHERE sub.item_id = d.id AND sub.type = "document" AND sub.published = 1) AS total_subscriptions');

		
		$query->select('(SELECT COUNT(*) FROM #__judownload_reports AS r WHERE r.item_id = d.id AND r.type = "document") AS total_reports');

		
		$query->select('(SELECT GROUP_CONCAT(catids.id ORDER BY dx_catids.main DESC, dx_catids.ordering ASC SEPARATOR ",") FROM (#__judownload_categories AS catids JOIN #__judownload_documents_xref AS dx_catids ON catids.id = dx_catids.cat_id) WHERE d.id = dx_catids.doc_id GROUP BY d.id) AS cat_ids');
		
		$query->select('(SELECT GROUP_CONCAT(cattitles.title ORDER BY dx_cattitles.main DESC, dx_cattitles.ordering ASC SEPARATOR "|||") FROM (#__judownload_categories AS cattitles JOIN #__judownload_documents_xref AS dx_cattitles ON cattitles.id = dx_cattitles.cat_id) WHERE d.id = dx_cattitles.doc_id GROUP BY d.id) AS cat_titles');

		

		
		$accessLevel = implode(',', $user->getAuthorisedViewLevels());
		$db          = JFactory::getDbo();
		$date        = JFactory::getDate();
		$nullDate    = $db->quote($db->getNullDate());
		$nowDate     = $db->quote($date->toSql());

		
		$fieldQuery = $db->getQuery(true);
		$fieldQuery->select('field.id');
		$fieldQuery->from('#__judownload_fields AS field');
		$fieldQuery->where('field.group_id != 1');
		$fieldQuery->where('field.details_view = 1');

		$fieldQuery->where('field.published = 1');
		$fieldQuery->where('field.publish_up <= ' . $nowDate);
		$fieldQuery->where('(field.publish_down = ' . $nullDate . ' OR field.publish_down > ' . $nowDate . ')');

		
		$fieldQuery->where('(field.access IN (' . $accessLevel . ') OR field.who_can_download_can_access = 1)');

		$category = JUDownloadFrontHelperCategory::getMainCategory($documentId);
		if (is_object($category))
		{
			$fieldQuery->where('field.group_id = ' . $category->fieldgroup_id);
		}

		$fieldQuery->join('', '#__judownload_fields_groups AS field_group ON field.group_id = field_group.id');
		$fieldQuery->where('field_group.published = 1');
		$fieldQuery->where('field_group.access IN (' . $accessLevel . ')');

		$fieldQuery->group('field.id');

		$db->setQuery($fieldQuery);

		
		$fields = $db->loadObjectList();
		foreach ($fields AS $field)
		{
			$query->select('IFNULL (fields_values_' . $field->id . '.value, "") AS field_values_' . $field->id);
			$query->join('LEFT', '#__judownload_fields_values AS fields_values_' . $field->id . ' ON fields_values_' . $field->id . '.doc_id = d.id AND fields_values_' . $field->id . '.field_id = ' . $field->id);
		}

		$query->where('d.id = ' . $documentId);
		$db->setQuery($query);
		$documentObject = $db->loadObject();
		
		if (!is_object($documentObject))
		{
			JError::raiseError(404, JText::_('COM_JUDOWNLOAD_DOCUMENT_NOT_FOUND'));

			return false;
		}

		
		$documentObject->params = JUDownloadFrontHelperDocument::getDocumentDisplayParams($documentObject->id);

		
		if (!$user->get('guest'))
		{
			$canEditDocument      = JUDownloadFrontHelperPermission::canEditDocument($documentObject->id);
			$canDeleteDocument    = JUDownloadFrontHelperPermission::canDeleteDocument($documentObject->id);
			$canEditStateDocument = JUDownloadFrontHelperPermission::canEditStateDocument($documentObject);
			$documentObject->params->set('access-edit', $canEditDocument);
			$documentObject->params->set('access-edit-state', $canEditStateDocument);
			$documentObject->params->set('access-delete', $canDeleteDocument);
		}

		
		$canReportDocument   = JUDownloadFrontHelperPermission::canReportDocument($documentObject->id);
		$canContactDocument  = JUDownloadFrontHelperPermission::canContactDocument($documentObject->id);
		$canRateDocument     = JUDownloadFrontHelperPermission::canRateDocument($documentObject->id);
		$canDownloadDocument = JUDownloadFrontHelperPermission::canDownloadDocument($documentObject->id, false);
		$canCommentDocument  = JUDownloadFrontHelperPermission::canComment($documentObject->id);

		$documentObject->params->set('access-report', $canReportDocument);
		$documentObject->params->set('access-contact', $canContactDocument);
		$documentObject->params->set('access-rate', $canRateDocument);
		$documentObject->params->set('access-download', $canDownloadDocument);
		$documentObject->params->set('access-comment', $canCommentDocument);

		$hasPassword = JUDownloadFrontHelperDocument::documentHasPassword($documentObject);
		$documentObject->params->set('has-password', $hasPassword);
		if ($hasPassword)
		{
			$validPassword = JUDownloadFrontHelperPassword::checkPassword($documentObject);
		}
		else
		{
			$validPassword = true;
		}

		$documentObject->params->set('valid-password', $validPassword);

		if ($canDownloadDocument && !$validPassword)
		{
			$documentObject->allow_enter_password = JUDownloadFrontHelperPassword::allowEnterPassword($documentObject->id);
		}

		$token                         = JSession::getFormToken();
		$return                        = base64_encode(urlencode(JUri::getInstance()));
		$documentObject->download_link = JRoute::_('index.php?option=com_judownload&task=download.download&doc_id=' . $documentObject->id . '&' . $token . '=1');
		$documentObject->download_link .= '&amp;return=' . $return;

		if ($params->get('show_rule_messages', 'modal') != 'hide')
		{
			$downloadRuleErrorMessages = JUDownloadFrontHelperDocument::getDownloadRuleErrorMessages($documentObject->id);
			if ($downloadRuleErrorMessages !== true)
			{
				$documentObject->error_msg = $downloadRuleErrorMessages;
			}
		}

		$documentObject->template_params = new JRegistry($documentObject->template_params);

		
		if ($params->get('show_new_label', 1) && JUDownloadFrontHelper::isWithinXDays($documentObject->publish_up, $params->get('num_day_to_show_as_new', 10)))
		{
			$documentObject->label_new = true;
		}
		else
		{
			$documentObject->label_new = false;
		}

		
		if ($params->get('show_updated_label', 1) && JUDownloadFrontHelper::isWithinXDays($documentObject->updated, $params->get('num_day_to_show_as_updated', 10)))
		{
			$documentObject->label_updated = true;
		}
		else
		{
			$documentObject->label_updated = false;
		}

		
		if ($params->get('show_hot_label', 1) && JUDownloadFrontHelperDocument::checkHotDocument($documentObject->publish_up, $params->get('num_download_per_day_to_be_hot', 10), $documentObject->downloads))
		{
			$documentObject->label_hot = true;
		}
		else
		{
			$documentObject->label_hot = false;
		}

		
		if ($params->get('show_featured_label', 1) && $documentObject->featured)
		{
			$documentObject->label_featured = true;
		}
		else
		{
			$documentObject->label_featured = false;
		}

		
		$documentObject->next_item     = $this->getNextPrevItem($documentObject, 'next');
		$documentObject->prev_item     = $this->getNextPrevItem($documentObject, 'prev');
		$documentObject->is_subscriber = $this->isSubscriber($user->id, $documentObject->id, 'document');

		return $documentObject;
	}
Пример #3
0
	public static function canComment($documentId, $email = '')
	{
		
		$canViewDocument = JUDownloadFrontHelperPermission::userCanDoDocument($documentId, true);
		if ($canViewDocument == false)
		{
			return false;
		}

		
		$userIdPassed = self::checkBlackListUserId();
		if (!$userIdPassed)
		{
			return false;
		}

		
		$userIpPassed = self::checkBlackListUserIP();
		if (!$userIpPassed)
		{
			return false;
		}

		
		$params = JUDownloadHelper::getParams(null, $documentId);
		$user   = JFactory::getUser();

		$isDocumentOwner           = JUDownloadFrontHelperPermission::isDocumentOwner($documentId);
		$ownerCanCommentOnDocument = $params->get('document_owner_can_comment', 0);
		
		if ($isDocumentOwner && $ownerCanCommentOnDocument)
		{
			
			$ownerCanCommentManyTimes = $params->get('document_owner_can_comment_many_times', 0);
			if ($ownerCanCommentManyTimes)
			{
				return true;
			}
			else
			{
				$totalCommentsOnDoc = JUDownloadFrontHelperComment::getTotalCommentsOnDocumentOfUser($documentId, $user->id);
				if ($totalCommentsOnDoc == 0)
				{
					return true;
				}
			}
		}

		$asset = 'com_judownload.document.' . $documentId;

		if ($user->authorise('judl.comment.create', $asset) || (JUDownloadFrontHelperPermission::canDownloadDocument($documentId) && $params->get('can_download_can_comment', 0)))
		{
			
			if ($user->authorise('judl.comment.create.many_times', $asset))
			{
				return true;
			}
			else
			{
				if (!$user->get('guest'))
				{
					$totalCommentsOnDoc = JUDownloadFrontHelperComment::getTotalCommentsOnDocumentOfUser($documentId, $user->id);
					if ($totalCommentsOnDoc == 0)
					{
						return true;
					}
				}
				else
				{
					if ($email != '')
					{
						$totalCommentsPerOneDocumentForGuest = JUDownloadFrontHelperComment::getTotalCommentsOnDocumentForGuest($documentId, $email);
						if ($totalCommentsPerOneDocumentForGuest == 0)
						{
							return true;
						}
					}
					else
					{
						return true;
					}
				}
			}
		}

		return false;
	}
Пример #4
0
	public static function appendDataToDocumentObjList(&$documentObjectList, $params, $usingForMod = false)
	{
		if (is_array($documentObjectList) && count($documentObjectList))
		{
			$user   = JFactory::getUser();
			$token  = JSession::getFormToken();
			$return = base64_encode(urlencode(JUri::getInstance()));

			foreach ($documentObjectList AS $documentObject)
			{
				
				JUDownloadHelper::getDocumentById($documentObject->id, false, $documentObject);

				$documentObject->params = JUDownloadFrontHelperDocument::getDocumentDisplayParams($documentObject->id);

				if (!isset($documentObject->total_files))
				{
					$documentObject->total_files = JUDownloadFrontHelperDocument::getTotalPublishedFilesOfDocument($documentObject->id);
				}

				
				if (!$user->get('guest'))
				{
					$canEditDocument      = JUDownloadFrontHelperPermission::canEditDocument($documentObject->id);
					$canEditStateDocument = JUDownloadFrontHelperPermission::canEditStateDocument($documentObject);
					$canDeleteDocument    = JUDownloadFrontHelperPermission::canDeleteDocument($documentObject->id);
					$documentObject->params->set('access-edit', $canEditDocument);
					$documentObject->params->set('access-edit-state', $canEditStateDocument);
					$documentObject->params->set('access-delete', $canDeleteDocument);
				}

				
				if ($params->get('show_report_btn_in_listview', 1) || $usingForMod)
				{
					$canReportDocument = JUDownloadFrontHelperPermission::canReportDocument($documentObject->id);
					$documentObject->params->set('access-report', $canReportDocument);
				}

				if ($params->get('show_download_btn_in_listview', 1) || $usingForMod)
				{
					$canDownloadDocument = JUDownloadFrontHelperPermission::canDownloadDocument($documentObject->id, false);
					$documentObject->params->set('access-download', $canDownloadDocument);

					$hasPassword = JUDownloadFrontHelperDocument::documentHasPassword($documentObject);
					$documentObject->params->set('has-password', $hasPassword);

					if ($hasPassword)
					{
						$validPassword = JUDownloadFrontHelperPassword::checkPassword($documentObject);
					}
					else
					{
						$validPassword = true;
					}

					$documentObject->params->set('valid-password', $validPassword);

					if ($canDownloadDocument && !$validPassword)
					{
						$documentObject->allow_enter_password = JUDownloadFrontHelperPassword::allowEnterPassword($documentObject->id);
					}

					$documentObject->download_link = JRoute::_('index.php?option=com_judownload&task=download.download&doc_id=' . $documentObject->id . '&' . $token . '=1');
					$documentObject->download_link .= '&amp;return=' . $return;

					if ($params->get('show_rule_messages', 'modal') != 'hide')
					{
						$downloadRuleErrorMessages = JUDownloadFrontHelperDocument::getDownloadRuleErrorMessages($documentObject->id);
						if ($downloadRuleErrorMessages !== true)
						{
							$documentObject->error_msg = $downloadRuleErrorMessages;
						}
					}
				}

				
				if ($documentObject->published != 1)
				{
					$documentObject->label_unpublished = true;
				}
				else
				{
					$documentObject->label_unpublished = false;
				}

				
				$documentObject->label_pending = false;
				$nowDate                       = JFactory::getDate()->toSql();
				if (intval($documentObject->publish_up) > 0)
				{
					if (strtotime($documentObject->publish_up) > strtotime($nowDate))
					{
						$documentObject->label_pending = true;
					}
				}

				
				$documentObject->label_expired = false;
				if (intval($documentObject->publish_down) > 0)
				{
					if (intval($documentObject->publish_up) > 0)
					{
						if (strtotime($documentObject->publish_up) <= strtotime($nowDate))
						{
							if (strtotime($documentObject->publish_down) < strtotime($nowDate))
							{
								$documentObject->label_expired = true;
							}
						}
					}
					else
					{
						if (strtotime($documentObject->publish_down) < strtotime($nowDate))
						{
							$documentObject->label_expired = true;
						}
					}
				}

				
				if ($params->get('show_new_label', 1) && JUDownloadFrontHelper::isWithinXDays($documentObject->publish_up, $params->get('num_day_to_show_as_new', 10)))
				{
					$documentObject->label_new = true;
				}
				else
				{
					$documentObject->label_new = false;
				}

				
				if ($params->get('show_updated_label', 1) && JUDownloadFrontHelper::isWithinXDays($documentObject->updated, $params->get('num_day_to_show_as_updated', 10)))
				{
					$documentObject->label_updated = true;
				}
				else
				{
					$documentObject->label_updated = false;
				}

				
				if ($params->get('show_hot_label', 1) && JUDownloadFrontHelperDocument::checkHotDocument($documentObject->publish_up, $params->get('num_download_per_day_to_be_hot', 10), $documentObject->downloads))
				{
					$documentObject->label_hot = true;
				}
				else
				{
					$documentObject->label_hot = false;
				}

				
				if ($params->get('show_featured_label', 1) && $documentObject->featured)
				{
					$documentObject->label_featured = true;
				}
				else
				{
					$documentObject->label_featured = false;
				}
			}
		}
	}
Пример #5
0
	public function canView($options = array())
	{
		$storeId = md5(__METHOD__ . "::" . $this->doc_id . "::" . $this->id . "::" . serialize($options));

		if (!isset(self::$cache[$storeId]))
		{
			
			if (!$this->isPublished())
			{
				self::$cache[$storeId] = false;

				return self::$cache[$storeId];
			}

			
			$app            = JFactory::getApplication();
			$languageFilter = $app->getLanguageFilter();
			if ($languageFilter)
			{
				$languageTag = JFactory::getLanguage()->getTag();
				if (($this->language != $languageTag && $this->language != '*' && $this->language != ''))
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
			}

			if ($this->doc_id)
			{
				$document_display_params = JUDownloadFrontHelperDocument::getDocumentDisplayParams($this->doc_id);
				$document_display_fields = $document_display_params->get('fields');
			}

			$options = (array) $options;

			$field_name = $this->field_name ? $this->field_name : $this->id;
			if ($this->isDetailsView($options))
			{
				
				if (isset($document_display_fields->$field_name) && isset($document_display_fields->$field_name->details_view))
				{
					if (!$document_display_fields->$field_name->details_view)
					{
						self::$cache[$storeId] = false;

						return self::$cache[$storeId];
					}
				}
				
				elseif (!$this->details_view)
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
			}
			else
			{
				
				if (isset($document_display_fields->$field_name) && isset($document_display_fields->$field_name->list_view))
				{
					if (!$document_display_fields->$field_name->list_view)
					{
						self::$cache[$storeId] = false;

						return self::$cache[$storeId];
					}
				}
				
				elseif (!$this->list_view)
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
			}

			
			if (isset($this->doc) && $this->doc->cat_id)
			{
				$params = JUDownloadHelper::getParams($this->doc->cat_id);
			}
			else
			{
				$params = JUDownloadHelper::getParams(null, $this->doc_id);
			}

			
			$show_empty_field = $params->get('show_empty_field', 0);
			if ($this->doc_id && !$show_empty_field)
			{
				$field_value = $this->value;

				if (is_null($field_value))
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}

				if (is_string($field_value) && trim($field_value) === '')
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}

				if (is_array($field_value) && count($field_value) == 0)
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
			}

			$user = JFactory::getUser();
			if ($user)
			{
				$viewLevels    = JAccess::getAuthorisedViewLevels($user->id);
				$fieldGroupObj = JUDownloadFrontHelperField::getFieldGroupById($this->group_id);
				
				if (!in_array($fieldGroupObj->access, $viewLevels))
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
				else
				{
					if (in_array($this->access, $viewLevels))
					{
						self::$cache[$storeId] = true;

						return self::$cache[$storeId];
					}
					else
					{
						
						if ($this->doc_id && $this->who_can_download_can_access)
						{
							$canDownloadDocument = JUDownloadFrontHelperPermission::canDownloadDocument((int) $this->doc_id, true);

							return $canDownloadDocument;
						}
					}
				}
			}

			self::$cache[$storeId] = false;

			return self::$cache[$storeId];
		}

		return self::$cache[$storeId];
	}
Пример #6
0
	$additionFields[] = 'license_id';
	$additionFields[] = 'confirm_license';
}

$specialFields = JUDownloadFrontHelperField::getFields($this->item, null, array("created", "title", "version", "featured", "downloads"), array(), $additionFields);
?>

<tr class="<?php echo $item_class; ?>">
<?php
if ($this->params->get('allow_zip_file', 1) && $this->params->get('allow_download_multi_docs', 0))
{ ?>
	<td class="id">
		<?php
		if ($this->item->total_files > 0 || (isset($specialFields['external_link']) && !empty($specialFields['external_link'])))
		{
			$canDownloadDocument = JUDownloadFrontHelperPermission::canDownloadDocument($this->item->id, false);
			if (!$canDownloadDocument)
			{ ?>
				<input type="checkbox" name="doc_id[]" class="judl-cb-disabled" disabled
				       value="<?php echo $this->item->id; ?>" id="cb<?php echo $this->index; ?>"/>
			<?php
			}
			else
			{
				if ($this->item->params->get('valid-password'))
				{ ?>
					<input type="checkbox" checked="checked" name="doc_id[]" class="judl-cb"
					       value="<?php echo $this->item->id; ?>" id="cb<?php echo $this->index; ?>"/>
				<?php
				}
				else