Ejemplo n.º 1
0
 public function processSaveCmsInfo()
 {
     if ($id_info = Tools::getValue('id_info')) {
         $info = new InfoBlock((int) $id_info);
     } else {
         $info = new InfoBlock();
         if (Shop::isFeatureActive()) {
             $shop_ids = Tools::getValue('checkBoxShopAsso_configuration');
             if (!$shop_ids) {
                 $this->html .= '<div class="alert alert-danger conf error">' . $this->l('You have to select at least one shop.') . '</div>';
                 return false;
             }
         } else {
             $info->id_shop = Shop::getContextShopID();
         }
     }
     $languages = Language::getLanguages(false);
     $text = array();
     foreach ($languages as $lang) {
         $text[$lang['id_lang']] = Tools::getValue('text_' . $lang['id_lang']);
     }
     $info->text = $text;
     if (Shop::isFeatureActive() && !$info->id_shop) {
         $saved = true;
         foreach ($shop_ids as $id_shop) {
             $info->id_shop = $id_shop;
             $saved &= $info->add();
         }
     } else {
         $saved = $info->save();
     }
     if ($saved) {
         $this->_clearCache('blockcmsinfo.tpl');
     } else {
         $this->html .= '<div class="alert alert-danger conf error">' . $this->l('An error occurred while attempting to save.') . '</div>';
     }
     return $saved;
 }