예제 #1
0
파일: util.php 프로젝트: uzura8/flockbird
 /**
  * @dataProvider check_is_reduced_public_flag_range_provider
  */
 public function test_check_is_reduced_public_flag_range($original_public_flag = null, $changed_public_flag = null, $expected = null)
 {
     $test = Site_Util::check_is_reduced_public_flag_range($original_public_flag, $changed_public_flag);
     $this->assertEquals($expected, $test);
 }
예제 #2
0
파일: orm.php 프로젝트: uzura8/flockbird
 public static function check_properties_updated(\Orm\Model $obj, $check_properties)
 {
     if (empty($check_properties)) {
         return false;
     }
     $check_properties = (array) $check_properties;
     foreach ($check_properties as $key => $property) {
         if (is_array($property)) {
             $conditions = $property;
             $property = $key;
             foreach ($conditions as $condition => $value) {
                 if (!$obj->is_changed($property)) {
                     continue;
                 }
                 if ($condition == 'ignore_property') {
                     if ($obj->is_changed($value)) {
                         continue;
                     }
                     return true;
                 }
                 if ($condition == 'ignore_value') {
                     list($before, $after) = \Util_Orm::get_changed_values($obj, $property);
                     if ($value == 'reduced_public_flag_range') {
                         if (Site_Util::check_is_reduced_public_flag_range($before, $after)) {
                             continue;
                         }
                     } elseif ($value == 'reduced_num') {
                         if (preg_match('/`' . $property . '`\\s+\\-\\s+1/', $after)) {
                             continue;
                         }
                         if (is_numeric($before) && is_numeric($after) && $before > $after) {
                             continue;
                         }
                     }
                     return true;
                 }
             }
         } else {
             if ($obj->is_changed($property)) {
                 return true;
             }
         }
     }
     return false;
 }
예제 #3
0
 public static function get_public_flag_for_update_with_check_child_data($public_flag, Model_Timeline $obj)
 {
     $check_target_types = array(\Config::get('timeline.types.album_image'));
     if (!in_array($obj->type, $check_target_types)) {
         return false;
     }
     $public_flag_range_max = Model_TimelineChildData::get_public_flag_range_max4timeline_id($obj->id);
     if ($public_flag_range_max === false) {
         return $public_flag;
     }
     if (\Site_Util::check_is_reduced_public_flag_range($public_flag_range_max, $public_flag)) {
         return $public_flag_range_max;
     }
     return $public_flag;
 }