clean() static public method

Clean display value deleting html tags
static public clean ( $value, $striptags = true, $keep_bad = 2 ) : clean
$value string: string value
$striptags bool: strip all html tags
$keep_bad int: 1 : neutralize tag anb content, 2 : remove tag and neutralize content
return clean value
Exemplo n.º 1
0
 /**
  * @see CommonDBTM::getName()
  **/
 function getName($options = array())
 {
     if ($rule = getItemForItemtype(static::$itemtype)) {
         return Html::clean($rule->getMinimalCriteriaText($this->fields));
     }
     return NOT_AVAILABLE;
 }
Exemplo n.º 2
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB, $CFG_GLPIG;
     if (!Session::haveRight("contract", "r")) {
         return false;
     }
     $type = $item->getType();
     $ID = $item->getField('id');
     $con = new Contract();
     $query = "SELECT *\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n                      AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
         $pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
         $pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
         $i++;
         while ($j < $number) {
             $cID = $DB->result($result, $j, "contracts_id");
             $assocID = $DB->result($result, $j, "id");
             if ($con->getFromDB($cID)) {
                 $pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
             }
             $j++;
         }
     } else {
         $pdf->displayTitle("<b>" . __('No item found') . "</b>");
     }
     $pdf->displaySpace();
 }
Exemplo n.º 3
0
 static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareLicense $license, $main = true, $cpt = true)
 {
     global $DB;
     $ID = $license->getField('id');
     $pdf->setColumnsSize(100);
     $entity = '';
     if (Session::isMultiEntitiesMode() && !$main) {
         $entity = ' (' . Html::clean(Dropdown::getDropdownName('glpi_entities', $license->fields['entities_id'])) . ')';
     }
     $pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>" . $entity));
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), Software::getTypeName(1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $license->fields['softwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Type') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $license->fields['softwarelicensetypes_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $license->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Serial number') . '</i></b>', $license->fields['serial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Purchase version') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_buy']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Inventory number') . '</i></b>', $license->fields['otherserial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Version in use') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_use']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Expiration') . '</i></b>', Html::convDate($license->fields['expire'])));
     $col2 = '';
     if ($cpt) {
         $col2 = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Affected computers') . '</i></b>', Computer_SoftwareLicense::countForLicense($ID));
     }
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _x('quantity', 'Number') . '</i></b>', $license->fields['number'] > 0 ? $license->fields['number'] : __('Unlimited')), $col2);
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $license, 'comment');
     if ($main) {
         $pdf->displaySpace();
     }
 }
Exemplo n.º 4
0
 static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
 {
     global $DB;
     $ID = $item->getField('id');
     if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) {
         return false;
     }
     $knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id');
     $fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id));
     $question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8")));
     $answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8")));
     $pdf->setColumnsSize(100);
     if (Toolbox::strlen($fullcategoryname) > 0) {
         $pdf->displayTitle('<b>' . __('Category name') . '</b>');
         $pdf->displayLine($fullcategoryname);
     }
     if (Toolbox::strlen($question) > 0) {
         $pdf->displayTitle('<b>' . __('Subject') . '</b>');
         $pdf->displayText('', $question, 5);
     } else {
         $pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>');
     }
     if (Toolbox::strlen($answer) > 0) {
         $pdf->displayTitle('<b>' . __('Content') . '</b>');
         $pdf->displayText('', $answer, 5);
     } else {
         $pdf->displayTitle('<b>' . __('No answer found') . '</b>');
     }
     $pdf->setColumnsSize(50, 15, 15, 10, 10);
     $pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2));
     $pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]);
     $pdf->displaySpace();
 }
