Skip to content

Commit

Permalink
Merge pull request #641 from Hoffi1/develop
Browse files Browse the repository at this point in the history
lot stuff (recurrence, pkg version check, introtext, overridables)
  • Loading branch information
Hoffi1 committed Apr 3, 2014
2 parents 2015516 + b3c2752 commit 9c544c5
Show file tree
Hide file tree
Showing 52 changed files with 582 additions and 82 deletions.
8 changes: 7 additions & 1 deletion admin/language/en-GB/en-GB.com_jem.ini
Expand Up @@ -142,6 +142,9 @@ COM_JEM_FIELD_CATEGORIES = "Categories <span class='star'>&nbsp;*</span>"
COM_JEM_NEW_EVENT = "Add Event"
COM_JEM_SELECTCONTACT="Select Contact"
COM_JEM_RESET_HITS="Reset Hits"
COM_JEM_EDITEVENT_WARN_RECURRENCE_TITLE="ATTENTION!"
COM_JEM_EDITEVENT_WARN_RECURRENCE_TEXT="This event is part of a set of recurring events. If you save this event it will be removed from this set. Even if you just save it without editing at all.<br>If you choose any recurrence in this event a new set of recurring events will be created."
COM_JEM_EDITEVENT_WARN_RECURRENCE_FIRST_TEXT="This event is the first one of a set of recurring events. If you save this event the set will be dissolved. Even if you just save it without editing at all.<br>If you choose any recurrence in this event a new set of recurring events will be created."

; EVENTS-View
COM_JEM_EVENTS_FEATURED="Featured event"
Expand Down Expand Up @@ -513,6 +516,9 @@ COM_JEM_ERROR_END_BEFORE_START="Event start must begin before end"

;Recurrence
COM_JEM_RECURRING_EVENTS="Repeating Events"
COM_JEM_RECURRING_EVENT="Repeating event"
COM_JEM_RECURRING_EVENT_DESC="This event is part of a set of recurring events."
COM_JEM_RECURRING_FIRST_EVENT_DESC="This event is the first one of a set of recurring events."
COM_JEM_RECURRENCE="Recurrence"
COM_JEM_NOTHING="nothing"
COM_JEM_DAYLY="daily"
Expand Down Expand Up @@ -968,7 +974,7 @@ COM_JEM_ATT_FILTER_ATTENDING="Attending"
COM_JEM_ATT_FILTER_WAITING="Waiting"
COM_JEM_ADD_RECURRENCE="Add Recurrence"
COM_JEM_DATE_FORMAT_DESC="Date Format. For example fill in: D, j. F Y"
COM_JEM_SETTINGS_RECURENCE_LIMITDAYS_DESC="Recurrencelimit in days, the count is from today"
COM_JEM_SETTINGS_RECURENCE_LIMITDAYS_DESC="Recurrence limit in days, the count is from today"
COM_JEM_SETTINGS_SELECTFIRSTWEEKDAY_DESC="Select Firstweekday"
COM_JEM_WIDTH_ATTENDEE_COLUMN_DESC="Width of the Attendee Column"
COM_JEM_COPY_VENUE="Copy Venue"
Expand Down
21 changes: 20 additions & 1 deletion admin/models/event.php
Expand Up @@ -148,12 +148,19 @@ public function getItem($pk = null)
}

if ($item->id){
// Store current recurrence values
$item->recurr_bak = new stdClass;
foreach (get_object_vars($item) as $k => $v) {
if (strncmp('recurrence_', $k, 11) === 0) {
$item->recurr_bak->$k = $v;
}
}

$item->recurrence_type = '';
$item->recurrence_number = '';
$item->recurrence_byday = '';
$item->recurrence_counter = '';
$item->recurrence_first_id = '';
$item->recurrence_type = '';
$item->recurrence_limit = '';
$item->recurrence_limit_date = '';
}
Expand Down Expand Up @@ -260,6 +267,11 @@ public function save($data)
$metakeywords = $jinput->get('meta_keywords', '', '');
$metadescription = $jinput->get('meta_description', '', '');

// event maybe first of recurrence set -> dissolve complete set
if (JemHelper::dissolve_recurrence($data['id'])) {
$this->cleanCache();
}

if ($data['dates'] == null || $data['recurrence_type'] == '0')
{
$data['recurrence_number'] = '';
Expand All @@ -270,6 +282,13 @@ public function save($data)
$data['recurrence_limit_date'] = '';
$data['recurrence_first_id'] = '';
}else{
if ($data['id']) {
// edited event maybe part of a recurrence set
// -> drop event from set
$data['recurrence_first_id'] = '';
$data['recurrence_counter'] = '';
}

$data['recurrence_number'] = $recurrencenumber;
$data['recurrence_byday'] = $recurrencebyday;
}
Expand Down
20 changes: 20 additions & 0 deletions admin/views/event/tmpl/edit.php
Expand Up @@ -180,6 +180,26 @@ function commoff()
action="<?php echo JRoute::_('index.php?option=com_jem&layout=edit&id='.(int) $this->item->id); ?>"
class="form-validate" method="post" name="adminForm" id="event-form" enctype="multipart/form-data">

