Пример #1
0
 /**
  * @requiresRight id WRITE
  */
 public function index()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     $revisions = RepositoryProxy::getRevisions($resource->getUri());
     $returnRevision = array();
     foreach ($revisions as $revision) {
         $returnRevision[] = array('id' => $revision->getVersion(), 'modified' => \tao_helpers_Date::displayeDate($revision->getDateCreated()), 'author' => UserHelper::renderHtmlUser($revision->getAuthorId()), 'message' => _dh($revision->getMessage()));
     }
     $this->setData('resourceLabel', _dh($resource->getLabel()));
     $this->setData('id', $resource->getUri());
     $this->setData('revisions', $returnRevision);
     $this->setView('History/index.tpl');
 }
<?php

/**
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; under version 2
 * of the License (non-upgradable).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Copyright (c) 2015 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
 *
 *
 */
use oat\taoRevision\model\RepositoryProxy;
use oat\taoRevision\model\rds\Repository;
$config = array('persistence' => 'default');
RepositoryProxy::setImplementation(new Repository($config));
 /**
  * Helper to determin suitable next version nr
  * 
  * @param string $resourceId
  * @return number
  */
 protected static function getNextVersion($resourceId)
 {
     $candidate = 0;
     foreach (RepositoryProxy::getRevisions($resourceId) as $revision) {
         $version = $revision->getVersion();
         if (is_numeric($version) && $version > $candidate) {
             $candidate = $version;
         }
     }
     return $candidate + 1;
 }