Page 1 of 1

[SOLVED] Multiple notifications from custom module.

Posted: Tue Jan 29, 2013 12:15 pm
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.

Re: Multiple notifications from custom module.

Posted: Tue Jan 29, 2013 4:01 pm
by calguy1000
Return an array of stdclass objects.

Re: Multiple notifications from custom module.

Posted: Wed Jan 30, 2013 6:20 am
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.