Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GLPI
glpi
Commits
d47fa943
Commit
d47fa943
authored
Jan 22, 2021
by
Cédric Anne
Browse files
Merge branch '9.5/bugfixes'
parents
06199f7f
5d1f5c61
Changes
12
Hide whitespace changes
Inline
Side-by-side
inc/commonitilobject.class.php
View file @
d47fa943
...
...
@@ -6696,15 +6696,14 @@ abstract class CommonITILObject extends CommonDBTM {
$total_actiontime
=
0
;
$criteria
=
[
'SELECT'
=>
'actiontime'
,
'DISTINCT'
=>
true
,
'SELECT'
=>
[
'SUM'
=>
'actiontime AS actiontime'
],
'FROM'
=>
$task_table
,
'WHERE'
=>
[
$foreignKey
=>
$this
->
fields
[
'id'
]]
];
$
iterator
=
$DB
->
request
(
$criteria
);
foreach
(
$iterator
as
$req
)
{
$total_actiontime
+
=
$r
eq
[
'actiontime'
];
$
req
=
$DB
->
request
(
$criteria
);
if
(
$row
=
$req
->
next
()
)
{
$total_actiontime
=
$r
ow
[
'actiontime'
];
}
if
(
$total_actiontime
>
0
)
{
echo
"<h3>"
;
...
...
inc/console/database/installcommand.class.php
View file @
d47fa943
...
...
@@ -275,7 +275,7 @@ class InstallCommand extends AbstractConfigureCommand {
FROM information_schema.tables
WHERE table_schema = '
{
$db_name
}
'
AND table_type = 'BASE TABLE'
AND table_name LIKE 'glpi_%'"
AND table_name LIKE 'glpi
\
_%'"
);
if
(
!
$tables_result
)
{
throw
new
\
Symfony\Component\Console\Exception\RuntimeException
(
'Unable to check GLPI tables existence.'
);
...
...
inc/console/migration/buildmissingtimestampscommand.class.php
View file @
d47fa943
...
...
@@ -63,7 +63,7 @@ class BuildMissingTimestampsCommand extends AbstractCommand {
'FROM'
=>
'information_schema.columns'
,
'WHERE'
=>
[
'table_schema'
=>
$this
->
db
->
dbdefault
,
'table_name'
=>
[
'LIKE'
,
'glpi_%'
],
'table_name'
=>
[
'LIKE'
,
'glpi
\
_%'
],
'column_name'
=>
[
'date_creation'
,
'date_mod'
],
],
'ORDER'
=>
[
'table_name'
,
'column_name'
],
...
...
inc/console/migration/timestampscommand.class.php
View file @
d47fa943
...
...
@@ -77,7 +77,7 @@ class TimestampsCommand extends AbstractCommand {
],
'WHERE'
=>
[
'information_schema.columns.table_schema'
=>
$this
->
db
->
dbdefault
,
'information_schema.columns.table_name'
=>
[
'LIKE'
,
'glpi_%'
],
'information_schema.columns.table_name'
=>
[
'LIKE'
,
'glpi
\
_%'
],
'information_schema.columns.data_type'
=>
'datetime'
,
'information_schema.tables.table_type'
=>
'BASE TABLE'
,
...
...
inc/dashboard/dashboard.class.php
View file @
d47fa943
...
...
@@ -487,4 +487,4 @@ class Dashboard extends \CommonDBTM {
return
true
;
}
}
\ No newline at end of file
}
inc/dashboard/provider.class.php
View file @
d47fa943
...
...
@@ -44,6 +44,7 @@ use Group;
use
Group_Ticket
;
use
Problem
;
use
QueryExpression
;
use
QuerySubQuery
;
use
Search
;
use
Session
;
use
Stat
;
...
...
@@ -701,7 +702,7 @@ class Provider extends CommonGLPI {
$series
=
[
'inter_total'
=>
[
'name'
=>
_nx
(
'ticket'
,
'Opened'
,
'Opened'
,
\
Session
::
getPluralNumber
()),
'name'
=>
_nx
(
'ticket'
,
'Opened'
,
'Opened'
,
Session
::
getPluralNumber
()),
'search'
=>
[
'criteria'
=>
[
[
...
...
@@ -720,7 +721,7 @@ class Provider extends CommonGLPI {
]
],
'inter_solved'
=>
[
'name'
=>
_nx
(
'ticket'
,
'Solved'
,
'Solved'
,
\
Session
::
getPluralNumber
()),
'name'
=>
_nx
(
'ticket'
,
'Solved'
,
'Solved'
,
Session
::
getPluralNumber
()),
'search'
=>
[
'criteria'
=>
[
[
...
...
@@ -856,50 +857,55 @@ class Provider extends CommonGLPI {
$statuses
=
Ticket
::
getAllStatusArray
();
$t_table
=
Ticket
::
getTable
();
$
criteria
=
array_merge_recursive
(
$
sub_query
=
array_merge_recursive
(
[
'DISTINCT'
=>
true
,
'SELECT'
=>
[
new
QueryExpression
(
"FROM_UNIXTIME(UNIX_TIMESTAMP("
.
$DB
->
quoteName
(
"
$t_table
.date"
)
.
"),'%Y-%m') AS period"
),
new
QueryExpression
(
"SUM(IF(
$t_table
.status = "
.
Ticket
::
INCOMING
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'New'
))
),
new
QueryExpression
(
"SUM(IF(
$t_table
.status = "
.
Ticket
::
ASSIGNED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Processing (assigned)'
))
),
new
QueryExpression
(
"SUM(IF(
$t_table
.status = "
.
Ticket
::
PLANNED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Processing (planned)'
))
),
new
QueryExpression
(
"SUM(IF(
$t_table
.status = "
.
Ticket
::
WAITING
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
__
(
'Pending'
))
),
new
QueryExpression
(
"SUM(IF(
$t_table
.status = "
.
Ticket
::
SOLVED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Solved'
))
),
new
QueryExpression
(
"SUM(IF(
$t_table
.status = "
.
Ticket
::
CLOSED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Closed'
))
),
],
'SELECT'
=>
[
"
$t_table
.*"
],
'FROM'
=>
$t_table
,
'WHERE'
=>
[
"
$t_table
.is_deleted"
=>
0
,
]
+
getEntitiesRestrictCriteria
(
$t_table
),
'ORDER'
=>
'period ASC'
,
'GROUP'
=>
[
'period'
]
],
// limit count for profiles with limited rights
Ticket
::
getCriteriaFromProfile
(),
self
::
getFiltersCriteria
(
$t_table
,
$params
[
'apply_filters'
])
);
$criteria
=
[
'SELECT'
=>
[
new
QueryExpression
(
"FROM_UNIXTIME(UNIX_TIMESTAMP("
.
$DB
->
quoteName
(
"
{
$t_table
}
_distinct.date"
)
.
"),'%Y-%m') AS period"
),
new
QueryExpression
(
"SUM(IF(
{
$t_table
}
_distinct.status = "
.
Ticket
::
INCOMING
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'New'
))
),
new
QueryExpression
(
"SUM(IF(
{
$t_table
}
_distinct.status = "
.
Ticket
::
ASSIGNED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Processing (assigned)'
))
),
new
QueryExpression
(
"SUM(IF(
{
$t_table
}
_distinct.status = "
.
Ticket
::
PLANNED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Processing (planned)'
))
),
new
QueryExpression
(
"SUM(IF(
{
$t_table
}
_distinct.status = "
.
Ticket
::
WAITING
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
__
(
'Pending'
))
),
new
QueryExpression
(
"SUM(IF(
{
$t_table
}
_distinct.status = "
.
Ticket
::
SOLVED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Solved'
))
),
new
QueryExpression
(
"SUM(IF(
{
$t_table
}
_distinct.status = "
.
Ticket
::
CLOSED
.
", 1, 0))
as "
.
$DB
->
quoteValue
(
_x
(
'status'
,
'Closed'
))
),
],
'FROM'
=>
new
QuerySubQuery
(
$sub_query
,
"
{
$t_table
}
_distinct"
),
'ORDER'
=>
'period ASC'
,
'GROUP'
=>
[
'period'
]
];
$iterator
=
$DB
->
request
(
$criteria
);
$s_criteria
=
[
...
...
inc/dbmysql.class.php
View file @
d47fa943
...
...
@@ -558,7 +558,7 @@ class DBmysql {
*
* @return DBmysqlIterator
*/
function
listTables
(
$table
=
'glpi_%'
,
array
$where
=
[])
{
function
listTables
(
$table
=
'glpi
\
_%'
,
array
$where
=
[])
{
$iterator
=
$this
->
request
([
'SELECT'
=>
'table_name as TABLE_NAME'
,
'FROM'
=>
'information_schema.tables'
,
...
...
@@ -577,7 +577,7 @@ class DBmysql {
* @return DBmysqlIterator
*/
public
function
getMyIsamTables
():
DBmysqlIterator
{
$iterator
=
$this
->
listTables
(
'glpi_%'
,
[
'engine'
=>
'MyIsam'
]);
$iterator
=
$this
->
listTables
(
'glpi
\
_%'
,
[
'engine'
=>
'MyIsam'
]);
return
$iterator
;
}
...
...
@@ -891,7 +891,7 @@ class DBmysql {
// with all known tables
$retrieve_all
=
!
$this
->
cache_disabled
&&
empty
(
$this
->
table_cache
);
$result
=
$this
->
listTables
(
$retrieve_all
?
'glpi_%'
:
$tablename
);
$result
=
$this
->
listTables
(
$retrieve_all
?
'glpi
\
_%'
:
$tablename
);
$found_tables
=
[];
while
(
$data
=
$result
->
next
())
{
$found_tables
[]
=
$data
[
'TABLE_NAME'
];
...
...
@@ -1553,7 +1553,7 @@ class DBmysql {
'FROM'
=>
'information_schema.columns'
,
'WHERE'
=>
[
'information_schema.columns.table_schema'
=>
$DB
->
dbdefault
,
'information_schema.columns.table_name'
=>
[
'LIKE'
,
'glpi_%'
],
'information_schema.columns.table_name'
=>
[
'LIKE'
,
'glpi
\
_%'
],
'information_schema.columns.data_type'
=>
[
'datetime'
]
]
])
->
next
();
...
...
inc/migration.class.php
View file @
d47fa943
...
...
@@ -1290,7 +1290,7 @@ class Migration {
'FROM'
=>
'information_schema.columns'
,
'WHERE'
=>
[
'table_schema'
=>
$DB
->
dbdefault
,
'table_name'
=>
[
'LIKE'
,
'glpi_%'
],
'table_name'
=>
[
'LIKE'
,
'glpi
\
_%'
],
'OR'
=>
[
[
'column_name'
=>
$old_fkey
],
[
'column_name'
=>
[
'LIKE'
,
$old_fkey
.
'_%'
]],
...
...
@@ -1356,7 +1356,7 @@ class Migration {
'FROM'
=>
'information_schema.columns'
,
'WHERE'
=>
[
'table_schema'
=>
$DB
->
dbdefault
,
'table_name'
=>
[
'LIKE'
,
'glpi_%'
],
'table_name'
=>
[
'LIKE'
,
'glpi
\
_%'
],
'OR'
=>
[
[
'column_name'
=>
'itemtype'
],
[
'column_name'
=>
[
'LIKE'
,
'itemtype_%'
]],
...
...
inc/search.class.php
View file @
d47fa943
...
...
@@ -3507,7 +3507,7 @@ JAVASCRIPT;
||
(
isset
(
$searchopt
[
$ID
][
"forcegroupby"
])
&&
$searchopt
[
$ID
][
"forcegroupby"
]))
{
$ADDITONALFIELDS
.
=
" IFNULL(GROUP_CONCAT(DISTINCT CONCAT(IFNULL(`
$table$addtable
`.`
$key
`,
'"
.
self
::
NULLVALUE
.
"'),
'"
.
self
::
SHORTSEP
.
"',
$tocomputeid
) SEPARATOR '"
.
self
::
LONGSEP
.
"'), '"
.
self
::
NULLVALUE
.
self
::
SHORTSEP
.
"')
'"
.
self
::
SHORTSEP
.
"',
$tocomputeid
)
ORDER BY
$tocomputeid
SEPARATOR '"
.
self
::
LONGSEP
.
"'), '"
.
self
::
NULLVALUE
.
self
::
SHORTSEP
.
"')
AS `"
.
$NAME
.
"_
$key
`, "
;
}
else
{
$ADDITONALFIELDS
.
=
"`
$table$addtable
`.`
$key
` AS `"
.
$NAME
.
"_
$key
`, "
;
...
...
inc/stat.class.php
View file @
d47fa943
...
...
@@ -762,9 +762,11 @@ class Stat extends CommonGLPI {
$solved_status
=
array_merge
(
$closed_status
,
$item
->
getSolvedStatusArray
());
$criteria
=
[];
$WHERE
=
[
"
$table
.is_deleted"
=>
0
]
+
getEntitiesRestrictCriteria
(
$table
);
$WHERE
=
[];
if
(
$item
->
maybeDeleted
())
{
$WHERE
[
"
$table
.is_deleted"
]
=
0
;
}
$WHERE
+=
getEntitiesRestrictCriteria
(
$table
);
$LEFTJOIN
=
[];
$INNERJOIN
=
[];
$LEFTJOINUSER
=
[
...
...
@@ -1020,7 +1022,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT
'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1041,7 +1043,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT
'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1068,7 +1070,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT
'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1089,7 +1091,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT
'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1111,7 +1113,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT
'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1227,7 +1229,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT
'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1259,7 +1261,7 @@ class Stat extends CommonGLPI {
$criteria
=
[
'SELECT'
=>
[
$date_unix
,
'COUNT'
=>
"
$table
.id AS total_visites"
'COUNT
DISTINCT
'
=>
"
$table
.id AS total_visites"
],
'FROM'
=>
$table
,
'WHERE'
=>
$WHERE
,
...
...
@@ -1928,4 +1930,3 @@ class Stat extends CommonGLPI {
return
"fas fa-chart-bar"
;
}
}
inc/state.class.php
View file @
d47fa943
...
...
@@ -119,16 +119,21 @@ class State extends CommonTreeDropdown {
}
else
{
$table
=
getTableForItemType
(
$itemtype
);
$WHERE
=
[];
if
(
$item
->
maybeDeleted
())
{
$WHERE
[
"
$table
.is_deleted"
]
=
0
;
}
if
(
$item
->
maybeTemplate
())
{
$WHERE
[
"
$table
.is_template"
]
=
0
;
}
$WHERE
+=
getEntitiesRestrictCriteria
(
$table
);
$iterator
=
$DB
->
request
([
'SELECT'
=>
[
'states_id'
,
'COUNT'
=>
'* AS cpt'
],
'FROM'
=>
$table
,
'WHERE'
=>
[
'is_deleted'
=>
0
,
'is_template'
=>
0
]
+
getEntitiesRestrictCriteria
(
$table
),
'WHERE'
=>
$WHERE
,
'GROUP'
=>
'states_id'
]);
...
...
inc/ticket.class.php
View file @
d47fa943
...
...
@@ -5179,12 +5179,13 @@ class Ticket extends CommonITILObject {
);
break
;
case
"process"
:
// planned or assigned tickets
case
"process"
:
// planned or assigned
or incoming
tickets
$WHERE
=
array_merge
(
$WHERE
,
$search_assign
,
[
'glpi_tickets.status'
=>
self
::
getProcessStatusArray
()]
[
'glpi_tickets.status'
=>
array_merge
(
self
::
getProcessStatusArray
()
,
[
self
::
INCOMING
])
]
);
break
;
case
"toapprove"
:
//tickets waiting for approval
...
...
@@ -5359,6 +5360,7 @@ class Ticket extends CommonITILObject {
if
(
count
(
$JOINS
))
{
$criteria
=
array_merge_recursive
(
$criteria
,
$JOINS
);
}
$iterator
=
$DB
->
request
(
$criteria
);
$total_row_count
=
count
(
$iterator
);
$displayed_row_count
=
(
int
)
$_SESSION
[
'glpidisplay_count_on_home'
]
>
0
...
...
@@ -5410,15 +5412,32 @@ class Ticket extends CommonITILObject {
break
;
case
"process"
:
$options
[
'criteria'
][
0
][
'field'
]
=
12
;
// status
$options
[
'criteria'
][
0
][
'searchtype'
]
=
'equals'
;
$options
[
'criteria'
][
0
][
'value'
]
=
'process'
;
$options
[
'criteria'
][
0
][
'link'
]
=
'AND'
;
$options
[
'criteria'
][
1
][
'field'
]
=
8
;
// groups_id_assign
$options
[
'criteria'
][
1
][
'searchtype'
]
=
'equals'
;
$options
[
'criteria'
][
1
][
'value'
]
=
'mygroups'
;
$options
[
'criteria'
][
1
][
'link'
]
=
'AND'
;
$options
[
'criteria'
]
=
[
[
'field'
=>
8
,
'searchtype'
=>
'equals'
,
'value'
=>
'mygroups'
,
'link'
=>
'AND'
,
],
[
'link'
=>
'AND'
,
'criteria'
=>
[
[
'link'
=>
'AND'
,
'field'
=>
12
,
'searchtype'
=>
'equals'
,
'value'
=>
Ticket
::
INCOMING
,
],
[
'link'
=>
'OR'
,
'field'
=>
12
,
'searchtype'
=>
'equals'
,
'value'
=>
'process'
,
]
]
]
];
echo
"<a href=
\"
"
.
Ticket
::
getSearchURL
()
.
"?"
.
Toolbox
::
append_params
(
$options
,
'&'
)
.
"
\"
>"
.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment