function ResourcesUserRoomsList ($user_id ='', $sort= TRUE, $return_objects = TRUE, $only_rooms = TRUE) {
        $this->user_id = $user_id;
        if (!$this->user_id)
            $this->user_id = $GLOBALS['user']->id;

        $this->global_perms = getGlobalPerms($this->user_id);
        $this->return_objects = $return_objects;
        $this->only_rooms = $only_rooms;
        $this->restore();
        
        if ($sort) {
            $this->sort();
        }
    }
Example #2
0
    function AssignObjectPerms ($assign_id, $user_id='') {
        global $user, $perm;
        
        if ($user_id)
            $this->user_id=$user_id;
        else
            $this->user_id=$user->id;
        
        $this->assign_id=$assign_id;
        
        //check if user is root
        if ($perm->have_perm("root")) {
            $this->perm="admin";
        } else //check if resources admin
            if (getGlobalPerms($this->user_id) == "admin")
                $this->perm="admin";

        //check if the user assigns the assign 
        if ($this->perm != "admin") {
            $query = "SELECT 1
                      FROM resources_assign
                      WHERE assign_user_id = ? AND assign_id = ?";
            $statement = DBManager::get()->prepare($query);
            $statement->execute(array(
                $this->user_id,
                $this->assign_id
            ));
            $this->owner = (bool)$statement->fetchColumn();

            if ($this->owner) {
                $this->perm = 'admin';
            }
        }
        
        //else check if the user is admin of the assigned resource
        if ($this->perm != "admin") {
            $query = "SELECT resource_id FROM resources_assign WHERE assign_id = ?";
            $statement = DBManager::get()->prepare($query);
            $statement->execute(array($this->assign_id));
            $resource_id = $statement->fetchColumn();

            if ($resource_id) {
                $ObjectPerms = ResourceObjectPerms::Factory($resource_id);
                if ($ObjectPerms->havePerm('tutor')) {
                    $this->perm = 'admin';
                }
            }
        }
    }
Example #3
0
                </select>
            <? endif; ?>
            </td>
        </tr>
    <? endforeach; ?>
<? else : ?>
        <tr>
            <td>&nbsp;</td>
            <td colspan="2" style="color: red">
                <?php 
echo _('Das Objekt wurde noch keinem Typ zugewiesen. Um Eigenschaften bearbeiten zu können, müssen Sie vorher einen Typ festlegen!');
?>
            </td>
        </tr>
<? endif; ?>
    <? if ($resObject->getCategoryId() && getGlobalPerms($user->id) == 'admin') : ?>
        <tr>
            <td>&nbsp;</td>
            <td>
                <b><?php 
echo _('gleichzeitige Belegung');
?>
</b><br>
                <br>
                <label for="change_multiple_assign">
                    <?php 
echo _('Die Ressource darf mehrfach zur gleichen Zeit belegt werden - <br>Überschneidungschecks finden <u>nicht</u> statt!');
?>
                </label>
            </td>
            <td>
Example #4
0
        if ($reqObj->getResourceId())
            $_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["considered_resources"][$reqObj->getResourceId()] = array("type"=>"requested");

        //add resource_ids from room groups
        if (get_config('RESOURCES_ENABLE_GROUPING')){
            $room_group = RoomGroups::GetInstance();
            $group_id = $_SESSION['resources_data']['actual_room_group'];
            if ($room_group->getGroupCount($group_id)){
                foreach ($room_group->getGroupContent($group_id) as $val) {
                    $_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["considered_resources"][$val] = array("type"=>"grouped");
                }
            }
        }

        //add the matching ressources to selection
        if (getGlobalPerms($user->id) != "admin")
            $resList = new ResourcesUserRoomsList ($user->id, FALSE, FALSE);
        $matching_resources = $reqObj->searchRooms(FALSE, TRUE, 0, 0, TRUE, (is_object($resList)) ? array_keys($resList->getRooms()) : FALSE);
        if ($_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["search_limit_high"] > $reqObj->last_search_result_count) {
            $_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["search_limit_high"] = $reqObj->last_search_result_count;
        }

        foreach ($matching_resources as $key => $val) {
            if (!$_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["considered_resources"][$key])
                $_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["considered_resources"][$key] = array("type"=>"matching");
        }

        //add resource_ids from clipboard
        if (is_array($marked_clip_ids))
            foreach ($marked_clip_ids as $val)
                    $_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["considered_resources"][$val] = array("type"=>"clipped");
Example #5
0
 public function searchRoomsToRequest($search_exp, $properties = false)
 {
     $permitted_rooms = null;
     if (getGlobalPerms($GLOBALS['user']->id) != 'admin' && !Config::GetInstance()->getValue('RESOURCES_ALLOW_ROOM_REQUESTS_ALL_ROOMS')) {
         $my_rooms = new ResourcesUserRoomsList($GLOBALS['user']->id, false, false, true);
         $global_resources = DBManager::get()->query("SELECT resource_id FROM resources_objects WHERE owner_id='global'")->fetchAll(PDO::FETCH_COLUMN);
         $permitted_rooms = array_unique(array_merge(array_keys($my_rooms->getRooms()), $global_resources));
     }
     return $this->searchRooms($search_exp, $properties, 0, 0, true, $permitted_rooms);
 }
