Plugin migration from GLPI 0.80 to 0.83

GLPI core functions & methods changes

Group_Ticket::getTicketGroups($tickets_id)   =>   Group_Ticket::getGroups($tickets_id)
Ticket_User::getTicketUsers($tickets_id)     =>   Ticket_User::getUsers($tickets_id)
openArrowMassive()                           =>   openArrowMassives() 
closeArrowMassive($name='', $label='')       =>   closeArrowMassives($options) 

*Functions & methods call changes :*

 location.class - $this->showNetpoints()    => Netpoint::showForLocation($item)

 addConfirmationOnAction()           =>  Html::addConfirmationOnAction()
 addMessageAfterRedirect()           =>  Session::addMessageAfterRedirect()
 addslashes_deep()                   =>  Toolbox::addslashes_deep()
 addToNavigateListItems()            =>  Session::addToNavigateListItems()
 ajaxDisplaySearchTextForDropdown()  =>  Ajax::displaySearchTextForDropdown()
 ajaxDropdown()                      =>  Ajax::dropdown()
 ajaxFooter()                        =>  Html::ajaxFooter()
 ajaxUpdateItem()                    =>  Ajax::updateItem() 
 ajaxUpdateItemJsCode()              =>  Ajax::updateItemJsCode() 
 ajaxUpdateItemOnEvent()             =>  Ajax::updateItemOnEvent()  
 ajaxUpdateItemOnEventJsCode()       =>  Ajax::updateItemOnEventJsCode()
 ajaxUpdateItemOnInputTextEvent()    =>  Ajax::updateItemOnInputTextEvent()
 ajaxUpdateItemOnSelectEvent()       =>  Ajax::updateItemOnSelectEvent() 
 append_params()                     =>  Toolbox::append_params()
 autocompletionTextField()           =>  Html::autocompletionTextField()

 callCron()                          =>  CronTask::callCron()
 callCronForce()                     =>  CronTask::callCronForce() 
 canUseImapPop()                     =>  Toolbox::canUseImapPop()
 canUseLdap()                        =>  Toolbox::canUseLdap()
 changeActiveEntities()              =>  Session::changeActiveEntities()
 changeProgressBarMessage()          =>  Html::changeProgressBarMessage()
 changeProgressBarPosition()         =>  Html::changeProgressBarPosition()
 changeProfile()                     =>  Session::changeProfile()
 checkCentralAccess()                =>  Session::checkCentralAccess()
 checkFaqAccess()                    =>  Session::checkFaqAccess()
 checkHelpdeskAccess()               =>  Session::checkHelpdeskAccess()
 checkLoginUser()                    =>  Session::checkLoginUser()
 checkNewVersionAvailable()          =>  Toolbox::checkNewVersionAvailable()
 checkSeveralRightsOr()              =>  Session::checkSeveralRightsOr()
 checkRight()                        =>  Session::checkRight()
 checkWriteAccessToDirs()            =>  Config::checkWriteAccessToDirs()
 clean_cross_side_scripting_deep()   =>  Toolbox::clean_cross_side_scripting_deep()
 cleanInputText()                    =>  Html::cleanInputText()
 cleanParametersURL()                =>  Html::cleanParametersURL()
 cleanPostForTextArea()              =>  Html::cleanPostForTextArea()
 closeArrowMassive($name,$label)     =>  Html::closeArrowMassives(array($name => $label))
 commonCheckForUseGLPI()             =>  Toolbox::commonCheckForUseGLPI()
 commonDropdownUpdateItem()          =>  Ajax::commonDropdownUpdateItem()
 commonFooter()                      =>  Html::footer()
 commonHeader()                      =>  Html::header()
 constructMailServerConfig()         =>  Toolbox::constructMailServerConfig()
 convDate()                          =>  Html::convDate()
 convDateTime()                      =>  Html::convDateTime()
 createAjaxTabs()                    =>  Ajax::createTabs()
 createProgressBar()                 =>  Html::createProgressBar()

 decodeFromUtf8()                    =>  Toolbox::decodeFromUtf8()
 decrypt()                           =>  Toolbox::decrypt()
 deleteDir()                         =>  Toolbox::deleteDir()
 destroySession (Auth.class)         =>  Session::destroy()
 displayBackLink()                   =>  Html::displayBackLink()
 displayDebugInfos()                 =>  Html::displayDebugInfos()
 displayErrorAndDie()                =>  Html::displayErrorAndDie()
 displayMessageAfterRedirect()       =>  Html::displayMessageAfterRedirect()
 displayNotFoundError()              =>  Html::displayNotFoundError()
 displayProgressBar()                =>  Html::displayProgressBar()
 displayRightError()                 =>  Html::displayRightError()
 displayTitle()                      =>  Html::displayTitle()
 doHook()                            =>  Plugin::doHook()
 doHookFunction()                    =>  Plugin::doHookFunction()
 doOneHook()                         =>  Plugin::doOneHook()

 encodeInUtf8()                      =>  Toolbox::encodeInUtf8()
 encrypt()                           =>  Toolbox::encrypt()

 filesizeDirectory ()                =>  Toolbox::filesizeDirectory()
 formatNumber()                      =>  Html::formatNumber()

 getActiveTab()                      =>  Session::getActiveTab()
 getAllReplicateForAMaster()         =>  AuthLDAP::getAllReplicateForAMaster()
 getCountLogin()                     =>  Event::getCountLogin()
 getItemTypeFormURL()                =>  Toolbox::getItemTypeFormURL()
 getItemTypeSearchURL()              =>  Toolbox::getItemTypeSearchURL()
 getItemTypeTabsURL()                =>  Toolbox::getItemTypeTabsURL()
 getLoginUserID()                    =>  Session::getLoginUserID()
 get_magic_quotes_gpc()              =>  Toolbox::get_magic_quotes_gpc()
 get_magic_quotes_runtime()          =>  Toolbox::get_magic_quotes_runtime()
 getMemoryLimit()                    =>  Toolbox::getMemoryLimit()
 getPluginSearchOptions()            =>  Plugin::getPluginSearchOptions()
 getPluginsDatabaseRelations()       =>  Plugin::getPluginsDatabaseRelations()
 getPluginsDropdowns()               =>  Plugin::getPluginsDropdowns()
 getRandomString()                   =>  Toolbox::getRandomString()
 getSize()                           =>  Toolbox::getSize()
 getTimestampTimeUnits()             =>  Toolbox::getTimestampTimeUnits()
 getURLContent()                     =>  Toolbox::getURLContent()
 getWarrantyExpir()                  =>  Infocom::getWarrantyExpir()
 glpi_flush()                        =>  Html::glpi_flush()
 glpi_header()                       => Html::redirect(redirect URL)
                                     => Html::back() means Html::redirect($_SERVER['HTTP_REFERER'])

 haveAccessToAllOfEntities()         =>  Session::haveAccessToAllOfEntities()
 haveAccessToEntity()                =>  Session::haveAccessToEntity()
 haveAccessToOneOfEntities()         =>  Session::haveAccessToOneOfEntities()
 haveRecursiveAccessToEntity()       =>  Session::haveRecursiveAccessToEntity()
 haveRight()                         =>  Session::haveRight()
 header_nocache()                    =>  Html::header_nocache()
 helpFooter()                        =>  Html::helpFooter()
 helpHeader()                        =>  Html::helpHeader()
 html_clean()                        =>  Html::clean()
 html_entity_decode_deep()           =>  Html::entity_decode_deep()
 htmlentities_deep()                 =>  Html::entities_deep()

 includeCommonHtmlHeader()           =>  Html::includeHeader()
 initEditorSystem()                  =>  Html::initEditorSystem()
 initEntityProfiles()                =>  Session::initEntityProfiles()
 initNavigateListItems()             =>  Session::initNavigateListItems()
 initSession (Auth.class)            =>  Session::init()
 isMultiEntitiesMode()               =>  Session::isMultiEntitiesMode()

 key_exists_deep()                   =>  Toolbox::key_exists_deep()

 ldap_get_entries_clean()            =>  AuthLDAP::get_entries_clean() 
 listTemplates()                     =>  CommonDBTM::listTemplates()
 loadGroups()                        =>  Session::loadGroups()
 loadLanguage()                      =>  Session::loadLanguage()
 logDebug()                          =>  Toolbox::logDebug()
 logInFile()                         =>  Toolbox::logInFile()

 makeTextCriteria()                  =>  Search::makeTextCriteria()
 makeTextSearch()                    =>  Search::makeTextSearch()
 manageBeginAndEndPlanDates()        =>  Toolbox::manageBeginAndEndPlanDates()
 manageRedirect()                    =>  Toolbox::manageRedirect()

 nl2br_deep()                        =>  Html::nl2br_deep()
 nullFooter()                        =>  Html::nullFooter()
 nullHeader()                        =>  Html::nullHeader()

 openArrowMassive()                  =>  Html::openArrowMassives()
 optimize_tables()                   =>  DBmysql::optimize_tables()

 popFooter()                         =>  Html::popFooter()
 popHeader()                         =>  Html::popHeader()
 printAjaxPager()                    =>  Html::printAjaxPager()
 printCleanArray()                   =>  Html::printCleanArray()
 printHelpDesk()                     =>  Ticket::showFormHelpdesk()
 printPager()                        =>  Html::printPager()
 printPagerForm()                    =>  Html::printPagerForm()

 refreshDropdownPopupInMainWindow()  =>  Ajax::refreshDropdownPopupInMainWindow()
 refreshPopupMainWindow()            =>  Ajax::refreshPopupMainWindow()
 resume_text()                       =>  Html::resume_text()
 resume_name()                       =>  Html::resume_name()
 return_bytes_from_ini_vars()        =>  Toolbox::return_bytes_from_ini_vars()

 seems_utf8()                        =>  Toolbox::seems_utf8()
 sendFile()                          =>  Toolbox::sendFile()
 setActiveTab()                      =>  Session::setActiveTab()
 setGlpiSessionPath()                =>  Session::setPath()
 showDateFormItem()                  =>  Html::showDateFormItem()
 showDateTimeFormItem()              =>  Html::showDateTimeFormItem()
 showGenericDateTimeSearch()         =>  Html::showGenericDateTimeSearch()
 showMailServerConfig()              =>  Toolbox::showMailServerConfig()
 showOtherAuthList($target)          =>  Auth::showOtherAuthList()
 showProfileSelecter()               =>  Html::showProfileSelecter()
 showToolTip()                       =>  Html::showToolTip()
 simpleHeader()                      =>  Html::simpleHeader()
 startGlpiSession()                  =>  Session::start()
 stripslashes_deep()                 =>  Toolbox::stripslashes_deep()

 testWriteAccessToDirectory()        =>  Toolbox::testWriteAccessToDirectory()
 timestampToString()                 =>  Html::timestampToString()

 utf8_str_pad()                      =>  Toolbox::str_pad()
 utf8_strlen()                       =>  Toolbox::strlen()
 utf8_strpos()                       =>  Toolbox::strpos()
 utf8_strtolower ()                  =>  Toolbox::strtolower()
 utf8_strtoupper()                   =>  Toolbox::strtoupper()
 utf8_substr()                       =>  Toolbox::substr()
 unclean_cross_side_scripting_deep() =>  Toobox::unclean_cross_side_scripting_deep()
 userErrorHandlerDebug()             =>  Toolbox::userErrorHandlerDebug()
 userErrorHandlerNormal()            =>  Toolbox::userErrorHandlerNormal()

 weblink_extract()                   =>  Html::weblink_extract()

 *Constants changes*

 DROPDOWN_EMPTY_VALUE     =>  Dropdown::EMPTY_VALUE

 DEBUG_MODE               =>  Session::DEBUG_MODE
 NORMAL_MODE              =>  Session::NORMAL_MODE
 TRANSLATION_MODE         =>  Session::TRANSLATION_MODE

 HISTORY_....             => Log::HISTORY_....    

 BOOKMARK_SEARCH          => Bookmark::SEARCH
