-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set acls for videos, playlists and series
- Loading branch information
Showing
9 changed files
with
265 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
require_once __DIR__.'/../bootstrap.php'; | ||
require_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
use Opencast\Models\Config; | ||
use Opencast\Models\VideoSync; | ||
use Opencast\Models\Videos; | ||
use Opencast\Models\ScheduleHelper; | ||
use Opencast\Models\REST\ApiEventsClient; | ||
use Opencast\Models\REST\ApiPlaylistsClient; | ||
use Opencast\Models\REST\Config as OCConfig; | ||
|
||
class OpencastSyncAcls extends CronJob | ||
{ | ||
|
||
public static function getName() | ||
{ | ||
return _('Opencast - Synchronisiert ACLs für Events'); | ||
} | ||
|
||
public static function getDescription() | ||
{ | ||
return _('Opencast: Synchronisiert ACLs für Events'); | ||
} | ||
|
||
/** | ||
* Iterate over all videos andf playlists from opencast known to Stud.IP | ||
* and set the correct ACLs accordingly | ||
* | ||
* @param string $last_result | ||
* @param array $parameters | ||
* | ||
* @return void | ||
*/ | ||
public function execute($last_result, $parameters = array()) | ||
{ | ||
$db = DBManager::get(); | ||
|
||
// iterate over all active configured oc instances | ||
$configs = Config::findBySql('active = 1'); | ||
|
||
foreach ($configs as $config) { | ||
// check, if this opencast instance is accessible | ||
$version = false; | ||
|
||
echo 'working on config '. $config->id ."\n"; | ||
$version = OCConfig::getOCBaseVersion($config->id); | ||
|
||
if (!$version) { | ||
echo 'cannot connect to opencast, skipping!' ."\n"; | ||
continue; | ||
} else { | ||
echo "found opencast with version $version, continuing\n"; | ||
} | ||
|
||
// update endpoints, just to make sure | ||
$config->updateEndpoints(); | ||
|
||
// call opencast to get all event ids | ||
$api_client = ApiEventsClient::getInstance($config['id']); | ||
|
||
foreach ($api_client->getAll() as $event) { | ||
// only add videos / reinspect videos if they are readily processed | ||
if ($event->status == 'EVENTS.EVENTS.STATUS.PROCESSED') { | ||
// check if video exists in Stud.IP | ||
$video = Videos::findByEpisode($event->identifier); | ||
|
||
if ($video->config_id != $config->id) { | ||
echo 'config id mismatch for Video with id: '. $video->id .", $config->id <> {$video->config_id}\n"; | ||
continue; | ||
} | ||
|
||
Videos::checkEventACL(null, null, $video); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.