Skip to content

Commit

Permalink
Fix Topic and update writeCurrent,removeUseCurrent method
Browse files Browse the repository at this point in the history
  • Loading branch information
TriangleShooter committed Mar 29, 2017
1 parent 4c3b72f commit 289dd85
Show file tree
Hide file tree
Showing 27 changed files with 218 additions and 317 deletions.
63 changes: 62 additions & 1 deletion Model/Behavior/Nc2ToNc3BaseBehavior.php
Expand Up @@ -454,7 +454,7 @@ protected function _convertChoiceValue($nc2Value, $nc3Choices) {
return null;
}

$nc3Choices = rsort($nc3Choices, SORT_NUMERIC);
rsort($nc3Choices, SORT_NUMERIC);
foreach ($nc3Choices as $nc3Choice) {
if ($nc2Value >= $nc3Choice) {
$nc2Value = $nc3Choice;
Expand Down Expand Up @@ -640,4 +640,65 @@ protected function _convertWYSIWYG($content) {
$body = $content;
return $body;
}

/**
* Write Current.
*
* @param Model $model Model using this behavior.
* @param array $frameMap array data.
* @param string $pluginKey plugin key.
* @return void
* @throws Exception
*/
public function writeCurrent(Model $model, $frameMap, $pluginKey) {
return $this->_writeCurrent($frameMap, $pluginKey);
}

/**
* Remove Current.
*
* @param Model $model Model using this behavior.
* @return void
* @throws Exception
*/
public function removeUseCurrent(Model $model) {
return $this->_removeUseCurrent();
}

/**
* Write Current.
*
* @param array $frameMap array data.
* @param string $pluginKey plugin key.
* @return void
* @throws Exception
*/
protected function _writeCurrent($frameMap, $pluginKey) {
$nc3RoomId = $frameMap['Frame']['room_id'];
Current::write('Frame.key', $frameMap['Frame']['key']);
Current::write('Frame.room_id', $frameMap['Frame']['room_id']);
Current::write('Frame.plugin_key', $pluginKey);

// @see https://github.com/NetCommons3/Topics/blob/3.1.0/Model/Behavior/TopicsBaseBehavior.php#L347
Current::write('Plugin.key', $pluginKey);

// @see https://github.com/NetCommons3/Workflow/blob/3.1.0/Model/Behavior/WorkflowBehavior.php#L171-L175
Current::write('Room.id', $nc3RoomId);
CurrentBase::$permission[$nc3RoomId]['Permission']['content_publishable']['value'] = true;
}

/**
* Remove Current.
*
* @return void
* @throws Exception
*/
protected function _removeUseCurrent() {
// 登録処理で使用しているデータを空に戻す
Current::remove('Frame.key');
Current::remove('Frame.room_id');
Current::remove('Frame.plugin_key');
Current::remove('Plugin.key');
Current::remove('Room.id');
}
}
4 changes: 4 additions & 0 deletions Model/Behavior/Nc2ToNc3CircularNoticeBehavior.php
Expand Up @@ -84,6 +84,10 @@ public function generateNc3CircularNoticeFrameSettingData(Model $model, $nc2Circ
'public_type' => '1',
'created_user' => $Nc2ToNc3User->getCreatedUser($nc2CircularBlock['Nc2CircularBlock'])
],
'BlocksLanguage' => [
'language_id' => '',
'name' => ''
],
'CircularNoticeFrameSetting' => [
'id' => '',
'frame_key' => $frameMap['Frame']['key'],
Expand Down
1 change: 1 addition & 0 deletions Model/Nc2ToNc3.php
Expand Up @@ -236,6 +236,7 @@ public function migration($data) {
'Nc2ToNc3Search',
'Nc2ToNc3Task',
'Nc2ToNc3Video',
'Nc2ToNc3Topic',
];

foreach ($migrationModelNames as $migrationModelName) {
Expand Down
45 changes: 4 additions & 41 deletions Model/Nc2ToNc3Faq.php
Expand Up @@ -124,7 +124,7 @@ private function __saveFaqFromNc2($nc2Faqs) {
continue;
}

$this->__writeCurrent($frameMap, 'faqs');
$this->writeCurrent($frameMap, 'faqs');

$BlocksLanguage->create();
if (!$Faq->saveFaq($data)) {
Expand Down Expand Up @@ -167,7 +167,7 @@ private function __saveFaqFromNc2($nc2Faqs) {
throw $ex;
}
}
$this->__removeUseCurrent();
$this->removeUseCurrent();

$this->writeMigrationLog(__d('nc2_to_nc3', ' Faq data Migration end.'));

Expand Down Expand Up @@ -199,7 +199,7 @@ private function __saveFaqBlockFromNc2($nc2FaqBlocks) {

$nc2BlockId = $nc2FaqBlock['Nc2FaqBlock']['block_id'];
$frameMap = $Nc2ToNc3Frame->getMap($nc2BlockId);
$this->__writeCurrent($frameMap, 'faqs');
$this->writeCurrent($frameMap, 'faqs');

if (!$FaqFrameSetting->saveFaqFrameSetting($data)) {
$message = $this->getLogArgument($nc2FaqBlock) . "\n" .
Expand All @@ -226,48 +226,11 @@ private function __saveFaqBlockFromNc2($nc2FaqBlocks) {
throw $ex;
}
}
$this->__removeUseCurrent();
$this->removeUseCurrent();

$this->writeMigrationLog(__d('nc2_to_nc3', ' FaqFrameSetting data Migration end.'));

return true;
}

/**
* Write Current.
*
* @param array $frameMap array data.
* @param string $pluginKey plugin key.
* @return void
* @throws Exception
*/
private function __writeCurrent($frameMap, $pluginKey) {
$nc3RoomId = $frameMap['Frame']['room_id'];
Current::write('Frame.key', $frameMap['Frame']['key']);
Current::write('Frame.room_id', $frameMap['Frame']['room_id']);
Current::write('Frame.plugin_key', $pluginKey);

// @see https://github.com/NetCommons3/Topics/blob/3.1.0/Model/Behavior/TopicsBaseBehavior.php#L347
Current::write('Plugin.key', $pluginKey);

// @see https://github.com/NetCommons3/Workflow/blob/3.1.0/Model/Behavior/WorkflowBehavior.php#L171-L175
Current::write('Room.id', $nc3RoomId);
CurrentBase::$permission[$nc3RoomId]['Permission']['content_publishable']['value'] = true;
}

/**
* Remove Current.
*
* @return void
* @throws Exception
*/
private function __removeUseCurrent() {
// 登録処理で使用しているデータを空に戻す
Current::remove('Frame.key');
Current::remove('Frame.room_id');
Current::remove('Frame.plugin_key');
Current::remove('Plugin.key');
Current::remove('Room.id');
}
}

41 changes: 2 additions & 39 deletions Model/Nc2ToNc3Iframe.php
Expand Up @@ -100,7 +100,7 @@ private function __saveIframeFromNc2($nc2Iframes) {

$nc2BlockId = $nc2Iframe['Nc2Iframe']['block_id'];
$frameMap = $Nc2ToNc3Frame->getMap($nc2BlockId);
$this->__writeCurrent($frameMap, 'iframes');
$this->writeCurrent($frameMap, 'iframes');

$Frame->create();
if (!$Iframe->saveIframe($data)) {
Expand Down Expand Up @@ -146,47 +146,10 @@ private function __saveIframeFromNc2($nc2Iframes) {
}
}

$this->__removeUseCurrent();
$this->removeUseCurrent();

$this->writeMigrationLog(__d('nc2_to_nc3', ' Iframe data Migration end.'));

return true;
}

/**
* Write Current.
*
* @param array $frameMap array data.
* @param string $pluginKey plugin key.
* @return void
* @throws Exception
*/
private function __writeCurrent($frameMap, $pluginKey) {
$nc3RoomId = $frameMap['Frame']['room_id'];
Current::write('Frame.key', $frameMap['Frame']['key']);
Current::write('Frame.room_id', $frameMap['Frame']['room_id']);
Current::write('Frame.plugin_key', $pluginKey);

// @see https://github.com/NetCommons3/Topics/blob/3.1.0/Model/Behavior/TopicsBaseBehavior.php#L347
Current::write('Plugin.key', $pluginKey);

// @see https://github.com/NetCommons3/Workflow/blob/3.1.0/Model/Behavior/WorkflowBehavior.php#L171-L175
Current::write('Room.id', $nc3RoomId);
CurrentBase::$permission[$nc3RoomId]['Permission']['content_publishable']['value'] = true;
}

/**
* Remove Current.
*
* @return void
* @throws Exception
*/
private function __removeUseCurrent() {
// 登録処理で使用しているデータを空に戻す
Current::remove('Frame.key');
Current::remove('Frame.room_id');
Current::remove('Frame.plugin_key');
Current::remove('Plugin.key');
Current::remove('Room.id');
}
}
43 changes: 3 additions & 40 deletions Model/Nc2ToNc3Link.php
Expand Up @@ -124,7 +124,7 @@ private function __saveLinkFromNc2($nc2Linklists) {
continue;
}

$this->__writeCurrent($frameMap, 'links');
$this->writeCurrent($frameMap, 'links');

$LinkBlock->create();
$BlocksLanguage->create();
Expand Down Expand Up @@ -173,7 +173,7 @@ private function __saveLinkFromNc2($nc2Linklists) {
}
}

