/**
  * Add category action
  */
 public function actionaddcategory()
 {
     // Perms
     if (!Yii::app()->user->checkAccess('op_extensions_addcats')) {
         throw new CHttpException(403, Yii::t('error', 'Sorry, You don\'t have the required permissions to enter this section'));
     }
     $model = new ExtensionsCats();
     if (isset($_POST['ExtensionsCats'])) {
         $model->attributes = $_POST['ExtensionsCats'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('extensions', 'Category Added.'));
             $this->redirect(array('index'));
         }
     }
     // Adding sub?
     if (Yii::app()->request->getParam('parentid')) {
         $model->parentid = Yii::app()->request->getParam('parentid');
     }
     $roles = AuthItem::model()->findAll(array('order' => 'type DESC, name ASC'));
     $_roles = array();
     if (count($roles)) {
         foreach ($roles as $role) {
             $_roles[AuthItem::model()->types[$role->type]][$role->name] = $role->name;
         }
     }
     // Parent list
     $parents = array();
     $parentlist = ExtensionsCats::model()->getRootCats();
     if (count($parentlist)) {
         foreach ($parentlist as $row) {
             $parents[$row->id] = $row->title;
         }
     }
     $this->breadcrumbs[Yii::t('extensions', 'Adding Category')] = '';
     $this->pageTitle[] = Yii::t('extensions', 'Adding Category');
     // Render
     $this->render('category_form', array('model' => $model, 'parents' => $parents, 'roles' => $_roles, 'label' => Yii::t('extensions', 'Adding Category')));
 }