/**
     * Returns the number of this resource that are not booked during an event
     * time.
     *
     * @param  CalendarDateTime $time
     * @return bool|int
     */
    public function getAvailableForEvent($time)
    {
        if ($this->Type == 'Unlimited') {
            return true;
        }
        $start = $time->getStartTimestamp();
        $end = $time->getEndTimestamp();
        // First just get simple non-recurring bookings, often this will be
        // enough to check if a resource is available.
        $dateFilter = sprintf('"StartDate" BETWEEN \'%1$s\' AND \'%2$s\'
			OR "EndDate" BETWEEN \'%1$s\' AND \'%2$s\'
			OR ("StartDate" < \'%1$s\' AND "EndDate" > \'%2$s\')', date('Y-m-d', $start), date('Y-m-d', $end));
        $filter = "\"CalendarEvent\".\"Recursion\" = 0 AND \"CalendarDateTimeID\" <> {$time->ID} AND ({$dateFilter})";
        $bookings = $this->Events($filter, null, 'INNER JOIN "CalendarEvent" ON "CalendarEvent"."ID" = "CalendarDateTime"."EventID"');
        $bookings = $bookings->toArray('ID');
        // Since the event calendar doesn't use a proper date time storage, we
        // need to manually filter events again here.
        foreach ($bookings as $id => $booking) {
            if ($booking->getEndTimestamp() < $start || $booking->getStartTimestamp() > $end) {
                unset($bookings[$id]);
            }
        }
        if ($bookings && $this->Type == 'Single') {
            return false;
        }
        // Now also load all the recurring events, and check if they occur on
        // this day.
        $recurring = $this->Events(sprintf('"CalendarDateTimeID" <> %d
				AND "CalendarEvent"."Recursion" = 1
				AND ("EndDate" IS NULL OR "EndDate" > \'%s\')
				AND ("StartDate" IS NULL OR "StartDate" < \'%s\')', $time->ID, date('Y-m-d', $start), date('Y-m-d', $end)), null, 'INNER JOIN "CalendarEvent" ON "CalendarEvent"."ID" = "CalendarDateTime"."EventID"');
        // Now loop through each day this event runs on, and check if any of the
        // events fall on it. If they do just push them onto the bookings set.
        foreach ($recurring as $datetime) {
            $counter = $start;
            while ($counter <= $end) {
                if ($counter > strtotime($datetime->EndDate)) {
                    break;
                }
                if ($datetime->Event()->recursionHappensOn($counter)) {
                    $bookings[$datetime->ID] = $datetime;
                    break;
                }
                $counter = sfTime::add($counter, 1, sfTime::DAY);
            }
        }
        if ($bookings && $this->Type == 'Single') {
            return false;
        }
        if (!count($bookings)) {
            return $this->Type == 'Limited' ? (int) $this->Quantity : true;
        }
        $quantity = (int) $this->Quantity;
        foreach ($bookings as $booking) {
            $quantity -= $booking->BookingQuantity;
        }
        return $quantity > 0 ? $quantity : false;
    }
Example #2
0
 /**
  * Constructor
  * 
  * @param string $date
  * @param array $data
  * @param int $year
  * @param int $month  display month, it can differ from a month in date
  */
 public function __construct($date, $data, $year, $month)
 {
     parent::__construct($date);
     $this->_data = $data;
     $this->_year = $year;
     $this->_displayMonth = $month;
 }
 public function getCMSFields()
 {
     $f = parent::getCMSFields();
     $f->insertBefore(new TextField('Title', _t('CalendarAnnouncement.TITLE', 'Title of announcement')), "StartDate");
     $f->insertBefore(new TextareaField('Content', _t('CalendarAnnouncement.CONTENT', 'Announcement content')), "StartDate");
     $this->extend('updateCMSFields', $f);
     return $f;
 }
 protected function _padUp()
 {
     $start = $this->_runner->format(self::FORMAT_DATE);
     $end = $this->_runner->ceil(CalendarDateTime::W)->format(self::FORMAT_DATE);
     $this->_runner->modify($start);
     while ($this->_runner->format(self::FORMAT_DATE) <= $end) {
         $this->_array[$this->_yearKey][$this->_monthKey][] = $this->_runner->format(self::FORMAT_DATE);
         $this->_runner->addDay();
     }
     $this->_runner->modify($start)->addDay();
 }
 public function getProjectConfiguration(BedrockSetting $settings)
 {
     if ($format = $settings->getDateFormat()) {
         CalendarDateTime::set_date_format($format);
     }
     if ($months = $settings->getDefaultFutureMonths()) {
         self::$defaultFutureMonths = $months;
     }
     if ($time = $settings->getTimeFormat()) {
         CalendarDateTime::set_time_format($time);
     }
 }
 public function hydrate(CalendarDateTime $dt, Calendar $calendar)
 {
     $this->CachedCalendarID = $calendar->ID;
     foreach ($dt->db() as $field => $type) {
         $this->{$field} = $dt->{$field};
     }
     foreach ($dt->has_one() as $field => $type) {
         $this->{$field . "ID"} = $dt->{$field . "ID"};
     }
     $this->DateRange = $dt->DateRange();
     $this->TimeRange = $dt->TimeRange();
     $this->ICSLink = $dt->ICSLink();
     $this->Title = $dt->getTitle();
     $this->Content = $dt->getContent();
     return $this;
 }
 public function __construct($items = null)
 {
     parent::__construct();
     if (CalendarDateTime::dmy()) {
         $firstName = "Day";
         $firstFunc = "getDaysMap";
         $secondName = "Month";
         $secondFunc = "getMonthsMap";
     } else {
         $firstName = "Month";
         $firstFunc = "getMonthsMap";
         $secondName = "Day";
         $secondFunc = "getDaysMap";
     }
     $this->addFilterField(new FieldGroup(new DropdownField('Start' . $firstName, _t('CalendarFilterFieldSet.START', 'Start'), CalendarUtil::$firstFunc()), new DropdownField('Start' . $secondName, '', CalendarUtil::$secondFunc()), new DropdownField('StartYear', '', CalendarUtil::getYearsMap())));
     $this->addFilterField(new FieldGroup(new DropdownField('End' . $firstName, _t('CalendarFilterFieldSet.END', 'End'), CalendarUtil::$firstFunc()), new DropdownField('End' . $secondName, '', CalendarUtil::$secondFunc()), new DropdownField('EndYear', '', CalendarUtil::getYearsMap())));
 }
 /**
  * Notifies the users of any changes made to the event.
  */
 protected function onAfterWrite()
 {
     parent::onAfterWrite();
     // If any details have changed and the system is configured to send out
     // a notification email then do so.
     $email = $this->Event()->EmailNotifyChanges;
     $changed = $this->getChangedFields(false, 2);
     $notify = explode(',', $this->Event()->NotifyChangeFields);
     $notify = array_intersect_key($changed, array_flip($notify));
     if (!$email || !$changed || !$notify) {
         return;
     }
     $emails = DB::query(sprintf('SELECT "Email", "Name" FROM "EventRegistration" WHERE "TimeID" = %d ' . 'AND "Status" = \'Valid\' GROUP BY "Email"', $this->ID));
     if (!($emails = $emails->map())) {
         return;
     }
     $changed = new DataObjectSet();
     foreach ($notify as $field => $data) {
         $changed->push(new ArrayData(array('Label' => singleton('EventRegistration')->fieldLabel($field), 'Before' => $data['before'], 'After' => $data['after'])));
     }
     $email = new Email();
     $email->setSubject(sprintf('Event Details Changed For %s (%s)', $this->EventTitle(), SiteConfig::current_site_config()->Title));
     $email->setTemplate('EventRegistrationChangeEmail');
     $email->populateTemplate(array('Time' => $this, 'SiteConfig' => SiteConfig::current_site_config(), 'Changed' => $changed, 'Link' => $this->Link()));
     // We need to send the email for each registration individually.
     foreach ($emails as $address => $name) {
         $_email = clone $email;
         $_email->setTo($address);
         $_email->populateTemplate(array('Name' => $name));
         $_email->send();
     }
 }
 protected function _buildArray()
 {
     $this->_runner = $this->_from;
     $this->_yearKey = $this->_runner->getYear();
     $this->_monthKey = $this->_runner->getMonth();
     $this->_array[$this->_yearKey] = array();
     $dayIndex = $this->_runner->getDay() - 1;
     while ($this->_runner->format(self::FORMAT_DATE) <= $this->_to) {
         if ($this->_runner->isFirstDayOfMonth()) {
             $dayIndex = $this->_runner->getDay() - 1;
             if ($this->_runner->isFirstDayOfYear()) {
                 $this->_yearKey = $this->_runner->getYear();
                 $this->_array[$this->_yearKey] = array();
             }
             $this->_monthKey = $this->_runner->getMonth();
             $this->_array[$this->_yearKey][$this->_monthKey] = array();
         }
         $this->_array[$this->_yearKey][$this->_monthKey][$dayIndex] = $this->_runner->format(self::FORMAT_DATE);
         $this->_runner->addDay();
         $dayIndex++;
     }
 }
 /**
  * Import events created with: http://www.myeventon.com/
  * into a 'CalendarEvent' Page type from Unclecheese's "Event Calendar" module
  *
  * Step 2) Update the page to 'CalendarEvent' page type and add event data appropriately
  */
 public function importEvents_MyEventOn_Step2($calendarHolder = null)
 {
     $this->logFunctionStart(__FUNCTION__);
     if (!class_exists('CalendarDateTime')) {
         throw new WordpressImportException(__FUNCTION__ . ' requires Unclecheese\'s "Event Calendar" module');
     }
     if (!CalendarDateTime::has_extension('WordpressImportDataExtension')) {
         throw new WordpressImportException('CalendarDateTime requires WordpressImportDataExtension.');
     }
     // Debug
     //Debug::dump($this->_db->getPosts('ajde_events', true)); exit;
     // Get the calendar holder the events should belong to.
     if ($calendarHolder === null) {
         $calendarHolder = Calendar::get()->filter(array('WordpressData' => '1'))->first();
         if (!$calendarHolder) {
             $calendarHolder = Calendar::create();
             $calendarHolder->Title = 'Wordpress Imported Events';
             $calendarHolder->URLSegment = 'events';
             $calendarHolder->WordpressData = 1;
             try {
                 $this->writeAndPublishRecord($calendarHolder);
             } catch (Exception $e) {
                 $this->log($calendarHolder, 'error', $e);
             }
         }
     }
     // Convert to CalendarEvent and attach relevant event data
     $existingWpRecords = singleton('Page')->WordpressRecordsByWordpressID();
     foreach ($this->_db->getPosts('ajde_events') as $wpData) {
         $wpID = $wpData['ID'];
         if (!isset($existingWpRecords[$wpID])) {
             $this->log('Unable to find Wordpress ID #' . $wpID, 'error');
             continue;
         }
         $record = $existingWpRecords[$wpID];
         $wpMeta = $this->_db->attachAndGetPostMeta($wpData);
         if ($record->ClassName !== 'CalendarEvent') {
             $record = $record->newClassInstance('CalendarEvent');
         }
         $record->ParentID = $calendarHolder->ID;
         $startDate = isset($wpMeta['evcal_srow']) && $wpMeta['evcal_srow'] ? (int) $wpMeta['evcal_srow'] : null;
         $endDate = isset($wpMeta['evcal_erow']) && $wpMeta['evcal_erow'] ? (int) $wpMeta['evcal_erow'] : null;
         if ($startDate && $endDate) {
             $subRecord = null;
             if ($record->exists()) {
                 $subRecord = $record->DateTimes()->find('WordpressID', $wpID);
             }
             if (!$subRecord) {
                 $subRecord = CalendarDateTime::create();
             }
             $subRecord->AllDay = isset($wpMeta['evcal_allday']) && $wpMeta['evcal_allday'] === 'yes';
             $subRecord->StartDate = date('Y-m-d', $startDate);
             $subRecord->StartTime = date('H:i:s', $startDate);
             $subRecord->EndDate = date('Y-m-d', $endDate);
             $subRecord->EndTime = date('H:i:s', $endDate);
             $subRecord->WordpressData = $record->WordpressData;
             if (!$subRecord->exists()) {
                 // NOTE(Jake): Will write $subRecord when $record is written if not exists, otherwise
                 //			   it will write it when it's ->add()'d
                 $record->DateTimes()->add($subRecord);
             } else {
                 try {
                     $record->write();
                     $this->log($record, 'changed');
                 } catch (Exception $e) {
                     $this->log($record, 'error', $e);
                 }
             }
         }
         // Support Addressable extension from Addressable module
         if (isset($wpMeta['evcal_location'])) {
             if ($record->Address !== $wpMeta['evcal_location']) {
                 $record->Address = $wpMeta['evcal_location'];
             }
         }
         // Support Geocodable extension from Addressable module
         if (isset($wpMeta['evcal_lat'])) {
             $record->Lat = $wpMeta['evcal_lat'];
         }
         if (isset($wpMeta['evcal_lng'])) {
             $record->Lng = $wpMeta['evcal_lng'];
         }
         $changedFields = $record->getChangedFields(true, DataObject::CHANGE_VALUE);
         unset($changedFields['Lat']);
         unset($changedFields['Lng']);
         if ($changedFields) {
             try {
                 $isPublished = isset($wpData['post_status']) && $wpData['post_status'] === 'publish' || $record->isPublished();
                 $this->writeAndPublishRecord($record, $isPublished);
             } catch (Exception $e) {
                 $this->log($record, 'error', $e);
             }
         } else {
             $this->log($record, 'nochange');
         }
     }
     $this->logFunctionEnd(__FUNCTION__);
 }
require_once Director::baseFolder() . '/event_calendar/code/sfTime.class.php';
require_once Director::baseFolder() . '/event_calendar/code/sfDate.class.php';
require_once Director::baseFolder() . '/event_calendar/code/sfDateTimeToolkit.class.php';
require_once Director::baseFolder() . '/event_calendar/code/CalendarUI.class.php';
if (!class_exists("DataObjectManager")) {
    user_error(_t('EventCalendar.DATAOBJECTMANAGER', 'Event Calendar requires the DataObjectManager module.'), E_USER_ERROR);
}
LeftAndMain::require_javascript('event_calendar/javascript/calendar_interface.js');
LeftAndMain::require_css('event_calendar/css/calendar_cms.css');
Object::add_extension('SiteTree', 'CalendarSiteTree');
Calendar::set_param('language', 'EN');
Calendar::set_param('timezone', 'US-Eastern');
CalendarDateTime::set_param('offset', '-04:00');
CalendarDateTime::set_date_format('dmy');
CalendarDateTime::set_time_format('24');
i18n::include_locale_file('event_calendar', 'en_US');
// Override to specify custom date templates. Falls back on lang file.
/**
 * Available date format keys
 
 	** Start Date **
	%{sWeekDayShort}    e.g. Mon
	%{sWeekDayFull}     e.g. Monday
	%{sDayNumFull}      e.g. 09
	%{sDayNumShort}		e.g. 9
	%{sDaySuffix}		e.g. th, rd, st
	%{sMonNumShort}		e.g. 8
	%{sMonNumFull}		e.g. 08
	%{sMonShort}		e.g. Oct
	%{sMonFull}			e.g. October
Example #12
0
 public function doSyncFromFeed($data, $form)
 {
     $feeds = $this->Feeds();
     foreach ($feeds as $feed) {
         $feedreader = new ICSReader($feed->URL);
         $events = $feedreader->getEvents();
         foreach ($events as $event) {
             // translate iCal schema into Match schema
             $uid = strtok($event['UID'], '@');
             if ($match = Match::get()->filter(array("UID" => $uid))->First()) {
                 $feedevent = $match;
             } else {
                 $feedevent = Match::create();
                 $feedevent->UID = $uid;
             }
             $feedevent->Title = $event['SUMMARY'];
             //Get opposition with some string fun
             $feedevent->Opposition = trim(str_replace(array("-", "Black Doris Rovers", "vs"), "", $event['SUMMARY']));
             if (preg_match('/Round/', $feedevent->Opposition)) {
                 $opp = explode(" ", $feedevent->Opposition);
                 $opp = array_slice($opp, 2);
                 $feedevent->Opposition = trim(implode(" ", $opp));
             }
             if (isset($event['DESCRIPTION']) && !empty($event['DESCRIPTION']) && $event['DESCRIPTION'] != " ") {
                 $scores = str_replace("Result\n", "", $event['DESCRIPTION']);
                 $scores = explode("-", $scores);
                 foreach ($scores as $score) {
                     $score = trim($score);
                     $bits = explode(" ", $score);
                     if (preg_match('/Black Doris Rovers/', $score)) {
                         $feedevent->BDRScore = end($bits);
                     } else {
                         $feedevent->OppositionScore = end($bits);
                     }
                 }
                 if (intval($feedevent->BDRScore) > intval($feedevent->OppositionScore)) {
                     $feedevent->Result = 'Win';
                 } elseif (intval($feedevent->BDRScore) < intval($feedevent->OppositionScore)) {
                     $feedevent->Result = 'Loss';
                 } else {
                     $feedevent->Result = 'Draw';
                 }
             } else {
                 $feedevent->BDRScore = NULL;
                 $feedevent->OppositionScore = NULL;
                 $feedevent->Result = NULL;
             }
             $startdatetime = $this->iCalDateToDateTime($event['DTSTART']);
             if (array_key_exists('DTEND', $event) && $event['DTEND'] != NULL) {
                 $enddatetime = $this->iCalDateToDateTime($event['DTEND']);
             } elseif (array_key_exists('DURATION', $event) && $event['DURATION'] != NULL) {
                 $enddatetime = $this->iCalDurationToEndTime($event['DTSTART'], $event['DURATION']);
             }
             $new = false;
             if ($feedevent->DateTimes()->Count() == 0) {
                 $cdt = CalendarDateTime::create();
                 $new = true;
             } else {
                 $cdt = $feedevent->DateTimes()->First();
             }
             $cdt->StartDate = $startdatetime->format('Y-m-d');
             $cdt->StartTime = $startdatetime->format('H:i:s');
             $cdt->EndDate = $enddatetime->format('Y-m-d');
             $cdt->EndTime = $enddatetime->format('H:i:s');
             if ($new == true) {
                 $feedevent->DateTimes()->add($cdt);
             } else {
                 $cdt->write();
             }
             $feedevent->ParentID = $this->ID;
             $feedevent->write();
             $feedevent->publish('Stage', 'Live');
         }
     }
     $form->sessionMessage('Sync Succeeded', 'good');
     $data = $this->data();
     $data->LastSyncDate = date("Y-m-d H:i:s");
     $data->write();
     $data->publish('Stage', 'Live');
     return $this->redirectBack();
 }
Example #13
0
 public static function get_time_format()
 {
     if ($timeFormat = CalendarDateTime::config()->time_format_override) {
         return $timeFormat;
     }
     return _t('CalendarDateTime.TIMEFORMAT', '24');
 }
    public function run($request)
    {
        Restrictable::set_enabled(false);
        Versioned::reading_stage('Stage');
        $admin = Security::findAnAdministrator();
        Session::set("loggedInAs", $admin->ID);
        $toPublish = array();
        $home = SiteTree::get()->filter('URLSegment', 'home')->first();
        if ($home) {
            $this->o("Home page already exists, _not_ bootstrapping");
            return;
        }
        $site = Multisites::inst()->getCurrentSite();
        $toPublish[] = $site;
        $dashboard = SiteDashboardPage::create(array('Title' => 'Dashboard', 'URLSegment' => 'dashboard', 'ParentID' => $site->ID));
        $dashboard->write();
        $this->o("Created Dashboard");
        $toPublish[] = $dashboard;
        $home = RedirectorPage::create(array('Title' => 'Home', 'URLSegment' => 'home', 'ParentID' => $site->ID));
        $home->LinkToID = $dashboard->ID;
        $home->write();
        $toPublish[] = $home;
        $this->o("Created homepage");
        $group = Group::create(array('Title' => 'All members'));
        $events = Calendar::create(array('Title' => 'Events', 'URLSegment' => 'events', 'ParentID' => $site->ID));
        $events->write();
        $toPublish[] = $events;
        $dummyEvent = CalendarEvent::create(array('Title' => 'Sample event', 'ParentID' => $events->ID));
        $dummyEvent->write();
        $toPublish[] = $dummyEvent;
        $dateTime = CalendarDateTime::create(array('StartDate' => strtotime('+1 week'), 'AllDay' => 1, 'EventID' => $dummyEvent->ID));
        $dateTime->write();
        $files = FileListingPage::create(array('Title' => 'File Listing', 'ParentID' => $site->ID));
        $files->write();
        $toPublish[] = $files;
        $news = MediaHolder::create(array('Title' => 'News', 'MediaTypeID' => 3, 'ParentID' => $site->ID));
        $news->write();
        $toPublish[] = $news;
        $text = <<<WORDS
\t\t\t<p>Oh no! Pull a sickie, this epic cuzzie is as rip-off as a snarky morepork. Mean while, in behind the 
\t\t\t\tbicycle shed, Lomu and The Hungery Caterpilar were up to no good with a bunch of cool jelly tip icecreams. 
\t\t\t\t\tThe flat stick force of his chundering was on par with Rangi's solid rimu chilly bin. Put the jug on 
\t\t\twill you bro, all these hard yakka utes can wait till later. The first prize for frying up goes to... 
\t\t\t\t\t\t\tsome uni student and his wicked wet blanket, what a egg. Bro, giant wekas are really tip-top good
\t\twith dodgy fellas, aye. You have no idea how nuclear-free our bung kiwis were aye. Every time</p><p>
\t\t\t\t\t\tI see those carked it wifebeater singlets it's like Castle Hill all over again aye, pissed 
\t\t\t\t\t\t\t\t\t\tas a rat. Anyway, Uncle Bully is just Mr Whippy in disguise, to find the true meaning of 
\t\t\t\t\t\t\t\t\t\t\tlife, one must start whale watching with the box of fluffies, mate. After the trotie
\t\t\t\t\t\t\t\t\t\t\t\tis jumped the ditch, you add all the heaps good whitebait fritters to 
\t\t\t\t\t\t\t\t\t\t\t\t\tthe paua you've got yourself a meal.</p><p>Technology has allowed
\t\t\t\t\t\t\t\t\t\t\t\t\t\tmint pukekos to participate in the global conversation of
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tchoice keas. The next Generation of pearler dole bludgers have already packed a sad over at the beach. What's the hurry The Topp Twins? There's plenty of twink sticks in that one episode of Tux Wonder Dogs, you know the one bro. The sausage sizzle holds the most sweet as community in the country.. A Taniwha was playing rugby when the random reffing the game event occured. Those bloody Jaffa's, this outrageously awesome seabed is as tapu as a naff bloke. Pavalova is definitely not Australian, you don't know his story, bro. Mean while, in the sleepout, Jim Hickey and Sir Edmond Hillary were up to no good with a bunch of beautiful whanaus. The stuffed force of his cruising for a brusing was on par with James Cook's pretty suss pikelet. Put the jug on will you bro, all these buzzy stubbiess can wait till later.</p><p>The first prize for preparing the hungi goes to... Bazza and his rough as guts pohutukawa, what a sad guy. Bro, Monopoly money, from the New Zealand version with Queen Street and stuff are really hard case good with stink girl guide biscuits, aye. You have no idea how thermo-nuclear our sweet as mates were aye. Every time I see those fully sick packets of Wheetbix it's like Mt Cook all over again aye, see you right. Anyway, Mrs Falani is just Jonah Lomu in disguise, to find the true meaning of life, one must start rooting with the milk, mate. After the native vegetable is munted, you add all the beached as pieces of pounamu to the cheese on toast you've got yourself a meal. Technology has allowed primo kumaras to participate in the global conversation of sweet  gumboots. The next Generation of beaut manuses have already cooked over at Pack n' Save. What's the hurry Manus Morissette? There's plenty of onion dips in West Auckland. The tinny house holds the most same same but different community in the country.. Helen Clarke was packing a sad when the pretty suss whinging event occured. Eh, this stoked hongi is as cracker as a kiwi as chick.</p><p>Mean while, in the pub, Hercules Morse, as big as a horse and James and the Giant Peach were up to no good with a bunch of paru pinapple lumps. The bloody force of his wobbling was on par with Dr Ropata's crook lamington. Put the jug on will you bro, all these mean as foreshore and seabed issues can wait till later. The first prize for rooting goes to... Maui and his good as L&amp;P, what a hottie. Bro, marmite shortages are really shithouse good with hammered toasted sandwiches, aye. You have no idea how chocka full our chronic Bell Birds were aye. Every time I see those rip-off rugby balls it's like smoko time all over again aye, cook your own eggs Jake. Anyway, Cardigan Bay is just Spot, the Telecom dog in disguise, to find the true meaning of life, one must start pashing with the mince pie, mate.</p>
\t\t\t
WORDS;
        $story = MediaPage::create(array('Title' => 'Sample news item', 'Content' => $text, 'ParentID' => $news->ID));
        $story->write();
        $toPublish[] = $story;
        $group->write();
        $this->o("Created All Members group");
        $member = Member::create(array('FirstName' => 'Anon', 'Surname' => 'Ymous', 'Email' => '*****@*****.**'));
        $member->write();
        $member->Groups()->add($group);
        $site->Theme = 'ssau-minimalist';
        $site->LoggedInGroups()->add($group);
        $site->write();
        $this->o("Configured Site object");
        foreach ($toPublish as $item) {
            if (!is_object($item)) {
                print_r($item);
                continue;
            }
            $item->doPublish();
        }
        $this->o("Published everything");
        $message = <<<MSG
Your community system has been succesfully installed! Some things you might be interested in doing from this point are...

* Replying to this post! 
* Customising your dashboard
* Uploading some files and images to browse in the [file listing](file-listing)
* Create some events
* Add some RSS feeds to your Announcements dashlet (use the wrench to configure it!)
MSG;
        singleton('MicroBlogService')->createPost(null, $message, 'Installed!', 0, null, array('logged_in' => 1));
        Restrictable::set_enabled(true);
    }