PageRenderTime 169ms CodeModel.GetById 61ms app.highlight 65ms RepoModel.GetById 35ms app.codeStats 1ms

/plugins/system/nnframework/helpers/assignments.php

https://bitbucket.org/organicdevelopment/joomla-2.5
PHP | 693 lines | 618 code | 38 blank | 37 comment | 148 complexity | 479297755527d75595b05b6bf25bbc40 MD5 | raw file
  1<?php
  2/**
  3 * NoNumber Framework Helper File: Assignments
  4 *
  5 * @package         NoNumber Framework
  6 * @version         12.8.2
  7 *
  8 * @author          Peter van Westen <peter@nonumber.nl>
  9 * @link            http://www.nonumber.nl
 10 * @copyright       Copyright Š 2012 NoNumber All Rights Reserved
 11 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 12 */
 13
 14// No direct access
 15defined('_JEXEC') or die;
 16
 17/**
 18 * Assignments
 19 * $assignment = no / include / exclude / none
 20 */
 21class NNFrameworkAssignmentsHelper
 22{
 23	var $_version = '12.8.2';
 24
 25	var $_db = null;
 26	var $_params = null;
 27	var $_types = array();
 28	var $_passes = array();
 29
 30	function __construct()
 31	{
 32		$this->_db = JFactory::getDBO();
 33
 34		$config = JFactory::getConfig();
 35		$this->_date = JFactory::getDate();
 36		$this->_date->setTimeZone(new DateTimeZone($config->getValue('config.offset')));
 37
 38		$this->_types = array(
 39			'MenuItem',
 40			'HomePage',
 41			'Cats',
 42			'Articles',
 43			'Categories_FC',
 44			'Tags_FC',
 45			'Types_FC',
 46			'Items_FC',
 47			'Categories_K2',
 48			'Tags_K2',
 49			'Items_K2',
 50			'Categories_MR',
 51			'Categories_ZOO',
 52			'Components',
 53			'URL',
 54			'OS',
 55			'Browsers',
 56			'Date',
 57			'Seasons',
 58			'Months',
 59			'Days',
 60			'Time',
 61			'UserGroupLevels',
 62			'Users',
 63			'Languages',
 64			'Templates',
 65			'Categories_VirtueMart',
 66			'Items_VirtueMart',
 67			'PHP'
 68		);
 69		$this->_classes = array();
 70	}
 71
 72	function getRequestParams()
 73	{
 74		$params = new stdClass();
 75		$params->option = JRequest::getCmd('option');
 76		$params->view = JRequest::getCmd('view');
 77		$params->task = JRequest::getCmd('task');
 78		$params->id = JRequest::getInt('id');
 79		$params->Itemid = JRequest::getInt('Itemid');
 80
 81		switch ($params->option) {
 82			case 'com_categories':
 83				$params->option = 'com_content';
 84				$params->view = 'category';
 85				break;
 86			case 'com_sections':
 87				$params->option = 'com_content';
 88				$params->view = 'section';
 89				break;
 90			case 'com_mr':
 91				$params->item_id = JRequest::getInt('article');
 92				$params->category_id = JRequest::getInt('category_id');
 93				$params->id = ($params->item_id) ? $params->item_id : $params->category_id;
 94				break;
 95			case 'com_zoo':
 96				$params->item_id = JRequest::getInt('item_id');
 97				$params->category_id = JRequest::getInt('category_id');
 98				$params->id = ($params->item_id) ? $params->item_id : $params->category_id;
 99				break;
100			case 'com_virtuemart':
101				$params->item_id = JRequest::getInt('virtuemart_product_id');
102				$params->category_id = JRequest::getInt('virtuemart_category_id');
103				$params->id = ($params->item_id) ? $params->item_id : $params->category_id;
104				break;
105		}
106
107		if (!$params->id) {
108			$cid = JRequest::getVar('cid', array(0), 'method', 'array');
109			$cid = array((int) $cid['0']);
110			$params->id = $cid['0'];
111		}
112
113		return $params;
114	}
115
116	function initParams(&$params, $type = '')
117	{
118		if (!isset($params->assignment)) {
119			$params->assignment = 'all';
120		} else {
121			$this->getAssignmentState($params->assignment);
122		}
123
124		if (!isset($params->selection)) {
125			$params->selection = array();
126		}
127		if (!isset($params->params)) {
128			$params->params = null;
129		}
130
131		$this->maintype = $type;
132		switch ($type) {
133			case 'MenuItem':
134				$this->maintype = 'Menu';
135				break;
136			case 'Cats':
137			case 'Articles':
138				$this->maintype = 'Content';
139				break;
140			case 'Categories_FC':
141			case 'Tags_FC':
142			case 'Types_FC':
143			case 'Items_FC':
144				$this->maintype = 'FlexiContent';
145				break;
146			case 'Categories_K2':
147			case 'Tags_K2':
148			case 'Items_K2':
149				$this->maintype = 'K2';
150				break;
151			case 'Categories_MR':
152				$this->maintype = 'Resources';
153				break;
154			case 'Categories_ZOO':
155				$this->maintype = 'ZOO';
156				break;
157			case 'OS':
158				$this->maintype = 'Browsers';
159				break;
160			case 'Date':
161			case 'Seasons':
162			case 'Months':
163			case 'Days':
164			case 'Time':
165				$this->maintype = 'DateTime';
166				break;
167			case 'UserGroupLevels':
168			case 'Users':
169				$this->maintype = 'Users';
170				break;
171			case 'Categories_VirtueMart':
172			case 'Items_VirtueMart':
173				$this->maintype = 'VirtueMart';
174				break;
175		}
176
177		switch ($type) {
178			case 'MenuItem':
179				if (!isset($params->params->inc_children)) {
180					$params->params->inc_children = 0;
181				}
182				if (!isset($params->params->inc_noItemid)) {
183					$params->params->inc_noItemid = 0;
184				}
185				break;
186			case 'Articles':
187				if (!isset($params->params->keywords)) {
188					$params->params->keywords = '';
189				}
190				break;
191			case 'SecsCats':
192			case 'Cats':
193				if (!isset($params->params->inc_children)) {
194					$params->params->inc_children = 1;
195				}
196				if (!isset($params->params->inc_sections)) {
197					$params->params->inc_sections = 1;
198				}
199				if (!isset($params->params->inc_categories)) {
200					$params->params->inc_categories = 1;
201				}
202				if (!isset($params->params->inc_articles)) {
203					$params->params->inc_articles = 1;
204				}
205				if (!isset($params->params->inc_others)) {
206					$params->params->inc_others = 0;
207				}
208				break;
209			case 'Categories_FC':
210			case 'Categories_K2':
211			case 'Categories_MR':
212			case 'Categories_ZOO':
213			case 'Categories_VirtueMart':
214				if (!isset($params->params->inc_children)) {
215					$params->params->inc_children = 0;
216				}
217				if (!isset($params->params->inc_categories)) {
218					$params->params->inc_categories = 1;
219				}
220				if (!isset($params->params->inc_items)) {
221					$params->params->inc_items = 1;
222				}
223				break;
224			case 'Tags_FC':
225			case 'Tags_K2':
226				if (!isset($params->params->inc_tags)) {
227					$params->params->inc_tags = 1;
228				}
229				if (!isset($params->params->inc_items)) {
230					$params->params->inc_items = 1;
231				}
232				break;
233			case 'Date':
234			case 'Time':
235				if (!isset($params->params->publish_up)) {
236					$params->params->publish_up = 0;
237				}
238				if (!isset($params->params->publish_down)) {
239					$params->params->publish_down = 0;
240				}
241				break;
242			case 'Seasons':
243				if (!isset($params->params->hemisphere)) {
244					$params->params->hemisphere = 'northern';
245				}
246				break;
247		}
248	}
249
250	function passAll(&$params, $match_method = 'and', $article = 0)
251	{
252		if (empty($params)) {
253			return 1;
254		}
255
256		jimport('joomla.filesystem.file');
257
258		$app = JFactory::getApplication();
259		$this->_params = $this->getRequestParams();
260
261		// if no id is found, check if menuitem exists to get view and id
262		if ($app->isSite() && (!$this->_params->option || !$this->_params->id)) {
263			$menu = $app->getMenu('site');
264			if (empty($this->_params->Itemid)) {
265				$menuItem = $menu->getActive();
266			} else {
267				$menuItem = $menu->getItem($this->_params->Itemid);
268			}
269			if (!$this->_params->option) {
270				$this->_params->option = (empty($menuItem->query['option'])) ? null : $menuItem->query['option'];
271			}
272			$this->_params->view = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
273			$this->_params->task = (empty($menuItem->query['task'])) ? null : $menuItem->query['task'];
274			if (!$this->_params->id) {
275				$this->_params->id = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
276			}
277			unset($menuItem);
278		}
279
280		$aid = ($article && isset($article->id)) ? '['.$article->id.']' : '';
281		$id = md5($aid.json_encode($params));
282
283		if (isset($this->_passes[$id])) {
284			$pass = $this->_passes[$id];
285		} else {
286			$pass = ($match_method == 'and') ? 1 : 0;
287			foreach ($this->_types as $type) {
288				if (isset($params[$type])) {
289					$this->initParams($params[$type], $type);
290					if (($pass && $match_method == 'and') || (!$pass && $match_method == 'or')) {
291						$tid = md5($type.$aid.':'.json_encode($params[$type]));
292						if (isset($this->_passes[$tid])) {
293							$pass = $this->_passes[$tid];
294						} else {
295							if ($params[$type]->assignment == 'all') {
296								$pass = 1;
297							} else if ($params[$type]->assignment == 'none') {
298								$pass = 0;
299							} else {
300								if (!isset($this->_classes[$this->maintype]) && JFile::exists(__DIR__.'/assignments/'.strtolower($this->maintype).'.php')) {
301									require_once __DIR__.'/assignments/'.strtolower($this->maintype).'.php';
302									$class = 'NNFrameworkAssignments'.$this->maintype;
303									$this->_classes[$this->maintype] = new $class;
304								}
305								if (isset($this->_classes[$this->maintype])) {
306									$func = 'pass'.$type;
307									$pass = $this->_classes[$this->maintype]->$func($this, $params[$type]->params, $params[$type]->selection, $params[$type]->assignment, $article);
308								}
309							}
310							$this->_passes[$tid] = $pass;
311						}
312					}
313				}
314			}
315			$this->_passes[$id] = $pass;
316		}
317
318		return ($pass) ? 1 : 0;
319	}
320
321	/**
322	 * passSimple
323	 *
324	 * @param <string> $value
325	 * @param <array> $selection
326	 * @param <string> $assignment
327	 *
328	 * @return <bool>
329	 */
330	function passSimple($values = '', $selection = array(), $assignment = 'all', $caseinsensitive = 0)
331	{
332		$values = $this->makeArray($values, 1);
333		$selection = $this->makeArray($selection);
334
335		$pass = 0;
336		foreach ($values as $value) {
337			if ($caseinsensitive) {
338				if (in_array(strtolower($value), array_map('strtolower', $selection))) {
339					$pass = 1;
340					break;
341				}
342			} else {
343				if (in_array($value, $selection)) {
344					$pass = 1;
345					break;
346				}
347			}
348		}
349
350		if ($pass) {
351			return ($assignment == 'include');
352		} else {
353			return ($assignment == 'exclude');
354		}
355	}
356
357	/**
358	 * getAssignmentState
359	 *
360	 * @param <string> $assignment
361	 */
362	function getAssignmentState(&$assignment)
363	{
364		switch ($assignment) {
365			case 1:
366			case 'include':
367				$assignment = 'include';
368				break;
369			case 2:
370			case 'exclude':
371				$assignment = 'exclude';
372				break;
373			case 3:
374			case -1:
375			case 'none':
376				$assignment = 'none';
377				break;
378			default:
379				$assignment = 'all';
380				break;
381		}
382	}
383
384	function getMenuItemParams($id = 0)
385	{
386		$query = $this->_db->getQuery(true);
387		$query->select('m.params');
388		$query->from('#__menu AS m');
389		$query->where('m.id = '.(int) $id);
390		$this->_db->setQuery($query);
391		$params = $this->_db->loadResult();
392
393		$parameters = NNParameters::getInstance();
394		return $parameters->getParams($params);
395	}
396
397	function getParentIds($id = 0, $table = 'menu', $parent = 'parent_id', $child = 'id')
398	{
399		$parent_ids = array();
400
401		if (!$id) {
402			return $parent_ids;
403		}
404
405		while ($id) {
406			$query = $this->_db->getQuery(true);
407			$query->select($this->_db->qn($parent));
408			$query->from('#__'.$table);
409			$query->where($this->_db->qn($child).' = '.(int) $id);
410			$this->_db->setQuery($query);
411			$id = $this->_db->loadResult();
412			if ($id) {
413				$parent_ids[] = $id;
414			}
415		}
416		return $parent_ids;
417	}
418
419	/**
420	 * makeArray
421	 *
422	 * @param <array> $array
423	 * @param <boolean> $onlycommas
424	 */
425	function makeArray($array = '', $onlycommas = 0, $trim = 1)
426	{
427		if (!is_array($array)) {
428			if (!$onlycommas && !(strpos($array, '|') === false)) {
429				$array = explode('|', $array);
430			} else {
431				$array = explode(',', $array);
432			}
433		}
434		if ($trim) {
435			if ($trim && !empty($array)) {
436				foreach ($array as $key => $val) {
437					$array[$key] = trim($val);
438				}
439			}
440		}
441		return $array;
442	}
443
444	function passMenuItem(&$params, $selection = array(), $assignment = 'all')
445	{
446		if (!isset($this->_classes['Menu']) && JFile::exists(__DIR__.'/assignments/menu.php')) {
447			require_once __DIR__.'/assignments/menu.php';
448			$this->_classes[$this->maintype] = new NNFrameworkAssignmentsMenu;
449		}
450		if (isset($this->_classes['Menu'])) {
451			return $this->_classes['Menu']->passMenuItem($this, $params, $selection, $assignment);
452		}
453		return 1;
454	}
455
456
457	function getAssignmentsFromParams(&$params, $use_sef = 2)
458	{
459		jimport('joomla.filesystem.file');
460
461		$assignments = array();
462		if (isset($params->assignto_menuitems) && $params->assignto_menuitems) {
463			$assignments['MenuItem'] = new stdClass();
464			$assignments['MenuItem']->assignment = $params->assignto_menuitems;
465			$assignments['MenuItem']->selection = $params->assignto_menuitems_selection;
466			$assignments['MenuItem']->params = new stdClass();
467			$assignments['MenuItem']->params->inc_children = $params->assignto_menuitems_inc_children;
468			$assignments['MenuItem']->params->inc_noItemid = $params->assignto_menuitems_inc_noitemid;
469		}
470		if (isset($params->assignto_homepage) && $params->assignto_homepage) {
471			$assignments['HomePage'] = new stdClass();
472			$assignments['HomePage']->assignment = $params->assignto_homepage;
473		}
474		if (isset($params->assignto_cats) && $params->assignto_cats) {
475			$assignments['Cats'] = new stdClass();
476			$assignments['Cats']->assignment = $params->assignto_cats;
477			$assignments['Cats']->selection = $params->assignto_cats_selection;
478			$assignments['Cats']->params = new stdClass();
479			$incs = $this->makeArray($params->assignto_cats_inc);
480			$assignments['Cats']->params->inc_categories = in_array('inc_cats', $incs);
481			$assignments['Cats']->params->inc_articles = in_array('inc_arts', $incs);
482			$assignments['Cats']->params->inc_others = in_array('inc_others', $incs);
483			$assignments['Cats']->params->inc_children = $params->assignto_cats_inc_children;
484		}
485		if (isset($params->assignto_articles) && $params->assignto_articles) {
486			$assignments['Articles'] = new stdClass();
487			$assignments['Articles']->assignment = $params->assignto_articles;
488			$assignments['Articles']->selection = $params->assignto_articles_selection;
489			$assignments['Articles']->params = new stdClass();
490			$assignments['Articles']->params->keywords = $params->assignto_articles_keywords;
491		}
492		if (JFile::exists( JPATH_ADMINISTRATOR.'/components/com_flexicontent/admin.flexicontent.php' )) {
493			if (isset($params->assignto_fccats) && $params->assignto_fccats) {
494				$assignments['Categories_FC'] = new stdClass();
495				$assignments['Categories_FC']->assignment = $params->assignto_fccats;
496				$assignments['Categories_FC']->selection = $params->assignto_fccats_selection;
497				$assignments['Categories_FC']->params = new stdClass();
498				$assignments['Categories_FC']->params->inc_children = $params->assignto_fccats_inc_children;
499				$incs = $this->makeArray( $params->assignto_fccats_inc );
500				$assignments['Categories_FC']->params->inc_categories = in_array( 'inc_cats', $incs );
501				$assignments['Categories_FC']->params->inc_items = in_array( 'inc_items', $incs );
502			}
503			if (isset($params->assignto_fctags) && $params->assignto_fctags) {
504				$assignments['Tags_FC'] = new stdClass();
505				$assignments['Tags_FC']->assignment = $params->assignto_fctags;
506				$assignments['Tags_FC']->selection = $params->assignto_fctags_selection;
507				$assignments['Tags_FC']->params = new stdClass();
508				$incs = $this->makeArray( $params->assignto_fctags_inc );
509				$assignments['Tags_FC']->params->inc_tags = in_array( 'inc_tags', $incs );
510				$assignments['Tags_FC']->params->inc_items = in_array( 'inc_items', $incs );
511			}
512			if (isset($params->assignto_fctypes) && $params->assignto_fctypes) {
513				$assignments['Types_FC'] = new stdClass();
514				$assignments['Types_FC']->assignment = $params->assignto_fctypes;
515				$assignments['Types_FC']->selection = $params->assignto_fctypes_selection;
516				$assignments['Types_FC']->params = new stdClass();
517			}
518			if (isset($params->assignto_fcitems) && $params->assignto_fcitems) {
519				$assignments['Items_FC'] = new stdClass();
520				$assignments['Items_FC']->assignment = $params->assignto_fcitems;
521				$assignments['Items_FC']->selection = $params->assignto_fcitems_selection;
522			}
523		}
524		if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_k2/admin.k2.php')) {
525			if (isset($params->assignto_k2cats) && $params->assignto_k2cats) {
526				$assignments['Categories_K2'] = new stdClass();
527				$assignments['Categories_K2']->assignment = $params->assignto_k2cats;
528				$assignments['Categories_K2']->selection = $params->assignto_k2cats_selection;
529				$assignments['Categories_K2']->params = new stdClass();
530				$assignments['Categories_K2']->params->inc_children = $params->assignto_k2cats_inc_children;
531				$incs = $this->makeArray($params->assignto_k2cats_inc);
532				$assignments['Categories_K2']->params->inc_categories = in_array('inc_cats', $incs);
533				$assignments['Categories_K2']->params->inc_items = in_array('inc_items', $incs);
534			}
535			if (isset($params->assignto_k2tags) && $params->assignto_k2tags) {
536				$assignments['Tags_K2'] = new stdClass();
537				$assignments['Tags_K2']->assignment = $params->assignto_k2tags;
538				$assignments['Tags_K2']->selection = $params->assignto_k2tags_selection;
539				$assignments['Tags_K2']->params = new stdClass();
540				$incs = $this->makeArray($params->assignto_k2tags_inc);
541				$assignments['Tags_K2']->params->inc_tags = in_array('inc_tags', $incs);
542				$assignments['Tags_K2']->params->inc_items = in_array('inc_items', $incs);
543			}
544			if (isset($params->assignto_k2items) && $params->assignto_k2items) {
545				$assignments['Items_K2'] = new stdClass();
546				$assignments['Items_K2']->assignment = $params->assignto_k2items;
547				$assignments['Items_K2']->selection = $params->assignto_k2items_selection;
548			}
549		}
550		if (JFile::exists( JPATH_ADMINISTRATOR.'/components/com_resource/resource.php' )) {
551			if (isset($params->assignto_mrcats) && $params->assignto_mrcats) {
552				$assignments['Categories_MR'] = new stdClass();
553				$assignments['Categories_MR']->assignment = $params->assignto_mrcats;
554				$assignments['Categories_MR']->selection = $params->assignto_mrcats_selection;
555				$assignments['Categories_MR']->params = new stdClass();
556				$assignments['Categories_MR']->params->inc_children = $params->assignto_mrcats_inc_children;
557				$incs = $this->makeArray( $params->assignto_mrcats_inc );
558				$assignments['Categories_MR']->params->inc_categories = in_array( 'inc_cats', $incs );
559				$assignments['Categories_MR']->params->inc_items = in_array( 'inc_items', $incs );
560			}
561		}
562		if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_zoo/zoo.php')) {
563			if (isset($params->assignto_zoocats) && $params->assignto_zoocats) {
564				$assignments['Categories_ZOO'] = new stdClass();
565				$assignments['Categories_ZOO']->assignment = $params->assignto_zoocats;
566				$assignments['Categories_ZOO']->selection = $params->assignto_zoocats_selection;
567				$assignments['Categories_ZOO']->params = new stdClass();
568				$assignments['Categories_ZOO']->params->inc_children = $params->assignto_zoocats_inc_children;
569				$incs = $this->makeArray($params->assignto_zoocats_inc);
570				$assignments['Categories_ZOO']->params->inc_apps = in_array('inc_apps', $incs);
571				$assignments['Categories_ZOO']->params->inc_categories = in_array('inc_cats', $incs);
572				$assignments['Categories_ZOO']->params->inc_items = in_array('inc_items', $incs);
573			}
574		}
575		if (isset($params->assignto_components) && $params->assignto_components) {
576			$assignments['Components'] = new stdClass();
577			$assignments['Components']->assignment = $params->assignto_components;
578			$assignments['Components']->selection = $params->assignto_components_selection;
579		}
580		if (isset($params->assignto_urls) && $params->assignto_urls) {
581			$assignments['URL'] = new stdClass();
582			$assignments['URL']->assignment = $params->assignto_urls;
583
584			if ($use_sef == 2) {
585				$config = JFactory::getConfig();
586				$use_sef = ($config->getValue('config.sef') == 1);
587			}
588			$assignments['URL']->selection = $use_sef ? $params->assignto_urls_selection_sef : $params->assignto_urls_selection;
589			$assignments['URL']->selection = str_replace("\r", '', $assignments['URL']->selection);
590			$assignments['URL']->selection = explode("\n", $assignments['URL']->selection);
591		}
592		if (isset($params->assignto_os) && $params->assignto_os) {
593			$assignments['OS'] = new stdClass();
594			$assignments['OS']->assignment = $params->assignto_os;
595			$selection = array();
596			if (!empty($params->assignto_os_selection)) {
597				$selection = array_merge($selection, $params->assignto_os_selection);
598			}
599			if (isset($params->assignto_searchbots_selection) && !empty($params->assignto_searchbots_selection)) {
600				$selection = array_merge($selection, $params->assignto_searchbots_selection);
601			}
602			$assignments['OS']->selection = $selection;
603		}
604		if (isset($params->assignto_browsers) && $params->assignto_browsers) {
605			$assignments['Browsers'] = new stdClass();
606			$assignments['Browsers']->assignment = $params->assignto_browsers;
607			$selection = array();
608			if (!empty($params->assignto_browsers_selection)) {
609				$selection = array_merge($selection, $params->assignto_browsers_selection);
610			}
611			if (isset($params->assignto_mobile_selection) && !empty($params->assignto_mobile_selection)) {
612				$selection = array_merge($selection, $params->assignto_mobile_selection);
613			}
614			$assignments['Browsers']->selection = $selection;
615		}
616		if (isset($params->assignto_date) && $params->assignto_date) {
617			$assignments['Date'] = new stdClass();
618			$assignments['Date']->assignment = $params->assignto_date;
619			$assignments['Date']->params = new stdClass();
620			$assignments['Date']->params->publish_up = $params->assignto_date_publish_up;
621			$assignments['Date']->params->publish_down = $params->assignto_date_publish_down;
622		}
623		if (isset($params->assignto_seasons) && $params->assignto_seasons) {
624			$assignments['Seasons'] = new stdClass();
625			$assignments['Seasons']->assignment = $params->assignto_seasons;
626			$assignments['Seasons']->selection = $params->assignto_seasons_selection;
627			$assignments['Seasons']->params = new stdClass();
628			$assignments['Seasons']->params->hemisphere = $params->assignto_seasons_hemisphere;
629		}
630		if (isset($params->assignto_months) && $params->assignto_months) {
631			$assignments['Months'] = new stdClass();
632			$assignments['Months']->assignment = $params->assignto_months;
633			$assignments['Months']->selection = $params->assignto_months_selection;
634		}
635		if (isset($params->assignto_days) && $params->assignto_days) {
636			$assignments['Days'] = new stdClass();
637			$assignments['Days']->assignment = $params->assignto_days;
638			$assignments['Days']->selection = $params->assignto_days_selection;
639		}
640		if (isset($params->assignto_time) && $params->assignto_time) {
641			$assignments['Time'] = new stdClass();
642			$assignments['Time']->assignment = $params->assignto_time;
643			$assignments['Time']->params = new stdClass();
644			$assignments['Time']->params->publish_up = $params->assignto_time_publish_up;
645			$assignments['Time']->params->publish_down = $params->assignto_time_publish_down;
646		}
647		if (isset($params->assignto_usergrouplevels) && $params->assignto_usergrouplevels) {
648			$assignments['UserGroupLevels'] = new stdClass();
649			$assignments['UserGroupLevels']->assignment = $params->assignto_usergrouplevels;
650			$assignments['UserGroupLevels']->selection = $params->assignto_usergrouplevels_selection;
651		}
652		if (isset($params->assignto_users) && $params->assignto_users) {
653			$assignments['Users'] = new stdClass();
654			$assignments['Users']->assignment = $params->assignto_users;
655			$assignments['Users']->selection = $params->assignto_users_selection;
656		}
657		if (isset($params->assignto_languages) && $params->assignto_languages) {
658			$assignments['Languages'] = new stdClass();
659			$assignments['Languages']->assignment = $params->assignto_languages;
660			$assignments['Languages']->selection = $params->assignto_languages_selection;
661		}
662		if (isset($params->assignto_templates) && $params->assignto_templates) {
663			$assignments['Templates'] = new stdClass();
664			$assignments['Templates']->assignment = $params->assignto_templates;
665			$assignments['Templates']->selection = $params->assignto_templates_selection;
666		}
667		if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_virtuemart/admin.virtuemart.php')) {
668			if (isset($params->assignto_virtuemartcats) && $params->assignto_virtuemartcats) {
669				$assignments['Categories_VirtueMart'] = new stdClass();
670				$assignments['Categories_VirtueMart']->assignment = $params->assignto_virtuemartcats;
671				$assignments['Categories_VirtueMart']->selection = $params->assignto_virtuemartcats_selection;
672				$assignments['Categories_VirtueMart']->params = new stdClass();
673				$assignments['Categories_VirtueMart']->params->inc_children = $params->assignto_virtuemartcats_inc_children;
674				$incs = $this->makeArray($params->assignto_virtuemartcats_inc);
675				$assignments['Categories_VirtueMart']->params->inc_categories = in_array('inc_cats', $incs);
676				$assignments['Categories_VirtueMart']->params->inc_items = in_array('inc_items', $incs);
677			}
678			if (isset($params->assignto_virtuemartitems) && $params->assignto_virtuemartitems) {
679				$assignments['Items_VirtueMart'] = new stdClass();
680				$assignments['Items_VirtueMart']->assignment = $params->assignto_virtuemartitems;
681				$assignments['Items_VirtueMart']->selection = $params->assignto_virtuemartitems_selection;
682			}
683		}
684		if (isset($params->assignto_php) && $params->assignto_php) {
685			$assignments['PHP'] = new stdClass();
686			$assignments['PHP']->assignment = $params->assignto_php;
687			$assignments['PHP']->selection = $params->assignto_php_selection;
688		}
689
690		return $assignments;
691	}
692
693}