Файл: InstantSocial/uploud/plugins/p_present_gifts/plugin.php
Строк: 94
<?php
/*********************************************************************************************/
// //
// InstantPresent v1.0 (c) 2010 //
// http://www.instantcms.ru/, info@instantcms.ru //
// //
// written by Somebody & Александр, 2010 //
// //
/*********************************************************************************************/
class p_present_gifts extends cmsPlugin {
// ==================================================================== //
public function __construct(){
parent::__construct();
// Информация о плагине
$this->info['plugin'] = 'p_present_gifts';
$this->info['title'] = 'Плагин Подарки';
$this->info['description'] = 'Добавляет вкладку "Подарки" в профили всех пользователей';
$this->info['author'] = 'Somebody & Александр';
$this->info['version'] = '1.1';
$this->info['tab'] = 'Подарки'; //-- Заголовок закладки в профиле
// Настройки по-умолчанию
$this->config['Количество подарков'] = 10;
// События, которые будут отлавливаться плагином
$this->events[] = 'USER_PROFILE';
}
// ==================================================================== //
/**
* Процедура установки плагина
* @return bool
*/
public function install(){
return parent::install();
}
// ==================================================================== //
/**
* Процедура обновления плагина
* @return bool
*/
public function upgrade(){
return parent::upgrade();
}
// ==================================================================== //
/**
* Обработка событий
* @param string $event
* @param array $user
* @return html
*/
public function execute($event, $user){
parent::execute();
$inCore = cmsCore::getInstance();
$ListPresents = array();
$my_id = $inUser->id;
$user_id = $user['id'];
$limit = $this->config['Количество подарков'];
$sql = "SELECT cms_present_list.id as pr_id,
cms_present_list.user_id_from,
cms_present_list.user_id_to,
cms_present_list.present_id,
cms_present_list.message,
cms_present.id,
cms_present.link,
cms_users.id,
cms_users.login,
cms_users.nickname,
DATE_FORMAT(cms_present_list.time, '%d-%m-%Y (%H:%i)') as time
FROM cms_present_list, cms_present, cms_users
WHERE cms_present_list.user_id_to = {$user_id} AND cms_present_list.present_id = cms_present.id AND cms_present_list.user_id_from = cms_users.id
ORDER BY time DESC
LIMIT {$limit}";
$result = $this->inDB->query($sql);
$total = $this->inDB->num_rows($result);
if ($total){
while($ListPresent = $this->inDB->fetch_assoc($result)){
$ListPresents[] = $ListPresent;
}
}
ob_start();
$smarty= $this->inCore->initSmarty('plugins', 'p_present_gifts.tpl');
$smarty->assign('total', $total);
$smarty->assign('ListPresent', $ListPresents);
$smarty->assign('my_id ', $my_id);
$smarty->display('p_present_gifts.tpl');
$html = ob_get_clean();
return $html;
}
// ==================================================================== //
}
?>