My first Plugin

Locked
User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

My first Plugin

Post by jbruni » Thu Nov 15, 2007 4:04 am

I will share some experiences from the "making of" my first Plugin.

Please, download it and unzip: http://br.geocities.com/joaohbruni/plug ... _admin.zip

You will see there are only 4 files in there:

1- notifyadmin.xml  (the Plugin installation and configuration file)

2- notifyadmin.php (this is the Plugin itself)

3- en-GB.plg_system_notifyadmin.ini  (language file - english)

4- pt-BR.plg_system_notifyadmin.ini  (language file - portuguese)

What this plugin does? It sends a notification e-mail when an Author edits an article.

In Joomla! 1.5, the users who are Authors are allowed to EDIT their articles AFTER they are already PUBLISHED.

That´s nice.

I am building a website with Joomla! 1.5, and I need to receive an e-mail when this thing happens (an author edit an article). So, I started making the plugin...

There were TWO fronts:

1- Installation, Configuration and Language issues.
2- The code to detect the situation and send an e-mail, without changing the core itself.

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

1- notifyadmin.xml (the XML file)

Post by jbruni » Thu Nov 15, 2007 4:39 am

Let´s see the XML file:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<install version="1.5" type="plugin" group="system">
    <name>System - Notify admin plugin</name>
    <version>1.0.1</version>
    <author>J Bruni</author>
    <creationDate>November 2007</creationDate>
    <copyright>(C) 2007 J Bruni. All rights reserved.</copyright>
    <license>GNU/GPL</license>
    <authorEmail>joaohbruni@yahoo.com.br</authorEmail>
    <authorUrl>www.radiosai.org.br</authorUrl>
    <description>Notify administrator when article is edited by author</description>
    <files>
        <filename plugin="notifyadmin">notifyadmin.php</filename>
    </files>
    <languages>
        <language tag="en-GB">en-GB.plg_system_notifyadmin.ini</language>
        <language tag="pt-BR">pt-BR.plg_system_notifyadmin.ini</language>
    </languages>
    <params>
        <param name="subject" type="text" size="18" default="" label="Subject of notification e-mail" description="Text between brackets at beggining of notification e-mail subject" />
        <param name="recipient" type="text" size="45" default="" label="Recipient(s) of notification e-mail" description="Comma-separated list of e-mail addresses to receive notification e-mail" />
    </params>
</install>
The first declaration in important:



It means the Joomla! version is 1.5, the extension type is plugin, and the type of plugin is system.

What type of plugin is your plugin? What types of plugin exist? Look at the Plugins installed, at the Administrator interface... you will see the following types:

- authentication
- content
- editors
- editors-xtd
- search
- system
- user
- xmlrpc

I don´t know if there are more types of plugin. (See more on this: What Are Extensions?)

When making your own Plugin, substitute in the XML file:

- name (full name of the Plugin)
- version (version of the Plugin)
- author (your name)
- creationDate (follow the month / year format)
- copyright  (copyright info)
- license (GNU/GPL is Joomla´s license)
- authorEmail (your e-mail)
- authorUrl  (your URL)

Next, there is the description

Notify administrator when article is edited by author

This string can be translated in the language file!  :o Yes, it appears in the administrator interface, and can be translated!

Then, a list of the files used by the plugin (except language ones and the XML itself):


   
        notifyadmin.php
   


Well... in our case, there is a single file. Attention to the naming conventions. The plugin, the XML file and the php file have the same name.

Next, the language files:


   
        en-GB.plg_system_notifyadmin.ini
        pt-BR.plg_system_notifyadmin.ini
   


The naming is important. First, the language id ("en-GB", "pt-BR", etc.), then a dot, then "plg", then a underscore, then the type of plugin ("system", in our case), then another underscore, then the name of the plugin, then a dot, and finally the "ini" extension.

And, at last, the configuration parameters that will appear in the admin interface.


   
       
       
   


