PMA\libraries\Table::setUiProp PHP Method

setUiProp() public method

If pmadb and table_uiprefs is set, it will save the UI preferences to phpMyAdmin database. Available property: - PROP_SORTED_COLUMN - PROP_COLUMN_ORDER - PROP_COLUMN_VISIB
public setUiProp ( string $property, mixed $value, string $table_create_time = null ) : boolean | Message
$property string Property
$value mixed Value for the property
$table_create_time string Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
return boolean | Message
    public function setUiProp($property, $value, $table_create_time = null)
    {
        if (!isset($this->uiprefs)) {
            $this->loadUiPrefs();
        }
        // we want to save the create time if the property is PROP_COLUMN_ORDER
        if (!$this->isView() && ($property == self::PROP_COLUMN_ORDER || $property == self::PROP_COLUMN_VISIB)) {
            $curr_create_time = $this->getStatusInfo('CREATE_TIME');
            if (isset($table_create_time) && $table_create_time == $curr_create_time) {
                $this->uiprefs['CREATE_TIME'] = $curr_create_time;
            } else {
                // there is no $table_create_time, or
                // supplied $table_create_time is older than current create time,
                // so don't save
                return Message::error(sprintf(__('Cannot save UI property "%s". The changes made will ' . 'not be persistent after you refresh this page. ' . 'Please check if the table structure has been changed.'), $property));
            }
        }
        // save the value
        $this->uiprefs[$property] = $value;
        // check if pmadb is set
        $cfgRelation = PMA_getRelationsParam();
        if ($cfgRelation['uiprefswork']) {
            return $this->saveUiprefsToDb();
        }
        return true;
    }

Usage Example

Esempio n. 1
0
/**
 * Function to set a column property
 *
 * @param Table  $pmatable      Table instance
 * @param string $request_index col_order|col_visib
 *
 * @return boolean $retval
 */
function PMA_setColumnProperty($pmatable, $request_index)
{
    $property_value = explode(',', $_REQUEST[$request_index]);
    switch ($request_index) {
        case 'col_order':
            $property_to_set = Table::PROP_COLUMN_ORDER;
            break;
        case 'col_visib':
            $property_to_set = Table::PROP_COLUMN_VISIB;
            break;
        default:
            $property_to_set = '';
    }
    $retval = $pmatable->setUiProp($property_to_set, $property_value, $_REQUEST['table_create_time']);
    if (gettype($retval) != 'boolean') {
        $response = PMA\libraries\Response::getInstance();
        $response->setRequestStatus(false);
        $response->addJSON('message', $retval->getString());
        exit;
    }
    return $retval;
}
All Usage Examples Of PMA\libraries\Table::setUiProp