/** * @dataProvider array_in_array_provider */ public function test_array_in_array($targets = null, $haystacks = null, $expected = null) { $test = Util_Array::array_in_array($targets, $haystacks); if ($expected === true) { $this->assertTrue($test); } if ($expected === false) { $this->assertFalse($test); } else { $this->assertEquals($expected, $test); } }
public static function check_ids_in_models($target_ids, $objs, $id_column_name = 'id') { return Util_Array::array_in_array($target_ids, self::conv_col2array($objs, $id_column_name)); }
public static function save_with_relations($album_id, \Model_Member $member = null, $public_flag = null, $file_path = null, $timeline_type_key = 'album_image', $optional_values = array()) { if (!\Util_Array::array_in_array(array_keys($optional_values), array('name', 'shot_at', 'shot_at_time', 'public_flag'))) { throw new \InvalidArgumentException('Parameter optional_values is invalid.'); } if (is_null($public_flag)) { $public_flag = isset($optional_values['public_flag']) ? $optional_values['public_flag'] : conf('public_flag.default'); } $album = null; if (empty($member)) { $album = Model_Album::find($album_id, array('related' => 'member')); $member = $album->member; } $options = \Site_Upload::get_uploader_options($member->id, 'ai', $album_id); $uploadhandler = new \Site_Uploader($options); $file = $uploadhandler->save($file_path); if (!empty($file->error)) { throw new \FuelException($file->error); } $self = new self(); $self->album_id = $album_id; $self->file_name = $file->name; $self->public_flag = $public_flag; $self->shot_at = self::get_shot_at_for_insert($file->shot_at, isset($optional_values['shot_at_time']) ? $optional_values['shot_at_time'] : null, isset($optional_values['shot_at']) ? $optional_values['shot_at'] : null); $self->save(); // カバー写真の更新 if ($timeline_type_key == 'album_image_profile') { if (!$album) { $album = Model_Album::find($album_id); } $album->cover_album_image_id = $self->id; $album->save(); } // timeline 投稿 if (\Module::loaded('timeline')) { switch ($timeline_type_key) { case 'album_image_profile': $timeline_foreign_id = $self->id; $timeline_child_foreign_ids = array(); break; case 'album': case 'album_image': default: $timeline_foreign_id = $self->album->id; $timeline_child_foreign_ids = array($self->id); break; } \Timeline\Site_Model::save_timeline($member->id, $public_flag, $timeline_type_key, $timeline_foreign_id, $self->updated_at, null, null, $timeline_child_foreign_ids); } return array($self, $file); }