Exemple #1
0
 /**
  * Add the page title and toolbar.
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $isNew = $this->item->id == 0;
     if (isset($this->item->checked_out)) {
         $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
     } else {
         $checkedOut = false;
     }
     $canDo = iCagendaHelper::getActions();
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title(JText::_('COM_ICAGENDA_TITLE_MAIL'), 'mail.png');
     } else {
         JToolBarHelper::title('iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_TITLE_MAIL') . '</span>', 'mail');
     }
     $icTitle = JText::_('COM_ICAGENDA_TITLE_MAIL');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::custom('mail', 'forward.png', 'forward.png', 'ICAGENDA_JTOOLBAR_SEND', false);
     } else {
         JToolbarHelper::custom('mail', 'envelope.png', 'send_f2.png', 'ICAGENDA_JTOOLBAR_SEND', false);
     }
     JToolBarHelper::cancel('mail.cancel', 'JTOOLBAR_CLOSE');
 }
Exemple #2
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.0
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/icagenda.php';
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $state = $this->get('State');
     $canDo = iCagendaHelper::getActions($state->get('filter.category_id'));
     //JToolBarHelper::title(JText::_('COM_ICAGENDA_TITLE_ICAGENDA_IMAGE'));
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title(JText::_('COM_ICAGENDA_TITLE_ICAGENDA_IMAGE'));
     } else {
         $logo_icagenda_url = '../media/com_icagenda/images/iconicagenda36.png';
         if (file_exists($logo_icagenda_url)) {
             $logo_icagenda = '<img src="' . $logo_icagenda_url . '" height="36px" alt="iCagenda" />';
         } else {
             $logo_icagenda = 'iCagenda :: ' . JText::_('COM_ICAGENDA_TITLE_ICAGENDA') . '';
         }
         JToolBarHelper::title($logo_icagenda, 'icagenda');
     }
     $icTitle = JText::_('COM_ICAGENDA_TITLE_ICAGENDA');
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
 }
Exemple #3
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.0
  */
 protected function addToolbar()
 {
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JRequest::setVar('hidemainmenu', true);
     } else {
         JFactory::getApplication()->input->set('hidemainmenu', true);
     }
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = iCagendaHelper::getActions();
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title($isNew ? 'iCagenda - ' . JText::_('COM_ICAGENDA_LEGEND_NEW_EVENT') : 'iCagenda - ' . JText::_('COM_ICAGENDA_LEGEND_EDIT_EVENT'), 'event');
     } else {
         JToolBarHelper::title($isNew ? 'iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_LEGEND_NEW_EVENT') . '</span>' : 'iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_LEGEND_EDIT_EVENT') . '</span>', $isNew ? 'new' : 'pencil-2');
     }
     $icTitle = $isNew ? JText::_('COM_ICAGENDA_LEGEND_NEW_EVENT') : JText::_('COM_ICAGENDA_LEGEND_EDIT_EVENT');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
     // Build the actions for new and existing records.
     if ($isNew) {
         // For new records, check the create permission.
         if ($canDo->get('core.create')) {
             JToolBarHelper::apply('event.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('event.save', 'JTOOLBAR_SAVE');
             JToolBarHelper::custom('event.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
         }
         JToolBarHelper::cancel('event.cancel', 'JTOOLBAR_CANCEL');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 // We can save the new record
                 JToolBarHelper::apply('event.apply', 'JTOOLBAR_APPLY');
                 JToolBarHelper::save('event.save', 'JTOOLBAR_SAVE');
                 // We can save this record, but check the create permission to see
                 // if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::custom('event.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
                 }
             }
         }
         // If checked out, we can still save
         if ($canDo->get('core.create')) {
             JToolBarHelper::custom('event.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
         }
         JToolBarHelper::cancel('event.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Exemple #4
0
 /**
  * Method to display a view.
  *
  * @param	boolean			$cachable	If true, the view output will be cached
  * @param	array			$urlparams	An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/icagenda.php';
     // Set Input J3
     $jinput = JFactory::getApplication()->input;
     // Load the submenu.
     if (version_compare(JVERSION, '3.0', 'lt')) {
         iCagendaHelper::addSubmenu(JRequest::getCmd('view', 'icagenda'));
         $view = JRequest::getCmd('view', 'icagenda');
         JRequest::setVar('view', $view);
     } else {
         iCagendaHelper::addSubmenu($jinput->get('view', 'icagenda'));
         $view = $jinput->get('view', 'icagenda');
         $jinput->set('view', $view);
     }
     parent::display();
     return $this;
 }
Exemple #5
0
 /**
  * Add the page title and toolbar.
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $isNew = $this->item->id == 0;
     if (isset($this->item->checked_out)) {
         $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
     } else {
         $checkedOut = false;
     }
     $canDo = iCagendaHelper::getActions();
     //JToolBarHelper::title(JText::_('COM_ICAGENDA_TITLE_CATEGORY'), 'category.png');
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title($isNew ? 'iCagenda - ' . JText::_('COM_ICAGENDA_LEGEND_NEW_REGISTRATION') : 'iCagenda - ' . JText::_('COM_ICAGENDA_LEGEND_EDIT_REGISTRATION'), 'registration.png');
     } else {
         JToolBarHelper::title($isNew ? 'iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_LEGEND_NEW_REGISTRATION') . '</span>' : 'iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_LEGEND_EDIT_REGISTRATION') . '</span>', $isNew ? 'new' : 'pencil-2');
     }
     $icTitle = $isNew ? JText::_('COM_ICAGENDA_LEGEND_NEW_REGISTRATION') : JText::_('COM_ICAGENDA_LEGEND_EDIT_REGISTRATION');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.edit.own') || $canDo->get('core.create'))) {
         JToolBarHelper::apply('registration.apply', 'JTOOLBAR_APPLY');
         JToolBarHelper::save('registration.save', 'JTOOLBAR_SAVE');
     }
     if (!$checkedOut && $canDo->get('core.create')) {
         JToolBarHelper::custom('registration.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         JToolBarHelper::custom('registration.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('registration.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('registration.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Exemple #6
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/icagenda.php';
     $state = $this->get('State');
     //		$canDo	= iCagendaHelper::getActions($state->get('filter.registration_id'));
     $canDo = iCagendaHelper::getActions();
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title('iCagenda - ' . JText::_('COM_ICAGENDA_TITLE_REGISTRATION'), 'registration.png');
     } else {
         JToolBarHelper::title('iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_TITLE_REGISTRATION') . '</span>', 'users');
     }
     $icTitle = JText::_('COM_ICAGENDA_TITLE_REGISTRATION');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
     //Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/registration';
     if (file_exists($formPath)) {
         // Add Export Button to the ToolBar
         $bar = JToolBar::getInstance('toolbar');
         $export_icon = version_compare(JVERSION, '3.0', 'ge') ? 'download' : 'export';
         $bar->appendButton('Popup', $export_icon, 'JTOOLBAR_EXPORT', 'index.php?option=com_icagenda&amp;view=download&amp;tmpl=component', 600, 300);
         JToolBarHelper::divider();
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('registration.add', 'JTOOLBAR_NEW');
         }
         if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
             JToolBarHelper::editList('registration.edit', 'JTOOLBAR_EDIT');
         }
     }
     if ($canDo->get('core.edit.state')) {
         if (isset($this->items[0]->state)) {
             //				JToolBarHelper::divider();
             JToolBarHelper::custom('registrations.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('registrations.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         } else {
             // If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'registrations.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('registrations.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('registrations.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
         }
     }
     // Show trash and delete for components that uses the state field
     if (isset($this->items[0]->state)) {
         if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
             JToolBarHelper::deleteList('', 'registrations.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('registrations.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_icagenda');
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         JHtmlSidebar::setAction('index.php?option=com_icagenda&view=registrations');
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_REGISTRATIONS_SELECT_STATUS'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_REGISTRATIONS_SELECT_CATEGORY'), 'filter_categories', JHtml::_('select.options', $this->get('Categories'), 'value', 'text', $this->state->get('filter.categories'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_REGISTRATIONS_SELECT_EVENT'), 'filter_events', JHtml::_('select.options', $this->get('Events'), 'value', 'text', $this->state->get('filter.events'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_REGISTRATIONS_SELECT_DATE'), 'filter_dates', JHtml::_('select.options', $this->get('Dates'), 'value', 'text', $this->state->get('filter.dates'), true));
     }
 }
Exemple #7
0
 /**
  * Add the page title and toolbar.
  *
  * @since	3.4.0
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'icagenda.php';
     $state = $this->get('State');
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $canDo = iCagendaHelper::getActions();
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title('iCagenda - ' . JText::_('COM_ICAGENDA_CUSTOMFIELDS'), 'customfields.png');
     } else {
         JToolBarHelper::title('iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_CUSTOMFIELDS') . '</span>', 'list-2');
     }
     $icTitle = JText::_('COM_ICAGENDA_CUSTOMFIELDS');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
     //Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/customfield';
     if (file_exists($formPath)) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('customfield.add', 'JTOOLBAR_NEW');
         }
         if ($canDo->get('core.edit')) {
             JToolBarHelper::editList('customfield.edit', 'JTOOLBAR_EDIT');
         }
     }
     if ($canDo->get('core.edit.state')) {
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('customfields.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('customfields.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         } else {
             //If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'customfields.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('customfields.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('customfields.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
         }
     }
     // Show trash and delete for components that uses the state field
     if (isset($this->items[0]->state)) {
         if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
             JToolBarHelper::deleteList('', 'customfields.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('customfields.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_icagenda');
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         JHtmlSidebar::setAction('index.php?option=com_icagenda&view=customfields');
         JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_CUSTOMFIELDS_FILTER_OPTION_SELECT_PARENT_FORM'), 'filter_parent_form', JHtml::_('select.options', $this->get('ParentForm'), 'value', 'text', $this->state->get('filter.parent_form'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_CUSTOMFIELDS_FILTER_OPTION_SELECT_TYPE'), 'filter_type', JHtml::_('select.options', $this->get('FieldTypes'), 'value', 'text', $this->state->get('filter.type'), true));
     }
 }
 /**
  * Overloaded bind function to pre-process the params.
  *
  * @param	array		Named array
  * @return	null|string	null is operation was satisfactory, otherwise returns an error
  * @see		JTable:bind
  * @since	1.3
  */
 public function bind($array, $ignore = '')
 {
     /**
      * Serialize Single Dates
      */
     $dev_option = '0';
     if (iCagendaHelper::isSerialized($array['dates'])) {
         $dates = unserialize($array['dates']);
     } elseif ($dev_option == '1') {
         $dates = $this->setDatesOptions($array['dates']);
     } else {
         $dates = $this->getDates($array['dates']);
     }
     rsort($dates);
     if ($dev_option == '1') {
         $array['dates'] = $array['dates'];
     } else {
         $array['dates'] = serialize($dates);
     }
     /**
      * Serialize Period Dates
      */
     $nodate = '0000-00-00 00:00:00';
     // Calcul des dates d'une période.
     $startdate = $array['startdate'];
     $enddate = $array['enddate'];
     if ($startdate == NULL) {
         $startdate = $nodate;
     }
     if ($enddate == NULL) {
         $enddate = $nodate;
     }
     if ($startdate == $nodate && $enddate != $nodate) {
         $enddate = $nodate;
     }
     $startcontrol = $this->mkt($startdate);
     $endcontrol = $this->mkt($enddate);
     $errorperiod = '';
     if ($startcontrol > $endcontrol) {
         $errorperiod = '1';
     } else {
         if (class_exists('DateInterval')) {
             // Create array with all dates of the period - PHP 5.3+
             $start = new DateTime($startdate);
             $interval = '+1 days';
             $date_interval = DateInterval::createFromDateString($interval);
             $timestartdate = date('H:i', strtotime($startdate));
             $timeenddate = date('H:i', strtotime($enddate));
             if ($timeenddate <= $timestartdate) {
                 $end = new DateTime("{$enddate} +1 days");
             } else {
                 $end = new DateTime($enddate);
             }
             // Retourne toutes les dates.
             $perioddates = new DatePeriod($start, $date_interval, $end);
             $out = array();
         } else {
             // Create array with all dates of the period - PHP 5.2
             if ($startdate != $nodate && $enddate != $nodate) {
                 $start = new DateTime($startdate);
                 $timestartdate = date('H:i', strtotime($startdate));
                 $timeenddate = date('H:i', strtotime($enddate));
                 if ($timeenddate <= $timestartdate) {
                     $end = new DateTime("{$enddate} +1 days");
                 } else {
                     $end = new DateTime($enddate);
                 }
                 while ($start < $end) {
                     $out[] = $start->format('Y-m-d H:i');
                     $start->modify('+1 day');
                 }
             }
         }
         // Prépare serialize.
         if (!empty($perioddates)) {
             foreach ($perioddates as $dt) {
                 $out[] = $dt->format('Y-m-d H:i');
             }
         }
     }
     // Serialize les dates de la période.
     if ($startdate != $nodate && $enddate != $nodate) {
         if ($errorperiod != '1') {
             $array['period'] = serialize($out);
             if (iCagendaHelper::isSerialized($array['period'])) {
                 $period = unserialize($array['period']);
             } else {
                 $period = $this->getPeriod($array['period']);
             }
             rsort($period);
             $array['period'] = serialize($period);
         } else {
             $array['period'] = '';
         }
     } else {
         $array['period'] = '';
     }
     /**
      * Set Week Days
      */
     if (!isset($array['weekdays'])) {
         $array['weekdays'] = '';
     }
     if (is_array($array['weekdays'])) {
         $array['weekdays'] = implode(',', $array['weekdays']);
     }
     /**
      * Create Next Date
      */
     $todaytime = time();
     $NextDates = $this->getNextDates($dates);
     if (isset($period)) {
         $NextPeriod = $this->getNextPeriod($period, $array['weekdays']);
     } else {
         $NextPeriod = $this->getNextDates($dates);
     }
     $today = time();
     $day = date('d');
     $m = date('m');
     $y = date('y');
     $hour = date('H');
     $min = date('i');
     $today = mktime(0, 0, 0, $m, $day, $y);
     $nextdmkt = strtotime($NextDates);
     $nextpmkt = strtotime($NextPeriod);
     $nextDmktdate = $this->mktdate($NextDates);
     $nextPmktdate = $this->mktdate($NextPeriod);
     $nextDmkttime = $this->mkttime($NextDates);
     $nextPmkttime = $this->mkttime($NextPeriod);
     // Controle Date à venir
     if ($nextDmktdate >= $today && $nextPmktdate >= $today) {
         if ($nextDmktdate < $nextPmktdate) {
             $array['next'] = $this->getNextDates($dates);
         }
         if ($nextDmktdate > $nextPmktdate) {
             $array['next'] = $this->getNextPeriod($period, $array['weekdays']);
         }
         if ($nextDmktdate == $nextPmktdate) {
             if ($nextDmkttime >= $nextPmkttime) {
                 if (isset($period)) {
                     $array['next'] = $this->getNextPeriod($period, $array['weekdays']);
                 } else {
                     $array['next'] = $this->getNextDates($dates);
                 }
             } else {
                 $array['next'] = $this->getNextDates($dates);
             }
         }
     }
     if ($nextDmktdate < $today && $nextPmktdate >= $today) {
         $array['next'] = $this->getNextPeriod($period, $array['weekdays']);
     }
     if ($nextDmktdate >= $today && $nextPmktdate < $today) {
         $array['next'] = $this->getNextDates($dates);
     }
     if ($nextDmktdate < $today && $nextPmktdate < $today) {
         if ($nextDmktdate < $nextPmktdate) {
             $array['next'] = $this->getNextPeriod($period, $array['weekdays']);
         }
         if ($nextDmktdate >= $nextPmktdate) {
             $array['next'] = $this->getNextDates($dates);
         }
     }
     // Control of dates if valid (EDIT SINCE VERSION 3.0 - update 3.1.4)
     if (($nextdmkt >= '943916400' and $nextdmkt <= '944002800') && $errorperiod == '1') {
         $array['next'] = '-3600';
     }
     if (($nextdmkt == '943916400' or $nextdmkt == '943920000') && ($nextpmkt == '943916400' or $nextpmkt == '943920000')) {
         $array['next'] = '-3600';
     }
     if ($array['next'] == '-3600') {
         $state = 0;
         $this->_db->setQuery('UPDATE `#__icagenda_events`' . ' SET `state` = ' . (int) $state . ' WHERE `id` = ' . (int) $array['id']);
         if (version_compare(JVERSION, '3.0', 'lt')) {
             $this->_db->query();
         } else {
             $this->_db->execute();
         }
     }
     /**
      * Set Creator infos
      */
     $user = JFactory::getUser();
     $userId = $user->get('id');
     if ($array['created_by'] == '0') {
         $array['created_by'] = $userId;
     }
     if (isset($array['params']) && is_array($array['params'])) {
         // Convert the params field to a string.
         $parameter = new JRegistry();
         $parameter->loadArray($array['params']);
         $array['params'] = (string) $parameter;
     }
     $username = $user->get('name');
     $array['username'] = $username;
     /**
      * Set File upload
      */
     if (!isset($array['file'])) {
         $file = JRequest::getVar('jform', null, 'files', 'array');
         $fileUrl = $this->upload($file);
         $array['file'] = $fileUrl;
     }
     /**
      * Set Meta data
      */
     if (isset($array['metadata']) && is_array($array['metadata'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['metadata']);
         $array['metadata'] = (string) $registry;
     }
     $mail_new_event = '0';
     $mail_new_event = JComponentHelper::getParams('com_icagenda')->get('mail_new_event', '0');
     $return[] = parent::bind($array, $ignore);
     if ($mail_new_event == 1) {
         $title = $array['title'];
         $id_event = $array['id'];
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('id AS eventID')->from('#__icagenda_events')->order('id DESC');
         $db->setQuery($query);
         $eventID = $db->loadResult();
         $new_event = JRequest::getVar('new_event');
         $title = $array['title'];
         $description = $array['desc'];
         $venue = '';
         if ($array['place']) {
             $venue .= $array['place'] . ' - ';
         }
         if ($array['city']) {
             $venue .= $array['city'];
         }
         if ($array['city'] && $array['country']) {
             $venue .= ', ';
         }
         if ($array['country']) {
             $venue .= $array['country'];
         }
         if (strtotime($array['startdate'])) {
             $date = 'Du ' . $array['startdate'] . ' au ' . $array['startdate'];
         } else {
             $date = $array['next'];
         }
         $baseURL = JURI::base();
         $baseURL = str_replace('/administrator', '', $baseURL);
         $baseURL = ltrim($baseURL, '/');
         if ($array['image']) {
             $image = '<img src="' . $baseURL . '/' . $array['image'] . '" />';
         }
         if ($new_event == '1' && $eventID && $array['state'] == '1' && $array['approval'] == '0') {
             $return[] = self::notificationNewEvent($eventID + 1, $title, $description, $venue, $date, $image, $new_event);
         }
         //			elseif ($new_event == '0')
         //			{
         //					$return[] = self::notificationNewEvent($array['id'], 'Edited Event', $new_event);
         //			}
     }
     return $return;
 }
Exemple #9
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/icagenda.php';
     $state = $this->get('State');
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $canDo = iCagendaHelper::getActions();
     $icagenda_categories = class_exists('icagendaCategories') ? icagendaCategories::getList() : false;
     // Set Title
     if (version_compare(JVERSION, '3.0', 'lt')) {
         JToolBarHelper::title('iCagenda - ' . JText::_('COM_ICAGENDA_TITLE_EVENTS'), 'events.png');
     } else {
         JToolBarHelper::title('iCagenda <span style="font-size:14px;">- ' . JText::_('COM_ICAGENDA_TITLE_EVENTS') . '</span>', 'calendar');
     }
     $icTitle = JText::_('COM_ICAGENDA_TITLE_EVENTS');
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $title = $app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - iCagenda: ' . $icTitle;
     $document->setTitle($title);
     //Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/event';
     if (file_exists($formPath) && $icagenda_categories) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('event.add', 'JTOOLBAR_NEW');
         }
         if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
             JToolBarHelper::editList('event.edit');
         }
     }
     if ($canDo->get('core.edit.state') && $icagenda_categories) {
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('events.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('events.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         } else {
             // If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'events.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('events.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('events.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
         }
     }
     // Show trash and delete for components that uses the state field
     if (isset($this->items[0]->state) && $icagenda_categories) {
         if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
             JToolBarHelper::deleteList('', 'events.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('events.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_icagenda');
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         JHtmlSidebar::setAction('index.php?option=com_icagenda&view=events');
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_SELECT_STATE'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_SELECT_CATEGORY'), 'filter_category', JHtml::_('select.options', $this->get('Categories'), 'value', 'text', $this->state->get('filter.category'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_SELECT_DATES'), 'filter_upcoming', JHtml::_('select.options', $this->get('Upcoming'), 'value', 'text', $this->state->get('filter.upcoming'), true));
         JHtmlSidebar::addFilter(JText::_('COM_ICAGENDA_SELECT_SITE_ITEMID'), 'filter_site_itemid', JHtml::_('select.options', $this->get('MenuItemID'), 'value', 'text', $this->state->get('filter.site_itemid'), true));
     }
 }