CommonDBTM::getEmpty PHP Method

getEmpty() public method

Get an empty item
public getEmpty ( ) : true
return true if succeed else false
    function getEmpty()
    {
        global $DB;
        //make an empty database object
        $table = $this->getTable();
        if (!empty($table) && ($fields = $DB->list_fields($table))) {
            foreach ($fields as $key => $val) {
                $this->fields[$key] = "";
            }
        } else {
            return false;
        }
        if (array_key_exists('entities_id', $this->fields) && isset($_SESSION["glpiactive_entity"])) {
            $this->fields['entities_id'] = $_SESSION["glpiactive_entity"];
        }
        $this->post_getEmpty();
        // Call the plugin hook - $this->fields can be altered
        Plugin::doHook("item_empty", $this);
        return true;
    }

Usage Example

示例#1
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::getEmpty()
  **/
 function getEmpty()
 {
     parent::getEmpty();
     //Keep the same behavior as in previous versions
     $this->fields['open_window'] = 1;
 }
All Usage Examples Of CommonDBTM::getEmpty
CommonDBTM