I simply downloaded some Joomla! 1.5 plugins from the Extensions Directory and looked at how the "param" declarations were. It becomes easy to find out how to do it yourself.

Here, we have TWO parameters, both TEXT type.
The first, subject, for the e-mail subject.
The second, recipient, to store the e-mail destination address.

What is important:

- The name of the parameter (will be used in the plugin code).
- You can set a default value.
- The label and the description attributes are also translated!  :o

Yes! In the portuguese language file, they are translated, and in the admin interface, they appear translated. It is wonderful!
Last edited by jbruni on Sat Nov 17, 2007 2:03 pm, edited 1 time in total.

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

2- notifyadmin.php (the Plugin!)

Post by jbruni » Thu Nov 15, 2007 4:59 am

Now, let´s see the plugin php code.

First, the "skeleton":

Code: Select all

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

class plgSystemNotifyadmin extends JPlugin
{
         /**
	 * Constructor
	 *
	 * For php4 compatability we must not use the __constructor as a constructor for plugins
	 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
	 * This causes problems with cross-referencing necessary for the observer design pattern.
	 *
	 * @access	protected
	 * @param	object $subject The object to observe
	 * @param 	array  $config  An array that holds the plugin configuration
	 * @since	1.0
	 */
	function plgSystemNotifyadmin(& $subject, $config)
	{
	
		parent::__construct($subject,$config);
	}

	function onAfterRoute()
	{

		// THE "TRUE" CODE COMES HERE

	}

}
?>
What should be noticed here?

1- The name of the class: "plgSystemNotifyadmin"
First, plg, then the cappitalized type of plugin (System), then, the cappitalized name of the plugin ("Notifyadmin")

2- The name of the constructor: must be the same name of the class.

3- The name of the event function:
Well, this took me quite some time to find out the correct event to use.
Look at the index.php from Joomla!'s root. There you will find the triggering of some events:

$mainframe->triggerEvent('onAfterInitialise');
$mainframe->triggerEvent('onAfterRoute');
$mainframe->triggerEvent('onAfterDispatch');
$mainframe->triggerEvent('onAfterRender');

Well... if you name a function inside your plugin class with the same name of an event that is triggered, you know what will happen? Yes! Your plugin function will be called when the event happens! (or "the event is triggered")

Which event to choose? I didn´t know, so I tried "OnAfterDispatch"... It didn´t work the way I wanted. Then I discovered that "OnAfterRoute" was the right one (the right moment) for this situation. It worked perfectly!

So, simply naming the function with the event name (OnAfterRoute) does the magic of being called when the event is triggered. Isn´t it wonderful?
Last edited by jbruni on Sat Nov 17, 2007 2:03 pm, edited 1 time in total.

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

2- notifyadmin.php (the Plugin!) continuation

Post by jbruni » Thu Nov 15, 2007 5:23 am

So, here is the "REAL" plugin code:

Code: Select all

<?php
	function onAfterRoute()
	{

		$user =& JFactory::getUser();
		$isAuthor = ($user->usertype == 'Author');
		$isSaving = (JRequest::getCmd( 'task' ) == 'save') && (JRequest::getCmd( 'option' ) == 'com_content');

		if ($isAuthor && $isSaving) {

			$lang   =& JFactory::getLanguage();
			$lang->load( 'plg_system_notifyadmin' , JPATH_ADMINISTRATOR );

			$msg = $user->name . ' <' . $user->email .'> ' . JText::_( 'has edited article' ) . ' "' . JRequest::getVar( 'title' ) . "\"\n";
			$URI =& JFactory::getURI();
			$msg .= 'URL: ' . $URI->current() . '?view=article&catid=' . JRequest::getInt( 'catid' ) . '&id=' . JRequest::getInt( 'id' ) . '&Itemid=' . JRequest::getInt( 'Itemid' ) . '&option=com_content' . "\n";

			$mail =& JFactory::getMailer();
			$mail->setSubject( '[' . $this->params->get( 'subject' , JText::_( 'ARTICLE EDITED' ) ) . '] ' . JRequest::getVar( 'title' ) );
			$mail->setBody($msg);
			$mail->addRecipient( $this->params->get( 'recipient' , $mail->From ) );
			$mail->Send();

		}

	}
?>
Let´s see step by step:


$user =& JFactory::getUser();
$isAuthor = ($user->usertype == 'Author');
$isSaving = (JRequest::getCmd( 'task' ) == 'save') && (JRequest::getCmd( 'option' ) == 'com_content');


What are the conditions to send the notification e-mail?
First, the user must be an Author.
Second, he/she must be saving an existing article.

Looking at the finished code, it seems easy... but, how did I find that?

Before, I used "file_put_contents" php function to show me some information about $_REQUEST and some Joomla! objects... as JUser, JSession, JMail... and the global $mainframe!

(And I also did a lot of Joomla! 1.5 API Reference searches ans researches.)


global $mainframe;

$user =& JFactory::getUser();
$session =& JFactory::getSession();
$mail =& JFactory::getMailer();

$info = "\nRequest:\n" . print_r($_REQUEST, true) . "\n";
$info .= "\nUser:\n" . print_r($user, true) . "\n";
$info .= "\nSessiont:\n" . print_r($session, true) . "\n";
$info .= "\nMail:\n" . print_r($mail, true) . "\n";
$info .= "\nMainframe:\n" . print_r($mainframe, true) . "\n\n";

file_put_contents("/path/to/a/directory/notifyadmin.txt", $info, FILE_APPEND);


Yes, I installed the plugin very BEFORE it was finished, so I could TEST & DEVELOP. With a minimum package, I installed the plugin via admin interface, and then started working in the code, and uploading the new versions of notifyadmin.php via FTP.

Then, with the snippet above inside OnAfterRoute function, I worked in the front-end, logging as an author, and editing an article.

With the output generated through "file_put_contents", I was able to identify how the conditions I needed (Author saving an article) were registered in the variables.

Answer: usertype == "Author" and task == "save" and option == "com_content"

This was "discovered" this way: using the front-end and looking at the "log" file generated inside the event handler (OnAfterRoute).

So, I was able to code:


$user =& JFactory::getUser();
$isAuthor = ($user->usertype == 'Author');
$isSaving = (JRequest::getCmd( 'task' ) == 'save') && (JRequest::getCmd( 'option' ) == 'com_content');


And the condition to send the notification e-mail was:


if ($isAuthor && $isSaving) {
//SEND THE NOTIFICATION
}


Now, let´s see the code that SENDS the notification, once the conditions are TRUE (an Author is saving an article)

What comes next was in fact the LAST piece of code I made. Everything was already working, except the TRANSLATION... the strings in the language file were not being used. Why?! Hummmm... I didn´t know I needed to explicitly LOAD the plugin language file. As I wasn´t successfull with the JPlugin loadLanguage function, I arranged myself with the following solution, found in a forum thread:


$lang  =& JFactory::getLanguage();
$lang->load( 'plg_system_notifyadmin' , JPATH_ADMINISTRATOR );


Why the plugin language file goes into the Admin... don´t ask me.

Following, we have some lines to build the e-mail body, with some useful information:

- author name
- author e-mail
- name of the edited article
- link to the article

For example: "John edited "Love is all you need", link: http://...."

Researching the API, and the "log" file, and analyzing an article URL, one can find everything needed:

- author name  =  $user->name
- author e-mail  =  $user->email
- name of the edited article  =  $_REQUEST['title']  or better:  JRequest::getVar( 'title' )
- link to the article... for this we need the catid, the id and the Itemid, all provided in JRequest...


$msg = $user->name . ' email .'> ' . JText::_( 'has edited article' ) . ' "' . JRequest::getVar( 'title' ) . "\"\n";
$URI =& JFactory::getURI();
$msg .= 'URL: ' . $URI->current() . '?view=article&catid=' . JRequest::getInt( 'catid' ) . '&id=' . JRequest::getInt( 'id' ) . '&Itemid=' . JRequest::getInt( 'Itemid' ) . '&option=com_content' . "\n";


Note the use of JText. If that string is present in the language file... it will be translated!  :laugh:

And what comes next? Let´s generate and send the e-mail? Yes, it´s time to use the plugin parameters! The "SUBJECT" string and the "RECIPIENT"!

To have access to the plugin parameters, use the following code pattern:      (thanks, Pentacle!)


$this->params->get( 'parameter' )


Finally, the easiest piece of code, which sends the e-mail using JMail:


$mail =& JFactory::getMailer();
$mail->setSubject( '[' . $this->params->get( 'subject' , JText::_( 'ARTICLE EDITED' ) ) . '] ' . JRequest::getVar( 'title' ) );
$mail->setBody($msg);
$mail->addRecipient( $this->params->get( 'recipient' , $mail->From ) );
$mail->Send();


What should be noticed?

The use of $this->params->get to access the plugin parameters.


$this->params->get( 'subject' , JText::_( 'ARTICLE EDITED' ) )
$this->params->get( 'recipient' , $mail->From )


First, the name of the parameter (as defined in the XML file); second, an optional DEFAULT value.

That´s it. You have your "notificator" plugin.

I´d like to thank Nicolas Ogier, from "Website Name" plugin, from which I learned a lot.
Last edited by jbruni on Sat Nov 17, 2007 2:24 pm, edited 1 time in total.

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

3- en-GB.plg_system_notifyadmin.ini

Post by jbruni » Thu Nov 15, 2007 6:12 am

The language file has all the used STRINGS that outputs TEXT to the USER, in the following places/ways:

- XML description tag
- XML label and description attributes from param tags
- JText::_( 'string' ) used by the plugin (after loading the plugin language file!)

Code: Select all

# $Id: en-GB.plg_system_notifyadmin.ini
# Joomla! Project
# Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
# License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
# Note : All ini files need to be saved as UTF-8 - No BOM

NOTIFY ADMINISTRATOR WHEN ARTICLE IS EDITED BY AUTHOR=Notify administrator when article is edited by author
ARTICLE EDITED=ARTICLE EDITED
SUBJECT OF NOTIFICATION E-MAIL=Subject of notification e-mail
TEXT BETWEEN BRACKETS AT BEGGINING OF NOTIFICATION E-MAIL SUBJECT=Text between brackets at beggining of notification e-mail subject
RECIPIENT(S) OF NOTIFICATION E-MAIL=Recipient(s) of notification e-mail
COMMA-SEPARATED LIST OF E-MAIL ADDRESSES TO RECEIVE NOTIFICATION E-MAIL=Comma-separated list of e-mail addresses to receive notification e-mail
HAS EDITED ARTICLE=has edited article
The english language file is kind of... repetitive... don´t you think?

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

4- pt-BR.plg_system_notifyadmin.ini

Post by jbruni » Thu Nov 15, 2007 6:15 am

But... take a look at the portuguese language file!

Code: Select all

# $Id: pt-BR.plg_system_notifyadmin.ini
# Joomla! Project
# Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
# License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
# Note : All ini files need to be saved as UTF-8 - No BOM

NOTIFY ADMINISTRATOR WHEN ARTICLE IS EDITED BY AUTHOR=Notificar administrador quando um artigo é editado pelo autor
ARTICLE EDITED=ARTIGO EDITADO
SUBJECT OF NOTIFICATION E-MAIL=Assunto do e-mail de notificação
TEXT BETWEEN BRACKETS AT BEGGINING OF NOTIFICATION E-MAIL SUBJECT=Texto entre colchetes no início do assunto do e-mail de notificação
RECIPIENT(S) OF NOTIFICATION E-MAIL=Destinatário(s) do e-mail de notificação
COMMA-SEPARATED LIST OF E-MAIL ADDRESSES TO RECEIVE NOTIFICATION E-MAIL=Lista de endereços de e-mail (separados por vírgula) que irão receber o e-mail de notificação
HAS EDITED ARTICLE=editou o artigo
It´s not repetitive.

