当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::dbinsert方法代码示例

本文整理汇总了PHP中Item::dbinsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::dbinsert方法的具体用法?PHP Item::dbinsert怎么用?PHP Item::dbinsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Item的用法示例。


在下文中一共展示了Item::dbinsert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Link

 } else {
     // Use default category ID if it was not selected on the form
     $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
 }
 $title = $l_File->get('title');
 if (empty($title)) {
     $title = $l_File->get('name');
 }
 $edited_Item->set('title', $title);
 // replacing category if selected at preview screen
 if (isset($title_Array[$fileNum])) {
     $edited_Item->set('title', $title_Array[$fileNum]);
 }
 $DB->begin('SERIALIZABLE');
 // INSERT NEW POST INTO DB:
 if ($edited_Item->dbinsert()) {
     // echo '<br>file meta: '.$l_File->meta;
     if ($l_File->meta == 'notfound') {
         // That file has no meta data yet, create it now!
         $l_File->dbsave();
     }
     // Let's make the link!
     $edited_Link = new Link();
     $edited_Link->set('itm_ID', $edited_Item->ID);
     $edited_Link->set('file_ID', $l_File->ID);
     $edited_Link->set('position', 'teaser');
     $edited_Link->set('order', 1);
     $edited_Link->dbinsert();
     $DB->commit();
     $Messages->add(sprintf(T_('&laquo;%s&raquo; has been posted.'), $l_File->dget('name')), 'success');
     $fileNum++;
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:items.ctrl.php

示例2: xmlrpcs_new_item


//.........这里部分代码省略.........
        // Main category does not exist:
        return xmlrpcs_resperror(11);
        // User error 11
    }
    // Check if category exists and can be used
    if (!xmlrpcs_check_cats($params['main_cat_ID'], $Blog, $params['extra_cat_IDs'])) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    /*
     * CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs)
     * NOTE: extra_cat_IDs array now includes main_cat_ID too, so we are actually checking ALL categories below
     */
    if (!$current_User->check_perm('cats_post!' . $params['status'], 'edit', false, $params['extra_cat_IDs'])) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    if (!empty($params['item_typ_ID'])) {
        if (!preg_match('~^[0-9]+$~', $params['item_typ_ID'])) {
            // Only accept numeric values, switch to default value
            $params['item_typ_ID'] = 1;
        }
        foreach ($posttypes_perms as $l_permname => $l_posttypes) {
            // "Reverse" the $posttypes_perms array:
            foreach ($l_posttypes as $ll_posttype) {
                $posttype2perm[$ll_posttype] = $l_permname;
            }
        }
        if (isset($posttype2perm[$params['item_typ_ID']])) {
            // Check permission for this post type
            if (!$current_User->check_perm('cats_' . $posttype2perm[$params['item_typ_ID']], 'edit', false, $params['extra_cat_IDs'])) {
                // Permission denied
                return xmlrpcs_resperror(3);
                // User error 3
            }
        }
    }
    logIO('Post type: ' . $params['item_typ_ID']);
    logIO('Permission granted.');
    // CHECK HTML SANITY:
    if (($params['title'] = check_html_sanity($params['title'], 'xmlrpc_posting')) === false) {
        return xmlrpcs_resperror(21, $Messages->get_string('Invalid post title, please correct these errors:', ''));
    }
    if (($params['content'] = check_html_sanity($params['content'], 'xmlrpc_posting')) === false) {
        return xmlrpcs_resperror(22, $Messages->get_string('Invalid post contents, please correct these errors:' . "\n", '', "  //  \n", 'xmlrpc'));
    }
    if (empty($params['date'])) {
        $params['date'] = date('Y-m-d H:i:s', time() + $Settings->get('time_difference'));
    }
    // INSERT NEW POST INTO DB:
    load_class('items/model/_item.class.php', 'Item');
    $edited_Item = new Item();
    $edited_Item->set('title', $params['title']);
    $edited_Item->set('content', $params['content']);
    $edited_Item->set('issue_date', $params['date']);
    $edited_Item->set('main_cat_ID', $params['main_cat_ID']);
    $edited_Item->set('extra_cat_IDs', $params['extra_cat_IDs']);
    $edited_Item->set('status', $params['status']);
    $edited_Item->set('ptyp_ID', $params['item_typ_ID']);
    $edited_Item->set('featured', $params['featured']);
    $edited_Item->set_tags_from_string($params['tags']);
    $edited_Item->set('locale', $current_User->locale);
    $edited_Item->set_creator_User($current_User);
    if ($params['excerpt'] != '') {
        $edited_Item->set('excerpt', $params['excerpt']);
    }
    if ($params['urltitle'] != '') {
        $edited_Item->set('urltitle', $params['urltitle']);
    }
    if ($params['parent_ID'] != '') {
        $edited_Item->set('parent_ID', $params['parent_ID']);
    }
    if (!empty($params['order'])) {
        $edited_Item->set('order', $params['order']);
    }
    // Do not set if order is 0
    if ($Blog->get_setting('allow_comments') != 'never' && $Blog->get_setting('disable_comments_bypost')) {
        // Comment status
        $edited_Item->set('comment_status', $params['comment_status']);
    }
    $edited_Item->dbinsert('through_xmlrpc');
    if (empty($edited_Item->ID)) {
        return xmlrpcs_resperror(99, 'Error while inserting item: ' . $DB->last_error);
    }
    logIO('Posted with ID: ' . $edited_Item->ID);
    if (!empty($params['custom_fields']) && is_array($params['custom_fields']) && count($params['custom_fields']) > 0) {
        // TODO sam2kb> Add custom fields
        foreach ($params['custom_fields'] as $field) {
            // id, key, value
            logIO('Custom field: ' . var_export($field, true));
        }
    }
    // Execute or schedule notifications & pings:
    logIO('Handling notifications...');
    $edited_Item->handle_post_processing(true);
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($edited_Item->ID));
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_xmlrpcs.funcs.php

示例3: wpxml_import


//.........这里部分代码省略.........
                $old_tags_other_blogs_sql = !empty($old_tags_other_blogs) ? ' AND tag_ID NOT IN ( ' . implode(', ', $old_tags_other_blogs) . ' )' : '';
                // Remove the tags that are no longer used
                $DB->query('DELETE FROM T_items__tag
					WHERE tag_ID IN ( ' . implode(', ', $old_tags_this_blog) . ' )' . $old_tags_other_blogs_sql);
            }
            // Remove the links of tags with posts
            $DB->query('DELETE FROM T_items__itemtag WHERE itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
        }
        echo T_('OK') . '<br /><br />';
    }
    /* Import authors */
    $authors = array();
    $authors_IDs = array();
    if (isset($xml_data['authors']) && count($xml_data['authors']) > 0) {
        global $Settings, $UserSettings;
        echo T_('Importing the users... ');
        evo_flush();
        // Get existing users
        $SQL = new SQL();
        $SQL->SELECT('user_login, user_ID');
        $SQL->FROM('T_users');
        $existing_users = $DB->get_assoc($SQL->get());
        $authors_count = 0;
        foreach ($xml_data['authors'] as $author) {
            if (empty($existing_users[(string) $author['author_login']])) {
                // Insert new user into DB if User doesn't exist with current login name
                $GroupCache =& get_GroupCache();
                if (!empty($author['author_group'])) {
                    // Set user group from xml data
                    if (($UserGroup =& $GroupCache->get_by_name($author['author_group'], false)) === false) {
                        // If user's group doesn't exist yet, we should create new
                        $UserGroup = new Group();
                        $UserGroup->set('name', $author['author_group']);
                        $UserGroup->dbinsert();
                    }
                } else {
                    // Set default user group is it is not defined in xml
                    if (($UserGroup =& $GroupCache->get_by_name('Normal Users', false)) === false) {
                        // Exit from import of users, because we cannot set default user group
                        break;
                    }
                }
                unset($author_created_from_country);
                if (!empty($author['author_created_from_country'])) {
                    // Get country ID from DB by code
                    $CountryCache =& get_CountryCache();
                    if (($Country =& $CountryCache->get_by_name($author['author_created_from_country'], false)) !== false) {
                        $author_created_from_country = $Country->ID;
                    }
                }
                // Get regional IDs by their names
                $author_regions = wp_get_regional_data($author['author_country'], $author['author_region'], $author['author_subregion'], $author['author_city']);
                $User = new User();
                $User->set('login', $author['author_login']);
                $User->set('email', $author['author_email']);
                $User->set('firstname', $author['author_first_name']);
                $User->set('lastname', $author['author_last_name']);
                $User->set('pass', $author['author_pass']);
                $User->set_Group($UserGroup);
                $User->set('status', !empty($author['author_status']) ? $author['author_status'] : 'autoactivated');
                $User->set('nickname', $author['author_nickname']);
                $User->set('url', $author['author_url']);
                $User->set('level', $author['author_level']);
                $User->set('locale', $author['author_locale']);
                $User->set('gender', $author['author_gender'] == 'female' ? 'F' : ($author['author_gender'] == 'male' ? 'M' : ''));
                if ($author['author_age_min'] > 0) {
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:67,代码来源:_wp.funcs.php

示例4: pbm_process_messages


//.........这里部分代码省略.........
                    if ($hasRelated) {
                        pbm_process_attachments($content, $parsedMIME['Related'], $mediadir, $pbmBlog->get_media_url(), true, 'related');
                    }
                } else {
                    pbm_msg(T_('Unable to access media directory. No attachments processed.'), true);
                }
            } else {
                pbm_msg(T_('Files module is disabled or missing!'), true);
            }
        }
        // CHECK and FORMAT content
        global $Plugins;
        $renderer_params = array('Blog' => &$pbmBlog, 'setting_name' => 'coll_apply_rendering');
        $renderers = $Plugins->validate_renderer_list($Settings->get('eblog_renderers'), $renderer_params);
        pbm_msg('Applying the following text renderers: ' . implode(', ', $renderers));
        // Do some optional filtering on the content
        // Typically stuff that will help the content to validate
        // Useful for code display
        // Will probably be used for validation also
        $Plugins_admin =& get_Plugins_admin();
        $params = array('object_type' => 'Item', 'object_Blog' => &$pbmBlog);
        $Plugins_admin->filter_contents($post_title, $content, $renderers, $params);
        pbm_msg('Filtered post content: <pre style="font-size:10px">' . htmlspecialchars($content) . '</pre>');
        $context = $Settings->get('eblog_html_tag_limit') ? 'commenting' : 'posting';
        $post_title = check_html_sanity($post_title, $context, $pbmUser);
        $content = check_html_sanity($content, $context, $pbmUser);
        global $Messages;
        if ($Messages->has_errors()) {
            // Make it easier for user to find and correct the errors
            pbm_msg("\n" . sprintf(T_('Processing message: %s'), $post_title), true);
            pbm_msg($Messages->get_string(T_('Cannot post, please correct these errors:'), 'error'), true);
            $Messages->clear();
            rmdir_r($tmpDirMIME);
            continue;
        }
        if ($test_mode_on) {
            // Test mode
            pbm_msg('<b class="green">It looks like the post can be successfully saved in the database. However we will not do it in test mode.</b>');
        } else {
            load_class('items/model/_item.class.php', 'Item');
            global $pbm_items, $DB, $localtimenow;
            $post_status = 'published';
            pbm_msg(sprintf('<h4>Saving item "%s" in the database</h4>', $post_title));
            // INSERT NEW POST INTO DB:
            $edited_Item = new Item();
            $edited_Item->set_creator_User($pbmUser);
            $edited_Item->set($edited_Item->lasteditor_field, $pbmUser->ID);
            $edited_Item->set('title', $post_title);
            $edited_Item->set('content', $content);
            $edited_Item->set('datestart', $post_date);
            $edited_Item->set('datemodified', date('Y-m-d H:i:s', $localtimenow));
            $edited_Item->set('main_cat_ID', $main_cat_ID);
            $edited_Item->set('extra_cat_IDs', $extra_cat_IDs);
            $edited_Item->set('status', $post_status);
            $edited_Item->set('locale', $pbmUser->locale);
            $edited_Item->set('renderers', $renderers);
            // INSERT INTO DB:
            $edited_Item->dbinsert('through_email');
            pbm_msg(sprintf('Item created?: ' . (isset($edited_Item->ID) ? 'yes' : 'no')));
            // Execute or schedule notifications & pings:
            $edited_Item->handle_post_processing(true);
            if (!empty($pbm_item_files)) {
                // Attach files
                $FileCache =& get_FileCache();
                $order = 1;
                foreach ($pbm_item_files as $filename) {
                    pbm_msg(sprintf('Saving file "%s" in the database', $filename));
                    $pbmFile =& $FileCache->get_by_root_and_path('collection', $pbmBlog->ID, $filename);
                    $pbmFile->meta = 'notfound';
                    // Save time and don't try to load meta from DB, it's not there anyway
                    $pbmFile->dbsave();
                    pbm_msg(sprintf('File saved?: ' . (isset($pbmFile->ID) ? 'yes' : 'no')));
                    pbm_msg(sprintf('Attaching file "%s" to the post', $filename));
                    // Let's make the link!
                    $pbmLink = new Link();
                    $pbmLink->set('itm_ID', $edited_Item->ID);
                    $pbmLink->set('file_ID', $pbmFile->ID);
                    $pbmLink->set('position', 'aftermore');
                    $pbmLink->set('order', $order++);
                    $pbmLink->dbinsert();
                    pbm_msg(sprintf('File attached?: ' . (isset($pbmLink->ID) ? 'yes' : 'no')));
                }
            }
            // Save posted items sorted by author user for reports
            $pbm_items['user_' . $pbmUser->ID][] = $edited_Item;
            ++$post_cntr;
        }
        pbm_msg('Message posting successful');
        // Delete temporary directory
        rmdir_r($tmpDirMIME);
        if (!$test_mode_on && $Settings->get('eblog_delete_emails')) {
            pbm_msg('Marking message for deletion from inbox: ' . $index);
            imap_delete($mbox, $index);
            ++$del_cntr;
        }
    }
    // Expunge messages marked for deletion
    imap_expunge($mbox);
    return true;
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_post_by_mail.funcs.php

