Example Plugin

From CashCrusaderWiki

(Difference between revisions)
Jump to: navigation, search
(Example plugin.php file)
Current revision (17:44, 7 October 2012) (edit) (undo)
m (grammar tweaks)
 
(5 intermediate revisions not shown.)
Line 16: Line 16:
var $date = 'Apr-17-2009 (v0.6.1)';
var $date = 'Apr-17-2009 (v0.6.1)';
-
function cron_job()//<-- scheduled tasks etc
+
// If your plugin does not use cronjobs, do not include cron_job function to your plugin.php.
-
{
+
// Scheduled tasks etc, this function is ran every time CashCrusader cronjobs are ran.
-
//Hint: put script in external file and include() it like below
+
// By default the frequency is every ten minutes. But may vary per site.
-
//include('mycron.php'); //would include file /public_html/scripts/plugins/yourpluginfolder/mycron.php
+
// Hint: put script in external file and include() it like below
 +
// include('mycron.php'); //would include file /public_html/scripts/plugins/yourpluginfolder/mycron.php
 +
function cron_job() {
return 1;
return 1;
}
}
-
function admin_page()//<-- default admin area page of your plugin
+
// The admin area front page of your plugin.
-
{
+
// This function is loaded after clicking 'YourPlugin name' link on plugins list.
-
//This function is loaded after clicking 'YourPlugin name' link on plugins list
+
// Direct link: http://domain/scripts/admin/pload.php?p_load=yourpluginclass
-
//Direct link: http://domain/scripts/admin/pload.php?p_load=yourpluginclass
+
function admin_page() {
return 1;
return 1;
}
}
-
function public_page()//<-- default public page
+
// The default public page of your plugin.
-
{
+
// Like <?php plugin('yourpluginclass'); //this would be in /pages/somefile.php ?>
-
//like <?php plugin('yourpluginclass'); //this would be in /pages/somefile.php ?>
+
function public_page() {
return 1;
return 1;
}
}
-
+
 
-
function runner()//<-- called at start up time of runner.php, like when user clicks a link or banner
+
// If your plugin does not use runner, do not include runner function to your plugin.php
-
{
+
// Called at start up time of runner.php, like when user clicks a link or banner.
 +
function runner() {
return 1;
return 1;
}
}
-
function yourownpublicfunction()
+
// Example public page function:
-
{
+
// <?php plugin('yourpluginclass', 'yourownpublicfunction'); ?>
-
//another public page function <?php plugin('yourpluginclass', 'yourownpublicfunction'); //this would be in /pages/somefile.php ?>
+
// This would be in /pages/somefile.php
-
//you can have many own functions
+
// You can have many own functions.
 +
function yourownpublicfunction() {
return 1;
return 1;
}
}
-
 
+
// Example admin page function
-
function yourownadminfunction()
+
// Link to this function would be:
-
{
+
// http://domain/scripts/admin/pload.php?p_load=yourpluginclass&function=yourownadminfunction
-
//another admin page function <?php plugin('yourpluginclass', 'yourownpublicfunction'); //this would be in /pages/somefile.php ?>
+
// 'p_load' and 'function' can be POSTed or via GET like above
-
//Link to this function: http://domain/scripts/admin/pload.php?p_load=yourpluginclass&function=yourownadminfunction
+
function yourownadminfunction() {
return 1;
return 1;
}
}
 +
// Hook to integrate your plugin to the admin panel's user viewer
 +
// Requires CashCrusader 3.0 or later
 +
// You may echo data to browser and it will be shown in /admin/viewuser.php?userid=$user
 +
function admin_viewuser($user) {
 +
return 1;
 +
}
 +
 +
// Hook to integrate your plugin to the admin panel's reminder section
 +
// Requires CashCrusader 3.0 or later
 +
// You may echo data to browser and it will be shown in top right of the admin panel notes
 +
function admin_reminder() {
 +
return 1;
 +
}
 +
 +
// Hook to integrate your plugin to the user login event
 +
// Requires CashCrusader 3.0 or later
 +
// The event is triggered every time a user logins
 +
function user_login($user) {
 +
return 1;
 +
}
 +
 +
