Ejemplo n.º 1
0
 /**
  * Imports events from a ics file
  *
  * @throws  Exception
  *
  * @return  void
  */
 public function importics()
 {
     $input = JFactory::getApplication()->input;
     // Let's start uploading the file
     $file = JRequest::getVar('ics_file', null, 'files', 'array');
     $catid = $input->getInt("caid", 0);
     if (empty($file)) {
         throw new Exception("COM_MATUKIO_NO_FILE");
     }
     if (empty($catid)) {
         throw new Exception("COM_MATUKIO_PLEASE_SELECT_A_CATEGORY");
     }
     jimport('joomla.filesystem.file');
     $count = 0;
     if (!strtolower(JFile::getExt($file['name'])) == 'ics') {
         throw new Exception("COM_MATUKIO_NO_ICS_FILE");
     }
     $ar = $this->icsToArray($file['tmp_name']);
     var_dump($ar);
     $user_id = JFactory::getUser()->id;
     // Go through the events saved in the file
     foreach ($ar as $e) {
         if ($e['BEGIN'] == 'VEVENT') {
             $new = MatukioHelperUtilsEvents::getEventEditTemplate();
             // Our real events
             $new->publisher = $user_id;
             $new->title = $e['SUMMARY'];
             $new->shortdesc = $e['SUMMARY'];
             $new->place = $e['LOCATION'];
             $new->description = $e['DESCRIPTION'];
             $new->begin = date("Y-m-d H:i:s", strtotime($e['DTSTART']));
             $new->end = date("Y-m-d H:i:s", strtotime($e['DTEND']));
             $new->booked = $new->begin;
             $new->catid = $catid;
             $new->updated = date("Y-m-d H:i:s");
             $new->publishdate = date("Y-m-d H:i:s");
             // Save new event
             $tab = JTable::getInstance('Matukio', 'Table');
             if (!$tab->bind($new)) {
                 throw new Exception($tab->getError(), 42);
             }
             if (!$tab->check()) {
                 throw new Exception($tab->getError(), 42);
             }
             if (!$tab->store()) {
                 throw new Exception($tab->getError(), 42);
             }
             $tab->checkin();
             // Save date in rec dates
             MatukioHelperRecurring::saveRecurringDateForEvent($tab);
             $count++;
         }
     }
     $msg = JText::_("COM_MATUKIO_ICS_IMPORT_SUCCESSFULLY") . " " . $count;
     $link = 'index.php?option=com_matukio&view=import';
     $this->setRedirect($link, $msg);
 }
Ejemplo n.º 2
0
 /**
  * Gets the event if any out of the database
  *
  * @return mixed
  */
 public function getEvent()
 {
     $event_id = JFactory::getApplication()->input->getInt("id", 0);
     $event = MatukioHelperUtilsEvents::getEventEditTemplate($event_id);
     return $event;
 }
Ejemplo n.º 3
0
 /**
  * Displays the form
  *
  * @param   string  $tpl  - The template
  *
  * @return  mixed|object
  */
 public function display($tpl = null)
 {
     $my = JFactory::getuser();
     $dateid = JFactory::getApplication()->input->getInt('dateid', 1);
     $catid = JFactory::getApplication()->input->getInt('catid', 0);
     $params = JComponentHelper::getParams('com_matukio');
     $menuitemid = JFactory::getApplication()->input->get('Itemid');
     if ($menuitemid) {
         $site = new JSite();
         $menu = $site->getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     if (empty($catid)) {
         $catid = $params->get('catid', 0);
     }
     $search = JFactory::getApplication()->input->get('search', '', 'string');
     $limit = JFactory::getApplication()->input->getInt('limit', 5);
     $limitstart = JFactory::getApplication()->input->getInt('limitstart', 0);
     $vorlage = JFactory::getApplication()->input->getInt('vorlage', 0);
     $cid = JFactory::getApplication()->input->getInt('cid', 0);
     if (empty($cid)) {
         // Access check for creating new event
         if (!JFactory::getUser()->authorise('core.create', 'com_matukio')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } else {
         // Access check for editing this event
         if (!JFactory::getUser()->authorise('core.edit.own', 'com_matukio')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     $row = null;
     // Load event
     $row = MatukioHelperUtilsEvents::getEventEditTemplate($cid);
     // Ist es eine Vorlage
     if ($vorlage > 0) {
         $row->id = "";
         $row->pattern = "";
     }
     if ($cid < 1) {
         $row->publisher = $my->id;
         $row->semnum = MatukioHelperUtilsEvents::createNewEventNumber(date('Y'));
     }
     $row->vorlage = $vorlage;
     // New Event
     if (empty($row->begin) || $row->begin == "0000-00-00 00:00:00") {
         $row->begin = date("Y-m-d 14:00:00");
         $row->end = date("Y-m-d 17:00:00");
         $row->booked = date("Y-m-d 12:00:00");
     }
     $zeit = explode(" ", $row->begin);
     $row->begin_date = $zeit[0];
     $zeit = explode(":", $zeit[1]);
     $row->begin_hour = $zeit[0];
     $row->begin_minute = $zeit[1];
     $zeit = explode(" ", $row->end);
     $row->end_date = $zeit[0];
     $zeit = explode(":", $zeit[1]);
     $row->end_hour = $zeit[0];
     $row->end_minute = $zeit[1];
     $zeit = explode(" ", $row->booked);
     $row->booked_date = $zeit[0];
     $zeit = explode(":", $zeit[1]);
     $row->booked_hour = $zeit[0];
     $row->booked_minute = $zeit[1];
     // MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_MY_OFFERS'), "index.php?option=com_matukio&view=myevents");
     if ($cid) {
         MatukioHelperUtilsBasic::expandPathway($row->title, "");
     } else {
         MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_NEW_EVENT'), "");
     }
     $this->event = $row;
     $this->search = $search;
     $this->catid = $catid;
     $this->limit = $limit;
     $this->limitstart = $limitstart;
     $this->dateid = $dateid;
     parent::display($tpl);
 }
 /**
  * Cert user
  *
  * @throws  Exception - if access is denied!
  * @return  void
  */
 public function certificateUser()
 {
     if (!JFactory::getUser()->authorise('core.edit.own', 'com_matukio')) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     $msg = JTEXT::_("COM_MATUKIO_SEND_USER_CERTIFICATE");
     $database = JFactory::getDBO();
     $cid = JFactory::getApplication()->input->getInt('cid', 0);
     $uid = JFactory::getApplication()->input->getInt('uid', 0);
     $database->setQuery("SELECT * FROM #__matukio_bookings WHERE id='" . $uid . "'");
     $row = $database->loadObject();
     if ($row->certificated == 0) {
         $cert = 1;
         $certmail = 6;
     } else {
         $cert = 0;
         $certmail = 7;
     }
     $database->setQuery("UPDATE #__matukio_bookings SET certificated = " . $database->quote($cert) . " WHERE id='" . $uid . "'");
     if (!$database->execute()) {
         throw new Exception($database->getError(), 500);
     }
     $event = MatukioHelperUtilsEvents::getEventEditTemplate($row->semid);
     MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $uid, $certmail);
     $link = JRoute::_('index.php?option=com_matukio&view=participants&art=2&cid=' . $cid);
     $this->setRedirect($link, $msg);
 }