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
e4863550
authored
2014-10-16 11:05:57 -0400
by
Marty Penner
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Clean up Notifications\print_user_notices
1 parent
aa4c2aff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
40 deletions
com/Notifications/Notifications.php
com/Notifications/Notifications.php
View file @
e486355
...
...
@@ -44,73 +44,49 @@ function get_user_notices($uid)
}
}
function
print_user_notices
(
$show_more
=
true
)
function
print_user_notices
()
{
$user
=
new
User\CurrentAccount
();
get_user_notices
(
$user
->
ID
);
if
(
CBV\on_page
(
'/dashboard'
))
{
$limit
=
5
;
}
else
{
$limit
=
10
;
}
$notices
=
Vars
::
$notices
;
$total_rows
=
count
(
$notices
);
$next_id
=
isset
(
$_POST
[
'last_id'
])
?
(
$_POST
[
'last_id'
]
+
1
)
:
0
;
$end
=
((
$next_id
+
$limit
)
<
$total_rows
)
?
(
$next_id
+
$limit
)
:
$total_rows
;
if
(
count
(
$notices
)
<
1
)
{
//print '<tr><td colspan="3">You have no new notices.</td></tr>';
}
$rows
=
''
;
$rows
=
""
;
$last_id
=
0
;
for
(
$i
=
0
;
$i
<
$total_rows
;
$i
++
)
{
$the_notice
=
get_post
(
$notices
[
$i
][
'notification_id'
]);
$system
=
get_post_meta
(
$notices
[
$i
][
'notification_id'
],
'system'
,
true
);
$content
=
$system
[
'message'
];
$id
=
$the_notice
->
ID
;
if
(
isset
(
$notices
[
$i
][
'args'
])
&&
count
(
$notices
[
$i
][
'args'
])
>
0
)
:
foreach
(
$notices
[
$i
][
'args'
]
as
$key
=>
$val
)
{
if
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
{
$content
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>Click here</a>"
,
$content
);
$content
=
str_replace
(
'{'
.
$key
.
'}'
,
"<a href='"
.
$val
.
"'>Click here</a>"
,
$content
);
}
else
{
$content
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$content
);
$content
=
str_replace
(
'{'
.
$key
.
'}'
,
$val
,
$content
);
}
}
endif
;
$rows
.=
'<tr class="notice-row" id="'
.
$i
.
'">'
;
if
(
$notices
[
$i
][
'status'
]
==
"unread"
)
{
$rows
.=
'<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '
.
((
$notices
[
$i
][
'status'
]
==
"read"
)
?
'read'
:
'unread'
)
.
'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>'
;
if
(
$notices
[
$i
][
'status'
]
==
'unread'
)
{
$rows
.=
'<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '
.
((
$notices
[
$i
][
'status'
]
==
'read'
)
?
'read'
:
'unread'
)
.
'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>'
;
}
else
{
$rows
.=
'<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>'
;
}
/*
if($system['system_message_type']=="none"):
$rows .= '<td colspan="2" style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>';
else:
*/
if
(
$system
[
'system_message_type'
]
==
"none"
)
{
$system
[
'system_message_type'
]
=
"notice"
;
if
(
$system
[
'system_message_type'
]
==
'none'
)
{
$system
[
'system_message_type'
]
=
'notice'
;
}
$rows
.=
'<td width="80" style="vertical-align:middle;"><span>'
.
ucfirst
(
str_replace
(
"_"
,
" "
,
$system
[
'system_message_type'
]))
.
'</span></td>'
;
$rows
.=
'<td style="vertical-align:middle;">'
.
nl2br
(
$content
)
.
'<br /><span class="legal">Sent: '
.
date
(
"M j, Y @ h:ia"
,
$notices
[
$i
][
'sent_date'
])
.
'</span></td>'
;
/*endif;*/
$rows
.=
'<td width="80" style="vertical-align:middle;"><span>'
.
ucfirst
(
str_replace
(
'_'
,
' '
,
$system
[
'system_message_type'
]))
.
'</span></td>'
;
$rows
.=
'<td style="vertical-align:middle;">'
.
nl2br
(
$content
)
.
'<br /><span class="legal">Sent: '
.
date
(
'M j, Y @ h:ia'
,
$notices
[
$i
][
'sent_date'
])
.
'</span></td>'
;
$rows
.=
'</tr>'
;
$last_id
=
$i
;
}
if
(
$end
<
$total_rows
&&
CBV\on_page
(
'/notices'
))
{
//$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>';
}
if
(
isset
(
$_POST
[
'ajax'
]))
{
...
...
Please
register
or
sign in
to post a comment