Browse Source

Merge branch 'teodesian-notification-center' into local_driver

Andy Baugh 7 years ago
parent
commit
805901a006

+ 4 - 0
Makefile

@@ -6,6 +6,8 @@ mkdir:
 install: mkdir depend-all
 	cp -f lib/Cpanel/iContact/Provider/Schema/*.pm /var/cpanel/perl/Cpanel/iContact/Provider/Schema/
 	cp -f lib/Cpanel/iContact/Provider/*.pm /var/cpanel/perl/Cpanel/iContact/Provider/
+	cd notification-center
+	make install
 
 install-slack: mkdir
 	cp -f lib/Cpanel/iContact/Provider/Schema/Slack.pm /var/cpanel/perl/Cpanel/iContact/Provider/Schema/Slack.pm
@@ -38,6 +40,8 @@ uninstall:
 	[ ! -f /var/cpanel/perl/Cpanel/iContact/Provider/Schema/Discord.pm ] || rm /var/cpanel/perl/Cpanel/iContact/Provider/Schema/Discord.pm
 	[ ! -f /var/cpanel/perl/Cpanel/iContact/Provider/Local.pm ] || rm /var/cpanel/perl/Cpanel/iContact/Provider/Local.pm
 	[ ! -f /var/cpanel/perl/Cpanel/iContact/Provider/Schema/Local.pm ] || rm /var/cpanel/perl/Cpanel/iContact/Provider/Schema/Local.pm
+	cd notification-center
+	make uninstall
 
 test: depend-all depend-test
 	[ ! -x /usr/local/cpanel/3rdparty/bin/prove ] || /usr/local/cpanel/3rdparty/bin/prove t/*.t

+ 12 - 0
notification-center/Makefile

@@ -0,0 +1,12 @@
+install:
+	install -m 0700 notification-center.pl /usr/local/cpanel/whostmgr/docroot/cgi/addon_notification-center.cgi
+	install -m 0700 notification-center.tt /usr/local/cpanel/whostmgr/docroot/templates/addon_notification-center.tmpl
+	install -m 0755 nfcenter.png /usr/local/cpanel/whostmgr/docroot/addon_plugins/nfcenter.png
+	mkdir -p /var/cpanel/apps; /bin/true
+	chmod 0755 /var/cpanel/apps
+	/usr/local/cpanel/bin/register_appconfig notification-center.conf
+uninstall:
+	rm /usr/local/cpanel/whostmgr/docroot/cgi/addon_notification-center.cgi
+	rm /usr/local/cpanel/whostmgr/docroot/templates/addon_notification-center.tmpl
+	rm /var/cpanel/apps/notification-center.conf
+	rm /usr/local/cpanel/whostmgr/docroot/addon_plugins/nfcenter.png

BIN
notification-center/nfcenter.png


+ 8 - 0
notification-center/notification-center.conf

@@ -0,0 +1,8 @@
+service=whostmgr
+user=$authuser
+url=cgi/addon_notification-center.cgi
+entryurl=addon_notification-center.cgi
+displayname=Notification Center
+icon=nfcenter.png
+acls=any
+target=_self

+ 30 - 0
notification-center/notification-center.pl

@@ -0,0 +1,30 @@
+#!/usr/local/cpanel/3rdparty/bin/perl
+
+package WHM::Plugin::NotificationCenter;
+
+use strict;
+use warnings;
+
+use CGI qw/:standard/;
+print header();
+
+use Cpanel::Template;
+
+use lib '/var/cpanel/perl';
+
+use Cpanel::iContact::Provider::Local::Getter;
+
+main() unless caller;
+
+sub main {
+
+    my $vars = {
+        notifications => Cpanel::iContact::Provider::Local::Getter::get( user => $ENV{REMOTE_USER} );
+    };
+
+    Cpanel::Template::process_template( 'whostmgr', { template_file => 'addon_notification-center.tmpl', data => $vars } );
+
+    return 0;
+}
+
+1;

+ 39 - 0
notification-center/notification-center.tt

@@ -0,0 +1,39 @@
+[% USE Whostmgr -%]
+[% WRAPPER 'master_templates/master.tmpl'
+    app_key = 'Notification Center'
+    header = 'Notification Center'
+    icon = '/addon_plugins/nfcenter.png'
+    breadcrumburl = '/cgi/addon_notification-center.cgi'
+    skipbreadcrumb = 0
+    theme = "bootstrap"
+    show_upgrade_message = 1
+    stylesheets = ['/cjt/css/ajaxapp-min.css',
+                   '/templates/common/revised_notices.min.css',
+                   '/templates/packages/common.min.css',
+                   '/styles/unified_optimized.css'
+                  ]
+    extrastyle = ''
+    include_legacy_stylesheets = 1
+-%]
+[% PROCESS '_pkg_hover.tmpl' -%]
+[% PROCESS '_ajaxapp_header.tmpl' -%]
+
+<table class="table table-striped responsive-table" border="1" cellspacing="0" cellpadding="2" >
+    <thead>
+        <tr>
+            <td>[% locale.maketext('Notification') %]</td>
+            <td>[% locale.maketext('Time Occurred') %]</td>
+        </tr>
+    </thead>
+    <tbody>
+        [% FOREACH notification IN data.notifications.keys.sort %]
+        <tr>
+            <td>[% data.notifications.$notification.subject %]</td>
+            <td>[% notification %]</td>
+        </tr>
+        [% END %]
+    </tbody>
+</table>
+
+[% PROCESS '_ajaxapp_footer.tmpl' -%]
+[% END #wrapper -%]

+ 11 - 1
scripts/generate_testing_configuration.pl

@@ -28,10 +28,20 @@ foreach my $key ( keys( %$settings_hr ) ) {
     print $fh "$key: " . <STDIN>;
 }
 close( $fh );
+
+my $provepath = 'prove';
+# Figure out if cPanel perl & prove exist. If so, use it, as it'll have a better chance of working.
+if( -f '/usr/local/cpanel/3rdparty/bin/perl' ) {
+    print "Checking cPanel Perl version...\n";
+    my $cpperl_ver = `/usr/local/cpanel/3rdparty/bin/perl -e 'print substr( \$], 0, 1 ) . substr( \$], 3, 2 );'`;
+    print "Looks like perl $cpperl_ver.\n";
+    $provepath = "/usr/local/cpanel/3rdparty/perl/$cpperl_ver/bin/prove";
+}
+
 print STDOUT (
     "Done writing to $gitdir/.${file_name_prefix}testrc.\n",
     "The functional test in t/ should now work when ran like so:\n",
-    "AUTHOR_TESTS=1 prove $gitdir/t/Cpanel-iContact-Provider-$module_name.t\n"
+    "AUTHOR_TESTS=1 $provepath $gitdir/t/Cpanel-iContact-Provider-$module_name.t\n"
 );
 
 0;