Skip to content

Commit

Permalink
Update for add entry group rights and more
Browse files Browse the repository at this point in the history
  • Loading branch information
kveldscholten committed Apr 4, 2017
1 parent da03188 commit 14055fe
Show file tree
Hide file tree
Showing 21 changed files with 533 additions and 514 deletions.
114 changes: 59 additions & 55 deletions application/modules/events/config/config.php
Expand Up @@ -6,6 +6,8 @@

namespace Modules\Events\Config;

use\Ilch\Config\Database as IlchDatabase;

class Config extends \Ilch\Config\Install
{
public $config = [
Expand Down Expand Up @@ -42,33 +44,35 @@ public function install()
{
$this->db()->queryMulti($this->getInstallSql());

$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig->set('event_boxEventLimit', '5');
$databaseConfig->set('event_uploadpath', 'application/modules/events/static/upload/image/');
$databaseConfig->set('event_height', '150');
$databaseConfig->set('event_width', '450');
$databaseConfig->set('event_size', '102400');
$databaseConfig->set('event_filetypes', 'jpg jpeg png gif');
$databaseConfig->set('event_google_maps_api_key', '');
$databaseConfig->set('event_google_maps_map_typ', 'ROADMAP');
$databaseConfig->set('event_google_maps_zoom', '18');
$databaseConfig = new IlchDatabase($this->db());
$databaseConfig->set('event_add_entries_accesses', '2')
->set('event_box_event_limit', '5')
->set('event_uploadpath', 'application/modules/events/static/upload/image/')
->set('event_height', '150')
->set('event_width', '450')
->set('event_size', '102400')
->set('event_filetypes', 'jpg jpeg png gif')
->set('event_google_maps_api_key', '')
->set('event_google_maps_map_typ', 'ROADMAP')
->set('event_google_maps_zoom', '18');
}

public function uninstall()
{
$this->db()->queryMulti('DROP TABLE `[prefix]_events`;
DROP TABLE `[prefix]_events_entrants`;
DROP TABLE `[prefix]_events_currencies`');
$this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'event_boxEventLimit';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_uploadpath';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_height';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_width';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_size';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_filetypes';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_google_maps_api_key';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_google_maps_map_typ';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_google_maps_zoom';
DELETE FROM `[prefix]_modules_folderrights` WHERE `key` = 'events';");
DROP TABLE `[prefix]_events_entrants`;
DROP TABLE `[prefix]_events_currencies`');
$this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'event_add_entries_accesses';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_box_event_limit';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_uploadpath';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_height';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_width';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_size';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_filetypes';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_google_maps_api_key';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_google_maps_map_typ';
DELETE FROM `[prefix]_config` WHERE `key` = 'event_google_maps_zoom';
DELETE FROM `[prefix]_modules_folderrights` WHERE `key` = 'events';");

if ($this->db()->ifTableExists('[prefix]_calendar_events')) {
$this->db()->queryMulti("DELETE FROM `[prefix]_calendar_events` WHERE `url` = 'events/events/index/';");
Expand All @@ -77,43 +81,43 @@ public function uninstall()

public function getInstallSql()
{
$installSql = 'CREATE TABLE IF NOT EXISTS `[prefix]_events` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`user_id` INT(11) NOT NULL,
`start` DATETIME NOT NULL,
`end` DATETIME NOT NULL,
`title` VARCHAR(100) NOT NULL,
`place` VARCHAR(150) NOT NULL,
`lat_long` VARCHAR(100) NULL DEFAULT NULL,
`image` VARCHAR(255) NULL DEFAULT NULL,
`text` LONGTEXT NOT NULL,
`currency` TINYINT(1) NOT NULL,
`price` VARCHAR(255) NOT NULL,
`price_art` TINYINT(1) NOT NULL,
`show` TINYINT(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
$installSql = 'CREATE TABLE IF NOT EXISTS `[prefix]_events` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`user_id` INT(11) NOT NULL,
`start` DATETIME NOT NULL,
`end` DATETIME NOT NULL,
`title` VARCHAR(100) NOT NULL,
`place` VARCHAR(150) NOT NULL,
`lat_long` VARCHAR(100) NULL DEFAULT NULL,
`image` VARCHAR(255) NULL DEFAULT NULL,
`text` LONGTEXT NOT NULL,
`currency` TINYINT(1) NOT NULL,
`price` VARCHAR(255) NOT NULL,
`price_art` TINYINT(1) NOT NULL,
`show` TINYINT(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `[prefix]_events_entrants` (
`event_id` INT(11) NOT NULL,
`user_id` INT(11) NOT NULL,
`status` TINYINT(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `[prefix]_events_entrants` (
`event_id` INT(11) NOT NULL,
`user_id` INT(11) NOT NULL,
`status` TINYINT(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `[prefix]_events_currencies` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `[prefix]_events_currencies` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (1, "EUR (€)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (2, "USD ($)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (3, "GBP (£)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (4, "AUD ($)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (5, "NZD ($)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (6, "CHF");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (1, "EUR (€)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (2, "USD ($)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (3, "GBP (£)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (4, "AUD ($)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (5, "NZD ($)");
INSERT INTO `[prefix]_events_currencies` (`id`, `name`) VALUES (6, "CHF");
INSERT INTO `[prefix]_modules_folderrights` (`key`, `folder`) VALUES ("events", "static/upload/image");';
INSERT INTO `[prefix]_modules_folderrights` (`key`, `folder`) VALUES ("events", "static/upload/image");';

if ($this->db()->ifTableExists('[prefix]_calendar_events')) {
return $installSql.'INSERT INTO `[prefix]_calendar_events` (`url`) VALUES ("events/events/index/");';
Expand Down
53 changes: 27 additions & 26 deletions application/modules/events/controllers/Index.php
Expand Up @@ -23,17 +23,17 @@ public function indexAction()
$this->getLayout()->getTitle()
->add($this->getTranslator()->trans('menuEvents'));
$this->getLayout()->getHmenu()
->add($this->getTranslator()->trans('menuEvents'), ['controller' => 'index']);
->add($this->getTranslator()->trans('menuEvents'), ['controller' => 'index']);

$upcomingLimit = 5;
$otherLimit = 5;
$pastLimit = 5;

$this->getView()->set('entrantsMapper', $entrantsMapper);
$this->getView()->set('eventList', $eventMapper->getEntries());
$this->getView()->set('eventListUpcoming', $eventMapper->getEventListUpcoming($upcomingLimit));
$this->getView()->set('getEventListOther', $eventMapper->getEventListOther($otherLimit));
$this->getView()->set('eventListPast', $eventMapper->getEventListPast($pastLimit));
$this->getView()->set('entrantsMapper', $entrantsMapper)
->set('eventList', $eventMapper->getEntries())
->set('eventListUpcoming', $eventMapper->getEventListUpcoming($upcomingLimit))
->set('getEventListOther', $eventMapper->getEventListOther($otherLimit))
->set('eventListPast', $eventMapper->getEventListPast($pastLimit));
}

public function treatAction()
Expand All @@ -44,22 +44,23 @@ public function treatAction()
$currencyMapper = new CurrencyMapper();

$event = $eventMapper->getEventById($this->getRequest()->getParam('id'));

if ($this->getRequest()->getParam('id')) {
$this->getLayout()->getTitle()
->add($this->getTranslator()->trans('menuEvents'))
->add($event->getTitle())
->add($this->getTranslator()->trans('edit'));
$this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuEvents'), ['action' => 'index'])
->add($event->getTitle(), ['controller' => 'show', 'action' => 'event', 'id' => $event->getId()])
->add($this->getTranslator()->trans('edit'), ['action' => 'treat', 'id' => $event->getId()]);
->add($event->getTitle(), ['controller' => 'show', 'action' => 'event', 'id' => $event->getId()])
->add($this->getTranslator()->trans('edit'), ['action' => 'treat', 'id' => $event->getId()]);

$this->getView()->set('event', $eventMapper->getEventById($this->getRequest()->getParam('id')));
} else {
$this->getLayout()->getTitle()
->add($this->getTranslator()->trans('menuEvents'))
->add($this->getTranslator()->trans('add'));
$this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuEvents'), ['action' => 'index'])
->add($this->getTranslator()->trans('add'), ['action' => 'treat']);
->add($this->getTranslator()->trans('add'), ['action' => 'treat']);
}

$imageAllowedFiletypes = $this->getConfig()->get('event_filetypes');
Expand All @@ -75,7 +76,7 @@ public function treatAction()

Validation::setCustomFieldAliases([
'start' => 'startTime',
'end' => 'endTime'
'end' => 'endTime'
]);

$validation = Validation::create($this->getRequest()->getPost(), [
Expand Down Expand Up @@ -148,15 +149,15 @@ public function treatAction()
}

$eventModel->setUserId($this->getUser()->getId())
->setTitle($this->getRequest()->getPost('title'))
->setStart(new \Ilch\Date($this->getRequest()->getPost('start')))
->setEnd(new \Ilch\Date($this->getRequest()->getPost('end')))
->setPlace($this->getRequest()->getPost('place'))
->setText($this->getRequest()->getPost('text'))
->setCurrency($this->getRequest()->getPost('currency'))
->setPrice($this->getRequest()->getPost('price'))
->setPriceArt($this->getRequest()->getPost('priceArt'))
->setShow($this->getRequest()->getPost('calendarShow'));
->setTitle($this->getRequest()->getPost('title'))
->setStart(new \Ilch\Date($this->getRequest()->getPost('start')))
->setEnd(new \Ilch\Date($this->getRequest()->getPost('end')))
->setPlace($this->getRequest()->getPost('place'))
->setText($this->getRequest()->getPost('text'))
->setCurrency($this->getRequest()->getPost('currency'))
->setPrice($this->getRequest()->getPost('price'))
->setPriceArt($this->getRequest()->getPost('priceArt'))
->setShow($this->getRequest()->getPost('calendarShow'));
$eventMapper->save($eventModel);

if ($this->getRequest()->getPost('image_delete') != '') {
Expand Down Expand Up @@ -189,13 +190,13 @@ public function treatAction()
$this->getView()->set('calendarShow', 1);
}

$this->getView()->set('settingMapper', $settingMapper);
$this->getView()->set('image_height', $imageHeight);
$this->getView()->set('image_width', $imageWidth);
$this->getView()->set('image_size', $imageSize);
$this->getView()->set('image_filetypes', $imageAllowedFiletypes);
$this->getView()->set('currencies', $currencyMapper->getCurrencies());
$this->getView()->set('event_google_maps_api_key', $this->getConfig()->get('event_google_maps_api_key'));
$this->getView()->set('settingMapper', $settingMapper)
->set('image_height', $imageHeight)
->set('image_width', $imageWidth)
->set('image_size', $imageSize)
->set('image_filetypes', $imageAllowedFiletypes)
->set('currencies', $currencyMapper->getCurrencies())
->set('event_google_maps_api_key', $this->getConfig()->get('event_google_maps_api_key'));
}

public function delAction()
Expand Down

0 comments on commit 14055fe

Please sign in to comment.