示例5: Item

      */
     attach_browse_tabs(false);
     $AdminUI->set_path('collections', 'comments');
     $AdminUI->breadcrumbpath_add(T_('Comment recycle bins'), '?ctrl=comments&amp;action=emptytrash');
     break;
 case 'elevate':
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('comment');
     $item_content = $edited_Comment->get_author_name() . ' ' . T_('wrote') . ': <blockquote>' . $edited_Comment->get_content() . '</blockquote>';
     $new_Item = new Item();
     $new_Item->set('status', 'draft');
     $new_Item->set_creator_by_login($current_User->login);
     $new_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
     $new_Item->set('title', T_('Elevated from comment'));
     $new_Item->set('content', $item_content);
     if (!$new_Item->dbinsert()) {
         $Messages->add(T_('Unable to create the new post!'), 'error');
         break;
     }
     // Deprecate the comment after elevating
     $edited_Comment->set('status', 'deprecated');
     $edited_Comment->dbupdate();
     // Move all child comments to new created post
     move_child_comments_to_item($edited_Comment->ID, $new_Item->ID);
     header_redirect(url_add_param($admin_url, 'ctrl=items&blog=' . $blog . '&action=edit&p=' . $new_Item->ID, '&'));
     break;
 case 'list':
 case 'mass_delete':
     /*
      * Latest comments:
      */
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:_comments.ctrl.php

