/**
  * function action_plugin_activation
  * Registers an EventLog module and cron job for this plugin
  * @param string The name of the plugin that is being activated
  **/
 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         EventLog::register_type('authentification', 'persistence');
         CronTab::add_hourly_cron('persistence', 'persistence', 'Clean up stale persistent cookies');
     }
 }
 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         EventLog::register_type('PreApproved');
         if (!Options::get('preapproved__approved_count')) {
             Options::set('preapproved__approved_count', 1);
         }
     }
 }
Beispiel #3
0
 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         if (!extension_loaded('curl') && !@dl('curl')) {
             EventLog::log('Could not load CURL, which is needed for OpenID to work.', 'err', 'authentication', 'OpenID');
             throw new Exception('Could not load CURL, which is needed for OpenID to work.');
         }
         EventLog::register_type('authentification', 'OpenID');
     }
 }
Beispiel #4
0
 /**
  * Set up for the whole test suite
  */
 protected function module_setup()
 {
     set_time_limit(0);
     if ($user = User::get_by_name('eventlog_test')) {
         $this->user = $user;
         //$this->skip_all("User {$user->id} is required 'posts_test' user.");
     } else {
         $this->user = User::create(array('username' => 'eventlog_test', 'email' => '*****@*****.**', 'password' => md5('q' . rand(0, 65535))));
     }
     $this->types = array('testing' => 'unit_tests', 'testing2' => 'unit_tests_2', 'testing3' => 'unit_tests_3', 'testing4' => 'unit_tests_4', 'testing5' => 'unit_tests_5');
     foreach ($this->types as $type => $module) {
         EventLog::register_type($type, $module);
     }
 }
    /**
     * Plugin plugin_activation action, executed when any plugin is activated
     * @param string $file The filename of the plugin that was activated.
     */
    public function action_plugin_activation($file = '')
    {
        // Was this plugin activated?
        if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
            // Register a default event log type for this plugin
            EventLog::register_type("default", "FeedList");
            // Register the name of a new database table
            DB::register_table('feedlist');
            // 'plugin_activation' hook is called without first calling 'init'
            // Create the database table, or upgrade it
            switch (DB::get_driver_name()) {
                case 'mysql':
                    $schema = 'CREATE TABLE {feedlist} (
				id INT UNSIGNED AUTO_INCREMENT,
				feed_id INT NOT NULL DEFAULT 0,
				guid VARCHAR(255) NOT NULL,
				title VARCHAR(255) NOT NULL,
				link VARCHAR(255) NOT NULL,
				updated DATETIME NOT NULL,
				description TEXT,
				PRIMARY KEY (id),
				UNIQUE KEY guid (guid)
				);';
                    break;
                case 'sqlite':
                    $schema = 'CREATE TABLE {feedlist} (
				id INTEGER PRIMARY KEY AUTOINCREMENT, 
				feed_id INTEGER NOT NULL DEFAULT 0,
				guid VARCHAR(255) UNIQUE NOT NULL,
				title VARCHAR(255) NOT NULL,
				link VARCHAR(255) NOT NULL,
				updated DATETIME NOT NULL,
				description TEXT
				);';
                    break;
            }
            DB::dbdelta($schema);
            // Log a table creation event
            EventLog::log('Installed feedlist cache table.');
            // Add a periodical execution event to be triggered hourly
            CronTab::add_hourly_cron('feedlist', 'load_feeds', 'Load feeds for feedlist plugin.');
            // Log the cron creation event
            EventLog::log('Added hourly cron for feed updates.');
        }
    }
 public static function add_report_type($type)
 {
     parent::register_type(self::LOG_MODULE, $type);
 }
Beispiel #7
0
	/**
	 * Register the Pingback event type with the event log
	 */
	public function action_plugin_activation( $file )
	{
		if ( realpath( $file ) == __FILE__ ) {
			EventLog::register_type( 'Pingback' );
		}
	}
Beispiel #8
0
 /**
  * Write the default options
  */
 private function create_default_options()
 {
     // Let's prepare the EventLog here, first
     EventLog::register_type('default', 'habari');
     EventLog::register_type('user', 'habari');
     EventLog::register_type('authentication', 'habari');
     EventLog::register_type('content', 'habari');
     EventLog::register_type('comment', 'habari');
     // Create the default options
     $defaults = array('installed' => true, 'title' => $this->handler_vars['blog_title'], 'pagination' => 5, 'atom_entries' => 5, 'theme_name' => 'Charcoal', 'theme_dir' => 'charcoal', 'comments_require_id' => 1, 'locale' => $this->handler_vars['locale'], 'timezone' => 'UTC', 'dateformat' => 'Y-m-d', 'timeformat' => 'g:i a', 'log_min_severity' => 3, 'spam_percentage' => 100, 'GUID' => sha1(Utils::nonce()), 'private-GUID' => sha1(Utils::nonce()), 'public-GUID' => sha1(Utils::nonce()));
     // Get values from config installation profile
     foreach ($this->handler_vars as $id => $value) {
         if (preg_match('/option_(.+)/u', $id, $matches)) {
             $defaults[$matches[1]] = $value;
         }
     }
     // Apply values to the options table and activate the default theme
     foreach ($defaults as $key => $value) {
         Options::set($key, $value);
     }
     // Add the cronjob to trim the log so that it doesn't get too big
     CronTab::add_daily_cron('trim_log', Method::create('\\Habari\\EventLog', 'trim'), _t('Trim the log table'));
     // Add the cronjob to check for plugin updates
     CronTab::add_daily_cron('update_check', Method::create('\\Habari\\Update', 'cron'), _t('Perform a check for plugin updates.'));
     // Add the cronjob to run garbage collection on expired sessions
     CronTab::add_hourly_cron('session_gc', Method::create('\\Habari\\Session', 'gc'), _t('Perform session garbage collection.'));
     return true;
 }