<?php $recurr = empty($this->item->recurr_bak) ? $this->item : $this->item->recurr_bak; ?>
<?php if (!empty($recurr->recurrence_number) || !empty($recurr->recurrence_type)) : ?>
<div class="description">
<div style="float:left;">
<?php echo JemOutput::recurrenceicon($recurr, false, false); ?>
</div>
<div class="floattext" style="margin-left:36px;">
<strong><?php echo JText::_('COM_JEM_EDITEVENT_WARN_RECURRENCE_TITLE'); ?></strong>
<br>
<?php
if (!empty($recurr->recurrence_type) && empty($recurr->recurrence_first_id)) {
echo nl2br(JText::_('COM_JEM_EDITEVENT_WARN_RECURRENCE_FIRST_TEXT'));
} else {
echo nl2br(JText::_('COM_JEM_EDITEVENT_WARN_RECURRENCE_TEXT'));
}
?>
</div>
</div>
<div class="clear"></div>
<?php endif; ?>

<!-- START OF LEFT DIV -->
<div class="width-55 fltlft">
Expand Down
4 changes: 2 additions & 2 deletions admin/views/events/tmpl/default.php
Expand Up @@ -147,10 +147,10 @@
<td class="eventtitle">
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_jem&task=event.edit&id='.(int) $row->id); ?>">
<?php echo $this->escape($row->title); ?>
<?php echo $this->escape($row->title) . JemOutput::recurrenceicon($row); ?>
</a>
<?php else : ?>
<?php echo $this->escape($row->title); ?>
<?php echo $this->escape($row->title) . JemOutput::recurrenceicon($row); ?>
<?php endif; ?>
<br />
<?php if (JString::strlen($row->alias) > 25) : ?>
Expand Down
15 changes: 15 additions & 0 deletions media/css/backend.css
Expand Up @@ -673,4 +673,19 @@ input#csvexport{
.select_country
{
max-width:210px;
}

/* scale icon to fit text height */
.icon-inline {
height: 1.2em;
margin-left: 0.3em;
}

/* prevent problem with Bluestork */
#recurrence_output select,
select#jform_recurrence_type {
float: none;
}
input#jform_recurrence_limit_date {
margin-left: 0;
}
6 changes: 6 additions & 0 deletions media/css/jem.css
Expand Up @@ -288,6 +288,12 @@ div#jem .flyermodal {
box-shadow:none;
}

/* scale icon to fit text height */
div#jem .icon-inline {
height: 1em;
margin-left: 0.3em;
}

/**
* maps, ...
*/
Expand Down
Binary file added media/images/icon-16-recurrence-first.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/images/icon-16-recurrence.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/images/icon-32-recurrence-first.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/images/icon-32-recurrence.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
175 changes: 175 additions & 0 deletions package/pkg_install.php
@@ -0,0 +1,175 @@
<?php
/**
* JEM Package
* @package JEM.Package
*
* @copyright (C) 2013-2014 joomlaeventmanager.net
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*
* @copyright (C) 2008 - 2013 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.org
**/
defined ( '_JEXEC' ) or die ();

