本文整理汇总了PHP中UserSettings::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSettings::delete方法的具体用法?PHP UserSettings::delete怎么用?PHP UserSettings::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSettings
的用法示例。
在下文中一共展示了UserSettings::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserSettings
/**
* Initialize the order param
*/
function init_order_param()
{
global $UserSettings;
if (empty($UserSettings)) {
$UserSettings = new UserSettings();
}
// attribution of an order type
$this->order_param = 'results_' . $this->param_prefix . 'order';
$order_request = param($this->order_param, 'string', '', true);
// remove symbols '-' from the end
$order_request = rtrim($order_request, '-');
if ($this->force_order_by_count !== NULL && !empty($order_request)) {
// Check if we should force an order filed to default value
if ($this->get_total_rows() > $this->force_order_by_count) {
// This table has very much records we should force an order to default
$reverse_default_order = str_replace('D', 'A', $this->default_order);
$reverse_default_order = $reverse_default_order == $this->default_order ? str_replace('A', 'D', $this->default_order) : $reverse_default_order;
if ($order_request != $this->default_order && $order_request != $reverse_default_order) {
// If an order from request is not default then we must change it to default
$this->order = $this->default_order;
$order_request_title = $order_request;
if (isset($this->cols)) {
// Try to find a title of the ordered field to display it in warning message
$order_index = strpos($order_request, 'A');
$order_index = $order_index === FALSE ? strpos($order_request, 'D') : $order_index;
if (isset($this->cols[$order_index]) && isset($this->cols[$order_index]['th'])) {
$order_request_title = $this->cols[$order_index]['th'];
}
}
// Add a message to inform user about this order type is not allowed in this case
$this->add_message(sprintf(T_('In order to maintain good performance, you cannot sort by %s when there are more than %s results.'), $order_request_title, number_format($this->force_order_by_count, 0, '', ' ')));
}
}
}
if (empty($this->order)) {
// Set an order from GET request
$this->order = $order_request;
}
if (!empty($this->param_prefix) && !empty($this->order) && $this->order != $UserSettings->get($this->order_param)) {
// Change an order param in DB for current user and current list
if ($this->order == $this->default_order) {
// Delete an order param for current list if it is a default value
$UserSettings->delete($this->order_param);
} else {
// Set a new value of an order param for current list
$UserSettings->set($this->order_param, $this->order);
}
$UserSettings->dbupdate();
}
if (!empty($this->param_prefix) && empty($this->order)) {
// Set an order param from DB
if ($UserSettings->get($this->order_param) != '') {
// Set a value for current list if it was already defined
$this->order = $UserSettings->get($this->order_param);
}
}
if (empty($this->order)) {
// Set a default value
$this->order = $this->default_order;
}
}
示例2: UserSettings
/**
* Initialize the order param
*
* @param string default ordering of columns (special syntax) if not specified in the URL params
* example: -A-- will sort in ascending order on 2nd column
* example: ---D will sort in descending order on 4th column
*/
function init_order_param($default_order)
{
global $UserSettings;
if (empty($UserSettings)) {
$UserSettings = new UserSettings();
}
// attribution of an order type
$this->order_param = 'results_' . $this->param_prefix . 'order';
$this->order = param($this->order_param, 'string', '', true);
// remove symbols '-' from the end
$this->order = preg_replace('/(-*[AD]+)(-*)/i', '$1', $this->order);
if (!empty($this->param_prefix) && !empty($this->order) && $this->order != $UserSettings->get($this->order_param)) {
// Change an order param in DB for current user and current list
if ($this->order == $default_order) {
// Delete an order param for current list if it is a default value
$UserSettings->delete($this->order_param);
} else {
// Set a new value of an order param for current list
$UserSettings->set($this->order_param, $this->order);
}
$UserSettings->dbupdate();
}
if (!empty($this->param_prefix) && empty($this->order)) {
// Set an order param from DB
if ($UserSettings->get($this->order_param) != '') {
// Set a value for current list if it was already defined
$this->order = $UserSettings->get($this->order_param);
}
}
if (empty($this->order)) {
// Set a default value
$this->order = $default_order;
}
}