Tuesday, September 22, 2009
InfoPath Code - Loop through items in a secondary data source from a SharePoint List
InfoPath - Update Repeating Elements in a Secondary Data Source
For example, when populating a CAML template with data from an InfoPath form so that it can be submitted to SharePoint, each field in the CAML template is a "field" element, which uses the value of the "name" attribute to determine which column/field in the SharePoint list to map to. The function (JScript or VBScript) in the linked article loops through each field element in the CAML XML data source until it finds the required field, by testing if the name attribute matches the name of the field/column to map data to. it then sets the value of the field element to the value of a field in the main data source of the InfoPath form.
Discussion relating to article include a solution to a scenario which required using the code provided in the article to loop through items in an InfoPath Form's secondary data source from a SharePoint list until the an item containing a specific value in the text column was found.
If found, the code was then re-used to populate the CAML template with data required to update the SharePoint list item. If the item was not found, a separate CAML template is populated with the data required to create a new SharePoint list item.
When the form is submitted, rules are configured with conditions to test if a new item is to be created in the SharePoint list, or updated if the item already exists. Two separate CAML templates are used here which required a separate data connection to submit the data to the SharePoint list using the Lists Web Service (updateListItem method) of the SharePoint site. Only one of the two submit data connections are executed to create or update a SharePoint list item as required.
See InfoPath Code - Loop Through Repeating Group in a Secondary Data Source for full details.
Related:
InfoPath - Update Existing SharePoint List Item Programmatically Using CAML
This article demonstrates how to set up data connections in an InfoPath form to Update an existing item in a SharePoint list using CAML and the Lists Web Service of the SharePoint Site.
InfoPath: Transfer Data Between 2 Forms
This article emplains how to transfer data from one InfoPath form to another, by loading the XML Document of the Second form and populating the required fields in the main data source of the form. JScript is used to transfer the data. Code examples are provided.
Friday, September 4, 2009
Fix Corrupt Table in PhpBB3 MySQL Database - Grant Administrator/Founder using PhpMyAdmin
- How to fix corrupt table in PhpBB3 Database using PhpMyAdmin (phpbb_users table corrupt in PhpBB3 forum).
- How to add a forum administrator/founder using PhpMyAdmin.
Can't open file: 'phpbb_users.MYI'. (errno: 145) [1016]
damage to the database will also determine the chance of PhpMyAdmin or similar being able to repair the table without affecting the overall functionality of the application or database. In some cases, you won't be able to repair the damaged table, and as a result will be required to retore the entire database from a working backup in order to have the forums functioning again.
If possible, export as much of the database as possible (all tables except the corrupted) prior to performing any repairs on the database, as there is a high chance that you will loose some data
which may affect the PhpBB3 functionality in various ways. If successful, any entries which may
have been removed during the repair can then be added back into the table from a previous (non corrupt) backup.
I can't stress how important it is to make and keep regular backups of the database and website, as cases like this one put you at risk of losing all, or a large amount of data from the database if no recent backups are available after a serious/major problem.
1. Repair the Corrupt Table using PhpMyAdmin
Using PhpMyAdmin, determine which tables have become corrupt by displaying all tables in the database. The corrupt databases in this case are "in use", produce an error if trying to display any records from the table. I was able to repair the corrupt table by selecting the table and choosing "Repair Table" from the drop-down menu after the list of tables.
Once repaired, the database and forum was functioning again, but to repair the table a row was removed from the table by PhpMyAdmin, which happened to be the administrator/founder account. This didn't stop the forums from functioning, but I was not able to log into the Administration control panel to manage and administer the forums.
2. Create New Account to become a Forum Founder/Administrator
In this case, the administrator/founder account was recreated as PhpMyAdmin had removed the entry from the phpbb_users table when repairing the corrupt database table, freeing up the username used by the administrator/founder of the forums. Usually, both accounts exist when logging on as the administrator, so a new forum account would not need to be created. As the "administrator" account had been recreated, all founder permissions were lost and the user was now a standard "registered user".
3. Set the Founder/Administrator Permissions: Modify the phpbb_users table
4. Purge the Cache
After updating the user's type, I manually purged the cache by removing all files in the "cache/" directory except for .htaccess and index.html. Warning: This may remove HTML or CSS customisations made to templates if done via the Administration Control Panel, as a fresh copy of all required template files will be copied from the template directory of the selected style/theme when required.
Once founder/administrator permissions were granted again on the new administrator account, I was able to login to the Administration Control Panel to manage the board/forum.
When attempting to view the user profile of the original administrator account which was used to post a thread or reply on the forums, a "The requested user does not exist" message is displayed as the original administrator account no longer exists. As the founder/administrator is now a new user, all posts created using the original administrator account need to be set as posts on the new administrator account.
5. Relink the Author Link on Posts to Point to the New Profile
- Get the user_id of the original administrator/founder account and the new account (with the same username) by obtaining the value of query string paramater "u" of the address/url to the user profile. Example: /memberlist.php?mode=viewprofile&u=21&sid=...
- Using PhpMyAdmin or similar, edit the entry in the users table where the "user_id" is equal to the user_id of the new administrator account.
- Set the user_id field to the user_id of the original administrator/founder account which no longer exists.
- Make sure the user_type value for the account is set to 3 (global administrator/founder). Apply the changes.
- Set the user_group value to 5 to add the user to the administrators group.
Warning: Changing "user_type" and "user_group" values affects users permissions across the forum. Configuring incorrectly may result in the wrong account being granted founder permissions on the forum which would result in the user having access to everything (including the Administration control Panel of the forum). If permissions are granted to forums via groups, changing the group_id for a user by editing database records may also result in the user being granted elevated permissions or the account becoming inactive. You should always maintain forum permissions and users via the forums Administration Control Panel where possible. When the Administration Control panel is not accessible for the above or any other reason, records/entries in the database can be modified directly, but extreme caution must be taken to avoid applying incorrect changes to user data, or changes which may result in the user's account not functioning at all.
Summary
The phpbb_users table of the database used by the PhpBB3 forums had become corrupt for an unknown reason. Repairing the table in the database using PhpMyAdmin resulted in the record for the forum Administrator/Founder being removed. A new account was created, and modified using PhpMyAdmin to be granted the required administrator/founder permissions. The user_id was then set to match the id of the previous forum administrator account (same username).
The Phpbb3 Forums are now functioning fully again, including the forum founder/administrator account for access to the Administration Control Panel to manage the forums. I have also increased the frequency of incremental database and web server backups to help avoid this in future.
Saturday, August 8, 2009
InfoPath - Programming Tips - InfoPath Form Devlopment
There is no simple answer to this question, as it comes down to a matter of personal preference. This article is aimed at reducing the development time for InfoPath forms of various scales. The following are some tips to help you make the right decision.
Firstly, I should note that InfoPath is a great tool for creating electronic forms, as many features are provided to including data connections to external sources (Database, SharePoint, etc.), data validation and conditional formatting which allow complex forms to be created and submitted without using any code.
I my opinion, as an InfoPath form becomes more complex the efficiency of the form's development is reduced when avoiding using code. This is due to the amount of mouse clicking required to set default values, create rules and apply formatting conditions to individual elements in a data source, or controls on the form template. If code is not a strength and you don't mind a bit of clicking, then this probably isn't a bad way to go as it does have a major benefit which is often overlooked: The Logic Inspector. If all, or most form functionality can be created without using code, the Logic Inspector will reflect the amount of detail put into the form's design as well as giving an overview of any functions if code is used. It allows you to see at a glance, as well as print details of any validation, field calculations, rules or programming used across the entire form.
Code is Reusable
InfoPath form code can be written to allow reuse in multiple forms which may have completely different requirements for functionality and layout. Developing to enable code reuse will prove to be a significant benefit to any developer. Having access to code that you know that works as well as an intimate understanding of how it works will save a many hours of development, as well as providing building blocks for further development.
It will take longer during the initial stages to develop forms using code, but as you gain experience and start build a "bank" of reusable code, development time will significantly decrease.
If developing a set of forms, starting from a common template with the layout and theme already applied to the form can also reduce development time as well as enhance the professional appearance of the set of forms.
Choose an appropriate language to become most familure with
Many languages are supported when using InfoPath forms (JScript, VBScript, C#, VB), sometimes making it harder to find relevant information or resources when troubleshooting and learning. Some languages are more powerful than others in the functionality offered, or the ease of coding. You should try to use the same code language between different forms which are developed as it allows for code reuse and a steeper learning curve. C# is the most recent and provides the greatest set of core functionality followed by VB. VBScript and JScript offer less, but are very common and easy to code in terms of syntax strictness.
No need to over do it!
After saying all this, I should stress a few key points:
- If a form is simple code may not be required. If a form doesn't require complex validation, formatting and rules, as well as not having a large number of fields in the main data source it should be quicker to set up using the tools provided by InfoPath.
- It does take time to learn how to use code to enhance form functionality and reduce development time for complex forms. Don't dive straight in the deep end; break up what you are trying to do, then learn and implement individual components as required. Develop individual components in a separate form which can be saved in a separate location easily for use in future form development.
- Reuse Code and Form layout. Write code in ways that make it reusable. Create snippets and forms containing individual functions, or a set of related functionality to start building up a "bank" of resources. Reuse a previous form's layout as a starting point for aesthetics when developing a form set, or forms which incorporare company branding.
InfoPath Performance for SharePoint Data Connections
- See this and other InfoPath articles on my SharePoint Blog: InfoPath Posts, InfoPath - When to use code in InfoPath forms
Thursday, August 6, 2009
Php XML-RPC Bulk Ping Sites and Directories - FREE SEO
WebmasterHub.net - FREE SEO - Submit to Directories
Only recently launched, WebmasterHub.net provide FREE SEO including a bulk ping service to submit sites, blogs and/or RSS feeds. The bulk ping service uses XML-RPC and the weblogUpdates.ping, or weblogUpdates.extendedPing method if available. The service currently pings around 50 popular directories, but is still evolving.
See my blog post XML-RPC Blog Ping for more details of the development the bulk ping service using Php and MySQL. The free service is written in Php, and utilises the Weblog_Pinger class, which has been developed to ignore ping requests if the server has already been pinged recently (5 minutes) to help avoid being banned from submitting to a particular site or directory. Additional functionality developed includes storing and retrieving XML- RPC server and site/blog details from a database, allowing the system to evolve as well as making it easy to update or add new servers blogs and sites.
A list of the XML-RPC servers being pinged using the WebmasterHub.net bulk pinger will be published on the website soon. To suggest a new server, please send details of the server (web address and port if non- standard) using the feedback form on the site (see below for link). I will try to have any new server suggestions added within a day or two.
The service is hosted for free at WebmasterHub.net to members. Registration is quick, easy and FREE, an email address, login and password is all that's required. Please feel free to comment by providing feedback on the site ( http://www.webmasterhub.net/contact.php ), or by emailing support at support@webmasterhub.net .
WebmasterHub.net also provide a resource directory for webmasters, web developers and designers which cover many areas relating to web development (including SharePoint and InfoPath). Members can add new resources and sites to the directory, which will be listed instantly. Content is reviewed and removed if deemed inappropriate. Users can also submit a content breach report if desired. The WebmasterHub.net community forum for members is currently being set up, which will be available soon.
As WebmasterHub.net is a new website, the free SEO services and webmaster resource directory are a work in progress. Please take the time to register, submit a resource and/or provide feedback as member contribution is vital during these early stages. Award programs are currently being set up for regular resource directory and forum contributers.
-----------------------------------------------
http://www.webmasterhub.net/ - WebmasterHub.net :: Webmasters Developers Designers
- Register for FREE Now http://www.webmasterhub.net/register.php FREE SEO - Submit your site to directories for free.
- Free SEO - Submit to 100 + popular directories for free - WebmasterHub.net.
- Webmaster & Developer Resources - Browse the WebmasterHub.net resource directory for webmasters, web developers and designers.
WebmasterHub.net Resource Directory:
- Documentation and APIs
- Domain Name Services - DNS Hosting, Dynaic DNS, Domain Name Search
- E-Commerce - Ad/Affiliate Programs, Online Payment methods, SSL Certificates, E-Commerce Security
- HTML / CSS - Menu Generators, Tools, tips and tricks
- Multimedia - Stock photography, Button, Logo, Background/texture Generators, Media Libraries, PhotoShop
- Open Source - Development Communities, Php Applications, Blog, Chat, Forum Applications
- Programming and Scripting - Tips, tutorials and code samples for a range of pupular languages
- Programming Tools - Code generators, Developer tools (Text editors), Debugging, Compilers, Source Code Libraries
- Security - firewalls, Credential Managers, Anrivirus, Secure File Removal, Encryption, Spyware/Adware management
- SharePoint - InfoPath Forms, Web Parts, Tutorials, Tips and How Tos, Administrative Tools/Utilities, Workflow
- Software - FTP Clients, SSH / Telnet Clients, Version Control, Sitemap / Meta Tag Generators
- Tutorials - SharePoint, Programming and Scripting, PhotoShop, Flash, HTML/CSS, JavaScript/JScript, CGI
- Web Hosting Services - Web Hosting, Email Hosting
- Webmaster Tools - IP Address and Host Name lookups, Website Statics and Analysis
- Website Promotion - Blog/Site/RSS submission Software and Services, Keyword research Tools, Search Engine Ranking Checks/Simulators, Meta tag Generators, SEO Information and Tips
- Website Templates - HTML/CSS, Flash, Business/Corporate, Blog Templates
Saturday, August 1, 2009
SEO Tips for Beginners
SEO (Search Engine Optimisation) Tips and Tools
Saturday, July 4, 2009
WebmasterHub.net - Webmasters Developmers and Designers

WebmasterHub.net is live!! WebmasterHub.net offers a directory of resources, tools and tutorials for webmasters, web developers and designers.
Register for free to receive free Search Engine Optimisation (SEO) including access to submit a site or resource to the resource directory and the Webmasterhub.net Bulk Pinger to bulk submit your site or blog to many popular sites and directories.
Tuesday, June 2, 2009
Php: Manage session times using code - Expiration / Timeout script
The following article demonstrates how to take control of php session times by including a php script into pages on your site.
This can be useful if you don't have access to the php installation and the php.ini configuration file, as it gives you the flexibility to choose the length of php sessions on your site without requiring access to the server or config.
Usage:
When a user is successfully logged into your site, store the time that the user logged in into a session variable $_SESSION['last_use'].
The following php script session_timer.php needs to be included on all pages of the site, or at least all pages that require the user to be logged in. The session_start() function is included at the top the session_timer.php script. This means that it is not required at the top of any page which includes session_timer.php.
|
Each time the user requests a page on the site, the current time is checked against the last use time ($_SESSION['last_use']). If over 600 seconds (10 minutes) have passed, the session is destroyed and the page reloaded (in case it is cached). If less than 10 minutes have passed, the last use session variable is reset to the current time to keep the sssion going.
