This tutorial studies the design and implementation of "Tom Friend" application
<?php
/*
* Application: Tom Friend
* Author: SocialEngineMods
*
*
*/
class app_tomfriend extends semods_myapp {
// this function is called to handle the hook
function handlehook($hook_name) {
switch($hook_name) {
case "se_signup_success":
{
// This is the list of users to befriend as a comma separated string, set using admin interface.
$befriend_users = $this->app->get_global_setting('befriend','');
if($befriend_users == '')
return;
// iterate over all "tom friend" users and befriend them with current user (newly signup up)
$befriend_users = explode(',',$befriend_users);
foreach($befriend_users as $befriend_user) {
$tom_user = new se_user( array( $befriend_user ) );
if($tom_user->user_exists) {
// make a mutual friend connection between "tom friend" and the current user (viewer)
$this->viewer->user_friend_add($tom_user->user_info['user_id'], 1, '', '');
$tom_user->user_friend_add($this->viewer->user_info['user_id'], 1, '', '');
}
}
}
break;
}
}
}
?>
<?xml version="1.0" encoding="UTF-8"?>
<application>
<version>1.00</version>
<title>Tom Friend</title>
<author>SocialEngineMods</author>
<author>
<name>SocialEngineMods</name>
<email>info@socialenginemods.net</email>
<website>http://www.socialenginemods.net/</website>
</author>
<hash>6566ebcd75422bdff5d67ea4cf671904</hash>
<type>app</type>
<description><![CDATA[Tom Friend]]></description>
<pages_admin>100030001</pages_admin>
<show_in_user_menu>0</show_in_user_menu>
<has_user_interface>0</has_user_interface>
<hooks list="true">
<hook name="se_signup_success"></hook>
</hooks>
<languages list="true">
<language code="en" name="English" list="true">
<languagevar id="100030000"><![CDATA[Tom Friend]]></languagevar>
<languagevar id="100030001"><![CDATA[Setup Friends]]></languagevar>
<languagevar id="100030002"><![CDATA[Application Settings - Tom Friend]]></languagevar>
<languagevar id="100030003"><![CDATA[Setup who will be the Tom Friend(s) of the new user.]]></languagevar>
<languagevar id="100030004"><![CDATA[General Settings]]></languagevar>
<languagevar id="100030005"><![CDATA[Do you want each new user that signs up to your social network to automatically
be friends with another specific user? This feature was made popular by MySpace, wherein
you are automatically friends with "Tom" when you sign up. <br><br>
Instructions: <br><br>
1) Create a new user if necessary. This user will be the one that is automatically made friends with all other new users.
<br><br>
2) Get this user's user ID. You can get this by going to "View Users" in the Admin Panel and finding the username.
The ID is the number in the leftmost column.
<br><br>
3) Enter the ID in the text box above
<br><br>
4) If you want to have multiple users get added as a friends, separate the ID's with commas, like this: 1,2,3. No spaces!
<br>]]></languagevar>
<languagevar id="100030006"><![CDATA[User ID's:]]></languagevar>
<languagevar id="100030007"><![CDATA[Save Settings]]></languagevar>
<languagevar id="100030008"><![CDATA[Saved.]]></languagevar>
<languagevar id="100030009"><![CDATA[User with ID %d doesn't exist.]]></languagevar>
</language>
</languages>
</application>