Exemplo n.º 5
0
function superadmin($login)
{
    global $conf;
    foreach ($conf['admin']['logins'] as $admin) {
        if (Html::clean($login) == $admin) {
            return TRUE;
        }
    }
    return FALSE;
}
Exemplo n.º 6
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////Tasks///////////
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_tickettasks`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No task found.'));
     } else {
         $pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>"));
         $pdf->setColumnsSize(20, 20, 20, 20, 20);
         $pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $actiontime = Html::timestampToString($data['actiontime'], false);
             $planification = '';
             if (empty($data['begin'])) {
                 if (isset($data["state"])) {
                     $planification = Planning::getState($data["state"]) . "<br>";
                 }
                 $planification .= _e('None');
             } else {
                 if (isset($data["state"])) {
                     $planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"]));
                 }
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"]));
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s  %2$s'), __('By'), getUserName($data["users_id_tech"])));
             }
             if ($data['taskcategories_id']) {
                 $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             toolbox::logdebug("lib", $data);
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1));
         }
     }
     $pdf->displaySpace();
 }
Exemplo n.º 7
0
 static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareVersion $version)
 {
     global $DB;
     $ID = $version->getField('id');
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>"));
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $version->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), _n('Software', 'Software', 2) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $version->fields['softwares_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Status') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_states', $version->fields['states_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Operating system') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_operatingsystems', $version->fields['operatingsystems_id']))));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $version, 'comment');
     $pdf->displaySpace();
 }
Exemplo n.º 8
0
 static function pdfMain(PluginPdfSimplePDF $pdf, Peripheral $item)
 {
     PluginPdfCommon::mainTitle($pdf, $item);
     PluginPdfCommon::mainLine($pdf, $item, 'name-status');
     PluginPdfCommon::mainLine($pdf, $item, 'location-type');
     PluginPdfCommon::mainLine($pdf, $item, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $item, 'group-model');
     PluginPdfCommon::mainLine($pdf, $item, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $item, 'contact-otherserial');
     PluginPdfCommon::mainLine($pdf, $item, 'user_management');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']))));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $item, 'comment');
     $pdf->displaySpace();
 }
 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
 {
     global $DB;
     $ID = $item->getField('id');
     // From ComputerVirtualMachine::showForComputer()
     $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}'");
     $pdf->setColumnsSize(100);
     if (count($virtualmachines)) {
         $pdf->displayTitle("<b>" . __('List of virtual machines') . "</b>");
         $pdf->setColumnsSize(20, 8, 8, 8, 25, 8, 8, 15);
         $pdf->setColumnsAlign('left', 'center', 'center', 'center', 'left', 'right', 'right', 'left');
         $typ = explode(' ', __('Virtualization system'));
         $sys = explode(' ', __('Virtualization model'));
         $sta = explode(' ', __('State of the virtual machine'));
         $pdf->displayTitle(__('Name'), $typ[0], $sys[0], $sta[0], __('UUID'), __('CPU'), __('Mio'), __('Machine'));
         foreach ($virtualmachines as $virtualmachine) {
             $name = '';
             if ($link_computer = ComputerVirtualMachine::findVirtualMachine($virtualmachine)) {
                 $computer = new Computer();
                 if ($computer->getFromDB($link_computer)) {
                     $name = $computer->getName();
                 }
             }
             $pdf->displayLine($virtualmachine['name'], Html::clean(Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id'])), Html::clean(Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id'])), Html::clean(Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id'])), $virtualmachine['uuid'], $virtualmachine['vcpu'], Html::clean(Html::formatNumber($virtualmachine['ram'], false, 0)), $name);
         }
     } else {
         $pdf->displayTitle("<b>" . __('No virtual machine associated with the computer') . "</b>");
     }
     // From ComputerVirtualMachine::showForVirtualMachine()
     if ($item->fields['uuid']) {
         $where = "`uuid`" . ComputerVirtualMachine::getUUIDRestrictRequest($item->fields['uuid']);
         $hosts = getAllDatasFromTable('glpi_computervirtualmachines', $where);
         if (count($hosts)) {
             $pdf->setColumnsSize(100);
             $pdf->displayTitle("<b>" . __('List of host machines') . "</b>");
             $pdf->setColumnsSize(26, 37, 37);
             $pdf->displayTitle(__('Name'), __('Operating system'), __('Entity'));
             $computer = new Computer();
             foreach ($hosts as $host) {
                 if ($computer->getFromDB($host['computers_id'])) {
                     $pdf->displayLine($computer->getName(), Html::clean(Dropdown::getDropdownName('glpi_operatingsystems', $computer->getField('operatingsystems_id'))), Html::clean(Dropdown::getDropdownName('glpi_entities', $computer->getEntityID())));
                 }
             }
         }
     }
     $pdf->displaySpace();
 }
Exemplo n.º 10
0
 static function pdfMain(PluginPdfSimplePDF $pdf, NetworkEquipment $item)
 {
     PluginPdfCommon::mainTitle($pdf, $item);
     PluginPdfCommon::mainLine($pdf, $item, 'name-status');
     PluginPdfCommon::mainLine($pdf, $item, 'location-type');
     PluginPdfCommon::mainLine($pdf, $item, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $item, 'group-model');
     PluginPdfCommon::mainLine($pdf, $item, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $item, 'contact-otherserial');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('User') . '</i></b>', getUserName($item->fields['users_id'])), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Network') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_networks', $item->fields['networks_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Domain') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_domains', $item->fields['domains_id']))));
     $pdf->displayLine(__('The MAC address and the IP of the equipment are included in an aggregated network port'));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _n('Firmware', 'Firmwares', 1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_networkequipmentfirmwares', $item->fields['networkequipmentfirmwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . '</i></b>', $item->fields['ram']));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $item, 'comment');
     $pdf->displaySpace();
 }
Exemplo n.º 11
0
 static function pdfForGroup(PluginPdfSimplePDF $pdf, Group $group, $tree)
 {
     global $DB, $CFG_GLPI;
     $used = array();
     $ids = array();
     // Retrieve member list
     $entityrestrict = Group_User::getDataForGroup($group, $used, $ids, '', $tree);
     $title = "<b>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', 2) . "</b>", __('D=Dynamic'));
     $number = count($used);
     if ($number > $_SESSION['glpilist_limit']) {
         $title = sprintf(__('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . "/" . $number);
     } else {
         $title = sprintf(__('%1$s (%2$s)'), $title, $number);
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle($title);
     if ($number) {
         $user = new User();
         $group = new Group();
         if ($tree) {
             $pdf->setColumnsSize(35, 45, 10, 10);
             $pdf->displayTitle(User::getTypeName(1), Group::getTypeName(1), __('Manager'), __('Delegatee'));
         } else {
             $pdf->setColumnsSize(60, 20, 20);
             $pdf->displayTitle(User::getTypeName(1), __('Manager'), __('Delegatee'));
         }
         for ($i = 0; $i < $number && $i < $_SESSION['glpilist_limit']; $i++) {
             $data = $used[$i];
             $name = Html::clean(getUserName($data["id"]));
             if ($data["is_dynamic"]) {
                 $name = sprintf(__('%1$s (%2$s)'), $name, '<b>' . __('D') . '</b>');
             }
             if ($tree) {
                 $group->getFromDB($data["groups_id"]);
                 $pdf->displayLine($name, $group->getName(), Dropdown::getYesNo($data['is_manager']), Dropdown::getYesNo($data['is_userdelegate']));
             } else {
                 $pdf->displayLine($name, Dropdown::getYesNo($data['is_manager']), Dropdown::getYesNo($data['is_userdelegate']));
             }
         }
     } else {
         $pdf->setColumnsAlign('center');
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
 function getDatasForTemplate($event, $options = array())
 {
     $this->datas['##badge.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.badge.entity##'] = __('Entity');
     $this->datas['##badge.action##'] = $event == "ExpiredBadges" ? __('Badges at the end of the validity', 'badges') : __('Badges which expires', 'badges');
     $this->datas['##lang.badge.name##'] = __('Name');
     $this->datas['##lang.badge.dateexpiration##'] = __('Date of end of validity', 'badges');
     $this->datas['##lang.badge.serial##'] = __('Serial number');
     $this->datas['##lang.badge.users##'] = __('Allotted to', 'badges');
     foreach ($options['badges'] as $id => $badge) {
         $tmp = array();
         $tmp['##badge.name##'] = $badge['name'];
         $tmp['##badge.serial##'] = $badge['serial'];
         $tmp['##badge.users##'] = Html::clean(getUserName($badge["users_id"]));
         $tmp['##badge.dateexpiration##'] = Html::convDate($badge['date_expiration']);
         $this->datas['badges'][] = $tmp;
     }
 }
Exemplo n.º 13
0
 static function pdfMain(PluginPdfSimplePDF $pdf, Software $software)
 {
     PluginPdfCommon::mainTitle($pdf, $software);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $software->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Publisher') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_manufacturers', $software->fields['manufacturers_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Location') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_locations', $software->fields['locations_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Category') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwarecategories', $software->fields['softwarecategories_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Technician in charge of the hardware') . '</i></b>', getUserName($software->fields['users_id_tech'])), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Associable to a ticket') . '</i></b>', $software->fields['is_helpdesk_visible'] ? __('Yes') : __('No')));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group in charge of the hardware') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $software->fields['groups_id_tech']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('User') . '</i></b>', getUserName($software->fields['users_id'])));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $software->fields['groups_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('Last update on %s'), Html::convDateTime($software->fields['date_mod'])));
     if ($software->fields['softwares_id'] > 0) {
         $col2 = '<b><i> ' . __('from') . ' </i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_softwares', $software->fields['softwares_id']));
     } else {
         $col2 = '';
     }
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Upgrade') . '</i></b>', $software->fields['is_update'] ? __('Yes') : __('No'), $col2));
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $software, 'comment');
     $pdf->displaySpace();
 }
Exemplo n.º 14
0
 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $query = "SELECT `glpi_filesystems`.`name` AS fsname, `glpi_computerdisks`.*\n                FROM `glpi_computerdisks`\n                LEFT JOIN `glpi_filesystems`\n                  ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n                WHERE (`computers_id` = '" . $ID . "')";
     $result = $DB->query($query);
     $pdf->setColumnsSize(100);
     if ($DB->numrows($result) > 0) {
         $pdf->displayTitle("<b>" . _n('Volume', 'Volumes', 2) . "</b>");
         $pdf->setColumnsSize(22, 23, 22, 11, 11, 11);
         $pdf->displayTitle('<b>' . __('Name'), __('Partition'), _('Mount point'), __('Type'), __('Global size'), __('Free size') . '</b>');
         $pdf->setColumnsAlign('left', 'left', 'left', 'center', 'right', 'right');
         while ($data = $DB->fetch_assoc($result)) {
             $pdf->displayLine('<b>' . Toolbox::decodeFromUtf8(empty($data['name']) ? $data['ID'] : $data['name'], "windows-1252") . '</b>', $data['device'], $data['mountpoint'], Html::clean(Dropdown::getDropdownName('glpi_filesystems', $data["filesystems_id"])), sprintf(__('%s Mio'), Html::clean(Html::formatNumber($data['totalsize'], false, 0))), sprintf(__('%s Mio'), Html::clean(Html::formatNumber($data['freesize'], false, 0))));
         }
     } else {
         $pdf->displayTitle("<b>" . __('No volume found', 'pdf') . "</b>");
     }
     $pdf->displaySpace();
 }
Exemplo n.º 15
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     // Get the Full history for the item (really a good idea ?, should we limit this)
     $changes = Log::getHistoryData($item);
     $pdf->setColumnsSize(100);
     if (count($changes) > 0) {
         $pdf->displayTitle("<b>" . __('Historical') . "</b>");
         $pdf->setColumnsSize(14, 15, 20, 51);
         $pdf->displayTitle('<b><i>' . __('ID'), __('Date'), __('User'), __('Field'), _x('name', 'Update') . '</i></b>');
         foreach ($changes as $data) {
             if ($data['display_history']) {
                 $pdf->displayLine($data['id'], $data['date_mod'], $data['user_name'], $data['field'], Html::clean($data['change']));
             }
         }
         // Each log
     } else {
         $pdf->displayTitle("<b>" . __('No historical') . "</b>");
     }
     $pdf->displaySpace();
 }
Exemplo n.º 16
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $CFG_GLPI;
     $ID = $item->getField('id');
     if (!Session::haveRight("infocom", "r")) {
         return false;
     }
     $ic = new Infocom();
     $pdf->setColumnsSize(100);
     if ($ic->getFromDBforDevice(get_class($item), $ID)) {
         $pdf->displayTitle("<b>" . __('Financial and administrative information') . "</b>");
         $pdf->setColumnsSize(50, 50);
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Supplier') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Budget') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_budgets", $ic->fields["budgets_id"]))));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Order number') . "</i></b>", $ic->fields["order_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Order date') . "</i></b>", Html::convDate($ic->fields["order_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Immobilization number') . "</i></b>", $ic->fields["immo_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Date of purchase') . "</i></b>", Html::convDate($ic->fields["buy_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Invoice number') . "</i></b>", $ic->fields["bill"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery date') . "</i></b>", Html::convDate($ic->fields["delivery_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery form') . "</i></b>", $ic->fields["delivery_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Startup date') . "</i></b>", Html::convDate($ic->fields["use_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), _('Date of last physical inventory') . "</i></b>", Html::convDate($ic->fields["inventory_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty extension value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["warranty_value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization duration') . "</i></b>", sprintf(__('%1$s (%2$s)'), sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]), Infocom::getAmortTypeName($ic->fields["sink_type"]))));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Account net value') . "</i></b>", Infocom::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $CFG_GLPI['date_tax'], "n")), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization coefficient') . "</i></b>", $ic->fields["sink_coeff"]));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('TCO (value + tracking cost)') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Monthly TCO') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]))));
         PluginPdfCommon::mainLine($pdf, $ic, 'comment');
         $pdf->setColumnsSize(100);
         $pdf->displayTitle("<b>" . __('Warranty information') . "</b>");
         $pdf->setColumnsSize(50, 50);
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Start date of warranty') . "</i></b>", Html::convDate($ic->fields["warranty_date"])), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty duration') . "</i></b>", sprintf(__('%1$s - %2$s'), sprintf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]), sprintf(__('Valid to %s'), Infocom::getWarrantyExpir($ic->fields["buy_date"], $ic->fields["warranty_duration"])))));
         $col1 = "<b><i>" . __('Alarms on financial and administrative information') . "</i></b>";
         if ($ic->fields["alert"] == 0) {
             $col1 = sprintf(__('%1$s: %2$s'), $col1, __('No'));
         } else {
             if ($ic->fields["alert"] == 4) {
                 $col1 = sprintf(__('%1$s: %2$s'), $col1, __('Warranty expiration date'));
             }
         }
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty information') . "</i></b>", $ic->fields["warranty_info"]), $col1);
     } else {
         $pdf->displayTitle("<b>" . __('No financial information', 'pdf') . "</b>");
     }
     $pdf->displaySpace();
 }
Exemplo n.º 17
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////followups///////////
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Ticket followup') . "</b>");
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_ticketfollowups`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->displayLine(__('No followup for this ticket.'));
     } else {
         while ($data = $DB->fetch_array($result)) {
             $pdf->setColumnsSize(44, 14, 42);
             $pdf->displayTitle("<b><i>" . __('Source of followup') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Requester') . "</i></b>");
             // Author
             if ($data['requesttypes_id']) {
                 $lib = Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::clean(getUserName($data["users_id"])));
             $pdf->displayText('<b><i>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</i></b>', $data["content"]));
         }
     }
     $pdf->displaySpace();
 }
