Esempio n. 1
0
    $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $SessSemName[1]));
    $query = "SELECT range_id, dokument_id, url
              FROM dokumente
              WHERE seminar_id = ? AND user_id != ?
                AND GREATEST(mkdate, IFNULL(chdate, 0)) > ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array(
        $SessSemName[1],
        $user->id,
        Request::int('zipnewest'),
    ));
    $download_ids = $statement->fetchAll(PDO::FETCH_ASSOC);

    foreach($download_ids as $key => $dl_id) {
        if ($folder_tree->isDownloadFolder($dl_id['range_id'], $user->id)
            && check_protected_download($dl_id['dokument_id']) && $dl_id['url'] == "") {
            $download_ids[$key] = $dl_id['dokument_id'];
        } else {
            unset($download_ids[$key]);
        }
    }
    if (count($download_ids)>0) {
        $zip_file_id = createSelectedZip($download_ids, true, true);
        if($zip_file_id){
            $zip_name = prepareFilename($SessSemName[0].'-'._("Neue Dokumente").'.zip');
            header('Location: ' . getDownloadLink( $zip_file_id, $zip_name, 4));
            page_close();
            die;
        }
    }
}
Esempio n. 2
0
/**
 * Displays one file/document with all of its information and options.
 *
 */
function display_file_line ($datei, $folder_id, $open, $change, $move, $upload, $all, $refresh=FALSE, $filelink="", $anchor_id, $position = "middle") {
    global $_fullname_sql,$SessionSeminar,$SessSemName, $rechte, $anfang,
        $user, $SemSecLevelWrite, $SemUserStatus, $check_all, $countfiles;
    //Einbinden einer Klasse, die Informationen über den ganzen Baum enthält
    $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $SessionSeminar));
    $javascriptok = true;
    print "\n\t<div class=\"".($rechte ? "draggable" : "")."\" id=\"file_".$folder_id."_$countfiles\">";
    print "<div style=\"display:none\" id=\"getmd5_fi".$folder_id."_$countfiles\">".$datei['dokument_id']."</div>";
    print "<table cellpadding=0 border=0 cellspacing=0 width=\"100%\"><tr class=\"handle\">";
    if (!$all) {
        print "<td class=\"tree-elbow-end\">" . Assets::img("datatree_2.gif") . "</td>";
    }

    //Farbe des Pfeils bestimmen:
    $chdate = (($datei["chdate"]) ? $datei["chdate"] : $datei["mkdate"]);
    if (object_get_visit($SessSemName[1], "documents") < $chdate)
        $timecolor = "#FF0000";
    else {
        $timediff = (int) log((time() - doc_newest($folder_id)) / 86400 + 1) * 15;
        if ($timediff >= 68)
            $timediff = 68;
        $red = dechex(255 - $timediff);
        $other = dechex(119 + $timediff);
        $timecolor= "#" . $red . $other . $other;
    }

    if ($open[$datei["dokument_id"]]) {
        print "<td id=\"file_".$datei["dokument_id"]."_arrow_td\" nowrap valign=\"top\"" .
            "align=\"left\" width=1% bgcolor=\"$timecolor\" class=\"printhead3\" valign=\"bottom\"><a href=\"";
        print URLHelper::getLink("?close=".$datei["dokument_id"]."#anker");
        print "\" class=\"tree\" onClick=\"return STUDIP.Filesystem.changefilebody('".
            $datei["dokument_id"]."', '".$SessionSeminar."')\">".
            Assets::img('forumgraurunt2.png', tooltip2(_('Objekt zuklappen')) + array('id' => 'file_'. $datei["dokument_id"] . '_arrow_img')).
            "</a></td>";
    } else {
        print "<td id=\"file_".$datei["dokument_id"]."_arrow_td\" nowrap valign=\"top\" align=\"left\" width=1% bgcolor=\"$timecolor\" class=\"printhead2\" valign=\"bottom\"><a href=\"";
        print URLHelper::getLink("?open=".$datei["dokument_id"]."#anker");
        print "\" class=\"tree\" onClick=\"return STUDIP.Filesystem.changefilebody('".
            $datei["dokument_id"]."', '".$SessionSeminar."')\">".
            Assets::img('forumgrau2.png', tooltip2(_('Objekt aufklappen')) + array('id' => 'file_'. $datei["dokument_id"] . '_arrow_img')).
            "</a></td>";
    }

    // -> Pfeile zum Verschieben (bzw. die Ziehfläche)
    if ((!$all) && ($rechte)) {
        $countfiles++;
        $bewegeflaeche = "<span class=\"updown_marker\" id=\"pfeile_".$datei["dokument_id"]."\">";
        if (($position == "middle") || ($position == "bottom")) {
            $bewegeflaeche .= "<a href=\"".URLHelper::getLink('?open='.$datei['dokument_id'])."_mfu_\" title=\""._("Datei nach oben schieben").
                "\">" . Icon::create('arr_2up', 'sort')->asImg(['class' => 'text-top']) . "</a>";
        }
        if (($position == "middle") || ($position == "top")) {
            $bewegeflaeche .= "<a href=\"".URLHelper::getLink('?open='.
                    $datei['dokument_id'])."_mfd_\" title=\""._("Datei nach unten schieben").
                    "\">". Icon::create('arr_2down', 'sort')->asImg(['class' => 'text-top']) . "</a>";
        }
        $bewegeflaeche .= "</span>";
    }

    print "<td class=\"printhead\" valign=\"bottom\">";
    if ($change == $datei["dokument_id"]) {
        print "<span id=\"file_".$datei["dokument_id"]."_header\" style=\"font-weight: bold\"><a href=\"".URLHelper::getLink("?close=".$datei["dokument_id"]."#anker")."\" class=\"tree\"";
        print ' name="anker"></a>';
        print GetFileIcon(getFileExtension($datei['filename']))->asImg();
        print "<input style=\"font-size: 8pt; width: 50%;\" type=\"text\" size=\"20\" maxlength=\"255\" name=\"change_name\" aria-label=\"Ordnername eingeben\" value=\"".htmlReady($datei["name"])."\"></b>";
    } else {
        if (($move == $datei["dokument_id"]) ||  ($upload == $datei["dokument_id"]) || ($anchor_id == $datei["dokument_id"])) {
            print "<a name=\"anker\"></a>";
        }
        $type = ($datei['url'] != '')? 6 : 0;
        // LUH Spezerei:
        if (check_protected_download($datei["dokument_id"])) {
            print "<a href=\"".GetDownloadLink( $datei["dokument_id"], $datei["filename"], $type, "normal")."\" class=\"extern\">".GetFileIcon(getFileExtension($datei['filename']))->asImg()."</a>";
        } else {
            print Icon::create('info-circle', 'inactive')->asImg();
        }
        //Jetzt folgt der Link zum Aufklappen
        if ($open[$datei["dokument_id"]]) {
      print "<a href=\"".URLHelper::getLink("?close=".$datei["dokument_id"]."#anker")."\" class=\"tree\" onClick=\"return STUDIP.Filesystem.changefilebody('".$datei["dokument_id"]."')\">";
            print "&nbsp;<span id=\"file_".$datei["dokument_id"]."_header\" style=\"font-weight: bold\">";
        } else {
            print "<a href=\"".URLHelper::getLink("?open=".$datei["dokument_id"]."#anker")."\" class=\"tree\" onClick=\"return STUDIP.Filesystem.changefilebody('".$datei["dokument_id"]."')\">";
            print "&nbsp;<span id=\"file_".$datei["dokument_id"]."_header\" style=\"font-weight: normal\">";
        }
        print htmlReady($datei['t_name']);

        print "</span>";
    }

    //add the size
    print '&nbsp;&nbsp;(' . relsize($datei['filesize'], $datei['filesize'] < 1024);

    //add number of downloads
    print " / ".(($datei["downloads"] == 1) ? $datei["downloads"]." "._("Download") : $datei["downloads"]." "._("Downloads")).")";


    //So und jetzt die rechtsbündigen Sachen:
    print "</a></td><td align=\"right\" class=\"printhead\" valign=\"bottom\">";
    if ($datei['username']) {
        print "<a href=\"".URLHelper::getLink('dispatch.php/profile?username='******'username'])."\">".htmlReady($datei['fullname'])."</a> ";
    } else {
        print htmlReady($datei['author_name']);
    }
    print $bewegeflaeche." ";

    //Workaround for older data from previous versions (chdate is 0)
    print " ".date("d.m.Y - H:i", (($datei["chdate"]) ? $datei["chdate"] : $datei["mkdate"]));

    if ($all) {
      if ((!$upload) && ($datei["url"]=="") && check_protected_download($datei["dokument_id"])) {
        $checked = ($check_all || in_array($datei["dokument_id"], Request::getArray('download_ids'))) ? 'checked' : '';
        $box = sprintf ("<input type=\"CHECKBOX\" %s name=\"download_ids[]\" value=\"%s\">",$checked , $datei["dokument_id"]);
        print $box;
      } else {
        echo Icon::create('decline', 'inactive', ['title' => _("Diese Datei kann nicht als ZIP-Archiv heruntergeladen werden."), 'style' => 'padding-left:5px;'])->asImg();
    }
    }
    print "</td></tr>";

    //Ab jetzt kommt der Bereich zum Runterladen und Bearbeiten:
    if (isset($open[$datei["dokument_id"]])) {
        //Dokument-Content ausgeben
        print "<tr id=\"file_".$datei["dokument_id"]."_body_row\">".(($all) ? "" : "<td></td>")."<td colspan=3><div id=\"file_".$datei["dokument_id"]."_body\">";
        //Der eigentliche Teil ist outsourced in die folgende Funktion,
        //damit der Körper auch über Ajax abgerufen werden kann.
        display_file_body($datei, $folder_id, $open, $change, $move, $upload, $all, $refresh, $filelink);
    } else {
        print "<tr id=\"file_".$datei["dokument_id"]."_body_row\">".(($all) ? "" : "<td></td>")."<td colspan=3><div id=\"file_".$datei["dokument_id"]."_body\" style=\"display:none\">";
    }
    print "</div></td></tr></table>\n\t</div>";
}
Esempio n. 3
0
 /**
  * checks access to the document for user with given user_id
  * the number of deleted rows.
  * @param string user_id: id of the user
  * @return boolean: true if user has access to the document
  */
 public function checkAccess($user_id)
 {
     if (!$this->getValue('dokument_id')) {
         return false;
     }
     $object_type = get_object_type($this->getValue('seminar_id'));
     $access = false;
     if (in_array($object_type, array('inst', 'fak'))) {
         //download from institute and user is always allowed
         if (get_config('ENABLE_FREE_ACCESS') || $GLOBALS['perm']->have_perm('user', $user_id)) {
             $access = true;
         } else {
             //check external download module (types 6 and 10)
             $result = DBManager::get()->query("SELECT * FROM extern_config WHERE range_id = '" . $this->getValue('seminar_id') . "' AND config_type IN (6,10)")->fetchColumn();
             $access = (bool) $result;
         }
     } else {
         if ($object_type == 'sem') {
             //download from course is allowed if course is free for all or user is participant
             if (Seminar::GetInstance($this->getValue('seminar_id'))->isPublic()) {
                 $access = true;
             } else {
                 $access = $GLOBALS['perm']->have_studip_perm('user', $this->getValue('seminar_id'), $user_id);
             }
         } else {
             if ($object_type == 'user') {
                 // message attachement
                 $st = DBManager::get()->prepare("SELECT message_user.user_id FROM dokumente\n                INNER JOIN message_user ON message_id=range_id\n                WHERE dokument_id = ?");
                 $st->execute(array($this->getValue('dokument_id')));
                 $message_user = $st->fetchAll(PDO::FETCH_COLUMN);
                 if (count($message_user)) {
                     $access = in_array($user_id, $message_user);
                 } else {
                     //Blubberdatei aus persönlichem Blubb
                     $access = $GLOBALS['perm']->have_perm('user', $user_id);
                 }
             }
         }
     }
     //if allowed basically, check for closed folders and protected documents
     if ($access && in_array($object_type, array('inst', 'fak', 'sem'))) {
         $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $this->getValue('seminar_id')));
         if (!$folder_tree->isDownloadFolder($this->getValue('range_id'), $user_id)) {
             $access = false;
         }
         if (!check_protected_download($this->getValue('dokument_id'))) {
             $access = false;
         }
     }
     return $access;
 }