Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
20.00% |
1 / 5 |
CRAP | |
7.69% |
1 / 13 |
| TaskItem | |
0.00% |
0 / 1 |
|
20.00% |
1 / 5 |
72.71 | |
7.69% |
1 / 13 |
| tableName | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| rules | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| attributeLabels | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| getTask | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| filterValidItems | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 7 |
|||
| <?php | |
| /** | |
| * @link https://www.humhub.org/ | |
| * @copyright Copyright (c) 2018 HumHub GmbH & Co. KG | |
| * @license https://www.humhub.com/licences | |
| * | |
| */ | |
| namespace humhub\modules\tasks\models\checklist; | |
| use Yii; | |
| use humhub\components\ActiveRecord; | |
| use humhub\modules\tasks\models\Task; | |
| use humhub\modules\tasks\permissions\ManageTasks; | |
| /** | |
| * This is the model class for table "task_item". | |
| * | |
| * The followings are the available columns in table 'task_item': | |
| * @property integer $id | |
| * @property integer $task_id | |
| * @property string $title | |
| * @property integer $completed | |
| * @property integer $sort_order | |
| * | |
| * @property Task $task | |
| */ | |
| class TaskItem extends ActiveRecord | |
| { | |
| /** | |
| * @inheritdocs | |
| */ | |
| protected $managePermission = ManageTasks::class; | |
| /** | |
| * @return string the associated database table name | |
| */ | |
| public static function tableName() | |
| { | |
| return 'task_item'; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function rules() | |
| { | |
| return [ | |
| [['task_id', 'title'], 'required'], | |
| [['task_id', 'sort_order', 'completed'], 'integer'], | |
| [['title'], 'string', 'max' => 255], | |
| [['description', 'notes'], 'safe'], | |
| ]; | |
| } | |
| /** | |
| * @return array customized attribute labels (name=>label) | |
| */ | |
| public function attributeLabels() | |
| { | |
| return [ | |
| 'id' => 'ID', | |
| 'title' => Yii::t('TasksModule.models_taskitem', 'Title'), | |
| 'completed' => Yii::t('TasksModule.models_taskitem', 'Completed'), | |
| ]; | |
| } | |
| public function getTask() | |
| { | |
| return $this->hasOne(Task::class, ['id' => 'task_id']); | |
| } | |
| public static function filterValidItems($itemArr) | |
| { | |
| if($itemArr == null) { | |
| return []; | |
| } | |
| $result = []; | |
| foreach ($itemArr as $key => $itemText) { | |
| if($itemText != null && $itemText !== '') { | |
| $result[$key] = $itemText; | |
| } | |
| } | |
| return $result; | |
| } | |
| } |