Example #6
0
    function showListObject ($resource_id, $admin_buttons=FALSE) {
        global $edit_structure_object, $RELATIVE_PATH_RESOURCES, $ActualObjectPerms, $SessSemName,
            $user, $perm, $clipObj, $view_mode, $view;

        //Object erstellen
        $resObject = ResourceObject::Factory($resource_id);

        if (!$resObject->getId())
            return FALSE;

        //link add for special view mode (own window)
        if ($view_mode == "no_nav")
            $link_add = "&quick_view=".$view."&quick_view_mode=".$view_mode;

        if ($this->simple_list){
            //create a simple list intead of printhead/printcontent-design
            $return="<li><a href=\"".URLHelper::getLink('?view=view_details&actual_object='.$resObject->getId().$link_add)."\">".htmlReady($resObject->getName())."</a></li>\n";
            print $return;
        } else {
            //Daten vorbereiten
            if (!$resObject->getCategoryIconnr())
                $icon = Icon::create('folder-full', 'inactive')->asImg(['class' => 'text-top']);
            else
                $icon = Assets::img('cont_res' . $resObject->getCategoryIconnr() . '.gif');

            if ($_SESSION['resources_data']["structure_opens"][$resObject->id]) {
                $link = URLHelper::getLink('?structure_close=' . $resObject->id . $link_add . '#a');
                $open = 'open';
                if ($_SESSION['resources_data']["actual_object"] == $resObject->id)
                    echo '<a name="a"></a>';
            } else {
                $link = URLHelper::getLink('?structure_open=' . $resObject->id . $link_add . '#a');
                $open = 'close';
            }

            $titel='';
            if ($resObject->getCategoryName())
                $titel=$resObject->getCategoryName().": ";
            if ($edit_structure_object == $resObject->id) {
                echo "<a name=\"a\"></a>";
                $titel.="<input style=\"font-size: 8pt; width: 100%;\" type=\"text\" size=20 maxlength=255 name=\"change_name\" value=\"".htmlReady($resObject->getName())."\">";
            } else {
                $titel.=htmlReady($resObject->getName());
            }

            //create a link on the titel, too
            if (($link) && ($edit_structure_object != $resObject->id))
                $titel = "<a href=\"$link\" class=\"tree\" >$titel</a>";

            if ($resObject->getOwnerLink())
                $zusatz=sprintf (_("verantwortlich:")." <a href=\"%s\"><font color=\"#333399\">%s</font></a>", $resObject->getOwnerLink(), htmlReady($resObject->getOwnerName()));
            else
                $zusatz=sprintf (_("verantwortlich:")." %s", htmlReady($resObject->getOwnerName()));

            if ($perm->have_perm('root') || getGlobalPerms($user->id) == "admin"){
                $simple_perms = 'admin';
            } elseif (ResourcesUserRoomsList::CheckUserResource($resObject->getId())){
                $simple_perms = 'tutor';
            } else {
                $simple_perms = false;
            }

            //clipboard in/out
            if ((is_object($clipObj)) && $simple_perms && $resObject->getCategoryId())
                if ($clipObj->isInClipboard($resObject->getId()))
                    $zusatz .= " <a href=\"".URLHelper::getLink('?clip_out='.$resObject->getId().$link_add)."\">" . Icon::create('resources+remove', 'clickable', ['title' => _("Aus der Merkliste entfernen")])->asImg(16, ["alt" => _("Aus der Merkliste entfernen")]) . "</a>";
                else
                    $zusatz .= " <a href=\"".URLHelper::getLink('?clip_in='.$resObject->getId().$link_add)."\">" . Icon::create('resources+add', 'clickable', ['title' => _("In Merkliste aufnehmen")])->asImg(16, ["alt" => _("In Merkliste aufnehmen")]) . "</a>";

            $new=TRUE;

            $edit .= '<div style="text-align: center"><div class="button-group">';

            if ($open == 'open') {
                // check if the edit buttons for admins shell be shown
                if ($admin_buttons && ($simple_perms == "admin")) {
                    $edit .= LinkButton::create(_('Neues Objekt'), URLHelper::getURL('?create_object=' . $resObject->id));
                    if ($resObject->isDeletable()) {
                        $edit .= LinkButton::create(_('Löschen'), URLHelper::getURL('?kill_object=' . $resObject->id));
                    }
                }


                if ($resObject->getCategoryId()) {
                    if (ResourceObject::isScheduleViewAllowed($resObject->getId())) {
                        if ($view_mode == 'no_nav') {
                            $edit .= LinkButton::create(_('Belegung'), URLHelper::getURL('?show_object=' . $resObject->id
                                . '&quick_view=view_schedule&quick_view_mode=' . $view_mode));
                        } else {
                            $edit .= LinkButton::create(_('Belegung'), URLHelper::getURL('?show_object=' . $resObject->id
                                . '&view=view_schedule'));
                        }
                    }
                }
                if ($simple_perms && $resObject->isRoom()) {
                    $edit .= LinkButton::create(_('Benachrichtigung'), UrlHelper::getScriptURL('dispatch.php/resources/helpers/resource_message/' . $resObject->id), array('data-dialog' => ''));
                }
                if ($view_mode == 'no_nav') {
                    $edit .= LinkButton::create(_('Eigenschaften'), URLHelper::getURL('?show_object=' . $resObject->id
                        . '&quick_view=view_details&quick_view_mode=' . $view_mode));
                } else {
                    $edit .= LinkButton::create(_('Eigenschaften'), URLHelper::getURL('?show_object=' . $resObject->id
                        . '&view=view_details'));
                }

                //clipboard in/out
                if (is_object($clipObj) && $simple_perms && $resObject->getCategoryId())
                    if ($clipObj->isInClipboard($resObject->getId())) {
                        $edit .= LinkButton::create(_('Aus Merkliste entfernen'),
                            URLHelper::getURL('?clip_out=' .$resObject->getId() . $link_add));
                    } else {
                        $edit .= LinkButton::create(_('In Merkliste aufnehmen') . ' >',
                            URLHelper::getURL('?clip_in=' .$resObject->getId() . $link_add));
                    }
            }
            $edit .= '</div></div>';
            $content = $resObject->getDescription();
            //Daten an Ausgabemodul senden
            $this->showRow($icon, $link, $titel, $zusatz, 0, 0, 0, $new, $open, $content, $edit);
        }
        return TRUE;
    }
