how can i add privilege checkbox of custom addon for vendor in cs cart ? - cs-cart

By default addons access will restricted to vendor. If i'll give the privilege to particular vendor he will able to access that addons.
thanks in advance

/You need auth area firts/
$condition = '';
if (AREA != 'A') {
$auth = $_SESSION['auth'];
$condition = ' AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'usergroup_ids', true) . ") AND status = 'A'";
}
return....
You can see example in APP/addons/attachments

Related

How to disable TFA (Two factor authentication)

I enabled TFA in Joomla 3.2 and it worked fine, but my smartphone is unaccessible.
Then I cannot go in backend and I tried to disable the plugin plg_twofactorauth_totp in database but it stay enabled.
Disabling by rename the folder hide Secret Key input, but I wasn't able to login.
Go to your MySQL database for joomla, go to the users table. Clear the value of otpKey. you should be able to login without a key now.
https://gist.github.com/medigeek/28a047be0d0d527a95769130a6faf559
This code will disable two-factor auth plugins and clear keys for Joomla! Super Users.
This script disables Joomla!'s two factor authentication plugin and clears the otpKey and otep values for Super Users. It allows you to login when you aren't able to use Google authenticator for any reason.
Usage:
Place it in the Joomla! 3.x root dir (where configuration.php and index.php are) and run it. Then login and leave the security key field empty.
Warning: Use with caution. Backup before use!
Snapshot of the code
<?php
/* This script disables Joomla!'s two factor authentication
* plugin and clears the otpKey and otep values for Super
* Users. It allows you to login when you aren't able to
* use Google authenticator for any reason.
* Usage:
* Place it in the Joomla! 3.x root dir (where configuration.php
* and index.php are) and run it. Then login and leave the
* security key field empty.
* Warning: Use with caution. Backup before use.
*/
define('_JEXEC', 1);
define('JPATH_BASE', __DIR__);
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(JPATH_BASE . '/defines.php')) { require_once JPATH_BASE . '/defines.php'; }
if (!defined('_JDEFINES')) { require_once JPATH_BASE . '/includes/defines.php'; }
require_once JPATH_LIBRARIES . '/import.legacy.php'; // Get the framework.
require_once JPATH_LIBRARIES . '/cms.php'; // Bootstrap the CMS libraries.
class Reset2FA extends JApplicationCli
{
public function execute()
{
$this->out('Initialising');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query2 = $db->getQuery(true);
//get users by group: (array of integers)
$sadminids = JAccess::getUsersByGroup(8); // 8 = Super Users
$strsadminids = implode(',', $sadminids);
$this->out(sprintf('Super User IDs: %s', $strsadminids));
$this->out('Disabling twofactorauth plugin (totp and yubikey)');
// Fields to update.
$fields = array(sprintf('%s = 0', $db->quoteName('enabled')));
// Conditions for which records should be updated.
// plg_twofactorauth_totp
// plg_twofactorauth_yubikey
$conditions = array(sprintf('%s LIKE %s', $db->quoteName('name'), $db->quote('plg_twofactorauth_%')));
$query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
$this->out('Disabling/clearing otpKey and otep for all Super Users');
// UPDATE 2
$fields2 = array(
$db->quoteName('otpKey') . " = ''",
$db->quoteName('otep') . " = ''",
);
// Conditions for which records should be updated.
// otpKey
// otep
$conditions2 = array(
$db->quoteName('otpKey') . " != ''",
$db->quoteName('otep') . " != ''",
sprintf('%s IN (%s)', $db->quoteName('id'), $strsadminids)
);
$query2->update($db->quoteName('#__users'))->set($fields2)->where($conditions2);
$db->setQuery($query2);
$result2 = $db->execute();
$this->out('Done');
}
}
JApplicationCli::getInstance('Reset2FA')->execute();
?>

Magento Admin Create Order not showing Custom Options

I have simple products with custom options in my store. They work perfectly from the front end, but if I try to add an order from the admin section, The custom options do not show up.
I only have this problem if the type of custom option is a dropdown, multi select, radio buttons, or check boxes. If it is a text field, date or anything else, it works fine.
I am assumming i need to make some changes to something in the /www/app/design/adminhtml/default/default/template/sales/order/create area, but no clue what i should try.
Looking a bit further, I found this /www/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/grid.php
/**
* Get Custom Options of item
*
* #param Mage_Sales_Model_Quote_Item $item
* #return array
*/
public function getCustomOptions(Mage_Sales_Model_Quote_Item $item)
{
$optionStr = '';
$this->_moveToCustomerStorage = true;
if ($optionIds = $item->getOptionByCode('option_ids')) {
foreach (explode(',', $optionIds->getValue()) as $optionId) {
if ($option = $item->getProduct()->getOptionById($optionId)) {
$optionValue = $item->getOptionByCode('option_' . $option->getId())->getValue();
$optionStr .= $option->getTitle() . ':';
$quoteItemOption = $item->getOptionByCode('option_' . $option->getId());
$group = $option->groupFactory($option->getType())
->setOption($option)
->setQuoteItemOption($quoteItemOption);
$optionStr .= $group->getEditableOptionValue($quoteItemOption->getValue());
$optionStr .= "\n";
}
}
}
return $optionStr;
}
The best way to find the correct template path is to turn on admin template hints.
By default magento does not provide a way to accomplish from the admin, but you can easily accomplish this using one of these methods Enable template path hint in admin pages - Magento

store wise email not working magento 1.5