Beispiel #9
0
 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         EventLog::register_type('autoapprove', 'autoapprove');
     }
 }
Beispiel #10
0
	/**
	 * Get the integer value for the given module/type, or <code>false</code>.
	 *
	 * @param string $module the module
	 * @param string $type the type
	 * @return mixed numeric value for the given module/type, or <code>false</code>
	 */
	public static function type( $module, $type )
	{
		self::list_logentry_types();
		if ( array_key_exists( $module, self::$types ) && array_key_exists( $type, self::$types[$module] ) ) {
			return self::$types[$module][$type];
		}
		if ( $type != null && $module != null ) {
			EventLog::register_type( $type, $module );
			self::list_logentry_types( true );
			return self::$types[$module][$type];
		}
		return false;
	}
Beispiel #11
0
 /**
  * Write the default options
  */
 private function create_default_options()
 {
     // Create the default options
     Options::set('installed', true);
     Options::set('title', $this->handler_vars['blog_title']);
     Options::set('base_url', MultiByte::substr($_SERVER['REQUEST_URI'], 0, MultiByte::strrpos($_SERVER['REQUEST_URI'], '/') + 1));
     Options::set('pagination', '5');
     Options::set('atom_entries', '5');
     Options::set('theme_name', 'k2');
     Options::set('theme_dir', 'k2');
     Options::set('comments_require_id', 1);
     Options::set('locale', $this->handler_vars['locale']);
     Options::set('timezone', 'UTC');
     Options::set('dateformat', 'Y-m-d');
     Options::set('timeformat', 'g:i a');
     // generate a random-ish number to use as the salt for
     // a SHA1 hash that will serve as the unique identifier for
     // this installation.  Also for use in cookies
     Options::set('GUID', sha1(Options::get('base_url') . Utils::nonce()));
     // Let's prepare the EventLog here, as well
     EventLog::register_type('default', 'habari');
     EventLog::register_type('user', 'habari');
     EventLog::register_type('authentication', 'habari');
     EventLog::register_type('content', 'habari');
     EventLog::register_type('comment', 'habari');
     // Add the cronjob to truncate the log so that it doesn't get too big
     CronTab::add_daily_cron('truncate_log', array('Utils', 'truncate_log'), _t('Truncate the log table'));
     return true;
 }
Beispiel #12
0
	/**
	 * Write the default options
	 */
	private function create_default_options()
	{
		// Create the default options

		Options::set( 'installed', true );

		Options::set( 'title', $this->handler_vars['blog_title'] );
		Options::set( 'pagination', '5' );
		Options::set( 'atom_entries', '5' );
		Options::set( 'theme_name', 'k2' );
		Options::set( 'theme_dir', 'k2' );
		Themes::activate_theme( 'k2', 'k2' );
		Options::set( 'comments_require_id', 1 );
		Options::set( 'locale', $this->handler_vars['locale'] );
		Options::set( 'timezone', 'UTC' );
		Options::set( 'dateformat', 'Y-m-d' );
		Options::set( 'timeformat', 'g:i a' );
		Options::set( 'log_min_severity', 3 );		// the default logging level - 3 should be 'info'
		Options::set( 'spam_percentage', 100 );

		// generate a random-ish number to use as the salt for
		// a SHA1 hash that will serve as the unique identifier for
		// this installation.  Also for use in cookies
		Options::set( 'GUID', sha1( Utils::nonce() ) );

		// Let's prepare the EventLog here, as well
		EventLog::register_type( 'default', 'habari' );
		EventLog::register_type( 'user', 'habari' );
		EventLog::register_type( 'authentication', 'habari' );
		EventLog::register_type( 'content', 'habari' );
		EventLog::register_type( 'comment', 'habari' );

		// Add the cronjob to trim the log so that it doesn't get too big
		CronTab::add_daily_cron( 'trim_log', array( 'EventLog', 'trim' ), _t( 'Trim the log table' ) );
		
		// Add the cronjob to check for plugin updates
		CronTab::add_daily_cron( 'update_check', array( 'Update', 'cron' ), _t( 'Perform a check for plugin updates.' ) );

		return true;
	}
 public function action_plugin_activation($file)
 {
     if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
         EventLog::register_type('ThreadedComment');
     }
 }