Exemplo n.º 18
0
 static function pdfMain(PluginPdfSimplePDF $pdf, Monitor $item)
 {
     PluginPdfCommon::mainTitle($pdf, $item);
     PluginPdfCommon::mainLine($pdf, $item, 'name-status');
     PluginPdfCommon::mainLine($pdf, $item, 'location-type');
     PluginPdfCommon::mainLine($pdf, $item, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $item, 'group-model');
     PluginPdfCommon::mainLine($pdf, $item, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $item, 'contact-otherserial');
     PluginPdfCommon::mainLine($pdf, $item, 'user-management');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Size') . '</i></b>', sprintf(__('%1$s %2$s'), $item->fields['size'], '"')));
     $opts = array('have_micro' => __('Microphone'), 'have_speaker' => __('Speakers'), 'have_subd' => __('Sub-D'), 'have_bnc' => __('BNC'), 'have_dvi' => __('DVI'), 'have_pivot' => __('Pivot'), 'have_hdmi' => __('HDMI'), 'have_displayport' => __('DisplayPort'));
     foreach ($opts as $key => $val) {
         if (!$item->fields[$key]) {
             unset($opts[$key]);
         }
     }
     $pdf->setColumnsSize(100);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Flags') . '</i></b>', count($opts) ? implode(', ', $opts) : __('None')));
     PluginPdfCommon::mainLine($pdf, $item, 'comment');
     $pdf->displaySpace();
 }
