Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sucs-site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Moras
sucs-site
Commits
fd3ba314
Commit
fd3ba314
authored
15 years ago
by
Graham Cole
Browse files
Options
Downloads
Patches
Plain Diff
long overdue interface for editing library book data
parent
4abebd3f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/library.php
+21
-1
21 additions, 1 deletion
components/library.php
templates/library-book-edit.tpl
+32
-0
32 additions, 0 deletions
templates/library-book-edit.tpl
templates/library-book.tpl
+5
-8
5 additions, 8 deletions
templates/library-book.tpl
with
58 additions
and
9 deletions
components/library.php
+
21
−
1
View file @
fd3ba314
...
...
@@ -55,6 +55,7 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) {
$mode
=
"display"
;
$checkout_request
=
false
;
$book_index
=
intval
(
$pathlist
[
$library_index
+
1
]);
if
(
isset
(
$session
->
groups
[
$permission
]))
$smarty
->
assign
(
'editable'
,
true
);
// Check this book actually exists
$loans
=
$DB
->
GetAll
(
"SELECT onloan FROM books WHERE id=? LIMIT 1"
,
array
(
$book_index
));
...
...
@@ -62,7 +63,7 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) {
$mode
=
"bookerror"
;
}
else
{
// See if we're supposed to be loaning
or
returning this book
// See if we're supposed to be loaning
/
returning
/editing/saving
this book
if
(
$session
->
loggedin
&&
isset
(
$_REQUEST
[
'action'
]))
{
if
(
$_REQUEST
[
'action'
]
==
"loan"
)
{
if
(
isset
(
$session
->
groups
[
$permission
]))
{
...
...
@@ -77,6 +78,25 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) {
}
elseif
((
$_REQUEST
[
'action'
]
==
"return"
)
&&
isset
(
$session
->
groups
[
$permission
]))
{
// update DB
$DB
->
Query
(
"UPDATE books SET onloan='f', loandate=NULL WHERE id=?"
,
array
(
$book_index
));
}
elseif
((
$_REQUEST
[
'action'
]
==
"edit"
)
&&
isset
(
$session
->
groups
[
$permission
]))
{
// we're an editor and want to edit this book
$smarty
->
assign
(
"editing"
,
true
);
}
elseif
((
$_REQUEST
[
'action'
]
==
"save"
)
&&
isset
(
$session
->
groups
[
$permission
]))
{
// save edited book
$book
[
'title'
]
=
$_REQUEST
[
'title'
];
$book
[
'author'
]
=
$_REQUEST
[
'author'
];
$book
[
'publisher'
]
=
$_REQUEST
[
'publisher'
];
$book
[
'description'
]
=
$_REQUEST
[
'description'
];
if
(
$DB
->
AutoExecute
(
'books'
,
$book
,
'UPDATE'
,
"id="
.
$DB
->
qstr
(
$book_index
)))
{
message_flash_postponed
(
"Book Updated!"
);
//redirect to prevent form resubmission
header
(
'HTTP/1.1 303 See Other'
);
header
(
"Location:
$baseurl$path
"
);
}
else
{
trigger_error
(
"Error updating book: "
.
$DB
->
ErrorMsg
(),
E_USER_WARNING
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
templates/library-book-edit.tpl
0 → 100644
+
32
−
0
View file @
fd3ba314
<div
class=
"box"
>
<div
class=
"boxhead"
><h2>
{
$book.title
}
</h2></div>
<div
class=
"boxcontent"
>
<strong>
{
if
$book.onloan
}
On loan
{
else
}
Book Available
{/
if
}
</strong>
{
if
$book.image_url
!=
""
}
<img
class=
"emblem"
src=
"
{
$book.image_url
|
escape
}
"
alt=
"
{
$book.title
|
escape
}
"
/>
{/
if
}
{
if
$editable
==
true
}
<form
class=
"admin"
action=
"
{
$baseurl
}{
$path
}
?action=save"
method=
"POST"
>
<div
class=
"row"
>
<label
for=
"title"
>
Title
</label>
<span
class=
"textinput"
><input
type=
"text"
name=
"title"
value=
"
{
$book.title
}
"
/></span>
</div>
<div
class=
"row"
>
<label
for=
"author"
>
Author
</label>
<span
class=
"textinput"
><input
type=
"text"
name=
"author"
value=
"
{
$book.author
}
"
/></span>
</div>
<div
class=
"row"
>
<label
for=
"publisher"
>
Publisher
</label>
<span
class=
"textinput"
><input
type=
"text"
name=
"publisher"
value=
"
{
$book.publisher
}
"
/></span>
</div>
<div
class=
"row"
><label
for=
"description"
>
Description
</label><textarea
cols=
"50"
rows=
"20"
name=
"description"
>
{
$book.description
|
escape
}
</textarea></div>
<input
type=
"submit"
value=
"Save"
/>
</form>
{
else
}
<p>
You don't have permission to edit books
</p>
{/
if
}
<div
class=
"clear"
></div>
</div>
<div
class=
"hollowfoot"
><div><div></div></div></div>
</div>
This diff is collapsed.
Click to expand it.
templates/library-book.tpl
+
5
−
8
View file @
fd3ba314
...
...
@@ -3,20 +3,17 @@
<div
class=
"boxhead"
><h2>
{
$book.title
}
</h2></div>
<div
class=
"boxcontent"
>
{
if
$editable
==
true
}
<form
action=
""
method=
"POST"
>
<input
type=
"text"
name=
"title"
value=
"
{
$book.title
}
"
/>
<input
type=
"text"
name=
"author"
value=
"
{
$book.author
}
"
/>
<input
type=
"text"
name=
"publisher"
value=
"
{
$book.publisher
}
"
/>
<textarea
name=
"description"
value=
"
{
$book.description
}
"
/>
</form>
{/
if
}
<strong>
{
if
$book.onloan
}
On loan
{
else
}
Book Available
{/
if
}
</strong>
{
if
$book.image_url
!=
""
}
<img
class=
"emblem"
src=
"
{
$book.image_url
|
escape
}
"
alt=
"
{
$book.title
|
escape
}
"
/>
{/
if
}
<p>
Author:
{
$book.author
}
</p>
{
if
isset
(
$book.description
)
}
<div>
{
$book.description
}
</div>
{/
if
}
{
if
$editable
==
true
}
<div
class=
"edit"
>
<ul><li><a
href=
"?action=edit"
>
Edit
</a></li></ul>
</div>
{/
if
}
<div
class=
"clear"
></div>
</div>
<div
class=
"hollowfoot"
><div><div></div></div></div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment