├── LICENSE ├── README.md ├── front ├── phoneoperator.form.php ├── phoneoperator.php ├── profile.form.php ├── simcard.form.php ├── simcard.php ├── simcard_item.form.php ├── simcardsize.form.php ├── simcardsize.php ├── simcardtype.form.php ├── simcardtype.php ├── simcardvoltage.form.php └── simcardvoltage.php ├── hook.php ├── inc ├── config.class.php ├── phoneoperator.class.php ├── profile.class.php ├── simcard.class.php ├── simcard_item.class.php ├── simcardinjection.class.php ├── simcardsize.class.php ├── simcardtype.class.php └── simcardvoltage.class.php ├── locales ├── en_GB.mo ├── en_GB.po ├── es_ES.mo ├── es_ES.po ├── fr_FR.mo ├── fr_FR.po ├── ru_RU.mo ├── ru_RU.po ├── simcard.pot ├── sv_SE.mo └── sv_SE.po ├── setup.php ├── simcard.png ├── simcard.xml └── tools ├── HEADER ├── extract_template.sh ├── modify_headers.pl ├── move_to_po.php ├── update_mo.pl └── update_po.pl /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 | 294 | Copyright (C) 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 | , 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Simcard management for GLPI 2 | =========================== 3 | 4 | * Created bt Walid Nouh for GLPi 0.83 5 | * Updated by Anthony Piesset and Dethegeek for GLPi 0.84 6 | * Updated by Thierry Bugier Pineau for GLPi 0.85 and 0.90 7 | 8 | Integration in GLPI 9.2 9 | ----------------------- 10 | 11 | Simcards will be available as a new component in GLPI 9.2. Therefore, for fresh installations of GLPI 9.2, this plugin becomes useless. 12 | 13 | 14 | Installation (en) 15 | ----------------- 16 | 17 | * Download from: https://github.com/pluginsGLPI/simcard/releases 18 | * Uncompress in your `glpi/plugins` directory 19 | * Install, enable and configure from `http://yourglpiaddress.com` from Configuration > Plugins section. 20 | 21 | Installation (fr) 22 | ----------------- 23 | 24 | * Téléchargez depuis : https://github.com/pluginsGLPI/simcard/releases 25 | * Décompressez dans votre dossier `glpi/plugins` 26 | * Installez, activez et configurez sur `http://votreadresseglpi.fr` dans la section Configuration > Plugins 27 | 28 | Contributing 29 | ------------ 30 | 31 | * Open a ticket for each bug/feature so it can be discussed 32 | * Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins/index.html) 33 | * Refer to [GitFlow](http://git-flow.readthedocs.io/) process for branching 34 | * Work on a new branch on your own fork 35 | * Open a PR that will be reviewed by a developer 36 | -------------------------------------------------------------------------------- /front/phoneoperator.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardPhoneOperator(); 34 | include (GLPI_ROOT . "/front/dropdown.common.form.php"); 35 | -------------------------------------------------------------------------------- /front/phoneoperator.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardPhoneOperator(); 34 | include (GLPI_ROOT . "/front/dropdown.common.php"); 35 | -------------------------------------------------------------------------------- /front/profile.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | Profile::canView(); 34 | 35 | $profile = new PluginSimcardProfile(); 36 | 37 | //Save profile 38 | if (isset ($_POST['update'])) { 39 | $profile->update($_POST); 40 | } 41 | Html::back(); 42 | -------------------------------------------------------------------------------- /front/simcard.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | PluginSimcardSimcard::canView(); 34 | 35 | if (!isset($_GET["id"])) { 36 | $_GET["id"] = ""; 37 | } 38 | 39 | if (!isset($_GET["sort"])) { 40 | $_GET["sort"] = ""; 41 | } 42 | 43 | if (!isset($_GET["order"])) { 44 | $_GET["order"] = ""; 45 | } 46 | 47 | if (!isset($_GET["withtemplate"])) { 48 | $_GET["withtemplate"] = ""; 49 | } 50 | 51 | $simcard = new PluginSimcardSimcard(); 52 | //Add a new simcard 53 | if (isset($_POST["add"])) { 54 | $simcard->check(-1, CREATE, $_POST); 55 | if ($newID = $simcard->add($_POST)) { 56 | Event::log($newID, "simcard", 4, "inventory", 57 | sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); 58 | } 59 | Html::back(); 60 | 61 | // delete a simcard 62 | } else if (isset($_POST["delete"])) { 63 | $simcard->check($_POST['id'], DELETE); 64 | $ok = $simcard->delete($_POST); 65 | if ($ok) { 66 | Event::log($_POST["id"], "simcard", 4, "inventory", 67 | //TRANS: %s is the user login 68 | sprintf(__('%s deletes an item'), $_SESSION["glpiname"])); 69 | } 70 | $simcard->redirectToList(); 71 | 72 | } else if (isset($_POST["restore"])) { 73 | $simcard->check($_POST['id'], PURGE); 74 | if ($simcard->restore($_POST)) { 75 | Event::log($_POST["id"],"simcard", 4, "inventory", 76 | //TRANS: %s is the user login 77 | sprintf(__('%s restores the item'), $_SESSION["glpiname"])); 78 | } 79 | $simcard->redirectToList(); 80 | 81 | } else if (isset($_REQUEST["purge"])) { 82 | $simcard->check($_REQUEST['id'], PURGE); 83 | if ($simcard->delete($_REQUEST, 1)) { 84 | Event::log($_POST["id"], "simcard", 4, "inventory", 85 | //TRANS: %s is the user login 86 | sprintf(__('%s purges an item'), $_SESSION["glpiname"])); 87 | } 88 | $simcard->redirectToList(); 89 | 90 | //update a simcard 91 | } else if (isset($_POST["update"])) { 92 | $simcard->check($_POST['id'], UPDATE); 93 | $simcard->update($_POST); 94 | Event::log($_POST["id"], "simcard", 4, "inventory", 95 | //TRANS: %s is the user login 96 | sprintf(__('%s updates an item'), $_SESSION["glpiname"])); 97 | Html::back(); 98 | 99 | } else if (isset($_GET["unglobalize"])) { 100 | $simcard->check($_GET["id"], UPDATE); 101 | 102 | //TODO There is probably a bug here... 103 | Html::redirect(Toolbox::getItemTypeFormURL('PluginSimcardSimcard')."?id=".$_GET["id"]); 104 | 105 | } else {//print simcard information 106 | // Affichage du fil d'Ariane 107 | Html::header(PluginSimcardSimcard::getTypeName(2), '', "assets", "pluginsimcardsimcard", "simcard"); 108 | 109 | //show simcard form to add 110 | $simcard->display(array('id' => $_GET["id"], 111 | 'withtemplate' => $_GET["withtemplate"])); 112 | html::footer(); 113 | } 114 | -------------------------------------------------------------------------------- /front/simcard.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | // Affichage du fil d'Ariane 34 | Html::header(PluginSimcardSimcard::getTypeName(2), '', "assets", "pluginsimcardsimcard", "simcard"); 35 | 36 | $simcard = new PluginSimcardSimcard(); 37 | // TODO Is Checking canCreate useful before showing a list ? 38 | if (PluginSimcardSimcard::canView() || PluginSimcardSimcard::canCreate()) { 39 | Search::show("PluginSimcardSimcard"); 40 | } else { 41 | echo "


\"warning\"

