public function checkin($pks = array()) { $pks = (array) $pks; $table = $this->getTable(); $count = 0; if (empty($pks)) { $pks = array((int) $this->getState($this->getName() . '.id')); } foreach ($pks as $pk) { if ($table->load($pk)) { if ($table->checked_out > 0) { if (JUDownloadFrontHelperPermission::canCheckInComment($pk)) { if (!$table->checkin($pk)) { $this->setError($table->getError()); return false; } $count++; } else { $this->setError(JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_CHECK_IN_COMMENT')); return false; } } } else { $this->setError($table->getError()); return false; } } return $count; }
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']; } }