function plugin_relation_giveItem($type, $ID, $data, $num) { global $DB; $searchopt =& Search::getOptions($type); if (isset($searchopt[$ID]["itemlink_type"])) { $form = Toolbox::getItemTypeFormURL($searchopt[$ID]["itemlink_type"]); } $separator = "<br/>"; $dataraw = $data['raw']; $split = explode("\$\$\$\$", $dataraw['ITEM_' . $num]); $count = 0; $string = ""; //print_r($split); for ($i = 0; $i < count($split); $i++) { if (strlen(trim($split[$i])) > 0) { $item = explode("\$\$", $split[$i]); if (isset($item[0]) && isset($item[1]) && $item[1] > 0) { if ($count) { $string .= $separator; } $count++; if (!class_exists($item[0])) { continue; } $objeto = new $item[0](); if ($objeto->getFromDB($item[1])) { $nombre_objeto = $objeto->getNameID(); //if ( $objeto->canView() ) { $form = Toolbox::getItemTypeFormURL($item[0]); $string .= "<a id='PluginRelationRelation' href='"; $string .= $form . "?id=" . $item[1] . "'>"; switch ($ID) { case 2250: $string .= $nombre_objeto . "</a>" . " Clase: " . $item[0] . " Tipo Relacion: " . PluginRelationRelation::getNombreTiporelacion($item[2], 1); break; case 2251: $string .= $nombre_objeto . "</a>" . " Clase: " . $item[0] . " Tipo Relacion: " . PluginRelationRelation::getNombreTiporelacion($item[2], 0); break; } //} } unset($objeto); } } } return $string; }
/** * Log event into the history * @param device_type the type of the item to inject * @param device_id the id of the inserted item * @param the action_type the type of action(add or update) */ public static function logChange($device_type, $device_id, $parent_id, $child, $parent, $action_type, $child_type, $relation_type) { $parentchanges[0] = 0; $parentchanges[1] = ""; $childchanges[0] = 0; $childchanges[1] = ""; if ($child) { $child = "(" . $child . ")"; } if ($parent) { $parent = "(" . $parent . ")"; } if ($action_type == RELATIONS_LINK) { $child_name = ""; $childClase = $child_type; $objAsociado = new $childClase(); $objAsociado->getFromDB($device_id); switch ($child_type) { case "User": $child_name = getUserName($device_id); break; default: $child_name = $objAsociado->fields['name']; break; } $parentchanges[2] = __('Enlazado con ', 'Enlazado con ') . ' ' . $child_type . ' ' . $child_name . ' ' . $child . ' ' . __('Tipo Relacion', 'Tipo Relacion') . ' (' . PluginRelationRelation::getNombreTiporelacion($relation_type, 0) . ')'; $parent_name = ""; $parentClase = $device_type; $objAsociado = new $parentClase(); $objAsociado->getFromDB($parent_id); switch ($device_type) { case "User": $parent_name = getUserName($parent_id); break; default: $parent_name = $objAsociado->fields['name']; break; } $childchanges[2] = __('Enlazado con ', 'Enlazado con ') . ' ' . $device_type . ' ' . $parent_name . ' ' . $parent . ' ' . __('Tipo Relacion', 'Tipo Relacion') . ' (' . PluginRelationRelation::getNombreTiporelacion($relation_type, 1) . ')'; } else { if ($action_type == RELATIONS_UNLINK) { $child_name = ""; $childClase = $child_type; $objAsociado = new $childClase(); $objAsociado->getFromDB($device_id); switch ($child_type) { case "User": $child_name = getUserName($device_id); break; default: $child_name = $objAsociado->fields['name']; break; } $parentchanges[2] = __('Desenlazado de ', 'Desenlazado de ') . ' ' . $child_type . ' ' . $child_name . ' ' . $child . ' ' . __('Tipo Relacion', 'Tipo Relacion') . ' (' . PluginRelationRelation::getNombreTiporelacion($relation_type, 0) . ')'; $parent_name = ""; $parentClase = $device_type; $objAsociado = new $parentClase(); $objAsociado->getFromDB($parent_id); switch ($device_type) { case "User": $parent_name = getUserName($parent_id); break; default: $parent_name = $objAsociado->fields['name']; break; } $childchanges[2] = __('Desenlazado de ', 'Desenlazado de ') . ' ' . $device_type . ' ' . $parent_name . ' ' . $parent . ' ' . __('Tipo Relacion', 'Tipo Relacion') . ' (' . PluginRelationRelation::getNombreTiporelacion($relation_type, 1) . ')'; } } //echo "<br>parentchanges2=".$parentchanges[2]; //echo "<br>childchanges2=".$childchanges[2]; //echo "<br>"; Log::history($parent_id, $device_type, $parentchanges, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE); Log::history($device_id, $child_type, $childchanges, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE); }