Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ec5a5d18
authored
2011-03-01 16:41:46 +0000
by
Kevin Burton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated notifications system
1 parent
6b66cbf9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
9 deletions
com/Notifications/Admin.php
com/Notifications/Notifications.php
com/Notifications/views/form.php
com/Notifications/Admin.php
View file @
ec5a5d1
...
...
@@ -113,6 +113,11 @@ function display_page() {
,
'execute_date'
=>
$execute_date
));
if
(
count
(
$entry
->
email
[
'attachments'
]
)
>
0
)
{
$attachments
=
array_merge
(
$entry
->
email
[
'attachments'
],
$attachments
);
}
update_post_meta
(
$id
,
"email"
,
array
(
'subject'
=>
$subject
,
'text'
=>
$text
...
...
@@ -131,7 +136,19 @@ function display_page() {
$update
[
'ID'
]
=
$id
;
$update
[
'post_title'
]
=
$title
;
wp_update_post
(
$update
);
$id
=
$entry
->
ID
;
$details
=
get_post_meta
(
$id
,
'details'
,
true
);
$email
=
get_post_meta
(
$id
,
'email'
,
true
);
$system
=
get_post_meta
(
$id
,
'system'
,
true
);
$sms
=
get_post_meta
(
$id
,
'sms'
,
true
);
$entry
->
details
=
$details
;
$entry
->
email
=
$email
;
$entry
->
system
=
$system
;
$entry
->
sms
=
$sms
;
$flash
=
"<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"
;
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'views'
.
DIRECTORY_SEPARATOR
.
'form.php'
);
...
...
com/Notifications/Notifications.php
View file @
ec5a5d1
...
...
@@ -347,6 +347,27 @@ class Actions {
public
static
function
wp_ajax_print_user_notices
()
{
print_user_notices
();
}
public
static
function
wp_ajax_remove_attachment
()
{
$id
=
$_POST
[
'id'
];
$email
=
get_post_meta
(
$id
,
'email'
,
true
);
$attachments
=
$email
[
'attachments'
];
foreach
(
$attachments
as
$key
=>
$name
)
{
if
(
$name
==
$_POST
[
'file'
])
{
unset
(
$attachments
[
$key
]);
}
}
$email
[
'attachments'
]
=
$attachments
;
update_post_meta
(
$id
,
'email'
,
$email
);
$return
=
array
(
'success'
=>
'true'
);
die
(
json_encode
(
$return
));
}
}
class
Vars
{
...
...
com/Notifications/views/form.php
View file @
ec5a5d1
...
...
@@ -28,11 +28,9 @@ use Tz\WordPress\Tools;
</div>
<?php endif;?>
<?php
//print "
<
pre
>
";
//print_r(
$entry
);
//print "
</
pre
>
";
?>
<form enctype="
multipart
/
form
-
data
" method="
post
" action="
/
wp
-
admin
/
admin
.
php
?
page
=
notifications
&
action
=
edit
&
page_id
=<?
php
echo
$_GET
[
'page_id'
]
?>
">
...
...
@@ -116,18 +114,30 @@ use Tz\WordPress\Tools;
<td>
HTML Version (optional)
</td>
<td><textarea
name=
"html"
id=
"htmlversion"
class=
"wide-input-field"
rows=
"10"
style=
"width:100%;"
>
<?php
echo
$validation
->
set_value
(
'html'
,
$entry
->
email
[
'html'
]);
?>
</textarea>
<?php
echo
$validation
->
form_error
(
'html'
);
?>
</td>
</tr>
<tr>
<td
width=
"150"
>
Attachments
</td>
<td>
<input
type=
"file"
name=
"attachment[]"
/>
</td>
<td>
</td>
</tr>
<?php
$attachements
=
$entry
->
email
[
'attachments'
];
$allowed_attachments
=
3
;
foreach
(
$attachements
as
$attachment
)
:
?>
<tr>
<td>
</td>
<td><
input
type=
"file"
name=
"attachment[]"
/>
</td>
<td>
<
?php
echo
$attachment
;
?>
(
<a
href=
"#"
entry_id=
"
<?php
echo
$_GET
[
'page_id'
]
?>
"
class=
"attachment"
rel=
"
<?php
echo
$attachment
;
?>
"
>
remove
</a>
)
</td>
</tr>
<?php
$allowed_attachments
--
;
endforeach
;
?>
<?php
for
(
$a
=
1
;
$a
<=
$allowed_attachments
;
$a
++
)
:
?>
<tr>
<td>
</td>
<td><input
type=
"file"
name=
"attachment[]"
/></td>
</tr>
<?php
endfor
;
?>
</tbody>
</table>
...
...
@@ -170,7 +180,7 @@ use Tz\WordPress\Tools;
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'#execute_date'
).
datetimepicker
({
stepMinute
:
30
...
...
@@ -180,6 +190,39 @@ jQuery(document).ready(function() {
updateNotificationType
();
$
(
'.attachment'
).
live
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
var
$link
=
$
(
this
);
var
options
=
{
action
:
'remove_attachment'
,
ajax
:
'yes'
,
id
:
$link
.
attr
(
'entry_id'
)
,
file
:
$link
.
attr
(
'rel'
)
};
var
file_element
=
'<input type="file" name="attachment[]" />'
;
var
c
=
confirm
(
'Are you sure you want to remove this attachment?'
);
if
(
c
)
{
$
.
ajax
({
url
:
'/wp-admin/admin-ajax.php'
,
data
:
(
options
)
,
type
:
'POST'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
if
(
data
.
success
==
"true"
)
{
$link
.
parent
().
html
(
file_element
);
}
}
});
}
return
false
;
});
//jQuery('table.expandable tbody').hide();
jQuery
(
'table.expandable thead th'
).
click
(
function
()
{
var
$table
=
jQuery
(
this
).
parent
().
parent
().
parent
();
...
...
Please
register
or
sign in
to post a comment