$this->__removeUseCurrent();
$this->removeUseCurrent();

$this->writeMigrationLog(__d('nc2_to_nc3', ' Link data Migration end.'));

Expand Down Expand Up @@ -248,48 +248,11 @@ private function __saveLinkFrameSettingFromNc2($nc2LinklistBlocks) {
}
}

$this->__removeUseCurrent();
$this->removeUseCurrent();

$this->writeMigrationLog(__d('nc2_to_nc3', ' LinkFrameSetting data Migration end.'));

return true;
}

/**
* Write Current.
*
* @param array $frameMap array data.
* @param string $pluginKey plugin key.
* @return void
* @throws Exception
*/
private function __writeCurrent($frameMap, $pluginKey) {
$nc3RoomId = $frameMap['Frame']['room_id'];
Current::write('Frame.key', $frameMap['Frame']['key']);
Current::write('Frame.room_id', $frameMap['Frame']['room_id']);
Current::write('Frame.plugin_key', $pluginKey);

// @see https://github.com/NetCommons3/Topics/blob/3.1.0/Model/Behavior/TopicsBaseBehavior.php#L347
Current::write('Plugin.key', $pluginKey);

// @see https://github.com/NetCommons3/Workflow/blob/3.1.0/Model/Behavior/WorkflowBehavior.php#L171-L175
Current::write('Room.id', $nc3RoomId);
CurrentBase::$permission[$nc3RoomId]['Permission']['content_publishable']['value'] = true;
}

