Example #1
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 #2
0
    function showThreadLevel ($root_id, $level=0, $lines='')
    {
        global $edit_structure_object, $RELATIVE_PATH_RESOURCES, $ActualObjectPerms;

        // Prepare statement that obtains all children of a given resource
        $query = "SELECT resource_id
                  FROM resources_objects
                  WHERE parent_id = ?
                  ORDER BY name";
        $children_statement = DBManager::get()->prepare($query);

        //Daten des Objects holen
        $query = "SELECT resource_id
                  FROM resources_objects
                  WHERE resource_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($root_id));
        $resource_ids = $statement->fetchAll(PDO::FETCH_COLUMN);

        foreach ($resource_ids as $resource_id) {
            //Untergeordnete Objekte laden
            $children_statement->execute(array($resource_id));
            $children = $children_statement->fetchAll(PDO::FETCH_COLUMN);
            $children_statement->closeCursor();

            //Struktur merken
            $weitere = count($children);
            $this->lines[$level + 1] = $weitere;

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

            //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']["move_object"]) {
                $temp  = "&nbsp;<a href=\"".URLHelper::getLink('?target_object='.$resObject->id)."#a\">";
                $temp .= Icon::create('arr_2right', 'sort', ['title' => _('Objekt in diese Ebene verschieben')])->asImg();
                $temp .= "</a>";
                $icon = $temp . $icon;
            }

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

            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()));

            $new = true;

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

            if ($open == 'open') {
                //load the perms
                if (($ActualObjectPerms) && ($ActualObjectPerms->getId() == $resObject->getId())) {
                    $perms = $ActualObjectPerms->getUserPerm();
                } else {
                    $ThisObjectPerms = ResourceObjectPerms::Factory($resObject->getId());
                    $perms = $ThisObjectPerms->getUserPerm();
                }

                if ($edit_structure_object==$resObject->id) {
                    $content.= "<br><textarea name=\"change_description\" rows=3 cols=40>".htmlReady($resObject->getDescription())."</textarea><br>";
                    $content .= Button::create(_('Übernehmen'), 'send', array('value' => _('Änderungen speichern')));
                    $content .= LinkButton::createCancel(_('Abbrechen'), URLHelper::getURL('?cancel_edit=' . $resObject->id));
                    $content.= "<input type=\"hidden\" name=\"change_structure_object\" value=\"".$resObject->getId()."\">";
                    $open="open";
                } else {
                    $content=htmlReady($resObject->getDescription());
                }
                if ($_SESSION['resources_data']["move_object"] == $resObject->id) {
                    $content .= '<br>';
                    $content .= sprintf(_('Dieses Objekt wurde zum Verschieben markiert. '
                                         .'Bitte wählen Sie das Einfügen-Symbol %s, um es in die gewünschte Ebene zu verschieben.'),
                                        Icon::create('arr_2right', 'sort', ['title' => _('Klicken Sie auf dieses Symbol, um dieses Objekt in eine andere Ebene zu verschieben')])->asImg(16));
                }

                if ($resObject->getCategoryId()) {
                    $edit .= LinkButton::create(_('Belegung'), URLHelper::getURL('?view=view_schedule&show_object=' . $resObject->id));
                }
                $edit .= LinkButton::create(_('Eigenschaften'), URLHelper::getURL('?view=view_details&show_object=' . $resObject->id));


                if ($perms == "admin") {
                    if ($resObject->isRoom()) {
                        $edit .= LinkButton::create(_('Benachrichtigung'), UrlHelper::getScriptURL('dispatch.php/resources/helpers/resource_message/' . $resObject->id), array('data-dialog' => ''));
                    }
                    $edit .= "&nbsp;&nbsp;&nbsp;&nbsp;";
                    $edit .= LinkButton::create(_('Neues Objekt'), URLHelper::getURL('?create_object=' . $resObject->id));
                    $edit .= LinkButton::create(_('Neue Ebene'), URLHelper::getURL('?create_hierachie_level=' . $resObject->id));
                }

                $edit.= "&nbsp;&nbsp;&nbsp;&nbsp;";

                if ($weitere) {
                    $edit .= LinkButton::create(_('Liste öffnen'), URLHelper::getURL('?open_list=' . $resObject->id));
                }

                if ($_SESSION['resources_data']["move_object"] == $resObject->id) {
                    $edit .= LinkButton::createCancel(_('Abbrechen'), URLHelper::getURL('?cancel_move=TRUE'));
                } else if ($perms == "admin") {
                    $edit .= LinkButton::create(_('Verschieben'), URLHelper::getURL('?pre_move_object=' . $resObject->id));
                }

                if (!$weitere && $perms == "admin" && $resObject->isDeletable()) {
                    $edit .= LinkButton::create(_('Löschen'), '?kill_object=' . $resObject->id);
                }
            }

            $edit .= '</div></div>';

            //Daten an Ausgabemodul senden (aus resourcesVisual)
            $this->showRow($icon, $link, $titel, $zusatz, $level, $lines, $weitere, $new, $open, $content, $edit);

            //in weitere Ebene abtauchen &nbsp;
            foreach ($children as $child_id) {
                if ($_SESSION['resources_data']['structure_opens'][$resource_id])
                    $this->showThreadLevel($child_id, $level + 1, $lines);
            }
        }
    }