コード例 #1
0
ファイル: events.php プロジェクト: Simarpreet05/joomla
 public function saveImport()
 {
     $mainframe = JFactory::getApplication();
     $events = JRequest::getVar('events', '');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     if (!empty($events)) {
         $errors = array();
         foreach ($events as $index) {
             $event =& JTable::getInstance('Event', 'CTable');
             $event->title = JRequest::getString('event-' . $index . '-title', '');
             $event->startdate = JRequest::getString('event-' . $index . '-startdate', '');
             $event->enddate = JRequest::getString('event-' . $index . '-enddate', '');
             $event->offset = JRequest::getString('event-' . $index . '-offset', '0');
             $event->description = JRequest::getString('event-' . $index . '-description', '');
             $event->catid = JRequest::getString('event-' . $index . '-catid', '');
             $event->location = JRequest::getString('event-' . $index . '-location', '');
             $event->allowinvite = JRequest::getInt('event-' . $index . '-invite');
             $event->creator = $my->id;
             $event->summary = JRequest::getString('event-' . $index . '-summary', '');
             $event->ticket = JRequest::getInt('event-' . $index . '-ticket', 0);
             $error = array();
             if (empty($event->title)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_TITLE_ERROR');
             }
             if (empty($event->startdate)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_START_DATE_ERROR');
             } else {
                 $event->startdate = CTimeHelper::getFormattedUTC($event->startdate, $event->offset);
             }
             if (empty($event->enddate)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_END_DATE_ERROR');
             } else {
                 $event->enddate = CTimeHelper::getFormattedUTC($event->enddate, $event->offset);
             }
             if (empty($event->catid)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_CATEGORY_ERROR');
             }
             if (!empty($error)) {
                 $errors[] = $error;
             }
             //@rule: If event moderation is enabled, event should be unpublished by default
             $event->published = $config->get('event_moderation') ? 0 : 1;
             $event->created = JFactory::getDate()->toMySQL();
             // @rule: Only store event when no errors.
             if (empty($error)) {
                 $event->store();
                 // Since this is storing event, we also need to store the creator / admin
                 // into the events members table
                 $member = JTable::getInstance('EventMembers', 'CTable');
                 $member->eventid = $event->id;
                 $member->memberid = $event->creator;
                 $member->created = JFactory::getDate()->toMySQL();
                 // Creator should always be 1 as approved as they are the creator.
                 $member->status = COMMUNITY_EVENT_STATUS_ATTEND;
                 // @todo: Setup required permissions in the future
                 $member->permission = '1';
                 $member->store();
                 // Increment the member count.
                 $event->updateGuestStats();
                 // Apparently the updateGuestStats does not store the item. Need to store it again.
                 $event->store();
             }
         }
         if (!empty($errors)) {
             foreach ($errors as $err) {
                 $errorMessage .= implode(',', $err) . "\n";
             }
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=events&task=import', false), $errorMessage, 'error');
         } else {
             $message = $config->get('event_moderation') ? JText::_('COM_COMMUNITY_EVENTS_IMPORT_SUCCESS_MODERATED') : JText::_('COM_COMMUNITY_EVENTS_IMPORT_SUCCESS');
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=events&task=import', false), $message);
         }
     } else {
         $mainframe->redirect(CRoute::_('index.php?option=com_community&view=events&task=import', false), JText::_('COM_COMMUNITY_EVENTS_NOT_SELECTED'), 'error');
     }
 }
コード例 #2
0
                            <span><?php 
        echo JText::_('COM_COMMUNITY_EVENTS_START_TIME');
        ?>
</span>
                            <?php 
        echo CTimeHelper::getFormattedUTC($event->getStartDate(), $offsetValue);
        ?>
                        </div>

                        <div class="joms-form__group">
                            <span><?php 
        echo JText::_('COM_COMMUNITY_EVENTS_END_TIME');
        ?>
</span>
                            <?php 
        echo CTimeHelper::getFormattedUTC($event->getEndDate(), $offsetValue);
        ?>
                        </div>

                        <div class="joms-form__group">
                            <span><?php 
        echo JText::_('COM_COMMUNITY_TIMEZONE');
        ?>
</span>
                            <?php 
        $time = new DateTime('now', new DateTimeZone($offset));
        $time = (int) $time->format('P');
        ?>

                            <input class="joms-input" name="event-<?php 
        echo $i;
