function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile') {
         return PluginDatabasesDatabase::getTypeName(2);
     }
     return '';
 }
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = "/plugins/databases/front/database.php";
     $menu['links']['search'] = PluginDatabasesDatabase::getSearchURL(false);
     if (PluginDatabasesDatabase::canCreate()) {
         $menu['links']['add'] = PluginDatabasesDatabase::getFormURL(false);
     }
     return $menu;
 }
Esempio n. 3
0
function plugin_init_databases()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['databases'] = true;
    $PLUGIN_HOOKS['change_profile']['databases'] = array('PluginDatabasesProfile', 'changeProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['databases'] = true;
    if (Session::getLoginUserID()) {
        Plugin::registerClass('PluginDatabasesDatabase', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'addtabon' => 'Supplier'));
        Plugin::registerClass('PluginDatabasesProfile', array('addtabon' => 'Profile'));
        if (class_exists('PluginAccountsAccount')) {
            PluginAccountsAccount::registerType('PluginDatabasesDatabase');
        }
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            $_SESSION["glpi_plugin_environment_databases"] = 1;
            // Display a menu entry ?
            if (plugin_databases_haveRight("databases", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['databases']['title'] = PluginDatabasesDatabase::getTypeName(2);
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['databases']['page'] = '/plugins/databases/front/database.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['databases']['links']['search'] = '/plugins/databases/front/database.php';
            }
            if (plugin_databases_haveRight("databases", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['databases']['links']['add'] = '/plugins/databases/front/database.form.php';
                $PLUGIN_HOOKS['use_massive_action']['databases'] = 1;
            }
        } else {
            // Display a menu entry ?
            if (plugin_databases_haveRight("databases", "r")) {
                $PLUGIN_HOOKS['menu_entry']['databases'] = 'front/database.php';
                $PLUGIN_HOOKS['submenu_entry']['databases']['search'] = 'front/database.php';
            }
            if (plugin_databases_haveRight("databases", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['databases']['add'] = 'front/database.form.php?new=1';
                $PLUGIN_HOOKS['use_massive_action']['databases'] = 1;
            }
        }
        if (class_exists('PluginDatabasesDatabase_Item')) {
            // only if plugin activated
            $PLUGIN_HOOKS['pre_item_purge']['databases'] = array('Profile' => array('PluginDatabasesProfile', 'purgeProfiles'));
            $PLUGIN_HOOKS['plugin_datainjection_populate']['databases'] = 'plugin_datainjection_populate_databases';
        }
        // End init, when all types are registered
        $PLUGIN_HOOKS['post_init']['databases'] = 'plugin_databases_postinit';
        // Import from Data_Injection plugin
        $PLUGIN_HOOKS['migratetypes']['databases'] = 'plugin_datainjection_migratetypes_databases';
    }
}
Esempio n. 4
0
		
This file is part of databases.

Databases is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Databases is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Databases. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$plugin = new Plugin();
if ($plugin->isActivated("environment")) {
    Html::header(PluginDatabasesDatabase::getTypeName(2), '', "plugins", "environment", "databases");
} else {
    Html::header(PluginDatabasesDatabase::getTypeName(2), '', "plugins", "databases");
}
$database = new PluginDatabasesDatabase();
if ($database->canView() || Session::haveRight("config", "w")) {
    Search::show('PluginDatabasesDatabase');
} else {
    Html::displayRightError();
}
Html::footer();
function plugin_databases_MassiveActions($type)
{
    if (in_array($type, PluginDatabasesDatabase::getTypes(true))) {
        return array('PluginDatabasesDatabase' . MassiveAction::CLASS_ACTION_SEPARATOR . 'plugin_databases__add_item' => __('Associate to the database', 'databases'));
    }
    return array();
}
Esempio n. 6
0
function plugin_init_appliances()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['appliances'] = true;
    // Params : plugin name - string type - number - attributes
    Plugin::registerClass('PluginAppliancesAppliance', array('linkuser_types' => true, 'linkuser_tech_types' => true, 'linkgroup_types' => true, 'linkgroup_tech_types' => true, 'infocom_types' => true, 'document_types' => true, 'contract_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true));
    Plugin::registerClass('PluginAppliancesProfile', array('addtabon' => 'Profile'));
    Plugin::registerClass('PluginAppliancesEnvironment');
    Plugin::registerClass('PluginAppliancesApplianceType');
    Plugin::registerClass('PluginAppliancesAppliance_Item');
    Plugin::registerClass('PluginAppliancesOptvalue');
    Plugin::registerClass('PluginAppliancesOptvalue_Item');
    Plugin::registerClass('PluginAppliancesRelation');
    if (class_exists('PluginAccountsAccount')) {
        PluginAccountsAccount::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginCertificatesCertificate')) {
        PluginCertificatesCertificate::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginDatabasesDatabase')) {
        PluginDatabasesDatabase::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginDomainsDomain')) {
        PluginDomainsDomain::registerType('PluginAppliancesAppliance');
    }
    if (class_exists('PluginWebapplicationsWebapplication')) {
        PluginWebapplicationsWebapplication::registerType('PluginAppliancesAppliance');
    }
    // Define the type for which we know how to generate PDF, need :
    $PLUGIN_HOOKS['plugin_pdf']['PluginAppliancesAppliance'] = 'PluginAppliancesAppliancePDF';
    $PLUGIN_HOOKS['migratetypes']['appliances'] = 'plugin_datainjection_migratetypes_appliances';
    $PLUGIN_HOOKS['change_profile']['appliances'] = array('PluginAppliancesProfile', 'select');
    $PLUGIN_HOOKS['assign_to_ticket']['appliances'] = true;
    if (class_exists('PluginAppliancesAppliance')) {
        // only if plugin activated
        $PLUGIN_HOOKS['pre_item_purge']['appliances'] = array('Profile' => array('PluginAppliancesProfile', 'cleanProfile'));
        $PLUGIN_HOOKS['item_clone']['appliances'] = array('Profile' => array('PluginAppliancesProfile', 'cloneProfile'));
        $PLUGIN_HOOKS['plugin_datainjection_populate']['appliances'] = 'plugin_datainjection_populate_appliances';
    }
    if (isset($_SESSION["glpiID"])) {
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            $_SESSION["glpi_plugin_environment_appliances"] = 1;
            // Display a menu entry ?
            if (plugin_appliances_haveRight("appliance", "r")) {
                $PLUGIN_HOOKS['menu_entry']['appliances'] = false;
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['title'] = _n('Appliance', 'Appliances', 2, 'appliances');
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['page'] = '/plugins/appliances/front/appliance.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['links']['search'] = '/plugins/appliances/front/appliance.php';
            }
            if (plugin_appliances_haveRight("appliance", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['appliances']['links']['add'] = '/plugins/appliances/front/appliance.form.php';
                $PLUGIN_HOOKS['use_massive_action']['appliances'] = 1;
            }
        } else {
            // Display a menu entry ?
            if (plugin_appliances_haveRight("appliance", "r")) {
                $PLUGIN_HOOKS['menu_entry']['appliances'] = 'front/appliance.php';
                $PLUGIN_HOOKS['submenu_entry']['appliances']['search'] = 'front/appliance.php';
            }
            if (plugin_appliances_haveRight("appliance", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['appliances']['add'] = 'front/appliance.form.php?new=1';
                $PLUGIN_HOOKS['use_massive_action']['appliances'] = 1;
            }
        }
    }
    // Import from Data_Injection plugin
    $PLUGIN_HOOKS['data_injection']['appliances'] = "plugin_appliances_data_injection_variables";
    // Import webservice
    $PLUGIN_HOOKS['webservices']['appliances'] = 'plugin_appliances_registerMethods';
    // End init, when all types are registered
    $PLUGIN_HOOKS['post_init']['appliances'] = 'plugin_appliances_postinit';
}
Esempio n. 7
0
 function showScripts(PluginDatabasesDatabase $database)
 {
     global $DB, $CFG_GLPI;
     $instID = $database->fields['id'];
     if (!$database->can($instID, "r")) {
         return false;
     }
     $rand = mt_rand();
     $canedit = $database->can($instID, 'w');
     $query = "SELECT `glpi_plugin_databases_scripts`.`name` AS name,\n                        `glpi_plugin_databases_scripts`.`id`,\n                        `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`,\n                        `glpi_plugin_databases_scripts`.`path`,\n                        `glpi_plugin_databases_scripts`.`comment`,\n                        `glpi_plugin_databases_scripttypes`.`name` AS type\n               FROM `glpi_plugin_databases_scripts` ";
     $query .= " LEFT JOIN `glpi_plugin_databases_scripttypes`\n      ON (`glpi_plugin_databases_scripttypes`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_scripttypes_id`)";
     $query .= " LEFT JOIN `glpi_plugin_databases_databases`\n      ON (`glpi_plugin_databases_databases`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`)";
     $query .= " WHERE `glpi_plugin_databases_scripts`.`plugin_databases_databases_id` = '{$instID}'\n          ORDER BY `glpi_plugin_databases_scripts`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array();
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     if ($number != 0) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         if ($canedit && $number) {
             echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
         }
         echo "<th>" . __('Name') . "</th>";
         echo "<th>" . __('Type') . "</th>";
         echo "<th>" . __('Path', 'databases') . "</th>";
         echo "<th>" . __('Comments') . "</th>";
         echo "</tr>";
         Session::initNavigateListItems($this->getType(), PluginDatabasesDatabase::getTypeName(2) . " = " . $database->fields["name"]);
         $i = 0;
         $row_num = 1;
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems($this->getType(), $data['id']);
             $i++;
             $row_num++;
             echo "<tr class='tab_bg_1 center'>";
             echo "<td width='10'>";
             if ($canedit) {
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
             }
             echo "</td>";
             echo "<td class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/script.form.php?id=" . $data["id"] . "&amp;plugin_databases_databases_id=" . $data["plugin_databases_databases_id"] . "'>";
             echo $data["name"];
             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                 echo " (" . $data["id"] . ")";
             }
             echo "</a></td>";
             echo "<td class='center'>" . $data["type"] . "</td>";
             echo "<td class='left'>" . $data["path"] . "</td>";
             echo "<td class='center'>" . nl2br($data["comment"]) . "</td>";
             echo "</tr>";
         }
         echo "</table>";
     }
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Databases. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$database = new PluginDatabasesDatabase();
$database_item = new PluginDatabasesDatabase_Item();
if (isset($_POST["add"])) {
    $database->check(-1, CREATE, $_POST);
    $newID = $database->add($_POST);
    if ($_SESSION['glpibackcreated']) {
        Html::redirect($web->getFormURL() . "?id=" . $newID);
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $database->check($_POST['id'], DELETE);
        $database->delete($_POST);
        $database->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $script->update($_POST);
        }
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            if ($script->canCreate()) {
                $script->delete($_POST, 1);
            }
            Html::redirect(Toolbox::getItemTypeFormURL('PluginDatabasesDatabase') . "?id=" . $_POST["plugin_databases_databases_id"]);
        } else {
            if (isset($_POST["delete_script"])) {
                if ($script->canCreate()) {
                    foreach ($_POST["check"] as $ID => $value) {
                        $script->delete(array("id" => $ID), 1);
                    }
                }
                Html::back();
            } else {
                $script->checkGlobal(READ);
                $plugin = new Plugin();
                if ($plugin->isActivated("environment")) {
                    Html::header(PluginDatabasesDatabase::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "databases");
                } else {
                    Html::header(PluginDatabasesDatabase::getTypeName(2), '', "assets", "plugindatabasesmenu");
                }
                $script->display($_GET);
                Html::footer();
            }
        }
    }
}
Esempio n. 10
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Databases. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$database = new PluginDatabasesDatabase();
$database_item = new PluginDatabasesDatabase_Item();
if (isset($_POST["add"])) {
    $database->check(-1, 'w', $_POST);
    $newID = $database->add($_POST);
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $database->check($_POST['id'], 'w');
        $database->delete($_POST);
        $database->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $database->check($_POST['id'], 'w');
            $database->restore($_POST);
            $database->redirectToList();
 /**
  * Show databases associated to an item
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object for which associated databases must be displayed
  * @param $withtemplate    (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!Session::haveRight('plugin_databases', READ)) {
         return false;
     }
     if (!$item->can($item->fields['id'], READ)) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $canedit = $item->canadditem('PluginDatabasesDatabase');
     $rand = mt_rand();
     $is_recursive = $item->isRecursive();
     $query = "SELECT `glpi_plugin_databases_databases_items`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity,\n                       `glpi_plugin_databases_databases`.`name` AS assocName,\n                       `glpi_plugin_databases_databases`.*\n                FROM `glpi_plugin_databases_databases_items`\n                LEFT JOIN `glpi_plugin_databases_databases`\n                 ON (`glpi_plugin_databases_databases_items`.`plugin_databases_databases_id`=`glpi_plugin_databases_databases`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_databases_databases`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_databases_databases_items`.`items_id` = '{$ID}'\n                      AND `glpi_plugin_databases_databases_items`.`itemtype` = '" . $item->getType() . "' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_databases_databases", '', '', true);
     $query .= " ORDER BY `assocName`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $databases = array();
     $database = new PluginDatabasesDatabase();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $databases[$data['assocID']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit && $withtemplate < 2) {
         // Restrict entity for knowbase
         $entities = "";
         $entity = $_SESSION["glpiactive_entity"];
         if ($item->isEntityAssign()) {
             /// Case of personal items : entity = -1 : create on active entity (Reminder case))
             if ($item->getEntityID() >= 0) {
                 $entity = $item->getEntityID();
             }
             if ($item->isRecursive()) {
                 $entities = getSonsOf('glpi_entities', $entity);
             } else {
                 $entities = $entity;
             }
         }
         $limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_databases_databases", '', $entities, true);
         $q = "SELECT COUNT(*)\n               FROM `glpi_plugin_databases_databases`\n               WHERE `is_deleted` = '0'\n               {$limit}";
         $result = $DB->query($q);
         $nb = $DB->result($result, 0, 0);
         echo "<div class='firstbloc'>";
         if (Session::haveRight('plugin_databases', READ) && $nb > count($used)) {
             echo "<form name='database_form{$rand}' id='database_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL('PluginDatabasesDatabase') . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='4' class='center'>";
             echo "<input type='hidden' name='entities_id' value='{$entity}'>";
             echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             if ($item->getType() == 'Ticket') {
                 echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
             }
             PluginDatabasesDatabase::dropdownDatabase(array('entity' => $entities, 'used' => $used));
             echo "</td><td class='center' width='20%'>";
             echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a database', 'databases') . "\" class='submit'>";
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             Html::closeForm();
         }
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number && $withtemplate < 2) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . PluginDatabasesServerType::getTypeName(1) . "</th>";
     echo "<th>" . PluginDatabasesDatabaseCategory::getTypeName(1) . "</th>";
     echo "<th>" . __('Supplier') . "</th>";
     echo "<th>" . __('Editor', 'databases') . "</th>";
     echo "</tr>";
     $used = array();
     if ($number) {
         Session::initNavigateListItems('PluginDatabasesDatabase', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($databases as $data) {
             $databaseID = $data["id"];
             $link = NOT_AVAILABLE;
             if ($database->getFromDB($databaseID)) {
                 $link = $database->getLink();
             }
             Session::addToNavigateListItems('PluginDatabasesDatabase', $databaseID);
             $used[$databaseID] = $databaseID;
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$link}</td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_databases_servertypes", $data["plugin_databases_servertypes_id"]) . "</td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_databases_databasetypes", $data["plugin_databases_databasetypes_id"]) . "</td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]) . "</td>";
             echo "<td>";
             echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id=" . $data["suppliers_id"] . "\">";
             echo Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]);
             if ($_SESSION["glpiis_ids_visible"] == 1) {
                 echo " (" . $data["suppliers_id"] . ")";
             }
             echo "</a></td>";
             echo "</tr>";
             $i++;
         }
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate < 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Esempio n. 12
0
            $instance->update($_POST);
        }
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            if ($instance->canCreate()) {
                $instance->delete($_POST, 1);
            }
            Html::redirect(Toolbox::getItemTypeFormURL('PluginDatabasesDatabase') . "?id=" . $_POST["plugin_databases_databases_id"]);
        } else {
            if (isset($_POST["delete_instance"])) {
                if ($instance->canCreate()) {
                    foreach ($_POST["check"] as $ID => $value) {
                        $instance->delete(array("id" => $ID), 1);
                    }
                }
                Html::back();
            } else {
                $instance->checkGlobal("r");
                $plugin = new Plugin();
                if ($plugin->isActivated("environment")) {
                    Html::header(PluginDatabasesDatabase::getTypeName(2), '', "plugins", "environment", "databases");
                } else {
                    Html::header(PluginDatabasesDatabase::getTypeName(2), '', "plugins", "databases");
                }
                $instance->showForm($_GET["id"], array('plugin_databases_databases_id' => $_GET["plugin_databases_databases_id"]));
                Html::footer();
            }
        }
    }
}
Esempio n. 13
0
function plugin_databases_MassiveActionsDisplay($options = array())
{
    $database = new PluginDatabasesDatabase();
    if (in_array($options['itemtype'], PluginDatabasesDatabase::getTypes(true))) {
        $database->dropdownDatabases("plugin_databases_databases_id");
        echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __s('Post') . "\" >";
    }
    return "";
}
Esempio n. 14
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'databases'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginDatabasesDatabase::getTypeName(2) . "</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("databases", $this->fields["databases"], 1, 1, 1);
     } else {
         _e('No access');
         // No access;
     }
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginDatabasesDatabase::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }