Exemplo n.º 1
0
 public static function storeConfig()
 {
     $user = JFactory::getUser();
     if ($user->authorise('core.admin', 'com_virtuemart')) {
         $installed = VirtueMartModelConfig::checkVirtuemartInstalled();
         if ($installed) {
             VirtueMartModelConfig::installVMconfigTable();
             $confData = array();
             $confData['virtuemart_config_id'] = 1;
             $confData['config'] = VmConfig::$_jpConfig->toString();
             $confTable = VmTable::getInstance('configs', 'Table', array());
             if (!$confTable->bindChecknStore($confData)) {
                 vmError('storeConfig was not able to store config');
             }
         } else {
             self::$_virtuemart_vendor_id = 1;
         }
     }
 }
Exemplo n.º 2
0
    /**
     * Checks if user is admin or has vendorId=1,
     * if superadmin, but not a vendor it gives back vendorId=1 (single vendor, but multiuser administrated)
     *
     * @author Mattheo Vicini
     * @author Max Milbers
     */
    public static function isSuperVendor()
    {
        if (self::$_virtuemart_vendor_id === null) {
            $user = JFactory::getUser();
            if (!empty($user->id)) {
                $q = 'SELECT `virtuemart_vendor_id` FROM `#__virtuemart_vmusers` `au`
				WHERE `au`.`virtuemart_user_id`="' . $user->id . '" AND `au`.`user_is_vendor` = "1" ';
                $db = JFactory::getDbo();
                $db->setQuery($q);
                $virtuemart_vendor_id = $db->loadResult();
                if ($virtuemart_vendor_id) {
                    self::$_virtuemart_vendor_id = $virtuemart_vendor_id;
                } else {
                    if ($user->authorise('core.admin', 'com_virtuemart') or self::get('multix', 'none') == 'none' and $user->authorise('core.manage', 'com_virtuemart')) {
                        self::$_virtuemart_vendor_id = 1;
                    }
                }
            } else {
                self::$_virtuemart_vendor_id = 0;
                vmdebug('Not a vendor');
            }
        }
        //vmdebug('isSuperVendor',self::$_virtuemart_vendor_id);
        return self::$_virtuemart_vendor_id;
    }