(For plugins, use Bookmark::URI (GLPI doesn't perform controls over plugin's itemtype)

Addition to Plugin::registerClass method

'linkuser_tech_types' => true / false
'linkgroup_tech_types' => true / false
'addtabon' => array('itemtype') : a tab will be added by the plugin for this itemype
'forwardentityfrom' => itemtype : tells GLPI to spread parent's class entities_id & is_recursive changes to the plugin's object

Example :

Plugin::registerClass('PluginTicketssuppliersConfig',
                            array('addtabon'          => array('Supplier'), 
                                  'forwardentityfrom' => 'Supplier'));

The PluginTicketssuppliersConfig (which extends CommonDBChild) is added to the list of classes receiving entities_id & is_recursive modifications spread by the Supplier class.

GLPI core methods prototype changes

Ticket::showListForItem('Computer', $_POST["id"])          => Ticket::showListForItem($Computer);
addField($table, $field, $type, $update='', $condition=''  =>  addField($table, $field, $type, $options=array()
NetworkPort::showForItem($itemtype, $items_id)             => NetworkPort::showForItem(CommonDBTM $item, $withtemplate='')

New tab management

It's still possible to use the old fashioned tab management, but it's going to be deprecated in an upcoming released.

Using standard tabs, managed by another class

To display standard tabs, you need to use addStandardTab('itemtype', $tab, $options) in the object's defineTabs() method

Examples :

Software tab  :  
   $ong[2] = $LANG['Menu'][4];   
=>   $this->addStandardTab('Software',$ong, $options);

Document tab :           
   if (haveRight("document","r")) {
      $ong[5] = $LANG['Menu'][27];
   }
 =>  $this->addStandardTab('Document',$ong, $options);

In ajax/object.tabs.php you need to :
  • delete all '_case_' refering to standard tabs
  • replace calls to Plugin::displayAction() by CommonGLPI::displayStandardTab()

Example : https://forge.indepnet.net/projects/appliances/repository/revisions/143

If all tabs for an object are standard, then you don't need the ajax/object.tabs.php anymore: it can safely be removed (common.tabs.php will be automaticall used)

Adding a standard tab mangemed by a plugin's object

For an object to create standard tabs, it's mandatory to implement the 2 following methods :

To define tabs to display:

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

This method returns a string (the tab's name) or an array of strings (if several tabs are defined).
Rights controls must be performed in this method if necessary.

Display tabs content:

static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0);

Example : https://forge.indepnet.net/projects/appliances/repository/revisions/146

Dropdown and tabs

Dropdown tables are now using standard tabs management. You can now delete ajax/<dropdowntypename>.tabs.php, not used anymore.

Rules and tabs

Rules are also using standard tabs management.
You can now delete all ajax files related to tabs (in the core it was called ajax/rule.common.tabs.php).

GLPI core table deletion

The glpi_ticketplannings table and TicketPlanning class have been deleted.

Function moving

isPluginItemType and isCommandLine are now implemented in autoload.function.php (instead of common.function.php

Classname changes

TicketCategory has been rename to ITILCategory (table is glpi_itilcategories / foreign key is : itilcategories_id)

Hooks

New "post_prepareadd" hook

This hook is called after the pre_item_add hook and after prepareInputForAdd function, so just before adding data into the database.
(s)";

class_exists

There's a new way to instanciate an objet is class exists:

if (class_exists($itemtype) {
   $item = new $itemtype();
}

now becomes:
if ($item = getItemForItemtype($itemtype)) {

License

Licence information

plugin_version_foo function should now return a 'license' field' which contains the short license name (for example GPLv2+). This information will be displayed in the plugins list.

License file

If a LICENSE ou COPYING.txt file is present at the plugin's root, a link to the license file will be displayed on the plugin's list.

Header

Please check your plugins files to make sure that the license refers to your plugin and not to GLPI.