"; 43 | echo "".__s('Access denied')."
"; 44 | } 45 | 46 | Html::footer(); 47 | -------------------------------------------------------------------------------- /front/simcard_item.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | PluginSimcardSimcard::canUpdate(); 34 | 35 | $simcard_item = new PluginSimcardSimcard_Item(); 36 | if (isset($_POST["additem"])) { 37 | $simcard_item->can(-1, CREATE, $_POST); 38 | if ($newID = $simcard_item->add($_POST)) { 39 | } 40 | } else if (isset($_POST["delete_items"])) { 41 | if (isset($_POST['todelete'])) { 42 | foreach ($_POST['todelete'] as $id => $val) { 43 | if ($val == 'on') { 44 | $simcard_item->can($id, DELETE, $_POST); 45 | $ok = $simcard_item->delete(array('id' => $id)); 46 | } 47 | } 48 | } 49 | } 50 | Html::back(); 51 | -------------------------------------------------------------------------------- /front/simcardsize.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardSimcardSize(); 34 | include (GLPI_ROOT . "/front/dropdown.common.form.php"); 35 | -------------------------------------------------------------------------------- /front/simcardsize.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardSimcardSize(); 34 | include (GLPI_ROOT . "/front/dropdown.common.php"); 35 | -------------------------------------------------------------------------------- /front/simcardtype.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardSimcardType(); 34 | include (GLPI_ROOT . "/front/dropdown.common.form.php"); 35 | -------------------------------------------------------------------------------- /front/simcardtype.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardSimcardType(); 34 | include (GLPI_ROOT . "/front/dropdown.common.php"); 35 | -------------------------------------------------------------------------------- /front/simcardvoltage.form.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardSimcardVoltage(); 34 | include (GLPI_ROOT . "/front/dropdown.common.form.php"); 35 | -------------------------------------------------------------------------------- /front/simcardvoltage.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | include ('../../../inc/includes.php'); 32 | 33 | $dropdown = new PluginSimcardSimcardVoltage(); 34 | include (GLPI_ROOT . "/front/dropdown.common.php"); 35 | -------------------------------------------------------------------------------- /hook.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | /** 32 | * 33 | * Determine if the plugin should be installed or upgraded 34 | * 35 | * Returns 0 if the plugin is not yet installed 36 | * Returns 1 if the plugin is already installed 37 | * 38 | * @since 1.3 39 | * 40 | * @return number 41 | */ 42 | function plugin_simcard_currentVersion() { 43 | 44 | // Saves the current version to not re-detect it on multiple calls 45 | static $currentVersion = null; 46 | 47 | if ($currentVersion === null) { 48 | // result not cached 49 | if ( 50 | !TableExists('glpi_plugin_simcard_simcards_items') && 51 | !TableExists('glpi_plugin_simcard_configs') 52 | ) { 53 | // the plugin seems not installed 54 | $currentVersion = 0; 55 | } else { 56 | if (TableExists('glpi_plugin_simcard_configs')) { 57 | // The plugin is at least 1.3 58 | // Get the current version in the plugin's configuration 59 | $pluginSimcardConfig = new PluginSimcardConfig(); 60 | $currentVersion = $pluginSimcardConfig->getValue('Version'); 61 | } 62 | if ($currentVersion == '') { 63 | // The plugin is older than 1.3 64 | $currentVersion = '1.2'; 65 | } 66 | } 67 | } 68 | return $currentVersion; 69 | } 70 | 71 | function plugin_simcard_install() { 72 | include_once (GLPI_ROOT."/plugins/simcard/inc/profile.class.php"); 73 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcard.class.php"); 74 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcardsize.class.php"); 75 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcardvoltage.class.php"); 76 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcardtype.class.php"); 77 | include_once (GLPI_ROOT."/plugins/simcard/inc/phoneoperator.class.php"); 78 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcard_item.class.php"); 79 | include_once (GLPI_ROOT."/plugins/simcard/inc/config.class.php"); 80 | 81 | $migration = new Migration(PLUGIN_SIMCARD_VERSION); 82 | 83 | if (plugin_simcard_currentVersion() == 0) { 84 | // Installation of the plugin 85 | PluginSimcardConfig::install($migration); 86 | PluginSimcardProfile::install($migration); 87 | PluginSimcardSimcard::install($migration); 88 | PluginSimcardSimcardSize::install($migration); 89 | PluginSimcardSimcardVoltage::install($migration); 90 | PluginSimcardSimcardType::install($migration); 91 | PluginSimcardPhoneOperator::install($migration); 92 | PluginSimcardSimcard_Item::install($migration); 93 | } else { 94 | PluginSimcardConfig::upgrade($migration); 95 | PluginSimcardProfile::upgrade($migration); 96 | PluginSimcardSimcard::upgrade($migration); 97 | PluginSimcardSimcardSize::upgrade($migration); 98 | PluginSimcardSimcardVoltage::upgrade($migration); 99 | PluginSimcardSimcardType::upgrade($migration); 100 | PluginSimcardPhoneOperator::upgrade($migration); 101 | PluginSimcardSimcard_Item::upgrade($migration); 102 | 103 | } 104 | return true; 105 | } 106 | 107 | function plugin_simcard_uninstall() { 108 | include_once (GLPI_ROOT."/plugins/simcard/inc/profile.class.php"); 109 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcard.class.php"); 110 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcardsize.class.php"); 111 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcardvoltage.class.php"); 112 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcardtype.class.php"); 113 | include_once (GLPI_ROOT."/plugins/simcard/inc/phoneoperator.class.php"); 114 | include_once (GLPI_ROOT."/plugins/simcard/inc/simcard_item.class.php"); 115 | include_once (GLPI_ROOT."/plugins/simcard/inc/config.class.php"); 116 | 117 | PluginSimcardProfile::uninstall(); 118 | PluginSimcardSimcard::uninstall(); 119 | PluginSimcardSimcardSize::uninstall(); 120 | PluginSimcardSimcardVoltage::uninstall(); 121 | PluginSimcardSimcardType::uninstall(); 122 | PluginSimcardPhoneOperator::uninstall(); 123 | PluginSimcardSimcard_Item::uninstall(); 124 | PluginSimcardConfig::uninstall(); 125 | return true; 126 | } 127 | 128 | // Define dropdown relations 129 | function plugin_simcard_getDatabaseRelations() { 130 | 131 | $plugin = new Plugin(); 132 | 133 | if ($plugin->isActivated("simcard")) { 134 | return array( 135 | "glpi_plugin_simcard_simcardsizes" 136 | => array("glpi_plugin_simcard_simcards"=>"plugin_simcard_simcardsizes_id"), 137 | "glpi_plugin_simcard_simcardvoltages" 138 | => array("glpi_plugin_simcard_simcards"=>"plugin_simcard_simcardvoltages_id"), 139 | "glpi_plugin_simcard_phoneoperators" 140 | => array("glpi_plugin_simcard_simcards"=>"plugin_simcard_phoneoperators_id"), 141 | "glpi_plugin_simcard_simcardtypes" 142 | => array("glpi_plugin_simcard_simcards"=>"plugin_simcard_simcardtypes_id"), 143 | "glpi_users" => array("glpi_plugin_simcard_simcards"=>"users_id"), 144 | "glpi_users" => array("glpi_plugin_simcard_simcards"=>"users_id_tech"), 145 | "glpi_groups" => array("glpi_plugin_simcard_simcards"=>"groups_id"), 146 | "glpi_groups" => array("glpi_plugin_simcard_simcards"=>"groups_id_tech"), 147 | "glpi_manufacturers" => array("glpi_plugin_simcard_simcards" => "manufacturers_id"), 148 | "glpi_states" => array("glpi_plugin_simcard_simcards" => "states_id"), 149 | "glpi_locations" => array("glpi_plugin_simcard_simcards"=>"locations_id")); 150 | //"glpi_profiles" => array ("glpi_plugin_simcard_profiles" => "profiles_id")); 151 | } else { 152 | return array(); 153 | } 154 | } 155 | 156 | 157 | // Define Dropdown tables to be manage in GLPI : 158 | function plugin_simcard_getDropdown() { 159 | global $LANG; 160 | 161 | $plugin = new Plugin(); 162 | if ($plugin->isActivated("simcard")) { 163 | return array('PluginSimcardSimcardSize' => __('Size', 'simcard'), 164 | 'PluginSimcardPhoneOperator' => __('Provider', 'simcard'), 165 | 'PluginSimcardSimcardVoltage' => __('Voltage', 'simcard'), 166 | 'PluginSimcardSimcardType' => __('Type of SIM card', 'simcard')); 167 | } else { 168 | return array(); 169 | } 170 | 171 | } 172 | 173 | function plugin_simcard_AssignToTicket($types) { 174 | global $LANG; 175 | 176 | if (Session::haveRight(PluginSimcardProfile::RIGHT_SIMCARD_SIMCARD, PluginSimcardProfile::SIMCARD_ASSOCIATE_TICKET)) { 177 | $types['PluginSimcardSimcard'] = _sn('SIM card', 'SIM cards', 2, 'simcard'); 178 | } 179 | 180 | return $types; 181 | } 182 | 183 | //force groupby for multible links to items 184 | 185 | function plugin_simcard_forceGroupBy($type) { 186 | 187 | return true; 188 | switch ($type) { 189 | case 'PluginSimcardSimcard': 190 | return true; 191 | break; 192 | 193 | } 194 | return false; 195 | } 196 | 197 | 198 | function plugin_simcard_getAddSearchOptions($itemtype) { 199 | global $LANG; 200 | 201 | $sopt = array(); 202 | 203 | $reservedTypeIndex = PluginSimcardConfig::RESERVED_TYPE_RANGE_MIN; 204 | 205 | if (in_array($itemtype,PluginSimcardSimcard_Item::getClasses())) { 206 | if (PluginSimcardSimcard::canView()) { 207 | $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards'; 208 | $sopt[$reservedTypeIndex]['field'] = 'name'; 209 | $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard')." - ".__s('Name'); 210 | $sopt[$reservedTypeIndex]['forcegroupby'] = true; 211 | $sopt[$reservedTypeIndex]['massiveaction'] = false; 212 | $sopt[$reservedTypeIndex]['datatype'] = 'itemlink'; 213 | $sopt[$reservedTypeIndex]['itemlink_type'] = 'PluginSimcardSimcard'; 214 | $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' 215 | => array('table' => 'glpi_plugin_simcard_simcards_items', 216 | 'joinparams' => array('jointype' => 'itemtype_item'))); 217 | $reservedTypeIndex++; 218 | $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards'; 219 | $sopt[$reservedTypeIndex]['field'] = 'phonenumber'; 220 | $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard')." - ".__s('Phone number', 'simcard'); 221 | $sopt[$reservedTypeIndex]['massiveaction'] = false; 222 | $sopt[$reservedTypeIndex]['forcegroupby'] = true; 223 | $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' 224 | => array('table' => 'glpi_plugin_simcard_simcards_items', 225 | 'joinparams' => array('jointype' => 'itemtype_item'))); 226 | $reservedTypeIndex++; 227 | $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards'; 228 | $sopt[$reservedTypeIndex]['field'] = 'serial'; 229 | $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard')." - ".__s('IMSI', 'simcard'); 230 | $sopt[$reservedTypeIndex]['massiveaction'] = false; 231 | $sopt[$reservedTypeIndex]['forcegroupby'] = true; 232 | $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' 233 | => array('table' => 'glpi_plugin_simcard_simcards_items', 234 | 'joinparams' => array('jointype' => 'itemtype_item'))); 235 | } 236 | } 237 | return $sopt; 238 | } 239 | 240 | 241 | // Hook done on purge item case 242 | 243 | function plugin_item_purge_simcard($item) { 244 | 245 | $temp = new PluginSimcardSimcard_Item(); 246 | $temp->deleteByCriteria(array('itemtype' => get_class($item), 247 | 'items_id' => $item->getField('id'))); 248 | return true; 249 | } 250 | 251 | function plugin_datainjection_populate_simcard() { 252 | global $INJECTABLE_TYPES; 253 | 254 | $INJECTABLE_TYPES['PluginSimcardSimcardInjection'] = 'simcard'; 255 | } 256 | 257 | /** 258 | * 259 | * Determine if the plugin should be installed or upgraded 260 | * 261 | * Returns 0 if the plugin is not yet installed 262 | * Returns 1 if the plugin is already installed 263 | * 264 | * @since 1.3 265 | */ 266 | function plugin_simcard_postinit() { 267 | global $UNINSTALL_TYPES, $ORDER_TYPES, $ALL_CUSTOMFIELDS_TYPES, $DB; 268 | $plugin = new Plugin(); 269 | if ($plugin->isInstalled('uninstall') && $plugin->isActivated('uninstall')) { 270 | array_push($UNINSTALL_TYPES, 'PluginSimcardSimcard'); 271 | } 272 | if ($plugin->isInstalled('order') && $plugin->isActivated('order')) { 273 | array_push($ORDER_TYPES, 'PluginSimcardSimcard'); 274 | } 275 | if ($plugin->isInstalled('customfields') && $plugin->isActivated('customfields')) { 276 | PluginCustomfieldsItemtype::registerItemtype('PluginSimcardSimcard'); 277 | } 278 | } 279 | 280 | /** 281 | * Update helpdesk_item_type in a profile if a ProfileRight changes or is created 282 | * 283 | * Add or remove simcard item type to match the status of "associable to tickets" in simcard's right 284 | * 285 | * @since 1.4.1 286 | */ 287 | function plugin_simcard_profileRightUpdate($item) { 288 | if ($_SESSION['glpiactiveprofile']['id'] == $item->fields['profiles_id']) { 289 | if ($item->fields['name'] == PluginSimcardProfile::RIGHT_SIMCARD_SIMCARD) { 290 | $profile = new Profile(); 291 | $profile->getFromDB($item->fields['profiles_id']); 292 | $helpdeskItemTypes = json_decode($profile->fields['helpdesk_item_type'], true); 293 | if (!is_array($helpdeskItemTypes)) { 294 | $helpdeskItemTypes = array(); 295 | } 296 | $index = array_search('PluginSimcardSimcard', $helpdeskItemTypes); 297 | if ($item->fields['rights'] & PluginSimcardProfile::SIMCARD_ASSOCIATE_TICKET) { 298 | if ($index === false) { 299 | $helpdeskItemTypes[] = 'PluginSimcardSimcard'; 300 | if ($_SESSION['glpiactiveprofile']['id'] == $profile->fields['id']) { 301 | $_SESSION['glpiactiveprofile']['helpdesk_item_type'][] = 'PluginSimcardSimcard'; 302 | } 303 | } 304 | } else { 305 | if ($index !== false) { 306 | unset($helpdeskItemTypes[$index]); 307 | if ($_SESSION['glpiactiveprofile']['id'] == $profile->fields['id']) { 308 | // Just in case this is not the same index in the session vars 309 | $index = array_search('PluginSimcardSimcard', $_SESSION['glpiactiveprofile']['helpdesk_item_type']); 310 | if ($index !== false) { 311 | unset($_SESSION['glpiactiveprofile']['helpdesk_item_type'][$index]); 312 | } 313 | } 314 | } 315 | } 316 | $tmp = array( 317 | 'id' => $profile->fields['id'], 318 | 'helpdesk_item_type' => json_encode($helpdeskItemTypes) 319 | ); 320 | $profile->update($tmp, false); 321 | } 322 | } 323 | } 324 | ?> 325 | -------------------------------------------------------------------------------- /inc/config.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')) { 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | /** 36 | * 37 | * @author dethegeek 38 | * @since 1.3 39 | * 40 | */ 41 | class PluginSimcardConfig extends CommonDBTM { 42 | 43 | // Type reservation : https://forge.indepnet.net/projects/plugins/wiki/PluginTypesReservation 44 | // Reserved range : [10126, 10135] 45 | const RESERVED_TYPE_RANGE_MIN = 10126; 46 | const RESERVED_TYPE_RANGE_MAX = 10135; 47 | 48 | static $config = array(); 49 | 50 | /** 51 | * 52 | * 53 | * 54 | **/ 55 | static function install(Migration $migration) { 56 | global $DB; 57 | 58 | $table = getTableForItemType(__CLASS__); 59 | $query = "CREATE TABLE `".$table."` ( 60 | `id` int(11) NOT NULL AUTO_INCREMENT, 61 | `type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, 62 | `value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, 63 | PRIMARY KEY (`id`), 64 | UNIQUE KEY `unicity` (`type`) 65 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1"; 66 | $DB->query($query) or die($DB->error()); 67 | $query = "INSERT INTO `".$table."` 68 | (`type`,`value`) 69 | VALUES ('Version', '" . PLUGIN_SIMCARD_VERSION . "')"; 70 | $DB->query($query) or die($DB->error()); 71 | 72 | } 73 | 74 | /** 75 | * 76 | * 77 | * 78 | **/ 79 | static function upgrade(Migration $migration) { 80 | global $DB; 81 | 82 | switch (plugin_simcard_currentVersion()) { 83 | case '1.2': 84 | self::install($migration); 85 | break; 86 | 87 | default: 88 | $table = getTableForItemType(__CLASS__); 89 | $query = "UPDATE `".$table."` 90 | SET `value`= '" . PLUGIN_SIMCARD_VERSION . "' 91 | WHERE `type`='Version'"; 92 | $DB->query($query) or die($DB->error()); 93 | } 94 | } 95 | 96 | /** 97 | * 98 | * 99 | * 100 | **/ 101 | static function uninstall() { 102 | global $DB; 103 | 104 | $displayPreference = new DisplayPreference(); 105 | $displayPreference->deleteByCriteria(array("`num` >= " . self::RESERVED_TYPE_RANGE_MIN . " AND `num` <= " . self::RESERVED_TYPE_RANGE_MAX)); 106 | 107 | $table = getTableForItemType(__CLASS__); 108 | $query = "DROP TABLE IF EXISTS `". $table ."`"; 109 | 110 | $DB->query($query) or die($DB->error()); 111 | } 112 | 113 | /** 114 | * 115 | * 116 | * 117 | **/ 118 | static function loadCache() { 119 | global $DB; 120 | 121 | $table = getTableForItemType(__CLASS__); 122 | self::$config = array(); 123 | $query = "SELECT * FROM `". $table ."`"; 124 | $result = $DB->query($query); 125 | while ($data=$DB->fetch_array($result)) { 126 | self::$config[$data['type']] = $data['value']; 127 | } 128 | } 129 | 130 | /** 131 | * Add configuration value, if not already present 132 | * 133 | * @param $name field name 134 | * @param $value field value 135 | * 136 | * @return integer the new id of the added item (or FALSE if fail) 137 | **/ 138 | function addValue($name, $value) { 139 | $existing_value = $this->getValue($name); 140 | if (!is_null($existing_value)) { 141 | return false; 142 | } else { 143 | return $this->add(array('type' => $name, 144 | 'value' => $value)); 145 | } 146 | } 147 | 148 | /** 149 | * Get configuration value 150 | * 151 | * @param $name field name 152 | * 153 | * @return field value for an existing field, FALSE otherwise 154 | **/ 155 | function getValue($name) { 156 | if (isset(self::$config[$name])) { 157 | return self::$config[$name]; 158 | } 159 | 160 | $config = current($this->find("`type`='".$name."'")); 161 | if (isset($config['value'])) { 162 | return $config['value']; 163 | } 164 | return NULL; 165 | } 166 | 167 | /** 168 | * Update configuration value 169 | * 170 | * @param $name field name 171 | * @param $value field value 172 | * 173 | * @return boolean : TRUE on success 174 | **/ 175 | function updateValue($name, $value) { 176 | $config = current($this->find("`type`='".$name."'")); 177 | if (isset($config['id'])) { 178 | return $this->update(array('id'=> $config['id'], 'value'=>$value)); 179 | } else { 180 | return $this->add(array('type' => $name, 'value' => $value)); 181 | } 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /inc/phoneoperator.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')) { 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | /// Class PhoneOperator 36 | class PluginSimcardPhoneOperator extends CommonDropdown { 37 | 38 | static function getTypeName($nb=0) { 39 | global $LANG; 40 | return __('Provider', 'simcard'); 41 | } 42 | 43 | static function install(Migration $migration) { 44 | global $DB; 45 | 46 | $table = getTableForItemType(__CLASS__); 47 | if (!TableExists($table)) { 48 | $query = "CREATE TABLE IF NOT EXISTS `$table` ( 49 | `id` int(11) NOT NULL AUTO_INCREMENT, 50 | `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 51 | `comment` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 52 | PRIMARY KEY (`id`), 53 | KEY `name` (`name`) 54 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;"; 55 | $DB->query($query) or die($DB->error()); 56 | } 57 | } 58 | 59 | /** 60 | * 61 | * 62 | * @since 1.3 63 | **/ 64 | static function upgrade(Migration $migration) { 65 | global $DB; 66 | 67 | } 68 | 69 | static function uninstall() { 70 | global $DB; 71 | 72 | foreach (array('DisplayPreference', 'Bookmark') as $itemtype) { 73 | $item = new $itemtype(); 74 | $item->deleteByCriteria(array('itemtype' => __CLASS__)); 75 | } 76 | 77 | // Remove dropdowns localization 78 | $dropdownTranslation = new DropdownTranslation(); 79 | $dropdownTranslation->deleteByCriteria(array("itemtype LIKE 'PluginSimcardPhoneOperator'"), 1); 80 | 81 | $table = getTableForItemType(__CLASS__); 82 | $DB->query("DROP TABLE IF EXISTS `$table`"); 83 | } 84 | 85 | static function transfer($ID, $entity) { 86 | global $DB; 87 | 88 | $phoneOperator = new self(); 89 | 90 | if ($ID > 0) { 91 | // Not already transfer 92 | // Search init item 93 | $query = "SELECT * 94 | FROM `".$phoneOperator->getTable()."` 95 | WHERE `id` = '$ID'"; 96 | 97 | if ($result = $DB->query($query)) { 98 | if ($DB->numrows($result)) { 99 | $data = $DB->fetch_assoc($result); 100 | $data = Toolbox::addslashes_deep($data); 101 | $input['name'] = $data['name']; 102 | $input['entities_id'] = $entity; 103 | $newID = $phoneOperator->getID($input); 104 | 105 | if ($newID < 0) { 106 | $newID = $phoneOperator->import($input); 107 | } 108 | 109 | return $newID; 110 | } 111 | } 112 | } 113 | return 0; 114 | } 115 | } 116 | ?> 117 | -------------------------------------------------------------------------------- /inc/profile.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')){ 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | class PluginSimcardProfile extends Profile { 36 | 37 | const RIGHT_SIMCARD_SIMCARD = "simcard:simcard"; 38 | const SIMCARD_ASSOCIATE_TICKET = 128; 39 | 40 | static $rightname = 'profile'; 41 | 42 | function createAccess($ID) { 43 | $this->add(array('profiles_id' => $ID)); 44 | } 45 | 46 | static function createFirstAccess($ID) { 47 | $profileRight = new ProfileRight(); 48 | 49 | $currentRights = ProfileRight::getProfileRights( 50 | $ID, 51 | array(self::RIGHT_SIMCARD_SIMCARD) 52 | ); 53 | $firstAccessRights = array_merge($currentRights, array( 54 | self::RIGHT_SIMCARD_SIMCARD => ALLSTANDARDRIGHT 55 | + self::SIMCARD_ASSOCIATE_TICKET 56 | + READNOTE 57 | + UPDATENOTE 58 | )); 59 | $profileRight->updateProfileRights($ID, $firstAccessRights); 60 | 61 | //Add right to the current session 62 | $_SESSION['glpiactiveprofile'][self::RIGHT_SIMCARD_SIMCARD] = $firstAccessRights[self::RIGHT_SIMCARD_SIMCARD]; 63 | $_SESSION['glpiactiveprofile']['helpdesk_item_type'][] = 'PluginSimcardSimcard'; 64 | } 65 | 66 | //profiles modification 67 | function showForm($ID, $options = array()){ 68 | global $LANG; 69 | 70 | if (!Profile::canView()) { 71 | return false; 72 | } 73 | $canedit = self::canUpdate(); 74 | $profile = new Profile(); 75 | if ($ID){ 76 | //$this->getFromDBByProfile($ID); 77 | $profile->getFromDB($ID); 78 | } 79 | if ($canedit) { 80 | echo "
"; 81 | } 82 | 83 | $rights = $this->getAllRights(); 84 | $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 85 | 'default_class' => 'tab_bg_2')); 86 | 87 | if ($canedit) { 88 | echo "
"; 89 | echo ""; 90 | echo ""; 91 | echo "
"; 92 | } 93 | Html::closeForm(); 94 | $this->showLegend(); 95 | } 96 | 97 | static function install(Migration $migration) { 98 | global $DB; 99 | 100 | // Table no longer needed in GLPI 0.85+; drop it. Needed for upgrades 101 | $migration->dropTable(getTableForItemType(__CLASS__)); 102 | PluginSimcardProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); 103 | } 104 | 105 | /** 106 | * 107 | * 108 | * @since 1.3 109 | **/ 110 | static function upgrade(Migration $migration) { 111 | global $DB; 112 | 113 | $table = getTableForItemType(__CLASS__); 114 | switch (plugin_simcard_currentVersion()) { 115 | case '1.3': 116 | case '1.3.1': 117 | $query = "SELECT * FROM `glpi_plugin_simcard_profiles`"; 118 | $result = $DB->query($query); 119 | while ($data = $DB->fetch_assoc($result)) { 120 | // Write the access rights into the new ACLs system of GLPI 0.85 121 | $translatedRight = self::translateARight($data['simcard']) + self::translateARight($data['open_ticket']); 122 | if ($translatedRight & READ) { 123 | $translatedRight = $translatedRight | READNOTE; 124 | } 125 | if ($translatedRight & UPDATE) { 126 | $translatedRight = $translatedRight | READNOTE | UPDATENOTE; 127 | } 128 | $profileRight = new ProfileRight(); 129 | $profileRightFields['profiles_id'] = $data['profiles_id']; 130 | $profileRightFields['name'] = self::RIGHT_SIMCARD_SIMCARD; 131 | $profileRightFields['rights'] = $translatedRight; 132 | if ($profileRight->add($profileRightFields) === false) { 133 | die('Fatal error migrating profile rights'); 134 | } 135 | // The plugin is not yet active, the hook will not trigger automatically 136 | plugin_simcard_profileRightUpdate($profileRight); 137 | } 138 | $query = "DROP TABLE `glpi_plugin_simcard_profiles`"; 139 | $DB->query($query) or die($DB->error()); 140 | break; 141 | 142 | case '1.4': 143 | case '1.4.1': 144 | 145 | } 146 | } 147 | 148 | /** 149 | * Init profiles 150 | * 151 | **/ 152 | 153 | static function translateARight($old_right) { 154 | switch ($old_right) { 155 | case 'r' : 156 | return READ; 157 | 158 | case 'w': 159 | return ALLSTANDARDRIGHT; 160 | 161 | case '1': 162 | return self::SIMCARD_ASSOCIATE_TICKET; 163 | 164 | case '0': 165 | case '': 166 | default: 167 | return 0; 168 | } 169 | } 170 | 171 | static function uninstall() { 172 | global $DB; 173 | 174 | ProfileRight::deleteProfileRights(array( 175 | self::RIGHT_SIMCARD_SIMCARD 176 | )); 177 | unset($_SESSION["glpiactiveprofile"][self::RIGHT_SIMCARD_SIMCARD]); 178 | } 179 | 180 | function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { 181 | global $LANG; 182 | if ($item->getType()=='Profile') { 183 | return _sn('SIM card', 'SIM cards', 2, 'simcard'); 184 | } 185 | return ''; 186 | } 187 | 188 | 189 | static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { 190 | 191 | if ($item->getType() == 'Profile') { 192 | $profile = new self(); 193 | $profile->showForm($item->getField('id')); 194 | } 195 | return true; 196 | } 197 | 198 | function getAllRights() { 199 | $rights = array( 200 | array('itemtype' => 'PluginSimcardSimcard', 201 | 'label' => PluginSimcardSimcard::getTypeName(2), 202 | 'field' => 'simcard:simcard' 203 | ), 204 | ); 205 | return $rights; 206 | } 207 | 208 | } 209 | 210 | ?> -------------------------------------------------------------------------------- /inc/simcard.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')) { 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | /// Class Simcard 36 | class PluginSimcardSimcard extends CommonDBTM { 37 | 38 | // From CommonDBTM 39 | //static $types = array(''); 40 | public $dohistory = true; 41 | 42 | static $rightname = PluginSimcardProfile::RIGHT_SIMCARD_SIMCARD; 43 | protected $usenotepad = true; 44 | 45 | //~ static $types = array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer', 'Software', 'Entity'); 46 | static $types = array('Phone' , 'Entity'); 47 | 48 | /** 49 | * Name of the type 50 | * 51 | * @param $nb integer number of item in the type (default 0) 52 | **/ 53 | static function getTypeName($nb=0) { 54 | global $LANG; 55 | return _n('SIM card', 'SIM cards', $nb, 'simcard'); 56 | } 57 | 58 | /** 59 | * @since version 0.85 60 | * 61 | * @see commonDBTM::getRights() 62 | **/ 63 | function getRights($interface='central') { 64 | $rights = parent::getRights(); 65 | $rights[PluginSimcardProfile::SIMCARD_ASSOCIATE_TICKET] = __('Associable to a ticket'); 66 | 67 | return $rights; 68 | } 69 | 70 | function defineTabs($options=array()) { 71 | global $LANG; 72 | $ong = array(); 73 | $this->addDefaultFormTab($ong); 74 | if ($this->fields['id'] > 0) { 75 | if (!isset($options['withtemplate']) || empty($options['withtemplate'])) { 76 | $this->addStandardTab('PluginSimcardSimcard_Item', $ong, $options); 77 | $this->addStandardTab('NetworkPort', $ong, $options); 78 | $this->addStandardTab('Document_Item',$ong,$options); 79 | $this->addStandardTab('Infocom',$ong,$options); 80 | $this->addStandardTab('Contract_Item', $ong, $options); 81 | if ($this->fields['is_helpdesk_visible'] == 1) { 82 | $this->addStandardTab('Ticket',$ong,$options); 83 | $this->addStandardTab('Item_Problem', $ong, $options); 84 | } 85 | $this->addStandardTab('Notepad',$ong,$options); 86 | $this->addStandardTab('Log',$ong,$options); 87 | $this->addStandardTab('Event',$ong,$options); 88 | } else { 89 | $this->addStandardTab('Infocom',$ong,$options); 90 | $this->addStandardTab('Contract_Item', $ong, $options); 91 | $this->addStandardTab('Document_Item',$ong,$options); 92 | $this->addStandardTab('Log',$ong,$options); 93 | $this->addStandardTab('Event',$ong,$options); 94 | } 95 | } else { 96 | $ong[1] = __s('Main'); 97 | } 98 | 99 | return $ong; 100 | } 101 | 102 | /** 103 | * Print the simcard form 104 | * 105 | * @param $ID integer ID of the item 106 | * @param $options array 107 | * - target for the Form 108 | * - withtemplate template or basic simcard 109 | * 110 | *@return Nothing (display) 111 | **/ 112 | function showForm($ID, $options=array()) { 113 | global $CFG_GLPI, $DB, $LANG; 114 | 115 | if (!$this->canView()) return false; 116 | 117 | $target = $this->getFormURL(); 118 | $withtemplate = ''; 119 | 120 | if (isset($options['target'])) { 121 | $target = $options['target']; 122 | } 123 | 124 | if (isset($options['withtemplate'])) { 125 | $withtemplate = $options['withtemplate']; 126 | } 127 | 128 | $this->showFormHeader($options); 129 | 130 | if (isset($options['itemtype']) && isset($options['items_id'])) { 131 | echo ""; 132 | echo "".__s('Associated element').""; 133 | echo ""; 134 | $item = new $options['itemtype']; 135 | $item->getFromDB($options['items_id']); 136 | echo $item->getLink(1); 137 | echo ""; 138 | echo "\n"; 139 | echo ""; 140 | echo ""; 141 | } 142 | 143 | 144 | echo ""; 145 | echo "".__s('Name'). 146 | (isset($options['withtemplate']) && $options['withtemplate']?"*":""). 147 | ""; 148 | echo ""; 149 | $objectName = autoName($this->fields["name"], "name", 150 | (isset($options['withtemplate']) && $options['withtemplate']==2), 151 | $this->getType(), $this->fields["entities_id"]); 152 | Html::autocompletionTextField($this, 'name', array('value' => $objectName)); 153 | echo ""; 154 | echo "".__s('Status').""; 155 | echo ""; 156 | Dropdown::show('State', array('value' => $this->fields["states_id"])); 157 | echo "\n"; 158 | 159 | echo ""; 160 | echo "".__s('Location').""; 161 | echo ""; 162 | Dropdown::show('Location', array('value' => $this->fields["locations_id"], 163 | 'entity' => $this->fields["entities_id"])); 164 | echo ""; 165 | echo "".__s('Type of SIM card', 'simcard').""; 166 | echo ""; 167 | Dropdown::show('PluginSimcardSimcardType', 168 | array('value' => $this->fields["plugin_simcard_simcardtypes_id"])); 169 | echo "\n"; 170 | 171 | echo ""; 172 | echo "".__s('Technician in charge of the hardware').""; 173 | echo ""; 174 | User::dropdown(array('name' => 'users_id_tech', 175 | 'value' => $this->fields["users_id_tech"], 176 | 'right' => 'interface', 177 | 'entity' => $this->fields["entities_id"])); 178 | echo ""; 179 | echo "".__s('Size', 'simcard').""; 180 | echo ""; 181 | Dropdown::show('PluginSimcardSimcardSize', 182 | array('value' => $this->fields["plugin_simcard_simcardsizes_id"])); 183 | echo "\n"; 184 | 185 | // TODO : Add group in charge of hardware 186 | echo ""; 187 | echo "".__s('Group in charge of the hardware').""; 188 | echo ""; 189 | Group::dropdown(array('name' => 'groups_id_tech', 190 | 'value' => $this->fields['groups_id_tech'], 191 | 'entity' => $this->fields['entities_id'], 192 | 'condition' => '`is_assign`')); 193 | echo ""; 194 | 195 | echo "".__s('Voltage', 'simcard').""; 196 | echo ""; 197 | Dropdown::show('PluginSimcardSimcardVoltage', 198 | array('value' => $this->fields["plugin_simcard_simcardvoltages_id"])); 199 | echo "\n"; 200 | 201 | echo ""; 202 | echo "".__s('Provider', 'simcard').""; 203 | echo ""; 204 | Dropdown::show('PluginSimcardPhoneOperator', 205 | array('value' => $this->fields["plugin_simcard_phoneoperators_id"])); 206 | echo ""; 207 | 208 | echo "" . __s('Associable items to a ticket') . " :"; 209 | Dropdown::showYesNo('is_helpdesk_visible',$this->fields['is_helpdesk_visible']); 210 | echo "\n"; 211 | 212 | 213 | echo ""; 214 | echo "".__s('User').""; 215 | echo ""; 216 | User::dropdown(array('value' => $this->fields["users_id"], 217 | 'entity' => $this->fields["entities_id"], 218 | 'right' => 'all')); 219 | echo ""; 220 | 221 | echo ""; 222 | 223 | echo "".__s("Inventory number"). 224 | (isset($options['withtemplate']) && $options['withtemplate']?"*":""). 225 | ""; 226 | echo ""; 227 | $objectName = autoName($this->fields["otherserial"], "otherserial", 228 | (isset($options['withtemplate']) && $options['withtemplate']==2), 229 | $this->getType(), $this->fields["entities_id"]); 230 | Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName)); 231 | echo "\n"; 232 | echo ""; 233 | echo "".__s('Group').""; 234 | echo ""; 235 | Dropdown::show('Group', array('value' => $this->fields["groups_id"], 236 | 'entity' => $this->fields["entities_id"])); 237 | 238 | echo "\n"; 239 | 240 | echo ""; 241 | echo "".__s('Phone number', 'simcard').""; 242 | echo ""; 243 | Html::autocompletionTextField($this,'phonenumber'); 244 | echo ""; 245 | echo "".__s('Comments').""; 246 | echo ""; 247 | echo ""; 248 | echo "\n"; 249 | 250 | echo ""; 251 | echo "".__s('IMSI', 'simcard').""; 252 | echo ""; 253 | Html::autocompletionTextField($this,'serial'); 254 | echo "\n"; 255 | 256 | //Only show PIN and PUK code to users who can write (theses informations are highly sensible) 257 | if (PluginSimcardSimcard::canUpdate()) { 258 | echo ""; 259 | echo "".__s('Pin 1', 'simcard').""; 260 | echo ""; 261 | Html::autocompletionTextField($this,'pin'); 262 | echo "\n"; 263 | 264 | echo ""; 265 | echo "".__s('Pin 2', 'simcard').""; 266 | echo ""; 267 | Html::autocompletionTextField($this,'pin2'); 268 | echo "\n"; 269 | 270 | echo ""; 271 | echo "".__s('Puk 1', 'simcard').""; 272 | echo ""; 273 | Html::autocompletionTextField($this,'puk'); 274 | echo "\n"; 275 | 276 | echo ""; 277 | echo "".__s('Puk 2', 'simcard').""; 278 | echo ""; 279 | Html::autocompletionTextField($this,'puk2'); 280 | echo "\n"; 281 | } 282 | 283 | $this->showFormButtons($options); 284 | //$this->addDivForTabs(); 285 | 286 | return true; 287 | } 288 | 289 | function prepareInputForAdd($input) { 290 | 291 | if (isset($input["id"]) && $input["id"]>0) { 292 | $input["_oldID"] = $input["id"]; 293 | } 294 | unset($input['id']); 295 | unset($input['withtemplate']); 296 | 297 | return $input; 298 | } 299 | 300 | function post_addItem() { 301 | global $DB, $CFG_GLPI; 302 | 303 | // Manage add from template 304 | if (isset($this->input["_oldID"])) { 305 | Infocom::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']); 306 | Contract_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']); 307 | Document_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']); 308 | } 309 | 310 | if (isset($this->input['_itemtype']) && isset($this->input['_items_id'])) { 311 | $simcard_item = new PluginSimcardSimcard_Item(); 312 | $tmp['plugin_simcard_simcards_id'] = $this->getID(); 313 | $tmp['itemtype'] = $this->input['_itemtype']; 314 | $tmp['items_id'] = $this->input['_items_id']; 315 | $simcard_item->add($tmp); 316 | } 317 | 318 | } 319 | 320 | function getSearchOptions() { 321 | global $CFG_GLPI, $LANG; 322 | 323 | $tab = array(); 324 | $tab['common'] = __s('SIM card', 'simcard'); 325 | 326 | $tab[1]['table'] = $this->getTable(); 327 | $tab[1]['field'] = 'name'; 328 | $tab[1]['name'] = __('Name'); 329 | $tab[1]['datatype'] = 'itemlink'; 330 | $tab[1]['itemlink_type'] = $this->getType(); 331 | $tab[1]['massiveaction'] = false; // implicit key==1 332 | $tab[1]['injectable'] = true; 333 | $tab[1]['checktype'] = 'text'; 334 | $tab[1]['displaytype'] = 'text'; 335 | 336 | $tab[2]['table'] = $this->getTable(); 337 | $tab[2]['field'] = 'id'; 338 | $tab[2]['name'] = __('ID'); 339 | $tab[2]['massiveaction'] = false; // implicit field is id 340 | $tab[2]['injectable'] = false; 341 | 342 | $tab[4]['table'] = 'glpi_plugin_simcard_simcardtypes'; 343 | $tab[4]['field'] = 'name'; 344 | $tab[4]['name'] = __('Type'); 345 | $tab[4]['datatype'] = 'dropdown'; 346 | $tab[4]['massiveaction'] = true; 347 | $tab[4]['checktype'] = 'text'; 348 | $tab[4]['displaytype'] = 'dropdown'; 349 | $tab[4]['injectable'] = true; 350 | 351 | $tab[5]['table'] = $this->getTable(); 352 | $tab[5]['field'] = 'serial'; 353 | $tab[5]['name'] = __('IMSI', 'simcard'); 354 | $tab[5]['datatype'] = 'string'; 355 | $tab[5]['checktype'] = 'text'; 356 | $tab[5]['displaytype'] = 'text'; 357 | $tab[5]['injectable'] = true; 358 | 359 | $tab[6]['table'] = $this->getTable(); 360 | $tab[6]['field'] = 'otherserial'; 361 | $tab[6]['name'] = __('Inventory number'); 362 | $tab[6]['datatype'] = 'string'; 363 | $tab[6]['checktype'] = 'text'; 364 | $tab[6]['displaytype'] = 'text'; 365 | $tab[6]['injectable'] = true; 366 | 367 | $tab[16]['table'] = $this->getTable(); 368 | $tab[16]['field'] = 'comment'; 369 | $tab[16]['name'] = __('Comments'); 370 | $tab[16]['datatype'] = 'text'; 371 | $tab[16]['linkfield'] = 'comment'; 372 | $tab[16]['checktype'] = 'text'; 373 | $tab[16]['displaytype'] = 'multiline_text'; 374 | $tab[16]['injectable'] = true; 375 | 376 | $tab += Location::getSearchOptionsToAdd(); 377 | $tab += Notepad::getSearchOptionsToAdd(); 378 | 379 | $tab[3]['checktype'] = 'text'; 380 | $tab[3]['displaytype'] = 'dropdown'; 381 | $tab[3]['injectable'] = true; 382 | 383 | $tab[91]['injectable'] = false; 384 | $tab[93]['injectable'] = false; 385 | 386 | $tab[19]['table'] = $this->getTable(); 387 | $tab[19]['field'] = 'date_mod'; 388 | $tab[19]['name'] = __('Last update'); 389 | $tab[19]['datatype'] = 'datetime'; 390 | $tab[19]['massiveaction'] = false; 391 | $tab[19]['injectable'] = false; 392 | 393 | // TODO : This index has not any similar in GLPI, should find an other index 394 | $tab[23]['table'] = 'glpi_plugin_simcard_simcardvoltages'; 395 | $tab[23]['field'] = 'name'; 396 | $tab[23]['name'] = __('Voltage', 'simcard'); 397 | $tab[23]['datatype'] = 'dropdown'; 398 | $tab[23]['checktype'] = 'text'; 399 | $tab[23]['displaytype'] = 'dropdown'; 400 | $tab[23]['injectable'] = true; 401 | 402 | $tab[24]['table'] = 'glpi_users'; 403 | $tab[24]['field'] = 'name'; 404 | $tab[24]['linkfield'] = 'users_id_tech'; 405 | $tab[24]['name'] = __('Technician in charge of the hardware'); 406 | $tab[24]['datatype'] = 'dropdown'; 407 | $tab[24]['right'] = 'own_ticket'; 408 | $tab[24]['checktype'] = 'text'; 409 | $tab[24]['displaytype'] = 'dropdown'; 410 | $tab[24]['injectable'] = true; 411 | 412 | $tab[25]['table'] = 'glpi_plugin_simcard_simcardsizes'; 413 | $tab[25]['field'] = 'name'; 414 | $tab[25]['name'] = __('Size', 'simcard'); 415 | $tab[25]['datatype'] = 'dropdown'; 416 | $tab[25]['checktype'] = 'text'; 417 | $tab[25]['displaytype'] = 'dropdown'; 418 | $tab[25]['injectable'] = true; 419 | 420 | $tab[26]['table'] = 'glpi_plugin_simcard_phoneoperators'; 421 | $tab[26]['field'] = 'name'; 422 | $tab[26]['name'] = __('Provider', 'simcard'); 423 | $tab[26]['datatype'] = 'dropdown'; 424 | $tab[26]['checktype'] = 'text'; 425 | $tab[26]['displaytype'] = 'dropdown'; 426 | $tab[26]['injectable'] = true; 427 | 428 | $tab[27]['table'] = $this->getTable(); 429 | $tab[27]['field'] = 'phonenumber'; 430 | $tab[27]['name'] = __('Phone number', 'simcard'); 431 | $tab[27]['datatype'] = 'string'; 432 | $tab[27]['checktype'] = 'text'; 433 | $tab[27]['displaytype'] = 'text'; 434 | $tab[27]['injectable'] = true; 435 | 436 | if (PluginSimcardSimcard::canUpdate()) { 437 | $tab[28]['table'] = $this->getTable(); 438 | $tab[28]['field'] = 'pin'; 439 | $tab[28]['name'] = __('Pin 1', 'simcard'); 440 | $tab[28]['datatype'] = 'string'; 441 | $tab[28]['checktype'] = 'text'; 442 | $tab[28]['displaytype'] = 'text'; 443 | $tab[28]['injectable'] = true; 444 | 445 | $tab[29]['table'] = $this->getTable(); 446 | $tab[29]['field'] = 'puk'; 447 | $tab[29]['name'] = __('Puk 1', 'simcard'); 448 | $tab[29]['datatype'] = 'string'; 449 | $tab[29]['checktype'] = 'text'; 450 | $tab[29]['displaytype'] = 'text'; 451 | $tab[29]['injectable'] = true; 452 | 453 | $tab[30]['table'] = $this->getTable(); 454 | $tab[30]['field'] = 'pin2'; 455 | $tab[30]['name'] = __('Pin 2', 'simcard'); 456 | $tab[30]['datatype'] = 'string'; 457 | $tab[30]['checktype'] = 'text'; 458 | $tab[30]['displaytype'] = 'text'; 459 | $tab[30]['injectable'] = true; 460 | 461 | $tab[32]['table'] = $this->getTable(); 462 | $tab[32]['field'] = 'puk2'; 463 | $tab[32]['name'] = __('Puk 2', 'simcard'); 464 | $tab[32]['datatype'] = 'string'; 465 | $tab[32]['checktype'] = 'text'; 466 | $tab[32]['displaytype'] = 'text'; 467 | $tab[32]['injectable'] = true; 468 | } 469 | 470 | $tab[31]['table'] = 'glpi_states'; 471 | $tab[31]['field'] = 'name'; 472 | $tab[31]['name'] = __('Status'); 473 | $tab[31]['datatype'] = 'dropdown'; 474 | $tab[31]['checktype'] = 'text'; 475 | $tab[31]['displaytype'] = 'dropdown'; 476 | $tab[31]['injectable'] = true; 477 | 478 | $tab[71]['table'] = 'glpi_groups'; 479 | $tab[71]['field'] = 'completename'; 480 | $tab[71]['name'] = __('Group'); 481 | $tab[71]['datatype'] = 'dropdown'; 482 | $tab[71]['checktype'] = 'text'; 483 | $tab[71]['displaytype'] = 'dropdown'; 484 | $tab[71]['injectable'] = true; 485 | 486 | $tab[49]['table'] = 'glpi_groups'; 487 | $tab[49]['field'] = 'name'; 488 | $tab[49]['linkfield'] = 'groups_id_tech'; 489 | $tab[49]['condition'] = '`is_assign`'; 490 | $tab[49]['name'] = __('Group in charge of the hardware'); 491 | $tab[49]['datatype'] = 'dropdown'; 492 | $tab[49]['checktype'] = 'text'; 493 | $tab[49]['displaytype'] = 'dropdown'; 494 | $tab[49]['injectable'] = true; 495 | 496 | $tab[70]['table'] = 'glpi_users'; 497 | $tab[70]['field'] = 'name'; 498 | $tab[70]['name'] = __('User'); 499 | $tab[70]['datatype'] = 'dropdown'; 500 | $tab[70]['right'] = 'all'; 501 | $tab[70]['checktype'] = 'text'; 502 | $tab[70]['displaytype'] = 'dropdown'; 503 | $tab[70]['injectable'] = true; 504 | 505 | $tab[80]['table'] = 'glpi_entities'; 506 | $tab[80]['field'] = 'completename'; 507 | $tab[80]['name'] = __('Entity'); 508 | $tab[80]['injectable'] = false; 509 | 510 | $tab[90]['table'] = $this->getTable(); 511 | $tab[90]['field'] = 'notepad'; 512 | $tab[90]['name'] = __('Notes'); 513 | $tab[90]['massiveaction'] = false; 514 | $tab[90]['linkfield'] = 'notepad'; 515 | $tab[90]['checktype'] = 'text'; 516 | $tab[90]['displaytype'] = 'multiline_text'; 517 | $tab[90]['injectable'] = false; 518 | 519 | return $tab; 520 | } 521 | 522 | /** 523 | * Installation of the itemtype 524 | * 525 | * @param Migration $migration migration helper instance 526 | */ 527 | static function install(Migration $migration) { 528 | global $DB; 529 | $table = getTableForItemType(__CLASS__); 530 | if (!TableExists($table)) { 531 | $query = "CREATE TABLE IF NOT EXISTS `$table` ( 532 | `id` int(11) NOT NULL AUTO_INCREMENT, 533 | `entities_id` int(11) NOT NULL DEFAULT '0', 534 | `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 535 | `phonenumber` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 536 | `serial` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 537 | `pin` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 538 | `pin2` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 539 | `puk` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 540 | `puk2` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 541 | `otherserial` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 542 | `states_id` int(11) NOT NULL DEFAULT '0', 543 | `locations_id` int(11) NOT NULL DEFAULT '0', 544 | `users_id` int(11) NOT NULL DEFAULT '0', 545 | `users_id_tech` int(11) NOT NULL DEFAULT '0', 546 | `groups_id` int(11) NOT NULL DEFAULT '0', 547 | `groups_id_tech` int(11) NOT NULL DEFAULT '0', 548 | `plugin_simcard_phoneoperators_id` int(11) NOT NULL DEFAULT '0', 549 | `manufacturers_id` int(11) NOT NULL DEFAULT '0', 550 | `plugin_simcard_simcardsizes_id` int(11) NOT NULL DEFAULT '0', 551 | `plugin_simcard_simcardvoltages_id` int(11) NOT NULL DEFAULT '0', 552 | `plugin_simcard_simcardtypes_id` int(11) NOT NULL DEFAULT '0', 553 | `comment` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL, 554 | `date_mod` datetime DEFAULT NULL, 555 | `is_template` tinyint(1) NOT NULL DEFAULT '0', 556 | `is_global` tinyint(1) NOT NULL DEFAULT '0', 557 | `is_deleted` tinyint(1) NOT NULL DEFAULT '0', 558 | `template_name` varchar(255) COLLATE utf8_unicode_ci NULL, 559 | `ticket_tco` decimal(20,4) DEFAULT '0.0000', 560 | `is_helpdesk_visible` tinyint(1) NOT NULL DEFAULT '1', 561 | PRIMARY KEY (`id`), 562 | KEY `name` (`name`), 563 | KEY `entities_id` (`entities_id`), 564 | KEY `states_id` (`states_id`), 565 | KEY `plugin_simcard_phoneoperators_id` (`plugin_simcard_phoneoperators_id`), 566 | KEY `plugin_simcard_simcardsizes_id` (`plugin_simcard_simcardsizes_id`), 567 | KEY `plugin_simcard_simcardvoltages_id` (`plugin_simcard_simcardvoltages_id`), 568 | KEY `manufacturers_id` (`manufacturers_id`), 569 | KEY `pin` (`pin`), 570 | KEY `pin2` (`pin2`), 571 | KEY `puk` (`puk`), 572 | KEY `puk2` (`puk2`), 573 | KEY `serial` (`serial`), 574 | KEY `users_id` (`users_id`), 575 | KEY `users_id_tech` (`users_id_tech`), 576 | KEY `groups_id` (`groups_id`), 577 | KEY `is_template` (`is_template`), 578 | KEY `is_deleted` (`is_deleted`), 579 | KEY `is_helpdesk_visible` (`is_helpdesk_visible`), 580 | KEY `is_global` (`is_global`) 581 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;"; 582 | $DB->query($query) or die("Error adding table $table"); 583 | } 584 | } 585 | 586 | static function upgrade(Migration $migration) { 587 | global $DB; 588 | 589 | switch (plugin_simcard_currentVersion()) { 590 | case '1.2': 591 | $sql = "ALTER TABLE `glpi_plugin_simcard_simcards` 592 | ADD `plugin_simcard_simcardtypes_id` int(11) NOT NULL DEFAULT '0' AFTER `plugin_simcard_simcardvoltages_id`, 593 | ADD `groups_id_tech` int(11) NOT NULL DEFAULT '0' AFTER `groups_id`"; 594 | 595 | $DB->query($sql) or die($DB->error()); 596 | break; 597 | 598 | case '1.3': 599 | case '1.3.1': 600 | case '1.4': 601 | // Migrate notepad data 602 | if (FieldExists('glpi_plugin_simcard_simcards', 'notepad')) { 603 | $query = "SELECT id, notepad 604 | FROM `glpi_plugin_simcard_simcards` 605 | WHERE notepad IS NOT NULL 606 | AND notepad <> ''"; 607 | foreach ($DB->request($query) as $data) { 608 | $iq = "INSERT INTO `glpi_notepads` 609 | (`itemtype`, `items_id`, `content`, `date`, `date_mod`) 610 | VALUES ('".getItemTypeForTable('glpi_plugin_simcard_simcards')."', '".$data['id']."', 611 | '".addslashes($data['notepad'])."', NOW(), NOW())"; 612 | $DB->queryOrDie($iq, "0.85 migrate notepad data"); 613 | } 614 | $sql = "ALTER TABLE `glpi_plugin_simcard_simcards` 615 | DROP `notepad`"; 616 | 617 | $DB->query($sql) or die($DB->error()); 618 | } 619 | break; 620 | } 621 | } 622 | 623 | static function uninstall() { 624 | global $DB; 625 | 626 | // Remove unicity constraints on simcards 627 | FieldUnicity::deleteForItemtype("SimcardSimcard"); 628 | 629 | foreach (array('Notepad', 'DisplayPreference', 'Contract_Item', 'Infocom', 'Fieldblacklist', 'Document_Item', 'Bookmark', 'Log') as $itemtype) { 630 | $item = new $itemtype(); 631 | $item->deleteByCriteria(array('itemtype' => __CLASS__)); 632 | } 633 | 634 | $plugin = new Plugin(); 635 | if ($plugin->isActivated('datainjection') && class_exists('PluginDatainjectionModel')) { 636 | PluginDatainjectionModel::clean(array('itemtype' => __CLASS__)); 637 | } 638 | 639 | if ($plugin->isInstalled('customfields') && $plugin->isActivated('customfields')) { 640 | PluginCustomfieldsItemtype::unregisterItemtype('PluginSimcardSimcard'); 641 | } 642 | 643 | $table = getTableForItemType(__CLASS__); 644 | $DB->query("DROP TABLE IF EXISTS `$table`"); 645 | } 646 | 647 | function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { 648 | global $LANG; 649 | 650 | if (in_array(get_class($item), PluginSimcardSimcard_Item::getClasses()) 651 | || get_class($item) == 'Profile') { 652 | return array(1 => _sn('SIM card', 'SIM cards', 2, 'simcard')); 653 | } elseif (get_class($item) == __CLASS__) { 654 | return _sn('SIM card', 'SIM cards', 2, 'simcard'); 655 | } 656 | return ''; 657 | } 658 | 659 | /** 660 | * Show tab content for a simcard item 661 | * 662 | * @param CommonGLPI $item 663 | * @param number $tabnum 664 | * @param number $withtemplate 665 | */ 666 | static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { 667 | 668 | $self=new self(); 669 | if($item->getType()=='PluginSimcardSimcard') { 670 | $self->showtotal($item->getField('id')); 671 | } 672 | return true; 673 | } 674 | 675 | /** 676 | * Type than could be linked to a Rack 677 | * 678 | * @param $all boolean, all type, or only allowed ones 679 | * 680 | * @return array of types 681 | **/ 682 | static function getTypes($all=false) { 683 | 684 | if ($all) { 685 | return self::$types; 686 | } 687 | 688 | // Only allowed types 689 | $types = self::$types; 690 | 691 | foreach ($types as $key => $type) { 692 | if (!class_exists($type)) { 693 | continue; 694 | } 695 | 696 | $item = new $type(); 697 | if (!$item->canView()) { 698 | unset($types[$key]); 699 | } 700 | } 701 | return $types; 702 | } 703 | 704 | /** 705 | * Add menu entries the plugin needs to show 706 | * 707 | * @return array 708 | */ 709 | static function getMenuContent() { 710 | global $CFG_GLPI; 711 | 712 | $menu = array(); 713 | $menu['title'] = self::getTypeName(2); 714 | $menu['page'] = self::getSearchURL(false); 715 | $menu['links']['search'] = self::getSearchURL(false); 716 | if (self::canCreate()) { 717 | $menu['links']['add'] = '/front/setup.templates.php?itemtype=PluginSimcardSimcard&add=1'; 718 | $menu['links']['template'] = '/front/setup.templates.php?itemtype=PluginSimcardSimcard&add=0'; 719 | } 720 | return $menu; 721 | } 722 | 723 | 724 | /** 725 | * Actions done when item is deleted from the database 726 | * 727 | * @return nothing 728 | * */ 729 | function cleanDBonPurge() { 730 | $link = new PluginSimcardSimcard_Item(); 731 | $link->cleanDBonItemDelete($this->getType(), $this->getID()); 732 | } 733 | 734 | /** 735 | * Delete an item in the database. 736 | * 737 | * @see CommonDBTM::delete() 738 | * 739 | * @param $input array the _POST vars returned by the item form when press delete 740 | * @param $force boolean force deletion (default 0) 741 | * @param $history boolean do history log ? (default 1) 742 | * 743 | * @return boolean : true on success 744 | **/ 745 | function delete(array $input, $force=0, $history=1) { 746 | $deleteSuccessful = parent::delete($input, $force, $history); 747 | if ($deleteSuccessful != false) { 748 | if ($force == 1) { 749 | $notepad = new Notepad(); 750 | $notepad->deleteByCriteria(array( 751 | 'itemtype' => 'PluginSimcardSimcard', 752 | 'items_id' => $input['id'] 753 | )); 754 | } 755 | } 756 | return $deleteSuccessful; 757 | } 758 | 759 | /** 760 | * @since version 0.85 761 | * 762 | * @see CommonDBTM::getSpecificMassiveActions() 763 | * */ 764 | function getSpecificMassiveActions($checkitem = NULL) { 765 | $isadmin = static::canUpdate(); 766 | $actions = parent::getSpecificMassiveActions($checkitem); 767 | 768 | if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { 769 | if ($isadmin) { 770 | if (Session::haveRight('transfer', READ) && Session::isMultiEntitiesMode()) { 771 | $actions['PluginSimcardSimcard'.MassiveAction::CLASS_ACTION_SEPARATOR.'transfer'] = __('Transfer'); 772 | } 773 | } 774 | } 775 | return $actions; 776 | } 777 | 778 | /** 779 | * @since version 0.85 780 | * 781 | * @see CommonDBTM::showMassiveActionsSubForm() 782 | * */ 783 | static function showMassiveActionsSubForm(MassiveAction $ma) { 784 | 785 | switch ($ma->getAction()) { 786 | case "transfer" : 787 | Dropdown::show('Entity'); 788 | echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')); 789 | return true; 790 | break; 791 | } 792 | return parent::showMassiveActionsSubForm($ma); 793 | } 794 | 795 | /** 796 | * @since version 0.85 797 | * 798 | * @see CommonDBTM::processMassiveActionsForOneItemtype() 799 | * */ 800 | static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { 801 | global $DB; 802 | 803 | switch ($ma->getAction()) { 804 | case "transfer" : 805 | $input = $ma->getInput(); 806 | if ($item->getType() == 'PluginSimcardSimcard') { 807 | foreach ($ids as $key) { 808 | // Types 809 | $item->getFromDB($key); 810 | $type = PluginSimcardSimcardType::transfer($item->fields["plugin_simcard_simcardtypes_id"], $input['entities_id']); 811 | if ($type > 0) { 812 | $values["id"] = $key; 813 | $values["plugin_simcard_simcardtypes_id"] = $type; 814 | $item->update($values); 815 | } 816 | 817 | // Size 818 | $size = PluginSimcardSimcardSize::transfer($item->fields["plugin_simcard_simcardsizes_id"], $input['entities_id']); 819 | if ($size > 0) { 820 | $values["id"] = $key; 821 | $values["plugin_simcard_simcardsizes_id"] = $size; 822 | $item->update($values); 823 | } 824 | 825 | // Voltage 826 | $voltage = PluginSimcardSimcardVoltage::transfer($item->fields["plugin_simcard_simcardvoltages_id"], $input['entities_id']); 827 | if ($voltage > 0) { 828 | $values["id"] = $key; 829 | $values["plugin_simcard_simcardvoltages_id"] = $voltage; 830 | $item->update($values); 831 | } 832 | 833 | // Phoneoperator 834 | $phoneoperator = PluginSimcardPhoneOperator::transfer($item->fields["plugin_simcard_phoneoperators_id"], $input['entities_id']); 835 | if ($phoneoperator > 0) { 836 | $values["id"] = $key; 837 | $values["plugin_simcard_phoneoperators_id"] = $phoneoperator; 838 | $item->update($values); 839 | } 840 | 841 | unset($values); 842 | $values["id"] = $key; 843 | $values["entities_id"] = $input['entities_id']; 844 | 845 | if ($item->update($values)) { 846 | $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); 847 | } else { 848 | $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); 849 | } 850 | } 851 | } 852 | return; 853 | } 854 | parent::processMassiveActionsForOneItemtype($ma, $item, $ids); 855 | } 856 | 857 | } 858 | ?> 859 | -------------------------------------------------------------------------------- /inc/simcard_item.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')) { 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | // Relation between Simcard and Items (computer, phone, peripheral only) 36 | class PluginSimcardSimcard_Item extends CommonDBRelation{ 37 | 38 | // From CommonDBRelation 39 | static public $itemtype_1 = 'PluginSimcardSimcard'; 40 | static public $items_id_1 = 'plugin_simcard_simcards_id'; 41 | 42 | static public $itemtype_2 = 'itemtype'; 43 | static public $items_id_2 = 'items_id'; 44 | 45 | // Itemtypes simcards may be linked to 46 | static protected $linkableClasses = array( 47 | 'Computer', 48 | 'Peripheral', 49 | 'Phone', 50 | 'Printer', 51 | 'NetworkEquipment' 52 | ); 53 | 54 | /** 55 | * Name of the type 56 | * 57 | * @param $nb integer number of item in the type (default 0) 58 | **/ 59 | static function getTypeName($nb=0) { 60 | global $LANG; 61 | return __s('Direct Connections'); 62 | } 63 | 64 | /** 65 | * Check right on an item - overloaded to check is_global 66 | * 67 | * @param $ID ID of the item (-1 if new item) 68 | * @param $right Right to check : r / w / recursive 69 | * @param $input array of input data (used for adding item) (default NULL) 70 | * 71 | * @return boolean 72 | **/ 73 | function can($ID, $right, array &$input=NULL) { 74 | 75 | if ($ID<0) { 76 | // Ajout 77 | if (!($item = new $input['itemtype'])) { 78 | return false; 79 | } 80 | 81 | if (!$item->getFromDB($input['items_id'])) { 82 | return false; 83 | } 84 | if ($item->getField('is_global')==0 85 | && self::countForItem($ID) > 0) { 86 | return false; 87 | } 88 | } 89 | return parent::can($ID, $right, $input); 90 | } 91 | 92 | static function countForItem($id) { 93 | return countElementsInTable(getTableForItemType(__CLASS__), 94 | "`plugin_simcard_simcards_id`='$id'"); 95 | } 96 | 97 | /** 98 | * Count the number of relations having the itemtype of $item 99 | * 100 | * @param CommonDBTM $item Item whose relations to simcards shall be counted 101 | * @return integer count of relations between the item and simcards 102 | */ 103 | static function countForItemByItemtype(CommonDBTM $item) { 104 | $id = $item->getField('id'); 105 | $itemtype = $item->getType(); 106 | return countElementsInTable(getTableForItemType(__CLASS__), 107 | "`items_id`='$id' AND `itemtype`='$itemtype'"); 108 | } 109 | 110 | /** 111 | * Hook called After an item is uninstall or purge 112 | */ 113 | static function cleanForItem(CommonDBTM $item) { 114 | $temp = new self(); 115 | $temp->deleteByCriteria( 116 | array('itemtype' => $item->getType(), 117 | 'items_id' => $item->getField('id'))); 118 | } 119 | 120 | static function getClasses() { 121 | return self::$linkableClasses; 122 | } 123 | 124 | /** 125 | * Declare a new itemtype to be linkable to a simcard 126 | */ 127 | static function registerItemtype($itemtype) { 128 | if (!in_array($itemtype, self::$linkableClasses)) { 129 | array_push(self::$linkableClasses, $itemtype); 130 | Plugin::registerClass('PluginSimcardSimcard_Item', 131 | array('addtabon' => $itemtype)); 132 | } 133 | } 134 | 135 | static function install(Migration $migration) { 136 | global $DB; 137 | $table = getTableForItemType(__CLASS__); 138 | if (!TableExists($table)) { 139 | $query = "CREATE TABLE IF NOT EXISTS `$table` ( 140 | `id` int(11) NOT NULL AUTO_INCREMENT, 141 | `items_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to various table, according to itemtype (id)', 142 | `plugin_simcard_simcards_id` int(11) NOT NULL DEFAULT '0', 143 | `itemtype` varchar(100) COLLATE utf8_unicode_ci NOT NULL, 144 | PRIMARY KEY (`id`), 145 | KEY `plugin_simcard_simcards_id` (`plugin_simcard_simcards_id`), 146 | KEY `item` (`itemtype`,`items_id`) 147 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; 148 | $DB->query($query) or die ($DB->error()); 149 | } 150 | } 151 | 152 | /** 153 | * 154 | * 155 | * @since 1.3 156 | **/ 157 | static function upgrade(Migration $migration) { 158 | global $DB; 159 | 160 | } 161 | 162 | static function uninstall() { 163 | global $DB; 164 | $table = getTableForItemType(__CLASS__); 165 | $DB->query("DROP TABLE IF EXISTS `$table`"); 166 | } 167 | 168 | static function showForSimcard(PluginSimcardSimcard $simcard) { 169 | global $DB, $LANG; 170 | 171 | if (!$simcard->canView()) { 172 | return false; 173 | } 174 | $results = getAllDatasFromTable(getTableForItemType(__CLASS__), 175 | "`plugin_simcard_simcards_id` = '".$simcard->getID()."'"); 176 | echo "
"; 177 | echo ""; 178 | echo ""; 179 | echo ""; 180 | if (!empty($results)) { 181 | echo ""; 182 | echo ""; 183 | echo ""; 184 | echo ""; 185 | echo ""; 186 | echo ""; 187 | echo ""; 188 | foreach ($results as $data) { 189 | $item = new $data['itemtype']; 190 | $item->getFromDB($data['items_id']); 191 | echo ""; 192 | echo ""; 197 | echo ""; 200 | echo ""; 203 | echo ""; 206 | echo ""; 213 | echo ""; 218 | echo ""; 219 | } 220 | } 221 | 222 | if (PluginSimcardsimcard::canUpdate()) { 223 | echo ""; 229 | echo ""; 232 | } 233 | 234 | if (!empty($results)) { 235 | Html::openArrowMassives('items', true); 236 | Html::closeArrowMassives(array('delete_items' => _sx('button', 'Disconnect'))); 237 | } 238 | } 239 | echo "
".__("Associated item")."
".__s("Type")."".__s("Entity")."".__s("Name")."".__s("Serial number")."".__s("Inventory number")."
"; 193 | if (PluginSimcardSimcard::canUpdate()) { 194 | echo ""; 195 | } 196 | echo ""; 198 | echo call_user_func(array($data['itemtype'], 'getTypeName')); 199 | echo ""; 201 | echo Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']); 202 | echo ""; 204 | echo $item->getLink(); 205 | echo ""; 207 | if (isset($item->fields['serial'])) { 208 | echo $item->fields['serial']; 209 | } else { 210 | 211 | } 212 | echo ""; 214 | if (isset($item->fields['otherserial'])) { 215 | echo $item->fields['otherserial']; 216 | } 217 | echo "
"; 224 | if (empty($results)) { 225 | echo ""; 226 | // TODO : Dropdown::showAllItems is deprecated, use Dropdown::showSelectItemFromItemtypes instead 227 | Dropdown::showAllItems("items_id",0,0,$simcard->fields['entities_id'], self::getClasses()); 228 | echo ""; 230 | echo ""; 231 | echo "
" ; 240 | Html::closeForm(); 241 | echo "
"; 242 | } 243 | 244 | static function showForItem(CommonDBTM $item) { 245 | global $DB, $LANG; 246 | 247 | if (!$item->canView()) { 248 | return false; 249 | } 250 | 251 | // if (PluginSimcardSimcard::canCreate()) { 252 | // if ($item->canEdit($item->getField('id'))) { 253 | // $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard'); 254 | // $url.= "?itemtype=".$item->getType()."&items_id=".$item->getID()."&id=-1"; 255 | // echo "
"; 256 | 257 | // } 258 | // } 259 | $results = getAllDatasFromTable(getTableForItemType(__CLASS__), 260 | "`items_id` = '".$item->getID()."' AND `itemtype`='".get_class($item)."'"); 261 | echo "
"; 262 | echo ""; 263 | echo ""; 264 | echo ""; 265 | if (!empty($results)) { 266 | echo ""; 267 | echo ""; 268 | echo ""; 269 | echo ""; 270 | echo ""; 271 | echo ""; 272 | foreach ($results as $data) { 273 | $tmp = new PluginSimcardSimcard(); 274 | $tmp->getFromDB($data['plugin_simcard_simcards_id']); 275 | echo ""; 276 | echo ""; 281 | echo ""; 284 | echo ""; 287 | echo ""; 290 | echo ""; 293 | echo ""; 294 | } 295 | } 296 | 297 | if (PluginSimcardSimcard::canUpdate()) { 298 | echo ""; 314 | echo ""; 317 | 318 | if (!empty($results)) { 319 | Html::openArrowMassives('items', true); 320 | Html::closeArrowMassives(array ('delete_items' => _sx('button', 'Disconnect'))); 321 | } 322 | } 323 | echo "
".__s('Associated item')."
".__s('Entity')."".__s('Name')."".__s('IMSI')."".__s('Inventory number')."
"; 277 | if (PluginSimcardSimcard::canDelete()) { 278 | echo ""; 279 | } 280 | echo ""; 282 | echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']); 283 | echo ""; 285 | echo $tmp->getLink(); 286 | echo ""; 288 | echo $tmp->fields['serial']; 289 | echo ""; 291 | echo $tmp->fields['otherserial']; 292 | echo "
"; 299 | echo ""; 300 | echo ""; 301 | $used = array(); 302 | $query = "SELECT `id` 303 | FROM `glpi_plugin_simcard_simcards` 304 | WHERE `is_template`='0' 305 | AND `id` IN (SELECT `plugin_simcard_simcards_id` 306 | FROM `glpi_plugin_simcard_simcards_items`)"; 307 | foreach ($DB->request($query) as $use) { 308 | $used[] = $use['id']; 309 | } 310 | Dropdown::show('PluginSimcardSimcard', 311 | array ('name' => "plugin_simcard_simcards_id", 312 | 'entity' => $item->fields['entities_id'], 'used' => $used)); 313 | echo ""; 315 | echo ""; 316 | echo "
" ; 324 | Html::closeForm(); 325 | echo "
"; 326 | } 327 | 328 | function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { 329 | global $CFG_GLPI; 330 | 331 | if (PluginSimcardSimcard::canView()) { 332 | switch ($item->getType()) { 333 | case 'PluginSimcardSimcard' : 334 | if ($_SESSION['glpishow_count_on_tabs']) { 335 | return self::createTabEntry(_n('Associated item', 'Associated items', 2), self::countForSimcard($item)); 336 | } 337 | return _n('Associated item', 'Associated items', 2); 338 | 339 | default : 340 | if ($_SESSION['glpishow_count_on_tabs']) { 341 | return self::createTabEntry(PluginSimcardSimcard::getTypeName(2), self::countForItemByItemtype($item)); 342 | } 343 | return _n('SIM card', 'SIM cards', 2); 344 | 345 | } 346 | } 347 | return ''; 348 | } 349 | 350 | 351 | /** 352 | * 353 | * Count the number of associated items for a simcard item 354 | * 355 | * @param $item Simcard object 356 | **/ 357 | static function countForSimcard(PluginSimcardSimcard $item) { 358 | 359 | $restrict = "`glpi_plugin_simcard_simcards_items`.`plugin_simcard_simcards_id` = '".$item->getField('id')."'"; 360 | 361 | return countElementsInTable(array('glpi_plugin_simcard_simcards_items'), $restrict); 362 | } 363 | 364 | static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { 365 | 366 | if (in_array(get_class($item), PluginSimcardSimcard_Item::getClasses())) { 367 | self::showForItem($item); 368 | } elseif (get_class($item) == 'PluginSimcardSimcard') { 369 | self::showForSimcard($item); 370 | } 371 | return true; 372 | } 373 | } 374 | ?> 375 | -------------------------------------------------------------------------------- /inc/simcardinjection.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')){ 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | /// class SimcardInjection 36 | class PluginSimcardSimcardInjection extends PluginSimcardSimcard 37 | implements PluginDatainjectionInjectionInterface { 38 | 39 | function __construct() { 40 | //Needed for getSearchOptions ! 41 | $this->table = getTableForItemType(get_parent_class($this)); 42 | } 43 | 44 | 45 | function isPrimaryType() { 46 | return true; 47 | } 48 | 49 | 50 | function connectedTo() { 51 | return array(); 52 | } 53 | 54 | 55 | static function getTable() { 56 | $parenttype = get_parent_class(); 57 | return $parenttype::getTable(); 58 | } 59 | 60 | function getOptions($primary_type = '') { 61 | return Search::getOptions(get_parent_class($this)); 62 | } 63 | 64 | 65 | /** 66 | * Standard method to add an object into glpi 67 | * 68 | * @param values fields to add into glpi 69 | * @param options options used during creation 70 | * 71 | * @return an array of IDs of newly created objects : for example array(Computer=>1, Networkport=>10) 72 | */ 73 | function addOrUpdateObject($values=array(), $options=array()) { 74 | 75 | $lib = new PluginDatainjectionCommonInjectionLib($this,$values,$options); 76 | $lib->processAddOrUpdate(); 77 | return $lib->getInjectionResults(); 78 | } 79 | } 80 | 81 | ?> 82 | -------------------------------------------------------------------------------- /inc/simcardsize.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')) { 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | /// Class SimcardSize 36 | class PluginSimcardSimcardSize extends CommonDropdown { 37 | 38 | 39 | static function getTypeName($nb=0) { 40 | global $LANG; 41 | return __s('Size', 'simcard'); 42 | } 43 | 44 | static function install(Migration $migration) { 45 | global $DB; 46 | $table = getTableForItemType(__CLASS__); 47 | if (!TableExists($table)) { 48 | $query = "CREATE TABLE IF NOT EXISTS `$table` ( 49 | `id` int(11) NOT NULL AUTO_INCREMENT, 50 | `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 51 | `comment` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 52 | PRIMARY KEY (`id`), 53 | KEY `name` (`name`) 54 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; 55 | $DB->query($query) or die ("Error adding table $table"); 56 | 57 | $query = "INSERT INTO `$table` (`id`, `name`, `comment`) VALUES 58 | (1, 'Full-SIM', ''), 59 | (2, 'Micro-SIM', ''), 60 | (3, 'Mini-SIM', ''), 61 | (4, 'Nano-SIM', '');"; 62 | $DB->query($query) or die("Error adding simcard sizes"); 63 | } 64 | } 65 | 66 | /** 67 | * 68 | * 69 | * @since 1.3 70 | **/ 71 | static function upgrade(Migration $migration) { 72 | global $DB; 73 | 74 | } 75 | 76 | static function uninstall() { 77 | global $DB; 78 | 79 | foreach (array('DisplayPreference', 'Bookmark') as $itemtype) { 80 | $item = new $itemtype(); 81 | $item->deleteByCriteria(array('itemtype' => __CLASS__)); 82 | } 83 | 84 | // Remove dropdowns localization 85 | $dropdownTranslation = new DropdownTranslation(); 86 | $dropdownTranslation->deleteByCriteria(array("itemtype = 'PluginSimcardSimcardSize'"), 1); 87 | 88 | $table = getTableForItemType(__CLASS__); 89 | $DB->query("DROP TABLE IF EXISTS `$table`"); 90 | } 91 | 92 | static function transfer($ID, $entity) { 93 | global $DB; 94 | 95 | $simcardSize = new self(); 96 | 97 | if ($ID > 0) { 98 | // Not already transfer 99 | // Search init item 100 | $query = "SELECT * 101 | FROM `".$simcardSize->getTable()."` 102 | WHERE `id` = '$ID'"; 103 | 104 | if ($result = $DB->query($query)) { 105 | if ($DB->numrows($result)) { 106 | $data = $DB->fetch_assoc($result); 107 | $data = Toolbox::addslashes_deep($data); 108 | $input['name'] = $data['name']; 109 | $input['entities_id'] = $entity; 110 | $newID = $simcardSize->getID($input); 111 | 112 | if ($newID < 0) { 113 | $newID = $simcardSize->import($input); 114 | } 115 | 116 | return $newID; 117 | } 118 | } 119 | } 120 | return 0; 121 | } 122 | } 123 | ?> 124 | -------------------------------------------------------------------------------- /inc/simcardtype.class.php: -------------------------------------------------------------------------------- 1 | . 21 | -------------------------------------------------------------------------- 22 | @package simcard 23 | @author the simcard plugin team 24 | @copyright Copyright (c) 2010-2011 Simcard plugin team 25 | @license GPLv2+ 26 | http://www.gnu.org/licenses/gpl.txt 27 | @link https://github.com/pluginsglpi/simcard 28 | @link http://www.glpi-project.org/ 29 | @since 2009 30 | ---------------------------------------------------------------------- */ 31 | 32 | if (!defined('GLPI_ROOT')) { 33 | die("Sorry. You can't access directly to this file"); 34 | } 35 | 36 | /// Class SimcardType 37 | class PluginSimcardSimcardType extends CommonDropdown { 38 | 39 | static function getTypeName($nb = 0) { 40 | global $LANG; 41 | return __s('Type of SIM card', 'simcard'); 42 | } 43 | 44 | static function install(Migration $migration) { 45 | global $DB; 46 | 47 | $table = getTableForItemType(__CLASS__); 48 | if (!TableExists($table)) { 49 | $query = "CREATE TABLE IF NOT EXISTS `$table` ( 50 | `id` int(11) NOT NULL AUTO_INCREMENT, 51 | `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 52 | `comment` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 53 | PRIMARY KEY (`id`), 54 | KEY `name` (`name`) 55 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; 56 | $DB->query($query) or die("Error adding table $table"); 57 | } 58 | } 59 | 60 | /** 61 | * 62 | * 63 | * @since 1.3 64 | * */ 65 | static function upgrade(Migration $migration) { 66 | global $DB; 67 | 68 | switch (plugin_simcard_currentVersion()) { 69 | case '1.2': 70 | self::install($migration); 71 | break; 72 | } 73 | } 74 | 75 | static function uninstall() { 76 | global $DB; 77 | 78 | foreach (array('DisplayPreference', 'Bookmark') as $itemtype) { 79 | $item = new $itemtype(); 80 | $item->deleteByCriteria(array('itemtype' => __CLASS__)); 81 | } 82 | 83 | // Remove dropdowns localization 84 | $dropdownTranslation = new DropdownTranslation(); 85 | $dropdownTranslation->deleteByCriteria(array("itemtype = 'PluginSimcardSimcardType'"), 1); 86 | 87 | $table = getTableForItemType(__CLASS__); 88 | $DB->query("DROP TABLE IF EXISTS `$table`"); 89 | } 90 | 91 | static function transfer($ID, $entity) { 92 | global $DB; 93 | 94 | $simcardType = new self(); 95 | 96 | if ($ID > 0) { 97 | // Not already transfer 98 | // Search init item 99 | $query = "SELECT * 100 | FROM `".$simcardType->getTable()."` 101 | WHERE `id` = '$ID'"; 102 | 103 | if ($result = $DB->query($query)) { 104 | if ($DB->numrows($result)) { 105 | $data = $DB->fetch_assoc($result); 106 | $data = Toolbox::addslashes_deep($data); 107 | $input['name'] = $data['name']; 108 | $input['entities_id'] = $entity; 109 | $newID = $simcardType->getID($input); 110 | 111 | if ($newID < 0) { 112 | $newID = $simcardType->import($input); 113 | } 114 | 115 | return $newID; 116 | } 117 | } 118 | } 119 | return 0; 120 | } 121 | 122 | } 123 | 124 | ?> 125 | -------------------------------------------------------------------------------- /inc/simcardvoltage.class.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | if (!defined('GLPI_ROOT')) { 32 | die("Sorry. You can't access directly to this file"); 33 | } 34 | 35 | /// Class SimcardVoltage 36 | class PluginSimcardSimcardVoltage extends CommonDropdown { 37 | 38 | 39 | static function getTypeName($nb=0) { 40 | global $LANG; 41 | return __s('Voltage', 'simcard'); 42 | } 43 | 44 | static function install(Migration $migration) { 45 | global $DB; 46 | 47 | $table = getTableForItemType(__CLASS__); 48 | if (!TableExists($table)) { 49 | $query = "CREATE TABLE IF NOT EXISTS `$table` ( 50 | `id` int(11) NOT NULL AUTO_INCREMENT, 51 | `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 52 | `comment` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, 53 | PRIMARY KEY (`id`), 54 | KEY `name` (`name`) 55 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; 56 | $DB->query($query) or die ("Error adding table $table"); 57 | 58 | $query = "INSERT INTO `$table` (`id`, `name`, `comment`) VALUES 59 | (1, '3V', ''), 60 | (2, '5V', '');"; 61 | $DB->query($query) or die("Error adding simcard voltages"); 62 | } 63 | } 64 | 65 | /** 66 | * 67 | * 68 | * @since 1.3 69 | **/ 70 | static function upgrade(Migration $migration) { 71 | global $DB; 72 | 73 | } 74 | 75 | static function uninstall() { 76 | global $DB; 77 | 78 | foreach (array('DisplayPreference', 'Bookmark') as $itemtype) { 79 | $item = new $itemtype(); 80 | $item->deleteByCriteria(array('itemtype' => __CLASS__)); 81 | } 82 | 83 | // Remove dropdowns localization 84 | $dropdownTranslation = new DropdownTranslation(); 85 | $dropdownTranslation->deleteByCriteria(array("itemtype LIKE 'PluginSimcardSimcardVoltage'"), 1); 86 | 87 | $table = getTableForItemType(__CLASS__); 88 | $DB->query("DROP TABLE IF EXISTS `$table`"); 89 | } 90 | 91 | static function transfer($ID, $entity) { 92 | global $DB; 93 | 94 | $simcardVoltage = new self(); 95 | 96 | if ($ID > 0) { 97 | // Not already transfer 98 | // Search init item 99 | $query = "SELECT * 100 | FROM `".$simcardVoltage->getTable()."` 101 | WHERE `id` = '$ID'"; 102 | 103 | if ($result = $DB->query($query)) { 104 | if ($DB->numrows($result)) { 105 | $data = $DB->fetch_assoc($result); 106 | $data = Toolbox::addslashes_deep($data); 107 | $input['name'] = $data['name']; 108 | $input['entities_id'] = $entity; 109 | $newID = $simcardVoltage->getID($input); 110 | 111 | if ($newID < 0) { 112 | $newID = $simcardVoltage->import($input); 113 | } 114 | 115 | return $newID; 116 | } 117 | } 118 | } 119 | return 0; 120 | } 121 | 122 | } 123 | ?> 124 | -------------------------------------------------------------------------------- /locales/en_GB.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluginsGLPI/simcard/a7ff91e83c26630c50b73dcd961d7b32c23d00b4/locales/en_GB.mo -------------------------------------------------------------------------------- /locales/en_GB.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2014-04-23 21:04+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" 20 | 21 | #: hook.php:163 inc/simcard.class.php:181 inc/simcard.class.php:427 22 | #: inc/simcardsize.class.php:41 23 | msgid "Size" 24 | msgstr "Size" 25 | 26 | #: hook.php:164 inc/phoneoperator.class.php:40 inc/simcard.class.php:204 27 | #: inc/simcard.class.php:435 28 | msgid "Provider" 29 | msgstr "Provider" 30 | 31 | #: hook.php:165 hook.php:231 inc/simcard.class.php:197 32 | #: inc/simcard.class.php:409 inc/simcardvoltage.class.php:41 33 | msgid "Voltage" 34 | msgstr "Voltage" 35 | 36 | #: hook.php:166 inc/simcard.class.php:167 inc/simcardtype.class.php:41 37 | msgid "Type of SIM card" 38 | msgstr "Type of SIM card" 39 | 40 | #: hook.php:222 inc/simcard.class.php:243 inc/simcard.class.php:443 41 | msgid "Phone number" 42 | msgstr "Phone number" 43 | 44 | #: setup.php:130 45 | msgid "Sim cards management" 46 | msgstr "Sim cards management" 47 | 48 | #: inc/profile.class.php:127 49 | msgid "Right manager" 50 | msgstr "Right manager" 51 | 52 | #: inc/profile.class.php:263 inc/simcard.class.php:54 53 | msgid "SIM card" 54 | msgid_plural "SIM cards" 55 | msgstr[0] "SIM card" 56 | msgstr[1] "SIM cards" 57 | 58 | #: inc/simcard.class.php:253 inc/simcard.class.php:367 59 | msgid "IMSI" 60 | msgstr "IMSI" 61 | 62 | #: inc/simcard.class.php:273 inc/simcard.class.php:453 63 | msgid "Pin 1" 64 | msgstr "Pin 1" 65 | 66 | #: inc/simcard.class.php:279 inc/simcard.class.php:469 67 | msgid "Pin 2" 68 | msgstr "Pin 2" 69 | 70 | #: inc/simcard.class.php:285 inc/simcard.class.php:461 71 | msgid "Puk 1" 72 | msgstr "Puk 1" 73 | 74 | #: inc/simcard.class.php:291 inc/simcard.class.php:477 75 | msgid "Puk 2" 76 | msgstr "Puk 2" 77 | 78 | #: inc/simcard_item.class.php:217 79 | msgid "New SIM card" 80 | msgstr "New SIM card" 81 | -------------------------------------------------------------------------------- /locales/es_ES.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluginsGLPI/simcard/a7ff91e83c26630c50b73dcd961d7b32c23d00b4/locales/es_ES.mo -------------------------------------------------------------------------------- /locales/es_ES.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2014-04-23 21:04+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" 20 | 21 | #: hook.php:163 inc/simcard.class.php:181 inc/simcard.class.php:427 22 | #: inc/simcardsize.class.php:41 23 | msgid "Size" 24 | msgstr "Tamaño" 25 | 26 | #: hook.php:164 inc/phoneoperator.class.php:40 inc/simcard.class.php:204 27 | #: inc/simcard.class.php:435 28 | msgid "Provider" 29 | msgstr "Proveedor" 30 | 31 | #: hook.php:165 hook.php:231 inc/simcard.class.php:197 32 | #: inc/simcard.class.php:409 inc/simcardvoltage.class.php:41 33 | msgid "Voltage" 34 | msgstr "Voltaje" 35 | 36 | #: hook.php:166 inc/simcard.class.php:167 inc/simcardtype.class.php:41 37 | msgid "Type of SIM card" 38 | msgstr "Tipo de tarjeta SIM" 39 | 40 | #: hook.php:222 inc/simcard.class.php:243 inc/simcard.class.php:443 41 | msgid "Phone number" 42 | msgstr "Número de Teléfono" 43 | 44 | #: setup.php:130 45 | msgid "Sim cards management" 46 | msgstr "Tarjetas SIM" 47 | 48 | #: inc/profile.class.php:127 49 | msgid "Right manager" 50 | msgstr "Privilegios de Gestión" 51 | 52 | #: inc/profile.class.php:263 inc/simcard.class.php:54 53 | msgid "SIM card" 54 | msgid_plural "SIM cards" 55 | msgstr[0] "" 56 | msgstr[1] "" 57 | 58 | #: inc/simcard.class.php:253 inc/simcard.class.php:367 59 | msgid "IMSI" 60 | msgstr "IMSI" 61 | 62 | #: inc/simcard.class.php:273 inc/simcard.class.php:453 63 | msgid "Pin 1" 64 | msgstr "Pin 1" 65 | 66 | #: inc/simcard.class.php:279 inc/simcard.class.php:469 67 | msgid "Pin 2" 68 | msgstr "Pin 2" 69 | 70 | #: inc/simcard.class.php:285 inc/simcard.class.php:461 71 | msgid "Puk 1" 72 | msgstr "" 73 | 74 | #: inc/simcard.class.php:291 inc/simcard.class.php:477 75 | msgid "Puk 2" 76 | msgstr "" 77 | 78 | #: inc/simcard_item.class.php:217 79 | msgid "New SIM card" 80 | msgstr "Nueva tarjeta SIM" 81 | -------------------------------------------------------------------------------- /locales/fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluginsGLPI/simcard/a7ff91e83c26630c50b73dcd961d7b32c23d00b4/locales/fr_FR.mo -------------------------------------------------------------------------------- /locales/fr_FR.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2014-04-23 20:42+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Plural-Forms: nplurals=2; plural=n > 1;\n" 20 | 21 | #: hook.php:163 inc/simcard.class.php:181 inc/simcard.class.php:427 22 | #: inc/simcardsize.class.php:41 23 | msgid "Size" 24 | msgstr "Taille" 25 | 26 | #: hook.php:164 inc/phoneoperator.class.php:40 inc/simcard.class.php:204 27 | #: inc/simcard.class.php:435 28 | msgid "Provider" 29 | msgstr "Opérateur" 30 | 31 | #: hook.php:165 inc/simcard.class.php:409 inc/simcardvoltage.class.php:41 32 | msgid "Voltage" 33 | msgstr "Voltage" 34 | 35 | #: hook.php:166 inc/simcard.class.php:167 inc/simcardtype.class.php:41 36 | msgid "Type of SIM card" 37 | msgstr "Type de carte SIM" 38 | 39 | #: setup.php:130 40 | msgid "Sim cards management" 41 | msgstr "Gestion de cartes SIM" 42 | 43 | #: inc/profile.class.php:127 44 | msgid "Right manager" 45 | msgstr "Gestion des droits" 46 | 47 | #: inc/simcard.class.php:54 48 | msgid "SIM card" 49 | msgid_plural "SIM cards" 50 | msgstr[0] "Carte SIM" 51 | msgstr[1] "Cartes SIM" 52 | 53 | #: inc/simcard.class.php:243 inc/simcard.class.php:443 54 | msgid "Phone number" 55 | msgstr "Numéro de téléphone" 56 | 57 | #: inc/simcard.class.php:253 inc/simcard.class.php:367 58 | msgid "IMSI" 59 | msgstr "IMSI" 60 | 61 | #: inc/simcard.class.php:273 inc/simcard.class.php:453 62 | msgid "Pin 1" 63 | msgstr "PIN" 64 | 65 | #: inc/simcard.class.php:279 inc/simcard.class.php:469 66 | msgid "Pin 2" 67 | msgstr "PIN 2" 68 | 69 | #: inc/simcard.class.php:285 inc/simcard.class.php:461 70 | msgid "Puk 1" 71 | msgstr "PUK" 72 | 73 | #: inc/simcard.class.php:291 inc/simcard.class.php:477 74 | msgid "Puk 2" 75 | msgstr "PUK 2" 76 | 77 | #: inc/simcard_item.class.php:217 78 | msgid "New SIM card" 79 | msgstr "Nouvelle carte SIM" 80 | -------------------------------------------------------------------------------- /locales/ru_RU.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluginsGLPI/simcard/a7ff91e83c26630c50b73dcd961d7b32c23d00b4/locales/ru_RU.mo -------------------------------------------------------------------------------- /locales/ru_RU.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: simcard 1.4.1\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2014-04-23 21:04+0200\n" 11 | "PO-Revision-Date: 2015-11-17 15:14+0300\n" 12 | "Last-Translator: Igor Sidorenko \n" 13 | "Language-Team: Igor Sidorenko \n" 14 | "MIME-Version: 1.0\n" 15 | "Content-Type: text/plain; charset=UTF-8\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 18 | "X-Generator: Poedit 1.5.4\n" 19 | "Language: Russian\n" 20 | 21 | #: hook.php:163 inc/simcard.class.php:181 inc/simcard.class.php:427 22 | #: inc/simcardsize.class.php:41 23 | msgid "Size" 24 | msgstr "Размер" 25 | 26 | #: hook.php:164 inc/phoneoperator.class.php:40 inc/simcard.class.php:204 27 | #: inc/simcard.class.php:435 28 | msgid "Provider" 29 | msgstr "Провайдер" 30 | 31 | #: hook.php:165 hook.php:231 inc/simcard.class.php:197 32 | #: inc/simcard.class.php:409 inc/simcardvoltage.class.php:41 33 | msgid "Voltage" 34 | msgstr "Вольтаж" 35 | 36 | #: hook.php:166 inc/simcard.class.php:167 inc/simcardtype.class.php:41 37 | msgid "Type of SIM card" 38 | msgstr "Тип SIM-карты" 39 | 40 | #: hook.php:222 inc/simcard.class.php:243 inc/simcard.class.php:443 41 | msgid "Phone number" 42 | msgstr "Телефонный номер" 43 | 44 | #: setup.php:130 45 | msgid "Sim cards management" 46 | msgstr "Управление SIM-картами" 47 | 48 | #: inc/profile.class.php:127 49 | msgid "Right manager" 50 | msgstr "Права менеджера" 51 | 52 | #: inc/profile.class.php:263 inc/simcard.class.php:54 53 | msgid "SIM card" 54 | msgid_plural "SIM cards" 55 | msgstr[0] "SIM-карта" 56 | msgstr[1] "SIM-карты" 57 | 58 | #: inc/simcard.class.php:253 inc/simcard.class.php:367 59 | msgid "IMSI" 60 | msgstr "IMSI" 61 | 62 | #: inc/simcard.class.php:273 inc/simcard.class.php:453 63 | msgid "Pin 1" 64 | msgstr "Pin 1" 65 | 66 | #: inc/simcard.class.php:279 inc/simcard.class.php:469 67 | msgid "Pin 2" 68 | msgstr "Pin 2" 69 | 70 | #: inc/simcard.class.php:285 inc/simcard.class.php:461 71 | msgid "Puk 1" 72 | msgstr "Puk 1" 73 | 74 | #: inc/simcard.class.php:291 inc/simcard.class.php:477 75 | msgid "Puk 2" 76 | msgstr "Puk 2" 77 | 78 | #: inc/simcard_item.class.php:217 79 | msgid "New SIM card" 80 | msgstr "Новая SIM-карта" 81 | -------------------------------------------------------------------------------- /locales/simcard.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2014-04-23 21:04+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" 20 | 21 | #: hook.php:163 inc/simcard.class.php:181 inc/simcard.class.php:427 22 | #: inc/simcardsize.class.php:41 23 | msgid "Size" 24 | msgstr "" 25 | 26 | #: hook.php:164 inc/phoneoperator.class.php:40 inc/simcard.class.php:204 27 | #: inc/simcard.class.php:435 28 | msgid "Provider" 29 | msgstr "" 30 | 31 | #: hook.php:165 hook.php:231 inc/simcard.class.php:197 32 | #: inc/simcard.class.php:409 inc/simcardvoltage.class.php:41 33 | msgid "Voltage" 34 | msgstr "" 35 | 36 | #: hook.php:166 inc/simcard.class.php:167 inc/simcardtype.class.php:41 37 | msgid "Type of SIM card" 38 | msgstr "" 39 | 40 | #: hook.php:222 inc/simcard.class.php:243 inc/simcard.class.php:443 41 | msgid "Phone number" 42 | msgstr "" 43 | 44 | #: setup.php:130 45 | msgid "Sim cards management" 46 | msgstr "" 47 | 48 | #: inc/profile.class.php:127 49 | msgid "Right manager" 50 | msgstr "" 51 | 52 | #: inc/profile.class.php:263 inc/simcard.class.php:54 53 | msgid "SIM card" 54 | msgid_plural "SIM cards" 55 | msgstr[0] "" 56 | msgstr[1] "" 57 | 58 | #: inc/simcard.class.php:253 inc/simcard.class.php:367 59 | msgid "IMSI" 60 | msgstr "" 61 | 62 | #: inc/simcard.class.php:273 inc/simcard.class.php:453 63 | msgid "Pin 1" 64 | msgstr "" 65 | 66 | #: inc/simcard.class.php:279 inc/simcard.class.php:469 67 | msgid "Pin 2" 68 | msgstr "" 69 | 70 | #: inc/simcard.class.php:285 inc/simcard.class.php:461 71 | msgid "Puk 1" 72 | msgstr "" 73 | 74 | #: inc/simcard.class.php:291 inc/simcard.class.php:477 75 | msgid "Puk 2" 76 | msgstr "" 77 | 78 | #: inc/simcard_item.class.php:217 79 | msgid "New SIM card" 80 | msgstr "" 81 | -------------------------------------------------------------------------------- /locales/sv_SE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluginsGLPI/simcard/a7ff91e83c26630c50b73dcd961d7b32c23d00b4/locales/sv_SE.mo -------------------------------------------------------------------------------- /locales/sv_SE.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: \n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2014-04-23 21:04+0200\n" 11 | "PO-Revision-Date: 2014-11-18 21:20+0100\n" 12 | "Last-Translator: FULL NAME \n" 13 | "Language-Team: LANGUAGE \n" 14 | "Language: sv_SE\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 19 | "X-Generator: Poedit 1.6.10\n" 20 | 21 | #: hook.php:163 inc/simcard.class.php:181 inc/simcard.class.php:427 22 | #: inc/simcardsize.class.php:41 23 | msgid "Size" 24 | msgstr "Storlek" 25 | 26 | #: hook.php:164 inc/phoneoperator.class.php:40 inc/simcard.class.php:204 27 | #: inc/simcard.class.php:435 28 | msgid "Provider" 29 | msgstr "Utgivare" 30 | 31 | #: hook.php:165 hook.php:231 inc/simcard.class.php:197 32 | #: inc/simcard.class.php:409 inc/simcardvoltage.class.php:41 33 | msgid "Voltage" 34 | msgstr "Volt" 35 | 36 | #: hook.php:166 inc/simcard.class.php:167 inc/simcardtype.class.php:41 37 | msgid "Type of SIM card" 38 | msgstr "SIM-kortstyp" 39 | 40 | #: hook.php:222 inc/simcard.class.php:243 inc/simcard.class.php:443 41 | msgid "Phone number" 42 | msgstr "Telefonnummer" 43 | 44 | #: setup.php:130 45 | msgid "Sim cards management" 46 | msgstr "Hantera SIM-kort" 47 | 48 | #: inc/profile.class.php:127 49 | msgid "Right manager" 50 | msgstr "Rättighetshantering" 51 | 52 | #: inc/profile.class.php:263 inc/simcard.class.php:54 53 | msgid "SIM card" 54 | msgid_plural "SIM cards" 55 | msgstr[0] "SIM-kort" 56 | msgstr[1] "SIM-kort" 57 | 58 | #: inc/simcard.class.php:253 inc/simcard.class.php:367 59 | msgid "IMSI" 60 | msgstr "IMSI" 61 | 62 | #: inc/simcard.class.php:273 inc/simcard.class.php:453 63 | msgid "Pin 1" 64 | msgstr "Pin 1" 65 | 66 | #: inc/simcard.class.php:279 inc/simcard.class.php:469 67 | msgid "Pin 2" 68 | msgstr "Pin 2" 69 | 70 | #: inc/simcard.class.php:285 inc/simcard.class.php:461 71 | msgid "Puk 1" 72 | msgstr "Puk 1" 73 | 74 | #: inc/simcard.class.php:291 inc/simcard.class.php:477 75 | msgid "Puk 2" 76 | msgstr "Puk 2" 77 | 78 | #: inc/simcard_item.class.php:217 79 | msgid "New SIM card" 80 | msgstr "Nytt SIM-kort" 81 | -------------------------------------------------------------------------------- /setup.php: -------------------------------------------------------------------------------- 1 | . 20 | -------------------------------------------------------------------------- 21 | @package simcard 22 | @author the simcard plugin team 23 | @copyright Copyright (c) 2010-2011 Simcard plugin team 24 | @license GPLv2+ 25 | http://www.gnu.org/licenses/gpl.txt 26 | @link https://github.com/pluginsglpi/simcard 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ---------------------------------------------------------------------- */ 30 | 31 | define ("PLUGIN_SIMCARD_VERSION", "1.4.2"); 32 | 33 | // Minimal GLPI version, inclusive 34 | define ("PLUGIN_SIMCARD_GLPI_MIN_VERSION", "0.85"); 35 | 36 | // Init the hooks of the plugins -Needed 37 | function plugin_init_simcard() { 38 | global $PLUGIN_HOOKS,$CFG_GLPI,$LANG; 39 | 40 | $PLUGIN_HOOKS['csrf_compliant']['simcard'] = true; 41 | 42 | $plugin = new Plugin(); 43 | if ($plugin->isInstalled('simcard') && $plugin->isActivated('simcard')) { 44 | 45 | //load changeprofile function (does not exist anymore in this version) 46 | //$PLUGIN_HOOKS['change_profile']['simcard'] = array('PluginSimcardProfile','changeProfile'); 47 | 48 | $PLUGIN_HOOKS['assign_to_ticket']['simcard'] = true; 49 | 50 | $PLUGIN_HOOKS['plugin_datainjection_populate']['simcard'] 51 | = 'plugin_datainjection_populate_simcard'; 52 | $PLUGIN_HOOKS['item_purge']['simcard'] = array(); 53 | 54 | foreach (PluginSimcardSimcard_Item::getClasses() as $type) { 55 | $PLUGIN_HOOKS['item_purge']['simcard'][$type] = 'plugin_item_purge_simcard'; 56 | } 57 | 58 | $PLUGIN_HOOKS['item_update']['simcard']['ProfileRight'] = 'plugin_simcard_profileRightUpdate'; 59 | $PLUGIN_HOOKS['item_add']['simcard']['ProfileRight'] = 'plugin_simcard_profileRightUpdate'; 60 | 61 | Plugin::registerClass('PluginSimcardSimcard_Item', 62 | array('addtabon' => PluginSimcardSimcard_Item::getClasses())); 63 | Plugin::registerClass('PluginSimcardProfile', 64 | array('addtabon' => 'Profile')); 65 | 66 | // Params : plugin name - string type - number - class - table - form page 67 | Plugin::registerClass('PluginSimcardSimcard', 68 | array('linkgroup_types' => true, 69 | 'linkuser_types' => true, 70 | 'document_types' => true, 71 | 'contract_types' => true, 72 | 'ticket_types' => true, 73 | 'helpdesk_visible_types' => true, 74 | 'infocom_types' => true, 75 | 'unicity_types' => true, 76 | 'reservation_types' => true, 77 | 'location_types' => true 78 | )); 79 | array_push($CFG_GLPI['state_types'], 'PluginSimcardSimcard'); 80 | array_push($CFG_GLPI['globalsearch_types'], 'PluginSimcardSimcard'); 81 | 82 | //if glpi is loaded 83 | if (Session::getLoginUserID()) { 84 | 85 | // Display a menu entry ? 86 | if (PluginSimcardSimcard::canCreate() 87 | || PluginSimcardSimcard::canUpdate () 88 | || PluginSimcardSimcard::canDelete() 89 | || PluginSimcardSimcard::canView()) 90 | { 91 | //menu entry 92 | $PLUGIN_HOOKS['menu_toadd']['simcard'] = array('assets' => 'PluginSimcardSimcard'); 93 | //search link 94 | //add simcard to items details 95 | $PLUGIN_HOOKS['headings']['simcard'] = 'plugin_get_headings_simcard'; 96 | $PLUGIN_HOOKS['headings_action']['simcard'] = 'plugin_headings_actions_simcard'; 97 | $PLUGIN_HOOKS['headings_actionpdf']['simcard'] = 'plugin_headings_actionpdf_simcard'; 98 | } 99 | 100 | if (PluginSimcardSimcard::canCreate()) { 101 | //add link 102 | 103 | //use massiveaction in the plugin 104 | $PLUGIN_HOOKS['use_massive_action']['simcard'] = 1; 105 | } 106 | 107 | // Import from Data_Injection plugin 108 | $PLUGIN_HOOKS['migratetypes']['simcard'] = 'plugin_datainjection_migratetypes_simcard'; 109 | $PLUGIN_HOOKS['menu']['simcard'] = true; 110 | $PLUGIN_HOOKS['post_init']['simcard'] = 'plugin_simcard_postinit'; 111 | } 112 | } 113 | } 114 | 115 | // Get the name and the version of the plugin - Needed 116 | function plugin_version_simcard() { 117 | global $LANG; 118 | 119 | $author = "El Sendero"; 120 | $author.= ", Walid Nouh"; 121 | $author.= ", Thierry Bugier Pineau"; 122 | $author.= ", Anthony Piesset"; 123 | $author.= ", Dethegeek"; 124 | return array ('name' => __s('Sim cards management', 'simcard'), 125 | 'version' => PLUGIN_SIMCARD_VERSION, 126 | 'author' => $author, 127 | 'license' => 'GPLv2+', 128 | 'homepage' => 'https://github.com/pluginsglpi/simcard', 129 | 'minGlpiVersion' => PLUGIN_SIMCARD_GLPI_MIN_VERSION); 130 | } 131 | 132 | // Optional : check prerequisites before install : may print errors or add to message after redirect 133 | function plugin_simcard_check_prerequisites() { 134 | if (version_compare(GLPI_VERSION, PLUGIN_SIMCARD_GLPI_MIN_VERSION, 'lt')) { 135 | echo "This plugin requires GLPI >= " . PLUGIN_SIMCARD_GLPI_MIN_VERSION; 136 | return false; 137 | } 138 | return true; 139 | } 140 | 141 | // Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect 142 | function plugin_simcard_check_config() { 143 | return true; 144 | } 145 | 146 | /** 147 | * 148 | * Migrate itemtype integer (0.72) to string (0.80) 149 | * 150 | * @param array $types 151 | * @return string 152 | */ 153 | function plugin_datainjection_migratetypes_simcard($types) { 154 | $types[1300] = 'PluginSimcardsSimcard'; 155 | return $types; 156 | } 157 | 158 | ?> 159 | -------------------------------------------------------------------------------- /simcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluginsGLPI/simcard/a7ff91e83c26630c50b73dcd961d7b32c23d00b4/simcard.png -------------------------------------------------------------------------------- /simcard.xml: -------------------------------------------------------------------------------- 1 | 2 | Simcard 3 | simcard 4 | stable 5 | https://raw.githubusercontent.com/pluginsGLPI/simcard/master/simcard.png 6 | 7 | 8 | Simcard assets 9 | Objets carte SIM 10 | 11 | 12 | Add simcards management, link them to computers and phones 13 | Ajoute la gestion des cartes SIM, les associe aux ordinateurs et téléphones 14 | 15 | 16 | https://github.com/pluginsGLPI/simcard/wiki 17 | https://github.com/pluginsGLPI/simcard/releases 18 | https://github.com/pluginsGLPI/simcard/issues 19 | https://raw.githubusercontent.com/pluginsGLPI/simcard/master/README.md 20 | 21 | Dethegeek 22 | El Sendero 23 | Walid Nouh 24 | Anthony Piesset 25 | 26 | 27 | 28 | 1.4.2 29 | 0.85 30 | 0.90 31 | 9.1 32 | 33 | 34 | 1.4.1 35 | 0.85 36 | 0.90 37 | 38 | 39 | 1.3.1 40 | 0.84 41 | 42 | 43 | 1.3 44 | 0.84 45 | 46 | 47 | 0.83 48 | 0.83 49 | 50 | 51 | 0.80.3 52 | 0.80 53 | 54 | 55 | 080.2 56 | 0.80 57 | 58 | 59 | 0.80.1 60 | 0.80 61 | 62 | 63 | 0.80 64 | 0.80 65 | 66 | 67 | 68 | en_GB 69 | fr_FR 70 | es_ES 71 | sv_SE 72 | ru_RU 73 | 74 | GPL v2+ 75 | 76 | 77 | carte SIM 78 | 79 | 80 | simcard 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /tools/HEADER: -------------------------------------------------------------------------------- 1 | * @version $Id: HEADER 15930 2011-10-25 10:47:55Z jmd $ 2 | ------------------------------------------------------------------------- 3 | GLPI - Gestionnaire Libre de Parc Informatique 4 | Copyright (C) 2003-2011 by the INDEPNET Development Team. 5 | 6 | http://indepnet.net/ http://glpi-project.org 7 | ------------------------------------------------------------------------- 8 | 9 | LICENSE 10 | 11 | This file is part of GLPI. 12 | 13 | GLPI is free software; you can redistribute it and/or modify 14 | it under the terms of the GNU General Public License as published by 15 | the Free Software Foundation; either version 2 of the License, or 16 | (at your option) any later version. 17 | 18 | GLPI is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU General Public License for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with GLPI. If not, see . 25 | -------------------------------------------------------------------------- 26 | -------------------------------------------------------------------------------- /tools/extract_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | soft='GLPI - Simcard plugin' 4 | version='0.85' 5 | email=adelaunay@teclib.com 6 | copyright='INDEPNET Development Team' 7 | 8 | #xgettext *.php */*.php -copyright-holder='$copyright' --package-name=$soft --package-version=$version --msgid-bugs-address=$email -o locales/en_GB.po -L PHP --from-code=UTF-8 --force-po -i --keyword=_n:1,2 --keyword=__ --keyword=_e 9 | 10 | # Only strings with domain specified are extracted (use Xt args of keyword param to set number of args needed) 11 | 12 | xgettext *.php */*.php -o locales/glpi.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po \ 13 | --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t --keyword=_ex:1c,2,3t \ 14 | --keyword=_sx:1c,2,3t --keyword=_nx:1c,2,3,5t 15 | 16 | 17 | ### for using tx : 18 | ##tx set --execute --auto-local -r GLPI_example.glpi-084-current 'locales/.po' --source-lang en --source-file locales/glpi.pot 19 | ## tx push -s 20 | ## tx pull -a 21 | 22 | 23 | -------------------------------------------------------------------------------- /tools/modify_headers.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #!/usr/bin/perl -w 3 | 4 | # ---------------------------------------------------------------------- 5 | # GLPI - Gestionnaire Libre de Parc Informatique 6 | # Copyright (C) 2003-2006 by the INDEPNET Development Team. 7 | # 8 | # http://indepnet.net/ http://glpi-project.org 9 | # ---------------------------------------------------------------------- 10 | # 11 | # LICENSE 12 | # 13 | # This file is part of GLPI. 14 | # 15 | # GLPI is free software; you can redistribute it and/or modify 16 | # it under the terms of the GNU General Public License as published by 17 | # the Free Software Foundation; either version 2 of the License, or 18 | # (at your option) any later version. 19 | # 20 | # GLPI is distributed in the hope that it will be useful, 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | # GNU General Public License for more details. 24 | # 25 | # You should have received a copy of the GNU General Public License 26 | # along with GLPI; if not, write to the Free Software 27 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 | # ------------------------------------------------------------------------ 29 | 30 | 31 | do_dir(".."); 32 | 33 | 34 | sub do_dir{ 35 | local ($dir)=@_; 36 | print "Entering $dir\n"; 37 | 38 | opendir(DIRHANDLE,$dir)||die "ERROR: can not read current directory\n"; 39 | foreach (readdir(DIRHANDLE)){ 40 | if ($_ ne '..' && $_ ne '.'){ 41 | if (-d "$dir/$_"){ 42 | if ($_ !~ m/.svn/i && $_ !~ m/CVS/i && $_ !~ m/lib/i){ 43 | 44 | do_dir("$dir/$_"); 45 | } 46 | } else { 47 | if(!(-l "$dir/$_")){ 48 | if ((index($_,".php",0)!=-1)||(index($_,".txt",0)!=-1)||(index($_,".css",0)!=-1)){ 49 | do_file("$dir/$_"); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | closedir DIRHANDLE; 56 | 57 | } 58 | 59 | sub do_file{ 60 | local ($file)=@_; 61 | print $file."\n"; 62 | ### DELETE HEADERS 63 | open(INIT_FILE,$file); 64 | @lines=; 65 | close(INIT_FILE); 66 | 67 | open(TMP_FILE,">/tmp/tmp_glpi.txt"); 68 | 69 | $status=''; 70 | foreach (@lines){ 71 | if ($_ =~ m/\*\//){ 72 | $status="END"; 73 | } 74 | 75 | if ($status =~ m/END/||$status !~ m/BEGIN/){ 76 | print TMP_FILE $_; 77 | } 78 | 79 | if ($status !~ m/END/){ 80 | if ($_ =~ m/\/\*/){ 81 | $status="BEGIN"; 82 | ##### ADD NEW HEADERS 83 | open(HEADER_FILE,"HEADER"); 84 | @headers=; 85 | foreach (@headers){ 86 | print TMP_FILE $_; 87 | } 88 | close(HEADER_FILE) ; 89 | 90 | } 91 | } 92 | } 93 | close(TMP_FILE); 94 | 95 | system("cp -f /tmp/tmp_glpi.txt $file"); 96 | 97 | 98 | 99 | } 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /tools/move_to_po.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | // ---------------------------------------------------------------------- 31 | // Original Author of file: Julien Dombre 32 | // Purpose of file: 33 | // ---------------------------------------------------------------------- 34 | 35 | chdir(dirname($_SERVER["SCRIPT_FILENAME"])); 36 | 37 | if ($argv) { 38 | for ($i=1 ; $i'.$sing_trans.' '.$current_string_plural.'->'.$plural_trans."\n"; 158 | if (!strlen($sing_trans) || !strlen($plural_trans)) { 159 | // echo "clean\n"; 160 | $sing_trans = ''; 161 | $plural_trans = ''; 162 | } 163 | $content = "msgstr[0] \"$sing_trans\"\n"; 164 | $content .= "msgstr[1] \"$plural_trans\"\n"; 165 | } 166 | } else { 167 | $content=''; 168 | } 169 | } 170 | $context = ''; 171 | } 172 | // Standard replacement 173 | $content = preg_replace('/charset=CHARSET/','charset=UTF-8',$content); 174 | 175 | if (preg_match('/Plural-Forms/',$content)) { 176 | $content = "\"Plural-Forms: nplurals=2; plural=(n != 1)\\n\"\n"; 177 | } 178 | 179 | if (fwrite($po, $content) === FALSE) { 180 | echo "unable to write in po file"; 181 | exit; 182 | } 183 | 184 | } 185 | } 186 | fclose($pot); 187 | fclose($po); 188 | 189 | 190 | function search_in_dict($string, $context) { 191 | global $REFLANG, $LANG; 192 | 193 | if ($context) { 194 | $string = "$context/$string"; 195 | } 196 | 197 | $ponctmatch = "([\.: \(\)]*)"; 198 | $varmatch = "(%s)*"; 199 | 200 | if (preg_match("/$varmatch$ponctmatch(.*)$ponctmatch$varmatch$/U",$string,$reg)) { 201 | // print_r($reg); 202 | $left = $reg[1]; 203 | $left .= $reg[2]; 204 | $string = $reg[3]; 205 | $right = $reg[4]; 206 | if (isset($reg[5])) { 207 | $right .= $reg[5]; 208 | } 209 | } 210 | 211 | // echo $left.' <- '.$string.' -> '.$right."\n"; 212 | foreach ($REFLANG as $mod => $data) { 213 | 214 | foreach ($data as $key => $val) { 215 | 216 | if (!is_array($val)){ 217 | if (!isset($LANG[$mod][$key])) { 218 | continue; 219 | } 220 | 221 | // Search same case with punc 222 | if (strcmp($val,$left.$string.$right) === 0) { 223 | return $LANG[$mod][$key]; 224 | } 225 | // Search same case with punc 226 | if (strcasecmp($val,$left.$string.$right) === 0) { 227 | return $LANG[$mod][$key]; 228 | } 229 | 230 | // Search same case with left punc 231 | if (strcmp($val,$left.$string) === 0) { 232 | return $LANG[$mod][$key].$right; 233 | } 234 | // Search same case with left punc 235 | if (strcasecmp($val,$left.$string) === 0) { 236 | return $LANG[$mod][$key].$right; 237 | } 238 | 239 | // Search same case with right punc 240 | if (strcmp($val,$string.$right) === 0) { 241 | return $left.$LANG[$mod][$key]; 242 | } 243 | // Search same case with right punc 244 | if (strcasecmp($val,$string.$right) === 0) { 245 | return $left.$LANG[$mod][$key]; 246 | } 247 | 248 | // Search same case without punc 249 | if (strcmp($val,$string) === 0) { 250 | return $left.$LANG[$mod][$key].$right; 251 | } 252 | // Search non case sensitive 253 | if (strcasecmp($val,$string) === 0) { 254 | return $left.$LANG[$mod][$key].$right; 255 | } 256 | } else { 257 | //toolbox::logdebug($val); 258 | //toolbox::logdebug($key); 259 | //toolbox::logdebug($mod); 260 | foreach ($val as $k => $v) { 261 | if (!isset($LANG[$mod][$key][$k])) { 262 | continue; 263 | } 264 | 265 | // Search same case with punc 266 | if (strcmp($v,$left.$string.$right) === 0) { 267 | return $LANG[$mod][$key][$k]; 268 | } 269 | // Search same case with punc 270 | if (strcasecmp($v,$left.$string.$right) === 0) { 271 | return $LANG[$mod][$key][$k]; 272 | } 273 | 274 | // Search same case with left punc 275 | if (strcmp($v,$left.$string) === 0) { 276 | return $LANG[$mod][$key][$k].$right; 277 | } 278 | // Search same case with left punc 279 | if (strcasecmp($v,$left.$string) === 0) { 280 | return $LANG[$mod][$key][$k].$right; 281 | } 282 | 283 | // Search same case with right punc 284 | if (strcmp($v,$string.$right) === 0) { 285 | return $left.$LANG[$mod][$key][$k]; 286 | } 287 | // Search same case with right punc 288 | if (strcasecmp($v,$string.$right) === 0) { 289 | return $left.$LANG[$mod][$key][$k]; 290 | } 291 | 292 | // Search same case without punc 293 | if (strcmp($v,$string) === 0) { 294 | return $left.$LANG[$mod][$key][$k].$right; 295 | } 296 | // Search non case sensitive 297 | if (strcasecmp($v,$string) === 0) { 298 | return $left.$LANG[$mod][$key][$k].$right; 299 | } 300 | } 301 | } 302 | } 303 | } 304 | 305 | return ""; 306 | } 307 | ?> 308 | -------------------------------------------------------------------------------- /tools/update_mo.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #!/usr/bin/perl -w 3 | 4 | if (@ARGV!=0){ 5 | print "USAGE update_mo.pl\n\n"; 6 | 7 | exit(); 8 | } 9 | 10 | 11 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; 12 | foreach (readdir(DIRHANDLE)){ 13 | if ($_ ne '..' && $_ ne '.'){ 14 | 15 | if(!(-l "$dir/$_")){ 16 | if (index($_,".po",0)==length($_)-3) { 17 | $lang=$_; 18 | $lang=~s/\.po//; 19 | 20 | `msgfmt locales/$_ -o locales/$lang.mo`; 21 | } 22 | } 23 | 24 | } 25 | } 26 | closedir DIRHANDLE; 27 | 28 | # 29 | # 30 | -------------------------------------------------------------------------------- /tools/update_po.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #!/usr/bin/perl -w 3 | 4 | if (@ARGV!=2){ 5 | print "USAGE update_po.pl transifex_login transifex_password\n\n"; 6 | 7 | exit(); 8 | } 9 | $user = $ARGV[0]; 10 | $password = $ARGV[1]; 11 | 12 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; 13 | foreach (readdir(DIRHANDLE)){ 14 | if ($_ ne '..' && $_ ne '.'){ 15 | 16 | if(!(-l "$dir/$_")){ 17 | if (index($_,".po",0)==length($_)-3) { 18 | $lang=$_; 19 | $lang=~s/\.po//; 20 | 21 | `wget --user=$user --password=$password --output-document=locales/$_ http://www.transifex.net/api/2/project/GLPI_example/resource/glpipot/translation/$lang/?file=$_`; 22 | } 23 | } 24 | 25 | } 26 | } 27 | closedir DIRHANDLE; 28 | 29 | # 30 | # 31 | --------------------------------------------------------------------------------