/** * Save an existing or a new mood form POST */ public function apply() { CommunityLicenseHelper::_(); JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN')); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $scss = $jinput->post->get('scss', null, 'array'); $settings = $jinput->post->get('settings', null, 'array'); if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=moods', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } if (!is_null($scss)) { CommunityThemeHelper::parseScss($scss, 'general'); } // Handle image uploads $images['frontpage-image'] = $jinput->files->get('frontpage-image-new', '', 'NONE'); foreach ($images as $key => $image) { if (!empty($image['tmp_name']) && isset($image['name']) && !empty($image['name'])) { $imagePath = COMMUNITY_PATH_ASSETS; // same as the image path //check the file extension first and only allow jpg or png $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)); if (!in_array($ext, array('jpg', 'png')) || $image['type'] != 'image/png' && $image['type'] != 'image/jpeg') { } $imageJpg = $imagePath . '/' . $key . '.jpg'; $imagePng = $imagePath . '/' . $key . '.png'; //check if existing image exist, if yes, delete it if (file_exists($imageJpg)) { unlink($imageJpg); } if (file_exists($imagePng)) { unlink($imagePng); } //let move the tmp image to the actual path $finalPath = $imagePath . $key . '.' . $ext; move_uploaded_file($image['tmp_name'], $finalPath); require JPATH_ROOT . "/components/com_community/helpers/image.php"; CImageHelper::resizeProportional($finalPath, $finalPath, "image/{$ext}", 1000, 1000); $settings[$key] = $ext; } } // Parse settings finish CommunityThemeHelper::parseSettings($settings, 'general'); $message = JText::_('COM_COMMUNITY_THEME_GENERAL_UPDATED'); $mainframe->redirect('index.php?option=com_community&view=themegeneral', $message, 'message'); // Get the view type $document = JFactory::getDocument(); $viewType = $document->getType(); // Get the view $viewName = JRequest::getCmd('view', 'community'); $view = $this->getView($viewName, $viewType); $view->setLayout('edit'); $model = $this->getModel($viewName, 'CommunityAdminModel'); if ($model) { $view->setModel($model, $viewName); } $view->display(); }
/** * Save an existing or a new mood form POST */ public function apply() { CommunityLicenseHelper::_(); JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN')); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $scss = $jinput->post->get('scss', null, 'array'); if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=moods', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } if (!is_null($scss)) { CommunityThemeHelper::parseScss($scss, 'colors'); } $message = JText::_('COM_COMMUNITY_THEME_COLORS_UPDATED'); $mainframe->redirect('index.php?option=com_community&view=themecolors', $message, 'message'); }
/** * Save the profile information */ public function apply() { CommunityLicenseHelper::_(); JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN')); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=themegroups', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } // save the config first $configs = $jinput->post->get('config', null, 'array'); $model = $this->getModel('Configuration'); if (!empty($configs)) { $model->save($configs); } // There isn't much that can go wrong, no validation required $message = JText::_('COM_COMMUNITY_THEME_PROFILE_UPDATED'); $mainframe->redirect('index.php?option=com_community&view=themegroups', $message, 'message'); }
<?php /** * @copyright (C) 2013 iJoomla, Inc. - All rights reserved. * @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) * @author iJoomla.com <*****@*****.**> * @url https://www.jomsocial.com/license-agreement * The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 * More info at https://www.jomsocial.com/license-agreement */ // Disallow direct access to this file defined('_JEXEC') or die('Restricted access'); echo CommunityLicenseHelper::disabledHtml(); ?> <style> .container-main { padding-bottom: 0 !important; } </style> <form name="adminForm" id="adminForm" action="index.php?option=com_community" method="POST" enctype="multipart/form-data"> <div class="widget-box"> <div class="widget-header widget-header-flat"> <h5><?php echo JText::_('COM_COMMUNITY_CONFIGURATION_TITLE_PAGE_SETTINGS'); ?> </h5> </div> <div class="widget-body"> <div class="widget-main">
/** * Save the profile information */ public function apply() { CommunityLicenseHelper::_(); JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN')); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=themeprofile', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } $settings = $jinput->post->get('settings', array(), 'array'); $configs = $jinput->post->get('config', null, 'array'); // save the config first $model = $this->getModel('Configuration'); if (!empty($configs)) { $model->save($configs); } // First, parse the Cover Info fields and unset the extra keys $helper = new CommunityThemeHelper(); $settings['tagline'] = $helper->prepareCoverInfo($settings); // Handle image uploads #echo "<pre>";var_dump($post);die(); $images['default-cover'] = $jinput->files->get('default-cover-new', '', 'NONE'); $images['default-cover-male'] = $jinput->files->get('default-cover-male-new', '', 'NONE'); $images['default-cover-female'] = $jinput->files->get('default-cover-female-new', '', 'NONE'); $images['default-male-avatar'] = $jinput->files->get('default-male-avatar-new', '', 'NONE'); $images['default-female-avatar'] = $jinput->files->get('default-female-avatar-new', '', 'NONE'); $images['default-general-avatar'] = $jinput->files->get('default-general-avatar-new', '', 'NONE'); foreach ($images as $key => $image) { if (!empty($image['tmp_name']) && isset($image['name']) && !empty($image['name'])) { try { CImageHelper::autorotate($image['tmp_name']); } catch (Exception $e) { } $imagePath = COMMUNITY_PATH_ASSETS; // same as the image path //check the file extension first and only allow jpg or png $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)); if (!in_array($ext, array('jpg', 'jpeg', 'png')) || $image['type'] != 'image/png' && $image['type'] != 'image/jpeg') { $mainframe->redirect('index.php?option=com_community&view=themeprofile', JText::_('COM_COMMUNITY_THEME_IMAGE_ERROR'), 'error'); } $imageJpg = $imagePath . '/' . $key . '.jpg'; $imagePng = $imagePath . '/' . $key . '.png'; //check if existing image exist, if yes, delete it if (file_exists($imageJpg)) { unlink($imageJpg); } if (file_exists($imagePng)) { unlink($imagePng); } //let move the tmp image to the actual path $finalPath = $imagePath . $key . '.' . $ext; $finalPathThumb = $imagePath . $key . '-thumb.' . $ext; move_uploaded_file($image['tmp_name'], $finalPath); require_once JPATH_ROOT . "/components/com_community/helpers/image.php"; if (strstr($key, 'avatar')) { //avatars // Check 1:1 $size = CImageHelper::getSize($finalPath); if ($size->height != $size->width) { $message = JTEXT::_('COM_COMMUNITY_THEME_AVATAR_RESIZED'); } CImageHelper::resize($finalPath, $finalPath, "image/{$ext}", 160, 160); // thumb CImageHelper::resize($finalPath, $finalPathThumb, "image/{$ext}", 64, 64); } else { // other images CImageHelper::resizeProportional($finalPath, $finalPath, "image/{$ext}", 1000, 1000); } $settings[$key] = $ext; } } // Parse the rest of the settings afterwards $helper->parseSettings($settings, 'profile'); // There isn't much that can go wrong, no validation required if (!$message) { $message = JText::_('COM_COMMUNITY_THEME_PROFILE_UPDATED'); } $mainframe->redirect('index.php?option=com_community&view=themeprofile', $message, 'message'); }
public function store() { CommunityLicenseHelper::_(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=badges', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } $badge = JTable::getInstance('Badges', 'CommunityTable'); $badge->load(JRequest::getInt('badgeid')); $badge->title = $jinput->post->get('title', '', 'STRING'); $badge->published = $jinput->post->get('published', '', 'NONE'); $badge->points = $jinput->post->get('points', '', 'INT'); $isNew = $badge->id < 1; // handle image upload $badgeImage = $jinput->files->get('badge_image', '', 'NONE'); if (!empty($badgeImage['tmp_name']) && isset($badgeImage['name']) && !empty($badgeImage['name'])) { $imagePath = COMMUNITY_PATH_ASSETS; // same as the image path //check the file extension first and only allow jpg or png $ext = strtolower(pathinfo($badgeImage['name'], PATHINFO_EXTENSION)); if (!in_array($ext, array('jpg', 'png')) || $badgeImage['type'] != 'image/png' && $badgeImage['type'] != 'image/jpeg') { $mainframe->redirect('index.php?option=com_community&view=badges&layout=edit&id=' . $badge->id, JText::_('COM_COMMUNITY_BADGES_PARAMETERS_SAVE_ERROR'), 'error'); } else { $badge->image = $ext; $badge->store(); } $finalPath = COMMUNITY_PATH_ASSETS . "badge_" . $badge->id . ".{$ext}"; //check if existing image exist, if yes, delete it if (file_exists($finalPath)) { unlink($finalPath); } //let move the tmp image to the actual path move_uploaded_file($badgeImage['tmp_name'], $finalPath); $imgHeight = imagesx($finalPath); $imgWidth = imagesy($finalPath); if ($imgHeight >= 256 && $imgWidth >= 256) { //only resize if the width or height is larger require JPATH_ROOT . "/components/com_community/helpers/image.php"; CImageHelper::resizeProportional($finalPath, $finalPath, "image/{$ext}", 256, 256); } } $badge->store(); $badge->message = $isNew ? JText::_('COM_COMMUNITY_BADGES_CREATED') : JText::_('COM_COMMUNITY_BADGES_UPDATED'); return $badge; }
public function store() { CommunityLicenseHelper::_(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=moods', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } $mood = JTable::getInstance('Moods', 'CommunityTable'); $mood->load(JRequest::getInt('moodid')); $mood->title = $jinput->post->get('title', '', 'STRING'); $mood->published = $jinput->post->get('published', '', 'NONE'); $mood->description = $jinput->post->get('description', '', 'STRING'); $mood->custom = 1; $isNew = $mood->id < 1; // handle image upload $moodImage = $jinput->files->get('mood_image', '', 'NONE'); if (!empty($moodImage['tmp_name']) && isset($moodImage['name']) && !empty($moodImage['name'])) { $imagePath = COMMUNITY_PATH_ASSETS; // same as the image path //check the file extension first and only allow jpg or png $ext = strtolower(pathinfo($moodImage['name'], PATHINFO_EXTENSION)); if (!in_array($ext, array('jpg', 'png')) || $moodImage['type'] != 'image/png' && $moodImage['type'] != 'image/jpeg') { $mainframe->redirect('index.php?option=com_community&view=moods&layout=edit&id=' . $element, JText::_('COM_COMMUNITY_MOODS_ERROR_IMAGE_TYPE'), 'error'); } else { $mood->image = $ext; $mood->store(); } //check if existing image exist, if yes, delete it $finalPath = $imagePath . '/mood_' . $mood->id . "." . $ext; if (file_exists($finalPath)) { unlink($finalPath); } //let move the tmp image to the actual path move_uploaded_file($moodImage['tmp_name'], $finalPath); require JPATH_ROOT . "/components/com_community/helpers/image.php"; CImageHelper::resizeProportional($finalPath, $finalPath, "image/{$ext}", 35, 35); } $mood->store(); $mood->message = $isNew ? JText::_('COM_COMMUNITY_MOODS_CREATED') : JText::_('COM_COMMUNITY_MOODS_UPDATED'); return $mood; }