public function getDBCalendars() { if ($this->cached_data == null) { $calendars = GCalendarDBUtil::getAllCalendars(); $this->cached_data = $calendars; } return $this->cached_data; }
protected function getOptions() { $accounts = GCalendarDBUtil::getAllCalendars(); $options = array(); foreach ($accounts as $account) { $options[] = JHtml::_('select.option', $account->id, $account->name); } $options = array_merge(parent::getOptions(), $options); return $options; }
public function getDBCalendars() { if ($this->cached_data == null) { $calendarids = $this->getState('calendarids'); if (!empty($calendarids)) { $this->cached_data = GCalendarDBUtil::getCalendars($calendarids); } else { $this->cached_data = GCalendarDBUtil::getAllCalendars(); } } return $this->cached_data; }
/** * Returns all calendars in the database. The returned * rows contain an additional attribute selected which is set * to true when the specific calendar is mentioned in the * parameters property calendarids. * * @return the calendars specified in the database */ function getDBCalendars() { if ($this->cached_data == null) { $params = $this->getState('parameters.menu'); $calendarids = null; if ($params != null) { $calendarids = $params->get('calendarids'); } $this->cached_data = GCalendarDBUtil::getAllCalendars(); } return $this->cached_data; }
public static function getCalendars($params) { $calendarids = null; if ($params != null) { $calendarids = $params->get('calendarids'); if (empty($calendarids)) { return GCalendarDBUtil::getAllCalendars(); } return GCalendarDBUtil::getCalendars($calendarids); } else { return GCalendarDBUtil::getAllCalendars(); } }
/** * Returns the database entries as objects with the column fields as * variable (according to the joomla table framework). * * @param $calendarIDs the calendar ID's to find */ function getCalendars($calendarIDs) { $condition = ''; if (!empty($calendarIDs)) { if (is_array($calendarIDs)) { $condition = 'id IN ( ' . rtrim(implode(',', $calendarIDs), ',') . ')'; } else { $condition = 'id = ' . (int) rtrim($calendarIDs, ','); } } else { return GCalendarDBUtil::getAllCalendars(); } $db =& JFactory::getDBO(); $query = "SELECT id, calendar_id, name, color, magic_cookie FROM #__gcalendar where " . $condition; $db->setQuery($query); $results = $db->loadObjectList(); return $results; }
function checkDB() { $tmp = array(); $results = GCalendarDBUtil::getAllCalendars(); if (empty($results)) { $tmp[] = array('name' => 'DB Entries Check', 'description' => 'No DB data found.', 'status' => 'ok', 'solution' => ''); } else { foreach ($results as $result) { $events = GCalendarZendHelper::getEvents($result, null, null, 5); if ($events == null) { $message = array_shift(JFactory::getApplication()->getMessageQueue()); if (key_exists('message', $message)) { $message = $message['message']; } else { $message = print_r($message, true); } $desc = "An error occurred when reading calendar " . $result->name . ":<br>" . $message; $solution = "<ul><li>If the error is the same as in the connection test use the solution described there.</li>"; $solution .= "<li>Please check your shared settings of the calendar and the events, "; $solution .= "if you do not share your calendar with the public the <a href=\"http://code.google.com/apis/calendar/docs/2.0/developers_guide_protocol.html#AuthMagicCookie\">magic cookie</a> field must be set.</li>"; $solution .= "<li><b>If the problem still exists check the forum at <a href=\"http://g4j.digital-peak.com\">g4j.digital-peak.com</a>.</b></li></ul>"; $status = 'failure'; } else { if (empty($events)) { $solution = 'Create events in the calendar.'; $status = 'warning'; $desc = 'GCalendar could check the events without any problems from calendar ' . $result->name . '. But the result was empty.'; } else { $solution = ''; $status = 'ok'; $desc = 'GCalendar could read the events without any problems from calendar ' . $result->name . '.'; } } // $desc .= $desc.'<br><a href="'.$feed->feed_url.'" target="_blank">Here</a> is the url of the generated google calendar feed.'; $tmp[] = array('name' => $result->name . ' Check', 'description' => $desc, 'status' => $status, 'solution' => $solution); } } return $tmp; }
public static function getItemId($calendarId, $strict = false) { $component = JComponentHelper::getComponent('com_gcalendar'); $menu = JFactory::getApplication()->getMenu(); $items = $menu->getItems('component_id', $component->id); $default = null; if (is_array($items)) { foreach ($items as $item) { $default = $item; $paramsItem = $menu->getParams($item->id); $calendarids = $paramsItem->get('calendarids'); if (empty($calendarids)) { $results = GCalendarDBUtil::getAllCalendars(); if ($results) { $calendarids = array(); foreach ($results as $result) { $calendarids[] = $result->id; } } } $contains_gc_id = FALSE; if ($calendarids) { if (is_array($calendarids)) { $contains_gc_id = in_array($calendarId, $calendarids); } else { $contains_gc_id = $calendarId == $calendarids; } } if ($contains_gc_id) { return $item->id; } } } if ($strict = true) { return null; } return $default; }
/** * Returns a valid Item ID for the given calendar id. If none is found * NULL is returned. * * @param $cal_id * @return the item id */ function getItemId($cal_id) { $component =& JComponentHelper::getComponent('com_gcalendar'); $menu =& JSite::getMenu(); $items = $menu->getItems('componentid', $component->id); if (is_array($items)) { foreach ($items as $item) { $paramsItem =& $menu->getParams($item->id); $calendarids = $paramsItem->get('calendarids'); if (empty($calendarids)) { $results = GCalendarDBUtil::getAllCalendars(); if ($results) { $calendarids = array(); foreach ($results as $result) { $calendarids[] = $result->id; } } } $contains_gc_id = FALSE; if ($calendarids) { if (is_array($calendarids)) { $contains_gc_id = in_array($cal_id, $calendarids); } else { $contains_gc_id = $cal_id == $calendarids; } } if ($contains_gc_id) { return $item->id; } } } return null; }
$document->addStyleSheet(JURI::base() . 'components/com_gcalendar/libraries/jquery/fancybox/jquery.fancybox-1.3.4.css'); $document->addStyleSheet(JURI::base() . 'components/com_gcalendar/libraries/jquery/ext/tipTip.css'); $document->addStyleDeclaration("#ui-datepicker-div { z-index: 15 !important; }"); $document->addStyleSheet(JURI::base() . 'components/com_gcalendar/views/gcalendar/tmpl/gcalendar.css'); $params = $this->params; $theme = $params->get('theme', ''); if (JRequest::getVar('theme', null) != null) { $theme = JRequest::getWord('theme', null); } if (!empty($theme)) { $document->addStyleSheet(JURI::base() . 'components/com_gcalendar/libraries/jquery/themes/' . $theme . '/jquery-ui.custom.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_gcalendar/libraries/jquery/themes/aristo/jquery-ui.custom.css'); } $calendarids = $this->calendarids; $allCalendars = GCalendarDBUtil::getAllCalendars(); $calsSources = "\t\teventSources: [\n"; foreach ($allCalendars as $calendar) { $cssClass = "gcal-event_gccal_" . $calendar->id; $color = GCalendarUtil::getFadedColor($calendar->color); $document->addStyleDeclaration("." . $cssClass . ",.fc-agenda " . $cssClass . " .fc-event-time, ." . $cssClass . " a, ." . $cssClass . " div{background-color: " . $color . " !important; border-color: #" . $calendar->color . "; color: white;}"); if (empty($calendarids) || in_array($calendar->id, $calendarids)) { $value = html_entity_decode(JRoute::_('index.php?option=com_gcalendar&view=jsonfeed&format=raw&gcid=' . $calendar->id . '&Itemid=' . JRequest::getInt('Itemid'))); $calsSources .= "\t\t\t\t'" . $value . "',\n"; } } $calsSources = trim($calsSources, ",\n"); $calsSources .= "\t],\n"; $defaultView = $params->get('defaultView', 'month'); if ($params->get('defaultView', 'month') == 'week') { $defaultView = 'agendaWeek';