Plugin Directory

Changeset 782629


Ignore:
Timestamp:
10/04/2013 03:53:46 PM (12 years ago)
Author:
anukit
Message:

Made the 'active_plugins' option log more readable by identifying which plugin was activated or deactivated.

Location:
observer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • observer/trunk/lib/AMWObserver.php

    r769751 r782629  
    44
    55    protected $logfile;
    6     protected $version = '1.0.1';
     6    protected $version = '1.0.2';
    77
    88    /**
     
    122122        }
    123123
    124         // convert values to strings
    125         $oldvalue = (is_array($oldvalue) || is_object($oldvalue)) ? serialize($oldvalue) : $oldvalue;
    126         $newvalue = (is_array($newvalue) || is_object($newvalue)) ? serialize($newvalue) : $newvalue;
    127         $data = sprintf("(%s)->(%s)", $oldvalue, $newvalue);
     124        // handle this option separately?
     125        $specialHandler = 'handle_option_' . $option;
     126        if (method_exists($this, $specialHandler)) {
     127
     128            call_user_func(array(&$this, $specialHandler));
     129
     130        } else {
     131
     132            // convert values to strings
     133            $oldvalue = (is_array($oldvalue) || is_object($oldvalue)) ? serialize($oldvalue) : $oldvalue;
     134            $newvalue = (is_array($newvalue) || is_object($newvalue)) ? serialize($newvalue) : $newvalue;
     135            $data = sprintf("(%s)->(%s)", $oldvalue, $newvalue);
     136            $blogId = get_current_blog_id();
     137            $this->log('updated_option', $blogId, $option, $data);
     138
     139        }
     140
     141    }
     142
     143    /**
     144     * Logs when 'active_plugins' option is updated.
     145     * @param  string $option   The name of the option that was changed.
     146     * @param  mixed  $newvalue The new value for the option.
     147     * @param  mixed  $oldvalue The old value for the option.
     148     * @return void
     149     */
     150    public function handle_option_active_plugins($option, $oldvalue, $newvalue) {
     151
     152        // make sure we work with arrays
     153        $oldvalue = (is_array($oldvalue)) ? $oldvalue : array();
     154        $newvalue = (is_array($newvalue)) ? $newvalue : array();
     155
     156        // get changes
     157        $deactivated = array_diff($oldvalue, $newvalue);
     158        $activated   = array_diff($newvalue, $oldvalue);
     159
     160        // make a readable representation of the changes
     161        $data = '';
     162        if (count($deactivated)) {
     163            $data .= '(DEACTIVATED: "' . implode('","', $deactivated) . '")';
     164        }
     165        if (count($activated)) {
     166            $data .= '(ACTIVATED: "' . implode('","', $activated) . '")';
     167        }
     168
     169        // log it
    128170        $blogId = get_current_blog_id();
    129171        $this->log('updated_option', $blogId, $option, $data);
     172
    130173    }
    131174
  • observer/trunk/observer.php

    r769751 r782629  
    44Plugin URI: http://amwhalen.com
    55Description: Creates an audit trail log file for multisite super admin actions. Used only for multisite installations, and must be Network Activated.
    6 Version: 1.0.1
     6Version: 1.0.2
    77Author: Andy Whalen
    88Author URI: http://amwhalen.com
  • observer/trunk/readme.txt

    r769751 r782629  
    6464== Changelog ==
    6565
     66= 1.0.2 =
     67* Made the 'active_plugins' option log more readable by identifying which plugin was activated or deactivated.
     68
    6669= 1.0.1 =
    6770* Added some more ignored option updates.
Note: See TracChangeset for help on using the changeset viewer.