Exemplo n.º 19
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $type = get_class($item);
     if (!Session::haveRight("document", "r")) {
         return false;
     }
     $query = "SELECT `glpi_documents_items`.`id` AS assocID,\n                       `glpi_documents`.*\n                FROM `glpi_documents_items`\n                LEFT JOIN `glpi_documents`\n                     ON (`glpi_documents_items`.`documents_id` = `glpi_documents`.`id`)\n                WHERE `glpi_documents_items`.`items_id` = '" . $ID . "'\n                      AND `glpi_documents_items`.`itemtype` = '" . $type . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $pdf->setColumnsSize(100);
     if (!$number) {
         $pdf->displayTitle('<b>' . __('No associated documents', 'pdf') . '</b>');
     } else {
         $pdf->displayTitle('<b>' . __('Associated documents', 'pdf') . '</b>');
         $pdf->setColumnsSize(32, 15, 21, 19, 13);
         $pdf->displayTitle('<b>' . __('Name'), __('File'), __('Web link'), __('Heading'), _('MIME type') . '</b>');
         while ($data = $DB->fetch_assoc($result)) {
             $pdf->displayLine($data["name"], basename($data["filename"]), $data["link"], Html::clean(Dropdown::getDropdownName("glpi_documentcategories", $data["documentcategories_id"])), $data["mime"]);
         }
     }
     $pdf->displaySpace();
 }
Exemplo n.º 20
0
 static function pdfMain(PluginPdfSimplePDF $pdf, Printer $printer)
 {
     PluginPdfCommon::mainTitle($pdf, $printer);
     PluginPdfCommon::mainLine($pdf, $printer, 'name-status');
     PluginPdfCommon::mainLine($pdf, $printer, 'location-type');
     PluginPdfCommon::mainLine($pdf, $printer, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $printer, 'group-model');
     PluginPdfCommon::mainLine($pdf, $printer, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $printer, 'contact-otherserial');
     PluginPdfCommon::mainLine($pdf, $printer, 'user-management');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $printer->fields['groups_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Network') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_networks', $printer->fields['networks_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Domain') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_domains', $printer->fields['domains_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Memory') . '</i></b>', $printer->fields['memory_size']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Initial page counter') . '</i></b>', $printer->fields['init_pages_counter']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Current counter of pages') . '</i></b>', $printer->fields['last_pages_counter']));
     $opts = array('have_serial' => __('Serial'), 'have_parallel' => __('Parallel'), 'have_usb' => __('USB'), 'have_ethernet' => __('Ethernet'), 'have_wifi' => __('Wifi'));
     foreach ($opts as $key => $val) {
         if (!$printer->fields[$key]) {
             unset($opts[$key]);
         }
     }
     $pdf->setColumnsSize(100);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _n('Port', 'Ports', count($opts)) . '</i></b>', count($opts) ? implode(', ', $opts) : __('None')));
     PluginPdfCommon::mainLine($pdf, $printer, 'comment');
     $pdf->displaySpace();
 }
