1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 23:00:51 +03:00

Доработка типов топиков

This commit is contained in:
Mzhelskiy Maxim 2014-01-13 12:25:58 +07:00
parent c6c2a0a166
commit f960da0fa7
5 changed files with 156 additions and 0 deletions

View file

@ -584,4 +584,27 @@ class ModuleProperty extends ModuleORM {
public function GetTargetsByTag($iPropertyId,$sTag,$iCurrPage,$iPerPage) {
return array('collection'=>$this->oMapper->GetTargetsByTag($iPropertyId,$sTag,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
}
/**
* Производит изменение названия типа объекта, например "article" меняем на "news"
*
* @param $sType
* @param $sTypeNew
*/
public function ChangeTargetType($sType,$sTypeNew) {
$this->oMapper->UpdatePropertyByTargetType($sType,$sTypeNew);
$this->oMapper->UpdatePropertySelectByTargetType($sType,$sTypeNew);
$this->oMapper->UpdatePropertyValueByTargetType($sType,$sTypeNew);
$this->oMapper->UpdatePropertyValueSelectByTargetType($sType,$sTypeNew);
$this->oMapper->UpdatePropertyValueTagByTargetType($sType,$sTypeNew);
/**
* Сбрасываем кеши
*/
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array(
'ModuleProperty_EntityProperty_save',
'ModuleProperty_EntitySelect_save',
'ModuleProperty_EntityValue_save',
'ModuleProperty_EntityValueSelect_save',
'ModuleProperty_EntityValueTag_save',
));
}
}

View file

@ -210,4 +210,69 @@ class ModuleProperty_MapperProperty extends Mapper {
}
return $aReturn;
}
public function UpdatePropertyByTargetType($sTargetType,$sTargetTypeNew) {
$sql = "UPDATE
".Config::Get('db.table.property')."
SET target_type = ?
WHERE
target_type = ?
";
if ($this->oDb->query($sql,$sTargetTypeNew, $sTargetType)!==false) {
return true;
}
return false;
}
public function UpdatePropertySelectByTargetType($sTargetType,$sTargetTypeNew) {
$sql = "UPDATE
".Config::Get('db.table.property_select')."
SET target_type = ?
WHERE
target_type = ?
";
if ($this->oDb->query($sql,$sTargetTypeNew, $sTargetType)!==false) {
return true;
}
return false;
}
public function UpdatePropertyValueByTargetType($sTargetType,$sTargetTypeNew) {
$sql = "UPDATE
".Config::Get('db.table.property_value')."
SET target_type = ?
WHERE
target_type = ?
";
if ($this->oDb->query($sql,$sTargetTypeNew, $sTargetType)!==false) {
return true;
}
return false;
}
public function UpdatePropertyValueSelectByTargetType($sTargetType,$sTargetTypeNew) {
$sql = "UPDATE
".Config::Get('db.table.property_value_select')."
SET target_type = ?
WHERE
target_type = ?
";
if ($this->oDb->query($sql,$sTargetTypeNew, $sTargetType)!==false) {
return true;
}
return false;
}
public function UpdatePropertyValueTagByTargetType($sTargetType,$sTargetTypeNew) {
$sql = "UPDATE
".Config::Get('db.table.property_value_tag')."
SET target_type = ?
WHERE
target_type = ?
";
if ($this->oDb->query($sql,$sTargetTypeNew, $sTargetType)!==false) {
return true;
}
return false;
}
}

View file

@ -1609,6 +1609,16 @@ class ModuleTopic extends Module {
public function GetTopicTypeByCode($sCode) {
return $this->oMapperTopic->GetTopicTypeByCode($sCode);
}
/**
* Возвращает объект типа топика по его ID
*
* @param int $iId
*
* @return ModuleTopic_EntityTopicType|null
*/
public function GetTopicTypeById($iId) {
return $this->oMapperTopic->GetTopicTypeById($iId);
}
/**
* Добавляет новый тип топика в БД
*
@ -1633,4 +1643,20 @@ class ModuleTopic extends Module {
public function GetTopicTypeItems($aFilter=array()) {
return $this->oMapperTopic->GetTopicTypeItems($aFilter);
}
/**
* Обновляет тип топика в БД
*
* @param ModuleTopic_EntityTopicType $oType
*
* @return bool
*/
public function UpdateTopicType($oType) {
return $this->oMapperTopic->UpdateTopicType($oType);
}
public function UpdateTopicByType($sType,$sTypeNew) {
$res=$this->oMapperTopic->UpdateTopicByType($sType,$sTypeNew);
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_update"));
return $res;
}
}

View file

@ -87,4 +87,8 @@ class ModuleTopic_EntityTopicType extends Entity {
public function getUrlForAdd() {
return Router::GetPath('content/add').$this->getCode().'/';
}
public function getPropertyTargetType() {
return 'topic_'.$this->getCode();
}
}

View file

@ -885,6 +885,14 @@ class ModuleTopic_MapperTopic extends Mapper {
return null;
}
public function GetTopicTypeById($iId) {
$sql = 'SELECT * FROM ' . Config::Get('db.table.topic_type') . ' WHERE id = ?d';
if ($aRow = $this->oDb->selectRow($sql, $iId)) {
return Engine::GetEntity('ModuleTopic_EntityTopicType',$aRow);
}
return null;
}
public function AddTopicType($oType) {
$sql = "INSERT INTO ".Config::Get('db.table.topic_type')."
(name,
@ -912,6 +920,7 @@ class ModuleTopic_MapperTopic extends Mapper {
WHERE
1 = 1
{ and state = ?d }
ORDER BY sort desc
LIMIT 0, 500
";
$aReturn=array();
@ -922,4 +931,33 @@ class ModuleTopic_MapperTopic extends Mapper {
}
return $aReturn;
}
public function UpdateTopicType($oType) {
$sql = "UPDATE ".Config::Get('db.table.topic_type')."
SET
name= ?,
name_many= ?,
code= ?,
state= ?d,
sort= ?d,
params= ?
WHERE
id = ?d
";
$res=$this->oDb->query($sql,$oType->getName(),$oType->getNameMany(),$oType->getCode(),$oType->getState(),$oType->getSort(),$oType->getParams(),$oType->getId());
return $res===false or is_null($res) ? false : true;
}
public function UpdateTopicByType($sType,$sTypeNew) {
$sql = "UPDATE
".Config::Get('db.table.topic')."
SET topic_type = ?
WHERE
topic_type = ?
";
if ($this->oDb->query($sql,$sTypeNew, $sType)!==false) {
return true;
}
return false;
}
}