Import new column "HLinks" in careers csv import see BT#12861

pull/2487/head
Julio 7 years ago
parent d7dc7f2bee
commit 507917e7ac
  1. 40
      main/admin/career_diagram.php
  2. 2
      main/admin/careers.php
  3. 39
      main/cron/import_csv.php
  4. 2
      main/inc/lib/career.lib.php

@ -55,7 +55,7 @@ $interbreadcrumb[] = array(
'name' => get_lang('Careers'),
);
$action = isset($_GET['action']) ? $_GET['action'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$check = Security::check_token('request');
$token = Security::get_token();
@ -79,19 +79,39 @@ $item = $extraFieldValue->get_values_by_handler_and_field_variable(
false
);
// Check urls
$itemUrls = $extraFieldValue->get_values_by_handler_and_field_variable(
$careerId,
'career_urls',
false,
false,
false
);
$urlToString = '';
if (!empty($itemUrls) && !empty($itemUrls['value'])) {
$urls = explode(',', $itemUrls['value']);
$urlToString = '  ';
if (!empty($urls)) {
foreach ($urls as $urlData) {
$urlData = explode('@', $urlData);
$urlToString .= Display::url($urlData[0], $urlData[1]).' ';
}
}
}
$tpl = new Template(get_lang('Diagram'));
if (!empty($item) && isset($item['value']) && !empty($item['value'])) {
$html = Display::page_subheader2($careerInfo['name'].$urlToString);
$graph = unserialize($item['value']);
$tpl = new Template(get_lang('Diagram'));
$html = Display::page_subheader2($careerInfo['name']);
$html .= Career::renderDiagram($careerInfo, $graph);
$tpl->assign('content', $html);
$tpl->display_one_col_template();
} else {
api_not_allowed(
true,
Display::addFlash(
Display::return_message(
sprintf(get_lang('CareerXDoesntHaveADiagram'), $careerInfo['name']),
'warning'
)
);
sprintf(get_lang('CareerXDoesntHaveADiagram'), $careerInfo['name']),
'warning'
));
}
$tpl->display_one_col_template();

@ -151,7 +151,7 @@ switch ($action) {
break;
case 'edit':
// Action handling: Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$form = $career->return_form($url, 'edit');
// The validation or display

@ -42,6 +42,7 @@ class ImportCsv
'user' => 'external_user_id',
'calendar_event' => 'external_calendar_event_id',
'career' => 'external_career_id',
'career_urls' => 'career_urls',
'career_diagram' => 'career_diagram',
);
public $defaultAdminId = 1;
@ -337,6 +338,15 @@ class ImportCsv
'display_text' => 'Career diagram',
)
);
$extraField->save(
array(
'visible_to_self' => 1,
'field_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'variable' => $this->extraFieldIdNameList['career_urls'],
'display_text' => 'Career urls',
)
);
}
/**
@ -2347,6 +2357,20 @@ class ImportCsv
'extra_'.$extraFieldName => $itemId,
];
$extraFieldValue->saveFieldValues($params);
$links = isset($row['HLinks']) ? $row['HLinks'] : [];
if (!empty($links)) {
$extraFieldUrlName = $this->extraFieldIdNameList['career_urls'];
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
$extraFieldUrlName
);
$params = [
'item_id' => $careerId,
'extra_'.$extraFieldUrlName => $itemId,
];
$extraFieldValue->saveFieldValues($params);
}
}
} else {
if (isset($item['item_id'])) {
@ -2355,6 +2379,20 @@ class ImportCsv
'name' => $row['CareerName']
];
$career->update($params);
$links = isset($row['HLinks']) ? $row['HLinks'] : [];
if (!empty($links)) {
$extraFieldUrlName = $this->extraFieldIdNameList['career_urls'];
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
$extraFieldUrlName
);
$params = [
'item_id' => $item['item_id'],
'extra_'.$extraFieldUrlName => $links
];
$extraFieldValue->saveFieldValues($params);
}
}
}
}
@ -2510,7 +2548,6 @@ class ImportCsv
$parentList = explode(',', $row['DependedOn']);
foreach ($parentList as $parentId) {
$parentId = (int) $parentId;
echo $parentId.PHP_EOL;
if ($graph->hasVertex($parentId)) {
/** @var Vertex $parent */
$parent = $graph->getVertex($parentId);

@ -151,6 +151,7 @@ class Career extends Model
if (!empty($defaults['updated_at'])) {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}
$form->setDefaults($defaults);
// Setting the rules
@ -308,7 +309,6 @@ class Career extends Model
/** @var Vertex $vertex */
foreach ($graph->getVertices() as $vertex) {
$group = $vertex->getAttribute('Group');
$groupData = explode(':', $group);
$group = $groupData[0];
$groupLabel = isset($groupData[1]) ? $groupData[1] : '';

Loading…
Cancel
Save