protected function addBlock($formData, $pageID, $moduleID) { $zone = $formData['B_ZoneID']; $position = $formData['B_Position']; $title = $formData['BI_BlockTitle']; $showHeader = $formData['B_ShowHeader']; $secured = $formData['B_Secured']; // create new row in block table $block = new Blocks(); $row = $block->createRow(); $row->B_PageID = $pageID; $row->B_ModuleID = $moduleID; $row->B_Position = $position; $row->B_Secured = $secured; $row->B_ZoneID = $zone; $row->save(); // get the new block id $blockID = $row->B_ID; // create new row in blockindex table for each language of the website $Languages = Cible_FunctionsGeneral::getAllLanguage(); foreach ($Languages as $Lang) { $blockIndex = new BlocksIndex(); $rowBlockIndex = $blockIndex->createRow(); $rowBlockIndex->BI_BlockID = $blockID; $rowBlockIndex->BI_LanguageID = $Lang["L_ID"]; if ($Lang["L_ID"] == Zend_Registry::get("languageID")) { $rowBlockIndex->BI_BlockTitle = $title; } else { $rowBlockIndex->BI_BlockTitle = $title . "_" . $Lang["L_Suffix"]; } $rowBlockIndex->save(); } // update position of all block in the same page $db = Zend_Registry::get("db"); $where = "(B_Position >= " . $position . ") AND B_PageID = " . $pageID . " AND B_ID <> " . $blockID . " AND B_ZoneID = " . $zone; $db->update('Blocks', array('B_Position' => new Zend_Db_Expr('B_Position + 1')), $where); return $blockID; }