コード例 #3
0
ファイル: events.php プロジェクト: joshjim27/jobsglobal
 public function saveImport()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $events = $jinput->get('events', '', 'NONE');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $groupId = $jinput->get->get('groupid', 0, 'Int');
     $groupLink = $groupId > 0 ? '&groupid=' . $groupId : '';
     if (!empty($events)) {
         $errors = array();
         foreach ($events as $index) {
             $event = JTable::getInstance('Event', 'CTable');
             $event->title = $jinput->get('event-' . $index . '-title', '', 'String');
             $event->startdate = $jinput->get('event-' . $index . '-startdate', '', 'String');
             $event->enddate = $jinput->get('event-' . $index . '-enddate', '', 'String');
             $event->offset = $jinput->get('event-' . $index . '-offset', '0', 'String');
             $event->description = $jinput->get('event-' . $index . '-description', '', 'String');
             $event->catid = $jinput->get('event-' . $index . '-catid', '', 'String');
             $event->location = $jinput->get('event-' . $index . '-location', '', 'String');
             $event->allowinvite = $jinput->get('event-' . $index . '-invite', 'String');
             $event->creator = $my->id;
             $event->summary = $jinput->get('event-' . $index . '-summary', '', 'String');
             $event->ticket = $jinput->get('event-' . $index . '-ticket', 0, 'Int');
             $event->repeat = $jinput->get('event-' . $index . '-repeat', 0, 'String');
             $event->repeatend = $jinput->get('event-' . $index . '-repeatend', 'String');
             $postData['limit'] = $jinput->get('event-' . $index . '-limit', 0, 'Int');
             $error = array();
             $handler = CEventHelper::getHandler($event);
             $event->contentid = $handler->getContentId();
             $event->type = $handler->getType();
             if (empty($event->title)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_TITLE_ERROR');
             }
             if (empty($event->startdate)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_START_DATE_ERROR');
             } else {
                 $event->startdate = CTimeHelper::getFormattedUTC($event->startdate, $event->offset);
             }
             if (empty($event->enddate)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_END_DATE_ERROR');
             } else {
                 $event->enddate = CTimeHelper::getFormattedUTC($event->enddate, $event->offset);
             }
             if (empty($event->catid)) {
                 $error[] = JText::_('COM_COMMUNITY_EVENTS_CATEGORY_ERROR');
             }
             $eventChild = array();
             // check event recurrence limit.
             if (!empty($event->repeat)) {
                 $repeatLimit = 'COMMUNITY_EVENT_RECURRING_LIMIT_' . strtoupper($event->repeat);
                 if (defined($repeatLimit)) {
                     $eventChild = $this->_generateRepeatList($event, $postData);
                     if (count($eventChild) > constant($repeatLimit)) {
                         $error[] = $event->title . ' - ' . sprintf(JText::_('COM_COMMUNITY_EVENTS_REPEAT_LIMIT_ERROR'), constant($repeatLimit));
                     }
                 }
             }
             if (!empty($error)) {
                 $errors[] = $error;
             }
             //@rule: If event moderation is enabled, event should be unpublished by default
             $event->published = $this->isPublished();
             $event->created = JFactory::getDate()->toSql();
             // @rule: Only store event when no errors.
             if (empty($error)) {
                 $event->store();
                 // Save event member
                 if (!$event->isRecurring()) {
                     $this->_saveMember($event);
                     // Increment the member count.
                     $event->updateGuestStats();
                     // Apparently the updateGuestStats does not store the item. Need to store it again.
                     $event->store();
                 } else {
                     $event->parent = $event->id;
                 }
                 // Save recurring event's child.
                 $this->_saveRepeatChild($event, $eventChild, true, $postData);
                 // Create event activity stream.
                 $this->_addActivityStream($event);
                 //add notification: New group event is added
                 $this->_addGroupNotification($event);
             }
         }
         if (!empty($errors)) {
             foreach ($errors as $err) {
                 $errorMessage .= implode(',', $err) . "\n";
             }
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=events&task=import' . $groupLink, false), $errorMessage, 'error');
         } else {
             $message = !$event->isPublished() ? JText::_('COM_COMMUNITY_EVENTS_IMPORT_SUCCESS_MODERATED') : JText::_('COM_COMMUNITY_EVENTS_IMPORT_SUCCESS');
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=events&task=import' . $groupLink, false), $message);
         }
     } else {
         $mainframe->redirect(CRoute::_('index.php?option=com_community&view=events&task=import' . $groupLink, false), JText::_('COM_COMMUNITY_EVENTS_NOT_SELECTED'), 'error');
     }
 }