├── .github
└── workflows
│ ├── generatemo.yml
│ ├── release.yml
│ └── updatepot.yml
├── ISSUE_TEMPLATE.md
├── LICENSE
├── README.md
├── ajax
├── addnewvalue.php
├── dropdownCommandValue.php
├── dropdownTrackingDeviceType.php
├── index.php
└── shellcommand.exec.php
├── front
├── advanced_execution.php
├── commandgroup.form.php
├── commandgroup.php
├── commandgroup_item.form.php
├── index.php
├── massiveexec.php
├── menu.php
├── shellcommand.form.php
├── shellcommand.php
├── shellcommandpath.form.php
└── shellcommandpath.php
├── hook.php
├── inc
├── advanced_execution.class.php
├── commandgroup.class.php
├── commandgroup_item.class.php
├── index.php
├── menu.class.php
├── profile.class.php
├── shellcommand.class.php
├── shellcommand_item.class.php
├── shellcommandpath.class.php
└── webservice.class.php
├── index.php
├── locales
├── cs_CZ.mo
├── cs_CZ.po
├── de_DE.mo
├── de_DE.po
├── en_GB.mo
├── en_GB.po
├── es_EC.po
├── es_ES.mo
├── es_ES.po
├── fr_FR.mo
├── fr_FR.po
├── glpi.pot
├── pl_PL.mo
├── pl_PL.po
├── pt_BR.mo
├── pt_BR.po
├── ro_RO.mo
├── ro_RO.po
├── ru_RU.mo
├── ru_RU.po
├── tr_TR.mo
└── tr_TR.po
├── pics
└── large-loading.gif
├── setup.php
├── shellcommands.css
├── shellcommands.js
├── shellcommands.png
├── shellcommands.xml
├── sql
├── empty-1.0.sql
├── empty-1.1.sql
├── empty-1.2.0.sql
├── empty-1.3.0.sql
├── empty-1.7.0.sql
├── empty-2.2.0.sql
├── empty-4.0.0.sql
├── update-1.1.sql
├── update-1.2.0.sql
├── update-1.3.0.sql
└── update-1.7.0.sql
└── tools
├── extract_template.sh
├── update_mo.pl
└── update_po.pl
/.github/workflows/generatemo.yml:
--------------------------------------------------------------------------------
1 | name: Generate MO
2 | on:
3 | push:
4 | branches: [ master ]
5 | paths:
6 | - '**.po'
7 | env:
8 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 | jobs:
10 | run:
11 |
12 | name: Generate mo
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout repo
16 | uses: actions/checkout@v2
17 |
18 | - name: Setup Perl environment
19 | # You may pin to the exact commit or the version.
20 | # uses: shogo82148/actions-setup-perl@8d2e3d59a9516b785ed32169d48a4888eaa9b514
21 | uses: shogo82148/actions-setup-perl@v1.7.2
22 | - name: msgfmt
23 | # You may pin to the exact commit or the version.
24 | # uses: whtsky/msgfmt-action@6b2181f051b002182d01a1e1f1aff216230c5a4d
25 | uses: whtsky/msgfmt-action@20190305
26 | - name: Generate mo
27 | run: perl tools/update_mo.pl;
28 |
29 | - name: Commit changes
30 | uses: EndBug/add-and-commit@v5.1.0
31 | with:
32 |
33 | message: "Generate mo"
34 | - name: Push changes
35 |
36 | uses: actions-go/push@v1
37 |
38 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 |
2 | on:
3 | push:
4 | # Sequence of patterns matched against refs/tags
5 | tags:
6 | - '*.*.*' # Push events to matching ex:20.15.10
7 |
8 | name: Create release with tag
9 | env:
10 | TAG_VALUE: ${GITHUB_REF/refs\/tags\//}
11 | jobs:
12 | build:
13 | name: Upload Release Asset
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Checkout code
17 | uses: actions/checkout@v2
18 | - name: Build project # This would actually build your project, using zip for an example artifact
19 | id: build_
20 | env:
21 | GITHUB_NAME: ${{ github.event.repository.name }}
22 |
23 |
24 | run: sudo apt-get install libxml-xpath-perl;echo $(xpath -e '/root/versions/version[num="'${GITHUB_REF/refs\/tags\//}'"]/compatibility/text()' $GITHUB_NAME.xml);echo ::set-output name=version_glpi::$(xpath -e '/root/versions/version[num="'${GITHUB_REF/refs\/tags\//}'"]/compatibility/text()' $GITHUB_NAME.xml); rm -rf $GITHUB_NAME.xml tools wiki screenshots test .git .github ISSUE_TEMPLATE.md TODO.txt $GITHUB_NAME.png;cd ..; tar jcvf glpi-$GITHUB_NAME-${GITHUB_REF/refs\/tags\//}.tar.bz2 $GITHUB_NAME;ls -al;echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//};echo ${{ steps.getxml.outputs.info }};
25 | # run: rm -rf $GITHUB_NAME.xml tools wiki screenshots test ISSUE_TEMPLATE.md TODO.txt $GITHUB_NAME.png; tar -zcvf glpi-$GITHUB_NAME-$GITHUB_TAG.tar.gz $GITHUB_NAME
26 | - name: Create Release
27 | id: create_release
28 | uses: actions/create-release@v1
29 | env:
30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 | with:
32 | tag_name: ${{ github.ref }}
33 | release_name: |
34 | GLPI ${{ steps.build_.outputs.version_glpi }} : Version ${{ github.ref }} disponible / available
35 | body : Version ${{ steps.build_.outputs.tag }} released for GLPI ${{ steps.build_.outputs.version_glpi }}
36 | draft: false
37 | prerelease: true
38 | - name: Upload Release Asset
39 | id: upload-release-asset
40 | uses: actions/upload-release-asset@v1
41 | env:
42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 | GITHUB_NAME: ${{ github.event.repository.name }}
44 | with:
45 | upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
46 | asset_path: /home/runner/work/${{ github.event.repository.name }}/glpi-${{ github.event.repository.name }}-${{ steps.build_.outputs.tag }}.tar.bz2
47 | asset_name: glpi-${{ github.event.repository.name }}-${{ steps.build_.outputs.tag }}.tar.bz2
48 | asset_content_type: application/zip
49 |
50 |
--------------------------------------------------------------------------------
/.github/workflows/updatepot.yml:
--------------------------------------------------------------------------------
1 | name: Update POT
2 | on:
3 | push:
4 | branches: [ master ]
5 | paths-ignore:
6 | - 'locales/**'
7 |
8 | env:
9 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 | jobs:
11 | run:
12 |
13 | name: Update POT
14 |
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: Checkout repo
18 | uses: actions/checkout@v2
19 |
20 | - name: install xgettext
21 |
22 | run: sudo apt-get install gettext;
23 | - name: Update POT
24 | run: sh tools/extract_template.sh;
25 |
26 |
27 | - name: Commit changes
28 | uses: EndBug/add-and-commit@v5.1.0
29 | with:
30 | message: "Update POT"
31 | - name: Push changes
32 |
33 | uses: actions-go/push@v1
34 |
35 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Dear GLPi user.
2 |
3 | BEFORE SUBMITTING YOUR ISSUE, please make sure to read and follow these steps :
4 |
5 | * Verify that your question has not already been asked
6 | * Please use the below template.
7 | * Delete this text before submiting your issue.
8 |
9 | The Plugin team.
10 |
11 | ------------
12 | * Version of the plugin :
13 |
14 |
15 | * Version of your GLPI :
16 |
17 |
18 | * Steps to reproduce (which actions have you made) :
19 |
20 |
21 | * Expected result :
22 |
23 |
24 | * Actual result :
25 |
26 |
27 | * URL of the page :
28 |
29 |
30 | * Screenshot of the problem (if pertinent) :
31 |
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # shellcommands
2 | Plugin shellcommands pour GLPI
3 |
4 | Ce plugin a été archivé. Vous pouvez utiliser le plugin centreon https://github.com/pluginsGLPI/centreon à la place pour lancer des checks
5 |
6 | This plugin has been archived. You can use the centreon plugin https://github.com/pluginsGLPI/centreon instead to run checks
7 |
--------------------------------------------------------------------------------
/ajax/addnewvalue.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 | header("Content-Type: text/html; charset=UTF-8");
32 | Html::header_nocache();
33 |
34 | Session::checkLoginUser();
35 |
36 | switch ($_POST['action']) {
37 | case 'add':
38 | PluginShellcommandsAdvanced_Execution::addNewValue($_POST['count']);
39 | break;
40 | }
41 |
42 | Html::ajaxFooter();
43 |
44 |
--------------------------------------------------------------------------------
/ajax/dropdownCommandValue.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | if (strpos($_SERVER['PHP_SELF'], "dropdownCommandValue.php")) {
31 | include('../../../inc/includes.php');
32 | header("Content-Type: text/html; charset=UTF-8");
33 | Html::header_nocache();
34 | }
35 |
36 | if (!defined('GLPI_ROOT')) {
37 | die("Can not acces directly to this file");
38 | }
39 |
40 | Session::checkLoginUser();
41 |
42 | // No define value
43 | if (!isset($_POST['value'])) {
44 | $_POST['value'] = '';
45 | }
46 |
47 | $tabValue = explode('-', $_POST['value']);
48 | $dbu = new DbUtils();
49 | // Security
50 | if (!($item = $dbu->getItemForItemtype($_POST['itemtype'])) || sizeof($tabValue) < 2) {
51 | exit();
52 | }
53 |
54 | $link = $tabValue[0];
55 | $shellId = $tabValue[1];
56 |
57 | $item->getFromDB($_POST['itemID']);
58 | $shell_item = $dbu->getItemForItemtype($_POST['command_type']);
59 | $shell_item->getFromDB($shellId);
60 | $foreign_key = $shell_item->getForeignKeyField();
61 |
62 | $displaywith = false;
63 |
64 | if (isset($_POST['displaywith'])
65 | && is_array($_POST['displaywith'])
66 | && count($_POST['displaywith'])) {
67 |
68 | $displaywith = true;
69 | }
70 |
71 | // No define rand
72 | if (!isset($_POST['rand'])) {
73 | $_POST['rand'] = mt_rand();
74 | }
75 |
76 | if (isset($_POST['condition']) && !empty($_POST['condition'])) {
77 | $_POST['condition'] = rawurldecode(stripslashes($_POST['condition']));
78 | }
79 |
80 | if (!isset($_POST['emptylabel']) || $_POST['emptylabel'] == '') {
81 | $_POST['emptylabel'] = Dropdown::EMPTY_VALUE;
82 | }
83 |
84 | switch ($_POST['myname']) {
85 | case "command_name":
86 | // NAME
87 | if (strstr($link, '[NAME]')) {
88 | $tLink = str_replace("[NAME]", $item->getField('name'), $link);
89 | $shellExecute = "onClick='shellcommandsActions(\"" . PLUGIN_SHELLCOMMANDS_WEBDIR . "\", \"" . $_POST['toupdate'] . "\",
90 | " . json_encode(['id' => $shell_item->getID(),
91 | 'command_type' => $_POST['command_type'],
92 | 'itemID' => $_POST['itemID'],
93 | 'itemtype' => $_POST['itemtype'],
94 | 'value' => $tLink]) . ");'";
95 |
96 | // DOMAIN
97 | } else if (strstr($link, '[ID]')) {
98 | $tLink = str_replace("[ID]", $item->getID(), $link);
99 | $shellExecute = "onClick='shellcommandsActions(\"" . PLUGIN_SHELLCOMMANDS_WEBDIR . "\", \"" . $_POST['toupdate'] . "\",
100 | " . json_encode(['id' => $shell_item->getID(),
101 | 'command_type' => $_POST['command_type'],
102 | 'itemID' => $_POST['itemID'],
103 | 'itemtype' => $_POST['itemtype'],
104 | 'value' => $tLink]) . ");'";
105 |
106 | // DOMAIN
107 | } else if (strstr($link, '[DOMAIN]')) {
108 | if (isset($item->fields['domains_id'])) {
109 | $tLink = str_replace("[DOMAIN]", Dropdown::getDropdownName("glpi_domains", $item->getField('domains_id')), $link);
110 | $shellExecute = "onClick='shellcommandsActions(\"" . PLUGIN_SHELLCOMMANDS_WEBDIR . "\" , \"" . $_POST['toupdate'] . "\",
111 | " . json_encode(['id' => $shell_item->getID(),
112 | 'command_type' => $_POST['command_type'],
113 | 'itemID' => $_POST['itemID'],
114 | 'itemtype' => $_POST['itemtype'],
115 | 'value' => $tLink]) . ");'";
116 | }
117 |
118 | // IP or MAC
119 | } else if (strstr($link, '[IP]') || strstr($link, '[MAC]')) {
120 | $ip = [];
121 | $mac = [];
122 | $resultSelectCommand[0] = Dropdown::EMPTY_VALUE;
123 | $ipCount = 0;
124 | $macCount = 0;
125 |
126 | // if ($_POST['searchText'] != $CFG_GLPI["ajax_wildcard"]) {// if search text is called (ajax dropdown)
127 | // $where = " AND `glpi_networkports`.`name` ".Search::makeTextSearch($_POST['searchText']);
128 | // } else {
129 | $where = '';
130 | // }
131 | //
132 | // We search all ip and mac addresses
133 | $query2 = "SELECT `glpi_networkports`.*, `glpi_ipaddresses`.`name` as ip
134 | FROM `glpi_networkports`
135 | LEFT JOIN `glpi_networknames`
136 | ON (`glpi_networknames`.`items_id`=`glpi_networkports`.`id`)
137 | LEFT JOIN `glpi_ipaddresses`
138 | ON (`glpi_networknames`.`id`=`glpi_ipaddresses`.`items_id`)
139 | WHERE `glpi_networkports`.`items_id` = '" . $_POST['itemID'] . "'
140 | $where
141 | AND `glpi_networkports`.`itemtype` = '" . $item->getType() . "'
142 | ORDER BY `glpi_networkports`.`logical_number`";
143 |
144 | $result2 = $DB->query($query2);
145 |
146 | if ($DB->numrows($result2) > 0) {
147 | while ($data2 = $DB->fetchArray($result2)) {
148 | if ((!empty($data2["ip"]) && $data2["ip"] != '0.0.0.0')) {
149 | if (!empty($data2["name"])) {
150 | $ip[$ipCount]['name'] = $data2["name"];
151 | } else {
152 | $ip[$ipCount]['name'] = '(' . __('Network port') . ' ' . $data2["id"] . ')';
153 | }
154 | $ip[$ipCount]['ip'] = $data2["ip"];
155 | $ipCount++;
156 | }
157 | if (!empty($data2["mac"])) {
158 | if (!empty($data2["name"])) {
159 | $mac[$macCount]['name'] = $data2["name"];
160 | } else {
161 | $mac[$macCount]['name'] = '(' . __('Network port') . ' ' . $data2["id"] . ')';
162 | }
163 | $mac[$macCount]['mac'] = $data2["mac"];
164 | $macCount++;
165 | }
166 | }
167 | }
168 |
169 | // Add IP internal switch
170 | if (strstr($link, '[IP]')) {
171 | if ($item->getType() == 'NetworkEquipment') {
172 | $shellExecute = "onClick='shellcommandsActions(\"" . PLUGIN_SHELLCOMMANDS_WEBDIR . "\", \"" . $_POST['toupdate'] . "\",
173 | " . json_encode(['id' => $shell_item->getID(),
174 | 'command_type' => $_POST['command_type'],
175 | 'itemID' => $_POST['itemID'],
176 | 'itemtype' => $_POST['itemtype'],
177 | 'value' => $item->getField('ip')]) . ");'";
178 | }
179 |
180 | if ($ipCount > 0) {
181 | foreach ($ip as $key => $val) {
182 | $resultSelectCommand['IP-' . $shell_item->getId() . '-' . $val['ip'] . '-' . $key] = $val['ip'] . ' - ' . $val['name'];
183 | }
184 | }
185 | }
186 |
187 | // Add MAC internal switch
188 | if (strstr($link, '[MAC]')) {
189 | if ($item->getType() == 'NetworkEquipment') {
190 | $shellExecute = "onClick='shellcommandsActions(\"" . PLUGIN_SHELLCOMMANDS_WEBDIR . "\", \"" . $_POST['toupdate'] . "\",
191 | " . json_encode(['id' => $shell_item->getID(),
192 | 'command_type' => $_POST['command_type'],
193 | 'itemID' => $_POST['itemID'],
194 | 'itemtype' => $_POST['itemtype'],
195 | 'value' => $item->getField('mac')]) . ");'";
196 | }
197 | if ($macCount > 0) {
198 | foreach ($mac as $key => $val) {
199 | $resultSelectCommand['MAC-' . $shell_item->getId() . '-' . $val['mac'] . '-' . $key] = $val['mac'] . ' - ' . $val['name'];
200 | }
201 | }
202 | }
203 | }
204 |
205 | echo " ";
206 |
207 | if (isset($resultSelectCommand) && sizeof($resultSelectCommand) > 0) {
208 | $randSelect = Dropdown::showFromArray("ip", $resultSelectCommand, ['width' => $_POST['width']]);
209 | Ajax::updateItemOnSelectEvent("dropdown_ip$randSelect", "command_ip$randSelect", PLUGIN_SHELLCOMMANDS_WEBDIR . "/ajax/dropdownCommandValue.php",
210 | ['idtable' => 'NetworkPort',
211 | 'value' => '__VALUE__',
212 | 'itemID' => $_POST['itemID'],
213 | 'itemtype' => $item->getType(),
214 | 'command_type' => $_POST['command_type'],
215 | 'toupdate' => $_POST['toupdate'],
216 | 'myname' => "command_ip"]);
217 |
218 | echo "";
219 |
220 | } else if (isset($shellExecute)) {
221 | echo "";
222 | }
223 |
224 | break;
225 |
226 | case "command_ip":
227 | $ipmac = $tabValue[2];
228 |
229 | $shellExecute = "onClick='shellcommandsActions(\"" . PLUGIN_SHELLCOMMANDS_WEBDIR . "\", \"" . $_POST['toupdate'] . "\",
230 | " . json_encode(['id' => $shell_item->getID(),
231 | 'command_type' => $_POST['command_type'],
232 | 'itemID' => $_POST['itemID'],
233 | 'itemtype' => $_POST['itemtype'],
234 | 'value' => $ipmac]) . ");'";
235 | echo " ";
236 | echo "";
237 | break;
238 | }
239 |
240 |
241 | //if (isset($_POST["comment"]) && $_POST["comment"]) {
242 | // $paramscomment = ['value' => '__VALUE__', 'table' => $table];
243 | // Ajax::updateItemOnSelectEvent("dropdown_" . $_POST["myname"] . $_POST["rand"],
244 | // "comment_" . $_POST["myname"] . $_POST["rand"],
245 | // $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment);
246 | //}
247 |
248 | Ajax::commonDropdownUpdateItem($_POST);
249 |
--------------------------------------------------------------------------------
/ajax/dropdownTrackingDeviceType.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 | header("Content-Type: text/html; charset=UTF-8");
32 | Html::header_nocache();
33 |
34 | Session::checkLoginUser();
35 |
36 | $itemtype = $_POST["itemtype"] ?? '';
37 |
38 | // Make a select box
39 | if (isset($_POST["itemtype"])
40 | && CommonITILObject::isPossibleToAssignType($_POST["itemtype"])) {
41 | $dbu = new DbUtils();
42 | $table = $dbu->getTableForItemType($_POST["itemtype"]);
43 | $rand = mt_rand();
44 |
45 | // Message for post-only
46 | if (!isset($_POST["admin"]) || ($_POST["admin"] == 0)) {
47 | echo __('Enter the first letters (user, item name, serial or asset number)');
48 | }
49 | echo " ";
50 | $field_id = Html::cleanId("dropdown_" . $_POST['myname'] . $rand);
51 |
52 | $p = ['itemtype' => $_POST["itemtype"],
53 | 'entity_restrict' => $_POST['entity_restrict'],
54 | 'table' => $table,
55 | 'width' => $_POST["width"],
56 | 'myname' => $_POST["myname"],
57 | '_idor_token' => Session::getNewIDORToken($itemtype, [
58 | 'entity_restrict' => $_POST['entity_restrict'],
59 | ]),
60 | ];
61 |
62 | echo Html::jsAjaxDropdown($_POST['myname'], $field_id,
63 | $CFG_GLPI['root_doc'] . "/ajax/getDropdownFindNum.php",
64 | $p);
65 | // Auto update summary of active or just solved tickets
66 | $params = ['items_id' => '__VALUE__',
67 | 'itemtype' => $_POST['itemtype']];
68 |
69 | Ajax::updateItemOnSelectEvent($field_id, "item_ticket_selection_information",
70 | $CFG_GLPI["root_doc"] . "/ajax/ticketiteminformation.php",
71 | $params);
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/ajax/index.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
--------------------------------------------------------------------------------
/ajax/shellcommand.exec.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include("../../../inc/includes.php");
31 |
32 | Session::checkLoginUser();
33 |
34 | $command = new PluginShellcommandsShellcommand();
35 | $command_item = new PluginShellcommandsShellcommand_Item();
36 |
37 | $command->checkGlobal(READ);
38 |
39 | header("Content-Type: text/html; charset=UTF-8");
40 |
41 | switch ($_POST['command_type']) {
42 | case 'PluginShellcommandsShellcommand' :
43 | PluginShellcommandsShellcommand_Item::lauchCommand($_POST);
44 | break;
45 | case 'PluginShellcommandsCommandGroup' :
46 | PluginShellcommandsCommandGroup_Item::lauchCommand($_POST);
47 | break;
48 | case 'PluginShellcommandsAdvanced_Execution' :
49 | PluginShellcommandsAdvanced_Execution::lauchCommand($_POST);
50 | //Toolbox::logDebug($_POST);
51 | break;
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/front/advanced_execution.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | Html::header(PluginShellcommandsAdvanced_Execution::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "advanced_execution");
33 |
34 | $advanced_execution = new PluginShellcommandsAdvanced_Execution();
35 | if ($advanced_execution->canView() || Session::haveRight("config", UPDATE)) {
36 | $advanced_execution->showForm();
37 |
38 | } else {
39 | Html::displayRightError();
40 | }
41 |
42 | Html::footer();
43 |
--------------------------------------------------------------------------------
/front/commandgroup.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | if (empty($_GET["id"])) {
33 | $_GET["id"] = "";
34 | }
35 |
36 | $commandgroup = new PluginShellcommandsCommandGroup();
37 |
38 | if (isset($_POST["add"])) {
39 | // Check add rights for fields
40 | $commandgroup->check(-1, UPDATE, $_POST);
41 | $commandgroup->add($_POST);
42 |
43 | Html::back();
44 |
45 | } else if (isset($_POST["update"])) {
46 | // Check update rights for fields
47 | $commandgroup->check($_POST['id'], UPDATE, $_POST);
48 | $commandgroup->update($_POST);
49 |
50 | Html::back();
51 |
52 | } else if (isset($_POST["delete"])) {
53 | // Check delete rights for fields
54 | $commandgroup->check($_POST['id'], UPDATE, $_POST);
55 | $commandgroup->delete($_POST, 1);
56 | $commandgroup->redirectToList();
57 |
58 | } else {
59 | $commandgroup->checkGlobal(READ);
60 | Html::header(PluginShellcommandsCommandGroup::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "commandgroup");
61 | $commandgroup->display(['id' => $_GET["id"]]);
62 | Html::footer();
63 | }
64 |
--------------------------------------------------------------------------------
/front/commandgroup.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | Html::header(PluginShellcommandsCommandGroup::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "commandgroup");
33 |
34 | $command = new PluginShellcommandsCommandGroup();
35 | if ($command->canView() || Session::haveRight("config", UPDATE)) {
36 | Search::show("PluginShellcommandsCommandGroup");
37 | } else {
38 | Html::displayRightError();
39 | }
40 |
41 | Html::footer();
42 |
--------------------------------------------------------------------------------
/front/commandgroup_item.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | $group_item = new PluginShellcommandsCommandGroup_Item();
33 |
34 | if (isset($_POST["add"])) {
35 | $group_item->check(-1, UPDATE, $_POST);
36 | $group_item->add($_POST);
37 | Html::back();
38 |
39 | } else if (isset($_POST["up"]) || isset($_POST["up_x"])) {
40 | $group_item->orderItem($_POST, 'up');
41 | Html::back();
42 |
43 | } else if (isset($_POST["down"]) || isset($_POST["down_x"])) {
44 | $group_item->orderItem($_POST, 'down');
45 | Html::back();
46 | }
47 |
--------------------------------------------------------------------------------
/front/index.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
--------------------------------------------------------------------------------
/front/massiveexec.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 | include('../../../inc/includes.php');
30 |
31 | Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "shellcommand");
32 |
33 | $ma = $_SESSION["plugin_shellcommands"]["massiveaction"];
34 | unset($_SESSION["plugin_shellcommands"]["massiveaction"]);
35 |
36 | $ids = $_SESSION["plugin_shellcommands"]["ids"];
37 | unset($_SESSION["plugin_shellcommands"]["ids"]);
38 |
39 | // Launch massive action
40 | $dbu = new DbUtils();
41 | $processor = $dbu->getItemForItemtype($ma->processor);
42 | $processor->doMassiveAction($ma, $ids);
43 |
44 | Html::footer();
45 |
--------------------------------------------------------------------------------
/front/menu.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
33 | Html::header(PluginShellcommandsMenu::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand");
34 | } else {
35 | Html::helpHeader(PluginShellcommandsMenu::getTypeName(2));
36 | }
37 |
38 | $menu = new PluginShellcommandsMenu();
39 | $menu->showMenu();
40 |
41 | if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
42 | Html::footer();
43 | } else {
44 | Html::helpFooter();
45 | }
46 |
--------------------------------------------------------------------------------
/front/shellcommand.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | if (!isset($_GET["id"])) {
33 | $_GET["id"] = "";
34 | }
35 | if (!isset($_GET["withtemplate"])) {
36 | $_GET["withtemplate"] = "";
37 | }
38 |
39 | $command = new PluginShellcommandsShellcommand();
40 | $command_item = new PluginShellcommandsShellcommand_Item();
41 |
42 | if (isset($_POST["add"])) {
43 | $command->check(-1, UPDATE, $_POST);
44 | $newID = $command->add($_POST);
45 | Html::back();
46 |
47 | } else if (isset($_POST["update"])) {
48 | $command->check($_POST['id'], UPDATE);
49 | $command->update($_POST);
50 | Html::back();
51 |
52 | } else if (isset($_POST["additem"])) {
53 | if (!empty($_POST['itemtype'])) {
54 | if ($command->canCreate()) {
55 | $command_item->addItem($_POST["plugin_shellcommands_shellcommands_id"], $_POST['itemtype']);
56 | }
57 | }
58 | Html::back();
59 |
60 | } else if (isset($_POST["deleteitem"])) {
61 | if ($command->canCreate()) {
62 | $command_item->delete(['id' => $_POST["id"]]);
63 | }
64 | Html::back();
65 |
66 | } else {
67 | $command->checkGlobal(READ);
68 | Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "shellcommand");
69 | $command->display(['id' => $_GET["id"]]);
70 | Html::footer();
71 | }
72 |
--------------------------------------------------------------------------------
/front/shellcommand.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "shellcommand");
33 |
34 | $command = new PluginShellcommandsShellcommand();
35 | if ($command->canView() || Session::haveRight("config", UPDATE)) {
36 |
37 | Search::show("PluginShellcommandsShellcommand");
38 | } else {
39 | Html::displayRightError();
40 | }
41 |
42 | Html::footer();
43 |
--------------------------------------------------------------------------------
/front/shellcommandpath.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | $dropdown = new PluginShellcommandsShellcommandPath();
33 | include(GLPI_ROOT . "/front/dropdown.common.form.php");
34 |
35 |
--------------------------------------------------------------------------------
/front/shellcommandpath.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | include('../../../inc/includes.php');
31 |
32 | $dropdown = new PluginShellcommandsShellcommandPath();
33 | include(GLPI_ROOT . "/front/dropdown.common.php");
34 |
35 |
--------------------------------------------------------------------------------
/hook.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | function plugin_shellcommands_install()
31 | {
32 | global $DB;
33 |
34 | include_once(PLUGIN_SHELLCOMMANDS_DIR . "/inc/profile.class.php");
35 |
36 | $update = false;
37 | if (!$DB->tableExists("glpi_plugin_cmd_profiles")
38 | && !$DB->tableExists("glpi_plugin_shellcommands_shellcommands")) {
39 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/empty-4.0.0.sql");
40 | } elseif ($DB->tableExists("glpi_plugin_cmd_profiles")
41 | && !$DB->tableExists("glpi_plugin_cmd_path")) {
42 | $update = true;
43 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.1.sql");
44 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.2.0.sql");
45 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.3.0.sql");
46 | } elseif ($DB->tableExists("glpi_plugin_cmd_profiles")
47 | && $DB->fieldExists("glpi_plugin_cmd_profiles", "interface")) {
48 | $update = true;
49 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.2.0.sql");
50 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.3.0.sql");
51 | } elseif (!$DB->tableExists("glpi_plugin_shellcommands_shellcommands")) {
52 | $update = true;
53 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.3.0.sql");
54 | } elseif (!$DB->tableExists("glpi_plugin_shellcommands_commandgroups")) {
55 | $DB->runFile(PLUGIN_SHELLCOMMANDS_DIR . "/sql/update-1.7.0.sql");
56 | }
57 |
58 | if ($update) {
59 | $query_ = "SELECT *
60 | FROM `glpi_plugin_shellcommands_profiles` ";
61 | $result_ = $DB->query($query_);
62 | if ($DB->numrows($result_) > 0) {
63 | while ($data = $DB->fetchArray($result_)) {
64 | $query = "UPDATE `glpi_plugin_shellcommands_profiles`
65 | SET `profiles_id` = '" . $data["id"] . "'
66 | WHERE `id` = '" . $data["id"] . "';";
67 | $DB->query($query);
68 | }
69 | }
70 |
71 | $query = "ALTER TABLE `glpi_plugin_shellcommands_profiles`
72 | DROP `name` ;";
73 | $DB->query($query);
74 | }
75 |
76 | PluginShellcommandsProfile::initProfile();
77 | PluginShellcommandsProfile::createfirstAccess($_SESSION['glpiactiveprofile']['id']);
78 | $migration = new Migration("1.9.1");
79 | $migration->dropTable('glpi_plugin_shellcommands_profiles');
80 |
81 | return true;
82 | }
83 |
84 | function plugin_shellcommands_uninstall()
85 | {
86 | global $DB;
87 |
88 | $tables = [
89 | "glpi_plugin_shellcommands_shellcommands",
90 | "glpi_plugin_shellcommands_shellcommands_items",
91 | "glpi_plugin_shellcommands_commandgroups",
92 | "glpi_plugin_shellcommands_commandgroups_items",
93 | "glpi_plugin_shellcommands_profiles",
94 | "glpi_plugin_shellcommands_shellcommandpaths"
95 | ];
96 |
97 | foreach ($tables as $table) {
98 | $DB->query("DROP TABLE IF EXISTS `$table`;");
99 | }
100 |
101 | //old versions
102 | $tables = [
103 | "glpi_plugin_cmd",
104 | "glpi_plugin_cmd_device",
105 | "glpi_plugin_cmd_setup",
106 | "glpi_plugin_cmd_profiles",
107 | "glpi_plugin_cmd_path"
108 | ];
109 |
110 | foreach ($tables as $table) {
111 | $DB->query("DROP TABLE IF EXISTS `$table`;");
112 | }
113 |
114 | $tables_glpi = [
115 | "glpi_displaypreferences",
116 | "glpi_savedsearches"
117 | ];
118 |
119 | foreach ($tables_glpi as $table_glpi) {
120 | $DB->query("DELETE FROM `$table_glpi` WHERE `itemtype` = 'PluginShellcommandsShellcommand';");
121 | }
122 |
123 | include_once(PLUGIN_SHELLCOMMANDS_DIR . "/inc/profile.class.php");
124 |
125 | PluginShellcommandsProfile::removeRightsFromSession();
126 | PluginShellcommandsProfile::removeRightsFromDB();
127 |
128 | return true;
129 | }
130 |
131 | // Define dropdown relations
132 | function plugin_shellcommands_getDatabaseRelations()
133 | {
134 | if (Plugin::isPluginActive("shellcommands")) {
135 | return [
136 | "glpi_plugin_shellcommands_shellcommandpaths" => ["glpi_plugin_shellcommands_shellcommands" => "plugin_shellcommands_shellcommandpaths_id"],
137 | "glpi_profiles" => ["glpi_plugin_shellcommands_profiles" => "profiles_id"],
138 | "glpi_plugin_shellcommands_shellcommands" => ["glpi_plugin_shellcommands_shellcommands_items" => "plugin_shellcommands_shellcommands_id"],
139 | "glpi_plugin_shellcommands_shellcommands" => ["glpi_plugin_shellcommands_commandgroups_items" => "plugin_shellcommands_shellcommands_id"],
140 | "glpi_plugin_shellcommands_commandgroups" => ["glpi_plugin_shellcommands_commandgroups_items" => "plugin_shellcommands_commandgroups_id"],
141 | "glpi_entities" => ["glpi_plugin_shellcommands_shellcommands" => "entities_id"]
142 | ];
143 | } else {
144 | return [];
145 | }
146 | }
147 |
148 | // Define Dropdown tables to be manage in GLPI :
149 | function plugin_shellcommands_getDropdown()
150 | {
151 | if (Plugin::isPluginActive("shellcommands")) {
152 | return ['PluginShellcommandsShellcommandPath' => __('Path', 'shellcommands')];
153 | } else {
154 | return [];
155 | }
156 | }
157 |
158 | function plugin_shellcommands_postinit()
159 | {
160 | foreach (PluginShellcommandsShellcommand::getTypes(true) as $type) {
161 | CommonGLPI::registerStandardTab($type, 'PluginShellcommandsShellcommand_Item');
162 | }
163 | }
164 |
165 | /**
166 | * Register methods for Webservices plugin (if available)
167 | *
168 | * @return void
169 | */
170 | function plugin_shellcommands_registerWebservicesMethods()
171 | {
172 | global $WEBSERVICES_METHOD;
173 |
174 | if (Plugin::isPluginActive('webservices')) { // If webservices plugin is active
175 | $WEBSERVICES_METHOD['shellcommands.list'] = ['PluginShellcommandsWebservice', 'methodList'];
176 | $WEBSERVICES_METHOD['shellcommands.run'] = ['PluginShellcommandsWebservice', 'methodRun'];
177 | }
178 | }
179 |
180 |
181 | //display custom fields in the search
182 | function plugin_shellcommands_giveItem($type, $ID, $data, $num)
183 | {
184 | global $DB;
185 | $searchopt = &Search::getOptions($type);
186 | $table = $searchopt[$ID]["table"];
187 | $field = $searchopt[$ID]["field"];
188 | switch ($table . '.' . $field) {
189 | //display associated items with shellcommands
190 | case "glpi_plugin_shellcommands_shellcommands_items.itemtype" :
191 | $rows = $DB->request([
192 | 'SELECT' => 'itemtype',
193 | 'DISTINCT' => true,
194 | 'FROM' => 'glpi_plugin_shellcommands_shellcommands_items',
195 | 'WHERE' => ['plugin_shellcommands_shellcommands_id' => $data['id']],
196 | 'ORDERBY' => 'itemtype'
197 | ]);
198 | $out = '';
199 | foreach ($rows as $row) {
200 | $itemtype = $row['itemtype'];
201 | $item = new $itemtype();
202 | if (!class_exists($itemtype)) {
203 | continue;
204 | }
205 | $out .= $item->getTypeName() . " ";
206 | }
207 | return $out;
208 |
209 | break;
210 | }
211 | return "";
212 | }
213 |
214 | //force groupby for multible links to items
215 | function plugin_shellcommands_forceGroupBy($type)
216 | {
217 | return true;
218 | switch ($type) {
219 | case 'PluginShellcommandsShellcommand':
220 | return true;
221 | break;
222 | }
223 | return false;
224 | }
225 |
226 | function plugin_shellcommands_MassiveActions($type)
227 | {
228 | if (Plugin::isPluginActive("shellcommands")) {
229 | if (in_array($type, PluginShellcommandsShellcommand::getTypes(true))) {
230 | return [
231 | 'PluginShellcommandsShellcommand' . MassiveAction::CLASS_ACTION_SEPARATOR . "generate" => __(
232 | 'Command launch',
233 | 'shellcommands'
234 | ),
235 | 'PluginShellcommandsCommandGroup' . MassiveAction::CLASS_ACTION_SEPARATOR . "generate" => __(
236 | 'Command group launch',
237 | 'shellcommands'
238 | )
239 | ];
240 | }
241 | }
242 | return [];
243 | }
244 |
245 |
--------------------------------------------------------------------------------
/inc/advanced_execution.class.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | if (!defined('GLPI_ROOT')) {
31 | die("Sorry. You can't access directly to this file");
32 | }
33 |
34 | class PluginShellcommandsAdvanced_Execution extends CommonDBTM {
35 |
36 | public $dohistory = true;
37 | static $rightname = 'plugin_shellcommands';
38 |
39 | public static function getTypeName($nb = 0) {
40 | return _n('Advanced execution', 'Advanced executions', $nb, 'shellcommands');
41 | }
42 |
43 | static function canView() {
44 | return Session::haveRight(self::$rightname, READ);
45 | }
46 |
47 | static function canCreate() {
48 | return Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, DELETE]);
49 | }
50 |
51 | /**
52 | * Show form
53 | *
54 | * @global type $CFG_GLPI
55 | *
56 | * @param type $ID
57 | * @param type $options
58 | */
59 | function showForm($ID = 0, $options = []) {
60 | global $CFG_GLPI;
61 |
62 | echo "