Duplicate Transcribe languages variables
public function dublicate () {
$language_id_to_clone = ($this->EE->input->get_post("source_lang")) ? $this->EE->input->get_post("source_lang") : 1;
$site_id_to_clone = ($this->EE->input->get_post("source_site")) ? $this->EE->input->get_post("source_site") : 1;
$target_lang = ($this->EE->input->get_post("target_lang")) ? $this->EE->input->get_post("target_lang") : 4;
$target_site = ($this->EE->input->get_post("target_site")) ? $this->EE->input->get_post("target_site") : 5;
//english copy to english
//admin.php?S=1736f35e8929d2a29031274d6d2b0d87&D=cp&C=addons_modules&M=show_module_cp&module=transcribe&method=dublicate&source_lang=1&source_site=1&target_lang=1&target_site=5
//admin.php?S=1736f35e8929d2a29031274d6d2b0d87&D=cp&C=addons_modules&M=show_module_cp&module=transcribe&method=dublicate&source_lang=1&source_site=1&target_lang=1&target_site=4
//admin.php?S=1736f35e8929d2a29031274d6d2b0d87&D=cp&C=addons_modules&M=show_module_cp&module=transcribe&method=dublicate&source_lang=1&source_site=1&target_lang=1&target_site=3
//english copy to local languages
//admin.php?S=1736f35e8929d2a29031274d6d2b0d87&D=cp&C=addons_modules&M=show_module_cp&module=transcribe&method=dublicate&source_lang=1&source_site=1&target_lang=4&target_site=5
//admin.php?S=1736f35e8929d2a29031274d6d2b0d87&D=cp&C=addons_modules&M=show_module_cp&module=transcribe&method=dublicate&source_lang=1&source_site=1&target_lang=3&target_site=4
//admin.php?S=1736f35e8929d2a29031274d6d2b0d87&D=cp&C=addons_modules&M=show_module_cp&module=transcribe&method=dublicate&source_lang=1&source_site=1&target_lang=2&target_site=3
$exist_transcribe_variables = $this->EE->db->select('variable_id')
->where(array('language_id' => $target_lang , 'site_id' => $target_site))
->get('exp_transcribe_variables_languages')->result();
$exist_list = array();
foreach ($exist_transcribe_variables as $row)
{
$exist_list[] = $row->variable_id;
}
$clone_transcribe_variables = $this->EE->db->select('*')
->where(array('language_id' => $language_id_to_clone , 'site_id' => $site_id_to_clone))
->get('exp_transcribe_variables_languages')->result();
$translation_list = array ();
foreach ($clone_transcribe_variables as $row)
{
if (!in_array($row->variable_id, $exist_list)) {
$translation_list[] = $row->translation_id;
$translation_vl[$row->translation_id] = array (
'id' => null,
'variable_id' => $row->variable_id,
'translation_id' => $row->translation_id,
'language_id' => $target_lang,
'site_id' => $target_site
);
}
}
$all_varibles = $this->EE->db->where_in('id', $translation_list)->get('exp_transcribe_translations')->result();
foreach ($all_varibles as $row)
{
$data = array (
'id' => null,
'content' => ( ($language_id_to_clone != $target_lang) ? '* ' : '').$row->content,
'variable_id' => $row->variable_id
);
$this->EE->db->insert('exp_transcribe_translations', $data);
$translation_vl[$row->id]['translation_id'] = $this->EE->db->insert_id();
}
foreach ($translation_vl as $data)
{
$this->EE->db->insert('exp_transcribe_variables_languages', $data);
}
}