Exemplo n.º 21
0
 static function pdfMain(PluginPdfSimplePDF $pdf, Phone $item)
 {
     PluginPdfCommon::mainTitle($pdf, $item);
     PluginPdfCommon::mainLine($pdf, $item, 'name-status');
     PluginPdfCommon::mainLine($pdf, $item, 'location-type');
     PluginPdfCommon::mainLine($pdf, $item, 'tech-manufacturer');
     PluginPdfCommon::mainLine($pdf, $item, 'group-model');
     PluginPdfCommon::mainLine($pdf, $item, 'contactnum-serial');
     PluginPdfCommon::mainLine($pdf, $item, 'contact-otherserial');
     PluginPdfCommon::mainLine($pdf, $item, 'user-management');
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Power supply') . '</i></b>', Dropdown::getYesNo($item->fields['phonepowersupplies_id'])));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Brand') . '</i></b>', $item->fields['brand']), '<b><i>' . sprintf(__('%1$s: %2$s'), _x('quantity', 'Number of lines') . '</i></b>', $item->fields['number_line']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _n('Firmware', 'Firmwares', 1) . '</i></b>', $item->fields['firmware']));
     $opts = array('have_headset' => __('Headset'), 'have_hp' => __('Speaker'));
     foreach ($opts as $key => $val) {
         if (!$item->fields[$key]) {
             unset($opts[$key]);
         }
     }
     $pdf->setColumnsSize(100);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Flags') . '</i></b>', count($opts) ? implode(', ', $opts) : __('None')));
     PluginPdfCommon::mainLine($pdf, $item, 'comment');
     $pdf->displaySpace();
 }
 /**
  * Get all data needed for template processing
  *
  * @param $event
  * @param $options   array
  **/
 function getDatasForTemplate($event, $options = array())
 {
     //User who tries to add or update an item in DB
     $action = $options['action_user'] ? __('Add the item') : __('Update the item');
     $this->datas['##unicity.action_type##'] = $action;
     $this->datas['##unicity.action_user##'] = $options['action_user'];
     $this->datas['##unicity.date##'] = Html::convDateTime($options['date']);
     if ($item = getItemForItemtype($options['itemtype'])) {
         $this->datas['##unicity.itemtype##'] = $item->getTypeName(1);
         $this->datas['##unicity.message##'] = Html::clean($item->getUnicityErrorMessage($options['label'], $options['field'], $options['double']));
     }
     $this->datas['##unicity.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     if ($options['refuse']) {
         $this->datas['##unicity.action##'] = __('Record into the database denied');
     } else {
         $this->datas['##unicity.action##'] = __('Item successfully added but duplicate record on');
     }
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     $this->datas['##consumable.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.consumable.entity##'] = __('Entity');
     $this->datas['##consumable.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.consumable.entity##'] = __('Entity');
     switch ($event) {
         case self::CONSUMABLE_REQUEST:
             $this->datas['##consumable.action##'] = __('Consumable request', 'consumables');
             break;
         case self::CONSUMABLE_RESPONSE:
             $this->datas['##consumable.action##'] = __('Consumable validation', 'consumables');
             break;
     }
     // Consumable request
     $this->datas['##lang.consumablerequest.consumable##'] = _n('Consumable', 'Consumables', 1);
     $this->datas['##lang.consumablerequest.consumabletype##'] = _n('Consumable type', 'Consumable types', 1);
     $this->datas['##lang.consumablerequest.request_date##'] = __('Request date');
     $this->datas['##lang.consumablerequest.requester##'] = __('Requester');
     $this->datas['##lang.consumablerequest.status##'] = __('Status');
     $this->datas['##lang.consumablerequest.number##'] = __('Number of used consumables');
     $this->datas['##lang.consumablerequest.validator##'] = __('Approver');
     $this->datas['##lang.consumablerequest.comment##'] = __('Comments');
     $consumable = $options['consumablerequest'];
     $this->datas['##consumablerequest.consumable##'] = Dropdown::getDropdownName(ConsumableItem::getTable(), $consumable['consumables_id']);
     $this->datas['##consumablerequest.consumabletype##'] = Dropdown::getDropdownName(ConsumableItemType::getTable(), $consumable['consumableitemtypes_id']);
     $this->datas['##consumablerequest.request_date##'] = Html::convDateTime($consumable['date_mod']);
     $this->datas['##consumablerequest.end_date##'] = Html::convDateTime($consumable['end_date']);
     $this->datas['##consumablerequest.requester##'] = Html::clean(getUserName($consumable['requesters_id']));
     $this->datas['##consumablerequest.validator##'] = Html::clean(getUserName($consumable['validators_id']));
     $this->datas['##consumablerequest.number##'] = $consumable['number'];
     $this->datas['##consumablerequest.status##'] = CommonITILValidation::getStatus($consumable['status']);
     if (isset($options['comment'])) {
         $this->datas['##consumablerequest.comment##'] = Html::clean($options['comment']);
     }
 }
