Event Manager

The Event Manager allows user defined tags or modules to handle events triggered by other modules; i.e. News sends an event when a new article is added, and it is possible to trap that with a User Defined Tag (UDT), or another module without having to modify the news code.
In brief, here's how it works
  1. A module, or the core, can register, and then Send Events such as "newNews", or "newFronteEndUser" or "fileUploaded", "editPage", etc, etc, etc. There's some 50 events in the core at the moment, and then uploads and frontend users have been configured to send events. I still have to do selfreg, etc, etc, etc.
  2. There are pages in the "Admin Console/Extensions" to allow you to specify which modules, and/or user tags should handle those events, and the order that each of those handlers should be called in.
  3. If one of the handlers of an event is a module, then.... the modules DoEvent method is called with the name of the event, and whatever data it wants to send. Each triggered event needs to be documented, but as of this moment, most are.
This functionality allows anybody with a bit of php knowledge, and the ability to look through the cms source, etc. to write their own workflows. For example, it should be easy now to write a bridge between frontendusers and any forum software that you want to keep users and groups updated in the forum.
The search module also uses events, and now because of this mechanism, the content submitted with the uploads module, i.e.: the summary, and the description, are searchable with the search module and a link is provided to the detail report of the file, and then you have the ability to download the file.
Example 1.
To get CMS Made Simple to send someone an email when a content page is updated, do the following:
  1. Create a new user defined tag, and call it something like 'EmailEditor'. Put the following in the contents: mail('my@email.com.au','page updated','the page has been updated'); (replacing my@email.com.au with your email address of course). Save the UDT.
  2. Go to the Events page, and find the entry labelled "ContentEditPost" and click the edit button for it.
  3. Select your UDT from the dropdown list (the one you called 'EmailEditor') and click add.
Thats it. Now whenever someone updates a page you will be sent an email.
Because the content object also gets passed to the UDT, you should be able to put the actual page contents / title / author / whatever into the email that gets sent.
You should also probably use the cms mailer function, rather than the built-in php one. This is only a proof of concept. I just did this in CMS Made Simple 1.0.8 and it worked fine.
Example 2.
Create directory for every registered user.
  1. Install CGExtentions and FrontEndUsers (FEU) modules and make sure you can add user manually.
    CMSMailer comes with CMSms core.
  2. Configure CMSMailer.
  3. Create an User Defined Tag (UDT) "create_feu_dir". It creates directory
    "/uploads/front_end_users/uses_name_or_email".
    In case directory is not created (wrong permissions, low disk space, alien attack, ...) you will be informed by email.
    Note: this UDT depends on modules CGExtentions and CMSMailer.
  $gCms = cmsms(); //global $gCms;
  $config = $gCms->GetConfig();
  
  $subdir = 'front_end_users';
  $user_dir = $params['username'];
  
  $email = 'admin@**************';		/*your mail address*/
  /*sometimes it is better idea to create dir based on user id*/
  /*$user_dir = $params['id'];*/
  
  $destdir = cms_join_path($config['uploads_path'], $subdir, $user_dir);
  
  cge_dir::mkdirr($destdir);		/*this bit requires CGExtentions module*/
  
  /*Error handling depends on CMSMailer module*/
  if( !is_dir($destdir) ){
  	$body = 'Directory "'.$destdir.'" was not created for user ('
  	$body .= $params['id'].') '.$params['username'];
  	$subject = $body;
  	$mail =& $gCms->modules['CMSMailer']['object'];
  	$mail->AddAddress( $email );
  	$mail->IsHTML( false );
  	$mail->SetBody( $body );
  	$mail->SetSubject( $subject );
  	$mail->Send();
  	$mail->reset();
  }
  1. Go to "Extensions » Event Manager" and press on "Frontend User Management -> OnLogin". To see parameter sent by event to your UDT, click "Help" link on the right hand side on the same row.
  2. On next page select your UDT "create_feu_dir" and submit form.
  3. From now every user that signs in will have own directory for various documents. Give it a try :)


This page in: English - Deutsch - Español - Français - Italiano - Lietuvių - Nederlands - Norsk - Polski - Česky - Русский - Svenska - Tiếng Việt - عربي - 日本語 简体中文

User Handbook/Admin Panel/Extensions/Event Manager

From CMSMS

Arvixe - A CMSMS Partner