Example #7
0
    function showRequestList() {
        global $_fullname_sql, $CANONICAL_RELATIVE_PATH_STUDIP;

        $license_to_kill = (get_config('RESOURCES_ALLOW_DELETE_REQUESTS') && getGlobalPerms($GLOBALS['user']->id) == 'admin');
        if ($license_to_kill){
            echo chr(10) . '<script type="text/javascript">';
            echo chr(10) . '
            function auswahl_umkehr(){
                my_elements = document.forms[\'list_requests_form\'].elements[\'requests_marked_to_kill[]\'];
                if(!my_elements.length){
                    if(my_elements.checked)
                        my_elements.checked = false;
                    else
                        my_elements.checked = true;
                } else {
                    for(i = 0; i < my_elements.length; ++i){
                        if(my_elements[i].checked)
                        my_elements[i].checked = false;
                        else
                        my_elements[i].checked = true;
                    }
                }
            }';
            echo chr(10) . '</script>';
            echo chr(10) . '<form name="list_requests_form" method="post" action="'.URLHelper::getLink().'">';
            echo CSRFProtection::tokenTag();
            ?>
            <div align="right" style="padding-right: 5px">
                <?php 
echo LinkButton::create(_('Auswahl umkehren'), 'javascript:auswahl_umkehr();');
?>
                <?php 
echo Button::create('Löschen', 'do_delete_requests', array(title => _('Ausgewählte Anfragen löschen')));
?>
            </div>
            <br>
            <?
        }
        $i = 0;
        $zt = new ZebraTable(array('width' => '99%', 'padding' => '1', 'align' => 'center'));
        $zt->switchClass();
        echo $zt->openRow();
        echo $zt->cell("&nbsp;", array("class" => "content_seperator"));
        echo $zt->cell("<font size=\"-1\"><b>" . _("Zähler") . "</b></font>", array("class" => "content_seperator", 'colspan' => '3'));
        echo $zt->cell("<font size=\"-1\"><b>" . _("V.-Nummer") . "</b></font>", array("class" => "content_seperator"));
        echo $zt->cell("<font size=\"-1\"><b>" . _("Titel") . "</b></font>", array("class" => "content_seperator"));
        echo $zt->cell("<font size=\"-1\"><b>" . _("Dozenten") . "</b></font>", array("class" => "content_seperator"));
        echo $zt->cell("<font size=\"-1\"><b>" . _("Anfrager") . "</b></font>", array("class" => "content_seperator"));
        echo $zt->cell("<font size=\"-1\"><b>" . _("Start-Semester") . "<b></font>", array("class" => "content_seperator"));
        if ($license_to_kill){
            echo $zt->cell("<font size=\"-1\"><b>" . _("löschen") . "<b></font>", array("class" => "content_seperator", 'width' => '5%'));
        }
        echo $zt->closeRow();
        ?>
        <?
        foreach ($_SESSION['resources_data']['requests_working_on'] as $key => $val) {
            $i++;
            if ($_SESSION['resources_data']['requests_open'][$val['request_id']] || !$_SESSION['resources_data']['skip_closed_requests']) {
                $reqObj = new RoomRequest($val['request_id']);
                $semObj = new Seminar($reqObj->getSeminarId());

                if ($semObj->getName() != "") {
                    echo $zt->openRow();
                    //echo "<font size=\"-1\">";
                    echo $zt->cell("&nbsp;");
                    echo $zt->cell("<font size=\"-1\">$i.</font>");
                    echo $zt->cell("<a href=\"resources.php?view=edit_request&edit=".$val['request_id']."\">".Icon::create('edit', 'clickable', ['title' => _("Anfrage bearbeiten")])->asImg()."</a>");
                    echo $zt->cell((($_SESSION['resources_data']['requests_open'][$val['request_id']]) ? '' : Icon::create('accept', 'accept')->asImg())."</font>");
                    echo $zt->cell("<font size=\"-1\">".htmlReady($semObj->seminar_number)."</font>");
                    echo $zt->cell("<font size=\"-1\"><a href=\"dispatch.php/course/details/?sem_id=".$semObj->getId()."&send_from_search=true&send_from_search_page=".urlencode($CANONICAL_RELATIVE_PATH_STUDIP."resources.php?view=list_requests")."\">".my_substr(htmlReady($semObj->getName()),0,50)."</a><br></font>");
                    echo $zt->openCell();
                    echo "<font size=\"-1\">";
                    $k = false;
                    foreach ($semObj->getMembers('dozent') as $doz) {
                        if ($k) echo ", ";
                        echo "<a href=\"dispatch.php/profile?username={$doz['username']}\">".HtmlReady($doz['fullname'])."</a>";
                        $k = true;
                    }
                    echo "</font>";
                    $this->selectSemInstituteNames($semObj->getInstitutId());
                    if (!$this->all_semester) {
                        $semester = new SemesterData();
                        $this->all_semester = $semester->getAllSemesterData();
                    }
                    foreach ($this->all_semester as $one_sem) {
                        if ($one_sem['beginn'] == $semObj->semester_start_time) {
                            $cursem = $one_sem['name'];
                        }
                    }

                    echo $zt->closeCell();
                    echo $zt->cell("<font size=\"-1\"><a href=\"dispatch.php/profile?username="******"\">".get_fullname($reqObj->user_id)."</a></font>");
                    echo $zt->cell("<font size=\"-1\">$cursem</font>");
                    if ($license_to_kill){
                        echo $zt->cell("<font size=\"-1\"><input type=\"checkbox\" name=\"requests_marked_to_kill[]\" value=\"{$val['request_id']}\"></font>", array('align' => 'center'));
                    }
                    echo $zt->closeRow();
                }
            }
        }
        echo $zt->close();
        if ($license_to_kill){
            echo chr(10) . '</form>';
        }
    }
Example #8
0
 /**
  * Initialize the subnavigation of this item. This method
  * is called once before the first item is added or removed.
  */
 public function initSubNavigation()
 {
     global $perm, $auth;
     $username = $auth->auth['uname'];
     parent::initSubNavigation();
     if (!$perm->have_perm('user')) {
         return;
     }
     $sem_create_perm = in_array(get_config('SEM_CREATE_PERM'), array('root', 'admin', 'dozent')) ? get_config('SEM_CREATE_PERM') : 'dozent';
     // my courses
     if ($perm->have_perm('root')) {
         $navigation = new Navigation(_('Veranstaltungsübersicht'), 'dispatch.php/search/courses');
     } else {
         if ($perm->have_perm('admin')) {
             $navigation = new Navigation(_('Veranstaltungen an meinen Einrichtungen'), 'dispatch.php/my_courses');
         } else {
             $navigation = new Navigation(_('Meine Veranstaltungen'), 'dispatch.php/my_courses');
             if (!$perm->have_perm('dozent')) {
                 $navigation->addSubNavigation('browse', new Navigation(_('Veranstaltung hinzufügen'), 'dispatch.php/search/courses'));
                 if ($perm->have_perm('autor') && get_config('STUDYGROUPS_ENABLE')) {
                     $navigation->addSubNavigation('new_studygroup', new Navigation(_('Studiengruppe anlegen'), 'dispatch.php/course/wizard?studygroup=1'));
                 }
             } else {
                 if ($perm->have_perm($sem_create_perm)) {
                     $navigation->addSubNavigation('new_course', new Navigation(_('Neue Veranstaltung anlegen'), 'dispatch.php/course/wizard'));
                 }
                 if (get_config('STUDYGROUPS_ENABLE')) {
                     $navigation->addSubNavigation('new_studygroup', new Navigation(_('Studiengruppe anlegen'), 'dispatch.php/course/wizard?studygroup=1'));
                 }
             }
         }
     }
     $this->addSubNavigation('my_courses', $navigation);
     // course administration
     if ($perm->have_perm('admin')) {
         $navigation = new Navigation(_('Verwaltung von Veranstaltungen'), 'dispatch.php/my_courses');
         if ($perm->have_perm($sem_create_perm)) {
             $navigation->addSubNavigation('new_course', new Navigation(_('Neue Veranstaltung anlegen'), 'dispatch.php/course/wizard'));
         }
         if (get_config('STUDYGROUPS_ENABLE')) {
             $navigation->addSubNavigation('new_studygroup', new Navigation(_('Studiengruppe anlegen'), 'dispatch.php/course/wizard?studygroup=1'));
         }
         $this->addSubNavigation('admin_course', $navigation);
     }
     // insitute administration
     if ($perm->have_perm('admin')) {
         $navigation = new Navigation(_('Verwaltung von Einrichtungen'), 'dispatch.php/institute/basicdata/index?list=TRUE');
         $this->addSubNavigation('admin_inst', $navigation);
     }
     // user administration
     if ($perm->have_perm('root')) {
         $navigation = new Navigation(_('Verwaltung globaler Einstellungen'), 'admin_range_tree.php');
         $this->addSubNavigation('admin_user', $navigation);
     } else {
         if ($perm->have_perm('admin') && !get_config('RESTRICTED_USER_MANAGEMENT')) {
             $navigation = new Navigation(_('Globale Benutzerverwaltung'), 'dispatch.php/admin/user/');
             $this->addSubNavigation('admin_user', $navigation);
         }
     }
     // plugin and role administration
     if ($perm->have_perm('root')) {
         $navigation = new Navigation(_('Verwaltung von Plugins'), 'dispatch.php/admin/plugin');
         $navigation->addSubNavigation('admin_roles', new Navigation(_('Verwaltung von Rollen'), 'dispatch.php/admin/role'));
         $this->addSubNavigation('admin_plugins', $navigation);
     }
     // administration of ressources
     if ($perm->have_perm('admin')) {
         if (get_config('RESOURCES_ENABLE')) {
             $navigation = new Navigation(_('Verwaltung von Ressourcen'));
             $navigation->addSubNavigation('hierarchy', new Navigation(_('Struktur'), 'resources.php#a', array('view' => 'resources')));
             if ($perm->have_perm('admin') && get_config('RESOURCES_ALLOW_ROOM_REQUESTS')) {
                 if (getGlobalPerms($GLOBALS['user']->id) !== 'admin') {
                     $resList = new ResourcesUserRoomsList($GLOBALS['user']->id, false, false);
                     $show_roomplanning = $resList->roomsExist();
                 } else {
                     $show_roomplanning = true;
                 }
                 if ($show_roomplanning) {
                     $navigation->addSubNavigation('start_planning', new Navigation(_('Raumplanung'), 'resources.php?cancel_edit_request_x=1', array('view' => 'requests_start')));
                 }
             }
             if (getGlobalPerms($GLOBALS['user']->id) == 'admin') {
                 $navigation->addSubNavigation('edit_types', new Navigation(_('Anpassen'), 'resources.php', array('view' => 'edit_types')));
             }
             $this->addSubNavigation('ressources', $navigation);
         }
     }
     // messaging
     $navigation = new Navigation(_('Nachrichten'));
     $navigation->addSubNavigation('in', new Navigation(_('Posteingang'), 'dispatch.php/messages/overview'));
     $navigation->addSubNavigation('out', new Navigation(_('Gesendet'), 'dispatch.php/messages/sent'));
     $this->addSubNavigation('messaging', $navigation);
     // community
     $navigation = new Navigation(_('Community'));
     $navigation->addSubNavigation('online', new Navigation(_('Wer ist online?'), 'dispatch.php/online'));
     $navigation->addSubNavigation('contacts', new Navigation(_('Meine Kontakte'), 'dispatch.php/contact'));
     // study groups
     if (get_config('STUDYGROUPS_ENABLE')) {
         $navigation->addSubNavigation('browse', new Navigation(_('Studiengruppen'), 'dispatch.php/studygroup/browse'));
     }
     // ranking
     if (get_config('SCORE_ENABLE')) {
         $navigation->addSubNavigation('score', new Navigation(_('Rangliste'), 'dispatch.php/score'));
         $this->addSubNavigation('community', $navigation);
     }
     // calendar / home page
     if (!$perm->have_perm('admin')) {
         $navigation = new Navigation(_('Mein Profil'), 'dispatch.php/profile');
         if ($perm->have_perm('autor')) {
             $navigation->addSubNavigation('settings', new Navigation(_('Einstellungen'), 'dispatch.php/settings/general'));
         }
         $this->addSubNavigation('profile', $navigation);
         $navigation = new Navigation(_('Mein Planer'));
         if (get_config('CALENDAR_ENABLE')) {
             $navigation->addSubNavigation('calendar', new Navigation(_('Terminkalender'), 'dispatch.php/calendar/single'));
         }
         if (get_config('SCHEDULE_ENABLE')) {
             $navigation->addSubNavigation('schedule', new Navigation(_('Stundenplan'), 'dispatch.php/calendar/schedule'));
         }
         $this->addSubNavigation('planner', $navigation);
     }
     // global search
     $navigation = new Navigation(_('Suchen'), 'dispatch.php/search/courses');
     $navigation->addSubNavigation('user', new Navigation(_('Personensuche'), 'browse.php'));
     $navigation->addSubNavigation('course', new Navigation(_('Veranstaltungssuche'), 'dispatch.php/search/courses'));
     $this->addSubNavigation('search', $navigation);
     // tools
     $navigation = new Navigation(_('Tools'));
     $navigation->addSubNavigation('news', new Navigation(_('Ankündigungen'), 'dispatch.php/news/admin_news'));
     if (get_config('VOTE_ENABLE')) {
         $navigation->addSubNavigation('vote', new Navigation(_('Umfragen und Tests'), 'admin_vote.php', array('page' => 'overview', 'showrangeID' => $username)));
         $navigation->addSubNavigation('evaluation', new Navigation(_('Evaluationen'), 'admin_evaluation.php', array('rangeID' => $username)));
     }
     // literature
     if (get_config('LITERATURE_ENABLE')) {
         $navigation->addSubNavigation('literature', new Navigation(_('Literatur'), 'dispatch.php/literature/edit_list.php', array('_range_id' => 'self')));
     }
     // elearning
     if (get_config('ELEARNING_INTERFACE_ENABLE')) {
         $navigation->addSubNavigation('elearning', new Navigation(_('Lernmodule'), 'dispatch.php/elearning/my_accounts'));
     }
     // export
     if (get_config('EXPORT_ENABLE') && $perm->have_perm('tutor')) {
         $navigation->addSubNavigation('export', new Navigation(_('Export'), 'export.php'));
     }
     $this->addSubNavigation('tools', $navigation);
     // external help
     $navigation = new Navigation(_('Hilfe'), format_help_url('Basis.Allgemeines'));
     $navigation->addSubNavigation('intro', new Navigation(_('Schnelleinstieg'), format_help_url('Basis.SchnellEinstiegKomplett')));
     $this->addSubNavigation('help', $navigation);
 }
Example #9
0
 /**
  * edit one room requests in a dialog
  */
 public function edit_dialog_action()
 {
     if (Request::isXhr()) {
         $request = Request::getInstance();
         foreach ($request as $key => $value) {
             $request[$key] = studip_utf8decode($value);
         }
         if ($this->course_id != '-') {
             $this->edit_action();
             $title = PageLayout::getTitle();
         } else {
             $sem_create_data =& $_SESSION['sem_create_data'];
             if (Request::option('new_room_request_type')) {
                 if ($sem_create_data['room_requests'][Request::option('new_room_request_type')] instanceof RoomRequest) {
                     $request = clone $sem_create_data['room_requests'][Request::option('new_room_request_type')];
                 } else {
                     $request = new RoomRequest();
                     $request->seminar_id = '-';
                     $request->user_id = $GLOBALS['user']->id;
                     list($new_type, $id) = explode('_', Request::option('new_room_request_type'));
                     if ($new_type == 'date') {
                         $request->termin_id = Request::option('new_room_request_type');
                     } elseif ($new_type == 'cycle') {
                         $request->metadate_id = Request::option('new_room_request_type');
                     }
                 }
                 $room_request_form_attributes = self::process_form($request, $sem_create_data['sem_turnout']);
                 $this->search_result = $room_request_form_attributes['search_result'];
                 $this->search_by_properties = $room_request_form_attributes['search_by_properties'];
                 $this->admission_turnout = $sem_create_data['sem_turnout'];
                 $this->request = $request;
                 $room_categories = array_values(array_filter(getResourcesCategories(), create_function('$a', 'return $a["is_room"] == 1;')));
                 if (!$request->getCategoryId() && count($room_categories) == 1) {
                     $request->setCategoryId($room_categories[0]['category_id']);
                 }
                 $this->room_categories = $room_categories;
                 $this->new_room_request_type = Request::option('new_room_request_type');
                 $this->is_resources_admin = getGlobalPerms($GLOBALS['user']->id);
                 $title = _("Verwaltung von Raumanfragen");
                 if (Request::submitted('save') || Request::submitted('save_close')) {
                     if ($request->getSettedPropertiesCount() || $request->getResourceId()) {
                         $sem_create_data['room_requests'][Request::option('new_room_request_type')] = $request;
                         $this->request_stored = true;
                         if (Request::submitted('save')) {
                             PageLayout::postMessage(MessageBox::success(_("Die Raumanfrage und gewünschte Raumeigenschaften wurden gespeichert")));
                         }
                     } else {
                         PageLayout::postMessage(MessageBox::error(_("Die Anfrage kann noch nicht gespeichert werden, da Sie mindestens einen Raum oder mindestens eine Eigenschaft (z.B. Anzahl der Sitzplätze) angeben müssen!")));
                     }
                 }
                 $old_request = $sem_create_data['room_requests'][Request::option('new_room_request_type')];
                 if (!is_object($old_request) || $request->category_id != $old_request->category_id || $request->resource_id != $old_request->resource_id || $request->getProperties() != $old_request->getProperties() || $request->comment != $old_request->comment) {
                     PageLayout::postMessage(MessageBox::info(_("Die Änderungen an der Raumanfrage wurden noch nicht gespeichert!")));
                 }
             }
         }
         if (Request::submitted('save_close') && isset($this->request_stored)) {
             return $this->render_json(array('auto_close' => true, 'auto_reload' => $this->request_stored));
         } else {
             $this->render_template('course/room_requests/edit_dialog.php', null);
             $this->flash->discard();
             $content = $this->get_response()->body;
             $this->erase_response();
             return $this->render_json(array('title' => studip_utf8encode($title), 'content' => studip_utf8encode($content)));
         }
     } else {
         return $this->render_text('');
     }
 }
Example #10
0
 function bookable_rooms_action()
 {
     if (!getGlobalPerms($GLOBALS['user']->id) == 'admin') {
         $resList = new ResourcesUserRoomsList($GLOBALS['user']->id, false, false, false);
         if (!$resList->roomsExist()) {
             throw new AccessDeniedException();
         }
     }
     $select_options = Request::optionArray('rooms');
     $rooms = array_filter($select_options, function ($v) {
         return strlen($v) === 32;
     });
     $events = array();
     $dates = array();
     $timestamps = array();
     if (count(Request::getArray('new_date'))) {
         $new_date = array();
         foreach (Request::getArray('new_date') as $one) {
             if ($one['name'] == 'startDate') {
                 $dmy = explode('.', $one['value']);
                 $new_date['day'] = (int) $dmy[0];
                 $new_date['month'] = (int) $dmy[1];
                 $new_date['year'] = (int) $dmy[2];
             }
             $new_date[$one['name']] = (int) $one['value'];
         }
         if (check_singledate($new_date['day'], $new_date['month'], $new_date['year'], $new_date['start_stunde'], $new_date['start_minute'], $new_date['end_stunde'], $new_date['end_minute'])) {
             $start = mktime($new_date['start_stunde'], $new_date['start_minute'], 0, $new_date['month'], $new_date['day'], $new_date['year']);
             $ende = mktime($new_date['end_stunde'], $new_date['end_minute'], 0, $new_date['month'], $new_date['day'], $new_date['year']);
             $timestamps[] = $start;
             $timestamps[] = $ende;
             $event = new AssignEvent('new_date', $start, $ende, null, null, '');
             $events[$event->getId()] = $event;
         }
     }
     foreach (Request::optionArray('selected_dates') as $one) {
         $date = new SingleDate($one);
         if ($date->getStartTime()) {
             $timestamps[] = $date->getStartTime();
             $timestamps[] = $date->getEndTime();
             $event = new AssignEvent($date->getTerminID(), $date->getStartTime(), $date->getEndTime(), null, null, '');
             $events[$event->getId()] = $event;
             $dates[$date->getTerminID()] = $date;
         }
     }
     if (count($events)) {
         $result = array();
         $checker = new CheckMultipleOverlaps();
         $checker->setTimeRange(min($timestamps), max($timestamps));
         foreach ($rooms as $room) {
             $checker->addResource($room);
         }
         $checker->checkOverlap($events, $result, "assign_id");
         foreach ((array) $result as $room_id => $details) {
             foreach ($details as $termin_id => $conflicts) {
                 if ($termin_id == 'new_date' && Request::option('singleDateID')) {
                     $assign_id = SingleDateDB::getAssignID(Request::option('singleDateID'));
                 } else {
                     $assign_id = SingleDateDB::getAssignID($termin_id);
                 }
                 $filter = function ($a) use($assign_id) {
                     if ($a['assign_id'] && $a['assign_id'] == $assign_id) {
                         return false;
                     }
                     return true;
                 };
                 if (!count(array_filter($conflicts, $filter))) {
                     unset($result[$room_id][$termin_id]);
                 }
             }
         }
         $result = array_filter($result);
         $this->render_json(array_keys($result));
         return;
     }
     $this->render_nothing();
 }
Example #11
0
        $navigation->addSubNavigation('edit', $edit_nav);
        $navigation->addSubNavigation('list', $list_nav);
        $navigation->addSubNavigation('schedule', $view_nav);

        if (!$_SESSION['resources_data']['requests_working_on']) {
            $edit_nav->setEnabled(false);
            $list_nav->setEnabled(false);
            $view_nav->setEnabled(false);
        }

        $resources_nav->addSubNavigation('room_requests', $navigation);
    }
}

