Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL_Lockup_Factory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Digital Experience Group
UNL_Lockup_Factory
Commits
475a1b1c
Commit
475a1b1c
authored
8 years ago
by
Tyler Lemburg
Browse files
Options
Downloads
Patches
Plain Diff
Add daily digest script for emails
parent
327bd99d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/daily_digest.php
+75
-0
75 additions, 0 deletions
scripts/daily_digest.php
src/Emailer.php
+1
-0
1 addition, 0 deletions
src/Emailer.php
with
76 additions
and
0 deletions
scripts/daily_digest.php
0 → 100644
+
75
−
0
View file @
475a1b1c
<?php
$config_file
=
__DIR__
.
'/../config.sample.php'
;
if
(
file_exists
(
__DIR__
.
'/../config.inc.php'
))
{
$config_file
=
__DIR__
.
'/../config.inc.php'
;
}
require_once
$config_file
;
require_once
__DIR__
.
'/../vendor/composer/autoload.php'
;
use
Models\Lockup
;
use
Models\User
;
use
\Emailer
as
Emailer
;
# for each approver
$approvers
=
User
::
find
(
'all'
,
array
(
'conditions'
=>
array
(
'role'
=>
'approver'
)));
foreach
(
$approvers
as
$approver
)
{
# find all lockups that they have that are awaiting communicator approval
# (that were generated in the last 24 hours)
$lockups
=
Lockup
::
find
(
'all'
,
array
(
'conditions'
=>
array
(
'approver_id = ? AND status = ? AND date_created >= ?'
,
$approver
->
id
,
'awaiting_approval'
,
date
(
'Y-m-d H:i:s'
,
time
()
-
24
*
60
*
60
))));
# send an email if there is at least 1 of these
if
(
count
(
$lockups
)
>
0
)
{
$lockup_names
=
array
();
foreach
(
$lockups
as
$lockup
)
{
$lockup_names
[]
=
$lockup
->
getName
();
}
$body
=
'
Hello, '
.
$approver
->
name
.
'. We have '
.
count
(
$lockups
)
.
' new lockups awaiting your approval.
<br><br>
'
.
implode
(
$lockup_names
,
'<br>'
)
.
'
<br><br>
Please visit <a href="http://lockups.unl.edu/lockups/manage/">http://lockups.unl.edu/lockups/manage/</a> to view these lockups.
<br><br>
UNL Lockup Factory
'
;
Emailer
::
sendMail
(
$approver
->
email
,
"UNL Lockup Factory Digest"
,
$body
);
echo
'sent mail to '
.
$approver
->
email
;
echo
$body
;
}
}
# also do this for creative
$creative_emails
=
array
(
'mplioplis2@unl.edu'
);
# configurable value
# find all lockups that they have that are awaiting communicator approval
# (that were generated in the last 24 hours)
$lockups
=
Lockup
::
find
(
'all'
,
array
(
'conditions'
=>
array
(
'creative_status = ? AND date_created >= ?'
,
'awaiting_approval'
,
date
(
'Y-m-d H:i:s'
,
time
()
-
24
*
60
*
60
))));
# send an email if there is at least 1 of these
if
(
count
(
$lockups
)
>
0
)
{
$lockup_names
=
array
();
foreach
(
$lockups
as
$lockup
)
{
$lockup_names
[]
=
$lockup
->
getName
();
}
$body
=
'
Hello. We have '
.
count
(
$lockups
)
.
' new lockups awaiting creative approval.
<br><br>
'
.
implode
(
$lockup_names
,
'<br>'
)
.
'
<br><br>
Please visit <a href="http://lockups.unl.edu/lockups/manage/">http://lockups.unl.edu/lockups/manage/</a> to view these lockups.
<br><br>
UNL Lockup Factory
'
;
Emailer
::
sendMail
(
$creative_emails
,
"UNL Lockup Factory Digest"
,
$body
);
echo
'sent mail to creative'
;
echo
$body
;
}
This diff is collapsed.
Click to expand it.
src/Emailer.php
+
1
−
0
View file @
475a1b1c
...
...
@@ -28,6 +28,7 @@ class Emailer {
self
::
$mailer
->
addAddress
(
$to
);
}
self
::
$mailer
->
addReplyTo
(
'lemburg@unl.edu'
,
'Tyler Lemburg'
);
self
::
$mailer
->
addReplyTo
(
'mplioplis2@unl.edu'
,
'Marcelo Plioplis'
);
self
::
$mailer
->
isHTML
(
true
);
self
::
$mailer
->
Subject
=
$subject
;
...
...
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