Select Git revision
StudipTransformFormat.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Elmar Ludwig authored
Closes #1601 Merge request studip/studip!1159
Elmar Ludwig authoredCloses #1601 Merge request studip/studip!1159
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CoursewareContext.php 1.32 KiB
<?php
namespace Studip\Activity;
class CoursewareContext extends Context
{
public function __construct($courseware, $observer)
{
$this->courseware = $courseware;
$this->observer = $observer;
$id = explode('_' , $this->courseware->id);
$this->context = $id[0];
$this->range_id = $id[1];
}
protected function getProvider()
{
$this->addProvider('Studip\Activity\CoursewareProvider');
return $this->provider;
}
public function getRangeId()
{
return $this->range_id;
}
public function getContextType()
{
if ($this->context === 'user') {
return \Context::USER;
}
if ($this->context === 'course') {
return \Context::COURSE;
}
throw new \UnexpectedValueException("Unknown context type {$this->context}");
}
public function getContextFullname($format = 'default')
{
if ($this->context === 'user') {
$user = \User::find($this->range_id);
return $user->getFullname($format);
}
if ($this->context === 'course') {
$course = \Course::find($this->range_id);
return $course->getFullname($format);
}
throw new \UnexpectedValueException("Unknown context {$this->context}");
}
}