You are here

function rules_admin_rule_proxy::get_element_parent_id in Rules 6

Gets the id of the parent element

File

rules_admin/rules_admin.rule_proxy.inc, line 73
Contains the rules proxy class

Class

rules_admin_rule_proxy
This is a smally proxy for the real rule. It provides some useful operations for the admin UI. It builds a small index for the elements of a rule, so that they can be easily identified and modified.

Code

function get_element_parent_id($id) {
  $element = $this
    ->get_element($id);
  while ($id > 0) {
    $id--;

    //get the element and look if it's the parent
    $parent = $this
      ->get_element($id);
    foreach (element_children($parent) as $key) {
      if ($parent[$key] == $element) {

        //parent found!
        return $id;
      }
    }
  }
  return FALSE;
}