Skip to content

Commit

Permalink
共通処理の見直しによる修正
Browse files Browse the repository at this point in the history
  • Loading branch information
s-nakajima committed Sep 13, 2015
1 parent 0ff4b64 commit cebb557
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 128 deletions.
53 changes: 0 additions & 53 deletions Controller/BbsesAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class BbsesAppController extends AppController {
* @var array
*/
public $components = array(
// 'NetCommons.NetCommonsFrame',
'Pages.PageLayout',
'Security'
);
Expand All @@ -40,51 +39,6 @@ class BbsesAppController extends AppController {
'Bbses.BbsSetting'
);

/**
* use helpers
*
* @var array
*/
// public $helpers = array(
// 'NetCommons.Date',
// );

/**
* initBbs
*
* @param array $contains Optional result sets
* @return void
*/
// public function initBbs($contains = []) {
// if (! $bbs = $this->Bbs->getBbs($this->viewVars['blockId'], $this->viewVars['roomId'])) {
// $this->throwBadRequest();
// return false;
// }
// $bbs = $this->camelizeKeyRecursive($bbs);
// $this->set($bbs);
//
// if (! $bbsSetting = $this->BbsSetting->getBbsSetting($bbs['bbs']['key'])) {
// $bbsSetting = $this->BbsSetting->create(array(
// 'id' => null,
// 'bbs_key' => $bbs['bbs']['key']
// ));
// }
// $bbsSetting = $this->camelizeKeyRecursive($bbsSetting);
// $this->set($bbsSetting);
//
// if (in_array('bbsFrameSetting', $contains, true)) {
// if (! $bbsFrameSetting = $this->BbsFrameSetting->getBbsFrameSetting($this->viewVars['frameKey'])) {
// $bbsFrameSetting = $this->BbsFrameSetting->create(array(
// 'frame_key' => $this->viewVars['frameKey']
// ));
// }
// $bbsFrameSetting = $this->camelizeKeyRecursive($bbsFrameSetting);
// $this->set($bbsFrameSetting);
// }
//
// $this->set('userId', (int)$this->Auth->user('id'));
// }

/**
* initTabs
*
Expand All @@ -93,12 +47,6 @@ class BbsesAppController extends AppController {
* @return void
*/
public function initTabs($mainActiveTab, $blockActiveTab) {
// if (isset($this->params['pass'][1])) {
// $blockId = (int)$this->params['pass'][1];
// } else {
// $blockId = null;
// }

//タブの設定
$settingTabs = array(
'tabs' => array(
Expand Down Expand Up @@ -148,5 +96,4 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
);
$this->set('blockSettingTabs', $blockSettingTabs);
}

}
53 changes: 1 addition & 52 deletions Model/Bbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function beforeValidate($options = array()) {
* @param bool $created True if this save created a new record
* @param array $options Options passed from Model::save().
* @return void
* @throws InternalErrorException
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
* @see Model::save()
*/
Expand Down Expand Up @@ -328,56 +329,4 @@ public function deleteBbs($data) {
return true;
}

/**
* Update bbs_article_modified and bbs_article_count
*
* @param int $bbsId bbses.id
* @param string $bbsKey bbses.key
* @param int $languageId languages.id
* @return bool True on success
* @throws InternalErrorException
*/
// public function updateBbsArticle($bbsId, $bbsKey, $languageId) {
// $this->loadModels([
// 'BbsArticle' => 'Bbses.BbsArticle',
// ]);
// $db = $this->getDataSource();
//
// $conditions = array(
// 'bbs_id' => $bbsId,
// 'language_id' => $languageId,
// 'is_latest' => true
// );
// $count = $this->BbsArticle->find('count', array(
// 'recursive' => -1,
// 'conditions' => $conditions,
// ));
// if ($count === false) {
// throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
// }
//
// $article = $this->BbsArticle->find('first', array(
// 'recursive' => -1,
// 'fields' => 'modified',
// 'conditions' => $conditions,
// 'order' => 'modified desc'
// ));
// if ($article === false) {
// throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
// }
//
// $update = array(
// 'bbs_article_count' => $count
// );
// if ($article) {
// $update['bbs_article_modified'] = $db->value($article[$this->BbsArticle->alias]['modified'], 'string');
// }
//
// if (! $this->updateAll($update, array('Bbs.key' => $bbsKey))) {
// throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
// }
//
// return true;
// }

}
21 changes: 4 additions & 17 deletions Model/BbsArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ class BbsArticle extends BbsesAppModel {
* @var array
*/
public $belongsTo = array(
// 'Bbs' => array(
// 'className' => 'Bbses.Bbs',
// 'foreignKey' => 'bbs_id',
// 'conditions' => '',
// 'fields' => '',
// 'order' => ''
// ),
'BbsArticleTree' => array(
'type' => 'INNER',
'className' => 'Bbses.BbsArticleTree',
Expand All @@ -88,13 +81,6 @@ class BbsArticle extends BbsesAppModel {
'fields' => '',
'order' => ''
),
// 'CreatedUser' => array(
// 'className' => 'Users.User',
// 'foreignKey' => false,
// 'conditions' => 'BbsArticle.created_user = CreatedUser.id',
// 'fields' => 'CreatedUser.handlename',
// 'order' => ''
// )
);

/**
Expand Down Expand Up @@ -148,6 +134,7 @@ public function beforeValidate($options = array()) {
* @param bool $created True if this save created a new record
* @param array $options Options passed from Model::save().
* @return void
* @throws InternalErrorException
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
* @see Model::save()
*/
Expand Down Expand Up @@ -176,7 +163,7 @@ public function afterSave($created, $options = array()) {
}

/**
* Save article
* Save BbsArticle
*
* @param array $data received post data
* @return mixed On success Model::$data if its not empty or true, false on failure
Expand Down Expand Up @@ -217,7 +204,7 @@ public function saveBbsArticle($data) {
}

/**
* Delete posts
* Delete BbsArticle
*
* @param array $data received post data
* @return mixed On success Model::$data if its not empty or true, false on failure
Expand Down Expand Up @@ -287,7 +274,7 @@ public function deleteBbsArticle($data) {
}

/**
* Save comment as publish
* Save Comment as publish
*
* @param array $data received post data
* @return mixed On success Model::$data if its not empty or true, false on failure
Expand Down
5 changes: 3 additions & 2 deletions Model/BbsFrameSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public function beforeValidate($options = array()) {
}

/**
* Get bbs frame setting data
* Get BbsFrameSetting data
*
* @param bool $created If True, the results of the Model::find() to create it if it was null
* @return array BbsFrameSetting data
*/
public function getBbsFrameSetting($created) {
Expand All @@ -105,7 +106,7 @@ public function getBbsFrameSetting($created) {
}

/**
* save bbs
* Save BbsFrameSetting
*
* @param array $data received post data
* @return mixed On success Model::$data if its not empty or true, false on failure
Expand Down
11 changes: 7 additions & 4 deletions Model/Behavior/BbsArticleBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class BbsArticleBehavior extends ModelBehavior {
/**
* Update bbs_article_modified and bbs_article_count
*
* @param object $model instance of model
* @param int $bbsId bbses.id
* @param string $bbsKey bbses.key
* @param int $languageId languages.id
Expand Down Expand Up @@ -71,9 +72,9 @@ public function updateBbsByBbsArticle(Model $model, $bbsId, $bbsKey, $languageId
/**
* Update bbs_article_child_count
*
* @param int $rootId RootId for bbs posts
* @param int $status status
* @param int $increment increment
* @param object $model instance of model
* @param int $rootId RootId for root BbsArticle
* @param int $languageId languages.id
* @return mixed On success Model::$data if its not empty or true, false on failure
* @throws InternalErrorException
*/
Expand Down Expand Up @@ -103,6 +104,7 @@ public function updateBbsArticleChildCount(Model $model, $rootId, $languageId) {
/**
* Title of reply
*
* @param object $model instance of model
* @param string $title bbs_articles.title
* @return string bbs_articles.title
*/
Expand All @@ -125,7 +127,8 @@ public function getReplyTitle(Model $model, $title) {
/**
* Content of reply
*
* @param string $title bbs_articles.content
* @param object $model instance of model
* @param string $content bbs_articles.content
* @return string bbs_articles.content
*/
public function getReplyContent(Model $model, $content) {
Expand Down

0 comments on commit cebb557

Please sign in to comment.