Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Controller/TaskContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ public function edit() {
return $this->throwBadRequest();
}

$calendarKey = $taskContent['TaskContent']['calendar_key']; //ADD カレンダ連携キーの取り出し
//ADD カレンダ連携キーの取り出し
$calendarKey = $taskContent['TaskContent']['calendar_key'];
$taskContent['TaskContent']['use_calendar'] = ($calendarKey == "") ? 0 : 1;
if (! $this->request->data) {
$this->request->data = $taskContent;
Expand All @@ -173,7 +174,8 @@ public function edit() {
$this->_taskSetting['TaskSetting']['task_key'];
$this->request->data['TaskContent']['key'] = $key;

$this->request->data['TaskContent']['calendar_key'] = $calendarKey; //ADD カレンダー連携キー転写
//ADD カレンダー連携キー転写
$this->request->data['TaskContent']['calendar_key'] = $calendarKey;

// set status
$status = $this->Workflow->parseStatus();
Expand Down
9 changes: 6 additions & 3 deletions Controller/TaskContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ private function __list($conditions) {
$params = array();
$afterOrder = array(
'TaskContent.task_end_date' => 'asc',
'TaskContent.title' => 'asc',
'TaskContent.priority' => 'desc',
'TaskContent.progress_rate' => 'desc',
'TaskContent.title' => 'asc',
'TaskContent.modified' => 'desc'
);

Expand Down Expand Up @@ -242,9 +243,11 @@ private function __list($conditions) {
$params = $this->__setTaskChargeContents($params, $userParam);

// ToDo一覧を取得
$taskContents = $this->TaskContent->getTaskContentList($params, $order);
$results = $this->TaskContent->getTaskContentList($params, $order);
$taskContents = Hash::extract($results, 'tasks');

// 期限間近のToDo一覧を取得
$deadLineTasks = Hash::extract($taskContents, '{n}.TaskContents.{n}[isDeadLine=' . true . ']');
$deadLineTasks = Hash::extract($results, 'deadLineTasks');

// 期限間近のToDo一覧
$this->set('deadLineTasks', $deadLineTasks);
Expand Down
22 changes: 14 additions & 8 deletions Model/TaskContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ protected function _getValidateTaskDate($validate = array()) {
* @return array
*/
public function getTaskContentList($params = array(), $order = array()) {
$results = array();
$conditions = $this->getConditions(Current::read('Block.id'), $params);

$taskContents = $this->find('all',
Expand Down Expand Up @@ -409,6 +410,8 @@ public function getTaskContentList($params = array(), $order = array()) {
$isDeadLine = $this->isDeadLine($taskContent['TaskContent']['date_color']);
$addedTaskContents[] = array_merge($taskContent, array('isDeadLine' => $isDeadLine));
}
// 期限間近・期限切れの一覧を取得
$deadLineTasks = Hash::extract($addedTaskContents, '{n}[isDeadLine=' . true . ']');

// カテゴリIDがキーのコンテンツ連想配列を生成
$sortedTaskContents = Hash::combine(
Expand Down Expand Up @@ -442,7 +445,7 @@ public function getTaskContentList($params = array(), $order = array()) {
));
$categoryRates = Hash::combine($categoryData, '{n}.TaskContent.category_id', '{n}.TaskContent');

$results = array();
$resultArr = array();
foreach ($categories as $category) {
$result = array();
if (isset($sortedTaskContents[$category['id']])) {
Expand All @@ -459,10 +462,13 @@ public function getTaskContentList($params = array(), $order = array()) {
$categoryLangArr, $category['id'], array('name' => __d('tasks', 'No category'))
);
$result['Category']['category_priority'] = $categoryPriority;
$results[] = $result;
$resultArr[] = $result;
}
}

$results['deadLineTasks'] = $deadLineTasks;
$results['tasks'] = $resultArr;

return $results;
}

Expand Down Expand Up @@ -652,11 +658,11 @@ public function saveContent($data) {
//カレンダー連携ここから ADD
$cmd = 'del';
if ($data['TaskContent']['is_date_set']) {
$cmd =($data['TaskContent']['use_calendar']) ? 'save' : 'del';
$cmd = ($data['TaskContent']['use_calendar']) ? 'save' : 'del';
}
if ($cmd==='save') {
if ($cmd === 'save') {
//実施期間設定あり&&カレンダー登録する
$this->loadModels([
$this->loadModels([
'CalendarActionPlan' => 'Calendars.CalendarActionPlan',
]);

Expand Down Expand Up @@ -718,7 +724,7 @@ public function saveContent($data) {
'isDelRepeat' => false, //tasksはfalse固定
));
$delCalendarKey = $this->CalendarDeleteActionPlan->deletePlanForLink($data);
// if ($data['TaskContent']['calendar_key'] == $delCalendarKey) {
//if ($data['TaskContent']['calendar_key'] == $delCalendarKey) {
//削除が成功したので、calenar_keyをクリアし、use_calendarをOFFにして、
//TaskContentにsave(update)しておく。
$data['TaskContent']['calendar_key'] = '';
Expand All @@ -728,7 +734,7 @@ public function saveContent($data) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
$data['TaskContent'] = $savedData['TaskContent'];
// }
//}
$this->CalendarDeleteActionPlan->Behaviors->unload('Calendars.CalendarLink');
} else {
//calendar_keyが記録されていないので、なにもしない
Expand Down Expand Up @@ -861,7 +867,7 @@ public function deleteContentByKey($key) {
}

//カレンダー連携ここから ADD
$this->loadModels([
$this->loadModels([
'CalendarDeleteActionPlan' => 'Calendars.CalendarDeleteActionPlan',
]);
//削除用settings指定
Expand Down
51 changes: 28 additions & 23 deletions Test/Fixture/CalendarEventContentForTaskFixture.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?php
/**
* CalendarEventContentFixture
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author AllCreator <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
* CalendarEventContentForTaskFixture
*/

App::uses('CalendarEventContentFixture', 'Calendars.Test/Fixture');
Expand All @@ -15,27 +9,28 @@
* Summary for CalendarEventContentFixture
*/
class CalendarEventContentForTaskFixture extends CalendarEventContentFixture {
/**
* Plugin key
*
* @var string
*/

/**
* Plugin key
*
* @var string
*/
public $pluginKey = 'calendars';

/**
* Model name
*
* @var string
*/
/**
* Model name
*
* @var string
*/
public $name = 'CalendarEventContents';

/**
* Full Table Name
*
* @var string
*/
/**
* Full Table Name
*
* @var string
*/
public $table = 'calendar_event_contents';

/**
* Records
*
Expand All @@ -54,4 +49,14 @@ class CalendarEventContentForTaskFixture extends CalendarEventContentFixture {
),
);

/**
* Initialize the fixture.
*
* @return void
*/
public function init() {
require_once App::pluginPath('Calendars') . 'Config' . DS . 'Schema' . DS . 'schema.php';
$this->fields = (new CalendarsSchema())->tables[Inflector::tableize($this->name)];
parent::init();
}
}
50 changes: 27 additions & 23 deletions Test/Fixture/CalendarEventForTaskFixture.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?php
/**
* CalendarEventFixture
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author AllCreator <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
* CalendarEventForTaskFixture
*/

App::uses('CalendarEventFixture', 'Calendars.Test/Fixture');
Expand All @@ -16,27 +10,27 @@
*/
class CalendarEventForTaskFixture extends CalendarEventFixture {

/**
* Plugin key
*
* @var string
*/
/**
* Plugin key
*
* @var string
*/
public $pluginKey = 'calendars';

/**
* Model name
*
* @var string
*/
/**
* Model name
*
* @var string
*/
public $name = 'CalendarEvents';

/**
* Full Table Name
*
* @var string
*/
/**
* Full Table Name
*
* @var string
*/
public $table = 'calendar_events';

/**
* Records
*
Expand Down Expand Up @@ -944,4 +938,14 @@ class CalendarEventForTaskFixture extends CalendarEventFixture {
),
);

/**
* Initialize the fixture.
*
* @return void
*/
public function init() {
require_once App::pluginPath('Calendars') . 'Config' . DS . 'Schema' . DS . 'schema.php';
$this->fields = (new CalendarsSchema())->tables[Inflector::tableize($this->name)];
parent::init();
}
}
53 changes: 29 additions & 24 deletions Test/Fixture/CalendarEventShareUserForTaskFixture.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
<?php
/**
* CalendarEventShareUserFixture
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author AllCreator <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/

App::uses('CalendarEventShareUserFixture', 'Calendars.Test/Fixture');
App::uses('CalendarEventShareUserForTaskFixture', 'Calendars.Test/Fixture');

/**
* Summary for CalendarEventShareUserFixture
*/
class CalendarEventShareUserForTaskFixture extends CalendarEventShareUserFixture {

/**
* Plugin key
*
* @var string
*/
/**
* Plugin key
*
* @var string
*/
public $pluginKey = 'calendars';

/**
* Model name
*
* @var string
*/
/**
* Model name
*
* @var string
*/
public $name = 'CalendarEventShareUsers';

/**
* Full Table Name
*
* @var string
*/
/**
* Full Table Name
*
* @var string
*/
public $table = 'calendar_event_share_users';

/**
* Records
*
Expand All @@ -55,11 +49,22 @@ class CalendarEventShareUserForTaskFixture extends CalendarEventShareUserFixture
array(
'id' => 2,
'calendar_event_id' => 27,
'share_user' => 3, //編集長と共有
'share_user' => 3,
'created_user' => 1,
'created' => '2016-03-24 07:09:58',
'modified_user' => 1,
'modified' => '2016-03-24 07:09:58'
),
);

/**
* Initialize the fixture.
*
* @return void
*/
public function init() {
require_once App::pluginPath('Calendars') . 'Config' . DS . 'Schema' . DS . 'schema.php';
$this->fields = (new CalendarsSchema())->tables[Inflector::tableize($this->name)];
parent::init();
}
}
Loading