Skip to content

Instantly share code, notes, and snippets.

@aelvan
Last active December 12, 2015 12:09
Show Gist options
  • Save aelvan/4770416 to your computer and use it in GitHub Desktop.
Save aelvan/4770416 to your computer and use it in GitHub Desktop.
public function entry_submission_end() {
// get all structure listing entries
$listings_result = $this->EE->db->get('structure_listings');
// get all structure page entries
$pages_result = $this->EE->db->get('structure');
// get all transcribed entries
$transcribed_result = $this->EE->db->get('transcribe_entries_languages');
$language_lookup = array();
foreach ($transcribed_result->result() as $row) {
$language_lookup[$row->entry_id] = $row->language_id;
}
// loop over listing entries and check if they are the same language as parent
foreach ($listings_result->result() as $row) {
if ($language_lookup[$row->entry_id]!=$language_lookup[$row->parent_id]) {
$channel_id = $row->channel_id;
// find out if there's another page that has this language and the same listing connected.
foreach ($pages_result->result() as $page_row) {
if ($page_row->listing_cid==$channel_id) {
if ($language_lookup[$page_row->entry_id] == $language_lookup[$row->entry_id]) {
$data = array(
'parent_id' => $page_row->entry_id
);
$this->EE->db->where('entry_id', $row->entry_id);
$this->EE->db->update('structure_listings', $data);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment