Skip to content

Commit

Permalink
Merge 58386e7 into caa2037
Browse files Browse the repository at this point in the history
  • Loading branch information
ohga21 committed Aug 23, 2018
2 parents caa2037 + 58386e7 commit 6512268
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Controller/AnnouncementBlockRolePermissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function edit() {
return $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
}
$this->NetCommons->handleValidationError($this->AnnouncementSetting->validationErrors);
$this->request->data['BlockRolePermission'] = Hash::merge(
$this->request->data['BlockRolePermission'] = array_merge(
$permissions['BlockRolePermissions'],
$this->request->data['BlockRolePermission']
);
Expand Down
3 changes: 1 addition & 2 deletions Controller/AnnouncementBlocksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ public function add() {
} else {
//初期データセット
$this->request->data = $this->Announcement->createAll();
$this->request->data = Hash::merge($this->request->data,
$this->AnnouncementSetting->createBlockSetting());
$this->request->data += $this->AnnouncementSetting->createBlockSetting();
$this->request->data['Frame'] = Current::read('Frame');
}
}
Expand Down
3 changes: 1 addition & 2 deletions Controller/AnnouncementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public function edit() {
//初期データセット
if (! $this->request->data = $this->Announcement->getAnnouncement()) {
$this->request->data = $this->Announcement->createAll();
$this->request->data = Hash::merge($this->request->data,
$this->AnnouncementSetting->createBlockSetting());
$this->request->data += $this->AnnouncementSetting->createBlockSetting();
}
$this->request->data['Frame'] = Current::read('Frame');
}
Expand Down
6 changes: 2 additions & 4 deletions Model/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Announcement extends AnnouncementsAppModel {
* @see Model::save()
*/
public function beforeValidate($options = array()) {
$this->validate = Hash::merge($this->validate, array(
$this->validate = array_merge($this->validate, array(
'block_id' => array(
'numeric' => array(
'rule' => array('numeric'),
Expand All @@ -117,7 +117,6 @@ public function beforeValidate($options = array()) {
),
),
));

return parent::beforeValidate($options);
}

Expand Down Expand Up @@ -161,13 +160,12 @@ public function getAnnouncement() {
}
$announcement = $this->find('first', array(
'recursive' => 0,
'fields' => array('Announcement.*'),
'conditions' => $this->getBlockConditionById($conditions),
));
if (!$announcement) {
return $announcement;
}
return Hash::merge($announcement, $this->AnnouncementSetting->getAnnouncementSetting());
return ($announcement + $this->AnnouncementSetting->getAnnouncementSetting());
}

/**
Expand Down
2 changes: 0 additions & 2 deletions Test/Case/Model/Announcement/GetAnnouncementTest.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function testGetAnnouncementWOContentEditable() {

//期待値
$expected = $this->Announcement->findById($announcementId);
$expected = Hash::remove($expected, 'Block');

//テスト実施
$result = $this->Announcement->getAnnouncement();
Expand All @@ -87,7 +86,6 @@ public function testGetAnnouncementContentEditable() {

//期待値
$expected = $this->Announcement->findById($announcementId);
$expected = Hash::remove($expected, 'Block');

//テスト実施
$result = $this->Announcement->getAnnouncement();
Expand Down
2 changes: 1 addition & 1 deletion View/Announcements/edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $announcement = NetCommonsAppController::camelizeKeyRecursive(array('announcemen
<?php echo $this->NetCommonsForm->end(); ?>

<?php if ($this->Workflow->canDelete('Announcements.Announcement', $this->request->data) &&
Hash::get($this->request->data, 'Announcement.id')) : ?>
isset($this->request->data['Announcement']['id'])) : ?>
<div class="panel-footer text-right">
<?php echo $this->element('Announcements.Announcements/delete_form', array(
'url' => NetCommonsUrl::blockUrl(array('action' => 'delete', 'key' => $this->data['Announcement']['key']))
Expand Down
2 changes: 1 addition & 1 deletion View/Elements/AnnouncementBlocks/edit_form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<?php echo $this->Workflow->buttons('Announcement.status', NetCommonsUrl::backToIndexUrl('default_setting_action')); ?>
<?php echo $this->NetCommonsForm->end(); ?>

<?php if (Hash::get($this->request->data, 'Announcement.id')) : ?>
<?php if (isset($this->request->data['Announcement']['id'])) : ?>
<div class="panel-footer text-right">
<?php echo $this->element('Announcements.Announcements/delete_form', array(
'url' => NetCommonsUrl::actionUrl(array(
Expand Down
4 changes: 2 additions & 2 deletions View/Elements/Announcements/edit_form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
<?php echo $this->element('Blocks.public_type'); ?>
<?php echo $this->element(
'Blocks.modifed_info',
array('displayModified' => (bool)Hash::get($this->request->data, 'Announcement.id'))
array('displayModified' => isset($this->request->data['Announcement']['id']))
); ?>
<?php endif;
<?php endif;

0 comments on commit 6512268

Please sign in to comment.