Exemplo n.º 1
0
 function _createFilter($prefix = "")
 {
     if (!$this->filterField) {
         return "ev.state=1";
     }
     // The default is only to show published events
     if ($this->filter_value == 0) {
         return "ev.state=1";
     }
     // only show published events to non-logged in users
     $user = JFactory::getUser();
     if ($user->get('id') == 0) {
         return "ev.state=1";
     }
     if (JEVHelper::isEventPublisher(true) || JEVHelper::isEventEditor()) {
         if ($this->filter_value == -1) {
             return "";
         }
         return "ev.state=0";
     } else {
         if (JEVHelper::isEventCreator()) {
             $user = JFactory::getUser();
             if ($this->filter_value == -1) {
                 return "(ev.state=1 OR ev.created_by=" . $user->id . ")";
             }
             return "ev.state=0 && ev.created_by=" . $user->id;
         }
     }
     return "ev.state=1";
 }
Exemplo n.º 2
0
 protected function getLabel()
 {
     if (JFactory::getApplication()->isAdmin() || JEVHelper::isEventPublisher()) {
         return parent::getLabel();
     }
     return "";
 }
Exemplo n.º 3
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $showpriority = $params->get("showpriority", 0);
     JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php");
     JEVHelper::ConditionalFields($this->element, $this->form->getName());
     // only those who can publish globally can set priority field
     if ($showpriority && JEVHelper::isEventPublisher(true)) {
         $list = array();
         for ($i = 0; $i < 10; $i++) {
             $list[] = JHTML::_('select.option', $i, $i, 'val', 'text');
         }
         return JHTML::_('select.genericlist', $list, 'priority', "style='width:50px'", 'val', 'text', $this->value);
     } else {
         return "";
     }
 }
Exemplo n.º 4
0
 function edit($key = NULL, $urlVar = NULL)
 {
     // get the view
     $this->view = $this->getView("icalrepeat", "html");
     // Get/Create the model
     if ($model = $this->getModel("icalevent", "icaleventsModel")) {
         // Push the model into the view (as default)
         $this->view->setModel($model, true);
     }
     $db = JFactory::getDBO();
     $cid = JRequest::getVar('cid', array(0));
     JArrayHelper::toInteger($cid);
     if (is_array($cid) && count($cid) > 0) {
         $id = $cid[0];
     } else {
         $id = $cid;
     }
     if (!JEVHelper::isEventCreator()) {
         throw new Exception(JText::_('ALERTNOTAUTH'), 403);
         return false;
     }
     // front end passes the id as evid
     if ($id == 0) {
         $id = JRequest::getInt("evid", 0);
     }
     $db = JFactory::getDBO();
     $query = "SELECT rpt.eventid" . "\n FROM (#__jevents_vevent as ev, #__jevents_icsfile as icsf)" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n WHERE rpt.rp_id=" . $id . "\n AND icsf.ics_id=ev.icsid AND icsf.state=1";
     $db->setQuery($query);
     $ev_id = $db->loadResult();
     if ($ev_id == 0 || $id == 0) {
         $this->setRedirect('index.php?option=' . JEV_COM_COMPONENT . '&task=icalrepeat.list&cid[]=' . $ev_id, "ICal repeat does not exist");
         $this->redirect();
     }
     $repeatId = $id;
     $row = $this->queryModel->listEventsById($repeatId, true, "icaldb");
     if (!JEVHelper::canEditEvent($row)) {
         throw new Exception(JText::_('ALERTNOTAUTH'), 403);
         return false;
     }
     /*
      $db = JFactory::getDBO();
      // get list of groups
      $query = "SELECT id AS value, name AS text"
      . "\n FROM #__groups"
      . "\n ORDER BY id"	;
      $db->setQuery( $query );
      $groups = $db->loadObjectList();
     
      // build the html select list
      $glist = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="1"',
      'value', 'text', intval( $row->access() ) );
     */
     $glist = JEventsHTML::buildAccessSelect(intval($row->access()), 'class="inputbox" size="1"');
     // For repeats don't offer choice of ical or category
     // get all the raw native calendars
     $nativeCals = $this->dataModel->queryModel->getNativeIcalendars();
     $icsid = $row->icsid() > 0 ? $row->icsid() : current($nativeCals)->ics_id;
     $clist = '<input type="hidden" name="ics_id" value="' . $icsid . '" />';
     $this->view->assign('clistChoice', false);
     $this->view->assign('defaultCat', 0);
     // Set the layout
     $this->view->setLayout('edit');
     $this->view->assign('ev_id', $ev_id);
     $this->view->assign('rp_id', $repeatId);
     $this->view->assign('row', $row);
     $this->view->assign('nativeCals', $nativeCals);
     $this->view->assign('clist', $clist);
     $this->view->assign('repeatId', $repeatId);
     $this->view->assign('glist', $glist);
     $this->view->assignRef('dataModel', $this->dataModel);
     $this->view->assign('editCopy', false);
     // only those who can publish globally can set priority field
     if (JEVHelper::isEventPublisher(true)) {
         $list = array();
         for ($i = 0; $i < 10; $i++) {
             $list[] = JHTML::_('select.option', $i, $i, 'val', 'text');
         }
         $priorities = JHTML::_('select.genericlist', $list, 'priority', "", 'val', 'text', $row->priority());
         $this->view->assign('setPriority', true);
         $this->view->assign('priority', $priorities);
     } else {
         $this->view->assign('setPriority', false);
     }
     // for Admin interface only
     $this->view->assign('with_unpublished_cat', JFactory::getApplication()->isAdmin());
     $this->view->display();
 }
Exemplo n.º 5
0
 function save($array, &$queryModel, $rrule, $dryrun = false)
 {
     $cfg =& JEVConfig::getInstance();
     $db =& JFactory::getDBO();
     $user = JFactory::getUser();
     // Allow plugins to check data validity
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin("jevents");
     $res = $dispatcher->trigger('onBeforeSaveEvent', array(&$array, &$rrule, $dryrun));
     // TODO do error and hack checks here
     $ev_id = intval(JArrayHelper::getValue($array, "evid", 0));
     $newevent = $ev_id == 0;
     $data = array();
     // TODO add UID to edit form
     $data["UID"] = JArrayHelper::getValue($array, "uid", md5(uniqid(rand(), true)));
     $data["X-EXTRAINFO"] = JArrayHelper::getValue($array, "extra_info", "");
     $data["LOCATION"] = JArrayHelper::getValue($array, "location", "");
     $data["allDayEvent"] = JArrayHelper::getValue($array, "allDayEvent", "off");
     $data["CONTACT"] = JArrayHelper::getValue($array, "contact_info", "");
     $data["DESCRIPTION"] = JArrayHelper::getValue($array, "jevcontent", "");
     $data["publish_down"] = JArrayHelper::getValue($array, "publish_down", "2006-12-12");
     $data["publish_up"] = JArrayHelper::getValue($array, "publish_up", "2006-12-12");
     $data["SUMMARY"] = JArrayHelper::getValue($array, "title", "");
     $data["URL"] = JArrayHelper::getValue($array, "url", "");
     // If user is jevents can deleteall or has backend access then allow them to specify the creator
     $jevuser = JEVHelper::getAuthorisedUser();
     $creatorid = JRequest::getInt("jev_creatorid", 0);
     if ($creatorid > 0) {
         if (JVersion::isCompatible("1.6.0")) {
             //$access = JAccess::check($user->id, "core.deleteall","com_jevents");
             $access = $user->authorise('core.admin', 'com_jevents');
         } else {
             // Get an ACL object
             $acl =& JFactory::getACL();
             $grp = $acl->getAroGroup($user->get('id'));
             $access = $acl->is_group_child_of($grp->name, 'Public Backend');
         }
         if ($jevuser && $jevuser->candeleteall || $access) {
             $data["X-CREATEDBY"] = $creatorid;
         }
     }
     $ics_id = JArrayHelper::getValue($array, "ics_id", 0);
     if ($data["allDayEvent"] == "on") {
         $start_time = "00:00";
     } else {
         $start_time = JArrayHelper::getValue($array, "start_time", "08:00");
     }
     $publishstart = $data["publish_up"] . ' ' . $start_time . ':00';
     $data["DTSTART"] = JevDate::strtotime($publishstart);
     if ($data["allDayEvent"] == "on") {
         $end_time = "00:00";
     } else {
         $end_time = JArrayHelper::getValue($array, "end_time", "15:00");
     }
     $publishend = $data["publish_down"] . ' ' . $end_time . ':00';
     if (isset($array["noendtime"]) && $array["noendtime"]) {
         $publishend = $data["publish_down"] . ' 23:59:59';
     }
     $data["DTEND"] = JevDate::strtotime($publishend);
     // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day
     list($h, $m, $s) = explode(":", $end_time . ':00');
     if ($h + $m + $s == 0 && $data["allDayEvent"] == "on" && $data["DTEND"] > $data["DTSTART"]) {
         //if (($h+$m+$s)==0 && $data["allDayEvent"]=="on" && $data["DTEND"]>=$data["DTSTART"]) {
         //$publishend = JevDate::strftime('%Y-%m-%d 23:59:59',($data["DTEND"]-86400));
         $publishend = JevDate::strftime('%Y-%m-%d 23:59:59', $data["DTEND"]);
         $data["DTEND"] = JevDate::strtotime($publishend);
     }
     $data["RRULE"] = $rrule;
     $data["MULTIDAY"] = JArrayHelper::getValue($array, "multiday", "1");
     $data["NOENDTIME"] = JArrayHelper::getValue($array, "noendtime", "0");
     $data["X-COLOR"] = JArrayHelper::getValue($array, "color", "");
     $data["LOCKEVENT"] = JArrayHelper::getValue($array, "lockevent", "0");
     // Add any custom fields into $data array
     foreach ($array as $key => $value) {
         if (strpos($key, "custom_") === 0) {
             $data[$key] = $value;
         }
     }
     $vevent = iCalEvent::iCalEventFromData($data);
     $vevent->catid = JArrayHelper::getValue($array, "catid", 0);
     if (is_array($vevent->catid)) {
         JArrayHelper::toInteger($vevent->catid);
     }
     // if catid is empty then use the catid of the ical calendar
     if (is_string($vevent->catid) && $vevent->catid <= 0 || is_array($vevent->catid) && count($vevent->catid) == 0) {
         $query = "SELECT catid FROM #__jevents_icsfile WHERE ics_id={$ics_id}";
         $db->setQuery($query);
         $vevent->catid = $db->loadResult();
     }
     $vevent->access = intval(JArrayHelper::getValue($array, "access", 0));
     if (!JVersion::isCompatible("1.6.0")) {
         $vevent->access = $vevent->access > $user->aid ? $user->aid : $vevent->access;
     }
     $vevent->state = intval(JArrayHelper::getValue($array, "state", 0));
     // Shouldn't really do this like this
     $vevent->_detail->priority = intval(JArrayHelper::getValue($array, "priority", 0));
     // FRONT END AUTO PUBLISHING CODE
     $frontendPublish = JEVHelper::isEventPublisher();
     if (!$frontendPublish) {
         $frontendPublish = JEVHelper::canPublishOwnEvents($ev_id);
     }
     // Always unpublish if no Publisher otherwise publish automatically (for new events)
     // Should we always notify of new events
     $notifyAdmin = $cfg->get("com_notifyallevents", 0);
     if (!JFactory::getApplication()->isAdmin()) {
         if ($frontendPublish && $ev_id == 0) {
             $vevent->state = 1;
         } else {
             if (!$frontendPublish) {
                 $vevent->state = 0;
                 // In this case we send a notification email to admin
                 $notifyAdmin = true;
             }
         }
     }
     $vevent->icsid = $ics_id;
     if ($ev_id > 0) {
         $vevent->ev_id = $ev_id;
     }
     $rp_id = intval(JArrayHelper::getValue($array, "rp_id", 0));
     if ($rp_id > 0) {
         // I should be able to do this in one operation but that can come later
         $testevent = $queryModel->listEventsById(intval($rp_id), 1, "icaldb");
         if (!JEVHelper::canEditEvent($testevent)) {
             JError::raiseError(403, JText::_('ALERTNOTAUTH'));
         }
     }
     $db =& JFactory::getDBO();
     $success = true;
     //echo "class = ".get_class($vevent);
     if (!$dryrun) {
         if (!$vevent->store()) {
             echo $db->getErrorMsg() . "<br/>";
             $success = false;
             JError::raiseWarning(101, JText::_('COULD_NOT_SAVE_EVENT_'));
         }
     } else {
         // need a value for eventid to pretend we have saved the event so we can get the repetitions
         if (!isset($vevent->ev_id)) {
             $vevent->ev_id = 0;
         }
         $vevent->rrule->eventid = $vevent->ev_id;
     }
     // Only update the repetitions if the event edit says the reptitions will have changed or a new event
     if ($newevent || JRequest::getInt("updaterepeats", 1)) {
         $repetitions = $vevent->getRepetitions(true);
         if (!$dryrun) {
             if (!$vevent->storeRepetitions()) {
                 echo $db->getErrorMsg() . "<br/>";
                 $success = false;
                 JError::raiseWarning(101, JText::_('COULD_NOT_SAVE_REPETITIONS'));
             }
         }
     }
     $res = $dispatcher->trigger('onAfterSaveEvent', array(&$vevent, $dryrun));
     if ($dryrun) {
         return $vevent;
     }
     // If not authorised to publish in the frontend then notify the administrator
     if (!$dryrun && $success && $notifyAdmin && !JFactory::getApplication()->isAdmin()) {
         JLoader::register('JEventsCategory', JEV_ADMINPATH . "/libraries/categoryClass.php");
         $cat = new JEventsCategory($db);
         $cat->load($vevent->catid);
         $adminuser = $cat->getAdminUser();
         $adminEmail = $adminuser->email;
         $config = new JConfig();
         $sitename = $config->sitename;
         $subject = JText::_('JEV_MAIL_ADDED') . ' ' . $sitename;
         $subject = $vevent->state == '1' ? '[Info] ' . $subject : '[Approval] ' . $subject;
         $Itemid = JEVHelper::getItemid();
         // reload the event to get the reptition ids
         $evid = intval($vevent->ev_id);
         $testevent = $queryModel->getEventById($evid, 1, "icaldb");
         $rp_id = $testevent->rp_id();
         list($year, $month, $day) = JEVHelper::getYMD();
         //http://joomlacode1.5svn/index.php?option=com_jevents&task=icalevent.edit&evid=1&Itemid=68&rp_id=72&year=2008&month=09&day=10&lang=cy
         $uri =& JURI::getInstance(JURI::base());
         $root = $uri->toString(array('scheme', 'host', 'port'));
         $modifylink = '<a href="' . $root . JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.edit&evid=' . $evid . '&rp_id=' . $rp_id . '&Itemid=' . $Itemid . "&year={$year}&month={$month}&day={$day}") . '"><b>' . JText::_('JEV_MODIFY') . '</b></a>' . "\n";
         $viewlink = '<a href="' . $root . JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalrepeat.detail&evid=' . $rp_id . '&Itemid=' . $Itemid . "&year={$year}&month={$month}&day={$day}&login=1") . '"><b>' . JText::_('JEV_VIEW') . '</b></a>' . "\n";
         $created_by = $user->name;
         if ($created_by == null) {
             $created_by = "Anonymous";
             if (JRequest::getString("custom_anonusername", "") != "") {
                 $created_by = JRequest::getString("custom_anonusername", "") . " (" . JRequest::getString("custom_anonemail", "") . ")";
             }
         }
         JEV_CommonFunctions::sendAdminMail($sitename, $adminEmail, $subject, $testevent->title(), $testevent->content(), $created_by, JURI::root(), $modifylink, $viewlink);
     }
     if ($success) {
         return $vevent;
     }
     return $success;
 }
