Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yllen committed Nov 7, 2015
1 parent e1423d6 commit 3debffe
Show file tree
Hide file tree
Showing 64 changed files with 253 additions and 304 deletions.
2 changes: 1 addition & 1 deletion inc/calendar_holiday.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ static function cloneCalendar($oldid, $newid) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate) {
$nb = 0;
switch ($item->getType()) {
case 'Calendar' :
$nb = 1;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable($this->getTable(),
"calendars_id = '".$item->getID()."'");
Expand Down
2 changes: 1 addition & 1 deletion inc/calendarsegment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@ static function showForCalendar(Calendar $calendar) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate) {
$nb = 0;
switch ($item->getType()) {
case 'Calendar' :
$nb = 1;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable($this->getTable(),
"calendars_id = '".$item->getID()."'");
Expand Down
2 changes: 1 addition & 1 deletion inc/cartridge.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ static function getNotificationParameters($entity=0) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate && self::canView()) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Printer' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/cartridgeitem_printermodel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate && Printer::canView()) {
$nb = 0;
switch ($item->getType()) {
case 'CartridgeItem' :
$nb = 1;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForCartridgeItem($item);
}
Expand Down
2 changes: 1 addition & 1 deletion inc/change_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static function showForChange(Change $change) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Change' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/change_problem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static function getTypeName($nb=0) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (static::canView()) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Change' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/change_project.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function getSearchOptions() {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (static::canView()) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Change' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/change_ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static function getTypeName($nb=0) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (static::canView()) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Change' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/commonitilcost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
// can exists for template
if (($item->getType() == static::$itemtype)
&& static::canView()) {
$nb = 1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable($this->getTable(),
"`".$item->getForeignKeyField()."` = '".$item->getID()."'");
Expand Down
2 changes: 1 addition & 1 deletion inc/commonitiltask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (($item->getType() == $this->getItilObjectItemType())
&& $this->canView()) {
$nb = 1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$restrict = "`".$item->getForeignKeyField()."` = '".$item->getID()."'";

Expand Down
2 changes: 1 addition & 1 deletion inc/commonitilvalidation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
}

if (!$hidetab) {
$nb = 1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$restrict = "`".static::$items_id."` = '".$item->getID()."'";
// No rights for create only count asign ones
Expand Down
2 changes: 1 addition & 1 deletion inc/commontreedropdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate
&& ($item->getType() == $this->getType())) {
$nb = 1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable($this->getTable(),
"`".$this->getForeignKeyField()."` = '".$item->getID()."'");
Expand Down
2 changes: 1 addition & 1 deletion inc/computer_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

// can exists for Template
if ($item->can($item->getField('id'), READ)) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Phone' :
case 'Printer' :
Expand Down
2 changes: 1 addition & 1 deletion inc/computer_softwarelicense.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,10 @@ static function cloneComputer($oldid, $newid) {
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

$nb = 0;
switch ($item->getType()) {
case 'SoftwareLicense' :
if (!$withtemplate) {
$nb = 1;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForLicense($item->getID());
}
Expand Down
2 changes: 1 addition & 1 deletion inc/computer_softwareversion.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ static function cloneComputer($oldid, $newid) {
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Software' :
if (!$withtemplate) {
Expand Down
2 changes: 1 addition & 1 deletion inc/computerdisk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
// can exists for template
if (($item->getType() == 'Computer')
&& Computer::canView()) {
$nb =1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable('glpi_computerdisks',
"computers_id = '".$item->getID()."' AND `is_deleted`='0'");
Expand Down
2 changes: 1 addition & 1 deletion inc/computervirtualmachine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
if (!$withtemplate
&& ($item->getType() == 'Computer')
&& Computer::canView()) {
$nb = 1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable('glpi_computervirtualmachines',
"computers_id = '".$item->getID()."' AND `is_deleted`='0'");
Expand Down
2 changes: 1 addition & 1 deletion inc/consumable.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@ static function showSummary() {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate && Consumable::canView()) {
$nb = 0;
switch ($item->getType()) {
case 'ConsumableItem' :
$nb = 1;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForConsumableItem($item);
}
Expand Down
2 changes: 1 addition & 1 deletion inc/contact_supplier.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function getSearchOptions() {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate && Session::haveRight("contact_enterprise", READ)) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Supplier' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/contract_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

// Can exists on template
if (Contract::canView()) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Contract' :
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down
2 changes: 1 addition & 1 deletion inc/contract_supplier.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static function countForContract(Contract $item) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate) {
$nb = 1;
$nb = 0;
switch ($item->getType()) {
case 'Supplier' :
if (Contract::canView()) {
Expand Down
2 changes: 1 addition & 1 deletion inc/contractcost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
// can exists for template
if (($item->getType() == 'Contract')
&& Contract::canView()) {
$nb = 1;
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable('glpi_contractcosts', "contracts_id = '".$item->getID()."'");
}
Expand Down
15 changes: 6 additions & 9 deletions inc/crontasklog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.
-------------------------------------------------------------------------
LICENSE
Expand Down Expand Up @@ -76,20 +76,17 @@ static function cleanOld($id, $days) {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (!$withtemplate) {
$nb = 0;
switch ($item->getType()) {
case 'CronTask' :
$ong = array();
$ong[1] = __('Statistics');
if ($_SESSION['glpishow_count_on_tabs']) {
$ong[2] = self::createTabEntry(_n('Log', 'Logs', Session::getPluralNumber()),
countElementsInTable($this->getTable(),
"crontasks_id
= '".$item->getID()."'
AND `state`
= '".self::STATE_STOP."' "));
} else {
$ong[2] = _n('Log', 'Logs', Session::getPluralNumber());
$nb = countElementsInTable($this->getTable(),
"crontasks_id = '".$item->getID()."'
AND `state` = '".self::STATE_STOP."' ");
}
$ong[2] = self::createTabEntry(_n('Log', 'Logs', Session::getPluralNumber()), $nb);
return $ong;
}
}
Expand Down
25 changes: 10 additions & 15 deletions inc/document_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,18 @@ static function countForDocument(Document $item) {

function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

$nbdoc = $nbitem = 0;
switch ($item->getType()) {
case 'Document' :
$ong = array();
if ($_SESSION['glpishow_count_on_tabs']) {
$nb_items = self::countForDocument($item);
$ong[1] = self::createTabEntry(_n('Associated item', 'Associated items', $nb_items),
$nb_items);
} else {
$ong[1] = _n('Associated item', 'Associated items', Session::getPluralNumber());
}

if ($_SESSION['glpishow_count_on_tabs']) {
$ong[2] = self::createTabEntry(Document::getTypeName(self::countForItem($item)),
self::countForItem($item));
} else {
$ong[2] = Document::getTypeName(Session::getPluralNumber());
$nbdoc = self::countForDocument($item);
$nbitem = self::countForItem($item);
}
$ong[1] = self::createTabEntry(_n('Associated item', 'Associated items',
Session::getPluralNumber()), $nbdoc);
$ong[2] = self::createTabEntry(Document::getTypeName(Session::getPluralNumber()),
$nbitem);
return $ong;

default :
Expand All @@ -239,10 +234,10 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|| ($item->getType() == 'KnowbaseItem')) {

if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(Document::getTypeName(self::countForItem($item)),
self::countForItem($item));
$nbitem = self::countForItem($item);
}
return Document::getTypeName(Session::getPluralNumber());
return self::createTabEntry(Document::getTypeName(Session::getPluralNumber()),
$nbitem);
}
}
return '';
Expand Down
32 changes: 16 additions & 16 deletions inc/dropdowntranslation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.
-------------------------------------------------------------------------
LICENSE
Expand Down Expand Up @@ -70,11 +70,11 @@ function getForbiddenStandardMassiveAction() {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

if (self::canBeTranslated($item)) {
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()),
self::getNumberOfTranslationsForItem($item));
$nb = self::getNumberOfTranslationsForItem($item);
}
return self::getTypeName(Session::getPluralNumber());
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb);
}
return '';
}
Expand Down Expand Up @@ -134,15 +134,15 @@ function post_purgeItem() {
// If only completename for sons : drop
// foreach (getSonsOf(getTableForItemType($this->fields['itemtype']),
// $this->fields['items_id']) as $son) {
//
//
// if ($this->getNumberOfTranslations($this->fields['itemtype'], $son,
// 'name', $this->fields['language']) == 0) {
//
// $completenames_id = self::getTranslationID($son, $this->fields['itemtype'],
//
// $completenames_id = self::getTranslationID($son, $this->fields['itemtype'],
// 'completename',
// $this->fields['language']);
// if ($completenames_id) {
// $translation = new self();
// $translation = new self();
// $translation->delete(array('id' => $completenames_id));
// }
// }
Expand Down Expand Up @@ -170,7 +170,7 @@ function post_addItem() {
// Add to session
$_SESSION['glpi_dropdowntranslations'][$this->fields['itemtype']][$this->fields['field']]
= $this->fields['field'];

if (!isset($this->input['_no_completename'])) {
$translation = new self();
$translation->generateCompletename($this->fields, true);
Expand Down Expand Up @@ -246,7 +246,7 @@ function generateCompletename($input, $add=true) {
global $DB;
// Force completename translated : used for the first translation
$_SESSION['glpi_dropdowntranslations'][$input['itemtype']]['completename'] = 'completename';

//If there's already a completename for this language, get it's ID, otherwise 0
$completenames_id = self::getTranslationID($input['items_id'], $input['itemtype'],
'completename', $input['language']);
Expand All @@ -256,16 +256,16 @@ function generateCompletename($input, $add=true) {
&& isset($input['language'])) {
$item->getFromDB($input['items_id']);
$foreignKey = $item->getForeignKeyField() ;

//Regenerate completename : look for item's ancestors
$completename = "";

//Get ancestors as an array

if ($item->fields[$foreignKey] != 0) {
$completename = self::getTranslatedValue($item->fields[$foreignKey], $input['itemtype'], 'completename',
$input['language']);
}
}

if ($completename != '') {
$completename.= " > ";
Expand Down Expand Up @@ -294,11 +294,11 @@ function generateCompletename($input, $add=true) {
$translation->add($tmp);
}
}

$query = "SELECT `id`
FROM `".$item->getTable()."`
WHERE `$foreignKey` = '".$item->getID()."'";

foreach ($DB->request($query) as $tmp) {
$input2 = $input;
$input2['items_id'] = $tmp['id'];
Expand Down Expand Up @@ -691,7 +691,7 @@ static function regenerateAllCompletenameTranslationsFor($itemtype, $items_id) {
$dt->generateCompletename($data, false);
}
}

/**
* Check if there's at least one translation for this itemtype
*
Expand Down

0 comments on commit 3debffe

Please sign in to comment.