Computer_Item::dropdownConnect PHP Method

dropdownConnect() static public method

Make a select box for connections
static public dropdownConnect ( $itemtype, $fromtype, $myname, $entity_restrict, $onlyglobal, $used = [] ) : nothing
$itemtype type to connect
$fromtype from where the connection is
$myname select name
$entity_restrict Restrict to a defined entity (default = -1)
$onlyglobal display only global devices (used for templates) (default 0)
$used array Already used items ID: not to display in dropdown
return nothing (print out an HTML select box)
    static function dropdownConnect($itemtype, $fromtype, $myname, $entity_restrict = -1, $onlyglobal = 0, $used = array())
    {
        global $CFG_GLPI;
        $rand = mt_rand();
        $field_id = Html::cleanId("dropdown_" . $myname . $rand);
        $param = array('entity_restrict' => $entity_restrict, 'fromtype' => $fromtype, 'itemtype' => $itemtype, 'onlyglobal' => $onlyglobal, 'used' => $used);
        echo Html::jsAjaxDropdown($myname, $field_id, $CFG_GLPI['root_doc'] . "/ajax/getDropdownConnect.php", $param);
        return $rand;
    }

Usage Example

Example #1
0
GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
if (strpos($_SERVER['PHP_SELF'], "dropdownConnect.php")) {
    include '../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
} else {
    if (!defined('GLPI_ROOT')) {
        die("Sorry. You can't access this file directly");
    }
}
if (!isset($_POST['fromtype']) || !($fromitem = getItemForItemtype($_POST['fromtype']))) {
    exit;
}
$fromitem->checkGlobal(UPDATE);
$used = array();
if (isset($_POST["used"])) {
    $used = $_POST["used"];
}
Computer_Item::dropdownConnect($_POST["itemtype"], $_POST['fromtype'], $_POST['myname'], $_POST["entity_restrict"], $_POST["onlyglobal"], $used);
All Usage Examples Of Computer_Item::dropdownConnect