function getTemplatedetails() { $app = JFactory::getApplication (); $tBaseDir = JPath::clean(KPATH_SITE.'/template'); $template = $app->getUserState ( 'kunena.edit.template'); $details = KunenaTemplateHelper::parseXmlFile($tBaseDir, $template); return $details; }
function getTemplatedetails() { $template = $this->app->getUserState('kunena.edit.template'); $details = KunenaTemplateHelper::parseXmlFile($template); if (empty($template)) { $template = $this->getState('template'); $details = KunenaTemplateHelper::parseXmlFile($template); } return $details; }
<th><?php echo JText::_( 'COM_KUNENA_A_TEMPLATE_MANAGER_AUTHOR_URL' ); ?></th> </tr> </thead> <tfoot> <tr> <td colspan="7"> <?php echo KunenaLayout::factory('pagination/footer')->set('pagination', $this->pagination); ?> </td> </tr> </tfoot> <tbody> <?php $k = 0; $i = 0; foreach ( $this->templates as $id => $row) { if (KunenaTemplateHelper::templateCanBeUsed($row->name)): ?> <tr <?php echo 'class = "row' . $k . '"'; ?>> <td> <input type="radio" id="cb<?php echo $this->escape($row->directory);?>" name="cid[]" value="<?php echo $this->escape($row->directory); ?>" onclick="isChecked(this.checked);" /> </td> <td><?php $img_path = JUri::root(true).'/components/com_kunena/template/'.$row->directory.'/images/template_thumbnail.png'; ?> <span class="editlinktip hasTip" title="<?php echo $this->escape($row->name . '::<img border="1" src="' . $this->escape($img_path) . '" name="imagelib" alt="' . JText::_( 'COM_KUNENA_A_TEMPLATE_MANAGER_NO_PREVIEW' ) . '" width="200" height="145" />'); ?> "> <a href="#edit" onclick="return listItemTask('cb<?php echo $this->escape($row->directory); ?>','edit')"><?php echo $this->escape($row->name);?></a> </span> </td> <td class="center"> <?php if ($row->published == 1) { ?> <img src="<?php echo JUri::base(true); ?>/components/com_kunena/media/icons/small/default.png" alt="<?php echo JText::_( 'COM_KUNENA_A_TEMPLATE_MANAGER_DEFAULT' ); ?>" /> <?php } else { ?> <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo urlencode($row->directory);?>','publish')">
function uninstall() { $app = JFactory::getApplication (); $config = KunenaFactory::getConfig (); jimport ( 'joomla.filesystem.folder' ); $defaultemplate = $config->template; $cid = JRequest::getVar('cid', array(), 'method', 'array'); $id = array_shift($cid); $template = $id; if (! JRequest::checkToken ()) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $app->redirect ( KunenaRoute::_($this->baseurl, false) ); } // Initialize variables $retval = true; if ( !$id ) { $app->enqueueMessage ( JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_NOT_SPECIFIED'), 'error' ); $app->redirect ( KunenaRoute::_($this->baseurl, false) ); } if (KunenaTemplateHelper::isDefault($template) || $id == 'default') { $app->enqueueMessage ( JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL_CANNOT_DEFAULT', $id), 'error' ); $app->redirect ( KunenaRoute::_($this->baseurl, false) ); return; } $tpl = KPATH_SITE . '/template/'.$template; // Delete the template directory if (JFolder::exists($tpl)) { $retval = JFolder::delete($tpl); $app->enqueueMessage ( JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL_SUCCESS', $id) ); } else { JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE').' '.JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL').': '.JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_DIR_NOT_EXIST')); $retval = false; } $app->redirect ( KunenaRoute::_($this->baseurl, false) ); }
/** * */ function uninstall() { $cid = $this->app->input->get('cid', array(), 'method', 'array'); $id = array_shift($cid); $template = $id; if (!JSession::checkToken('post')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirect(KunenaRoute::_($this->baseurl, false)); return; } // Initialize variables $otemplate = KunenaTemplateHelper::parseXmlFile($id); if (!$otemplate) { $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_NOT_SPECIFIED'), 'error'); $this->setRedirect(KunenaRoute::_($this->baseurl, false)); return; } if (in_array($id, $this->locked)) { $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CTRL_TEMPLATES_ERROR_UNINSTALL_SYSTEM_TEMPLATE', $otemplate->name), 'error'); $this->setRedirect(KunenaRoute::_($this->baseurl, false)); return; } if (KunenaTemplateHelper::isDefault($template)) { $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CTRL_TEMPLATES_ERROR_UNINSTALL_DEFAULT_TEMPLATE', $otemplate->name), 'error'); $this->setRedirect(KunenaRoute::_($this->baseurl, false)); return; } $tpl = KPATH_SITE . '/template/' . $template; // Delete the template directory if (is_dir($tpl)) { $retval = KunenaFolder::delete($tpl); // Clear all cache, just in case. KunenaCacheHelper::clearAll(); $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL_SUCCESS', $id)); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ' ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_DIR_NOT_EXIST')); $retval = false; } $this->setRedirect(KunenaRoute::_($this->baseurl, false)); }
public function post() { $this->id = JRequest::getInt('parentid', 0); $fields = array('catid' => $this->catid, 'name' => JRequest::getString('authorname', $this->me->getName()), 'email' => JRequest::getString('email', null), 'subject' => JRequest::getVar('subject', null, 'POST', 'string', JREQUEST_ALLOWRAW), 'message' => JRequest::getVar('message', null, 'POST', 'string', JREQUEST_ALLOWRAW), 'icon_id' => JRequest::getInt('topic_emoticon', null), 'anonymous' => JRequest::getInt('anonymous', 0), 'poll_title' => JRequest::getString('poll_title', ''), 'poll_options' => JRequest::getVar('polloptionsID', array(), 'post', 'array'), 'poll_time_to_live' => JRequest::getString('poll_time_to_live', 0), 'tags' => JRequest::getString('tags', null), 'mytags' => JRequest::getString('mytags', null), 'subscribe' => JRequest::getInt('subscribeMe', 0)); $this->app->setUserState('com_kunena.postfields', $fields); if (!JSession::checkToken('post')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $template = KunenaFactory::getTemplate(); // Load language file from the template. $template->loadLanguage(); if (!$this->id) { // Create topic $category = KunenaForumCategoryHelper::get($this->catid); if (!$category->authorise('topic.create')) { $this->app->enqueueMessage($category->getError(), 'notice'); $this->setRedirectBack(); return; } list($topic, $message) = $category->newTopic($fields); } else { // Reply topic $parent = KunenaForumMessageHelper::get($this->id); if (!$parent->authorise('reply')) { $this->app->enqueueMessage($parent->getError(), 'notice'); $this->setRedirectBack(); return; } list($topic, $message) = $parent->newReply($fields); $category = $topic->getCategory(); } $templates = KunenaTemplateHelper::parseXmlFiles(); // set dynamic template information foreach ($templates as $tmpl) { if (KunenaTemplateHelper::isDefault($tmpl->directory)) { $template = $tmpl; } } if ($this->me->canDoCaptcha()) { if ($template->kversion >= 4.0) { if (JPluginHelper::isEnabled('captcha')) { $plugin = JPluginHelper::getPlugin('captcha'); $params = new JRegistry($plugin[0]->params); $captcha_pubkey = $params->get('public_key'); $catcha_privkey = $params->get('private_key'); if (!empty($captcha_pubkey) && !empty($catcha_privkey)) { JPluginHelper::importPlugin('captcha'); $dispatcher = JDispatcher::getInstance(); $captcha_response = $this->app->input->getString('g-recaptcha-response'); if (!empty($captcha_response)) { // For ReCaptcha API 2.0 $res = $dispatcher->trigger('onCheckAnswer', $this->app->input->getString('g-recaptcha-response')); } else { // For ReCaptcha API 1.0 $res = $dispatcher->trigger('onCheckAnswer', $this->app->input->getString('recaptcha_response_field')); } if (!$res[0]) { $this->setRedirectBack(); return; } } } } else { $captcha = KunenaSpamRecaptcha::getInstance(); if ($captcha->enabled()) { $success = $captcha->verify(); if (!$success) { $this->app->enqueueMessage($captcha->getError(), 'error'); $this->setRedirectBack(); return; } } } } // Redirect to full reply instead. if (JRequest::getString('fullreply')) { $this->setRedirect(KunenaRoute::_("index.php?option=com_kunena&view=topic&layout=reply&catid={$fields->catid}&id={$parent->getTopic()->id}&mesid={$parent->id}", false)); return; } // Flood protection if ($this->config->floodprotection && !$this->me->isModerator($category)) { $timelimit = JFactory::getDate()->toUnix() - $this->config->floodprotection; $ip = $_SERVER["REMOTE_ADDR"]; $db = JFactory::getDBO(); $db->setQuery("SELECT COUNT(*) FROM #__kunena_messages WHERE ip={$db->Quote($ip)} AND time>{$db->quote($timelimit)}"); $count = $db->loadResult(); if (KunenaError::checkDatabaseError() || $count) { $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_TOPIC_FLOOD', $this->config->floodprotection)); $this->setRedirectBack(); return; } } // Set topic icon if permitted if ($this->config->topicicons && isset($fields['icon_id']) && $topic->authorise('edit', null, false)) { $topic->icon_id = $fields['icon_id']; } // Remove IP address // TODO: Add administrator tool to remove all tracked IP addresses (from the database) if (!$this->config->iptracking) { $message->ip = ''; } // If requested: Make message to be anonymous if ($fields['anonymous'] && $message->getCategory()->allow_anonymous) { $message->makeAnonymous(); } // If configured: Hold posts from guests if (!$this->me->userid && $this->config->hold_guest_posts) { $message->hold = 1; } // If configured: Hold posts from users if ($this->me->userid && !$this->me->isModerator($category) && $this->me->posts < $this->config->hold_newusers_posts) { $message->hold = 1; } // Prevent user abort from this point in order to maintain data integrity. @ignore_user_abort(true); // Mark attachments to be added or deleted. $attachments = JRequest::getVar('attachments', array(), 'post', 'array'); $attachment = JRequest::getVar('attachment', array(), 'post', 'array'); $message->addAttachments(array_keys(array_intersect_key($attachments, $attachment))); $message->removeAttachments(array_keys(array_diff_key($attachments, $attachment))); // Upload new attachments foreach ($_FILES as $key => $file) { $intkey = 0; if (preg_match('/\\D*(\\d+)/', $key, $matches)) { $intkey = (int) $matches[1]; } if ($file['error'] != UPLOAD_ERR_NO_FILE) { $message->uploadAttachment($intkey, $key, $this->catid); } } // Make sure that message has visible content (text, images or objects) to be shown. $text = KunenaHtmlParser::parseBBCode($message->message); if (!preg_match('!(<img |<object |<iframe )!', $text)) { $text = trim(JFilterOutput::cleanText($text)); } if (!$text) { $this->app->enqueueMessage(JText::_('COM_KUNENA_LIB_TABLE_MESSAGES_ERROR_NO_MESSAGE'), 'error'); $this->setRedirectBack(); return; } $maxlinks = $this->checkMaxLinks($text, $topic); if (!$maxlinks) { $this->app->enqueueMessage(JText::_('COM_KUNENA_TOPIC_SPAM_LINK_PROTECTION'), 'error'); $this->setRedirectBack(); return; } // Activity integration $activity = KunenaFactory::getActivityIntegration(); if ($message->hold == 0) { if (!$topic->exists()) { $activity->onBeforePost($message); } else { $activity->onBeforeReply($message); } } // Save message $success = $message->save(); if (!$success) { $this->app->enqueueMessage($message->getError(), 'error'); $this->setRedirectBack(); return; } // Message has been sent, we can now clear saved form $this->app->setUserState('com_kunena.postfields', null); // Display possible warnings (upload failed etc) foreach ($message->getErrors() as $warning) { $this->app->enqueueMessage($warning, 'notice'); } // Create Poll $poll_title = $fields['poll_title']; $poll_options = $fields['poll_options']; if (!empty($poll_options) && !empty($poll_title)) { if ($topic->authorise('poll.create', null, false)) { $poll = $topic->getPoll(); $poll->title = $poll_title; $poll->polltimetolive = $fields['poll_time_to_live']; $poll->setOptions($poll_options); if (!$poll->save()) { $this->app->enqueueMessage($poll->getError(), 'notice'); } else { $topic->poll_id = $poll->id; $topic->save(); $this->app->enqueueMessage(JText::_('COM_KUNENA_POLL_CREATED')); } } else { $this->app->enqueueMessage($topic->getError(), 'notice'); } } // Update Tags $this->updateTags($message->thread, $fields['tags'], $fields['mytags']); $message->sendNotification(); //now try adding any new subscriptions if asked for by the poster $usertopic = $topic->getUserTopic(); if ($fields['subscribe'] && !$usertopic->subscribed) { if ($topic->subscribe(1)) { $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_SUBSCRIBED_TOPIC')); // Activity integration $activity = KunenaFactory::getActivityIntegration(); $activity->onAfterSubscribe($topic, 1); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_NO_SUBSCRIBED_TOPIC') . ' ' . $topic->getError()); } } if ($message->hold == 1) { $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_SUCCES_REVIEW')); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_SUCCESS_POSTED')); } $category = KunenaForumCategoryHelper::get($this->return); if ($message->authorise('read', null, false) && $this->id) { $this->setRedirect($message->getUrl($category, false)); } elseif ($topic->authorise('read', null, false)) { $this->setRedirect($topic->getUrl($category, false)); } else { $this->setRedirect($category->getUrl(null, false)); } }
function uninstall() { jimport('joomla.filesystem.folder'); $cid = JRequest::getVar('cid', array(), 'method', 'array'); $id = array_shift($cid); $template = $id; if (!JRequest::checkToken()) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->app->redirect(KunenaRoute::_($this->baseurl, false)); } // templates to prevent to remove $templates_locked = array('blue_eagle', 'mirage'); $otemplate = KunenaTemplateHelper::parseXmlFile($id); // Initialize variables $retval = true; if (!$otemplate) { $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_NOT_SPECIFIED'), 'error'); $this->app->redirect(KunenaRoute::_($this->baseurl, false)); } if (in_array($id, $templates_locked)) { $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CTRL_TEMPLATES_ERROR_UNINSTALL_SYSTEM_TEMPLATE', $otemplate->name), 'error'); $this->app->redirect(KunenaRoute::_($this->baseurl, false)); } if (KunenaTemplateHelper::isDefault($template)) { $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CTRL_TEMPLATES_ERROR_UNINSTALL_DEFAULT_TEMPLATE', $otemplate->name), 'error'); $this->app->redirect(KunenaRoute::_($this->baseurl, false)); return; } $tpl = KPATH_SITE . '/template/' . $template; // Delete the template directory if (JFolder::exists($tpl)) { $retval = JFolder::delete($tpl); $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL_SUCCESS', $id)); } else { JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ' ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_DIR_NOT_EXIST')); $retval = false; } $this->app->redirect(KunenaRoute::_($this->baseurl, false)); }