Exemplo n.º 6
0
 /**
  * Test to see if user is creator of the event or editor or above
  *
  * @param unknown_type $row
  * @param unknown_type $user
  * @return unknown
  */
 function hasAdvancedRowPermissions($row, $user = null)
 {
     // TODO make this call a plugin
     if ($user == null) {
         $user = JFactory::getUser();
     }
     // strictt publishing test
     if (JEVHelper::isEventEditor() || JEVHelper::isEventPublisher(true)) {
         return true;
     }
     if (is_null($row)) {
         return false;
     } else {
         if ($row->created_by() == $user->id) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 7
0
 protected function toggleICalEventPublish($cid, $newstate)
 {
     // clean out the cache
     $cache =& JFactory::getCache('com_jevents');
     $cache->clean(JEV_COM_COMPONENT);
     // Must be at least an event creator to publish events
     $is_event_editor = JEVHelper::isEventPublisher();
     if (!$is_event_editor) {
         if (is_array($cid)) {
             foreach ($cid as $id) {
                 if (!JEVHelper::canPublishOwnEvents($id)) {
                     JError::raiseError(403, JText::_('ALERTNOTAUTH'));
                 }
             }
         }
         $is_event_editor = true;
     }
     if (!$is_event_editor) {
         JError::raiseError(403, JText::_('ALERTNOTAUTH'));
     }
     $db =& JFactory::getDBO();
     foreach ($cid as $id) {
         // I should be able to do this in one operation but that can come later
         $event = $this->queryModel->getEventById(intval($id), 1, "icaldb");
         if (is_null($event) || !JEVHelper::canPublishEvent($event)) {
             JError::raiseError(403, JText::_('ALERTNOTAUTH'));
         }
         $sql = "UPDATE #__jevents_vevent SET state={$newstate} where ev_id='" . $id . "'";
         $db->setQuery($sql);
         $db->query();
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         if ($newstate == 1 && $params->get("com_notifyauthor", 0) && !$event->_author_notified) {
             $sql = "UPDATE #__jevents_vevent SET author_notified=1 where ev_id='" . $id . "'";
             $db->setQuery($sql);
             $db->query();
             JEV_CommonFunctions::notifyAuthorPublished($event);
         }
     }
     // I also need to trigger any onpublish event triggers
     $dispatcher =& JDispatcher::getInstance();
     // just incase we don't have jevents plugins registered yet
     JPluginHelper::importPlugin("jevents");
     $res = $dispatcher->trigger('onPublishEvent', array($cid, $newstate));
     if (JFactory::getApplication()->isAdmin()) {
         $this->setRedirect('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.list', "IcalEvent  : New published state Saved");
     } else {
         $Itemid = JRequest::getInt("Itemid");
         list($year, $month, $day) = JEVHelper::getYMD();
         $rettask = JRequest::getString("rettask", "day.listevents");
         // Don't return to the event detail since we may be filtering on published state!
         //$this->setRedirect( JRoute::_('index.php?option=' . JEV_COM_COMPONENT. "&task=icalrepeat.detail&evid=$id&year=$year&month=$month&day=$day&Itemid=$Itemid",false),"IcalEvent  : New published state Saved");
         $this->setRedirect(JRoute::_('index.php?option=' . JEV_COM_COMPONENT . "&task={$rettask}&year={$year}&month={$month}&day={$day}&Itemid={$Itemid}", false), "IcalEvent  : New published state Saved");
     }
 }
Exemplo n.º 8
0
 protected function toggleICalEventPublish($cid, $newstate)
 {
     $is_event_editor = JEVHelper::isEventPublisher();
     if (!$is_event_editor) {
         JError::raiseError(403, JText::_('ALERTNOTAUTH'));
     }
     parent::toggleICalEventPublish($cid, $newstate);
 }
Exemplo n.º 9
0
 /**
  * Test to see if user can publish event
  *
  * @param unknown_type $row
  * @param unknown_type $user
  * @return unknown
  */
 public static function canPublishEvent($row, $user = null)
 {
     // store in static to save repeated database calls
     static $authdata_editstate = array();
     // TODO make this call a plugin
     if ($user == null) {
         $user = JFactory::getUser();
     }
     // are we authorised to do anything with this category or calendar
     $jevuser = JEVHelper::getAuthorisedUser();
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $authorisedonly = $params->get("authorisedonly", 0);
     if ($authorisedonly) {
         if (!$jevuser) {
             // paid subs plugin may override this
             if ($row->created_by() == $user->id && $user->id > 0) {
                 $frontendPublish = JEVHelper::isEventPublisher(false);
                 return $frontendPublish;
             }
             return false;
         }
         if ($row->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
             $allowedcals = explode("|", $jevuser->calendars);
             if (!in_array($row->_icsid, $allowedcals)) {
                 return false;
             }
         }
         if ($row->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
             $allowedcats = explode("|", $jevuser->categories);
             if (!in_array($row->_catid, $allowedcats)) {
                 return false;
             }
             // check multi cats too
             if (JEVHelper::rowCatids($row)) {
                 if (count(array_diff(JEVHelper::rowCatids($row), $allowedcats))) {
                     return false;
                 }
             }
         }
         if ($jevuser->canpublishall) {
             return true;
         }
         if ($row->created_by() == $user->id && $jevuser->canpublishown) {
             return true;
         }
         return false;
     }
     // can publish all?
     if (JEVHelper::isEventPublisher(true)) {
         // This involes TOO many database queries in Joomla - one per category which can be a LOT
         /*
          $cats = JEVHelper::getAuthorisedCategories($user,'com_jevents', 'core.edit.state');
          if (in_array($row->_catid, $cats))
          return true;
         */
         // allow multi-categories
         $key = $row->catids() ? json_encode($row->catids()) : json_encode(intval($row->catid()));
         $authdata_editstate[$key] = JEVHelper::authoriseCategories('core.edit.state', $key, $user);
         return $authdata_editstate[$key];
         return true;
     } else {
         if ($row->created_by() == $user->id) {
             // Use generic helper method that can call the plugin to see if user can publish any events
             $isEventPublisher = JEVHelper::isEventPublisher();
             if ($isEventPublisher) {
                 return true;
             }
             $jevuser = JEVHelper::getAuthorisedUser();
             if (!is_null($jevuser)) {
                 return $jevuser->canpublishown;
             }
             $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
             $authorisedonly = $params->get("authorisedonly", 1);
             $publishown = $params->get("jevpublishown", 0);
             if (!$authorisedonly && $publishown) {
                 return true;
             }
             // This involes TOO many database queries in Joomla - one per category which can be a LOT
             /*
              $cats = JEVHelper::getAuthorisedCategories($user,'com_jevents', 'core.edit.state');
              if (in_array($row->_catid, $cats))
              return true;
             */
             $key = $row->catids() ? json_encode($row->catids()) : json_encode(intval($row->catid()));
             if (!isset($authdata_editstate[$key])) {
                 $authdata_editstate[$key] = JEVHelper::authoriseCategories('core.edit.state', $key, $user);
             }
             return $authdata_editstate[$key];
         }
     }
     if ($user->id > 0 && $row->catid() > 0) {
         $key = $row->catids() ? json_encode($row->catids()) : json_encode(intval($row->catid()));
         if (!isset($authdata_editstate[$key])) {
             $authdata_editstate[$key] = JEVHelper::authoriseCategories('core.edit.state', $key, $user);
         }
         return $authdata_editstate[$key];
     }
     return false;
 }
Exemplo n.º 10
0
 function listIcalEventRepeatsByCreator($creator_id, $limitstart, $limit, $orderby = "rpt.startrepeat")
 {
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $cfg =& JEVConfig::getInstance();
     $rows_per_page = $limit;
     if (empty($limitstart) || !$limitstart) {
         $limitstart = 0;
     }
     $limit = "";
     if ($limitstart > 0 || $rows_per_page > 0) {
         $limit = "LIMIT {$limitstart}, {$rows_per_page}";
     }
     // process the new plugins
     // get extra data and conditionality from plugins
     $extrawhere = array();
     $extrajoin = array();
     $extrafields = "";
     // must have comma prefix
     $extratables = "";
     // must have comma prefix
     $needsgroup = false;
     $catwhere = "\n WHERE ev.catid IN(" . $this->accessibleCategoryList() . ")";
     $params = JComponentHelper::getParams("com_jevents");
     if ($params->get("multicategory", 0)) {
         $extrajoin[] = "\n #__jevents_catmap as catmap ON catmap.evid = rpt.eventid";
         $extrajoin[] = "\n #__categories AS catmapcat ON catmap.catid = catmapcat.id";
         $extrafields .= ", GROUP_CONCAT(DISTINCT catmap.catid SEPARATOR ',') as catids";
         $extrawhere[] = " catmapcat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user));
         $extrawhere[] = " catmap.catid IN(" . $this->accessibleCategoryList() . ")";
         $needsgroup = true;
         $catwhere = "\n WHERE 1 ";
     }
     $adminCats = JEVHelper::categoryAdmin();
     $where = '';
     if ($creator_id == 'ADMIN') {
         $where = "";
     } else {
         if ($adminCats && count($adminCats) > 0) {
             if ($params->get("multicategory", 0)) {
                 $adminCats = " OR catmap.catid IN(" . implode(",", $adminCats) . ")";
             } else {
                 $adminCats = " OR ev.catid IN(" . implode(",", $adminCats) . ")";
             }
             $where = " AND ( ev.created_by = " . $user->id . $adminCats . ")";
         } else {
             $where = " AND ev.created_by = '{$creator_id}' ";
         }
     }
     $frontendPublish = JEVHelper::isEventPublisher();
     $filters = jevFilterProcessing::getInstance(array("published", "justmine", "category", "startdate", "search"));
     $filters->setWhereJoin($extrawhere, $extrajoin);
     $needsgroup = false;
     $dispatcher =& JDispatcher::getInstance();
     $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup));
     $extrajoin = count($extrajoin) ? " \n LEFT JOIN " . implode(" \n LEFT JOIN ", $extrajoin) : '';
     $extrawhere = count($extrawhere) ? ' AND ' . implode(' AND ', $extrawhere) : '';
     $needsgroup = false;
     $dispatcher =& JDispatcher::getInstance();
     $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup));
     if ($frontendPublish) {
         // TODO fine a single query way of doing this !!!
         $query = "SELECT rp_id" . "\n FROM #__jevents_repetition as rpt " . "\n LEFT JOIN #__jevents_vevent as ev ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . $extrawhere . $where . "\n  AND icsf.state=1" . "\n GROUP BY rpt.rp_id" . "\n ORDER BY " . ($orderby != "" ? $orderby : "rpt.startrepeat ASC") . "\n {$limit}";
         $db->setQuery($query);
         $rplist = $db->loadResultArray();
         //echo $db->explain();
         $rplist = implode(',', array_merge(array(-1), $rplist));
         $query = "SELECT ev.*, rpt.*, rr.*, det.*, ev.state as published" . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat  ) as ydn, MONTH(rpt.endrepeat   ) as mdn, DAYOFMONTH(rpt.endrepeat   ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat  ) as hdn, MINUTE(rpt.endrepeat   ) as mindn, SECOND(rpt.endrepeat   ) as sdn" . "\n FROM #__jevents_vevent as ev " . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n AND rpt.eventid = ev.ev_id" . "\n AND rpt.rp_id IN({$rplist})" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . $extrawhere . $where . "\n  AND icsf.state=1" . "\n GROUP BY rpt.rp_id" . "\n ORDER BY " . ($orderby != "" ? $orderby : "rpt.startrepeat ASC");
     } else {
         // TODO fine a single query way of doing this !!!
         $query = "SELECT rp_id" . "\n FROM #__jevents_vevent as ev " . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . $extrawhere . "\n AND icsf.state=1" . $where . "\n GROUP BY rpt.rp_id" . "\n ORDER BY " . ($orderby != "" ? $orderby : "rpt.startrepeat ASC") . "\n {$limit}";
         $db->setQuery($query);
         $rplist = $db->loadResultArray();
         $rplist = implode(',', array_merge(array(-1), $rplist));
         $query = "SELECT ev.*, rpt.*, rr.*, det.*, ev.state as published" . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat  ) as ydn, MONTH(rpt.endrepeat   ) as mdn, DAYOFMONTH(rpt.endrepeat   ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat  ) as hdn, MINUTE(rpt.endrepeat   ) as mindn, SECOND(rpt.endrepeat   ) as sdn" . "\n FROM #__jevents_vevent as ev " . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n AND rpt.rp_id IN({$rplist})" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . $where . "\n AND icsf.state=1" . $extrawhere . "\n GROUP BY rpt.rp_id" . "\n ORDER BY " . ($orderby != "" ? $orderby : "rpt.startrepeat ASC");
     }
     $db->setQuery($query);
     $icalrows = $db->loadObjectList();
     $icalcount = count($icalrows);
     for ($i = 0; $i < $icalcount; $i++) {
         // convert rows to jIcalEvents
         $icalrows[$i] = new jIcalEventRepeat($icalrows[$i]);
     }
     return $icalrows;
 }