Exemplo n.º 24
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     if (!static::canView()) {
         return false;
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '37';
     $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
     // Set default options
     if (!$ID) {
         $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
         foreach ($values as $key => $val) {
             if (!isset($options[$key])) {
                 $options[$key] = $val;
             }
         }
         if (isset($options['tickets_id'])) {
             $ticket = new Ticket();
             if ($ticket->getFromDB($options['tickets_id'])) {
                 $options['content'] = $ticket->getField('content');
                 $options['name'] = $ticket->getField('name');
                 $options['impact'] = $ticket->getField('impact');
                 $options['urgency'] = $ticket->getField('urgency');
                 $options['priority'] = $ticket->getField('priority');
                 $options['itilcategories_id'] = $ticket->getField('itilcategories_id');
                 $options['due_date'] = $ticket->getField('due_date');
             }
         }
         if (isset($options['problems_id'])) {
             $problem = new Problem();
             if ($problem->getFromDB($options['problems_id'])) {
                 $options['content'] = $problem->getField('content');
                 $options['name'] = $problem->getField('name');
                 $options['impact'] = $problem->getField('impact');
                 $options['urgency'] = $problem->getField('urgency');
                 $options['priority'] = $problem->getField('priority');
                 $options['itilcategories_id'] = $problem->getField('itilcategories_id');
                 $options['due_date'] = $problem->getField('due_date');
             }
         }
     }
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE, $options);
     }
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
     echo "<td class='left' width='{$colsize2}%'>";
     if (isset($options['tickets_id'])) {
         echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
     }
     if (isset($options['problems_id'])) {
         echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
     }
     $date = $this->fields["date"];
     if (!$ID) {
         $date = date("Y-m-d H:i:s");
     }
     Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
     echo "</td>";
     echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
     echo "<td width='{$colsize2}%' class='left'>";
     if ($this->fields["due_date"] == 'NULL') {
         $this->fields["due_date"] = '';
     }
     Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1));
     echo "</td></tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
         User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         echo "</td>";
         echo "<th>" . __('Last update') . "</th>";
         echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
         if ($this->fields['users_id_lastupdater'] > 0) {
             printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td></tr>";
     }
     if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th>" . __('Date of solving') . "</th>";
         echo "<td>";
         Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false));
         echo "</td>";
         if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
             echo "<th>" . __('Closing date') . "</th>";
             echo "<td>";
             Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     echo "</table>";
     echo "<table class='tab_cadre_fixe' id='mainformtable2'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . __('Status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
     ChangeValidation::alertValidation($this, 'status');
     echo "</td>";
     echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Only change during creation OR when allowed to change priority OR when user is the creator
     $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Category') . "</th>";
     echo "<td >";
     $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_change`='1'");
     ITILCategory::dropdown($opt);
     echo "</td>";
     echo "<th>" . __('Impact') . "</th>";
     echo "<td>";
     $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Total duration') . "</th>";
     echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>";
     echo "<th class='left'>" . __('Priority') . "</th>";
     echo "<td>";
     $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
     $idajax = 'change_priority_' . mt_rand();
     echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => 'dropdown_priority' . $idpriority);
     Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     $this->showActorsPartForm($ID, $options);
     echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . __('Title') . "</th>";
     echo "<td colspan='3'>";
     echo "<input type='text' size='90' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Description') . "</th>";
     echo "<td colspan='3'>";
     $rand = mt_rand();
     echo "<textarea id='content{$rand}' name='content' cols='90' rows='6'>" . Html::clean(Html::entity_decode_deep($this->fields["content"])) . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $options['colspan'] = 3;
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Display a line for an object
  *
  * @since version 0.85 (befor in each object with differents parameters)
  *
  * @param $id                 Integer  ID of the object
  * @param $options            array of options
  *      output_type            : Default output type (see Search class / default Search::HTML_OUTPUT)
  *      row_num                : row num used for display
  *      type_for_massiveaction : itemtype for massive action
  *      id_for_massaction      : default 0 means no massive action
  *      followups              : only for Tickets : show followup columns
  */
 static function showShort($id, $options = array())
 {
     global $CFG_GLPI, $DB;
     $p['output_type'] = Search::HTML_OUTPUT;
     $p['row_num'] = 0;
     $p['type_for_massiveaction'] = 0;
     $p['id_for_massiveaction'] = 0;
     $p['followups'] = false;
     if (count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $rand = mt_rand();
     /// TODO to be cleaned. Get datas and clean display links
     // Prints a job in short form
     // Should be called in a <table>-segment
     // Print links or not in case of user view
     // Make new job object and fill it from database, if success, print it
     $item = new static();
     $candelete = static::canDelete();
     $canupdate = Session::haveRight(static::$rightname, UPDATE);
     $showprivate = Session::haveRight('followup', TicketFollowup::SEEPRIVATE);
     $align = "class='center";
     $align_desc = "class='left";
     if ($p['followups']) {
         $align .= " top'";
         $align_desc .= " top'";
     } else {
         $align .= "'";
         $align_desc .= "'";
     }
     if ($item->getFromDB($id)) {
         $item_num = 1;
         $bgcolor = $_SESSION["glpipriority_" . $item->fields["priority"]];
         echo Search::showNewLine($p['output_type'], $p['row_num'] % 2);
         $check_col = '';
         if (($candelete || $canupdate) && $p['output_type'] == Search::HTML_OUTPUT && $p['id_for_massiveaction']) {
             $check_col = Html::getMassiveActionCheckBox($p['type_for_massiveaction'], $p['id_for_massiveaction']);
         }
         echo Search::showItem($p['output_type'], $check_col, $item_num, $p['row_num'], $align);
         // First column
         $first_col = sprintf(__('%1$s: %2$s'), __('ID'), $item->fields["id"]);
         if ($p['output_type'] == Search::HTML_OUTPUT) {
             $first_col .= "<br><img src='" . static::getStatusIconURL($item->fields["status"]) . "'\n                                alt=\"" . static::getStatus($item->fields["status"]) . "\" title=\"" . static::getStatus($item->fields["status"]) . "\">";
         } else {
             $first_col = sprintf(__('%1$s - %2$s'), $first_col, static::getStatus($item->fields["status"]));
         }
         echo Search::showItem($p['output_type'], $first_col, $item_num, $p['row_num'], $align);
         // Second column
         if ($item->fields['status'] == static::CLOSED) {
             $second_col = sprintf(__('Closed on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['closedate']));
         } else {
             if ($item->fields['status'] == static::SOLVED) {
                 $second_col = sprintf(__('Solved on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['solvedate']));
             } else {
                 if ($item->fields['begin_waiting_date']) {
                     $second_col = sprintf(__('Put on hold on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['begin_waiting_date']));
                 } else {
                     if ($item->fields['due_date']) {
                         $second_col = sprintf(__('%1$s: %2$s'), __('Due date'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['due_date']));
                     } else {
                         $second_col = sprintf(__('Opened on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['date']));
                     }
                 }
             }
         }
         echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=130");
         // Second BIS column
         $second_col = Html::convDateTime($item->fields["date_mod"]);
         echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=90");
         // Second TER column
         if (count($_SESSION["glpiactiveentities"]) > 1) {
             $second_col = Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']);
             echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=100");
         }
         // Third Column
         echo Search::showItem($p['output_type'], "<span class='b'>" . static::getPriorityName($item->fields["priority"]) . "</span>", $item_num, $p['row_num'], "{$align} bgcolor='{$bgcolor}'");
         // Fourth Column
         $fourth_col = "";
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $d) {
             $userdata = getUserName($d["users_id"], 2);
             $fourth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
             $fourth_col .= "<br>";
         }
         foreach ($item->getGroups(CommonITILActor::REQUESTER) as $d) {
             $fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
             $fourth_col .= "<br>";
         }
         echo Search::showItem($p['output_type'], $fourth_col, $item_num, $p['row_num'], $align);
         // Fifth column
         $fifth_col = "";
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $d) {
             $userdata = getUserName($d["users_id"], 2);
             $fifth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
             $fifth_col .= "<br>";
         }
         foreach ($item->getGroups(CommonITILActor::ASSIGN) as $d) {
             $fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
             $fifth_col .= "<br>";
         }
         foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $d) {
             $fifth_col .= Dropdown::getDropdownName("glpi_suppliers", $d["suppliers_id"]);
             $fifth_col .= "<br>";
         }
         echo Search::showItem($p['output_type'], $fifth_col, $item_num, $p['row_num'], $align);
         // Sixth Colum
         // Ticket : simple link to item
         $sixth_col = "";
         $is_deleted = false;
         $item_ticket = new Item_Ticket();
         $data = $item_ticket->find("`tickets_id` = " . $item->fields['id']);
         if ($item->getType() == 'Ticket') {
             if (!empty($data)) {
                 foreach ($data as $val) {
                     if (!empty($val["itemtype"]) && $val["items_id"] > 0) {
                         if ($object = getItemForItemtype($val["itemtype"])) {
                             if ($object->getFromDB($val["items_id"])) {
                                 $is_deleted = $object->isDeleted();
                                 $sixth_col .= $object->getTypeName();
                                 $sixth_col .= " - <span class='b'>";
                                 if ($item->canView()) {
                                     $sixth_col .= $object->getLink();
                                 } else {
                                     $sixth_col .= $object->getNameID();
                                 }
                                 $sixth_col .= "</span><br>";
                             }
                         }
                     }
                 }
             } else {
                 $sixth_col = __('General');
             }
             echo Search::showItem($p['output_type'], $sixth_col, $item_num, $p['row_num'], $is_deleted ? " class='center deleted' " : $align);
         }
         // Seventh column
         echo Search::showItem($p['output_type'], "<span class='b'>" . Dropdown::getDropdownName('glpi_itilcategories', $item->fields["itilcategories_id"]) . "</span>", $item_num, $p['row_num'], $align);
         // Eigth column
         $eigth_column = "<span class='b'>" . $item->getName() . "</span>&nbsp;";
         // Add link
         if ($item->canViewItem()) {
             $eigth_column = "<a id='" . $item->getType() . $item->fields["id"] . "{$rand}' href=\"" . $item->getLinkURL() . "\">{$eigth_column}</a>";
             if ($p['followups'] && $p['output_type'] == Search::HTML_OUTPUT) {
                 $eigth_column .= TicketFollowup::showShortForTicket($item->fields["id"]);
             } else {
                 if (method_exists($item, 'numberOfFollowups')) {
                     $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, sprintf(__('%1$s - %2$s'), $item->numberOfFollowups($showprivate), $item->numberOfTasks($showprivate)));
                 } else {
                     $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, $item->numberOfTasks($showprivate));
                 }
             }
         }
         if ($p['output_type'] == Search::HTML_OUTPUT) {
             $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip(Html::clean(Html::entity_decode_deep($item->fields["content"])), array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . $rand)));
         }
         echo Search::showItem($p['output_type'], $eigth_column, $item_num, $p['row_num'], $align_desc . " width='200'");
         //tenth column
         $tenth_column = '';
         $planned_infos = '';
         $tasktype = $item->getType() . "Task";
         $plan = new $tasktype();
         $items = array();
         foreach ($DB->request($plan->getTable(), array($item->getForeignKeyField() => $item->fields['id'])) as $plan) {
             if (isset($plan['begin']) && $plan['begin']) {
                 $items[$plan['id']] = $plan['id'];
                 $planned_infos .= sprintf(__('From %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), Html::convDateTime($plan['begin']));
                 $planned_infos .= sprintf(__('To %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), Html::convDateTime($plan['end']));
                 if ($plan['users_id_tech']) {
                     $planned_infos .= sprintf(__('By %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), getUserName($plan['users_id_tech']));
                 }
                 $planned_infos .= "<br>";
             }
         }
         unset($i, $j);
         $tenth_column = count($items);
         if ($tenth_column) {
             $tenth_column = "<span class='pointer'\n                              id='" . $item->getType() . $item->fields["id"] . "planning{$rand}'>" . $tenth_column . '</span>';
             $tenth_column = sprintf(__('%1$s %2$s'), $tenth_column, Html::showToolTip($planned_infos, array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . "planning" . $rand)));
         }
         echo Search::showItem($p['output_type'], $tenth_column, $item_num, $p['row_num'], $align_desc . " width='150'");
         // Finish Line
         echo Search::showEndLine($p['output_type']);
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' ><i>" . __('No item in progress.') . "</i></td></tr>";
     }
 }
Exemplo n.º 26
0
 /**
  * Show for PDF an resources : tasks informations
  * 
  * @param $pdf object for the output
  * @param $ID of the resources
  */
 static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli)
 {
     global $DB;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_resources_haveRight("resources", "r")) {
         return false;
     }
     $query = "SELECT * \n               FROM `glpi_plugin_resources_tasks` \n               WHERE `plugin_resources_resources_id` = '{$ID}'\n               AND `is_deleted` ='0'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . self::getTypeName(2) . '</b>');
         $pdf->setColumnsSize(14, 14, 14, 14, 16, 14, 14);
         $pdf->displayTitle('<b><i>' . __('Name'), __('Type'), __('Comments'), __('Duration'), __('Planning'), __('Resource manager', 'resources'), __('Group') . '</i></b>');
         $i++;
         while ($j < $number) {
             $tID = $DB->result($result, $j, "id");
             $actiontime_ID = $DB->result($result, $j, "actiontime");
             $actiontime = '';
             $units = Toolbox::getTimestampTimeUnits($actiontime_ID);
             $hour = $units['hour'];
             $minute = $units['minute'];
             if ($hour) {
                 $actiontime = $hour . __('Hour', 'Hours', 2);
             }
             if ($minute || !$hour) {
                 $actiontime .= $minute . __('Minute', 'Minutes', 2);
             }
             $restrict = " `plugin_resources_tasks_id` = '" . $tID . "' ";
             $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
             if (!empty($plans)) {
                 foreach ($plans as $plan) {
                     $planification = Html::convDateTime($plan["begin"]) . "&nbsp;->&nbsp;" . Html::convDateTime($plan["end"]);
                 }
             } else {
                 $planification = __('None');
             }
             $users_id = $DB->result($result, $j, "users_id");
             $managers = Html::clean(getUserName($users_id));
             $name = $DB->result($result, $j, "name");
             $task_type = $DB->result($result, $j, "plugin_resources_tasktypes_id");
             $comment = $DB->result($result, $j, "comment");
             $groups_id = $DB->result($result, $j, "groups_id");
             $pdf->displayLine(Html::clean($name), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_tasktypes", $task_type)), $comment, $actiontime, Html::clean($planification), $managers, Html::clean(Dropdown::getDropdownName("glpi_groups", $groups_id)));
             $j++;
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
Exemplo n.º 27
0
 /** Clean mail content : HTML + XSS + blacklisted content
  *
  * @since version 0.85
  *
  * @param $string text to clean
  *
  * @return cleaned text
  **/
 function cleanMailContent($string)
 {
     global $DB;
     // First clean HTML and XSS
     $string = Toolbox::clean_cross_side_scripting_deep(Html::clean($string));
     $rand = mt_rand();
     // Move line breaks to special CHARS
     $string = str_replace(array("<br>"), "=={$rand}==", $string);
     $string = str_replace(array("\r\n", "\n", "\r"), "=={$rand}==", $string);
     // Wrap content for blacklisted items
     $itemstoclean = array();
     foreach ($DB->request('glpi_blacklistedmailcontents') as $data) {
         $toclean = trim($data['content']);
         if (!empty($toclean)) {
             $toclean = str_replace(array("\r\n", "\n", "\r"), "=={$rand}==", $toclean);
             $itemstoclean[] = $toclean;
         }
     }
     if (count($itemstoclean)) {
         $string = str_replace($itemstoclean, '', $string);
     }
     $string = str_replace("=={$rand}==", "\n", $string);
     return $string;
 }
Exemplo n.º 28
0
 /**
  * Clean display value for sylk export
  *
  * @param $value string value
  *
  * @return clean value
  **/
 static function sylk_clean($value)
 {
     $value = preg_replace('/\\x0A/', ' ', $value);
     $value = preg_replace('/\\x0D/', NULL, $value);
     $value = str_replace("\"", "''", $value);
     $value = str_replace(';', ';;', $value);
     $value = Html::clean($value);
     return $value;
 }
Exemplo n.º 29
0
 /**
  * Convert rich text content to simple text content
  *
  * @since version 0.85
  *
  * @param $content : content to convert in html
  *
  * @return $content
  **/
 function setSimpleTextContent($content)
 {
     $content = Html::entity_decode_deep($content);
     // If is html content
     if ($content != strip_tags($content)) {
         $content = Html::clean($this->convertImageToTag($content), false, 1);
         $content = Html::entity_decode_deep(Html::clean($this->convertImageToTag($content)));
     }
     return $content;
 }
Exemplo n.º 30
0
/**
 * @param $pid
 * @param $data
 * @param $server
 * @param $prof
 * @param $verb
 * @param $mail
**/
function syncEntity($pid, $data, $server, $prof, $verb, $mail)
{
    global $DB, $LANG, $CFG_GLPI;
    // Re-establish DB connexion - mandatory in each forked process
    if (!DBConnection::switchToMaster()) {
        echo " {$pid}: lost DB connection\n";
        return 0;
    }
    // Server from entity (if not given from option)
    if ($data['authldaps_id'] > 0) {
        $server = $data['authldaps_id'];
    }
    $entity = new Entity();
    if ($entity->getFromDB($id = $data['id'])) {
        $tps = microtime(true);
        if ($verb) {
            echo "  {$pid}: Synchonizing entity '" . $entity->getField('completename') . "' ({$id}, mail={$mail})\n";
        }
        $sql = "SELECT DISTINCT glpi_users.*\n              FROM glpi_users\n              INNER JOIN glpi_profiles_users\n                  ON (glpi_profiles_users.users_id = glpi_users.id\n                      AND glpi_profiles_users.entities_id = {$id}";
        if ($prof > 0) {
            $sql .= "    AND glpi_profiles_users.profiles_id = {$prof}";
        }
        $sql .= ")\n               WHERE glpi_users.authtype = " . Auth::LDAP;
        if ($server > 0) {
            $sql .= " AND glpi_users.auths_id = {$server}";
        }
        $users = array();
        $results = array(AuthLDAP::USER_IMPORTED => 0, AuthLDAP::USER_SYNCHRONIZED => 0, AuthLDAP::USER_DELETED_LDAP => 0);
        $req = $DB->request($sql);
        $i = 0;
        $nb = $req->numrows();
        foreach ($req as $row) {
            $i++;
            $result = AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $row['name']), AuthLDAP::ACTION_SYNCHRONIZE, $row['auths_id']);
            if ($result) {
                $results[$result['action']] += 1;
                $users[$row['id']] = $row['name'];
                if ($result['action'] == AuthLDAP::USER_SYNCHRONIZED) {
                    if ($verb) {
                        echo "  {$pid}: User '" . $row['name'] . "' synchronized ({$i}/{$nb})\n";
                    }
                } else {
                    if ($verb) {
                        echo "  {$pid}: User '" . $row['name'] . "' deleted\n";
                    }
                }
            } else {
                if ($verb) {
                    echo "  {$pid}: Problem with LDAP for user '" . $row['name'] . "'\n";
                }
            }
        }
        $tps = microtime(true) - $tps;
        printf("  %d: Entity '%s' - Synchronized: %d, Deleted from LDAP: %d, Time: %.2f\"\n", $pid, $entity->getField('completename'), $results[AuthLDAP::USER_SYNCHRONIZED], $results[AuthLDAP::USER_DELETED_LDAP], $tps);
        if ($mail) {
            $report = '';
            $user = new User();
            foreach ($users as $id => $name) {
                if ($user->getFromDB($id)) {
                    $logs = Log::getHistoryData($user, 0, $_SESSION['glpilist_limit'], "`date_mod`='" . $_SESSION['glpi_currenttime'] . "'");
                    if (count($logs)) {
                        $report .= "\n{$name} (" . $user->getName() . ")\n";
                        foreach ($logs as $log) {
                            $report .= "\t";
                            if ($log['field']) {
                                $report .= $log['field'] . ": ";
                            }
                            $report .= Html::clean($log['change']) . "\n";
                        }
                    }
                } else {
                    $report .= "\n" . $name . "\n\t deleted\n";
                }
            }
            if ($report) {
                $report = "Synchronization of already imported users\n " . "Entité: " . $entity->getField('completename') . "\n " . "Date: " . Html::convDateTime($_SESSION['glpi_currenttime']) . "\n " . $report;
                $entdata = new Entity();
                $mmail = new NotificationMail();
                $mmail->AddCustomHeader("Auto-Submitted: auto-generated");
                $mmail->From = $CFG_GLPI["admin_email"];
                $mmail->FromName = "GLPI";
                $mmail->Subject = "[GLPI] LDAP directory link";
                $mmail->Body = $report . "\n--\n" . $CFG_GLPI["mailing_signature"];
                if ($mail & 1 && $entdata->getFromDB($entity->getField('id')) && $entdata->fields['admin_email']) {
                    $mmail->AddAddress($entdata->fields['admin_email']);
                } else {
                    if ($mail & 1 && $verb) {
                        echo "  {$pid}: No address found for email entity\n";
                    }
                    $mail = $mail & 2;
                }
                if ($mail & 2 && $CFG_GLPI['admin_email']) {
                    $mmail->AddAddress($CFG_GLPI['admin_email']);
                } else {
                    if ($mail & 2 && $verb) {
                        echo "  {$pid}: No address found for email admin\n";
                    }
                    $mail = $mail & 1;
                }
                if ($mail) {
                    if ($mmail->Send() && $verb) {
                        echo "  {$pid}: Report sent by email\n";
                    }
                } else {
                    echo "  {$pid}: Cannot send report (" . $entity->getField('completename') . ") " . "invalid address\n";
                }
            }
        }
        return $results[AuthLDAP::USER_DELETED_LDAP] + $results[AuthLDAP::USER_SYNCHRONIZED];
    }
    return 0;
}