/**
* Remove Current.
*
* @return void
* @throws Exception
*/
private function __removeUseCurrent() {
// 登録処理で使用しているデータを空に戻す
Current::remove('Frame.key');
Current::remove('Frame.room_id');
Current::remove('Frame.plugin_key');
Current::remove('Plugin.key');
Current::remove('Room.id');
}
}

42 changes: 2 additions & 40 deletions Model/Nc2ToNc3PhotoAlbum.php
Expand Up @@ -226,7 +226,7 @@ private function __savePhotoAlbumFromNc2($nc2PhotoalbumAlbums) {
$data['PhotoAlbum']['block_id'] = $nc3Block['Block']['id'];
Current::write('Block.id', $nc3Block['Block']['id']);

$this->__writeCurrent($frameMap, 'photo_albums');
$this->writeCurrent($frameMap, 'photo_albums');

$PhotoAlbum->create();
$PhotoAlbum->validate = [];
Expand Down Expand Up @@ -270,49 +270,11 @@ private function __savePhotoAlbumFromNc2($nc2PhotoalbumAlbums) {
}
}

$this->__removeUseCurrent();
$this->removeUseCurrent();

$this->writeMigrationLog(__d('nc2_to_nc3', ' PhotoAlbum data Migration end.'));

return true;
}

/**
* Write Current.
*
* @param array $frameMap array data.
* @param string $pluginKey plugin key.
* @return void
* @throws Exception
*/
private function __writeCurrent($frameMap, $pluginKey) {
$nc3RoomId = $frameMap['Frame']['room_id'];
Current::write('Frame.key', $frameMap['Frame']['key']);
Current::write('Frame.room_id', $frameMap['Frame']['room_id']);
Current::write('Frame.plugin_key', $pluginKey);

// @see https://github.com/NetCommons3/Topics/blob/3.1.0/Model/Behavior/TopicsBaseBehavior.php#L347
Current::write('Plugin.key', $pluginKey);

// @see https://github.com/NetCommons3/Workflow/blob/3.1.0/Model/Behavior/WorkflowBehavior.php#L171-L175
Current::write('Room.id', $nc3RoomId);
CurrentBase::$permission[$nc3RoomId]['Permission']['content_publishable']['value'] = true;
}

/**
* Remove Current.
*
* @return void
* @throws Exception
*/
private function __removeUseCurrent() {
// 登録処理で使用しているデータを空に戻す
Current::remove('Frame.key');
Current::remove('Frame.room_id');
Current::remove('Frame.plugin_key');
Current::remove('Plugin.key');
Current::remove('Room.id');
Current::remove('Block.id');
}
}

0 comments on commit 289dd85

Please sign in to comment.