Exemplo n.º 11
0
 protected function toggleICalEventPublish($cid, $newstate)
 {
     $is_event_editor = JEVHelper::isEventPublisher();
     if (!$is_event_editor) {
         throw new Exception(JText::_('ALERTNOTAUTH'), 403);
         return false;
     }
     parent::toggleICalEventPublish($cid, $newstate);
 }
Exemplo n.º 12
0
 /**
  * Test to see if user can publish event
  *
  * @param unknown_type $row
  * @param unknown_type $user
  * @return unknown
  */
 function canPublishEvent($row, $user = null)
 {
     // TODO make this call a plugin
     if ($user == null) {
         $user =& JFactory::getUser();
     }
     // are we authorised to do anything with this category or calendar
     $jevuser =& JEVHelper::getAuthorisedUser();
     if ($row->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
         $allowedcals = explode("|", $jevuser->calendars);
         if (!in_array($row->_icsid, $allowedcals)) {
             return false;
         }
     }
     if ($row->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
         $allowedcats = explode("|", $jevuser->categories);
         if (!in_array($row->_catid, $allowedcats)) {
             return false;
         }
     }
     if (JVersion::isCompatible("1.6.0")) {
         $cats = $user->getAuthorisedCategories('com_jevents', 'core.publish');
         if (in_array($row->_catid, $cats)) {
             return true;
         }
     }
     // can publish all?
     if (JEVHelper::isEventPublisher(true)) {
         return true;
     } else {
         if ($row->created_by() == $user->id) {
             // Use generic helper method that can call the plugin to see if user can publish any events
             $isEventPublisher = JEVHelper::isEventPublisher();
             if ($isEventPublisher) {
                 return true;
             }
             $jevuser =& JEVHelper::getAuthorisedUser();
             if (!is_null($jevuser)) {
                 return $jevuser->canpublishown;
             }
             $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
             $authorisedonly = $params->get("authorisedonly", 1);
             $publishown = $params->get("jevpublishown", 0);
             if (!$authorisedonly && $publishown) {
                 return true;
             }
             if (JVersion::isCompatible("1.6.0")) {
                 $cats = $user->getAuthorisedCategories('com_jevents', 'core.edit.state');
                 if (in_array($row->_catid, $cats)) {
                     return true;
                 }
             }
         }
     }
     if (JVersion::isCompatible("1.6.0")) {
         if ($user->id > 0 && $row->catid() > 0) {
             return $user->authorise('core.edit.state', 'com_jevents.category.' . $row->catid());
         }
     }
     return false;
 }