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

current code from svn, revision 62608

parents
Branches
No related tags found
No related merge requests found
Showing
with 2484 additions and 0 deletions
# EditorConfig is awesome: http://EditorConfig.org
# Top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
spaces_around_operators = true
spaces_around_brackets = outside
trim_trailing_whitespace = true
[*.php]
block_comment_start = /*
block_comment_end = */
line_comment = //
quote_type = single
.npmrc 0 → 100644
engine-strict=true
AUTHORS 0 → 100644
----------------------------------------------------------------------------
The Stud.IP CoreGroup
----------------------------------------------------------------------------
Marco Bohnsack <bohnsack@data-quest.de>
Rasmus Fuhse <fuhse@data-quest.de>
Till Glggler <tgloeggl@uos.de>
Thomas Hackl <thomas.hackl@uni-passau.de>
Cornelis Kater <kater@elsa.uni-hannover.de>
Elmar Ludwig <elmar.ludwig@uos.de>
Marcus Lunzenauer <marcus.lunzenauer@elanag.com>
Nico Mller <nico.mueller@uni-oldenburg.de>
Andr Noack <noack@data-quest.de>
Cornelia Roser <roser@hawk-hhg.de>
Sabine Scheele <sabine.scheele@hrz.uni-giessen.de>
David Siegfried <david.siegfried@uni-vechta.de>
Martin Stratmann <martin@herrstratmann.de>
Stefan Suchi <suchi@data-quest.de>
Peter Thienel <thienel@data-quest.de>
Jan-Hendrik Willms <tleilax@gmail.com>
----------------------------------------------------------------------------
Credits and Comments
----------------------------------------------------------------------------
Boris Erdmann <be@shonline.de>
Kristian Khntopp <kk@shonline.de>
PHPLib Development, all classes
Manuel Lemos <mlemos@acm.org>
E-mail address validation class
SMTP E-mail sending class
> Both classes taken with some minor changes from
> http://phpclasses.upperdesign.com
Brad Bulger <brad@wired.com>
Threaded Discussion with PHP/MySQL
> widely changed, based on a tutorial at webmonkey
Erik Bosrup
overLIB
> JavaScript library created to enhance websites with small popup boxes (tooltips)
> http://www.bosrup.com/web/overlib
Benjamin Zeiss <zeiss@math.uni-goettingen.de>
LaTex rendering class
> http://www.kellnerweg.de/~bzeiss/
Alexander Willner <mail@alexanderwillner.de>
Christian Bauer <cbauer79@gmx.net>
Michael Cohrs <michael@cohrs.de>
John Wowra <johnnyw@technologist.com>
voting-module, evaluation-module
Christian Bauer <cbauer79@gmx.net>
vCard-export, record of study
Florian Hansen <florian_h@gmx.net>
WAP pages for Stud.IP
Tobias Mller <tmoelle1@gwdg.de>
Stud.IP-Logo
Rosemary Wilson <rwilson@uni-goettingen.de>
Hartje Kriete <kriete@math.uni-goettingen.de>
Englisch translation
Oliver Brakel <obrakel@studip.de>
One of the initiators of Stud.IP
Arne Schrder <schroeder@data-quest.de>
Ilias2-Interface, E-Learning-Modules-Interface, Export
Dennis Reil <Dennis.Reil@offis.de>
PlugIn-Interface
Nils Kolja Windisch <info@nkwindisch.de>
Messaging System, Stud.IP Blog
Ralf Stockmann <rstockm@gwdg.de>
Forum System, Address Book, Design
Torsten Heinrich <to.heinrich@fh-osnabrueck.de>
Administration of times and room information
Jens Schmelzer <jens.schmelzer@fh-jena.de>
Smiley administration, calendar pop-up, lots of security related bugfixes
Jrg Rpke <roepke@uni-trier.de>
Tobias Thelen <tobias.thelen@uos.de>
Stud.IP help, event logging, wiki enhancements
Hartje Kriete <kriete@math.uni-goettingen.de>
English translation
Carola Kruse <carola.kruse@tu-braunschweig.de>
Jan Kulmann <jankul@zmml.uni-bremen.de>
Evaluation results, literature import, RSS-reader, plugins
Michael Riehemann <michael.riehemann@uni-oldenburg.de>
Frank Ollermann <frank.ollermann@uni-osnabrueck.de>
GUI & Usability
Arne Koesling <koesling@elsa.uni-hannover.de>
Andr Klaen <aklassen@uos.de>
----------------------------------------------------------------------------
CreativeCommons sources
----------------------------------------------------------------------------
Daniel Ulrich:
http://www.flickr.com/photos/threedots/177592275/
----------------------------------------------------------------------------
Any others whose names we probably forgot to add (email us and we'll put you
in here)
- The StudIP Core Group <info@studip.de> 2021
COPYING 0 → 100644
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
This diff is collapsed.
This diff is collapsed.
INSTALL 0 → 100644
Die Installation von Stud.IP ist halb so schlimm:
es müssen lediglich ein paar Dateien kopiert werden und ein paar
Programme laufen ;-)
Vorausgesetzt wird ein Webserver wie Apache2 oder nginx mit PHP-7.0 Modulen und
eine MySQL 5.7.6 Datenbank.
Was genau zu tun ist, steht in
> doc/de/studip-installation-guide-de-401.pdf
Sie können nach dem Kopieren der Dateien auf den Webserver und dem korrekten
Aufsetzen des Webservers auch unseren Installationsassistenten nutzen, den Sie
über den Pfad "install.php" Ihrer vorbereiteten Stud.IP-Installation aufrufen
können.
Also reinsehen und ausprobieren... Viel Spass damit!
You get in an try out. Have a lot of fun!
- The StudIP Core Group <info@studip.de> 2021
Makefile 0 → 100644
CODECEPT = composer/bin/codecept
SVGO = node_modules/svgo/bin/svgo
RESOURCES = $(shell find resources -type f)
# build all needed files
build: composer webpack-prod
# remove all generated files
clean: clean-composer clean-npm clean-webpack clean-doc
composer: composer/composer/installed.json
composer-dev: $(CODECEPT)
composer/composer/installed.json: composer.json composer.lock
composer install --no-dev
@touch $@
$(CODECEPT): composer.json composer.lock
composer install
@touch $@
clean-composer:
rm -rf composer
npm: node_modules/.package-lock.json
node_modules/.package-lock.json: package.json package-lock.json
npm install --no-save
clean-npm:
rm -rf node_modules
webpack-dev: .webpack.dev
webpack-prod: .webpack.prod
webpack-watch: npm
npm run webpack-watch
wds: npm
npm run wds
.webpack.dev: node_modules/.package-lock.json $(RESOURCES)
@rm -f .webpack.prod
npm run webpack-dev
@touch $@
.webpack.prod: node_modules/.package-lock.json $(RESOURCES)
@rm -f .webpack.dev
npm run webpack-prod
@touch $@
clean-webpack:
@rm -f .webpack.dev .webpack.prod
rm -rf public/assets/javascripts/*.js
rm -rf public/assets/javascripts/*.js.map
rm -rf public/assets/stylesheets/*.css
rm -rf public/assets/stylesheets/*.css.map
doc: force_update
doxygen Doxyfile
clean-doc:
rm -rf doc/html
test: test-unit
test-functional: $(CODECEPT)
$(CODECEPT) run functional
test-jsonapi: $(CODECEPT)
$(CODECEPT) run jsonapi
test-unit: $(CODECEPT)
$(CODECEPT) run unit
optimize-icons: npm
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/black -r
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/blue -r
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/green -r
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/grey -r
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/red -r
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/white -r
$(SVGO) --config=config/svgo.config.js -f public/assets/images/icons/yellow -r
# dummy target to force update of "doc" target
force_update:
LOCALES = en
NPM_BIN = $(shell npm bin)
VUE_GETTEXT_SOURCES = $(shell find ./resources -name '*.js' -o -name '*.vue' 2> /dev/null)
VUE_PO_FILE = js-resources.po
VUE_POT_FILE = ./locale/js-ressources.pot
VUE_TRANSLATIONS = ./resources/locales/translations.json
VUE_TRANSLATION_FILES ?= $(patsubst %,./resources/locales/%.json,$(LOCALES))
VUE_LOCALE_FILES ?= $(patsubst %,./locale/%/LC_MESSAGES/$(VUE_PO_FILE),$(LOCALES))
vue-gettext-extract: $(VUE_POT_FILE)
vue-gettext-compile: $(VUE_TRANSLATION_FILES)
vue-gettext-clean:; rm -f $(VUE_POT_FILE) $(VUE_TRANSLATIONS) $(VUE_TRANSLATIONS)
$(VUE_POT_FILE): $(VUE_GETTEXT_SOURCES)
$(NPM_BIN)/gettext-extract --quiet --attribute v-translate \
--output $@ $(VUE_GETTEXT_SOURCES)
@for lang in $(LOCALES); do \
export PO_FILE=./locale/$$lang/LC_MESSAGES/$(VUE_PO_FILE); \
if [ -f $$PO_FILE ]; then \
msgmerge --lang=$$lang \
-o $$PO_FILE \
-C $$PO_FILE \
./locale/$$lang/LC_MESSAGES/studip.po $@ || break ;\
msgattrib --set-obsolete --ignore-file=$(VUE_POT_FILE) -o $$PO_FILE $$PO_FILE; \
msgattrib --no-obsolete -o $$PO_FILE $$PO_FILE; \
else \
msginit --no-translator --locale=$$lang --input=$@ --output-file=$$PO_FILE || break ; \
msgattrib --no-wrap --no-obsolete -o $$PO_FILE $$PO_FILE || break; \
fi; \
done;
$(VUE_TRANSLATIONS): $(VUE_LOCALE_FILES)
$(NPM_BIN)/gettext-compile --output $@ $(VUE_LOCALE_FILES)
$(VUE_TRANSLATION_FILES): $(VUE_TRANSLATIONS)
php cli/vue-gettext-split-translations.php
README 0 → 100644
Stud.IP
For more information on Stud.IP please visit our website at
http://www.studip.de
or our developer forum at
http://develop.studip.de
For information on how to install this package please read the INSTALL file.
All files contained in this archive are licensed as stated in the COPYING
file. Please check out the AUTHORS file to see who helped make this possible.
If you find any bugs please feel free and send an e-mail to crew@studip.de.
You can also use our bugtracker located at:
http://develop.studip.de
Future versions of this code can be downloaded from:
http://sourceforge.net/projects/studip
Thanks for taking the time to download this code. If you have any questions
please feel free to contact us.
- The StudIP Core Group <info@studip.de> 2021
UPDATE 0 → 100644
Seit der Version 1.6 gibt es einen Migrationsmechanismus für die Stud.IP Datenbank.
Eingesetzt werden kann dieser ab einem Wechsel von Stud.IP 1.5.0-2 zu 1.6.0-1:
- DATENSICHERUNG durchführen!
- ACHTUNG! Der Migrationsmechanismus ist für Sprünge über mehrere major releases
nicht getestet! Zumindest für einen Sprung von 1.5.x auf 1.7.x oder neuer
sind Probleme bekannt.
- die alten Scriptdateien durch die neuen ersetzen, dabei besonders auf die Dateien
im Verzeichnis config sowie auf eventuelle eigene Anpassungen achten.
- Datenbankaktualisierungen entweder über die Webschnittstelle:
http://mein.server.de/studip/web_migrate.php
- ODER über die Komandozeile:
studip-4.6/cli/migrate.php
vornehmen.
- ACHTUNG! Bei einem Upgrade von Version 3.x auf Version 4.x muss die alte
Konfigurationsdatei config_local.inc.php noch im Konfigurationsverzeichnis liegen
während die Migrationen ausgeführt werden.
- The StudIP Core Group <info@studip.de> 2021
RELEASE 5.0.alpha-svn
<?php
/**
* additonal.php - controller class for the additonal data
*
* Admin of a Seminar can chose his required aux data and decide if it is
* forced from the user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Florian Bieringer <florian.bieringer@uni-passau.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package admin
* @since 3.0
*/
class Admin_AdditionalController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
// Load the course
$this->course = Course::findCurrent();
// Check permissions to be on this site
if (!$GLOBALS['perm']->have_studip_perm("tutor", $this->course->id)) {
throw new AccessDeniedException(_("Sie haben keine Berechtigung diese " .
"Veranstaltung zu verändern."));
}
}
/**
* Index displays and updates
*/
public function index_action()
{
/*
* Updaterequest
*/
if (Request::submitted('save')) {
if ($rule = Request::get('aux_data')) {
$this->course->aux_lock_rule = $rule;
$this->course->aux_lock_rule_forced = Request::get('forced') ? : 0;
} else {
// If no rule is set we cant force it
$this->course->aux_lock_rule = null;
$this->course->aux_lock_rule_forced = 0;
}
// purge data
if (Request::submitted('delete')) {
$stmt = DBManager::get()->prepare('DELETE FROM datafields_entries WHERE sec_range_id = ?');
$stmt->execute([$this->course->id]);
}
if ($this->course->store()) {
if (!is_null($this->course->aux_lock_rule)) {
PageLayout::postSuccess(_('Zusatzangaben wurden erfolgreich zugeordnet'));
} else {
PageLayout::postSuccess(_('Zuweisung der Zusatzangaben wurden aufgehoben'));
}
}
}
// Fetch data
$stmt = DBManager::get()->prepare('SELECT COUNT(*) FROM datafields_entries WHERE sec_range_id = ?');
$stmt->execute([$this->course->id]);
$this->count = $stmt->fetchColumn();
$this->list = AuxLockRule::findBySQL('1=1');
}
}
<?php
/**
*
**/
class Admin_ApiController extends AuthenticatedController
{
/**
*
**/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
require_once 'lib/bootstrap-api.php';
$GLOBALS['perm']->check('root');
Navigation::activateItem('/admin/config/api');
PageLayout::setTitle(_('API Verwaltung'));
$this->types = [
'website' => _('Website'),
'desktop' => _('Herkömmliches Desktopprogramm'),
'mobile' => _('Mobile App')
];
// Sidebar
$views = new ViewsWidget();
$views->addLink(_('Registrierte Applikationen'),
$this->url_for('admin/api'))
->setActive($action === 'index');
$views->addLink(_('Globale Zugriffseinstellungen'),
$this->url_for('admin/api/permissions'))
->setActive($action == 'permissions');
$views->addLink(_('Konfiguration'),
$this->url_for('admin/api/config'))
->setActive($action == 'config');
Sidebar::get()->addWidget($views);
$actions = new ActionsWidget();
$actions->addLink(_('Neue Applikation registrieren'),
$this->url_for('admin/api/edit'),
Icon::create('add', 'clickable'))
->asDialog();
Sidebar::get()->addWidget($actions);
}
/**
*
**/
public function index_action()
{
$this->consumers = RESTAPI\Consumer\Base::findAll();
$this->routes = RESTAPI\Router::getInstance()->getRoutes(true);
}
/**
*
**/
public function render_keys($id)
{
$consumer = RESTAPI\Consumer\Base::find($id);
return [
'Consumer Key = ' . $consumer->auth_key,
'Consumer Secret = ' . $consumer->auth_secret,
];
}
/**
*
**/
public function keys_action($id)
{
$details = $this->render_keys($id);
if (Request::isXhr()) {
$this->render_text(implode('<br>', $details));
} else {
PageLayout::postMessage(MessageBox::info(_('Die Schlüssel in den Details dieser Meldung sollten vertraulich behandelt werden!'), $details, true));
$this->redirect('admin/api/#' . $id);
}
}
/**
*
**/
public function edit_action($id = null)
{
$consumer = $id
? RESTAPI\Consumer\Base::find($id)
: RESTAPI\Consumer\Base::create(Request::option('consumer_type') ?: 'oauth');
if (Request::submitted('store')) {
$errors = [];
$consumer->active = (bool) Request::int('active');
$consumer->title = Request::get('title');
$consumer->contact = Request::get('contact');
$consumer->email = Request::get('email');
$consumer->callback = Request::get('callback');
$consumer->url = Request::get('url');
$consumer->type = Request::get('type') ?: null;
$consumer->commercial = Request::int('commercial');
$consumer->notes = Request::get('notes');
$consumer->description = Request::get('description');
if (!empty($errors)) {
$message = MessageBox::error(_('Folgende Fehler sind aufgetreten:'), $errors);
PageLayout::postMessage($message);
return;
}
$consumer->store();
if ($id) {
$message = MessageBox::success(_('Die Applikation wurde erfolgreich gespeichert.'));
} else {
$details = $this->render_keys($consumer->id);
$message = MessageBox::success(_('Die Applikation wurde erfolgreich erstellt, die Schlüssel finden Sie in den Details dieser Meldung.'), $details, true);
}
PageLayout::postMessage($message);
$this->redirect('admin/api/index#' . $consumer->id);
return;
}
$this->consumer = $consumer;
$this->id = $id;
}
/**
*
**/
public function toggle_action($id, $state = null)
{
$consumer = RESTAPI\Consumer\Base::find($id);
$consumer->active = $state === null ? !$consumer->active : ($state === 'on');
$consumer->store();
$message = $state
? _('Die Applikation wurde erfolgreich aktiviert.')
: _('Die Applikation wurde erfolgreich deaktiviert.');
PageLayout::postMessage(MessageBox::success($message));
$this->redirect('admin/api/#' . $consumer->id);
}
/**
*
**/
public function delete_action($id)
{
if (!Request::isPost()) {
throw new MethodNotAllowedException();
}
if ($consumer = RESTAPI\Consumer\Base::find($id)) {
$consumer->delete();
PageLayout::postSuccess(_('Die Applikation wurde erfolgreich gelöscht.'));
}
$this->redirect('admin/api');
}
/**
*
**/
public function permissions_action($consumer_id = null)
{
if (Request::submitted('store')) {
$perms = Request::getArray('permission');
$permissions = RESTAPI\ConsumerPermissions::get($consumer_id ?: 'global');
foreach ($perms as $route => $methods) {
foreach ($methods as $method => $granted) {
$permissions->set(urldecode($route), urldecode($method), (bool)$granted, true);
}
}
$permissions->store();
PageLayout::postMessage(MessageBox::success(_('Die Zugriffsberechtigungen wurden erfolgreich gespeichert')));
$this->redirect($consumer_id ? 'admin/api' : 'admin/api/permissions');
return;
}
$title = $consumer_id ? _('Zugriffsberechtigungen') : _('Globale Zugriffsberechtigungen');
$title .= ' - ' . PageLayout::getTitle();
PageLayout::setTitle($title);
$this->consumer_id = $consumer_id;
$this->router = RESTAPI\Router::getInstance();
$this->routes = $this->router->getRoutes(true, false);
$this->permissions = RESTAPI\ConsumerPermissions::get($consumer_id ?: 'global');
$this->global = $consumer_id ? RESTAPI\ConsumerPermissions::get('global') : false;
}
public function config_action()
{
$this->config = Config::get();
if (Request::isPost()) {
$this->config->store('API_ENABLED', Request::int('active', 0));
$this->config->store('API_OAUTH_AUTH_PLUGIN', Request::option('auth'));
PageLayout::postMessage(MessageBox::success(_('Die Einstellungen wurden gespeichert.')));
$this->redirect('admin/api/config');
}
}
}
<?php
/**
* autu_insert.php - controller class for the auto insert seminars
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Nico Müller <nico.mueller@uni-oldenburg.de>
* @author Michael Riehemann <michael.riehemann@uni-oldenburg.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package admin
* @since 2.1
*/
class Admin_AutoinsertController extends AuthenticatedController
{
/**
* Common tasks for all actions.
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
// user must have root permission
$GLOBALS['perm']->check('root');
Navigation::activateItem('/admin/user/auto_insert');
PageLayout::setTitle(_('Automatisiertes Eintragen verwalten'));
PageLayout::setHelpKeyword('Admins.AutomatisiertesEintragen');
}
/**
* Maintenance view for the auto insert parameters
*
*/
public function index_action()
{
// search seminars
if (Request::submitted('suchen')) {
if (Request::get('sem_search')) {
$this->sem_search = Request::get('sem_search');
$this->sem_select = Request::option('sem_select');
$search = new SeminarSearch();
$this->seminar_search = $search->getResults
(Request::get('sem_search'),
['search_sem_sem' => Request::option('sem_select')]
);
if (count($this->seminar_search) == 0) {
PageLayout::postInfo(_('Es wurden keine Veranstaltungen gefunden.'));
}
} else {
PageLayout::postError(_('Bitte geben Sie einen Suchparameter ein.'));
}
}
$seminare = AutoInsert::getAllSeminars();
$this->auto_sems = $seminare;
$domains = [];
$domains[] = [
'id' => 'keine',
'name' => _('Ohne Domäne'),
];
foreach (UserDomain::getUserDomains() as $domain) {
$domains[] = $domain;
}
$this->userdomains = $domains;
$links = new ActionsWidget();
$links->addLink(
_('Benutzergruppen manuell eintragen'),
$this->manualURL(),
Icon::create('visibility-visible')
);
Sidebar::Get()->addWidget($links);
}
/**
* Create a new seminar for auto insert
*/
public function new_action()
{
if (Request::submitted('anlegen')) {
$sem_id = Request::option('sem_id');
$domains = Request::getArray('rechte');
if (empty($domains)) {
PageLayout::postError(_('Mindestens ein Status sollte selektiert werden!'));
} else {
foreach ($domains as $id => $rechte) {
if ($id === 'keine')
$id = '';
if (!AutoInsert::checkSeminar($sem_id, $id)) {
AutoInsert::saveSeminar($sem_id, $rechte, $id);
PageLayout::postSuccess(_('Die Zuordnung wurde erfolgreich gespeichert!'));
} else {
PageLayout::postError(_('Das Seminar wird bereits zu diesem Zweck verwendet!'));
}
}
}
}
$this->redirect('admin/autoinsert');
}
/**
* Edit a rule
*
* @param string $seminar_id
*/
public function edit_action($seminar_id)
{
$domain = Request::get('domain_id');
$status = Request::get('status');
$remove = Request::get('remove');
if ($domain === 'keine')
$domain = '';
AutoInsert::updateSeminar($seminar_id, $domain, $status, $remove);
PageLayout::postSuccess(_('Die Statusgruppenanpassung wurde erfolgreich übernommen!'));
$this->redirect('admin/autoinsert');
}
/**
* Removes a seminar from the auto-insert list, with modal dialog
*
* @param string $seminar_id
*/
public function delete_action($seminar_id)
{
if (Request::int('delete') === 1) {
if (AutoInsert::deleteSeminar($seminar_id)) {
PageLayout::postSuccess(_('Die Zuordnung der Veranstaltung wurde gelöscht!'));
}
} elseif (!Request::get('back')) {
$this->flash['delete'] = $seminar_id;
}
$this->redirect('admin/autoinsert');
}
/**
* Maintenance view for the manual insert parameters
*
*/
public function manual_action()
{
PageLayout::setTitle(_('Manuelles Eintragen von Nutzergruppen in Veranstaltungen'));
if (Request::submitted('submit')) {
$filters = array_filter(Request::getArray('filter'));
if (!Request::get('sem_id') || Request::get('sem_id') == 'false') {
PageLayout::postError(_('Ungültiger Aufruf'));
} elseif (!count($filters)) {
PageLayout::postError(_('Keine Filterkriterien gewählt'));
} else {
$seminar = Seminar::GetInstance(Request::option('sem_id'));
$group = select_group($seminar->getSemesterStartTime());
$userlookup = new UserLookup();
foreach ($filters as $type => $values) {
$userlookup->setFilter($type, $values);
}
$user_ids = $userlookup->execute();
$real_users = 0;
foreach ($user_ids as $user_id) {
if (!AutoInsert::checkAutoInsertUser(Request::option('sem_id'), $user_id)) {
$seminar->addMember($user_id);
$real_users += AutoInsert::saveAutoInsertUser(Request::option('sem_id'), $user_id);
}
}
//messagebox
$text = sprintf(
_('Es wurden %u von %u möglichen Personen in die Veranstaltung %s eingetragen.'),
$real_users,
count($user_ids),
sprintf(
'<a href="%s">%s</a>',
URLHelper::getLink('dispatch.php/course/details/', ['cid' => $seminar->getId()]),
htmlReady($seminar->getName()
)
)
);
$details = [_('Etwaige Abweichungen der Personenzahlen enstehen durch bereits vorhandene bzw. wieder ausgetragene Personen.')];
if ($real_users > 0) {
PageLayout::postSuccess($text, $details);
} else {
PageLayout::postInfo($text, $details);
}
$this->redirect('admin/autoinsert/manual');
}
}
$this->sem_id = Request::option('sem_id');
$this->sem_search = Request::get('sem_search');
$this->sem_select = Request::option('sem_select');
$this->filtertype = Request::getArray('filtertype');
$this->filter = Request::getArray('filter');
if (count(Request::getArray('remove_filter'))) {
$this->filtertype = array_diff($this->filtertype, array_keys(Request::getArray('remove_filter')));
} elseif (Request::submitted('add_filter')) {
array_push($this->filtertype, Request::get('add_filtertype'));
}
if (Request::get('sem_search') and Request::get('sem_select')) {
if (Request::get('sem_search')) {
$search = new SeminarSearch('number-name');
$this->seminar_search = $search->getResults(Request::get('sem_search'), ['search_sem_sem' => $this->sem_select]);
if (count($this->seminar_search) == 0) {
PageLayout::postInfo(_('Es wurden keine Veranstaltungen gefunden.'));
}
} else {
PageLayout::postError(_('Im Suchfeld wurde nichts eingetragen!'));
}
}
$this->values = [];
foreach ($this->filtertype as $type) {
$this->values[$type] = UserLookup::getValuesForType($type);
}
$this->available_filtertypes = [
'fach' => _('Studienfach'),
'abschluss' => _('Studienabschluss'),
'fachsemester' => _('Studienfachsemester'),
'institut' => _('Einrichtung'),
'status' => _('Statusgruppe'),
'domain' => _('Domäne')
];
$links = new ActionsWidget();
$links->addLink(_('Übersicht'), $this->indexURL(), Icon::create('edit'));
Sidebar::Get()->addWidget($links);
}
/**
* Count how many user a insert
*/
public function manual_count_action()
{
$filters = array_filter(Request::getArray('filter'));
if (empty($filters)) {
$data = ['error' => _('Keine Filterkriterien gewählt')];
} else {
$userlookup = new UserLookup();
foreach ($filters as $type => $values) {
$userlookup->setFilter($type, $values);
}
$data = ['users' => count($userlookup->execute())];
}
$this->set_content_type('application/json;charset=utf-8');
return $this->render_text(json_encode($data));
}
}
<?php
/**
* banner.php - controller class for the banner administration
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Nico Müller <nico.mueller@uni-oldenburg.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package admin
* @since 2.4
*/
class Admin_BannerController extends AuthenticatedController
{
protected $_autobind = true;
/**
* Common tasks for all actions.
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
URLHelper::removeLinkParam('cid');
// user must have root permission
$GLOBALS['perm']->check('root');
// set navigation
Navigation::activateItem('/admin/locations/banner');
//pagelayout
PageLayout::setTitle(_('Verwaltung der Banner'));
// Define banner target types
$this->target_types = [
'url' => _('URL'),
'seminar' => _('Veranstaltung'),
'inst' => _('Einrichtung'),
'user' => _('Person'),
'none' => _('Kein Verweis'),
];
// Define banner priorities
$this->priorities = [
0 => '0 (' . _('nicht anzeigen') . ')',
1 => '1 (' . _('sehr niedrig') . ')',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
6 => '6',
7 => '7',
8 => '8',
9 => '9',
10 => '10 (' . _('sehr hoch') . ')',
];
//Infobox
$this->setSidebar();
}
/**
* Administration view for banner
*/
public function index_action()
{
$this->banners = Banner::getAllBanners();
}
public function info_action(Banner $banner)
{
if ($banner->isNew()) {
throw new Exception(sprintf(_('Es existiert kein Banner mit der Id "%s"'), $banner->id));
}
}
/**
* Displays edit form and performs according actions upon submit
*
* @param Banner $banner Banner object
*/
public function edit_action(Banner $banner)
{
if ($banner->isNew()) {
throw new Exception(sprintf(_('Es existiert kein Banner mit der Id "%s"'), $banner->id));
}
// edit banner input
if (Request::submitted('speichern')) {
$banner_path = Request::get('banner_path');
$description = Request::get('description');
$alttext = Request::get('alttext');
$target_type = Request::get('target_type');
$priority = Request::int('priority');
//add the right target
if ($target_type == 'url') {
$target = Request::get('target');
} else if ($target_type == 'inst') {
$target = Request::option('institut');
} else if ($target_type == 'user') {
$target = Request::username('user');
} else if ($target_type == 'seminar') {
$target = Request::option('seminar');
} else {
$target = Request::get('target');
}
$errors = [];
//upload file
$upload = $_FILES['imgfile'];
if (!empty($upload['name'])) {
$banner_path = $this->bannerupload($upload['tmp_name'], $upload['size'], $upload['name'], $errors);
}
if (!$target && $target_type != 'none') {
$errors[] = _('Es wurde kein Verweisziel angegeben.');
}
$startDate = explode('.',Request::get('start_date'));
if (($x = $this->valid_date(Request::int('start_hour'), Request::int('start_minute'), $startDate[0],$startDate[1], $startDate[2])) == -1) {
$errors[] = _('Bitte geben Sie einen gültiges Startdatum ein.');
} else {
$startdate = $x;
}
$endDate = explode('.',Request::get('end_date'));
if (($x = $this->valid_date(Request::int('end_hour'), Request::int('end_minute'), $endDate[0], $endDate[1], $endDate[2])) == -1) {
$errors[] = _('Bitte geben Sie einen gültiges Enddatum ein.');
} else {
$enddate = $x;
}
switch ($target_type) {
case 'url':
if (!preg_match('~^(https?|ftp)://~i', $target)) {
$errors[] = _('Das Verweisziel muss eine gültige URL sein (incl. http://).');
}
break;
case 'inst':
if (Institute::find($target) === null) {
$errors[] = _('Die angegebene Einrichtung existiert nicht. '
.'Bitte geben Sie eine gültige Einrichtungs-ID ein.');
}
break;
case 'user':
if (User::findByUsername($target) === null) {
$errors[] = _('Der angegebene Username existiert nicht.');
}
break;
case 'seminar':
try {
Seminar::getInstance($target);
} catch (Exception $e) {
$errors[] = _('Die angegebene Veranstaltung existiert nicht. '
.'Bitte geben Sie eine gültige Veranstaltungs-ID ein.');
}
break;
case 'none':
$target = '';
break;
}
if (count($errors) > 0) {
PageLayout::postError(_('Es sind folgende Fehler aufgetreten:'), $errors);
} else {
$banner->banner_path = $banner_path;
$banner->description = $description;
$banner->alttext = $alttext;
$banner->target_type = $target_type;
$banner->target = $target;
$banner->startdate = $startdate;
$banner->enddate = $enddate;
$banner->priority = $priority;
$banner->store();
PageLayout::postSuccess(_('Der Banner wurde erfolgreich gespeichert.'));
$this->redirect('admin/banner');
}
}
if ($banner['target_type'] == 'seminar') {
$seminar_name = get_object_name($banner['target'], 'sem');
$this->seminar = QuickSearch::get('seminar', new StandardSearch('Seminar_id'))
->setInputStyle('width: 240px')
->defaultValue($banner['target'],$seminar_name['name'])
->render();
}
if ($banner['target_type'] == 'user') {
$this->user = QuickSearch::get('user', new StandardSearch('username'))
->setInputStyle('width: 240px')
->defaultValue($banner['target'], $banner['target'])
->render();
}
if ($banner['target_type'] == 'inst') {
$institut_name = get_object_name($banner['target'], 'inst');
$this->institut = QuickSearch::get('institut', new StandardSearch('Institut_id'))
->setInputStyle('width: 240px')
->defaultValue($banner['target'], $institut_name['name'])
->render();
}
}
/**
* Create a new banner
*/
public function new_action()
{
// add new banner input
if (Request::submitted('anlegen')) {
$description = Request::get('description');
$alttext = Request::get('alttext');
$target_type = Request::option('target_type');
//add the right target
if ($target_type == 'url') {
$target = Request::get('target');
} else if ($target_type == 'inst') {
$target = Request::option('institut');
} else if ($target_type == 'user') {
$target = Request::username('user');
} else if ($target_type == 'seminar') {
$target = Request::option('seminar');
} else {
$target = Request::get('target');
}
$priority = Request::int('priority');
$errors = [];
$upload = $_FILES['imgfile'];
if (!$upload['name']) {
$errors[] = _('Es wurde kein Bild ausgewählt.');
} else {
$banner_path = $this->bannerupload($upload['tmp_name'], $upload['size'], $upload['name'], $errors);
}
$startDate = explode('.',Request::get('start_date'));
if (($x = $this->valid_date(Request::int('start_hour'), Request::int('start_minute'), $startDate[0],$startDate[1], $startDate[2])) == -1) {
$errors[] = _('Bitte geben Sie einen gültiges Startdatum ein.');
} else {
$startdate = $x;
}
$endDate = explode('.',Request::get('end_date'));
if (($x = $this->valid_date(Request::int('end_hour'), Request::int('end_minute'), $endDate[0], $endDate[1], $endDate[2])) == -1) {
$errors[] = _('Bitte geben Sie einen gültiges Enddatum ein.');
} else {
$enddate = $x;
}
if (!$target && $target_type != 'none') {
$errors[] = _('Es wurde kein Verweisziel angegeben.');
} else {
switch ($target_type) {
case 'url':
if (!preg_match('~^(https?|ftp)://~i', $target)) {
$errors[] = _('Das Verweisziel muss eine gültige URL sein (incl. http://).');
}
break;
case 'inst':
if (Institute::find($target) === null) {
$errors[] = _('Die angegebene Einrichtung existiert nicht. '
.'Bitte geben Sie eine gültige Einrichtungs-ID ein.');
}
break;
case 'user':
if (User::findByUsername($target) === null) {
$errors[] = _('Der angegebene Benutzername existiert nicht.') ;
}
break;
case 'seminar':
try {
Seminar::getInstance($target);
} catch (Exception $e) {
$errors[] = _('Die angegebene Veranstaltung existiert nicht. '
.'Bitte geben Sie eine gültige Veranstaltungs-ID ein.');
}
break;
case 'none':
$target = '';
break;
}
}
if (count($errors) > 0) {
PageLayout::postError(_('Es sind folgende Fehler aufgetreten:'), $errors);
} else {
$banner = new Banner();
$banner->banner_path = $banner_path;
$banner->description = $description;
$banner->alttext = $alttext;
$banner->target_type = $target_type;
$banner->target = $target;
$banner->startdate = $startdate;
$banner->enddate = $enddate;
$banner->priority = $priority;
$banner->store();
PageLayout::postSuccess(_('Der Banner wurde erfolgreich gespeichert.'));
$this->redirect('admin/banner');
}
}
}
/**
* Resets the click and view counter for the given banner
*
* @param Banner $banner
*/
public function reset_action(Banner $banner)
{
$banner->views = 0;
$banner->clicks = 0;
$banner->store();
$message = _('Die Klick- und Viewzahlen des Banners wurden zurückgesetzt');
PageLayout::postSuccess($message);
$this->redirect('admin/banner');
}
/**
*
* @param Banner $banner
*/
public function delete_action(Banner $banner)
{
if (Request::int('delete') == 1) {
$banner->delete();
PageLayout::postSuccess(_('Das Banner wurde erfolgreich gelöscht!'));
} elseif (!Request::get('back')) {
$this->flash['delete'] = ['banner_id' => $banner->id];
}
$this->redirect('admin/banner');
}
/**
* Upload a new picture
*
* @param String $img temporary upload path
* @param Int $img_size size of a image
* @param String $img_name name of the image
* @todo Relocate this function into the model?
*/
private function bannerupload($img, $img_size, $img_name, &$errors = [])
{
if (!$img_name) { //keine Datei ausgewählt!
return false;
}
//Dateiendung bestimmen
$dot = mb_strrpos($img_name, '.');
if ($dot) {
$l = mb_strlen($img_name) - $dot;
$ext = mb_strtolower(mb_substr($img_name, $dot + 1, $l));
}
//passende Endung ?
if (!in_array($ext, words('gif jpeg jpg png'))) {
$errors[] = sprintf(_('Der Dateityp der Bilddatei ist falsch (%s).<br>'
.'Es sind nur die Dateiendungen .gif, .png und .jpg erlaubt!')
, htmlReady($ext));
return false;
}
//na dann kopieren wir mal...
$uploaddir = $GLOBALS['DYNAMIC_CONTENT_PATH'] . '/banner';
$md5hash = md5($img_name . time());
$banner_path = $md5hash . '.' . $ext;
$newfile = $uploaddir . '/' . $banner_path;
if(!@move_uploaded_file($img, $newfile)) {
$errors[] = _('Es ist ein Fehler beim Kopieren der Datei aufgetreten. Das Bild wurde nicht hochgeladen!');
return true;
}
chmod($newfile, 0666 & ~umask()); // set permissions for uploaded file
return $banner_path;
}
/**
* Validate the date
*
* @param Int $h hour
* @param Int $m minute
* @param Int $d day
* @param Int $mo month
* @param Int $y year
*
*/
protected function valid_date($h, $m, $d, $mo, $y)
{
if ((int)$h + (int)$m + (int)$d + (int)$mo + (int)$y === 0) {
return 0; // 0= forever
}
// mktime returns -1 if date is invalid (and does some strange
// conversion which might be considered as a bug...)
return mktime($h ,$m, 0, $mo, $d, $y);
}
/**
* Extends this controller with neccessary sidebar
*
* @param String $view Currently viewed group
*/
protected function setSidebar()
{
$sidebar = Sidebar::Get();
$actions = new ActionsWidget();
$actions->addLink(
_('Neues Banner anlegen'),
$this->url_for('admin/banner/new'),
Icon::create('add')
)->asDialog('size=auto');
$sidebar->addWidget($actions);
}
}
<?php
/**
* cache.php
* Controller for managing system cache.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Thomas Hackl <studip@thomas-hackl.name>
* @copyright 2020 Stud.IP Core-Group
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @since 5.0
*/
class Admin_CacheController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
// Check permissions to be on this site
if (!$GLOBALS['perm']->have_perm('root')) {
throw new AccessDeniedException();
}
PageLayout::setTitle(_('Cache'));
Navigation::activateItem('/admin/config/cache');
$this->enabled = $GLOBALS['CACHING_ENABLE'];
$this->sidebar = Sidebar::get();
$views = new ViewsWidget();
$views->addLink(
_('Verwaltung'),
$this->url_for('admin/cache/settings')
)->setActive($action === 'settings');
if ($this->enabled) {
$views->addLink(
_('Statistiken'),
$this->url_for('admin/cache/stats')
)->setActive($action === 'stats');
}
$this->sidebar->addWidget($views);
if ($this->enabled) {
$actions = new ActionsWidget();
$actions->addLink(
_('Cache leeren'),
$this->url_for('admin/cache/flush'),
Icon::create('decline'),
['data-confirm' => _('Soll der gesamte Inhalt des Caches wirklich gelöscht werden?')]
);
$this->sidebar->addWidget($actions);
}
}
/**
* Show all available cache types.
*/
public function settings_action()
{
if ($this->enabled) {
$this->types = CacheType::findAndMapBySQL(function (CacheType $type) {
return $type->toArray();
}, "1 ORDER BY `cache_id`");
$currentCache = Config::get()->SYSTEMCACHE;
$currentCacheClass = CacheType::findOneByClass_name($currentCache['type']);
$this->cache = $currentCacheClass->class_name;
$this->config = $currentCacheClass->class_name::getConfig();
} else {
PageLayout::postWarning(
_('Caching ist systemweit ausgeschaltet, daher kann hier nichts konfiguriert werden.'));
}
}
/**
* Fetches necessary configuration for given cache type.
*
* @param string $className
*/
public function get_config_action($className)
{
$type = CacheType::findOneByClass_name($className);
$this->render_json($type->class_name::getConfig());
}
/**
* Stores cache settings to global config.
*/
public function store_settings_action()
{
// Take the whole Request object as array ...
$request = Request::getInstance()->getIterator()->getArrayCopy();
// ... remove cachetype entry as this is saved separately ...
unset($request['cachetype']);
// ... and use the rest of the request as cache config.
$settings = [
'type' => Request::get('cachetype'),
'config' => $request
];
// Store settings to global config.
if (Config::get()->store('SYSTEMCACHE', $settings)) {
PageLayout::postSuccess(_('Die Einstellungen wurden gespeichert.'));
StudipCacheFactory::unconfigure();
} else {
PageLayout::postError(_('Die Einstellungen konnten nicht gespeichert werden.'));
}
$this->relocate('admin/cache/settings');
}
/**
* Flush all cache content.
*/
public function flush_action()
{
$cache = StudipCacheFactory::getCache();
$cache->flush();
PageLayout::postSuccess(_('Die Inhalte des Caches wurden gelöscht.'));
$this->relocate('admin/cache/settings');
}
/**
* Show cache statistics.
*/
public function stats_action()
{
$cache = StudipCacheFactory::getCache();
$this->stats = $cache->getStats();
}
}
<?php
/**
* configuration.php - controller class for the configuration
*
* @author Jan-Hendrik Willms <tleilax+stuip@gmail.com>
* @author Nico Müller <nico.mueller@uni-oldenburg.de>
* @author Michael Riehemann <michael.riehemann@uni-oldenburg.de>
* @license GPL2 or any later version
* @package admin
* @since 2.0
*/
class Admin_ConfigurationController extends AuthenticatedController
{
/**
* Common before filter for all actions.
*
* @param String $action Called actions
* @param Array $args Passed arguments
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
// user must have root permission
$GLOBALS['perm']->check('root');
// set navigation
Navigation::activateItem('/admin/config/configuration');
$this->range_type = 'global';
foreach (['range', 'user', 'course', 'institute'] as $range_type) {
if (mb_strpos($action, $range_type) !== false) {
$this->range_type = $range_type;
}
}
$this->setupSidebar($this->range_type);
}
/**
* Maintenance view for the configuration parameters
*
* @param mixed $section Open section
*/
public function configuration_action($open_section = null)
{
PageLayout::setTitle(_('Verwaltung von Systemkonfigurationen'));
// Display only one section?
$section = Request::option('section');
if ($section == '-1') {
$section = null;
}
// Search for specific entries?
$needle = trim(Request::get('needle')) ?: null;
if ($needle) {
$this->subtitle = _('Suchbegriff:') . ' "' . htmlReady($needle) . '"';
}
// set variables for view
$this->only_section = $section;
$this->open_section = $open_section ?: $section;
$this->needle = $needle;
$this->sections = ConfigurationModel::getConfig($section, $needle);
$this->title = _('Verwaltung von Systemkonfigurationen');
$this->linkchunk = 'admin/configuration/edit_configuration';
$this->has_sections = true;
if ($needle && empty($this->sections)) {
PageLayout::postError(sprintf(_('Es wurden keine Ergebnisse zu dem Suchbegriff "%s" gefunden.'), htmlReady($needle)));
$this->redirect('admin/configuration/configuration');
}
}
/**
* Editview: Edit the configuration parameters: value, comment, section
*/
public function edit_configuration_action()
{
$field = Request::get('field');
$value = Request::get('value');
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
if ($this->validateInput($field, $value)) {
$section = Request::get('section_new') ?: Request::get('section');
$comment = Request::get('comment');
Config::get()->store($field, compact(words('value section comment')));
PageLayout::postSuccess(sprintf(
_('Der Konfigurationseintrag "%s" wurde erfolgreich übernommen!'),
htmlReady($field)
));
$this->relocate('admin/configuration/configuration/' . $section);
return;
}
}
// set variables for view
$this->config = ConfigurationModel::getConfigInfo($field);
$this->allconfigs = ConfigurationModel::getConfig();
PageLayout::setTitle(sprintf(_('Konfigurationsparameter: %s editieren'), $this->config['field']));
}
/**
* Rangeview: Show all user-parameter for a Range or show the system range-parameter
*/
public function range_configuration_action()
{
PageLayout::setTitle(_('Verwalten von Range-Konfigurationen'));
$range_id = Request::option('id');
if ($range_id) {
$range = RangeFactory::find($range_id);
$this->configs = ConfigurationModel::searchConfiguration($range);
$this->title = sprintf(
_('Vorhandene Konfigurationsparameter für "%s"'),
$range->getFullname()
);
$this->linkchunk = 'admin/configuration/edit_range_config/' . $range_id;
} else {
$this->configs = ConfigurationModel::searchConfiguration(null);
$this->title = _('Globale Konfigurationsparameter für alle Ranges');
$this->linkchunk = 'admin/configuration/edit_configuration/';
}
$this->has_sections = false;
}
/**
* Editview: Change range-parameter for one range (value)
*
* @param String $range_id
*/
public function edit_range_config_action($range_id)
{
$field = Request::get('field');
$range = RangeFactory::find($range_id);
PageLayout::setTitle(_('Bearbeiten von Konfigurationsparametern für die Range: ') . $range->getFullname());
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
$value = Request::get('value');
if ($this->validateInput($field, $value)) {
$range->getConfiguration()->store($field, $value);
PageLayout::postSuccess(sprintf(
_('Der Konfigurationseintrag: %s wurde erfolgreich geändert!'),
htmlReady($field)
));
$this->relocate('admin/configuration/range_configuration?id=' . $range_id);
return;
}
}
$this->config = ConfigurationModel::showConfiguration($range, $field);
$this->range = $range;
$this->field = $field;
}
/**
* Userview: Show all user-parameter for a user or show the system user-parameter
*/
public function user_configuration_action()
{
PageLayout::setTitle(_('Verwalten von Personenkonfigurationen'));
$user_id = Request::option('id');
$user = new User($user_id);
if (!$user->isNew()) {
$this->configs = ConfigurationModel::searchConfiguration($user);
$this->title = sprintf(
_('Vorhandene Konfigurationsparameter für "%s"'),
$user->getFullname()
);
$this->linkchunk = 'admin/configuration/edit_user_config/' . $user_id;
} else {
$this->configs = ConfigurationModel::searchConfiguration($user);
$this->title = _('Globale Konfigurationsparameter für alle Personen');
$this->linkchunk = 'admin/configuration/edit_configuration';
}
$this->has_sections = false;
$this->render_action('range_configuration');
}
/**
* Editview: Change user-parameter for one user (value)
*
* @param String $user_id
*/
public function edit_user_config_action(User $user)
{
PageLayout::setTitle(_('Bearbeiten von Konfigurationsparametern für die Person: ') . $user->getFullname());
$field = Request::get('field');
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
$value = Request::get('value');
if ($this->validateInput($field, $value)) {
$user->getConfiguration()->store($field, $value);
PageLayout::postSuccess(sprintf(
_('Der Konfigurationseintrag: %s wurde erfolgreich geändert!'),
htmlReady($field)
));
$this->relocate('admin/configuration/user_configuration?id=' . $user->id);
return;
}
}
$this->config = ConfigurationModel::showConfiguration($user, $field);
$this->range = $user;
$this->field = $field;
$this->render_action('edit_range_config');
}
/**
* Show all parameters for a course or show the system course parameters
*/
public function course_configuration_action()
{
PageLayout::setTitle(_('Verwalten von Veranstaltungskonfigurationen'));
$course_id = Request::option('id');
$course = new Course($course_id);
if (!$course->isNew()) {
$this->configs = ConfigurationModel::searchConfiguration($course);
$this->title = sprintf(
_('Vorhandene Konfigurationsparameter für "%s"'),
$course->getFullname()
);
$this->linkchunk = 'admin/configuration/edit_course_config/' . $course_id;
} else {
$this->configs = ConfigurationModel::searchConfiguration($course);
$this->title = _('Globale Konfigurationsparameter für alle Veranstaltungen');
$this->linkchunk = 'admin/configuration/edit_configuration';
}
$this->has_sections = false;
$this->render_action('range_configuration');
}
/**
* Change course parameter for one course (value)
*
* @param String $course_id
*/
public function edit_course_config_action(Course $course)
{
PageLayout::setTitle(_('Bearbeiten von Konfigurationsparametern für die Veranstaltung: ') . $course->getFullname());
$field = Request::get('field');
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
$value = Request::get('value');
if ($this->validateInput($field, $value)) {
$course->getConfiguration()->store($field, $value);
PageLayout::postSuccess(sprintf(
_('Der Konfigurationseintrag: %s wurde erfolgreich geändert!'),
htmlReady($field)
));
$this->relocate('admin/configuration/course_configuration?id=' . $course->id);
return;
}
}
$this->config = ConfigurationModel::showConfiguration($course, $field);
$this->range = $course;
$this->field = $field;
$this->render_action('edit_range_config');
}
/**
* Show all parameters for an institute or show the system institute parameters
*/
public function institute_configuration_action()
{
PageLayout::setTitle(_('Verwalten von Einrichtungskonfigurationen'));
$institute_id = Request::option('id');
$institute = new Institute($institute_id);
if (!$institute->isNew()) {
$this->configs = ConfigurationModel::searchConfiguration($institute);
$this->title = sprintf(
_('Vorhandene Konfigurationsparameter für "%s"'),
$institute->getFullname()
);
$this->linkchunk = 'admin/configuration/edit_institute_config/' . $institute_id;
} else {
$this->configs = ConfigurationModel::searchConfiguration($institute);
$this->title = _('Globale Konfigurationsparameter für alle Einrichtungen');
$this->linkchunk = 'admin/configuration/edit_configuration';
}
$this->has_sections = false;
$this->render_action('range_configuration');
}
/**
* Change institute parameter for one institute (value)
*
* @param String $institute
*/
public function edit_institute_config_action(Institute $institute)
{
PageLayout::setTitle(_('Bearbeiten von Konfigurationsparametern für die Einrichtung: ') . $institute->getFullname());
$field = Request::get('field');
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
$value = Request::get('value');
if ($this->validateInput($field, $value)) {
$institute->getConfiguration()->store($field, $value);
PageLayout::postSuccess(sprintf(_('Der Konfigurationseintrag: %s wurde erfolgreich geändert!'), htmlReady($field)));
$this->relocate('admin/configuration/institute_configuration?id=' . $institute->id);
return;
}
}
$this->config = ConfigurationModel::showConfiguration($institute, $field);
$this->range = $institute;
$this->field = $field;
$this->render_action('edit_range_config');
}
/**
* Validates given input
*
* @param String $field Config field to validate
* @param String $value Value that has been input
* @return boolean indicating whether the value is valid
*/
protected function validateInput($field, &$value)
{
$config = Config::get()->getMetadata($field);
// Step 1: Prepare input
if ($config['type'] === 'array') {
$value = json_decode($value, true);
} elseif ($config['type'] === 'i18n') {
$value = Request::i18n('value');
}
// Step 2: Validate
if ($config['type'] === 'integer' && !is_numeric($value)) {
$error = _('Bitte geben Sie bei Parametern vom Typ "integer" nur Zahlen ein!');
} elseif ($config['type'] === 'array' && !is_array($value)) {
$error = _('Bitte geben Sie bei Parametern vom Typ "array" ein Array oder Objekt in korrekter JSON Notation ein!');
} else {
return true;
}
PageLayout::postError($error);
return false;
}
/**
* Sets up the sidebar
*
* @param bool $range_type Determine the sidebar search type
*/
protected function setupSidebar($range_type)
{
// Basic info and layout
$sidebar = Sidebar::Get();
// Views
$views = $sidebar->addWidget(new ViewsWidget());
$views->addLink(
_('Globale Konfiguration'),
$this->url_for('admin/configuration/configuration')
)->setActive($range_type === 'global');
$views->addLink(
_('Range-Konfiguration'),
$this->url_for('admin/configuration/range_configuration')
)->setActive($range_type === 'range');
$views->addLink(
_('Personenkonfiguration'),
$this->url_for('admin/configuration/user_configuration')
)->setActive($range_type === 'user');
$views->addLink(
_('Veranstaltungskonfiguration'),
$this->url_for('admin/configuration/course_configuration')
)->setActive($range_type === 'course');
$views->addLink(
_('Einrichtungskonfiguration'),
$this->url_for('admin/configuration/institute_configuration')
)->setActive($range_type === 'institute');
// Add section selector when not in user mode
if ($range_type === 'global') {
$options = [];
foreach (ConfigurationModel::getConfig() as $key => $value) {
$options[$key] = $key ?: '- ' . _('Ohne Kategorie') . ' -';
}
$widget = new SelectWidget(
_('Anzeigefilter'),
$this->url_for('admin/configuration/configuration'),
'section',
'get'
);
$widget->addElement(new SelectElement(-1, _('alle anzeigen')));
$widget->setOptions($options);
$sidebar->addWidget($widget);
}
// Add specific searches (specific user when in user mode, keyword
// otherwise)
if ($range_type === 'range') {
$search = new SearchWidget($this->url_for('admin/configuration/range_configuration'));
$search->addNeedle(
_('Range suchen'), 'id', true,
new RangeSearch(),
'function () { $(this).closest("form").submit(); }',
Request::option('id')
);
} elseif ($range_type === 'user') {
$search = new SearchWidget($this->url_for('admin/configuration/user_configuration'));
$search->addNeedle(
_('Person suchen'), 'id', true,
new StandardSearch('user_id'),
'function () { $(this).closest("form").submit(); }',
Request::option('id')
);
} else if ($range_type === 'course') {
$search = new SearchWidget($this->url_for('admin/configuration/course_configuration'));
$search->addNeedle(
_('Veranstaltung suchen'), 'id', true,
new StandardSearch('Seminar_id'),
'function () { $(this).closest("form").submit(); }',
Request::option('id')
);
} else if ($range_type === 'institute') {
$search = new SearchWidget($this->url_for('admin/configuration/institute_configuration'));
$search->addNeedle(
_('Einrichtungen suchen'), 'id', true,
new StandardSearch('Institut_id'),
'function () { $(this).closest("form").submit(); }',
Request::option('id')
);
} else {
$search = new SearchWidget($this->url_for('admin/configuration/configuration'));
$search->addNeedle(_('Suchbegriff'), 'needle', true);
}
$sidebar->addWidget($search);
}
}
<?php
/**
* content_terms_of_use.php
*
* Controller for adding, editing and deleting content terms of use entries.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @copyright data-quest Suchi & Berg GmbH
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package admin
* @since 4.0
*/
class Admin_ContentTermsOfUseController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
if ($action === 'add') {
$action = 'edit';
}
parent::before_filter($action, $args);
// Do the permission check here since all actions are only accessible
// for root users:
if (!$GLOBALS['perm']->have_perm('root')) {
throw new AccessDeniedException();
}
PageLayout::setHelpKeyword('Dateien.Nutzungsbedingungen');
Navigation::activateItem('/admin/locations/content_terms_of_use');
}
/**
* This action displays a list of all content terms of use entries.
*/
public function index_action()
{
PageLayout::setTitle(_('Inhalts-Nutzungsbedingungen'));
//build sidebar
$actions = new ActionsWidget();
$actions->addLink(
_('Eintrag hinzufügen'),
$this->url_for('admin/content_terms_of_use/add'),
Icon::create('add')
)->asDialog('size=auto');
Sidebar::get()->addWidget($actions);
//load all ContentTermsOfUse entries:
$this->entries = ContentTermsOfUse::findBySql('1 ORDER BY position ASC, id ASC');
}
/**
* This action lets a root user edit a new content terms of use entry.
*/
public function edit_action()
{
$id = Request::get('entry_id') ?: null; // Convert possible empty string to null
$this->entry = new ContentTermsOfUse($id);
PageLayout::setTitle(
$this->entry->isNew() ? _('Eintrag hinzufügen') : _('Eintrag bearbeiten')
);
if ($id !== null && $this->entry->isNew()) {
PageLayout::postError(sprintf(
_('Eintrag für Nutzungsbedingungen mit ID %s wurde nicht in der Datenbank gefunden!'),
htmlReady($id)
));
$this->redirect('admin/content_terms_of_use/index');
return;
}
}
public function store_action()
{
if (!Request::isPost()) {
throw new MethodNotAllowedException();
}
$id = Request::get('id') ?: null; // Convert possible empty string to null
$entry = new ContentTermsOfUse($id);
$entry->id = Request::get('entry_id');
$entry->name = Request::i18n('name');
$entry->download_condition = Request::int('download_condition');
$entry->icon = Request::get('icon');
$entry->position = Request::int('position');
$entry->description = Request::i18n('description');
$entry->student_description = Request::i18n('student_description');
$entry->is_default = Request::int('is_default') ?: 0;
if (($errors = $entry->validate()) || $entry->store() === false) {
if (count($errors) === 1) {
PageLayout::postError(reset($errors));
} else {
PageLayout::postError(
_('Fehler beim Speichern des Eintrags für Nutzungsbedingungen'),
$errors
);
}
$this->entry = $entry;
$this->render_action('edit');
return;
}
PageLayout::postSuccess(_('Eintrag für Nutzungsbedingungen wurde gespeichert!'));
$this->redirect('admin/content_terms_of_use/index');
}
/**
* This action lets a root user delete a new content terms of use entry.
*/
public function delete_action()
{
PageLayout::setTitle(_('Eintrag löschen'));
$this->entry_id = Request::get('entry_id');
//load entry by looking at the entry_id:
$entry = ContentTermsOfUse::find($this->entry_id);
if (!$entry) {
//entry not found: return to index page
PageLayout::postError(sprintf(
_('Eintrag für Nutzungsbedingungen mit ID %s wurde nicht in der Datenbank gefunden!'),
htmlReady($this->entry_id)
));
$this->redirect('admin/content_terms_of_use/index');
return;
}
$this->dependent_files_count = FileRef::countBySql(
'content_terms_of_use_id = ?',
[$this->entry_id]
);
//delete was confirmed
if (Request::isPost()) {
if ($this->dependent_files_count > 0) {
//files depend on the entry! We must give them
//a new terms of use entry before we can delete
//the entry!
$this->other_entry_id = Request::get('other_entry_id');
if (!$this->other_entry_id) {
//Files depend on the old entry, but no new entry
//was selected. That's an error!
PageLayout::postError(sprintf(
_('Fehler beim Löschen von Eintrag mit ID %s: Es wurde für betroffene Dateien kein neuer Nutzungsbedingungen-Eintrag ausgewählt!'),
htmlReady($this->entry_id)
));
$this->redirect('admin/content_terms_of_use/index');
return;
}
//Change the content_terms_of_use_id for all file_refs
//that have the ID of the entry which is going to be removed.
$query = "UPDATE file_refs
SET content_terms_of_use_id = :new_id
WHERE content_terms_of_use_id = :removed_id";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':new_id', $this->other_entry_id);
$statement->bindValue(':removed_id', $this->entry_id);
$result = $statement->execute();
if (!$result) {
PageLayout::postError(sprintf(
_('Fehler beim Zuordnen von Dateien zu Eintrag mit ID %s! Eintrag mit ID %s wurde nicht gelöscht!'),
htmlReady($this->other_entry_id),
htmlReady($this->entry_id)
));
$this->redirect('admin/content_terms_of_use/index');
return;
}
}
//delete the entry:
if ($entry->delete()) {
if ($this->dependent_files_count > 0) {
PageLayout::postSuccess(sprintf(
_('Eintrag mit ID "%s" wurde gelöscht. Alle Dateien, welche diesen Eintrag verwendeten, nutzen nun den Eintrag mit ID "%s"!'),
htmlReady($this->entry_id),
htmlReady($this->other_entry_id)
));
} else {
PageLayout::postSuccess(sprintf(
_('Eintrag mit ID "%s" wurde gelöscht!'),
htmlReady($this->entry_id)
));
}
} else {
if ($this->dependent_files_count > 0) {
PageLayout::postError(sprintf(
_('Fehler beim Löschen von Eintrag mit ID "%s"! Alle Dateien, welche diesen Eintrag verwendeten, nutzen nun den Eintrag mit ID "%s"!'),
htmlReady($this->entry_id),
htmlReady($this->other_entry_id)
));
} else {
PageLayout::postError(sprintf(
_('Fehler beim Löschen von Eintrag mit ID "%s"!'),
htmlReady($this->entry_id)
));
}
}
$this->redirect('admin/content_terms_of_use/index');
return;
}
// form not submitted: If files depend on it,
// another entry must be selected for these files.
if ($this->dependent_files_count > 0) {
$this->other_entries = ContentTermsOfUse::findBySql(
'id <> :entry_id ORDER BY position ASC, id ASC',
[':entry_id' => $this->entry_id]
);
}
}
}
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment