Wall photos album in phpFox

In phpFox  the shared photos in wall are just uploaded.It does not create any album like “Wall Photos” similar to facebook.You can make use of this function by simple code customization.

Goto phpfox/module/photo/include/service/process.class.php

and find the function

public function add

Need to customize this function

after this codes

$oParseInput = Phpfox::getLib('parse.input');
// Create the fields to insert.
$aFields = array();

insert this codes


$fzk_check_album=$this->database()->select('*')
->from(Phpfox::getT('photo_album'))
->where('name = "Wall Photos" AND user_id =' . $iUserId)
->execute('getRow');
if(!empty($fzk_check_album))
{
$aVals['album_id']=$fzk_check_album['album_id'];
$aVals['set_album_cover']=0;
}
else
{

$fzk_aVals['name']="Wall Photos";
$fzk_aVals['description']="Wall Photos";

$fzk_aFields = array(
'name',
'module_id',
'group_id' => 'int',
'privacy' => 'int',
'privacy_comment' => 'int'
);
$fzk_aFieldsInfo = array(
'description'
);
$fzk_aFields['user_id'] = 'int';
$fzk_aFields[] = 'time_stamp';
// Add the users ID to the fields array
$fzk_aVals['user_id'] = Phpfox::getUserId();
// Add a time_stamp
$fzk_aVals['time_stamp'] = PHPFOX_TIME;

$fzk_aVals['name'] = $oParseInput->clean($fzk_aVals['name'], 255);
$fzk_aVals['description'] = $oParseInput->clean($fzk_aVals['description'], 255);

$fzk_iId = $this->database()->process($fzk_aFields, $fzk_aVals)->insert(Phpfox::getT('photo_album'));
$fzk_aFieldsInfo['album_id'] = 'int';
$fzk_aVals['album_id'] = $fzk_iId;
$this->database()->process($fzk_aFieldsInfo, $fzk_aVals)->insert(Phpfox::getT('photo_album_info'));
$aVals['album_id']=$fzk_iId;
$aVals['set_album_cover']=1;
}

If you feel customizing core files is not good method you can make use of phpFox plugin hooks

Using Plugin is the best method .So you need to create a plugin in your custom module

Goto phpfox/module/yourmodule/include/plugin and create a file photo.service_process_add__end.php and insert the below code in that file

$oParseInput = Phpfox::getLib('parse.input');
$fzk_check_album=$this->database()->select('*')
->from(Phpfox::getT('photo_album'))
->where('name = "Wall Photos" AND user_id =' . $iUserId)
->execute('getRow');

if(!empty($fzk_check_album))
{
$fzk_iAlbumId=$fzk_check_album['album_id'];
$this->database()->update(Phpfox::getT('photo'), array('is_cover' => '1','type_id' => '0','album_id' => (int) $fzk_iAlbumId), 'photo_id = ' . (int) $iId);
}
else
{
$fzk_aVals['name']="Wall Photos";
$fzk_aVals['description']="Wall Photos";
$fzk_aVals['name'] = $oParseInput->clean($fzk_aVals['name'], 255);
$fzk_aVals['description'] = $oParseInput->clean($fzk_aVals['description'], 255);
$fzk_aFields = array(
'name',
'module_id',
'group_id' => 'int',
'privacy' => 'int',
'privacy_comment' => 'int'
);
$fzk_aFieldsInfo = array(
'description'
);
$fzk_aFields['user_id'] = 'int';
$fzk_aFields[] = 'time_stamp';
// Add the users ID to the fields array
$fzk_aVals['user_id'] = Phpfox::getUserId();
// Add a time_stamp
$fzk_aVals['time_stamp'] = PHPFOX_TIME;
$fzk_iId = $this->database()->process($fzk_aFields, $fzk_aVals)->insert(Phpfox::getT('photo_album'));
$fzk_aFieldsInfo['album_id'] = 'int';
$fzk_aVals['album_id'] = $fzk_iId;
$this->database()->process($fzk_aFieldsInfo, $fzk_aVals)->insert(Phpfox::getT('photo_album_info'));
$this->database()->update(Phpfox::getT('photo'), array('is_cover' => '0','type_id' => '0','album_id' => (int) $fzk_iId), 'photo_id = ' . (int) $iId);
}