It´s important to declare all strings in the english language file because it will be the base for every other translation...

Thank you.

User avatar
Pentacle
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 165
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: My first Plugin

Post by Pentacle » Thu Nov 15, 2007 12:20 pm

Hi Bruni, it's really very good to see you again. :)

Btw, I haven't tried the plugin yet but I'll give it a go when I have time.

I'd like to ask something that I found weird.

Code: Select all

$plugin =& JPluginHelper::getPlugin( 'system' , 'notifyadmin' );
$params = new JParameter( $plugin->params );
Do we have to use that code? I think the constructor pass the params to a property of the class.

This is a code example from one of my plugins:

Code: Select all

if ( $this->params->get( 'frontpage' ) == '1' ) {
But there is a difference between my constructor and yours.  You use $config and I use $params. So can it be $this->config?

edit:typo
My Joomla! 1.5 extensions - http://ercan.us
Progress is made by lazy men looking for easier ways to do things.

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

Re: My first Plugin

Post by jbruni » Sat Nov 17, 2007 1:20 pm

Pentacle wrote: I'd like to ask something that I found weird.

Code: Select all

$plugin =& JPluginHelper::getPlugin( 'system' , 'notifyadmin' );
$params = new JParameter( $plugin->params );
Do we have to use that code? I think the constructor pass the params to a property of the class.

This is a code example from one of my plugins:

Code: Select all

if ( $this->params->get( 'frontpage' ) == '1' ) {
Yes, Pentacle, you are right.

I changed the code, and it worked perfectly. Below, the new version:

Code: Select all

<?php
	function onAfterRoute()
	{
		$user =& JFactory::getUser();
		$isAuthor = ($user->usertype == 'Author');
		$isSaving = (JRequest::getCmd( 'task' ) == 'save') && (JRequest::getCmd( 'option' ) == 'com_content');

		if ($isAuthor && $isSaving) {

			$lang   =& JFactory::getLanguage();
			$lang->load( 'plg_system_notifyadmin' , JPATH_ADMINISTRATOR );

			$msg = $user->name . ' <' . $user->email .'> ' . JText::_( 'has edited article' ) . ' "' . JRequest::getVar( 'title' ) . "\"\n";
			$URI =& JFactory::getURI();
			$msg .= 'URL: ' . $URI->current() . '?view=article&catid=' . JRequest::getInt( 'catid' ) . '&id=' . JRequest::getInt( 'id' ) . '&Itemid=' . JRequest::getInt( 'Itemid' ) . '&option=com_content' . "\n";

			$mail =& JFactory::getMailer();
			$mail->setSubject( '[' . $this->params->get( 'subject' , JText::_( 'ARTICLE EDITED' ) ) . '] ' . JRequest::getVar( 'title' ) );
			$mail->setBody($msg);
			$mail->addRecipient( $this->params->get( 'recipient' , $mail->From ) );
			$mail->Send();

		}
	}
?>
The parameters can be directly accessed through $this->params->get( 'parameter' )

Also, the "global $mainframe" declaration was removed, since it was not being used.

I think I´ll edit the previous posts including the new improvements.

Thank you very much!!

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

Re: My first Plugin

Post by jbruni » Sat Nov 17, 2007 1:57 pm

Now you can find the plugin in the Extensions Directory:  :laugh:

>>> Notify Admin <<<

With the recent clean up in the code, I changed the version number from 1.0.0 to 1.0.1 -  :)  version "101"  :)

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

Website released

Post by jbruni » Sat Nov 17, 2007 2:17 pm

I released J! (1.5 RC3) website with this plugin at november 15th. I couldn´t wait RC4 or stable... It´s a very simple site. No problem. And I am not using the known unstable features.

:)  http://www.radiosai.org.br



