[pLog-svn] r4489 - in plugins/trunk: . unported
unported/adminnotifier
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Thu Jan 4 19:39:53 GMT 2007
Author: oscar
Date: 2007-01-04 19:39:53 +0000 (Thu, 04 Jan 2007)
New Revision: 4489
Added:
plugins/trunk/unported/adminnotifier/
plugins/trunk/unported/adminnotifier/class/
plugins/trunk/unported/adminnotifier/locale/
plugins/trunk/unported/adminnotifier/pluginadminnotifier.class.php
plugins/trunk/unported/adminnotifier/templates/
Removed:
plugins/trunk/adminnotifier/
plugins/trunk/unported/adminnotifier/class/
plugins/trunk/unported/adminnotifier/locale/
plugins/trunk/unported/adminnotifier/pluginadminnotifier.class.php
plugins/trunk/unported/adminnotifier/templates/
Log:
unported plugin
Copied: plugins/trunk/unported/adminnotifier (from rev 4487, plugins/trunk/adminnotifier)
Copied: plugins/trunk/unported/adminnotifier/class (from rev 4488, plugins/trunk/adminnotifier/class)
Copied: plugins/trunk/unported/adminnotifier/locale (from rev 4488, plugins/trunk/adminnotifier/locale)
Deleted: plugins/trunk/unported/adminnotifier/pluginadminnotifier.class.php
===================================================================
--- plugins/trunk/adminnotifier/pluginadminnotifier.class.php 2007-01-04 14:29:05 UTC (rev 4487)
+++ plugins/trunk/unported/adminnotifier/pluginadminnotifier.class.php 2007-01-04 19:39:53 UTC (rev 4489)
@@ -1,132 +0,0 @@
-<?php
- include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
-
- /**
- * Sends notifications to administrators every time certain configurable events
- * occur in the system, such as new blogs created, new users created, etc.
- */
- class PluginAdminNotifier extends PluginBase
- {
-
- function PluginAdminNotifier()
- {
- $this->PluginBase();
-
- $this->id = "adminnotifier";
- $this->desc = "Sends email notifications to administrations every time certain events occur";
- $this->author = "The LifeType Project";
-
- // register our actions
- $this->registerAdminAction( "eventList", "AdminNotifierShowEventListAction" );
- $this->registerAdminAction( "updateEvents", "AdminNotifierUpdateEventsAction" );
-
- // register our menu options
- $this->addMenuEntry( "/menu/adminSettings", "adminNotifierGroup", "", "", false, true );
- $this->addMenuEntry( "/menu/adminSettings/adminNotifierGroup", "adminNotifier", "?op=eventList", "", false, true );
-
- // register our notifications
- $this->registerEvents();
- }
-
- function registerEvents()
- {
- // check our configuration and register as many event listeners as necessary
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
- $config =& Config::getConfig();
- $events = $config->getValue( "plugin_adminnotifier_events" );
-
- if( !is_array( $events ))
- $events = Array();
-
- foreach( $events as $eventId => $value ) {
- // register those that are configured
- $this->registerNotification( $eventId );
- }
- }
-
- /**
- * This method processes our event notifications
- */
- function process( $eventType, $params )
- {
- include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-
- // given the event id, let's get its string
- $events = PluginManager::getDefinedEvents();
- $eventList = array_flip( $events );
- $eventName = $eventList[ $eventType ];
-
- // build the message
- $rg = $this->blogInfo->getBlogRequestGenerator();
- $blogLink = $rg->blogLink();
- $blogName = $this->blogInfo->getBlog();
- $t = new Timestamp();
- $timestamp = $t->getTimestamp();
- $message = "Event: {$eventName}\n
- \n
- Generated by blog: {$blogName}\n
- Link: {$blogLink}\n
- \n
- Timestamp: {$timestamp}";
-
- // send the message to all administrators
- $this->notifyAdmins( $message );
- }
-
- /**
- * loads all the email addresses of all administrator users
- * @private
- * @return An array with email addresses
- */
- function getAdminEmailAddresses()
- {
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
- $prefix = Db::getPrefix();
- $query = "SELECT DISTINCT u.id AS id, u.user AS user, u.email AS email
- FROM {$prefix}users u, {$prefix}users_permissions p
- WHERE p.permission_id = 1 AND u.id = p.user_id AND u.status = ".USER_STATUS_ACTIVE;
-
- $db =& Db::getDb();
- $result = $db->Execute( $query );
- if( !$result )
- return Array();
-
- $admins = Array();
- while( $row = $result->FetchRow()) {
- $admins[] = $row["email"];
- }
-
- return( $admins );
- }
-
- /**
- * Sends the notification email to administrators
- * @param message The message to be sent to administrator users
- * @private
- */
- function notifyAdmins( $message )
- {
- include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
- include_once( PLOG_CLASS_PATH."class/mail/emailmessage.class.php" );
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
-
- // build the message
- $message = new EmailMessage();
- $config =& Config::getConfig();
- $message->setFrom( $config->getValue( "post_notification_source_address" ));
- $message->setSubject( "LifeType AdminNotifier Notification" );
- $message->setBody( $message );
-
- // load all the administrator users
- foreach( $this->getAdminEmailAddresses() as $emailAddress ) {
- $message->addTo( $emailAddress );
- }
-
- // once the message is ready, send it out
- $service = new EmailService();
- return( $service->sendMessage( $message ));
- }
- }
-?>
\ No newline at end of file
Copied: plugins/trunk/unported/adminnotifier/pluginadminnotifier.class.php (from rev 4488, plugins/trunk/adminnotifier/pluginadminnotifier.class.php)
Copied: plugins/trunk/unported/adminnotifier/templates (from rev 4488, plugins/trunk/adminnotifier/templates)
More information about the pLog-svn
mailing list