I have 5 different store in my website. My default store is English,
1) when someone registered from english store he get currect email in English language
2) when someone registered from german store he also get email in English language instead of german language.
Any idea for solving this issues.
Thanks,
Hardik
Finally i got the solution for new customer registration emails.
Mage/Customer/Model/Customer.php
in this file i have make some changes as following.
find this line of code
if (!$storeId)
{
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
and replace with
$storeId = ($storeId == '0')?$this->getSendemailStoreId():$storeId;
if ($this->getWebsiteId() != '0' && $storeId == '0')
{
$storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
reset($storeIds);
$storeId = current($storeIds);
}
Thanks,

Joomla 2.5 module permissions

I simply want to make a module visible dependent on whether a user belongs to a custom set of groups - including NOT visible if (s)he belongs to a particular group(s). For example, adverts show for public and registered but not a custom "premium" group. A shoutbox should appear for registered and premium but not "not logged in". Thus, the "guest" and "special" groups are pretty useless as far as I can tell. Am I missing something really simple?
If I have to use a 3rd party component/module to achieve this then a free or cheap one would be most beneficial.
Thanks.
One way to achieve this is to edit and create new access levels. To cover up the examples you gave in the question, the following could work:
You need to get the guests out of the root parent group called Public. You can do this by the following three steps:
Using the User Manager, create a new group called "Guest" with Public as parent.
Open up the User Manager Options.
Change Guest User Group to your new group Guest.
The guests on your site will from now on be put into the Guest group. Now you could create a access level for the advert. So create a new access level, name it something like "Non premium users" and add Guest and Registered. Now apply this access level to the module and it should work. Note that the premium group cannot have Registered as a parent.
Next is the access level for the shoutbox. I see two options for this access level. One of them is to create a new access level and add Registered and Premium to it. A simpler approach though is to add the Premium group to the already existing access level called Registered.
Helpful ACL Links:
Allowing Guest-Only Access to Menu Items and Modules
Joomla ACL: Access Levels
None of the ACL levels work 100% of the time for me, I had to hack the template I was using and add in some code...
<?php
// make sure user is an accepted user group
jimport( 'joomla.user.helper' );
$user =& JFactory::getUser();
$userId = $user->get( 'id' );
$groups = JUserHelper::getUserGroups($userId);
// print_r($groups);
/*
3 Author
4 Editor
5 Publisher
6 Manager
7 Administrator
8 Super Users
*/
$menu = '' ;
if (in_array("3", $groups)) {
// echo "<!-- Author Group Found! -->";
// echo '<!-- USER ID: ' . $userId . ' -->';
$menu .= "
<a href='http://yourdomain.com/authors-area'>Authors Area</a>
" ;
} elseif(in_array("4", $groups)) {
$menu .= "
<a href='http://yourdomain.com/editors-area'>Editors Area</a>
" ;
} elseif(in_array("5", $groups)) {
$menu .= "
<a href='http://yourdomain.com/publishers-area'>Publishers Area</a>
" ;
} elseif(in_array("6", $groups)) {
$menu .= "
<a href='http://yourdomain.com/managers-area'>Managers Area</a>
" ;
} elseif(in_array("7", $groups)) {
$menu .= "
<a href='http://yourdomain.com/administrators-area'>Administrators Area</a>
" ;
} elseif(in_array("8", $groups)) {
$menu .= "
<a href='http://yourdomain.com/superusers-area'>Super Users Area</a>
" ;
} else {
$null = '' ; ;
}
?>

Check if Admin is Logged in Within Observer

I'm attempting to check if the administrator is logged in from an observer. The problem is that while this is easy to do when viewing the admin module, viewing the frontend is another story.
There are several similar questions, but unfortunately none of them provide a working solution for Magento 1.6.2.
I wasn't able to successfully get isLoggedIn() to return true in the admin/session class. I also found out that there is a cookie for both frontend and adminhtml, which may help.
The accepted answer in this related question seems to suggest this may not be possible:
Magento - Checking if an Admin and a Customer are logged in
Another related question, with a solution that didn't help my specific case:
Magento : How to check if admin is logged in within a module controller?
It is possible. What you need to do is switch the session data. You can do this with the following code:
$switchSessionName = 'adminhtml';
if (!empty($_COOKIE[$switchSessionName])) {
$currentSessionId = Mage::getSingleton('core/session')->getSessionId();
$currentSessionName = Mage::getSingleton('core/session')->getSessionName();
if ($currentSessionId && $currentSessionName && isset($_COOKIE[$currentSessionName])) {
$switchSessionId = $_COOKIE[$switchSessionName];
$this->_switchSession($switchSessionName, $switchSessionId);
$whateverData = Mage::getModel('mymodule/session')->getWhateverData();
$this->_switchSession($currentSessionName, $currentSessionId);
}
}
protected function _switchSession($namespace, $id = null) {
session_write_close();
$GLOBALS['_SESSION'] = null;
$session = Mage::getSingleton('core/session');
if ($id) {
$session->setSessionId($id);
}
$session->start($namespace);
}
Late Answer but if as I found it on google:
This it not possible.
Why? Because the default session name in the frontend is frontend and the session name in the backend is admin. Because of this, the session data of the admin is not available in the frontend.
have you tried this :
Mage::getSingleton('admin/session', array('name' => 'adminhtml'))->isLoggedIn();
how about this ( I am not sure it will work or not )
require_once 'app/Mage.php';
umask(0);
$apps = Mage::app('default');
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
$adminSession = Mage::getSingleton('admin/session');
$adminSession->start();
if ($adminSession->isLoggedIn()) {
// check admin
}

Resources