/**
* JEM package installer script.
*/
class Pkg_JemInstallerScript {
/**
* List of supported versions. Newest version first!
* @var array
*/
protected $versions = array(
'PHP' => array (
'5.3' => '5.3.1',
'0' => '5.4.14' // Preferred version
),
'MySQL' => array (
'5.1' => '5.1',
'0' => '5.5' // Preferred version
),
'Joomla!' => array (
'3.0' => '', // Not supported
'2.5' => '2.5.6',
'0' => '2.5.19' // Preferred version
)
);

/**
* List of required PHP extensions.
* @var array
*/
protected $extensions = array ('gd', 'json', 'pcre'
, 'iconv' /* import */
, 'ctype', 'SimpleXML' /* iCalCreator */
, 'sockets', 'curl' /* Snoopy */
);

public function install($parent) {
return true;
}

public function discover_install($parent) {
return self::install($parent);
}

public function update($parent) {
return self::install($parent);
}

public function uninstall($parent) {
return true;
}

public function preflight($type, $parent) {
/** @var JInstallerComponent $parent */
$manifest = $parent->getParent()->getManifest();

// Prevent installation if requirements are not met.
if (!$this->checkRequirements($manifest->version)) return false;

return true;
}

public function makeRoute($uri) {
return JRoute::_($uri, false);
}

public function postflight($type, $parent) {
// Clear Joomla system cache.
/** @var JCache|JCacheController $cache */
$cache = JFactory::getCache();
$cache->clean('_system');

// Remove all compiled files from APC cache.
if (function_exists('apc_clear_cache')) {
@apc_clear_cache();
}

if ($type == 'uninstall') return true;

$this->enablePlugin('content', 'jem');
// $this->enablePlugin('search', 'jem');
// $this->enablePlugin('jem', 'mailer');

return true;
}

function enablePlugin($group, $element) {
$plugin = JTable::getInstance('extension');
if (!$plugin->load(array('type'=>'plugin', 'folder'=>$group, 'element'=>$element))) {
return false;
}
$plugin->enabled = 1;
return $plugin->store();
}

public function checkRequirements($version) {
$db = JFactory::getDbo();
$pass = $this->checkVersion('PHP', phpversion());
$pass &= $this->checkVersion('Joomla!', JVERSION);
$pass &= $this->checkVersion('MySQL', $db->getVersion ());
$pass &= $this->checkDbo($db->name, array('mysql', 'mysqli'));
$pass &= $this->checkExtensions($this->extensions);
$pass &= $this->checkMagicQuotes();
return $pass;
}

// Internal functions

protected function checkVersion($name, $version) {
$app = JFactory::getApplication();

$major = $minor = 0;
foreach ($this->versions[$name] as $major=>$minor) {
if (!$major || version_compare($version, $major, '<')) continue;
if ($minor && version_compare($version, $minor, '>=')) return true;
break;
}
if (!$major) $minor = reset($this->versions[$name]);
$recommended = end($this->versions[$name]);
if ($minor) {
$app->enqueueMessage(sprintf("%s %s is not supported. Minimum required version is %s %s, but it is highly recommended to use %s %s or later.", $name, $version, $name, $minor, $name, $recommended), 'notice');
} else {
$app->enqueueMessage(sprintf("%s %s is not supported. It is highly recommended to use %s %s or later.", $name, $version, $name, $recommended), 'notice');
}
return false;
}

protected function checkDbo($name, $types) {
$app = JFactory::getApplication();

if (in_array($name, $types)) {
return true;
}
$app->enqueueMessage(sprintf("Database driver '%s' is not supported. Please use MySQL instead.", $name), 'notice');
return false;
}

protected function checkExtensions($extensions) {
$app = JFactory::getApplication();

$pass = 1;
foreach ($extensions as $name) {
if (!extension_loaded($name)) {
$pass = 0;
$app->enqueueMessage(sprintf("Required PHP extension '%s' is missing. Please install it into your system.", $name), 'notice');
}
}
return $pass;
}

protected function checkMagicQuotes() {
$app = JFactory::getApplication();

// Abort if Magic Quotes are enabled, it was removed from phpversion 5.4
if (version_compare(phpversion(), '5.4', '<')) {
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$app->enqueueMessage("Magic Quotes are enabled. JEM requires Magic Quotes to be disabled.", 'notice');
return false;
}
}
return true;
}
}
7 changes: 5 additions & 2 deletions package/pkg_jem.xml
Expand Up @@ -2,8 +2,8 @@
<extension type="package" version="2.5" method="upgrade">
<name>pkg_jem</name>
<packagename>jem</packagename>
<creationDate>04 August 2013</creationDate>
<copyright>Copyright (C) 2013-2013 joomlaeventmanager.net</copyright>
<creationDate>March 2014</creationDate>
<copyright>Copyright (C) 2013-2014 joomlaeventmanager.net</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<author>JEM Community</author>
<authorEmail>info@joomlaeventmanager.net</authorEmail>
Expand All @@ -16,6 +16,8 @@
<packagerurl>http://www.joomlaeventmanager.net/</packagerurl>
<!-- <update>http://www.updateurl.com/update</update> -->

<scriptfile>pkg_install.php</scriptfile>

<files folder="packages">
<file type="component" id="com_jem">com_jem.zip</file>

Expand All @@ -24,6 +26,7 @@
<file type="module" id="mod_jem_cal" client="site">mod_jem_cal.zip</file>
<file type="module" id="mod_jem_teaser" client="site">mod_jem_teaser.zip</file>

<file type="plugin" id="jem" group="content">plg_content_jem.zip</file>
<file type="plugin" id="jem" group="search">plg_search_jem.zip</file>
<file type="plugin" id="jem" group="finder">plg_finder_jem.zip</file>
<file type="plugin" id="comments" group="jem">plg_jem_comments.zip</file>
Expand Down
1 change: 1 addition & 0 deletions plugins/plg_content_jem/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
42 changes: 42 additions & 0 deletions plugins/plg_content_jem/jem.php
@@ -0,0 +1,42 @@
<?php
/**
* @version 1.9.6
* @package JEM
* @copyright (C) 2013-2014 joomlaeventmanager.net
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

defined('_JEXEC') or die;

// Required? Normally events are triggered from somewhere within com_jem so helper is already loaded.
//require_once(JPATH_SITE.'/components/com_jem/helpers/helper.php');

/**
* JEM Content Plugin
*
* @package JEM.Plugin
* @subpackage Content.jem
* @since 1.9.6
*/
class plgContentJem extends JPlugin
{
/**
* Dissolve recurrence sets where deleted event is referred to as first.
*
* @param string The context for the content passed to the plugin.
* @param object The data relating to the content that was deleted.
* @since 1.9.6
*/
public function onContentAfterDelete($context, $data)
{
// Skip plugin if we are deleting something other than events
if (($context != 'com_jem.event') || empty($data->id)) {
return;
}

// event maybe first of recurrence set -> dissolve complete set
JemHelper::dissolve_recurrence($data->id);

return;
}
}

0 comments on commit 9c544c5

Please sign in to comment.