本文整理汇总了PHP中sp_add_sfmeta函数的典型用法代码示例。如果您正苦于以下问题:PHP sp_add_sfmeta函数的具体用法?PHP sp_add_sfmeta怎么用?PHP sp_add_sfmeta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_add_sfmeta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sp_featured_admin_options_save
function sp_featured_admin_options_save()
{
check_admin_referer('forum-adminform_userplugin', 'forum-adminform_userplugin');
# Save options
$topics = sp_filter_title_save(trim($_POST['topic_list']));
$topics = explode(',', $topics);
sp_add_sfmeta('featured', 'topics', $topics, true);
$posts = sp_filter_title_save(trim($_POST['post_list']));
$posts = explode(',', $posts);
sp_add_sfmeta('featured', 'posts', $posts, true);
$out = __('Featured topics and posts options updated', 'sp-featured');
return $out;
}
示例2: sp_featured_do_install
function sp_featured_do_install()
{
$options = sp_get_option('featured');
if (empty($options)) {
$options['dbversion'] = SPFEATUREDDBVERSION;
sp_update_option('featured', $options);
}
# set up our sfmeta if needed
$check = sp_get_sfmeta('featured', 'topics');
if (empty($check)) {
sp_add_sfmeta('featured', 'topics', array(), true);
}
$check = sp_get_sfmeta('featured', 'posts');
if (empty($check)) {
sp_add_sfmeta('featured', 'posts', array(), true);
}
}
示例3: sp_admin_bar_do_install
function sp_admin_bar_do_install()
{
global $spThisUser;
$oldOptions = sp_get_option('sfadminsettings');
$newOptions = sp_get_option('spAdminBar');
if (!isset($oldOptions['sfqueue']) && empty($newOptions)) {
$newOptions = array();
$newOptions['dashboardposts'] = false;
$newOptions['dbversion'] = SPABDBVERSION;
sp_add_option('spAdminBar', $newOptions);
$options = sp_get_member_item($spThisUser->ID, 'admin_options');
$options['sfadminbar'] = true;
sp_update_member_item($spThisUser->ID, 'admin_options', $options);
} else {
if (empty($newOptions)) {
$newOptions = array();
$newOptions['dashboardposts'] = $oldOptions['sfdashboardposts'];
$newOptions['dbversion'] = SPABDBVERSION;
sp_add_option('spAdminBar', $newOptions);
$options = sp_get_member_item($spThisUser->ID, 'admin_options');
$options['sfadminbar'] = true;
sp_update_member_item($spThisUser->ID, 'admin_options', $options);
unset($oldOptions['sfqueue']);
unset($oldOptions['sfmodasadmin']);
unset($oldOptions['sfshowmodposts']);
unset($oldOptions['sfbaronly']);
unset($oldOptions['sfdashboardposts']);
sp_update_option('sfadminsettings', $oldOptions);
}
}
# permission for bypassing akismet checks
sp_add_auth('bypass_akismet', __('Can bypass akismet check on posts', 'spab'), 1, 0, 0, 0, 3);
sp_activate_auth('bypass_akismet');
# create new Akismet setting
$akismet = sp_get_option('spAkismet');
if (empty($akismet)) {
sp_add_option('spAkismet', 1);
}
# get auto update running
$autoup = array('spabupdate', 'sp_ahah=admin-bar-update&target=newposts');
sp_add_sfmeta('autoupdate', 'admin', $autoup, 1);
}
示例4: sp_featured_do_process_actions
function sp_featured_do_process_actions()
{
global $spThisUser, $spGlobals;
# only admins and mods
if (!$spThisUser->admin && !$spThisUser->moderator) {
return;
}
if (isset($_POST['featuretopic']) && !empty($_POST['featuretopicaction'])) {
$topic = sp_esc_int($_POST['featuretopic']);
$featured = $spGlobals['featured']['topics'];
if ($_POST['featuretopicaction'] == 'add') {
$featured[] = $topic;
$featured = array_unique($featured);
} else {
$key = array_search($topic, $featured);
if ($key !== false) {
unset($featured[$key]);
}
}
sp_add_sfmeta('featured', 'topics', $featured, true);
$spGlobals['featured']['topics'] = $featured;
}
if (isset($_POST['featurepost']) && !empty($_POST['featurepostaction'])) {
$post = sp_esc_int($_POST['featurepost']);
$featured = $spGlobals['featured']['posts'];
if ($_POST['featurepostaction'] == 'add') {
$featured[] = $post;
$featured = array_unique($featured);
} else {
$key = array_search($post, $featured);
if ($key !== false) {
unset($featured[$key]);
}
}
sp_add_sfmeta('featured', 'posts', $featured, true);
$spGlobals['featured']['posts'] = $featured;
}
}
示例5: sp_create_usergroup_meta
function sp_create_usergroup_meta($members)
{
global $wp_roles;
$roles = array_keys($wp_roles->role_names);
if ($roles) {
foreach ($roles as $role) {
sp_add_sfmeta('default usergroup', $role, $members);
# initally set each role to members usergroup
}
}
}
示例6: sp_profile_delete_menu
function sp_profile_delete_menu($tab, $name)
{
# sanitize before use
$tab = sp_filter_title_save($tab);
$name = sp_filter_title_save($name);
# get the current tabs
$tabs = sp_profile_get_tabs();
if (empty($tabs)) {
return false;
}
# find the requested tab
foreach ($tabs as &$thisTab) {
if ($thisTab['name'] == $tab) {
# make sure the menu doesnt already exist on this tab
if ($thisTab['menus']) {
foreach ($thisTab['menus'] as $index => $menu) {
if ($menu['name'] == $name) {
unset($thisTab['menus'][$index]);
}
}
$thisTab['menus'] = array_values($thisTab['menus']);
}
}
}
# reorder tabs afer removal and save
$newtabs = serialize(array_values($tabs));
$result = sp_add_sfmeta('profile', 'tabs', $tabs);
return $result;
}
示例7: spa_save_usergroups_map_settings
function spa_save_usergroups_map_settings()
{
global $wp_roles;
check_admin_referer('forum-adminform_mapusers', 'forum-adminform_mapusers');
# save default usergroups
sp_add_sfmeta('default usergroup', 'sfguests', sp_esc_int($_POST['sfguestsgroup']));
# default usergroup for guests
sp_add_sfmeta('default usergroup', 'sfmembers', sp_esc_int($_POST['sfdefgroup']));
# default usergroup for members
# check for changes in wp role usergroup assignments
if (isset($_POST['sfrole'])) {
$roles = array_keys($wp_roles->role_names);
foreach ($_POST['sfrole'] as $index => $role) {
if ($_POST['sfoldrole'][$index] != $role) {
sp_add_sfmeta('default usergroup', $roles[$index], sp_esc_int($role));
}
}
}
$sfmemberopts = sp_get_option('sfmemberopts');
$sfmemberopts['sfsinglemembership'] = isset($_POST['sfsinglemembership']);
sp_update_option('sfmemberopts', $sfmemberopts);
$mess = spa_text('User mapping settings saved');
do_action('sph_option_map_settings_save');
return $mess;
}
示例8: sp_cron_check_news
function sp_cron_check_news()
{
$url = 'http://simple-press.com/downloads/simple-press/simple-press-news.xml';
$response = wp_remote_get($url, array('timeout' => 5));
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) {
return;
}
$body = wp_remote_retrieve_body($response);
if (!$body) {
return;
}
$newNews = new SimpleXMLElement($body);
if ($newNews) {
$data = sp_get_sfmeta('news', 'news');
$cur_id = !empty($data[0]['meta_value']) ? $data[0]['meta_value']['id'] : -999;
if ($newNews->news->id != $cur_id) {
$curNews = array();
$curNews['id'] = (string) $newNews->news->id;
$curNews['show'] = 1;
$curNews['news'] = addslashes_gpc((string) $newNews->news[0]->message);
sp_add_sfmeta('news', 'news', $curNews, 0);
}
}
}
示例9: sp_topic_sort_order
function sp_topic_sort_order()
{
global $spThisUser, $spGlobals;
$topicid = sp_esc_int($_GET['topicid']);
if (!$spThisUser->admin) {
sp_etext('Access denied - you do not have permission');
die;
}
# make sure we have valid forum
$thistopic = spdb_table(SFTOPICS, "topic_id={$topicid}", 'row');
$thisforum = spdb_table(SFFORUMS, "forum_id={$thistopic->forum_id}", 'row');
if (empty($thistopic)) {
die;
}
# if already reversed remove flag or reverse if not
$key = false;
if (isset($spGlobals['sort_order']['topic'])) {
$key = array_search($topicid, (array) $spGlobals['sort_order']['topic']);
}
if ($key === false) {
$spGlobals['sort_order']['topic'][] = $topicid;
} else {
unset($spGlobals['sort_order']['topic'][$key]);
$spGlobals['sort_order']['topic'] = array_keys($spGlobals['sort_order']['topic']);
}
sp_add_sfmeta('sort_order', 'topic', $spGlobals['sort_order']['topic'], 1);
sp_redirect(sp_build_url($thisforum->forum_slug, $thistopic->topic_slug, 1));
die;
}
示例10: sp_perform_install
//.........这里部分代码省略.........
$tables[] = SFUSERACTIVITY;
# sfusergroups table def
$sql = '
CREATE TABLE IF NOT EXISTS ' . SFUSERGROUPS . " (\n\t\t\t\t\tusergroup_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tusergroup_name text NOT NULL,\n\t\t\t\t\tusergroup_desc text default NULL,\n\t\t\t\t\tusergroup_badge varchar(50) default NULL,\n\t\t\t\t\tusergroup_join tinyint(4) unsigned NOT NULL default '0',\n\t\t\t\t\tusergroup_is_moderator tinyint(4) unsigned NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (usergroup_id)\n\t\t\t\t) " . spdb_charset();
spdb_query($sql);
$tables[] = SFUSERGROUPS;
# sfwaiting table def
$sql = '
CREATE TABLE IF NOT EXISTS ' . SFWAITING . " (\n\t\t\t\t\ttopic_id bigint(20) NOT NULL,\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tpost_count int(4) NOT NULL,\n\t\t\t\t\tpost_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tuser_id bigint(20) unsigned default '0',\n\t\t\t\t\tPRIMARY KEY\t (topic_id)\n\t\t\t\t) " . spdb_charset();
spdb_query($sql);
$tables[] = SFWAITING;
# now save off installed tables
sp_add_option('installed_tables', $tables);
echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
spa_etext('Tables created') . '</h5>';
break;
case 2:
# populate auths
spa_setup_auth_cats();
spa_setup_auths();
# set up the default permissions/roles
spa_setup_permissions();
echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
spa_etext('Permission data built') . '</h5>';
break;
case 3:
# Create default 'Guest' user group data
$guests = spa_create_usergroup_row('Guests', 'Default Usergroup for guests of the forum', '', '0', '0', false);
# Create default 'Members' user group data
$members = spa_create_usergroup_row('Members', 'Default Usergroup for registered users of the forum', '', '0', '0', false);
# Create default 'Moderators' user group data
$moderators = spa_create_usergroup_row('Moderators', 'Default Usergroup for moderators of the forum', '', '0', '1', false);
# Create default user groups
sp_add_sfmeta('default usergroup', 'sfguests', $guests);
# default usergroup for guests
sp_add_sfmeta('default usergroup', 'sfmembers', $members);
# default usergroup for members
sp_create_usergroup_meta($members);
# create default usergroups for existing wp roles
echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
spa_etext('Usergroup data built') . '</h5>';
break;
case 4:
$page_args = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => $current_user->ID, 'ping_status' => 'closed', 'comment_status' => 'closed', 'post_parent' => 0, 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'post_title' => 'Forum', 'page_template' => 'default');
$page_id = wp_insert_post($page_args);
$page = spdb_table(SFWPPOSTS, "ID={$page_id}", 'row');
sp_add_option('sfslug', $page->post_name);
# Update the guid for the new page
$guid = get_permalink($page_id);
spdb_query('UPDATE ' . SFWPPOSTS . " SET guid='{$guid}' WHERE ID={$page_id}");
sp_add_option('sfpage', $page_id);
echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
spa_etext('Forum page created') . '</h5>';
break;
case 5:
# Create Base Option Records (V1)
sp_add_option('sfuninstall', false);
sp_add_option('sfdates', get_option('date_format'));
sp_add_option('sftimes', get_option('time_format'));
sp_add_option('sfpermalink', get_permalink(sp_get_option('sfpage')));
sp_add_option('sflockdown', false);
$rankdata['posts'] = 2;
$rankdata['usergroup'] = 'none';
$rankdata['image'] = 'none';
sp_add_sfmeta('forum_rank', 'New Member', $rankdata, 1);
$rankdata['posts'] = 1000;
示例11: sp_update_forum_moderators
function sp_update_forum_moderators($forumid = '')
{
if (empty($forumid)) {
$forums = spdb_select('col', 'SELECT forum_id FROM ' . SFFORUMS, ARRAY_A);
} else {
$forums = (array) $forumid;
}
if (empty($forums)) {
return;
}
# udpate moderators list for each forum
$mods = array();
foreach ($forums as $forum) {
$sql = 'SELECT DISTINCT ' . SFMEMBERSHIPS . '.user_id, display_name
FROM ' . SFMEMBERSHIPS . '
JOIN ' . SFUSERGROUPS . ' ON ' . SFUSERGROUPS . '.usergroup_id = ' . SFMEMBERSHIPS . '.usergroup_id
JOIN ' . SFPERMISSIONS . ' ON ' . SFPERMISSIONS . ".forum_id = {$forum} AND " . SFMEMBERSHIPS . '.usergroup_id = ' . SFUSERGROUPS . '.usergroup_id
JOIN ' . SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFMEMBERSHIPS . '.user_id
WHERE usergroup_is_moderator=1';
$mods[$forum] = spdb_select('set', $sql, ARRAY_A);
}
sp_add_sfmeta('forum_moderators', 'users', $mods, 1);
}
示例12: table
if ($build < $section) {
# the cache table (5.4.2)
spdb_query('ALTER TABLE ' . SFFORUMS . ' ADD (topic_icon_locked varchar(50) default NULL)');
sp_response($section);
}
$section = 11061;
if ($build < $section) {
# create recent topic cache record
sp_add_option('topic_cache', 200);
$sql = 'SELECT DISTINCTROW forum_id, topic_id, post_id, post_status
FROM ' . SFPOSTS . '
ORDER BY post_id DESC
LIMIT 200';
$topics = spdb_select('set', $sql, ARRAY_N);
if ($topics) {
sp_add_sfmeta('topic_cache', 'new', $topics, true);
}
sp_response($section);
}
$section = 11071;
if ($build < $section) {
# add missing tables to installed list
$tables = sp_get_option('installed_tables');
if ($tables) {
if (!in_array(SFSPECIALRANKS, $tables)) {
$tables[] = SFSPECIALRANKS;
}
if (!in_array(SFUSERACTIVITY, $tables)) {
$tables[] = SFUSERACTIVITY;
}
if (!in_array(SFCACHE, $tables)) {
示例13: spa_save_css_data
function spa_save_css_data()
{
$css = '';
$curTheme = sp_get_option('sp_current_theme');
$css = esc_attr($_POST['spnewcontent']);
$css = sp_filter_save_nohtml($css);
if ($_POST['metaId'] == 0) {
sp_add_sfmeta('css', $curTheme['theme'], $css, true);
} else {
sp_update_sfmeta('css', $curTheme['theme'], $css, $_POST['metaId'], true);
}
$msg = spa_text('Custom theme CSS updated');
return $msg;
}
示例14: spa_save_messages_data
function spa_save_messages_data()
{
check_admin_referer('forum-adminform_messages', 'forum-adminform_messages');
# custom message for editor
$sfpostmsg = array();
$sfpostmsg['sfpostmsgtext'] = sp_filter_text_save(trim($_POST['sfpostmsgtext']));
$sfpostmsg['sfpostmsgtopic'] = isset($_POST['sfpostmsgtopic']);
$sfpostmsg['sfpostmsgpost'] = isset($_POST['sfpostmsgpost']);
sp_update_option('sfpostmsg', $sfpostmsg);
sp_update_option('sfeditormsg', sp_filter_text_save(trim($_POST['sfeditormsg'])));
# if set update, otherwise its empty, so remove
if ($_POST['sfsneakpeek'] != '') {
sp_add_sfmeta('sneakpeek', 'message', sp_filter_text_save(trim($_POST['sfsneakpeek'])));
} else {
$msg = sp_get_sfmeta('sneakpeek', 'message');
if (!empty($msg)) {
sp_delete_sfmeta($msg[0]['meta_id']);
}
}
$sflogin = array();
$sflogin = sp_get_option('sflogin');
$sflogin['sfsneakredirect'] = sp_filter_save_cleanurl($_POST['sfsneakredirect']);
sp_update_option('sflogin', $sflogin);
# if set update, otherwise its empty, so remove
if ($_POST['sfadminview'] != '') {
sp_add_sfmeta('adminview', 'message', sp_filter_text_save(trim($_POST['sfadminview'])));
} else {
$msg = sp_get_sfmeta('adminview', 'message');
if (!empty($msg)) {
sp_delete_sfmeta($msg[0]['meta_id']);
}
}
# if set update, otherwise its empty, so remove
if ($_POST['sfuserview'] != '') {
sp_add_sfmeta('userview', 'message', sp_filter_text_save(trim($_POST['sfuserview'])));
} else {
$msg = sp_get_sfmeta('userview', 'message');
if (!empty($msg)) {
sp_delete_sfmeta($msg[0]['meta_id']);
}
}
do_action('sph_component_messages_save');
$mess = spa_text('Custom messages updated');
return $mess;
}
示例15: sp_move_post
//.........这里部分代码省略.........
# start with creating the new topic
$newtopicslug = sp_create_slug($newtopicname, true, SFTOPICS, 'topic_slug');
# now create the topic and post records
$sql = 'INSERT INTO ' . SFTOPICS . "\n\t\t\t\t (topic_name, topic_slug, topic_date, forum_id, post_count, post_id, post_count_held, post_id_held)\n\t\t\t\t VALUES\n\t\t\t\t ('{$newtopicname}', '{$newtopicslug}', now(), {$newforumid}, 1, {$postid}, 1, {$postid});";
if (spdb_query($sql) == false) {
sp_notify(SPFAILURE, sp_text('Post move failed'));
return;
}
$newtopicid = $spVars['insertid'];
# check the topic slug and if empty use the topic id
if (empty($newtopicslug)) {
$newtopicslug = 'topic-' . $newtopicid;
$thistopic = spdb_query('UPDATE ' . SFTOPICS . " SET\n\t\t\t\t\t\t\t\t\t\ttopic_slug='{$newtopicslug}'\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id={$newtopicid}");
}
} else {
# it's a re-entry
$newtopicid = sp_esc_int($_POST['newtopicid']);
}
# Now determine the list of post ids to move
$posts = array();
switch ($action) {
case 'single':
$posts[] = $postid;
break;
case 'tostart':
$sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid} AND post_id <= {$postid}";
$posts = spdb_select('col', $sql);
break;
case 'toend':
$sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid} AND post_id >= {$postid}";
$posts = spdb_select('col', $sql);
break;
case 'select':
$idlist = sp_esc_str(trim($_POST['idlist'], ","));
if (empty($idlist)) {
$posts[] = $postid;
} else {
$where = "topic_id = {$oldtopicid} AND post_index IN ({$idlist})";
$sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid} AND post_index IN ({$idlist})";
$posts = spdb_select('col', $sql);
}
break;
}
if (empty($posts)) {
sp_notify(SPFAILURE, sp_text('Post move abandoned as no posts were selected'));
return;
}
# loop through and update post records and other housekeeping
foreach ($posts as $post) {
# update post record
$sql = 'UPDATE ' . SFPOSTS . " SET\n\t\t\t\t \ttopic_id={$newtopicid},\n\t\t\t\t \tforum_id={$newforumid},\n\t\t\t\t \tpost_status=0\n\t\t\t\t \tWHERE post_id={$post}";
spdb_query($sql);
# update post if in sfwaiting
spdb_query("UPDATE " . SFWAITING . " SET forum_id={$newforumid}, topic_id={$newtopicid} WHERE post_id={$post}");
# notify author of move
$thisPost = spdb_table(SFPOSTS, "post_id={$post}", 'row');
$sfadminsettings = sp_get_option('sfadminsettings');
if ($sfadminsettings['movenotice'] && $spThisUser->ID != $thisPost->user_id) {
$nData = array();
$nData['user_id'] = $thisPost->user_id;
$nData['guest_email'] = $thisPost->guest_email;
$nData['post_id'] = $post;
$nData['link'] = sp_permalink_from_postid($post);
$nData['link_text'] = spdb_table(SFTOPICS, "topic_id={$thisPost->topic_id}", 'topic_name');
$nData['message'] = sp_text('A post of yours was moved to');
$nData['expires'] = time() + 30 * 24 * 60 * 60;
# 30 days; 24 hours; 60 mins; 60secs
sp_add_notice($nData);
}
}
# flush and rebuild topic cache (since one or more posts approved)
sp_rebuild_topic_cache();
# rebuild indexing on target topic and forum
sp_build_post_index($newtopicid);
sp_build_forum_index($newforumid);
# determine if any posts left in old topic - just in case - delete or reindex
$sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid}";
$posts = spdb_select('col', $sql);
if (empty($posts)) {
spdb_query("DELETE FROM " . SFTOPICS . " WHERE topic_id=" . $oldtopicid);
} else {
sp_build_post_index($oldtopicid);
sp_build_forum_index($oldforumid);
}
do_action('sph_move_post', $oldtopicid, $newtopicid, $newforumid, $oldforumid, $postid, $spThisUser->ID);
sp_notify(SPSUCCESS, sp_text('Post moved'));
} elseif (isset($_POST['makepostmove2'])) {
# must be a move to an exisiting topic action
sp_add_sfmeta('post_move', 'post_move', $_POST, true);
}
if (isset($_POST['makepostmove3'])) {
# if a re-entry for move to exisiting - clear the sfmeta record
$meta = sp_get_sfmeta('post_move', 'post_move');
if ($meta) {
$id = $meta[0]['meta_id'];
sp_delete_sfmeta($id);
unset($spGlobals['post_move']);
}
}
}