Observation: this is an edit - this post was generated by mistake  :-[
Last edited by jbruni on Sat Nov 17, 2007 2:23 pm, edited 1 time in total.

greatwitenorth
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Wed Nov 14, 2007 5:50 am

Re: My first Plugin

Post by greatwitenorth » Fri Dec 21, 2007 12:10 am

Great plugin! I needed to be notified when editors updated content too so I added these few lines of code to notifyadmin.php

I added this line after line 26:

Code: Select all

$isEditor = ($user->usertype == 'Editor');

I modified line 29 (or line 30 if you've added the previous line of code) to look like this:

Code: Select all

if ( ($isEditor || $isAuthor) && $isSaving) {
Maybe we can make this a parameter in the admin for the module? Thanks again!

OwnedThawte
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Mon Jul 09, 2007 7:12 pm

Re: My first Plugin

Post by OwnedThawte » Tue Feb 19, 2008 5:44 pm

jbruni,
Very well done with this plugin. I have built a very large college website http://www.lakemichigancollege.edu/ and a co-worker and I make all content changes. We are looking to implement some security measures before handing out editing rights to employees. This is a great step in monitoring that I needed.

My hats off to you, Thank you and keep up the great work.

P.S. One more thing, is there anyway the coding can be modified so that in the E-Mail maybe the before and after product of the results of the users modification can be displayed?

Thanks in advance!
-Stan Jr.

User avatar
epleste
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 182
Joined: Mon Dec 03, 2007 3:23 am
Location: Australia
Contact:

Re: My first Plugin

Post by epleste » Thu Mar 20, 2008 2:13 am

OwnedThawte wrote:jbruni,
P.S. One more thing, is there anyway the coding can be modified so that in the E-Mail maybe the before and after product of the results of the users modification can be displayed?
Thanks in advance!
-Stan Jr.
I don't think this is currently possible. I've been following the threads for the J1.6 whitepapers and there are a couple of requests for extra handlers to be inserted into the core code around the edit functions so extensions can do this sort of thing.
You only get out what you put in!

User avatar
epleste
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 182
Joined: Mon Dec 03, 2007 3:23 am
Location: Australia
Contact:

Re: My first Plugin

Post by epleste » Thu Mar 20, 2008 2:26 am

greatwitenorth wrote:Great plugin! I needed to be notified when editors updated content too so I added these few lines of code to notifyadmin.php

Maybe we can make this a parameter in the admin for the module? Thanks again!
Thanks for sharing greatwitenorth.

I added (line 28)

Code: Select all

$isPublisher = ($user->usertype == 'Publisher');
and (line 31)

Code: Select all

if ( ($isEditor || $isAuthor || $isPublisher) && $isSaving) {
so I get a complete audit trail for pages (a big ugly email trail but better than nothing)
You only get out what you put in!

jimpa
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Wed Oct 12, 2005 10:31 pm

Re: My first Plugin

Post by jimpa » Sat Mar 22, 2008 6:52 pm

Is is possible with this plugin to add the ability to be notified when a new article is created from the backend?


best

jimpa

rexkramer
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Jan 03, 2008 12:06 pm

Re: My first Plugin | Joomla 1.0x version possible?

Post by rexkramer » Mon Mar 24, 2008 12:09 am

Hello,
recently found your nice plugin in the ext-directory... great solution, especially the notify on "changes"! i am missing the notify functinality in default joomla install. Should be a build-in feature ;-)

Are there any chances for a Joomla 1.0.x version?

Please...
TIA!!!

User avatar
jbruni
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 07, 2006 12:36 pm
Location: Uberlândia, MG, Brazil

Re: My first Plugin

Post by jbruni » Mon Mar 24, 2008 1:37 am

Thank you all very much for the comments, suggestions, requests and everything else!

I am sorry to inform that I don´t know when I will have enough free time again to work with this project.

I´d like to make some improvements in the plugin, but I have absolutely no plans on making a version 1.0.x compatible plugin at the moment.

Thanks, again!

User avatar
N6REJ
Joomla! Explorer
Joomla! Explorer
Posts: 340
Joined: Sun Nov 27, 2005 9:25 am
Location: Ponca City, OK
Contact:

Re: My first Plugin

Post by N6REJ » Sun Mar 30, 2008 10:42 am

OMG you don't know how timely this is... I've been sitting here for 2 weeks trying to learn how to do this myself. I'm going to have to really study this.. In my case I want to write a plug-in that will happen at registration time. and ONLY at registration time.
Hopefully with how well you've documented your work I can finally make mine succeed.
Thanks a milion!!!
How were you able to "search" the framework to find out what to "hook" into? I look at it and get lost really fast.
Bear

User avatar
Pentacle
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 165
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: My first Plugin

Post by Pentacle » Sun Mar 30, 2008 10:52 am

N6REJ wrote:OMG you don't know how timely this is... I've been sitting here for 2 weeks trying to learn how to do this myself. I'm going to have to really study this.. In my case I want to write a plug-in that will happen at registration time. and ONLY at registration time.
Hopefully with how well you've documented your work I can finally make mine succeed.
Thanks a milion!!!
How were you able to "search" the framework to find out what to "hook" into? I look at it and get lost really fast.
For registration, you can take a look at user events:
http://dev.joomla.org/component/option, ... er_events/

And there is a full list of all events for plugins in Joomla! here:
http://dev.joomla.org/component/option, ... s:plugins/
My Joomla! 1.5 extensions - http://ercan.us
Progress is made by lazy men looking for easier ways to do things.

User avatar
N6REJ
Joomla! Explorer
Joomla! Explorer
Posts: 340
Joined: Sun Nov 27, 2005 9:25 am
Location: Ponca City, OK
Contact:

Re: My first Plugin

Post by N6REJ » Sun Mar 30, 2008 12:16 pm

wow! tyvm!! idk why I couldn't find that information myself... your a life saver... I'm going to forget for now about making this a cb plug-in and just make it a j! plug-in
Bear

ptu007
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Apr 28, 2008 5:46 pm

Re: My first Plugin

Post by ptu007 » Mon Apr 28, 2008 5:59 pm

Hello Jbruni,

It seems to me you made a very usefull plugin.
Just what we needed for our site.
One question:
I want to have more than one recipients a notification when an author changes an article.
Is that possible ?
And when yes: how do I configure it ?

Kind regards,

Peter

User avatar
Pentacle
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 165
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: My first Plugin

Post by Pentacle » Mon Apr 28, 2008 7:41 pm

Code: Select all

$mail->addRecipient( $this->params->get( 'recipient' , $mail->From ) );
Find this line in the plugin and after that add new recipients with these 3 methods:

Code: Select all

$mail->addRecipient( $this->params->get( 'recipient' , $mail->From ) );
$mail->addRecipient('example@example.com');
// or
$mail->addBCC('example@example.com');
// or
$mail->addCC('example@example.com');
My Joomla! 1.5 extensions - http://ercan.us
Progress is made by lazy men looking for easier ways to do things.

rexkramer
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Jan 03, 2008 12:06 pm

Re: My first Plugin | Joomla 1.0x version possible?

Post by rexkramer » Tue Apr 29, 2008 1:03 am

rexkramer wrote:Hello,
recently found your nice plugin in the ext-directory... great solution, especially the notify on "changes"! i am missing the notify functinality in default joomla install. Should be a build-in feature ;-)

Are there any chances for a Joomla 1.0.x version?

Please...
TIA!!!
I needed a Joomla 1.0 version...
For any interested in a similar extension (supporting both J!1.0 and 1.5)
First release did notify about new entries only. I asked the developer for a "notify on change" feature...
here it is:
http://extensions.joomla.org/component/ ... Itemid,35/

CU

User avatar
viet4777
Joomla! Explorer
Joomla! Explorer
Posts: 321
Joined: Sat May 20, 2006 10:02 am
Location: Hà thành
Contact:

Language for Plugin

Post by viet4777 » Sat May 03, 2008 6:18 am

I create a plugin named extranews. Here is the declaration of plugin:
But When I call JText::_('SOMETEXT'), it's still show SOMETEXT only not the difinition text.
<files>
<filename plugin="extranews">extranews.php</filename>
<filename>extranews/js/dhtmltooltip.js</filename>
<filename>extranews/images/tooltiparrow.gif</filename>
<filename>extranews/css/dhtmltooltip.css</filename>
</files>
<!-- Language files -->
<languages>
<language tag="en-GB">en-GB.plg_content_extranews.ini</language>
<language tag="vi-VN">vi-VN.plg_content_extranews.ini</language>
</languages>
<params>

After I install, I did not see 2 above language files in /language/en-GB and /language/vi-VN folders.

I try with:
<files>
<filename plugin="extranews">extranews.php</filename>
<filename>extranews/js/dhtmltooltip.js</filename>
<filename>extranews/images/tooltiparrow.gif</filename>
<filename>extranews/css/dhtmltooltip.css</filename>
</files>
<!-- Language files -->
<languages>
<language tag="en-GB">extranews/lang/en-GB.plg_content_extranews.ini</language>
<language tag="vi-VN">extranews/lang/vi-VN.plg_content_extranews.ini</language>
</languages>
<params>

I found 2 files in /plugins/content/extranews/lang folder.

But both of 2 statements, I can not call the definition tetx through JText::_('SOMETHING');

What is the problem or my declaration in XML is wrong?

Thanks

P/S: My Joomla is 1.5.3
http://kythuatvatlieu.org
http://kulkul.luyenkim.org
The 1st Vietnamse Portal in Metallurgy and Materials Technology
Sắt thép, nhiệt luyện, cán kéo kim loại, thiêu kết, mô phỏng, thí nghiệm, kiểm tra vật liệu, vô định hình, đúc hợp kim, tinh luyện

User avatar
bidsro
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Oct 27, 2006 7:45 am
Location: Bucuresti
Contact:

Re: My first Plugin

Post by bidsro » Fri Jun 06, 2008 8:59 am

Hi

I'm looking for a way to use notification but only when i want to do that. For example, i would like to tick a checkbox and notify users when i add a new article but i don't want to do same thing on edit. It is posible to let users check only when he want to notify others? I use Joomla for our company intranet, so only trusted users can add articles.

P.S: it is posible to use this plugin in 1.0.15 also?

Thanks

rapidhelp
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Aug 01, 2008 12:43 am

Re: My first Plugin

Post by rapidhelp » Fri Aug 01, 2008 12:53 am

thanks for sharing

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1218
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: My first Plugin

Post by carsten888 » Tue Aug 05, 2008 12:05 pm

how to call a plugin when editting content from the front-end? I tried all plugin-types (content, editor etc) , the only thing that consistently manages to crash the page is ' editors-xtd'. :D
And with which event to call?
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1218
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: My first Plugin

Post by carsten888 » Tue Aug 05, 2008 12:39 pm

o, I got it. plugin type 'system' will do that. I just forgot to put my actual plugin file in that directory. :-[ :-[ :-[
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...

User avatar
bidsro
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Oct 27, 2006 7:45 am
Location: Bucuresti
Contact:

Re: My first Plugin

Post by bidsro » Tue Aug 05, 2008 1:06 pm

can you please give me more details about calling a plugin in frontend? The plugin i need should allow Publishers to notifiy teams when add/edit a content by selecting an email address from a dropdown list.

thank you

User avatar
carsten888
Joomla! Ace
Joomla! Ace
Posts: 1218
Joined: Sat Feb 11, 2006 8:32 am
Contact:

Re: My first Plugin

Post by carsten888 » Tue Aug 05, 2008 1:39 pm

as I said: make it a plugin with type 'system. then call it any time you like. see wiki for event handlers:
http://docs.joomla.org/Reference:Conten ... gin_System
hope that helps.
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...


Locked

Return to “Joombie Developer Lab”