/**
  * Saves a new version.
  *
  * @param EntryModel $entry
  *
  * @return bool
  */
 public function saveVersion(EntryModel $entry)
 {
     // Get the total number of existing versions for this entry/locale
     $totalVersions = craft()->db->createCommand()->from('entryversions')->where(array('and', 'entryId = :entryId', 'locale = :locale'), array(':entryId' => $entry->id, ':locale' => $entry->locale))->count('id');
     $versionRecord = new EntryVersionRecord();
     $versionRecord->entryId = $entry->id;
     $versionRecord->sectionId = $entry->sectionId;
     $versionRecord->creatorId = craft()->userSession->getUser() ? craft()->userSession->getUser()->id : $entry->authorId;
     $versionRecord->locale = $entry->locale;
     $versionRecord->num = $totalVersions + 1;
     $versionRecord->data = $this->_getRevisionData($entry);
     $versionRecord->notes = $entry->revisionNotes;
     return $versionRecord->save();
 }
 /**
  * Saves a new versoin.
  *
  * @param EntryModel $entry
  * @return bool
  */
 public function saveVersion(EntryModel $entry)
 {
     $versionRecord = new EntryVersionRecord();
     $versionRecord->entryId = $entry->id;
     $versionRecord->sectionId = $entry->sectionId;
     $versionRecord->creatorId = craft()->userSession->getUser()->id;
     $versionRecord->locale = $entry->locale;
     $versionRecord->data = $this->_getRevisionData($entry);
     return $versionRecord->save();
 }