// Hook to integrate your plugin to the user signup event
 +
// Requires CashCrusader 3.0 or later
 +
// The event is triggered every time a user registers
 +
function user_signup($user) {
 +
return 1;
 +
}
 +
 +
// Hook to integrate your plugin to the user purged event
 +
// Requires CashCrusader 3.0 or later
 +
// The event is triggered every time a user is purged from database
 +
function user_purged($user) {
 +
return 1;
 +
}
 +
 +
// Hook to integrate your plugin to the user profile updated event
 +
// Requires CashCrusader 3.0 or later
 +
// The event is triggered every time a user is updated
 +
function user_profile_updated($user) {
 +
return 1;
 +
}
}
}
?>
?>
</pre>
</pre>

Current revision

The most simple plugin example:

/public_html/scripts/plugins/yourpluginfolder/plugin.php

<?php
$plugins[]=array("name"=>"YourPlugin name", "classname"=>"yourpluginclass");

class yourpluginclass extends plugin_base
{
	var $class_name = 'yourpluginclass';
	var $file_name = 'yourpluginfolder/plugin.php';
	var $author = 'You';
	var $web = 'http://yourwebsite.com';
	var $name = 'YourPlugin name';
	var $date = 'Apr-17-2009 (v0.6.1)';

        // If your plugin does not use cronjobs, do not include cron_job function to your plugin.php.
        // Scheduled tasks etc, this function is ran every time CashCrusader cronjobs are ran.
        // By default the frequency is every ten minutes. But may vary per site.
        // Hint: put script in external file and include() it like below
        // include('mycron.php'); //would include file /public_html/scripts/plugins/yourpluginfolder/mycron.php
	function cron_job() {
		return 1; 
	}

        // The admin area front page of your plugin.
        // This function is loaded after clicking 'YourPlugin name' link on plugins list.
        // Direct link: http://domain/scripts/admin/pload.php?p_load=yourpluginclass
	function admin_page() {
		return 1;
	}
	
        // The default public page of your plugin.
        // Like <?php plugin('yourpluginclass'); //this would be in /pages/somefile.php ?>
	function public_page() {
		return 1;
	}

        // If your plugin does not use runner, do not include runner function to your plugin.php
        // Called at start up time of runner.php, like when user clicks a link or banner.
        function runner() {
		return 1;
 	}

        // Example public page function:
        // <?php plugin('yourpluginclass', 'yourownpublicfunction'); ?>
        // This would be in /pages/somefile.php
        // You can have many own functions.
        function yourownpublicfunction() {
		return 1;
 	}

        // Example admin page function
        // Link to this function would be:
        // http://domain/scripts/admin/pload.php?p_load=yourpluginclass&function=yourownadminfunction
        // 'p_load' and 'function' can be POSTed or via GET like above
        function yourownadminfunction() {
		return 1;
 	}

        // Hook to integrate your plugin to the admin panel's user viewer
        // Requires CashCrusader 3.0 or later
        // You may echo data to browser and it will be shown in /admin/viewuser.php?userid=$user
	function admin_viewuser($user) {
		return 1;
	}

        // Hook to integrate your plugin to the admin panel's reminder section
        // Requires CashCrusader 3.0 or later
        // You may echo data to browser and it will be shown in top right of the admin panel notes
	function admin_reminder() {
		return 1;
	}

        // Hook to integrate your plugin to the user login event
        // Requires CashCrusader 3.0 or later
        // The event is triggered every time a user logins
	function user_login($user) {
		return 1;
	}

        // Hook to integrate your plugin to the user signup event
        // Requires CashCrusader 3.0 or later
        // The event is triggered every time a user registers
	function user_signup($user) {
		return 1;
	}

        // Hook to integrate your plugin to the user purged event
        // Requires CashCrusader 3.0 or later
        // The event is triggered every time a user is purged from database
	function user_purged($user) {
		return 1;
	}

        // Hook to integrate your plugin to the user profile updated event
        // Requires CashCrusader 3.0 or later
        // The event is triggered every time a user is updated
	function user_profile_updated($user) {
		return 1;
	}

}
?>
Personal tools
Administration manual