本文整理汇总了PHP中value_or_default函数的典型用法代码示例。如果您正苦于以下问题:PHP value_or_default函数的具体用法?PHP value_or_default怎么用?PHP value_or_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了value_or_default函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_webuser_groups
SET website = :website, name = :name, code = :code, description = :description
WHERE id = :id', array('id' => $this->id, 'website' => $this->website, 'name' => value_or_default($this->name, ""), 'code' => value_or_default($this->code, ""), 'description' => value_or_default($this->description, "")));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:12,代码来源:webuser_group.class.php
示例2: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_profiles
SET name = :name, description = :description, menus = :menus
WHERE id = :id', array('name' => value_or_default($this->name, ""), 'description' => value_or_default($this->description, ""), 'menus' => json_encode($this->menus), 'id' => $this->id));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:12,代码来源:profile.class.php
示例3: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_functions
SET category = :category, codename = :codename, icon = :icon,
lid = :lid, enabled = :enabled
WHERE id = :id', array('id' => $this->id, 'category' => value_or_default($this->category, ""), 'codename' => value_or_default($this->codename, ""), 'icon' => value_or_default($this->icon, ""), 'lid' => value_or_default($this->lid, 0), 'enabled' => value_or_default($this->enabled, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:13,代码来源:nv_function.class.php
示例4: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_paths
SET type = :type, object_id = :object_id, lang = :lang,
path = :path, cache_file = :cache_file, cache_expires = :cache_expires, views = :views,
id = :id, website = :website', array("type" => $this->type, "object_id" => $this->object_id, "lang" => $this->lang, "path" => $this->path, "cache_file" => $this->cache_file, "cache_expires" => $this->cache_expires, "views" => value_or_default($this->views, 0), "id" => $this->id, "website" => $this->website));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:13,代码来源:path.class.php
示例5: update
public function update()
{
global $DB;
global $website;
$this->date = core_time();
$ok = $DB->execute('
UPDATE nv_webuser_votes
SET webuser = :webuser, object = :object, object_id = :object_id, value = :value, date = :date
WHERE id = :id AND website = :website', array('id' => $this->id, 'website' => value_or_default($this->website, $website->id), 'webuser' => value_or_default($this->webuser, 0), 'object' => $this->object, 'object_id' => $this->object_id, 'value' => $this->value, 'date' => value_or_default($this->date, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:14,代码来源:webuser_vote.class.php
示例6: save_properties_from_array
//.........这里部分代码省略.........
}
} else {
// compatibility with < Navigate 2.1 themes (to be removed)
$properties_names = array_keys($properties_assoc);
$block = block::block_group_block_by_property($properties_names[0]);
}
if (!isset($block->properties) || empty($block->properties)) {
return false;
}
$properties = $block->properties;
} else {
$properties = property::elements($template, $object_type);
}
if (!is_array($properties)) {
$properties = array();
}
foreach ($properties as $property) {
if (!isset($properties_assoc[$property->name]) && !isset($properties_assoc[$property->id])) {
continue;
}
$values_dict = array();
$value = '';
// we try to find the property value by "property name", if empty then we try to find it via "property id"
if (isset($properties_assoc[$property->name])) {
$value = $properties_assoc[$property->name];
}
if (empty($value)) {
$value = $properties_assoc[$property->id];
}
// multilanguage property?
if (in_array($property->type, array('text', 'textarea', 'link', 'rich_textarea')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) {
if (isset($properties_assoc[$property->name])) {
$values_dict = $properties_assoc[$property->name];
}
if (empty($values_dict)) {
$values_dict = $properties_assoc[$property->id];
}
$value = '[dictionary]';
}
if ($property->type == 'coordinates') {
if (is_array($value)) {
$value = $value['latitude'] . '#' . $value['longitude'];
}
// if it isn't an array, then we suppose it already has the right format
}
// property->type "decimal"; we don't need to reconvert, it should already be in the right format
if ($property->type == 'webuser_groups' && !empty($value)) {
$value = 'g' . implode(',g', $value);
}
// boolean (checkbox): if not checked, form does not send the value
if ($property->type == 'boolean' && empty($value)) {
$value = 0;
}
if (is_null($value)) {
$value = "";
}
// should not be needed because of value_or_default, but doing this here fixes some warnings
// remove the old property value row
$DB->execute('
DELETE FROM nv_properties_items
WHERE property_id = ' . protect($property->id) . '
AND element = ' . protect($property_object_type) . '
AND node_id = ' . protect($object_id) . (empty($node_uid) ? '' : ' AND node_uid = ' . protect($node_uid)) . '
AND website = ' . $ws->id);
// now we insert a new row
$DB->execute('
INSERT INTO nv_properties_items
(id, website, property_id, element, node_id, node_uid, name, value)
VALUES
( 0,
:website,
:property_id,
:type,
:object_id,
:node_uid,
:name,
:value
)', array(':website' => $ws->id, ':property_id' => $property->id, ':type' => $property_object_type, ':object_id' => value_or_default($object_id, 0), ':node_uid' => value_or_default($node_uid, ""), ':name' => $property->name, ':value' => value_or_default($value, "")));
// $error = $DB->get_last_error();
// set the dictionary for the multilanguage properties
$default_language = '';
if (isset($property->multilanguage) && ($property->multilanguage === 'false' || $property->multilanguage === false)) {
$default_language = $ws->languages_list[0];
}
if (in_array($property->type, array('text', 'textarea', 'rich_textarea', 'link')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) {
foreach ($ws->languages_list as $lang) {
if (!empty($default_language)) {
// property is NOT multilanguage, use the first value for all languages
$dictionary[$lang]['property-' . $property->id . '-' . $lang] = $values_dict[$default_language];
} else {
$dictionary[$lang]['property-' . $property->id . '-' . $lang] = $values_dict[$lang];
}
}
}
}
if (!empty($dictionary)) {
webdictionary::save_element_strings('property-' . $property_object_type, $object_id, $dictionary, $ws->id, $node_uid);
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:property.class.php
示例7: update
public function update()
{
global $DB;
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_files
SET
type = :type,
parent = :parent,
name = :fname,
size = :size,
mime = :mime,
width = :width,
height = :height,
focalpoint = :focalpoint,
title = :title,
description = :description,
date_added = :date_added,
uploaded_by = :uploaded_by,
permission = :permission,
access = :access,
groups = :groups,
system = :system,
enabled = :enabled
WHERE id = :id
AND website = :website_id
', array(":id" => $this->id, ":website_id" => $this->website, ":type" => $this->type, ":parent" => $this->parent, ":fname" => $this->name, ":size" => $this->size, ":mime" => $this->mime, ":width" => $this->width, ":height" => $this->height, ":focalpoint" => value_or_default($this->focalpoint, ''), ":title" => json_encode($this->title), ":description" => json_encode($this->description), ":date_added" => $this->date_added, ":uploaded_by" => $this->uploaded_by, ":permission" => $this->permission, ":access" => value_or_default($this->access, 0), ":groups" => $groups, ":system" => value_or_default($this->system, 0), ":enabled" => $this->enabled));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:44,代码来源:file.class.php
示例8: run
function run()
{
global $user;
switch (@$_REQUEST['act']) {
case 'json':
switch ($_REQUEST['oper']) {
case 'settings_panels':
// save dashboard panels state
$dashboard_panels = $_REQUEST['dashboard_panels'];
$user->setting('dashboard-panels', json_encode($dashboard_panels));
echo json_encode(true);
core_terminate();
break;
case 'feed':
$feed = new feed_parser();
$feed->set_cache(4 * 3600);
// once update each 4 hours
$feed->load($_REQUEST['url']);
list($channel, $articles, $count) = $feed->parse(0, $_REQUEST['limit'], 'newest');
$items = item::convert_from_rss($articles);
$display_language = $_REQUEST['language'];
if (!empty($items)) {
$feed_html = '';
for ($c = 0; $c < count($items); $c++) {
if (empty($items[$c])) {
break;
}
if (!isset($items[$c]->dictionary[$display_language])) {
// requested language not available, get the first available in the feed
$feed_languages = array_keys($items[$c]->dictionary);
$display_language = $feed_languages[0];
}
$tmp = array('<div class="navigate-panel-body-title ui-corner-all">' . '<a href="' . $items[$c]->paths[$display_language] . '" target="_blank">' . core_ts2date($items[$c]->date_to_display, true) . ' ' . '<strong>' . $items[$c]->dictionary[$display_language]['title'] . '</strong>' . '</a>' . '</div>', '<div id="navigatecms-feed-item-' . $items[$c]->id . '" class="navigate-panel-recent-feed-element">' . $items[$c]->dictionary[$display_language]['section-main'] . '</div>');
$feed_html .= implode("\n", $tmp);
}
}
echo $feed_html;
core_terminate();
break;
default:
// list or search
}
break;
case 'recent_items':
$ri = users_log::recent_items(value_or_default($_REQUEST['limit']), 10);
if (!is_array($ri)) {
$ri = array();
}
for ($i = 0; $i < count($ri); $i++) {
$action = $ri[$i];
$ri[$i]->_url = '?fid=' . $action->function . '&wid=' . $action->website . '&act=load&id=' . $action->item;
$ri[$i]->_link = '<a href="' . $ri[$i]->_url . '" title="' . htmlspecialchars($action->item_title) . ' | ' . htmlspecialchars(t($action->function_title, $action->function_title)) . '"><img src="' . $action->function_icon . '" align="absmiddle" /> ' . core_string_cut($action->item_title, 33) . '</a>';
}
echo json_encode($ri);
core_terminate();
break;
default:
$out = dashboard_create();
}
return $out;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:61,代码来源:dashboard.php
示例9: v
/**
* An alias of {@link value_or_default()}
*
*
* @param mixed $value
* @param mixed $default
* @return mixed
*/
function v($value, $default)
{
return value_or_default($value, $default);
}
开发者ID:plus3network,项目名称:PHPHelpers,代码行数:12,代码来源:limonade.php
示例10: update
public function update()
{
global $DB;
global $website;
global $events;
global $user;
if (!is_null($user)) {
if ($user->permission("items.edit") == 'false' && $this->author != $user->id) {
throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
}
if (!structure::category_allowed($this->category)) {
throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
}
}
$this->date_modified = core_time();
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_items
SET
association = :association,
category = :category,
embedding = :embedding,
template = :template,
date_to_display = :date_to_display,
date_published = :date_published,
date_unpublish = :date_unpublish,
date_modified = :date_modified,
author = :author,
galleries = :galleries,
comments_enabled_to = :comments_enabled_to,
comments_moderator = :comments_moderator,
access = :access,
groups = :groups,
permission = :permission,
views = :views,
votes = :votes,
score = :score,
position = :position
WHERE id = :id
AND website = :website', array(":association" => $this->association, ":category" => $this->category, ":embedding" => $this->embedding, ":template" => $this->template, ":date_to_display" => value_or_default($this->date_to_display, 0), ":date_published" => value_or_default($this->date_published, 0), ":date_unpublish" => value_or_default($this->date_unpublish, 0), ":date_modified" => $this->date_modified, ":author" => $this->author, ":galleries" => serialize($this->galleries), ":comments_enabled_to" => value_or_default($this->comments_enabled_to, 0), ":comments_moderator" => value_or_default($this->comments_moderator, 0), ":access" => $this->access, ":groups" => $groups, ":permission" => $this->permission, ":views" => $this->views, ":votes" => $this->votes, ":score" => $this->score, ":position" => value_or_default($this->position, 0), ":id" => $this->id, ":website" => $this->website));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
webdictionary::save_element_strings('item', $this->id, $this->dictionary, $this->website);
webdictionary_history::save_element_strings('item', $this->id, $this->dictionary, false, $this->website);
path::saveElementPaths('item', $this->id, $this->paths, $this->website);
$events->trigger('item', 'save', array('item' => $this));
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:61,代码来源:item.class.php
示例11: all_error_texts
function all_error_texts()
{
return implode('<br>', array_map('retry_error_text', array_keys(value_or_default($_GET, ERROR_GET_VARIABLE, array()))));
}
开发者ID:aliclark,项目名称:php-web-apps,代码行数:4,代码来源:php-web-apps.php
示例12: set_or_default
/**
* Sets a template variable with a value or a default value if value is empty
*
* @param string $name
* @param string $value
* @param string $default
* @return mixed setted value
*/
function set_or_default($name, $value, $default)
{
return set($name, value_or_default($value, $default));
}
开发者ID:sofadesign,项目名称:library.dev,代码行数:12,代码来源:limonade.php
示例13: update
public function update()
{
global $DB;
global $website;
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_structure
SET parent = :parent, position = :position, access = :access, groups = :groups,
permission = :permission, icon = :icon, metatags = :metatags,
date_published = :date_published, date_unpublish = :date_unpublish,
template = :template, visible = :visible, views = :views, votes = :votes, score = :score
WHERE id = :id
AND website = :website
', array(":id" => $this->id, ":website" => $this->website, ":parent" => value_or_default($this->parent, 0), ":position" => $this->position, ":access" => $this->access, ":groups" => $groups, ":permission" => $this->permission, ":icon" => value_or_default($this->icon, ''), ":metatags" => value_or_default($this->metatags, ''), ":template" => $this->template, ":date_published" => value_or_default($this->date_published, 0), ":date_unpublish" => value_or_default($this->date_unpublish, 0), ":visible" => $this->visible, ":views" => $this->views, ":votes" => $this->votes, ":score" => $this->score));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
webdictionary::save_element_strings('structure', $this->id, $this->dictionary, $this->website);
path::saveElementPaths('structure', $this->id, $this->paths, $this->website);
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:33,代码来源:structure.class.php
示例14: update
public function update()
{
global $DB;
if (!is_array($this->categories)) {
$this->categories = array();
}
$ok = $DB->execute('
UPDATE nv_feeds
SET categories = :categories, format = :format, image = :image, entries = :entries,
content = :content, views = :views, permission = :permission, enabled = :enabled
WHERE id = :id AND website = :website', array('id' => $this->id, 'website' => $this->website, 'categories' => implode(',', $this->categories), 'format' => $this->format, 'image' => value_or_default($this->image, 0), 'entries' => value_or_default($this->entries, 10), 'content' => $this->content, 'views' => value_or_default($this->views, 0), 'permission' => value_or_default($this->permission, 0), 'enabled' => value_or_default($this->enabled, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
webdictionary::save_element_strings('feed', $this->id, $this->dictionary);
path::saveElementPaths('feed', $this->id, $this->paths);
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:18,代码来源:feed.class.php
示例15: update
public function update()
{
global $DB;
global $website;
$ok = $DB->execute('UPDATE nv_block_groups
SET
`code` = :code,
title = :title,
notes = :notes,
blocks = :blocks
WHERE id = :id
AND website = :website
', array(':id' => $this->id, ':website' => $this->website, ':code' => value_or_default($this->code, ''), ':title' => value_or_default($this->title, ''), ':notes' => value_or_default($this->notes, ''), ':blocks' => json_encode($this->blocks)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:18,代码来源:block_group.class.php
示例16: update
public function update()
{
global $DB;
global $website;
$ok = $DB->execute('
UPDATE nv_templates
SET title = :title, file = :file, sections = :sections, gallery = :gallery,
comments = :comments, tags = :tags, statistics = :statistics,
permission = :permission, enabled = :enabled
WHERE id = :id
AND website = :website', array(':id' => $this->id, ':website' => value_or_default($this->website, $website->id), ':title' => value_or_default($this->title, ""), ':file' => value_or_default($this->file, ""), ':sections' => serialize($this->sections), ':gallery' => value_or_default($this->gallery, 0), ':comments' => value_or_default($this->comments, 0), ':tags' => value_or_default($this->tags, 0), ':statistics' => value_or_default($this->statistics, 0), ':permission' => value_or_default($this->permission, 0), ':enabled' => value_or_default($this->enabled, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:16,代码来源:template.class.php
示例17: nvweb_comments_list
function nvweb_comments_list($offset = 0, $limit = NULL, $permission = NULL, $order = 'oldest')
{
global $DB;
global $website;
global $current;
$limit = value_or_default($limit, 2147483647);
if ($order == 'newest' || $order == 'hierarchy_newest') {
$orderby = "nvc.date_created DESC";
} else {
$orderby = "nvc.date_created ASC";
}
$element = $current['object'];
if ($current['type'] == 'structure') {
if (empty($current['structure_elements'])) {
$current['structure_elements'] = $element->elements();
}
$element = $current['structure_elements'][0];
} else {
if ($current['type'] == 'item') {
$element = new item();
$element->load($current['id']);
}
}
if (strpos($order, 'hierarchy') !== false) {
// list comments keeping hierarchy
// MySQL (still) does not have recursive queries, meanwhile we apply the following procedure:
// find all comments of 0-depth (root level) and calculate if they have any reply
// then, in PHP, parse the results and load (recursively) all replies and subreplies
// in the result array, INSERT the additional results in the position where they must be respecting the order requested (oldest/newest)
// note 1: this procedure allows optimization, for now we've made it work
// note 2: the only drawback is that offset/limit it's only taken into account for the root level comments, so the
// number of results is variable on each request; we found that an acceptable drawback
$DB->query('
SELECT SQL_CALC_FOUND_ROWS nvc.*, nvwu.username, nvwu.avatar,
(SELECT COUNT(nvcr.id)
FROM nv_comments nvcr
WHERE nvcr.reply_to = nvc.id
AND nvcr.status = 0
) AS replies
FROM nv_comments nvc
LEFT OUTER JOIN nv_webusers nvwu
ON nvwu.id = nvc.user
WHERE nvc.website = ' . protect($website->id) . '
AND nvc.item = ' . protect($element->id) . '
AND nvc.status = 0
AND nvc.reply_to = 0
ORDER BY ' . $orderby . '
LIMIT ' . $limit . '
OFFSET ' . $offset);
$rs = $DB->result();
$out = array();
for ($r = 0; $r < count($rs); $r++) {
$rows_to_add = array();
if ($rs[$r]->replies > 0) {
$c = new comment();
$c->load_from_resultset(array($rs[$r]));
$rows_to_add = $c->get_replies();
}
$out[] = $rs[$r];
if (!empty($rows_to_add)) {
foreach ($rows_to_add as $rta) {
$out[] = $rta;
}
}
}
$rs = $out;
$total = count($rs);
} else {
$DB->query('
SELECT SQL_CALC_FOUND_ROWS nvc.*, nvwu.username, nvwu.avatar
FROM nv_comments nvc
LEFT OUTER JOIN nv_webusers nvwu
ON nvwu.id = nvc.user
WHERE nvc.website = ' . protect($website->id) . '
AND nvc.item = ' . protect($element->id) . '
AND nvc.status = 0
ORDER BY ' . $orderby . '
LIMIT ' . $limit . '
OFFSET ' . $offset);
$rs = $DB->result();
$total = $DB->foundRows();
}
return array($rs, $total);
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:84,代码来源:comments.php
示例18: save
public function save()
{
global $DB;
$ok = false;
$settings = $this->settings;
$settings = json_encode($settings);
if (empty($this->id)) {
$ok = $DB->execute('
INSERT INTO nv_extensions (id, website, extension, enabled, settings)
VALUES(0, :website, :code, :enabled, :settings)', array(':website' => $this->website, ':code' => $this->code, ':enabled' => value_or_default($this->enabled, 0), ':settings' => $settings));
} else {
$ok = $DB->execute('
UPDATE nv_extensions
SET enabled = :enabled, settings = :settings
WHERE id = :id', array(':enabled' => value_or_default($this->enabled, 0), ':settings' => $settings, ':id' => $this->id));
}
return $ok;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:18,代码来源:extension.class.php
示例19: action
public static function action($function, $item = '', $action = '', $item_title = '', $data = '')
{
global $DB;
global $website;
global $user;
$encoded_data = '';
if ($action == 'save' && function_exists('gzencode')) {
$encoded_data = gzencode($data);
}
// a blank (new) form requested
if ($action == 'load' && empty($item)) {
return true;
}
$wid = $website->id;
if (empty($wid)) {
$wid = 0;
}
$uid = $user->id;
if (empty($uid)) {
$uid = 0;
}
if (!is_numeric($function)) {
$func = core_load_function($function);
$function = $func->id;
}
// prepared statement
$ok = $DB->execute('
INSERT INTO nv_users_log
(id, `date`, user, website, `function`, item, action, item_title, data)
VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ? )', array(0, core_time(), $uid, $wid, $function, value_or_default($item, ""), value_or_default($action, ""), value_or_default((string) $item_title, ""), value_or_default($encoded_data, "")));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:36,代码来源:users_log.class.php
示例20: update
public function update($trigger_webuser_modified = true)
{
global $DB;
global $events;
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_webusers
SET
website = :website,
username = :username,
password = :password,
email = :email,
groups = :groups,
fullname = :fullname,
gender = :gender,
avatar = :avatar,
birthdate = :birthdate,
language = :language,
lastseen = :lastseen,
country = :country,
timezone = :timezone,
address = :address,
zipcode = :zipcode,
location = :location,
phone = :phone,
social_website = :social_website,
newsletter = :newsletter,
private_comment = :private_comment,
activation_key = :activation_key,
cookie_hash = :cookie_hash,
access = :access,
access_begin = :access_begin,
access_end = :access_end,
email_verification_date = :email_verification_date
WHERE id = :id
', array(':website' => $this->website, ':username' => $this->username, ':password' => $this->password, ':email' => $this->email, ':groups' => $groups, ':fullname' => $this->fullname, ':gender' => value_or_default($this->gender, ""), ':avatar' => $this->avatar, ':birthdate' => value_or_default($this->birthdate, 0), ':language' => value_or_default($this->language, ""), ':lastseen' => $this->lastseen, ':country' => $this->country, ':timezone' => $this->timezone, ':address' => $this->address, ':zipcode' => $this->zipcode, ':location' => $this->location, ':phone' => $this->phone, ':social_website' => value_or_default($this->social_website, ""), ':newsletter' => value_or_default($this->newsletter, 0), ':private_comment' => value_or_default($this->private_comment, ""), ':activation_key' => value_or_default($this->activation_key, ""), ':cookie_hash' => value_or_default($this->cookie_hash, ""), ":access" => value_or_default($this->access, 0), ":access_begin" => value_or_default($this->access_begin, 0), ":access_end" => value_or_default($this->access_end, 0), ':id' => $this->id, ':email_verification_date' => value_or_default($this->email_verification_date, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
if ($trigger_webuser_modified) {
$events->trigger('webuser', 'save', array('webuser' => $this));
}
return true;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:56,代码来源:webuser.class.php
注:本文中的value_or_default函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论