mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Наброски для функционала Стены
This commit is contained in:
parent
356b6527b2
commit
6458cbb51c
|
@ -33,7 +33,10 @@ class ActionProfile extends Action {
|
|||
*/
|
||||
protected $oUserProfile;
|
||||
|
||||
protected $oUserCurrent;
|
||||
|
||||
public function Init() {
|
||||
$this->oUserCurrent=$this->User_GetUserCurrent();
|
||||
}
|
||||
|
||||
protected function RegisterEvent() {
|
||||
|
@ -43,6 +46,9 @@ class ActionProfile extends Action {
|
|||
$this->AddEvent('ajaxfriendaccept', 'EventAjaxFriendAccept');
|
||||
|
||||
$this->AddEventPreg('/^.+$/i','/^(whois)?$/i','EventWhois');
|
||||
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^$/i','EventWall');
|
||||
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^add/i','EventWallAdd');
|
||||
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^load/i','EventWallLoad');
|
||||
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^comments$/i','/^(page(\d+))?$/i','EventFavouriteComments');
|
||||
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^(page(\d+))?$/i','EventFavourite');
|
||||
}
|
||||
|
@ -198,6 +204,131 @@ class ActionProfile extends Action {
|
|||
$this->SetTemplateAction('whois');
|
||||
}
|
||||
|
||||
/**
|
||||
* Отображение стены пользователя
|
||||
*/
|
||||
public function EventWall() {
|
||||
/**
|
||||
* Получаем логин из УРЛа
|
||||
*/
|
||||
$sUserLogin=$this->sCurrentEvent;
|
||||
/**
|
||||
* Проверяем есть ли такой юзер
|
||||
*/
|
||||
if (!($this->oUserProfile=$this->User_GetUserByLogin($sUserLogin))) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Получаем записи стены
|
||||
*/
|
||||
$aWall=$this->Wall_GetWall(array('wall_user_id'=>$this->oUserProfile->getId(),'pid'=>null),array('id'=>'desc'),1,Config::Get('module.wall.per_page'));
|
||||
$this->Viewer_Assign('aWall',$aWall['collection']);
|
||||
$this->Viewer_Assign('iCountWall',$aWall['count']);
|
||||
if ($aWall['collection']) {
|
||||
reset($aWall['collection']);
|
||||
$this->Viewer_Assign('iWallIdMore',current($aWall['collection'])->getId());
|
||||
$this->Viewer_Assign('iWallIdLess',end($aWall['collection'])->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливаем шаблон вывода
|
||||
*/
|
||||
$this->SetTemplateAction('wall');
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление записи на стену
|
||||
*/
|
||||
public function EventWallAdd() {
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
if (!$this->oUserCurrent) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
/**
|
||||
* Получаем логин из УРЛа
|
||||
*/
|
||||
$sUserLogin=$this->sCurrentEvent;
|
||||
/**
|
||||
* Проверяем есть ли такой юзер
|
||||
*/
|
||||
if (!($this->oUserProfile=$this->User_GetUserByLogin($sUserLogin))) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
|
||||
$oWall=Engine::GetEntity('Wall');
|
||||
$oWall->setWallUserId($this->oUserProfile->getId());
|
||||
$oWall->setUserId($this->oUserCurrent->getId());
|
||||
$oWall->setText(getRequest('sText'));
|
||||
$oWall->setPid(getRequest('iPid'));
|
||||
|
||||
if ($oWall->_Validate()) {
|
||||
/**
|
||||
* Экранируем текст и добавляем запись в БД
|
||||
*/
|
||||
$oWall->setText($this->Text_Parser($oWall->getText()));
|
||||
if (!$this->Wall_AddWall($oWall)) {
|
||||
$this->Message_AddError($this->Lang_Get('wall_add_error'),$this->Lang_Get('error'));
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Пробегаем по ошибкам валидации
|
||||
*/
|
||||
foreach($oWall->_getValidateErrors() as $sField=>$aErros) {
|
||||
foreach($aErros as $sError) {
|
||||
$this->Message_AddError($sError,$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax подгрузка сообщений стены
|
||||
*/
|
||||
public function EventWallLoad() {
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
/**
|
||||
* Получаем логин из УРЛа
|
||||
*/
|
||||
$sUserLogin=$this->sCurrentEvent;
|
||||
/**
|
||||
* Проверяем есть ли такой юзер
|
||||
*/
|
||||
if (!($this->oUserProfile=$this->User_GetUserByLogin($sUserLogin))) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Формируем фильтр для запроса к БД
|
||||
*/
|
||||
$aFilter=array(
|
||||
'wall_user_id'=>$this->oUserProfile->getId(),
|
||||
'pid'=>null
|
||||
);
|
||||
if (is_numeric(getRequest('iIdLess'))) {
|
||||
$aFilter['id_less']=getRequest('iIdLess');
|
||||
} elseif (is_numeric(getRequest('iIdMore'))) {
|
||||
$aFilter['id_more']=getRequest('iIdMore');
|
||||
} else {
|
||||
$this->Message_AddError($this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Получаем сообщения
|
||||
*/
|
||||
$aWall=$this->Wall_GetWall($aFilter,array('id'=>'desc'),1,Config::Get('module.wall.per_page'));
|
||||
$this->Viewer_Assign('aWall',$aWall['collection']);
|
||||
$this->Viewer_AssignAjax('sText', $this->Viewer_Fetch('actions/ActionProfile/wall_items.tpl'));
|
||||
$this->Viewer_AssignAjax('iCountWall',$aWall['count']);
|
||||
$this->Viewer_AssignAjax('iCountWallReturn',count($aWall['collection']));
|
||||
if ($aWall['collection']) {
|
||||
reset($aWall['collection']);
|
||||
$this->Viewer_AssignAjax('iWallIdMore',current($aWall['collection'])->getId());
|
||||
$this->Viewer_AssignAjax('iWallIdLess',end($aWall['collection'])->getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление пользователя в друзья, по отправленной заявке
|
||||
*/
|
||||
|
|
214
classes/modules/wall/Wall.class.php
Normal file
214
classes/modules/wall/Wall.class.php
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Модуль Wall - записи на стене профиля пользователя
|
||||
*
|
||||
*/
|
||||
class ModuleWall extends Module {
|
||||
|
||||
protected $oMapper;
|
||||
protected $oUserCurrent;
|
||||
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
*/
|
||||
public function Init() {
|
||||
$this->oMapper=Engine::GetMapper(__CLASS__);
|
||||
$this->oUserCurrent=$this->User_GetUserCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление записи на стену
|
||||
*
|
||||
* @param ModuleWall_EntityWall $oWall
|
||||
*
|
||||
* @return bool | ModuleWall_EntityWall
|
||||
*/
|
||||
public function AddWall($oWall) {
|
||||
if (!$oWall->getDateAdd()) {
|
||||
$oWall->setDateAdd(date("Y-m-d H:i:s"));
|
||||
}
|
||||
if (!$oWall->getIp()) {
|
||||
$oWall->setIp(func_getIp());
|
||||
}
|
||||
if ($iId=$this->oMapper->AddWall($oWall)) {
|
||||
$oWall->setId($iId);
|
||||
/**
|
||||
* Обновляем данные у родительской записи
|
||||
*/
|
||||
if ($oPidWall=$oWall->GetPidWall()) {
|
||||
$this->UpdatePidWall($oPidWall);
|
||||
}
|
||||
return $oWall;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновление записи
|
||||
*
|
||||
* @param ModuleWall_EntityWall $oWall
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function UpdateWall($oWall) {
|
||||
return $this->oMapper->UpdateWall($oWall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение списка записей по фильтру
|
||||
*
|
||||
* @param $aFilter
|
||||
* @param $aOrder
|
||||
* @param int $iCurrPage
|
||||
* @param int $iPerPage
|
||||
* @param array $aAllowData
|
||||
*
|
||||
* @return array('collection'=>array,'count'=>int)
|
||||
*/
|
||||
public function GetWall($aFilter,$aOrder,$iCurrPage=1,$iPerPage=10,$aAllowData=array('user'=>array(),'reply')) {
|
||||
$aResult=array(
|
||||
'collection'=>$this->oMapper->GetWall($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage),
|
||||
'count'=>$iCount
|
||||
);
|
||||
$aResult['collection']=$this->GetWallAdditionalData($aResult['collection'],$aAllowData);
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение записей по ID, без дополнительных данных
|
||||
*
|
||||
* @param array $aWallId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetWallsByArrayId($aWallId) {
|
||||
if (!is_array($aWallId)) {
|
||||
$aWallId=array($aWallId);
|
||||
}
|
||||
$aWallId=array_unique($aWallId);
|
||||
$aWalls=array();
|
||||
$aResult = $this->oMapper->GetWallsByArrayId($aWallId);
|
||||
foreach ($aResult as $oWall) {
|
||||
$aWalls[$oWall->getId()]=$oWall;
|
||||
}
|
||||
return $aWalls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение записей по ID с дополнительные связаными данными
|
||||
*
|
||||
* @param $aWallId
|
||||
* @param array $aAllowData
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetWallAdditionalData($aWallId,$aAllowData=array('user'=>array(),'reply')) {
|
||||
func_array_simpleflip($aAllowData);
|
||||
if (!is_array($aWallId)) {
|
||||
$aWallId=array($aWallId);
|
||||
}
|
||||
|
||||
$aWalls=$this->GetWallsByArrayId($aWallId);
|
||||
/**
|
||||
* Формируем ID дополнительных данных, которые нужно получить
|
||||
*/
|
||||
$aUserId=array();
|
||||
$aWallReplyId=array();
|
||||
foreach ($aWalls as $oWall) {
|
||||
if (isset($aAllowData['user'])) {
|
||||
$aUserId[]=$oWall->getUserId();
|
||||
}
|
||||
/**
|
||||
* Список последних записей хранится в строке через запятую
|
||||
*/
|
||||
if (isset($aAllowData['reply']) and is_null($oWall->getPid()) and $oWall->getLastReply()) {
|
||||
$aReply=explode(',',trim($oWall->getLastReply()));
|
||||
$aWallReplyId=array_merge($aWallReplyId,$aReply);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Получаем дополнительные данные
|
||||
*/
|
||||
$aUsers=isset($aAllowData['user']) && is_array($aAllowData['user']) ? $this->User_GetUsersAdditionalData($aUserId,$aAllowData['user']) : $this->User_GetUsersAdditionalData($aUserId);
|
||||
$aWallReply=array();
|
||||
if (isset($aAllowData['reply']) and count($aWallReplyId)) {
|
||||
$aWallReply=$this->GetWallAdditionalData($aWallReplyId,array('user'=>array()));
|
||||
}
|
||||
/**
|
||||
* Добавляем данные к результату
|
||||
*/
|
||||
foreach ($aWalls as $oWall) {
|
||||
if (isset($aUsers[$oWall->getUserId()])) {
|
||||
$oWall->setUser($aUsers[$oWall->getUserId()]);
|
||||
} else {
|
||||
$oWall->setUser(null); // или $oWall->setUser(new ModuleUser_EntityUser());
|
||||
}
|
||||
$aReply=array();
|
||||
if ($oWall->getLastReply()) {
|
||||
$aReplyId=explode(',',trim($oWall->getLastReply()));
|
||||
foreach($aReplyId as $iReplyId) {
|
||||
if (isset($aWallReply[$iReplyId])) {
|
||||
$aReply[]=$aWallReply[$iReplyId];
|
||||
}
|
||||
}
|
||||
}
|
||||
$oWall->setLastReplyWall($aReply);
|
||||
}
|
||||
return $aWalls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение записи по ID
|
||||
*
|
||||
* @param int $iId
|
||||
*
|
||||
* @return ModuleWall_EntityWall
|
||||
*/
|
||||
public function GetWallById($iId) {
|
||||
$aResult=$this->GetWallAdditionalData($iId);
|
||||
if (isset($aResult[$iId])) {
|
||||
return $aResult[$iId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновляет родительские данные у записи - количество ответов и ID последних ответов
|
||||
*
|
||||
* @param ModuleWall_EntityWall $oWall
|
||||
*
|
||||
* @param null|int $iLimit
|
||||
*/
|
||||
public function UpdatePidWall($oWall,$iLimit=null) {
|
||||
if (is_null($iLimit)) {
|
||||
$iLimit=Config::Get('module.wall.count_last_reply');
|
||||
}
|
||||
|
||||
$aResult=$this->GetWall(array('pid'=>$oWall->getId()),array('id'=>'desc'),1,$iLimit,array());
|
||||
if ($aResult['count']) {
|
||||
$oWall->setCountReply($aResult['count']);
|
||||
$oWall->setLastReply(join(',',array_keys($aResult['collection'])));
|
||||
$this->UpdateWall($oWall);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
63
classes/modules/wall/entity/Wall.entity.class.php
Normal file
63
classes/modules/wall/entity/Wall.entity.class.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleWall_EntityWall extends Entity {
|
||||
|
||||
/**
|
||||
* Определяем правила валидации
|
||||
*/
|
||||
protected $aValidateRules=array(
|
||||
array('text','string','max'=>10,'min'=>1,'allowEmpty'=>false),
|
||||
array('pid','pid'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Валидация родительского сообщения
|
||||
*
|
||||
* @param $sValue
|
||||
* @param $aParams
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ValidatePid($sValue,$aParams) {
|
||||
if (!$sValue) {
|
||||
$this->setPid(null);
|
||||
return true;
|
||||
} elseif ($oParentWall=$this->GetPidWall()) {
|
||||
/**
|
||||
* Если отвечаем на сообщение нужной стены и оно корневое, то все ОК
|
||||
*/
|
||||
if ($oParentWall->getWallUserId()==$this->getWallUserId() and !$oParentWall->getPid()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return $this->Lang_Get('wall_add_pid_error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает родительскую запись
|
||||
*
|
||||
* @return ModuleWall_EntityWall
|
||||
*/
|
||||
public function GetPidWall() {
|
||||
if ($this->getPid()) {
|
||||
return $this->Wall_GetWallById($this->getPid());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
?>
|
113
classes/modules/wall/mapper/Wall.mapper.class.php
Normal file
113
classes/modules/wall/mapper/Wall.mapper.class.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleWall_MapperWall extends Mapper {
|
||||
|
||||
public function AddWall($oWall) {
|
||||
$sql = "INSERT INTO ".Config::Get('db.table.wall')." SET ?a ";
|
||||
if ($iId=$this->oDb->query($sql,$oWall->_getData())) {
|
||||
return $iId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function UpdateWall($oWall) {
|
||||
$sql = "UPDATE ".Config::Get('db.table.wall')."
|
||||
SET
|
||||
count_reply = ?d,
|
||||
last_reply = ?
|
||||
WHERE id = ?d
|
||||
";
|
||||
return $this->oDb->query($sql,$oWall->getCountReply(),
|
||||
$oWall->getLastReply(),
|
||||
$oWall->getId());
|
||||
}
|
||||
|
||||
|
||||
public function GetWall($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
|
||||
$aOrderAllow=array('id','date_add');
|
||||
$sOrder='';
|
||||
foreach ($aOrder as $key=>$value) {
|
||||
if (!in_array($key,$aOrderAllow)) {
|
||||
unset($aOrder[$key]);
|
||||
} elseif (in_array($value,array('asc','desc'))) {
|
||||
$sOrder.=" {$key} {$value},";
|
||||
}
|
||||
}
|
||||
$sOrder=trim($sOrder,',');
|
||||
if ($sOrder=='') {
|
||||
$sOrder=' id desc ';
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT
|
||||
id
|
||||
FROM
|
||||
".Config::Get('db.table.wall')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND pid = ?d }
|
||||
{ AND pid IS NULL AND 1 = ?d }
|
||||
{ AND wall_user_id = ?d }
|
||||
{ AND ip = ? }
|
||||
{ AND id = ?d }
|
||||
{ AND id < ?d }
|
||||
{ AND id > ?d }
|
||||
ORDER by {$sOrder}
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->selectPage($iCount,$sql,
|
||||
(isset($aFilter['pid']) and !is_null($aFilter['pid'])) ? $aFilter['pid'] : DBSIMPLE_SKIP,
|
||||
(array_key_exists('pid',$aFilter) and is_null($aFilter['pid'])) ? 1 : DBSIMPLE_SKIP,
|
||||
isset($aFilter['wall_user_id']) ? $aFilter['wall_user_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['ip']) ? $aFilter['ip'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['id_less']) ? $aFilter['id_less'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['id_more']) ? $aFilter['id_more'] : DBSIMPLE_SKIP,
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=$aRow['id'];
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function GetWallsByArrayId($aArrayId) {
|
||||
if (!is_array($aArrayId) or count($aArrayId)==0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
".Config::Get('db.table.wall')."
|
||||
WHERE
|
||||
id IN(?a)
|
||||
ORDER BY FIELD(id,?a) ";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->select($sql,$aArrayId,$aArrayId)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=Engine::GetEntity('Wall',$aRow);
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -236,6 +236,9 @@ $config['module']['stream']['disable_vote_events'] = false;
|
|||
// Модуль Ls
|
||||
$config['module']['ls']['send_general'] = true; // Отправка на сервер LS общей информации о сайте (домен, версия LS и плагинов)
|
||||
$config['module']['ls']['use_counter'] = true; // Использование счетчика GA
|
||||
// Модуль Wall - стена
|
||||
$config['module']['wall']['count_last_reply'] = 3; // Число последних ответов на сообщени на стене для отображения в ленте
|
||||
$config['module']['wall']['per_page'] = 3; // Число сообщений на стене на одну страницу
|
||||
|
||||
|
||||
/**
|
||||
|
@ -319,6 +322,7 @@ $config['db']['table']['user_field'] = '___db.table.prefix___user_field
|
|||
$config['db']['table']['user_field_value'] = '___db.table.prefix___user_field_value';
|
||||
$config['db']['table']['topic_photo'] = '___db.table.prefix___topic_photo';
|
||||
$config['db']['table']['subscribe'] = '___db.table.prefix___subscribe';
|
||||
$config['db']['table']['wall'] = '___db.table.prefix___wall';
|
||||
|
||||
$config['db']['tables']['engine'] = 'InnoDB'; // InnoDB или MyISAM
|
||||
/**
|
||||
|
@ -493,6 +497,7 @@ $config['head']['default']['js'] = array(
|
|||
"___path.root.engine_lib___/internal/template/js/vote.js",
|
||||
"___path.root.engine_lib___/internal/template/js/poll.js",
|
||||
"___path.root.engine_lib___/internal/template/js/subscribe.js",
|
||||
"___path.root.engine_lib___/internal/template/js/wall.js",
|
||||
"___path.root.engine_lib___/internal/template/js/comments.js",
|
||||
"___path.root.engine_lib___/internal/template/js/blog.js",
|
||||
"___path.root.engine_lib___/internal/template/js/friend.js",
|
||||
|
|
91
engine/lib/internal/template/js/wall.js
Normal file
91
engine/lib/internal/template/js/wall.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
var ls = ls || {};
|
||||
|
||||
/**
|
||||
* Стена пользователя
|
||||
*/
|
||||
ls.wall = (function ($) {
|
||||
|
||||
this.options = {
|
||||
login: '',
|
||||
id_less: '',
|
||||
id_more: ''
|
||||
};
|
||||
|
||||
this.iIdLess=null;
|
||||
this.iIdMore=null;
|
||||
/**
|
||||
* Добавление записи
|
||||
*/
|
||||
this.add = function(sText, iPid) {
|
||||
var url = aRouter['profile']+this.options.login+'/wall/add/';
|
||||
var params = {sText: sText, iPid: iPid};
|
||||
'*addBefore*'; '*/addBefore*';
|
||||
ls.ajax(url, params, function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
this.loadNew();
|
||||
ls.hook.run('ls_wall_add_after',[sText, iPid, result]);
|
||||
}
|
||||
}.bind(this));
|
||||
return false;
|
||||
};
|
||||
|
||||
this.load = function(iIdLess,iIdMore,collback) {
|
||||
var url = aRouter['profile']+this.options.login+'/wall/load/';
|
||||
var params = {iIdLess: iIdLess ? iIdLess : '', iIdMore: iIdMore ? iIdMore : ''};
|
||||
'*loadBefore*'; '*/loadBefore*';
|
||||
ls.ajax(url, params, collback);
|
||||
return false;
|
||||
};
|
||||
|
||||
this.loadNext = function() {
|
||||
this.load(this.iIdLess,'',function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
if (result.iWallIdLess) {
|
||||
this.iIdLess=result.iWallIdLess;
|
||||
}
|
||||
if (result.iCountWall) {
|
||||
$('#wall-contener').append(result.sText);
|
||||
}
|
||||
var iCount=result.iCountWall-result.iCountWallReturn;
|
||||
if (iCount) {
|
||||
$('#wall-count-next').text(iCount);
|
||||
} else {
|
||||
$('#wall-button-next').detach();
|
||||
}
|
||||
ls.hook.run('ls_wall_loadnext_after',[this.iIdLess, result]);
|
||||
}
|
||||
}.bind(this));
|
||||
return false;
|
||||
};
|
||||
|
||||
this.loadNew = function() {
|
||||
this.load('',this.iIdMore,function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
if (result.iWallIdMore) {
|
||||
this.iIdMore=result.iWallIdMore;
|
||||
}
|
||||
if (result.iCountWall) {
|
||||
$('#wall-contener').prepend(result.sText);
|
||||
}
|
||||
ls.hook.run('ls_wall_loadnew_after',[this.iIdLess, result]);
|
||||
}
|
||||
}.bind(this));
|
||||
return false;
|
||||
};
|
||||
|
||||
this.init = function(opt) {
|
||||
if (opt) {
|
||||
$.extend(true,this.options,opt);
|
||||
}
|
||||
this.iIdLess=this.options.id_less;
|
||||
this.iIdMore=this.options.id_more;
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.wall || {},jQuery);
|
|
@ -25,4 +25,20 @@ CREATE TABLE IF NOT EXISTS `prefix_subscribe` (
|
|||
KEY `key` (`key`),
|
||||
KEY `target_id` (`target_id`),
|
||||
KEY `ip` (`ip`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `prefix_wall` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`pid` int(11) DEFAULT NULL,
|
||||
`wall_user_id` int(11) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`count_reply` int(11) NOT NULL DEFAULT '0',
|
||||
`last_reply` varchar(100) NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`ip` varchar(20) NOT NULL,
|
||||
`text` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pid` (`pid`),
|
||||
KEY `wall_user_id` (`wall_user_id`),
|
||||
KEY `ip` (`ip`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
@ -530,6 +530,11 @@ return array(
|
|||
'user_field_error_add_no_name' => 'You must specify the name of the field',
|
||||
'user_field_error_add_no_title' => 'You must specify a title field',
|
||||
'user_field_error_name_exists' => 'Field with that name already exists',
|
||||
/**
|
||||
* Wall
|
||||
*/
|
||||
'wall_add_pid_error' => 'At this message can not be reply',
|
||||
'wall_add_error' => 'Error adding a post to the wall',
|
||||
/**
|
||||
* Configs.
|
||||
*/
|
||||
|
|
|
@ -530,6 +530,11 @@ return array(
|
|||
'user_field_error_add_no_name' => 'Необходимо указать название поля',
|
||||
'user_field_error_add_no_title' => 'Необходимо указать заголовок поля',
|
||||
'user_field_error_name_exists' => 'Поле с таким именем уже существует',
|
||||
/**
|
||||
* Стена
|
||||
*/
|
||||
'wall_add_pid_error' => 'На данное сообщение невозможно ответить',
|
||||
'wall_add_error' => 'Ошибка добавления записи на стены',
|
||||
/**
|
||||
* Настройки
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
{assign var="sidebarPosition" value='left'}
|
||||
{include file='header.tpl'}
|
||||
|
||||
{assign var="oSession" value=$oUserProfile->getSession()}
|
||||
{assign var="oVote" value=$oUserProfile->getVote()}
|
||||
|
||||
|
||||
<div class="profile">
|
||||
<img src="{$oUserProfile->getProfileAvatarPath(48)}" alt="avatar" class="avatar" />
|
||||
|
||||
<div id="vote_area_user_{$oUserProfile->getId()}" class="vote {if $oUserProfile->getRating()>=0}vote-count-positive{else}vote-count-negative{/if} {if $oVote} voted {if $oVote->getDirection()>0}voted-up{elseif $oVote->getDirection()<0}voted-down{/if}{/if}">
|
||||
<a href="#" class="vote-up" onclick="return ls.vote.vote({$oUserProfile->getId()},this,1,'user');"></a>
|
||||
<div id="vote_total_user_{$oUserProfile->getId()}" class="vote-count" title="{$aLang.user_vote_count}: {$oUserProfile->getCountVote()}">{$oUserProfile->getRating()}</div>
|
||||
<a href="#" class="vote-down" onclick="return ls.vote.vote({$oUserProfile->getId()},this,-1,'user');"></a>
|
||||
</div>
|
||||
|
||||
<p class="strength">
|
||||
{$aLang.user_skill}: <strong class="total" id="user_skill_{$oUserProfile->getId()}">{$oUserProfile->getSkill()}</strong>
|
||||
</p>
|
||||
|
||||
|
||||
<h2 class="page-header user-login">{$oUserProfile->getLogin()}</h2>
|
||||
|
||||
{if $oUserProfile->getProfileName()}
|
||||
<p class="user-name">{$oUserProfile->getProfileName()|escape:'html'}</p>
|
||||
{/if}
|
||||
|
||||
{if $oUserCurrent && $oUserCurrent->getId()!=$oUserProfile->getId()}
|
||||
<ul id="profile_actions">
|
||||
{include file='actions/ActionProfile/friend_item.tpl' oUserFriend=$oUserProfile->getUserFriend()}
|
||||
<li><a href="{router page='talk'}add/?talk_users={$oUserProfile->getLogin()}">{$aLang.user_write_prvmsg}</a></li>
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<h3 class="profile-page-header">Стена</h3>
|
||||
|
||||
|
||||
{include file='menu.profile.tpl'}
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
ls.wall.init({
|
||||
login:'{$oUserProfile->getLogin()}',
|
||||
id_less:'{$iWallIdLess}',
|
||||
id_more:'{$iWallIdMore}'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Написать на стену:<br>
|
||||
<textarea rows="4" cols="30" id="wall_text"></textarea>
|
||||
<br>
|
||||
<input type="submit" value="отправить" onclick="ls.wall.add(jQuery('#wall_text').val(),0);">
|
||||
|
||||
<div id="wall-contener">
|
||||
{include file='actions/ActionProfile/wall_items.tpl'}
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<a href="#" onclick="return ls.wall.loadNext();" id="wall-button-next">Показать еще, всего <span id="wall-count-next">{$iCountWall}</span></a>
|
||||
|
||||
{include file='footer.tpl'}
|
|
@ -0,0 +1,16 @@
|
|||
{foreach from=$aWall item=oWall}
|
||||
{assign var="oWallUser" value=$oWall->getUser()}
|
||||
{assign var="aReplyWall" value=$oWall->getLastReplyWall()}
|
||||
<div>
|
||||
{$oWallUser->getLogin()} {date_format date=$oWall->getDateAdd() format="j F Y, H:i"}
|
||||
<br>
|
||||
{$oWall->getText()} - ({$oWall->getId()})
|
||||
<br>
|
||||
<a href="#">Ответить</a>
|
||||
<div style="border: 1px solid red;">
|
||||
{if $aReplyWall}
|
||||
{include file='actions/ActionProfile/wall_items_reply.tpl'}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
|
@ -0,0 +1,8 @@
|
|||
{foreach from=$aReplyWall item=oReplyWall}
|
||||
{assign var="oReplyUser" value=$oReplyWall->getUser()}
|
||||
<div>
|
||||
{$oReplyUser->getLogin()} {date_format date=$oReplyWall->getDateAdd() format="j F Y, H:i"}
|
||||
<br>
|
||||
{$oReplyWall->getText()} - ({$oReplyWall->getId()})
|
||||
</div>
|
||||
{/foreach}
|
Loading…
Reference in a new issue