[SOLVED] Multiple notifications from custom module.

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
ivanshum
Forum Members
Forum Members
Posts: 16
Joined: Sun Jul 03, 2011 10:01 am
Location: Russia

[SOLVED] Multiple notifications from custom module.

Post by ivanshum »

Hi all, I create a module and need two different notifications from it.
in <modulename>.module.php i write this code:

Code: Select all

	function GetNotificationOutput($priority = 3)
	{
		$gCms = cmsms();
		$db = $gCms->GetDb();
		$results = $db->GetOne('select count(*) from '.cms_db_prefix().'module_<modulename>_calendar where date = '.mktime(0, 0, 0, date("m") , date("d"), date("Y")));
		if ($results > 0)
		{
			$obj = new StdClass;
			$obj->priority = 2;
			$obj->html = '<some text>'
		}
		return $obj;
	}

It's first notification. How i can create second ??? They must work together.
Version of CMSMS:1.11.4 “Fernandina”
P.S.: Sorry for my English(If it so bad) :)
P.P.S: This module done nothing, I am newbie in developing modules for CMSMS. It is only for education.
Last edited by ivanshum on Thu Jan 31, 2013 5:49 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Multiple notifications from custom module.

Post by calguy1000 »

Return an array of stdclass objects.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
ivanshum
Forum Members
Forum Members
Posts: 16
Joined: Sun Jul 03, 2011 10:01 am
Location: Russia

Re: Multiple notifications from custom module.

Post by ivanshum »

Thanks, it's work! Made Simple so simple)
But I found a bug(?), Example:

Code: Select all

	function GetNotificationOutput($priority = 3)
	{
		$sn = 20;//For test second notification
		$gCms = cmsms();
		$db = $gCms->GetDb();
		//First notification
		$results = $db->GetOne('select count(*) from '.cms_db_prefix().'module_paper_calendar where date = '.mktime(0, 0, 0, date("m") , date("d"), date("Y")));
		if ($results > 0)
		{
			$obj[0] = new StdClass;
			$obj[0]->priority = 2;
			$obj[0]->html = 'На сегодня '.date("d/m/Y").' запланирована сборка выпуска '.$this->CreateLink($id, 'defaultadmin', $resultid, 'Подтвердить').' '.$this->CreateLink($id, 'defaultadmin', $resultid, 'Отменить');
		}
		//Second notification
		if ($sn > 15)
		{
			$obj[1] = new StdClass;
			$obj[1]->priority = 2;
			$obj[1]->html = '2ое';
		}
		return $obj;
	}
In this code when if ($results > 0) in first notification return false, then number of notifications is "2" but print only one (Screenshot1)
But if We added $obj = array_slice($obj,0); before return $obj; then all works fine. It change keys of array to 0,1,2,3,...
I think it can be bug of admin theme (I'm using OneEleven) or in core of CMS.
Attachments
Screenshot1
Screenshot1
Screenshot1.png (5.55 KiB) Viewed 2494 times
Post Reply

Return to “Developers Discussion”