function getSharedIds() { // retrieve calendar data $calendar = new CalendarShareCollection(new CalendarShare()); $sh = new SearchHandler($calendar, false); $sh->addConstraint(new Constraint('username', '=', EGS_USERNAME)); $calendar->load($sh); $calendar_id = array(); foreach ($calendar as $key => $value) { $calendar_id[$value->calendar_id] = $value->calendar_id; } return $calendar_id; }
function edit_gcal() { $flash = Flash::Instance(); $calendar = new Calendar(); $calendar->load($this->_data['id']); $this->view->set('calendar', $calendar); if (!$calendar->isOwner($this->_data['id'])) { $flash->addError("You cannot edit a calendar that doesn't belong to you"); sendTo('calendars', 'index', 'calendar'); } $colours = $calendar->getEnumOptions('colour'); $this->view->set('colours', $colours); $user = new User(); $users = $user->getAll(); foreach ($users as $key => $value) { if ($value != EGS_USERNAME) { $usernames[$key] = $value; } } $this->view->set('users', $usernames); $shared_users = array(); $shared_user = new CalendarShareCollection(new CalendarShare()); $sh = new SearchHandler($shared_user, false); $sh->addConstraint(new Constraint('calendar_id', '=', $this->_data['id'])); $sh->addConstraint(new Constraint('username', '!=', EGS_USERNAME)); $sh->setFields(array('id', 'calendar_id', 'username')); $shared_user->load($sh); if (count($shared_user->getArray()) > 0) { foreach ($shared_user->getArray() as $key => $value) { $shared_users[$key] = $value['username']; } } $this->view->set('shared_users', $shared_users); $sidebar = new SidebarController($this->view); $sidebar->addList('calendar_views', array('view_calendar' => array('link' => array('module' => 'calendar'), 'tag' => 'View Calendar'))); $sidebar->addList('calendars', array('manage_calendars' => array('link' => array('module' => 'calendar', 'controller' => 'calendars', 'action' => 'index'), 'tag' => 'Manage Calendars'))); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); parent::_new(); }
public function delete() { $flash = Flash::Instance(); $ce = $this->_uses['CalendarEvent']; $ce->load($this->_data['id']); if ($ce->owner != EGS_USERNAME) { $csc = new CalendarShareCollection(new CalendarShare()); $sh = new SearchHandler($csc); $sh->addConstraint(new Constraint('username', '=', EGS_USERNAME)); $csc->load($sh); if ($csc->count() == 0) { $flash->addError('You do not have permission to edit that entry'); sendBack(); } } parent::delete('CalendarEvent'); sendTo('index', 'index', array('calendar')); }