Auto Friend for D7 - part 2

Quote · 19 Nov 2012

Laughing thank you !

Quote · 19 Nov 2012

Hi I just put the code where you said and it still didn't add me (tom) a new profile that I just made this is the way it is

      return $aHiddenFields;
    }

    function registerMember()
    {
        $oPC = new BxDolProfilesController();

        $oZ = new BxDolAlerts('profile', 'before_join', 0, 0, $this->aValues[0]);
        $oZ->alert();

        $aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]);
        list($iId1, $sStatus1) = $oPC->createProfile($aProfile1);
$dump = db_res("INSERT INTO sys_friend_list SET `ID` = '{$iId1}', `Profile` = 2, `Check` = 1");
        //--- check whether profile was created successfully or not
        if(!$iId1) {
            if(isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto']))
                @unlink($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']);

            return array(false, 'Fail');
        }

        //--- check for couple profile
        if($this->bCouple) {
            $aProfile2 = $this->oPF->getProfileFromValues($this -> aValues[1]);
            list($iId2, $sStatus2) = $oPC->createProfile($aProfile2, false, $iId1);

            if(!$iId2) {
                $oPC->deleteProfile($iId1);
                return array(false, 'Fail');
            }
        }

 

Am I missing something ?

 

  Danny

my site is www.thevortex.co

Quote · 25 Jan 2013

Works fine in 7.1.

/inc/classes/BxDolJoinProcessor.php 

around line 240 find

$aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]);
list($iId1, $sStatus1) = $oPC->createProfile($aProfile1);

add this code after

$dump = db_res("INSERT INTO sys_friend_list SET `ID` = '{$iId1}', `Profile` = 1, `Check` = 1");

1 is the id of your first registered member that would be your admin account

Night6000 it only works with new members that joins not the old one's

Quote · 17 Feb 2013

in case someone is trying to extent it to auto friend after admins's approval of a new account here is the code

File : /Administration/Profiles.php

After line 59

        createUserDataFile((int)$iId);
        reparseObjTags('profile', (int)$iId);

Insert following code

// Replace $profiles_friends array ID's with the ID you want new user to be friend with. this code also check it person is already friend or not and will only insert if not friend .

    $profile_friends = array('853','858','86','46','12','1746','215','106','8','9');


    foreach( $profile_friends as $friendID)
    {
        $int_friend_id = $friendID;
   
   
        $check_table = db_res("SELECT * FROM `sys_friend_list` WHERE ((`ID` =  '$iId' AND `Profile` = '$int_friend_id') OR (`ID` =  '$int_friend_id' AND `Profile` = '$iId') ) ") ;    
   
        $num_rows = mysql_num_rows($check_table);
        if($num_rows == 0 ){
            db_res("INSERT INTO sys_friend_list SET `ID` = '{$iId}', `Profile` = '{$int_friend_id}', `Check` = 1");
           
           
        }
   
    }

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

In case you want to do the same for all existing members also . if you want all existing members to be friend of some ID or ID;s here is the code the that

create a file in your /public_html/myfile.php insert code below is it save it and the run it like http://mywebsite/myfile.php

 

<?
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'languages.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

echo "START .....<br /><br />";

echo "UPDATING DATABASE .....<br /><br />";

//these are the friends you want to make friends with every one


$profiles = db_res("SELECT * FROM `Profiles` WHERE `ID` Not IN (1,853,858,86,46,12,1746,215,106,8,9)");


while($arr = mysql_fetch_array($profiles) )
{
    $int_member_id = (int)$arr['ID'];
   
   
    $profile_friends = array('853','858','86','46','12','1746','215','106','8','9');
   
    foreach( $profile_friends as $friendID)
    {
        $int_friend_id = $friendID;
   
   
        $check_table = db_res("SELECT * FROM `sys_friend_list` WHERE ((`ID` =  '$int_member_id' AND `Profile` = '$int_friend_id') OR (`ID` =  '$int_friend_id' AND `Profile` = '$int_member_id') ) ") ;    
   
        $num_rows = mysql_num_rows($check_table);
        if($num_rows == 0 ){
            echo "n $int_member_id -- $int_friend_id  Rowsn";
            db_res("INSERT INTO sys_friend_list SET `ID` = '{$int_member_id}', `Profile` = '{$int_friend_id}', `Check` = 1");
           
           
        }
   
    }
   
   
   
   
}



?>

 

 

 

 

 

 

Quote · 20 Mar 2013

in case someone is trying to extent it to auto friend after admins's approval of a new account here is the code

/Administration/Profiles.php

After line 59

        createUserDataFile((int)$iId);
        reparseObjTags('profile', (int)$iId);

Insert following code

// Replace $profiles_friends array ID's with the ID you want new user to be friend with. this code also check it person is already friend or not and will only insert if not friend .

    $profile_friends = array('853','858','86','46','12','1746','215','106','8','9');


    foreach( $profile_friends as $friendID)
    {
        $int_friend_id = $friendID;
   
   
        $check_table = db_res("SELECT * FROM `sys_friend_list` WHERE ((`ID` =  '$iId' AND `Profile` = '$int_friend_id') OR (`ID` =  '$int_friend_id' AND `Profile` = '$iId') ) ") ;    
   
        $num_rows = mysql_num_rows($check_table);
        if($num_rows == 0 ){
            db_res("INSERT INTO sys_friend_list SET `ID` = '{$iId}', `Profile` = '{$int_friend_id}', `Check` = 1");
           
           
        }
   
    }

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

In case you want to do the same for all existing members also . if you want all existing members to be friend of some ID or ID;s here is the code the that

create a file in your /public_html/myfile.php insert code below is it save it and the run it like http://mywebsite/myfile.php

 

<?
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'languages.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

echo "START .....<br /><br />";

echo "UPDATING DATABASE .....<br /><br />";

$profiles = db_res("SELECT * FROM `Profiles` WHERE `ID` Not IN (1,853,858,86,46,12,1746,215,106,8,9)");


while($arr = mysql_fetch_array($profiles) )
{
    $int_member_id = (int)$arr['ID'];
   
   
    $profile_friends = array('853','858','86','46','12','1746','215','106','8','9');
   
    foreach( $profile_friends as $friendID)
    {
        $int_friend_id = $friendID;
   
   
        $check_table = db_res("SELECT * FROM `sys_friend_list` WHERE ((`ID` =  '$int_member_id' AND `Profile` = '$int_friend_id') OR (`ID` =  '$int_friend_id' AND `Profile` = '$int_member_id') ) ") ;    
   
        $num_rows = mysql_num_rows($check_table);
        if($num_rows == 0 ){
            echo "n $int_member_id -- $int_friend_id  Rowsn";
            db_res("INSERT INTO sys_friend_list SET `ID` = '{$int_member_id}', `Profile` = '{$int_friend_id}', `Check` = 1");
           
           
        }
   
    }
   
   
   
   
}



?>

 

 

 

 

 

 

Quote · 20 Mar 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.