// Reiter "Anpassen": Grundlegende Einstellungen fuer alle Ressourcen Admins
if ((getGlobalPerms($user->id) == 'admin') || ($perm->have_perm('root'))) {
    $navigation = new Navigation(_('Anpassen'));
    $navigation->addSubNavigation('edit_types', new Navigation(_('Typen verwalten'), 'resources.php', array('view' => 'edit_types')));
    $navigation->addSubNavigation('edit_properties', new Navigation(_('Eigenschaften verwalten'), 'resources.php', array('view' => 'edit_properties')));
    $navigation->addSubNavigation('edit_settings', new Navigation(_('globale Einstellungen verwalten'), 'resources.php', array('view' => 'edit_settings')));

    if ($perm->have_perm('root')) {
        $navigation->addSubNavigation('edit_perms', new Navigation(_('globale Rechte verwalten'), 'resources.php', array('view' => 'edit_perms')));
    }

    $resources_nav->addSubNavigation('settings', $navigation);
}

//load content, text, pictures and stuff
include ("$RELATIVE_PATH_RESOURCES/views/page_intros.inc.php");
//save messages from
Example #12
0
    function ResourcesUserRoots($range_id='') {
        global $user, $perm, $auth;

        if($range_id){
            $this->range_id = $range_id;
        }

        if (!$this->range_id)
            $this->range_id=$user->id;

        if (get_object_type($this->range_id) == "user") {
            //load the global perms in the resources-system (check if the user ist resources-root)
            $this->resources_global_perm=getGlobalPerms($this->range_id);
            //load the global studip perms (check, if user id root)
            $this->user_global_perm=get_global_perm($this->range_id);

            if ($this->resources_global_perm == "admin")
                $global_perm="root";
            else
                $global_perm=$this->user_global_perm;
        }

        //root or resoures root are able to see all resources (roots in tree)
        if ($global_perm == "root") {
            $query = "SELECT resource_id FROM resources_objects WHERE resource_id = root_id ORDER BY name";
            $statement = DBManager::get()->query($query);
            while ($resource_id = $statement->fetchColumn()) {
                $this->my_roots[$resource_id] = $resource_id;
            }
        } else {
            $my_objects            = search_administrable_objects();
            $my_objects[$user->id] = TRUE;
            $my_objects["global"]  = TRUE;

            //create the clause with all my id's
            $i=0;
            $clause = " (";
            foreach ($my_objects as $key=>$val) {
                if ($i)
                    $clause .= ", ";
                $clause .= "'$key'";
                $i++;
            }
            $clause .= ") ";

            //all objects where I have owner perms...
            $query = "SELECT resource_id, parent_id, root_id, level
                      FROM resources_objects
                      WHERE owner_id IN (?)
                      ORDER BY level DESC";
            $statement = DBManager::get()->prepare($query);
            $statement->execute(array(
                array_keys($my_objects)
            ));
            while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
                $my_resources[$row['resource_id']] = array(
                    'root_id'   => $row['root_id'],
                    'parent_id' => $row['parent_id'],
                    'level'     => $row['level']
                );
                $roots[$row['root_id']][] = $row['resource_id'];
            }

            //...and all objects where I have add perms...
            $query = "SELECT resource_id, parent_id, root_id, level
                      FROM resources_user_resources
                      LEFT JOIN resources_objects USING (resource_id)
                      WHERE user_id IN ('all', ?)
                      ORDER BY level DESC";
            $statement = DBManager::get()->prepare($query);
            $statement->execute(array(
                array_keys($my_objects)
            ));
            while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
                $my_resources[$row['resource_id']] = array(
                    'root_id'   => $row['root_id'],
                    'parent_id' => $row['parent_id'],
                    'level'     => $row['level']
                );
                $roots[$row['root_id']][] = $row['resource_id'];
            }

            if (is_array($my_resources)) {
                $query = "SELECT parent_id FROM resources_objects WHERE resource_id = ?";
                $statement = DBManager::get()->prepare($query);

                foreach ($my_resources as $key => $val) {
                    if (!$this->checked[$key]) {
                        if (sizeof($roots[$val["root_id"]]) == 1) {
                            $this->my_roots[$key] = $key;
                        } else {
                            //there are more than 2 resources in one thread...
                            $statement->execute(array($key));
                            $superordinated_id = $statement->fetchColumn();
                            $statement->closeCursor();

                            $top        = FALSE;
                            $last_found = $key;
                            while (!$top && $superordinated_id) {
                                $statement->execute(array($superordinated_id));
                                $parent_id = $statement->fetchColumn();
                                $statement->closeCursor();

                                if ($my_resources[$superordinated_id]) {
                                    $checked[$last_found] = TRUE;
                                    $last_found           = $superordinated_id;
                                }

                                $superordinated_id = $parent_id;
                                if ($parent_id == "0") {
                                    $top = TRUE;
                                }
                            }
                            $this->my_roots[$last_found] = $last_found;
                        }
                    }
                }
            }
        }

    }
