public static function CreateLinkMenu($module = null) { $cm = utopia::GetCurrentModule(); if ($module === null) { $module = $cm; } if (isset(self::$done[$module])) { return; } self::$done[$module] = true; $cmAdmin = is_subclass_of($cm, 'iAdminModule'); $modules = utopia::GetChildren($module); $highestpos = 0; foreach ($modules as $mid => $children) { if ($cmAdmin && !is_subclass_of($mid, 'iAdminModule')) { continue; } if (!$cmAdmin && is_subclass_of($mid, 'iAdminModule')) { continue; } foreach ($children as $child) { if (isset($child['callback'])) { continue; } if (isset($child['fieldLinks']) && $mid !== $cm) { continue; } if (uEvents::TriggerEvent('CanAccessModule', $mid) === FALSE) { continue; } if ($module !== $cm && $child['parent'] === '/') { continue; } $parent = '_modlinks_'; if (isset($child['parent']) && $child['parent'] !== '/') { $parent .= $child['parent']; } $obj = utopia::GetInstance($mid); $position = $obj->GetSortOrder(); if (isset($child['fieldLinks']) && $mid === $cm) { $position = 0; } if ($position > $highestpos) { $highestpos = $position; } uMenu::AddItem($parent . $mid, $obj->GetTitle(), $obj->GetURL(), $parent, null, $position); } self::CreateLinkMenu($mid); } if ($module === $cm) { // add separators $i = -10001; while ($i < $highestpos) { uMenu::AddItem('_sep_' . $i, '', '', '_modlinks_', null, $i); $i = $i + 1000; } } }
public function GetTargetFilters($field, $row) { // ErrorLog("GTF($field,$row)"); if ($row == NULL) { return NULL; } $searchModule = is_array($row) && array_key_exists('__module__', $row) ? $row['__module__'] : get_class($this); $children = isset(self::$targetChildren[$searchModule]) ? self::$targetChildren[$searchModule] : utopia::GetChildren($searchModule); $info = NULL; // get specific field foreach ($children as $links) { foreach ($links as $link) { if (!isset($link['parentField'])) { continue; } if ($link['parentField'] == $field) { $info = $link; break; } } } // if not found, check for fallback if (!$info) { if ($field !== '*') { return $this->GetTargetFilters('*', $row); } return NULL; } //echo "<br/>$field:"; // fieldLinks: array: parentField => childField // need to replace the values $targetModule = $info['child']; $newFilter = array(); // $additional = array(); //print_r($info['fieldLinks']); foreach ($info['fieldLinks'] as $linkInfo) { $value = NULL; // fromfield == mortgage_id // module_pk == VAL:note_id if (!$this->FieldExists($linkInfo['fromField']) and $fltr =& $this->FindFilter($linkInfo['fromField'])) { // no field exists, but we do have a filter, we should move that over $value = $this->GetFilterValue($fltr['uid']); // if its a union AND the fromfield equals the modules primarykey then show the module_pk // NO, if its a union, loop thru that modules fields to find the number of the fromField. then get the value of the corresponding number in this union parent module } elseif (array_key_exists('__module__', $row)) { $obj = utopia::GetInstance($row['__module__']); $unionFields = $obj->fields; $uFieldCount = 0; $keys = array_keys($unionFields); foreach ($keys as $uFieldAlias) { if ($uFieldAlias == $linkInfo['fromField']) { break; } $uFieldCount++; } $ourKeys = array_keys($this->fields); $correspondingKey = $ourKeys[$uFieldCount]; $value = $row[$correspondingKey]; } else { $value = $row[$linkInfo['fromField']]; // use actual value, getting the real value on every field causes a lot of lookups, the requested field must be the field that stores the actual value } //echo $value."<br/>"; if ($value !== NULL) { $obj = utopia::GetInstance($targetModule); $fltr = $obj->FindFilter($linkInfo['toField']); if ($fltr) { $newFilter['_f_' . $fltr['uid']] = $value; } } } return $newFilter; //print_r(array_merge($newFilter,$additional)); return array_merge($newFilter, $additional); // now returns an array $extra = array(); if (is_array($additional)) { foreach ($additional as $key => $val) { $extra[] = "{$key}={$val}"; } } array_unshift($extra, FilterArrayToString($newFilter)); return join('&', $extra); }