/** * Fill the array with all plugins found with this plugin for the current vendor * * @return True when plugins(s) was (were) found for this vendor, false otherwise * @author Oscar van Eijk * @author max Milbers * @author valerie Isaksen */ protected function getPluginMethods($vendorId) { if (!class_exists('tsmartModelUser')) { require VMPATH_ADMIN . DS . 'models' . DS . 'user.php'; } $usermodel = tmsModel::getModel('user'); $user = $usermodel->getUser(); $user->shopper_groups = (array) $user->shopper_groups; $db = JFactory::getDBO(); if (empty($vendorId)) { $vendorId = 1; } $select = 'SELECT i.*, '; $extPlgTable = '#__extensions'; $extField1 = 'extension_id'; $extField2 = 'element'; $select .= 'j.`' . $extField1 . '`,j.`name`, j.`type`, j.`element`, j.`folder`, j.`client_id`, j.`enabled`, j.`access`, j.`protected`, j.`manifest_cache`, j.`params`, j.`custom_data`, j.`system_data`, j.`checked_out`, j.`checked_out_time`, j.`state`, s.tsmart_shoppergroup_id '; if (!tsmConfig::$vmlang) { tsmConfig::setdbLanguageTag(); } $joins = array(); if (tsmConfig::$defaultLang != tsmConfig::$vmlang and tsmConfig::$langCount > 1) { $langFields = array($this->_psType . '_name', $this->_psType . '_desc'); $useJLback = false; if (tsmConfig::$defaultLang != tsmConfig::$jDefLang) { $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . '_' . tsmConfig::$jDefLang . '` as ljd'; $useJLback = true; } foreach ($langFields as $langField) { $expr2 = 'ld.' . $langField; if ($useJLback) { $expr2 = 'IFNULL(ld.' . $langField . ',ljd.' . $langField . ')'; } $select .= ', IFNULL(l.' . $langField . ',' . $expr2 . ') as ' . $langField . ''; } $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . 'methods_' . tsmConfig::$defaultLang . '` as ld using (`tsmart_' . $this->_psType . 'method_id`)'; $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . 'methods_' . tsmConfig::$vmlang . '` as l using (`tsmart_' . $this->_psType . 'method_id`)'; } else { $select .= ', l.* '; $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . 'methods_' . tsmConfig::$vmlang . '` as l using (`tsmart_' . $this->_psType . 'method_id`)'; } $q = $select . ' FROM `#__tsmart_' . $this->_psType . 'methods' . '` as i '; //$joins[] = ' JOIN `#__tsmart_' . $this->_psType . 'methods` AS i USING (`tsmart_' . $this->_psType . 'method_id`) '; $joins[] = ' LEFT JOIN `' . $extPlgTable . '` as j ON j.`' . $extField1 . '` = i.`' . $this->_psType . '_jplugin_id` '; $joins[] = ' LEFT OUTER JOIN `#__tsmart_' . $this->_psType . 'method_shoppergroups` AS s ON i.`tsmart_' . $this->_psType . 'method_id` = s.`tsmart_' . $this->_psType . 'method_id` '; $q .= implode(' ' . "\n", $joins); $q .= ' WHERE i.`published` = "1" AND j.`' . $extField2 . '` = "' . $this->_name . '" AND (i.`tsmart_vendor_id` = "' . $vendorId . '" OR i.`tsmart_vendor_id` = "0" OR i.`shared` = "1") AND ('; foreach ($user->shopper_groups as $groups) { $q .= ' s.`tsmart_shoppergroup_id`= "' . (int) $groups . '" OR'; } $q .= ' (s.`tsmart_shoppergroup_id`) IS NULL ) GROUP BY i.`tsmart_' . $this->_psType . 'method_id` ORDER BY i.`ordering`'; $db->setQuery($q); $this->methods = $db->loadObjectList(); if ($this->methods) { foreach ($this->methods as $method) { tsmTable::bindParameterable($method, $this->_xParams, $this->_varsToPushParam); } } else { if ($this->methods === false) { vmError('Error reading getPluginMethods ' . $q); } } return count($this->methods); }