Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positions plugin support #81

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function plugin_genericobject_install() {
return true;
}


function plugin_genericobject_uninstall() {
global $DB;

Expand Down Expand Up @@ -192,4 +193,4 @@ function plugin_genericobject_MassiveActions($type) {
} else {
return array();
}
}
}
4 changes: 4 additions & 0 deletions inc/object.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ function getLinkedItemTypesAsArray() {
return $this->objecttype->getLinkedItemTypesAsArray();
}

function canUsePluginPositions() {
return ($this->objecttype->canUsePluginPositions());
}

function title() {
}

Expand Down
22 changes: 21 additions & 1 deletion inc/type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ function showBehaviorForm($ID, $options=array()) {
"use_plugin_order" => __("order plugin", "genericobject"),
"use_plugin_uninstall" => __("item's uninstallation plugin", "genericobject"),
"use_plugin_simcard" => __("simcard plugin", "genericobject"),
"use_plugin_positions" => __("cartography plugin", "genericobject"),
);
$plugin = new Plugin();
$odd=0;
Expand Down Expand Up @@ -612,7 +613,7 @@ function showBehaviorForm($ID, $options=array()) {
echo "<input type='hidden' name='use_plugin_simcard' value='0'>\n";
}
break;
case 'use_plugin_geninventorynumber' :
case 'use_plugin_geninventorynumber' :
if ($plugin->isActivated('geninventorynumber')) {
Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
Expand All @@ -621,6 +622,16 @@ function showBehaviorForm($ID, $options=array()) {
echo "<input type='hidden' name='use_plugin_geninventorynumber' value='0'>\n";
}
break;
case 'use_plugin_positions' :
if ($plugin->isActivated('positions')) {
Html::showCheckbox(array('name' => $right,.
'checked' => $this->fields[$right]));
} else {
echo Dropdown::EMPTY_VALUE;
echo "<input type='hidden' name='use_plugin_positions' value='0'>\n";
}
break;

}
echo "</td>";
if ($odd == 1) {
Expand Down Expand Up @@ -1799,6 +1810,13 @@ function canUsePluginGeninventoryNumber() {
return $this->fields['use_plugin_geninventorynumber'];
}

function canUsePluginPositions() {
$plugin = new Plugin();
if (!$plugin->isInstalled("positions") || !$plugin->isActivated("positions")) {
return false;
}
return $this->fields['use_plugin_positions'];
}

function isTransferable() {
return Session::isMultiEntitiesMode();
Expand Down Expand Up @@ -1864,6 +1882,7 @@ static function install(Migration $migration) {
`use_plugin_order` tinyint(1) NOT NULL default '0',
`use_plugin_uninstall` tinyint(1) NOT NULL default '0',
`use_plugin_geninventorynumber` tinyint(1) NOT NULL default '0',
`use_plugin_positions` tinyint(1) NOT NULL default '0',
`use_menu_entry` tinyint(1) NOT NULL default '0',
`use_projects` tinyint(1) NOT NULL default '0',
`linked_itemtypes` text NULL,
Expand All @@ -1886,6 +1905,7 @@ static function install(Migration $migration) {
$migration->addField($table, "linked_itemtypes", "text");
$migration->addField($table, "plugin_genericobject_typefamilies_id", "integer");
$migration->addField($table, "use_plugin_simcard", "bool");
$migration->addField($table, "use_plugin_positions", "bool");
$migration->migrationOneTable($table);

// Migrate notepad data
Expand Down
2 changes: 2 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ function plugin_post_init_genericobject() {
$itemtype = $objecttype['itemtype'];
if (class_exists($itemtype)) {
$itemtype::registerType();
if (class_exists('PluginPositionsPosition') && !empty($objecttype['use_plugin_positions']))
PluginPositionsPosition::registerType($itemtype);
}

}
Expand Down