Set Magento website template, skin and layout programmatically

$groups['theme']['fields']['template']['value'] = 'template_name';
$groups['theme']['fields']['skin']['value'] = 'skin_name';
$groups['theme']['fields']['layout']['value'] = 'layout_name';
$groups['theme']['fields']['default']['value'] = 'template_name';
Mage::getModel('adminhtml/config_data')  
      ->setSection('design')  
      ->setWebsite('your_website')  
      ->setGroups($groups)  
      ->save(); 

Alternate method:

$installer->setConfigData('design/theme/template', 'facebook', 'stores', $store->getId());
$installer->setConfigData('design/theme/skin', 'facebook', 'stores', $store->getId());
$installer->setConfigData('design/theme/layout', 'facebook', 'stores', $store->getId());
$installer->setConfigData('design/theme/default', 'facebook', 'stores', $store->getId());

Switch Yii layout based on user role

You can assign different layouts to different users using following filter class

1. Add LayoutFilter.php to your protected/components/ folder

class LayoutFilter extends CFilter
{
 
    protected function preFilter($filterChain)
    {
        // logic being applied before the action is executed
        $roles = Yii::app()->user->getState('roles');
        if (!is_array($roles))
            $roles = array();
 
        if (in_array(User::ROLE_ADMIN, $roles))
        {
            $filterChain->controller->layout = 'admin/column2';
        } else
        {
            $filterChain->controller->layout = '//layouts/column2';
        }
 
        return parent::preFilter($filterChain);
    }
 
    protected function postFilter($filterChain)
    {
    // logic being applied after the action is executed
        return parent::postFilter($filterChain);
    }
 
}

2. Update protected/components/Controller.php and add following filters

public function filters()
{
    return array(
        'rights',
        array('application.components.LayoutFilter'),
    );
}

3. Update all controllers and add following filters

public function filters()
{
    return parent::filters() + array(
        'postOnly + delete', // we only allow deletion via POST request
    );
}