Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Uni Osnabrück
Stud.IP
Commits
102072cc
Commit
102072cc
authored
May 10, 2023
by
Jan-Hendrik Willms
Committed by
Jan-Hendrik Willms
May 10, 2023
Browse files
Options
Downloads
Patches
Plain Diff
use additional fields instead of overwriting getValue(), fixes #2624
Closes #2624 Merge request
studip/studip!1776
parent
cb3a4629
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/models/CronjobSchedule.class.php
+1
-1
1 addition, 1 deletion
lib/models/CronjobSchedule.class.php
lib/models/CronjobTask.class.php
+34
-31
34 additions, 31 deletions
lib/models/CronjobTask.class.php
with
35 additions
and
32 deletions
lib/models/CronjobSchedule.class.php
+
1
−
1
View file @
102072cc
...
...
@@ -120,7 +120,7 @@ class CronjobSchedule extends SimpleORMap
*/
public
function
getTitle
()
{
return
(
$this
->
content
[
'title'
]
?:
$this
->
task
->
name
)
??
''
;
return
$this
->
content
[
'title'
]
?:
$this
->
task
->
name
??
''
;
}
protected
function
cbJsonifyParameters
(
$type
)
...
...
This diff is collapsed.
Click to expand it.
lib/models/CronjobTask.class.php
+
34
−
31
View file @
102072cc
...
...
@@ -52,6 +52,40 @@ class CronjobTask extends SimpleORMap
'on_store'
=>
'store'
];
$config
[
'additional_fields'
]
=
[
'description'
=>
[
'get'
=>
function
(
CronjobTask
$task
):
string
{
if
(
$task
->
valid
)
{
return
$task
->
class
::
getDescription
();
}
return
_
(
'Unbekannt'
);
},
],
'name'
=>
[
'get'
=>
function
(
CronjobTask
$task
):
string
{
if
(
$task
->
valid
)
{
return
$task
->
class
::
getName
();
}
$result
=
$task
->
filename
;
if
(
strpos
(
$result
,
'public/plugins_packages'
)
!==
false
)
{
$result
=
preg_replace
(
'/.*public\/plugins_packages\/(.+)(_Cronjob)?(\.class)?\.php$/'
,
'$1'
,
$result
);
}
else
{
$result
=
preg_replace
(
'/(_Cronjob)?(\.class)?\.php$/'
,
''
,
basename
(
$result
));
}
$result
.
=
' ('
.
_
(
'fehlerhaft'
)
.
')'
;
return
$result
;
},
],
'parameters'
=>
[
'get'
=>
function
(
CronjobTask
$task
):
array
{
if
(
$task
->
valid
)
{
return
$task
->
class
::
getParameters
();
}
return
[];
},
],
];
$config
[
'registered_callbacks'
][
'after_initialize'
][]
=
'loadClass'
;
parent
::
configure
(
$config
);
...
...
@@ -118,37 +152,6 @@ class CronjobTask extends SimpleORMap
return
$result
;
}
/**
* Proxy the static methods "getDescription", "getName" and
* "getParameters" from the task class.
*
* @param String $field Field which should be accessed.
* @return mixed Value of the method call
*/
public
function
getValue
(
$field
)
{
if
(
in_array
(
$field
,
words
(
'description name parameters'
)))
{
if
(
$this
->
valid
)
{
$method
=
'get'
.
ucfirst
(
$field
);
return
call_user_func
(
"
{
$this
->
class
}
::
{
$method
}
"
);
}
elseif
(
$field
===
'description'
)
{
return
_
(
'Unbekannt'
);
}
elseif
(
$field
===
'name'
)
{
$result
=
$this
->
filename
;
if
(
strpos
(
$result
,
'public/plugins_packages'
)
!==
false
)
{
$result
=
preg_replace
(
'/.*public\/plugins_packages\/(.+)(_Cronjob)?(\.class)?\.php$/'
,
'$1'
,
$result
);
}
else
{
$result
=
preg_replace
(
'/(_Cronjob)?(\.class)?\.php$/'
,
''
,
basename
(
$result
));
}
$result
.
=
' ('
.
_
(
'fehlerhaft'
)
.
')'
;
return
$result
;
}
elseif
(
$field
===
'parameters'
)
{
return
[];
}
}
return
parent
::
getValue
(
$field
);
}
// Convenience methods to ease the usage
/**
...
...
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