Skip to content
Snippets Groups Projects
Commit d2bbb76d authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #78

parent 550ad14d
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 92 deletions
......@@ -9,14 +9,13 @@ class MyInstitutesController extends AuthenticatedController
if (!$GLOBALS['perm']->have_perm("root")) {
Navigation::activateItem('/browse/my_institutes');
}
$this->user_id = $GLOBALS['auth']->auth['uid'];
PageLayout::setHelpKeyword("Basis.MeineEinrichtungen");
PageLayout::setTitle(_("Meine Einrichtungen"));
$this->user_id = $GLOBALS['user']->id;
PageLayout::setHelpKeyword('Basis.MeineEinrichtungen');
PageLayout::setTitle(_('Meine Einrichtungen'));
}
public function index_action()
{
$this->institutes = MyRealmModel::getMyInstitutes();
if ($this->check_for_new($this->institutes)) {
......@@ -24,6 +23,11 @@ class MyInstitutesController extends AuthenticatedController
}
$this->nav_elements = MyRealmModel::calc_single_navigation($this->institutes);
$this->setupSidebar(
$this->institutes,
$this->check_for_new($this->institutes)
);
}
public function decline_inst_action($inst_id)
......@@ -31,22 +35,24 @@ class MyInstitutesController extends AuthenticatedController
$institut = Institute::find($inst_id);
$ticket_check = Seminar_Session::check_ticket(Request::option('studipticket'));
if (Request::option('cmd') != 'kill' && Request::get('cmd') != 'back') {
if (Request::option('cmd') !== 'kill' && Request::get('cmd') !== 'back') {
$this->flash['decline_inst'] = true;
$this->flash['inst_id'] = $inst_id;
$this->flash['name'] = $institut->name;
$this->flash['studipticket'] = Seminar_Session::get_ticket();
} elseif (Request::get('cmd') === 'kill' && $ticket_check && Request::get('cmd') !== 'back') {
$changed = InstituteMember::deleteBySQL(
"user_id = ? AND Institut_id = ? AND inst_perms = 'user'",
[$this->user_id, $inst_id]
);
if ($changed > 0) {
PageLayout::postSuccess(sprintf(
_('Die Zuordnung zur Einrichtung %s wurde aufgehoben.'),
'<strong>' . htmlReady($institut->name) . '</strong>'
));
} else {
if (Request::get('cmd') == 'kill' && $ticket_check && Request::get('cmd') != 'back') {
$query = "DELETE FROM user_inst WHERE user_id = ? AND Institut_id = ? AND inst_perms = 'user'";
$statement = DBManager::get()->prepare($query);
$statement->execute([$GLOBALS['user']->id, $inst_id]);
if ($statement->rowCount() > 0) {
PageLayout::postMessage(MessageBox::success(sprintf(_("Die Zuordnung zur Einrichtung %s wurde aufgehoben."), "<b>" . htmlReady($institut->name) . "</b>")));
} else {
PageLayout::postMessage(MessageBox::error(_('Datenbankfehler')));
}
PageLayout::postError(_('Datenbankfehler'));
}
}
$this->redirect('my_institutes/index');
......@@ -56,14 +62,14 @@ class MyInstitutesController extends AuthenticatedController
{
$institutes = MyRealmModel::getMyInstitutes();
foreach ($institutes as $index => $institut) {
MyRealmModel::setObjectVisits($institutes[$index], $institut['institut_id'], $GLOBALS['user']->id, $timestamp);
MyRealmModel::setObjectVisits($institutes[$index], $institut['institut_id'], $this->user_id, $timestamp);
}
PageLayout::postMessage(MessageBox::success(_('Alles als gelesen markiert!')));
PageLayout::postSuccess(_('Alles als gelesen markiert!'));
$this->redirect('my_institutes/index');
}
function check_for_new($my_obj)
protected function check_for_new($my_obj): bool
{
if(!empty($my_obj)) {
foreach ($my_obj as $inst) {
......@@ -75,8 +81,7 @@ class MyInstitutesController extends AuthenticatedController
return false;
}
function check_institute($institute)
protected function check_institute($institute): bool
{
if ($institute['visitdate'] || $institute['last_modified']) {
if ($institute['visitdate'] <= $institute["chdate"] || $institute['last_modified'] > 0) {
......@@ -98,4 +103,35 @@ class MyInstitutesController extends AuthenticatedController
return false;
}
private function setupSidebar(array $institutes, bool $reset)
{
$links = Sidebar::Get()->addWidget(new ActionsWidget());
if ($reset) {
$links->addLink(
_('Alles als gelesen markieren'),
$this->tabularasaURL(time()),
Icon::create('accept')
);
}
if ($GLOBALS['perm']->have_perm('dozent') && count($institutes) > 0) {
$links->addLink(
_('Einrichtungsdaten bearbeiten'),
URLHelper::getURL('dispatch.php/settings/statusgruppen'),
Icon::create('institute+edit')
);
}
if ($GLOBALS['perm']->have_perm('autor')) {
$links->addLink(
_('Einrichtungen suchen'),
URLHelper::getURL('dispatch.php/search/globalsearch#GlobalSearchInstitutes'),
Icon::create('institute+add')
);
$links->addLink(
_('Studiendaten bearbeiten'),
URLHelper::getURL('dispatch.php/settings/studies'),
Icon::create('person')
);
}
}
}
<?php
$is_important = function (?Navigation $nav): bool {
return $nav
&& $nav->getImage() instanceof Icon
&& in_array($nav->getImage()->getRole(), [Icon::ROLE_ATTENTION, Icon::ROLE_STATUS_RED]);
};
?>
<? if (isset($flash['decline_inst'])) : ?>
<?= QuestionBox::create(
sprintf(
......@@ -24,18 +32,16 @@
<table class="default" id="my_institutes">
<caption><?= _('Meine Einrichtungen') ?></caption>
<colgroup>
<col width="10px">
<col width="25px">
<col style="width: 25px">
<col>
<col width="<?= $nav_elements * 27 ?>px">
<col width="45px">
<col style="width: <?= $nav_elements * 32 ?>px">
<col style="width: 45px">
</colgroup>
<thead>
<tr>
<th></th>
<th></th>
<th><?= _("Name") ?></th>
<th style="text-align: center"><?= _("Inhalt") ?></th>
<th><?= _('Name') ?></th>
<th><?= _('Inhalt') ?></th>
<th></th>
</tr>
</thead>
......@@ -44,20 +50,21 @@
<? $lastVisit = $values['visitdate']; ?>
<? $instid = $values['institut_id'] ?>
<tr>
<td style="width:1px"></td>
<td>
<?= InstituteAvatar::getAvatar($instid)->getImageTag(Avatar::SMALL, ['title' => $values['name']]) ?>
</td>
<td style="text-align: left">
<a href="<?= URLHelper::getLink('dispatch.php/institute/overview', ['auswahl' => $instid]) ?>">
<?= htmlReady($GLOBALS['INST_TYPE'][$values["type"]]["name"] . ": " . $values["name"]) ?>
<?= htmlReady($GLOBALS['INST_TYPE'][$values['type']]['name'] . ': ' . $values['name']) ?>
</a>
</td>
<td style="text-align: left; white-space: nowrap">
<? if (!empty($values['navigation'])) : ?>
<ul class="my-courses-navigation">
<? foreach (MyRealmModel::array_rtrim($values['navigation']) as $key => $nav) : ?>
<li class="my-courses-navigation-item <? if ($is_important($nav)) echo 'my-courses-navigation-important'; ?>">
<? if (isset($nav) && $nav->isVisible(true)) : ?>
<a href="<?=
UrlHelper::getLink('dispatch.php/institute/overview',
......@@ -65,17 +72,18 @@
'redirect_to' => strtr($nav->getURL(), '?', '&')]) ?>" <?= $nav->hasBadgeNumber() ? 'class="badge" data-badge-number="' . intval($nav->getBadgeNumber()) . '"' : '' ?>>
<?= $nav->getImage()->asImg(20, $nav->getLinkAttributes()) ?>
</a>
<? elseif (is_string($key)) : ?>
<?= Assets::img('blank.gif', ['widtd' => 20, 'height' => 20]); ?>
<? else: ?>
<span class="empty-slot" style="width: 20px"></span>
<? endif ?>
<? endforeach ?>
</li>
<? endif ?>
</td>
<td style="text-align: left; white-space: nowrap">
<? if (Config::get()->ALLOW_SELFASSIGN_INSTITUTE && $values['perms'] == 'user') : ?>
<a href="<?=$controller->url_for('my_institutes/decline_inst/'.$instid)?>">
<?= Icon::create('door-leave', 'inactive', ['title' => _("aus der Einrichtung austragen")])->asImg(20) ?>
<? if (Config::get()->ALLOW_SELFASSIGN_INSTITUTE && $values['perms'] === 'user') : ?>
<a href="<?= $controller->decline_inst($instid) ?>">
<?= Icon::create('door-leave')->asImg(20, ['title' => _("aus der Einrichtung austragen")]) ?>
</a>
<? else : ?>
<?= Assets::img('blank.gif', ['size' => '20']) ?>
......@@ -86,24 +94,3 @@
</tbody>
</table>
<? endif ?>
<?php
$sidebar = Sidebar::Get();
$links = new ActionsWidget();
if ($reset) {
$links->addLink(_('Alles als gelesen markieren'),
$controller->url_for('my_institutes/tabularasa/' . time()), Icon::create('accept', 'clickable'));
}
if ($GLOBALS['perm']->have_perm('dozent') && !empty($institutes)) {
$links->addLink(_('Einrichtungsdaten bearbeiten'),
URLHelper::getURL('dispatch.php/settings/statusgruppen'), Icon::create('institute+edit', 'clickable') );
}
if ($GLOBALS['perm']->have_perm('autor')) {
$links->addLink(_('Einrichtungen suchen'),
URLHelper::getURL('dispatch.php/search/globalsearch#GlobalSearchInstitutes'), Icon::create('institute+add', 'clickable') );
$links->addLink(_('Studiendaten bearbeiten'),
URLHelper::getURL('dispatch.php/settings/studies'), Icon::create('person', 'clickable'));
}
$sidebar->addWidget($links);
......@@ -584,12 +584,12 @@ class MyRealmModel
* Get all user assigned institutes based on simple or map
* @return array
*/
public static function getMyInstitutes()
public static function getMyInstitutes(): array
{
$memberShips = InstituteMember::findByUser($GLOBALS['user']->id);
if (empty($memberShips)) {
return null;
return [];
}
$institutes = [];
$insts = new SimpleCollection($memberShips);
......
......@@ -15,7 +15,7 @@ class CoreAdmin extends CorePlugin implements StudipModule
public function getIconNavigation($course_id, $last_visit, $user_id)
{
$navigation = new Navigation(_('Verwaltung'), 'dispatch.php/course/management');
$navigation->setImage(Icon::create('admin', Icon::ROLE_INACTIVE, ['title' => _('Verwaltung')]));
$navigation->setImage(Icon::create('admin', Icon::ROLE_CLICKABLE, ['title' => _('Verwaltung')]));
return $navigation;
}
......
......@@ -21,7 +21,7 @@ class CoreCalendar extends CorePlugin implements StudipModule
}
$navigation = new Navigation(_('Kalender'), "seminar_main.php?auswahl={$course_id}&redirect_to=dispatch.php/calendar/single/");
$navigation->setImage(Icon::create('schedule', Icon::ROLE_INACTIVE));
$navigation->setImage(Icon::create('schedule', Icon::ROLE_CLICKABLE));
return $navigation;
}
......
......@@ -38,7 +38,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
* Now this module should put a copy of $material in its own area of the given course.
* @param OERMaterial $material
* @param Course $course
* @return void
* @return array|FileType
*/
static public function oerModuleIntegrateMaterialToCourse(OERMaterial $material, Course $course)
{
......@@ -98,7 +98,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
_('Dateibereich'),
"dispatch.php/{$range_type}/files"
);
$navigation->setImage(Icon::create('files', Icon::ROLE_INACTIVE));
$navigation->setImage(Icon::create('files'));
$condition = "INNER JOIN folders ON (folders.id = file_refs.folder_id)
WHERE folders.range_type = :range_type
......
......@@ -53,7 +53,7 @@ class CoreElearningInterface extends CorePlugin implements StudipModule
)
]);
} elseif ($result['count']) {
$nav->setImage(Icon::create('learnmodule', Icon::ROLE_INACTIVE), [
$nav->setImage(Icon::create('learnmodule', Icon::ROLE_CLICKABLE), [
'title' => sprintf(
ngettext(
'%d Lernmodul',
......
......@@ -56,7 +56,7 @@ class CoreOverview extends CorePlugin implements StudipModule
]);
$nav->setBadgeNumber($result['neue']);
} elseif ($result['count']) {
$nav->setImage(Icon::create('news', Icon::ROLE_INACTIVE), [
$nav->setImage(Icon::create('news', Icon::ROLE_CLICKABLE), [
'title' => sprintf(
ngettext(
'%d Ankündigung',
......
......@@ -38,7 +38,7 @@ class CoreParticipants extends CorePlugin implements StudipModule
$first_nav = reset($sub_nav);
$navigation = new Navigation($first_nav->getTitle(), $first_nav->getURL());
$navigation->setImage(Icon::create('persons', Icon::ROLE_INACTIVE));
$navigation->setImage(Icon::create('persons', Icon::ROLE_CLICKABLE));
return $navigation;
}
......@@ -55,7 +55,7 @@ class CoreParticipants extends CorePlugin implements StudipModule
}
$navigation = new Navigation(_('Teilnehmende'), $url);
$navigation->setImage(Icon::create('persons', Icon::ROLE_INACTIVE));
$navigation->setImage(Icon::create('persons', Icon::ROLE_CLICKABLE));
// Check permission, show no indicator if not at least tutor
if (!$GLOBALS['perm']->have_studip_perm('tutor', $course_id, $user_id)) {
......
......@@ -60,7 +60,7 @@ class CoreSchedule extends CorePlugin implements StudipModule
]);
$nav->setBadgeNumber($result['neue']);
} else {
$nav->setImage(Icon::create('schedule', Icon::ROLE_INACTIVE), [
$nav->setImage(Icon::create('schedule', Icon::ROLE_CLICKABLE), [
'title' => sprintf(
ngettext(
'%d Termin',
......
......@@ -61,7 +61,7 @@ class CoreScm extends CorePlugin implements StudipModule
);
}
} else {
$image = Icon::create('infopage', Icon::ROLE_INACTIVE);
$image = Icon::create('infopage', Icon::ROLE_CLICKABLE);
if ($result['count'] == 1) {
$title = $scm->tab_name;
} else {
......
......@@ -18,7 +18,7 @@ class CoreStudygroupAdmin extends CorePlugin implements StudipModule
public function getIconNavigation($course_id, $last_visit, $user_id)
{
$navigation = new Navigation(_('Verwaltung'), "dispatch.php/course/studygroup/edit/?cid={$course_id}");
$navigation->setImage(Icon::create('admin', Icon::ROLE_INACTIVE), ['title' => _('Verwaltung')]);
$navigation->setImage(Icon::create('admin', Icon::ROLE_CLICKABLE), ['title' => _('Verwaltung')]);
return $navigation;
}
......
......@@ -17,7 +17,7 @@ class CoreStudygroupParticipants extends CorePlugin implements StudipModule
public function getIconNavigation($course_id, $last_visit, $user_id)
{
$navigation = new Navigation(_('Teilnehmende'), "dispatch.php/course/studygroup/members/{$course_id}");
$navigation->setImage(Icon::create('persons', Icon::ROLE_INACTIVE));
$navigation->setImage(Icon::create('persons', Icon::ROLE_CLICKABLE));
if ($last_visit && CourseMember::countBySQL("seminar_id = :course_id AND mkdate >= :last_visit", ['last_visit' => $last_visit, 'course_id' => $course_id]) > 0) {
$navigation->setImage(Icon::create('persons+new', Icon::ROLE_ATTENTION));
}
......
......@@ -73,7 +73,7 @@ class CoreWiki extends CorePlugin implements StudipModule
$nav->setBadgeNumber($result['neue']);
} else {
$nav->setURL('wiki.php');
$nav->setImage(Icon::create('wiki', Icon::ROLE_INACTIVE, [
$nav->setImage(Icon::create('wiki', Icon::ROLE_CLICKABLE, [
'title' => sprintf(
ngettext(
'%d Wiki-Seite',
......
......@@ -101,7 +101,7 @@ class CoursewareModule extends CorePlugin implements SystemPlugin, StudipModule,
}
}
$nav = new Navigation(_('Courseware'), 'dispatch.php/course/courseware');
$nav->setImage(Icon::create('courseware', Icon::ROLE_INACTIVE), [
$nav->setImage(Icon::create('courseware', Icon::ROLE_CLICKABLE), [
'title' => _('Courseware'),
]);
......
......@@ -62,7 +62,7 @@ class GradebookModule extends CorePlugin implements SystemPlugin, StudipModule
$icon = $changed
? Icon::create('assessment+new', Icon::ROLE_NEW)
: Icon::create('assessment', Icon::ROLE_INACTIVE);
: Icon::create('assessment', Icon::ROLE_CLICKABLE);
$navigation = new Navigation($title, 'dispatch.php/course/gradebook/overview');
$navigation->setImage($icon, ['title' => $title]);
......
......@@ -82,7 +82,7 @@ class IliasInterfaceModule extends CorePlugin implements StudipModule, SystemPlu
)
]);
} elseif ($result['count_modules']) {
$nav->setImage(Icon::create('learnmodule', Icon::ROLE_INACTIVE), [
$nav->setImage(Icon::create('learnmodule', Icon::ROLE_CLICKABLE), [
'title' => sprintf(
ngettext(
'%d Lernobjekt',
......@@ -93,7 +93,7 @@ class IliasInterfaceModule extends CorePlugin implements StudipModule, SystemPlu
)
]);
} elseif ($result['count_courses']) {
$nav->setImage(Icon::create('learnmodule', Icon::ROLE_INACTIVE), [
$nav->setImage(Icon::create('learnmodule', Icon::ROLE_CLICKABLE), [
'title' => sprintf(
ngettext(
'%d ILIAS-Kurs',
......
......@@ -42,7 +42,7 @@ class LtiToolModule extends CorePlugin implements StudipModule, SystemPlugin, Pr
$icon = $changed
? Icon::create('link-extern+new', Icon::ROLE_NEW)
: Icon::create('link-extern', Icon::ROLE_INACTIVE);
: Icon::create('link-extern', Icon::ROLE_CLICKABLE);
$navigation = new Navigation($title, 'dispatch.php/course/lti');
$navigation->setImage($icon, ['title' => $title]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment