/** * Add this item into a particular changeset */ public function addToChangeset() { // We only add content into changesets that exists already - this is because until it exists, it doesn't // have an ID, meaning the relationship can't be created. From a usage standpoint this is okay... not ideal, // but users will always change something about a default created page before wanting it published (it also // means that non-modified default content doesn't get accidentally published...) $oid = $this->owner->ID; $mid = Member::currentUserID(); if (!$this->owner->ID || !Member::currentUserID()) { return; } // first see if it's in an active changeset already $changeset = $this->getCurrentChangeset(); if ($changeset) { return; } // if not, get the current user's changeset try { $changeset = $this->changesetService->getChangesetForUser(); if (!$changeset) { $changeset = $this->changesetService->createChangeset(sprintf(_t('Changesets.DEFAULT_TITLE', '%s started at %s'), Member::currentUser()->getTitle(), date('Y-m-d H:i:s'))); } if ($changeset) { $changeset->addItem($this->owner); } } catch (Exception $e) { SS_Log::log($e, SS_Log::ERR); } }