dolibarr  13.0.2
recruitment_recruitmentjobposition.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) ---Put here your own copyright and developer email---
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
31 {
32  global $db, $langs, $conf;
33 
34  $langs->load("recruitment");
35 
36  $h = 0;
37  $head = array();
38 
39  $head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_card.php", 1).'?id='.$object->id;
40  $head[$h][1] = $langs->trans("PositionToBeFilled");
41  $head[$h][2] = 'card';
42  $h++;
43 
44  if ($conf->global->MAIN_FEATURES_LEVEL >= 1) {
45  $head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_applications.php", 1).'?id='.$object->id;
46  $head[$h][1] = $langs->trans("Candidatures");
47  $head[$h][2] = 'candidatures';
48  $h++;
49  }
50 
51  if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
52  {
53  $nbNote = 0;
54  if (!empty($object->note_private)) $nbNote++;
55  if (!empty($object->note_public)) $nbNote++;
56  $head[$h][0] = dol_buildpath('/recruitment/recruitmentjobposition_note.php', 1).'?id='.$object->id;
57  $head[$h][1] = $langs->trans('Notes');
58  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
59  $head[$h][2] = 'note';
60  $h++;
61  }
62 
63  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
64  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
65  $upload_dir = $conf->recruitment->dir_output."/recruitmentjobposition/".dol_sanitizeFileName($object->ref);
66  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
67  $nbLinks = Link::count($db, $object->element, $object->id);
68  $head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_document.php", 1).'?id='.$object->id;
69  $head[$h][1] = $langs->trans('Documents');
70  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
71  $head[$h][2] = 'document';
72  $h++;
73 
74  $head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_agenda.php", 1).'?id='.$object->id;
75  $head[$h][1] = $langs->trans("Events");
76  $head[$h][2] = 'agenda';
77  $h++;
78 
79  // Show more tabs from modules
80  // Entries must be declared in modules descriptor with line
81  //$this->tabs = array(
82  // 'entity:+tabname:Title:@recruitment:/recruitment/mypage.php?id=__ID__'
83  //); // to add new tab
84  //$this->tabs = array(
85  // 'entity:-tabname:Title:@recruitment:/recruitment/mypage.php?id=__ID__'
86  //); // to remove a tab
87  complete_head_from_modules($conf, $langs, $object, $head, $h, 'recruitmentjobposition');
88 
89  complete_head_from_modules($conf, $langs, $object, $head, $h, 'recruitmentjobposition', 'remove');
90 
91  return $head;
92 }
93 
94 
103 function getPublicJobPositionUrl($mode, $ref = '', $localorexternal = 0)
104 {
105  global $conf, $dolibarr_main_url_root;
106 
107  $ref = str_replace(' ', '', $ref);
108  $out = '';
109 
110  // Define $urlwithroot
111  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
112  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
113  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
114 
115  $urltouse = DOL_MAIN_URL_ROOT;
116  if ($localorexternal) $urltouse = $urlwithroot;
117 
118  $out = $urltouse.'/public/recruitment/view.php?ref='.($mode ? '<font color="#666666">' : '').$ref.($mode ? '</font>' : '');
119  /*if (!empty($conf->global->RECRUITMENT_SECURITY_TOKEN))
120  {
121  if (empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) $out .= '&securekey='.$conf->global->RECRUITMENT_SECURITY_TOKEN;
122  else $out .= '&securekey='.dol_hash($conf->global->RECRUITMENT_SECURITY_TOKEN, 2);
123  }*/
124 
125  // For multicompany
126  if (!empty($out) && !empty($conf->multicompany->enabled)) $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
127 
128  return $out;
129 }
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
getPublicJobPositionUrl($mode, $ref= '', $localorexternal=0)
Return string with full Url.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).