示例6: Item

     debug_dump($post_author, 'post_author');
     debug_dump(isset($item_Author->ID) ? $item_Author->ID : 'NULL (simulating)', 'item_Author->ID');
     if (!$simulate) {
         $edited_Item = new Item();
         $edited_Item->set_creator_User($item_Author);
         $edited_Item->set('title', $post_title);
         $edited_Item->set('content', $post_content);
         $edited_Item->set('datestart', $post_date);
         $edited_Item->set('main_cat_ID', $post_category);
         $edited_Item->set('extra_cat_IDs', $post_catids);
         $edited_Item->set('status', $post_status);
         $edited_Item->set('locale', $post_locale);
         $edited_Item->set('notifications_status', 'finished');
         $edited_Item->set('comment_status', $comment_status);
         $edited_Item->set_renderers($post_renderers);
         $edited_Item->dbinsert();
         $post_ID = $edited_Item->ID;
     }
     $message .= '<li><span style="color:green">Imported successfully</span><ul><li>main category: <span style="color:#09c">' . get_catname($post_category) . '</span></li>';
     if (count($post_catids)) {
         $message .= '<li>extra categories: <span style="color:#09c">' . preg_replace('/(\\d+)/e', "get_catname('\\1')", implode(', ', $post_catids)) . '</span></li>';
     }
     $message .= '</ul></li>';
     $count_postscreated++;
 }
 echo $message . '</ul>';
 if (count($comments)) {
     // comments
     $message = '';
     $comments = explode("-----\nCOMMENT:", $comments[0]);
     foreach ($comments as $comment) {
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:mtimport.ctrl.php

示例7: wpxml_import


//.........这里部分代码省略.........
                    // Clear cache to save memory
                    $FileCache->clear();
                }
                // Start new transaction for the data inserting
                $DB->begin();
            }
            echo T_('OK') . '<br />';
        }
        echo '<br />';
    }
    /* Import authors */
    $authors = array();
    $authors_IDs = array();
    if (isset($xml_data['authors']) && count($xml_data['authors']) > 0) {
        global $Settings, $UserSettings;
        echo T_('Importing the users... ');
        evo_flush();
        // Get existing users
        $SQL = new SQL();
        $SQL->SELECT('user_login, user_ID');
        $SQL->FROM('T_users');
        $existing_users = $DB->get_assoc($SQL->get());
        $authors_count = 0;
        foreach ($xml_data['authors'] as $author) {
            if (empty($existing_users[(string) $author['author_login']])) {
                // Insert new user into DB if User doesn't exist with current login name
                $GroupCache =& get_GroupCache();
                if (!empty($author['author_group'])) {
                    // Set user group from xml data
                    if (($UserGroup =& $GroupCache->get_by_name($author['author_group'], false)) === false) {
                        // If user's group doesn't exist yet, we should create new
                        $UserGroup = new Group();
                        $UserGroup->set('name', $author['author_group']);
                        $UserGroup->dbinsert();
                    }
                } else {
                    // Set default user group is it is not defined in xml
                    if (($UserGroup =& $GroupCache->get_by_name('Normal Users', false)) === false) {
                        // Exit from import of users, because we cannot set default user group
                        break;
                    }
                }
                unset($author_created_from_country);
                if (!empty($author['author_created_from_country'])) {
                    // Get country ID from DB by code
                    $CountryCache =& get_CountryCache();
                    if (($Country =& $CountryCache->get_by_name($author['author_created_from_country'], false)) !== false) {
                        $author_created_from_country = $Country->ID;
                    }
                }
                // Get regional IDs by their names
                $author_regions = wp_get_regional_data($author['author_country'], $author['author_region'], $author['author_subregion'], $author['author_city']);
                $User = new User();
                $User->set('login', $author['author_login']);
                $User->set('email', $author['author_email']);
                $User->set('firstname', $author['author_first_name']);
                $User->set('lastname', $author['author_last_name']);
                $User->set('pass', $author['author_pass']);
                $User->set_Group($UserGroup);
                $User->set('status', !empty($author['author_status']) ? $author['author_status'] : 'autoactivated');
                $User->set('nickname', $author['author_nickname']);
                $User->set('url', $author['author_url']);
                $User->set('level', $author['author_level']);
                $User->set('locale', $author['author_locale']);
                $User->set('gender', $author['author_gender'] == 'female' ? 'F' : ($author['author_gender'] == 'male' ? 'M' : ''));
                if ($author['author_age_min'] > 0) {
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:67,代码来源:_wp.funcs.php


注:本文中的Item::dbinsert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。