Example #13
0
/**
 * Checks if current user has global access to resource occupation plans.
 * @return bool
 */
function hasGlobalOccupationAccess()
{
    return Config::get()->RESOURCES_ALLOW_VIEW_RESOURCE_OCCUPATION || $GLOBALS['perm']->have_perm('admin') || getGlobalPerms($GLOBALS['user']->id) == 'admin';
}
    function ResourceObjectPerms ($resource_id, $user_id='') {
        global $user, $perm;

        if ($user_id)
            $this->user_id=$user_id;
        else
            $this->user_id=$user->id;

        $this->resource_id=$resource_id;
        if (!$this->resource_id){
            $this->perm = false;
            return;
        }

        $resObject = ResourceObject::Factory($this->resource_id);
        $is_room = $resObject->isRoom();

        if ($is_room) {
            $inheritance = Config::get()->RESOURCES_INHERITANCE_PERMS_ROOMS;
        } else {
            $inheritance = Config::get()->RESOURCES_INHERITANCE_PERMS;
        }

        //check if user is root
        if ($perm->have_perm('root')) {
            $this->changePerm('admin');
        }
        //check if resources admin
        elseif (getGlobalPerms($this->user_id) === 'admin') {
            $this->changePerm('admin');
        }

        //check, if the resource is locked at the moment (only rooms!)
        if (($this->perm != "admin") && ($resObject->isLocked())) {
            $this->perm = FALSE;
            return;
        }

        //check if the user is owner of the object
        if ($this->perm != "admin") {
            $result = DBManager::get()->query("SELECT owner_id FROM resources_objects WHERE owner_id='$this->user_id' AND resource_id = '$this->resource_id' ");
            if ($result->fetch()) {
                $this->owner=TRUE;
                $this->changePerm("admin");
            } else {
                $this->owner=FALSE;
            }
        }

        //else check all the other possibilities
        if ($this->perm != "admin") {
            $my_administrable_objects = search_administrable_objects(); //the administrative ones....
            $my_objects=search_my_objects();                //...and the other, where the user is autor.
            $my_objects["all"] = TRUE;
            $my_objects = array_merge((array)$my_administrable_objects, (array)$my_objects);
            //check if one of my administrable (system) objects owner of the resourcen object, so that I am too...

            if (is_array($my_objects) && count($my_objects)){
                $objects_sql = " ('" . join("','", array_keys($my_objects)) . "') ";

                $superordinated_id = $this->resource_id;
                $top=FALSE;

                while ((!$top) && ($k<10000) && ($superordinated_id)) {
                    $result = DBManager::get()->query("SELECT owner_id, resource_id
                        FROM resources_objects
                        WHERE owner_id IN $objects_sql AND resource_id = '$superordinated_id' ");

                    while ($data = $result->fetch(PDO::FETCH_ASSOC)) {
                        if ($my_objects[$data['owner_id']]["perms"] == "admin"){
                            $this->changePerm("admin");
                        } else {
                            switch ($inheritance) {
                                case "1":
                                    $this->changePerm($my_objects[$data['owner_id']]["perms"]);
                                break;
                                default:
                                case "2":
                                    $this->changePerm("autor");
                                break;
                            }
                        }
                        if ($this->perm == "admin")
                        break;
                    }
                    ++$k;
                    if ($this->perm == "admin")
                        break;

                    //also check the additional perms...
                    $result = DBManager::get()->query("SELECT user_id,perms
                        FROM resources_user_resources
                        WHERE user_id IN $objects_sql AND resource_id = '$superordinated_id' ");

                    while ($data = $result->fetch(PDO::FETCH_ASSOC)){
                        $this->changePerm($data['perms']);
                        if ($this->perm == "admin")
                            break;
                    }
                    if ($this->perm == "admin")
                        break;

                    //select the next superordinated object
                    $result = DBManager::get()->query("SELECT parent_id FROM resources_objects WHERE resource_id = '$superordinated_id'");
                    $data = $result->fetch(PDO::FETCH_ASSOC);
                    $superordinated_id = $data['parent_id'];
                    if ($data['parent_id'] == "0")
                        $top = TRUE;
                }

            }
        }
    }
Example #15
0
 function checkOverlap($check_locks = TRUE)
 {
     global $user;
     $resObject = ResourceObject::Factory($this->resource_id);
     //we check overlaps always for a whole day
     $start = mktime(0, 0, 0, date("n", $this->begin), date("j", $this->begin), date("Y", $this->begin));
     if ($this->repeat_end) {
         $end = mktime(23, 59, 59, date("n", $this->repeat_end), date("j", $this->repeat_end), date("Y", $this->repeat_end));
     } else {
         $end = mktime(23, 59, 59, date("n", $this->end), date("j", $this->end), date("Y", $this->end));
     }
     //load the events of the actual assign...
     $events = $this->getEvents();
     //check, if an assign_lock for one of the events is active (results in an "overlap" so assign cant be saved)
     if (Config::get()->RESOURCES_ASSIGN_LOCKING_ACTIVE && $resObject->isLockable() && $resObject->isRoom() && getGlobalPerms($user->id) !== 'admin' && $check_locks) {
         foreach ($events as $obj) {
             $lock = getLockPeriod('assign', $obj->getBegin(), $obj->getEnd());
             if ($lock) {
                 $overlaps[] = array('begin' => $obj->getBegin(), 'end' => $obj->getEnd(), 'lock' => TRUE, 'lock_begin' => $lock[0], 'lock_end' => $lock[1], 'lock_id' => $lock[2]);
             }
         }
         if ($overlaps) {
             return $overlaps;
         }
     }
     //check for regular overlaps
     if (!$resObject->getMultipleAssign()) {
         //when multiple assigns are allowed, we need no check...
         $multiChecker = new CheckMultipleOverlaps();
         $multiChecker->setAutoTimeRange(array($this));
         $multiChecker->addResource($this->resource_id);
         $check_events = array();
         foreach ($events as $evtObj) {
             $check_events[$evtObj->getId()] = $evtObj;
         }
         $multiChecker->checkOverlap($check_events, $result);
         $overlaps = array();
         if (is_array($result[$this->resource_id][$this->id])) {
             foreach ($result[$this->resource_id][$this->id] as $overlapping_event) {
                 $overlaps[$overlapping_event["assign_id"]]["begin"] = $overlapping_event["begin"];
                 $overlaps[$overlapping_event["assign_id"]]["end"] = $overlapping_event["end"];
             }
         }
         return $overlaps;
     } else {
         return false;
     }
 }