PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/user-item/class-lp-user-item.php +90 -440 4.1.6.9 → 4.4.9 View file →
@@ -4,9 +4,9 @@
4 4 * Class LP_User_Item
5 5 *
6 6 * @since 3.0.0
7 7 */
8 -class LP_User_Item extends LP_Abstract_Object_Data implements ArrayAccess {
8 +class LP_User_Item extends LP_Abstract_Object_Data {
9 9 /**
10 10 * Auto increment
11 11 *
12 12 * @var int
@@ -67,14 +67,16 @@
67 67 *
68 68 * @var string
69 69 */
70 70 public $_parent_id = '';
71 -
72 -
73 71 /**
74 - * @var string
72 + * Key get data start time form DB.
75 73 */
76 - protected $_data_key = '';
74 + const KEY_DATA_START_TIME = 'start_time';
75 + /**
76 + * Key get data end time form DB.
77 + */
78 + const KEY_DATA_END_TIME = 'end_time';
77 79
78 80 /**
79 81 * LP_User_Item constructor.
80 82 *
@@ -115,34 +117,13 @@
115 117 $this->set_data( 'item_type', learn_press_get_post_type( $item['item_id'] ) );
116 118 $item_id = $item['item_id'];
117 119 }
118 120
119 - if ( ! empty( $item['start_time'] ) ) {
120 - $this->set_start_time( $item['start_time'] );
121 - } else {
122 - $this->set_start_time( current_time( 'mysql', 1 ) );
123 - }
121 + $this->set_start_time( $item[ self::KEY_DATA_START_TIME ] ?? time() );
122 + $this->set_end_time( $item[ self::KEY_DATA_END_TIME ] ?? '' );
123 + $this->set_user_id( absint( $item['user_id'] ?? get_current_user_id() ) );
124 + $this->set_status( $item['status'] ?? '' );
124 125
125 - if ( ! empty( $item['end_time'] ) ) {
126 - $this->set_end_time( $item['end_time'] );
127 - } else {
128 - $this->set_end_time( null );
129 - }
130 -
131 - if ( ! empty( $item['user_id'] ) ) {
132 - $item['user_id'] = absint( $item['user_id'] );
133 -
134 - $this->set_user_id( $item['user_id'] );
135 - } else {
136 - $this->set_user_id( get_current_user_id() );
137 - }
138 -
139 - if ( ! empty( $item['status'] ) ) {
140 - $this->set_status( $item['status'] );
141 - } else {
142 - $this->set_status( '' );
143 - }
144 -
145 126 if ( ! empty( $item['ref_id'] ) ) {
146 127 $item['ref_id'] = absint( $item['ref_id'] );
147 128
148 129 $this->set_ref_id( $item['ref_id'] );
@@ -164,15 +145,9 @@
164 145 if ( ! empty( $item['access_level'] ) ) {
165 146 $this->set_data( 'access_level', $item['access_level'] );
166 147 }
167 148
168 - if ( ! empty( $item['graduation'] ) ) {
169 - $this->set_data( 'graduation', $item['graduation'] );
170 - }
171 -
172 - $new_data = $this->get_mysql_data();
173 - ksort( $new_data );
174 - $this->_data_key = md5( serialize( $new_data ) );
149 + $this->set_data( 'graduation', $item['graduation'] ?? '' );
175 150 }
176 151
177 152 public function set_user_id( $user_id ) {
178 153 $this->set_data( 'user_id', $user_id );
@@ -220,32 +195,14 @@
220 195 * @param mixed $time .
221 196 *
222 197 * @return $this
223 198 */
224 - public function set_start_time( $time ) {
225 - $this->_set_data_date( 'start_time', $time );
199 + public function set_start_time( $time = '' ): LP_User_Item {
200 + $this->set_data_date( 'start_time', $time );
226 201
227 202 return $this;
228 203 }
229 204
230 - public function get_time( $field, $format = '', $human_diff_time = false ) {
231 - if ( ! $format ) {
232 - $format = get_option( 'date_format' );
233 - }
234 -
235 - $m_time = call_user_func( array( $this, 'get_' . $field ) );
236 - $time = mysql2date( 'G', call_user_func( array( $this, 'get_' . $field . '_gmt' ) ) );
237 - $time_diff = time() - $time;
238 -
239 - if ( $human_diff_time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
240 - $h_time = sprintf( __( '%s ago', 'learnpress' ), human_time_diff( $time ) );
241 - } else {
242 - $h_time = mysql2date( $format, $m_time );
243 - }
244 -
245 - return $h_time;
246 - }
247 -
248 205 /**
249 206 * Get start-time.
250 207 *
251 208 * @param string $format
@@ -250,43 +207,17 @@
250 207 *
251 208 * @param string $format
252 209 * @param bool $local
253 210 *
254 - * @return string|LP_Datetime
211 + * @return string|LP_Datetime|false
255 212 */
256 - public function get_start_time( $format = '', $local = false ) {
257 - $date = $this->get_data( 'start_time' );
213 + public function get_start_time( string $format = '', $local = false ) {
214 + $date = $this->get_data( self::KEY_DATA_START_TIME );
258 215
259 216 return $this->format_time( $date, $format, $local );
260 217 }
261 218
262 219 /**
263 - * @param $time
264 - *
265 - * @deprecated 4.0.0
266 - */
267 - public function set_start_time_gmt( $time ) {
268 - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0.0' );
269 - }
270 -
271 - /**
272 - * @param string $format
273 - *
274 - * @return array|bool|LP_Datetime|mixed|string
275 - * @deprecated
276 - */
277 - public function get_start_time_gmt( $format = '' ) {
278 - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0.0' );
279 -
280 - // $date = $this->get_data_date( 'start_time_gmt' );
281 - // if ( $format ) {
282 - // return $date->is_null() ? false : ( $format = 'i18n' ? learn_press_date_i18n( $date->getTimestamp() ) : $date->format( $format ) );
283 - // }
284 - //
285 - // return $date;
286 - }
287 -
288 - /**
289 220 * Set end-time for item.
290 221 *
291 222 * @param mixed $time
292 223 *
@@ -291,14 +222,10 @@
291 222 * @param mixed $time
292 223 *
293 224 * @return $this
294 225 */
295 - public function set_end_time( $time ) {
296 - if ( $time && '0000-00-00 00:00:00' !== $time ) {
297 - $this->_set_data_date( 'end_time', $time );
298 - } else {
299 - $this->_set_data( 'end_time', '' );
300 - }
226 + public function set_end_time( $time = '' ): LP_User_Item {
227 + $this->set_data_date( 'end_time', $time );
301 228
302 229 return $this;
303 230 }
304 231
@@ -308,18 +235,14 @@
308 235 * @param string $format
309 236 *
310 237 * @return string|LP_Datetime
311 238 */
312 - public function get_end_time( $format = '' ) {
313 - $date = $this->get_data( 'end_time' );
239 + public function get_end_time( string $format = '' ) {
240 + $date = $this->get_data( self::KEY_DATA_END_TIME );
314 241
315 242 return $this->format_time( $date, $format );
316 243 }
317 244
318 - public function get_start_time_local() {
319 -
320 - }
321 -
322 245 /**
323 246 * @param string|int|LP_Datetime $date
324 247 * @param string $format
325 248 * @param bool $local
@@ -338,49 +261,31 @@
338 261 return $format ? $date->format( $format, $local ) : $date;
339 262 }
340 263
341 264 /**
342 - * Get end-time.
343 - *
344 - * @param mixed $time
345 - *
346 - * @deprecated 4.0.0
347 - */
348 - public function set_end_time_gmt( $time ) {
349 - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0.0' );
350 - }
351 -
352 - /**
353 - * Get end-time.
354 - *
355 - * @param string $format
356 - *
357 - * @return string|LP_Datetime
358 - * @deprecated
359 - */
360 - public function get_end_time_gmt( $format = '' ) {
361 - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0.0' );
362 - }
363 -
364 - /**
365 265 * Get expiration time.
366 266 *
367 - * @param string $format
368 - *
369 267 * @return string|LP_Datetime $time
370 268 * @since 3.3.0
269 + * @version 3.3.2
371 270 */
372 - public function get_expiration_time( $format = '' ) {
271 + public function get_expiration_time() {
373 272 $duration = get_post_meta( $this->get_item_id(), '_lp_duration', true );
374 - $start_time = $this->get_start_time( '', false );
273 + $start_time = $this->get_start_time()->getTimestamp();
375 274
376 275 if ( ! absint( $duration ) || ! $start_time ) {
377 - return null;
276 + $expire = null;
277 + } else {
278 + // Convert duration from string to seconds.
279 + if ( ! is_numeric( $duration ) ) {
280 + $duration = strtotime( $duration ) - time();
281 + }
282 +
283 + $expire_time = $start_time + $duration;
284 + $expire = new LP_Datetime( $expire_time );
378 285 }
379 286
380 - $date = new LP_Datetime( $start_time->getPeriod( $duration, true ) );
381 -
382 - return $this->format_time( $date, $format );
287 + return apply_filters( 'learn-press/user-item/expiration-time', $expire, $duration, $this );
383 288 }
384 289
385 290 /**
386 291 * Set item-status.
@@ -406,12 +311,8 @@
406 311 * @editor tungnx
407 312 * @modify 4.1.3
408 313 */
409 314 public function get_status( string $field = 'status', bool $force_cache = false ): string {
410 - /*if ( ! is_null( $this->get_data( $field, null ) && ! $force_cache ) ) {
411 - return $this->get_data( $field );
412 - }*/
413 -
414 315 $got_status = '';
415 316
416 317 try {
417 318 // User is Guest
@@ -418,8 +319,16 @@
418 319 if ( (int) $this->get_user_id() === 0 ) {
419 320 return $got_status;
420 321 }
421 322
323 + if ( LP_COURSE_CPT === $this->get_type() ) {
324 + return $this->get_data( $field );
325 + }
326 +
327 + /*error_log('status user item id: ' . $this->get_id());
328 + error_log('status user item type: ' . $this->get_type());
329 + error_log('status user course status: ' . $this->get_data( $field ));*/
330 +
422 331 $lp_user_item = LP_User_Items_DB::getInstance();
423 332 $filter = new LP_User_Items_Filter();
424 333
425 334 $filter->user_id = $this->get_user_id();
@@ -434,9 +343,9 @@
434 343 }
435 344
436 345 $this->set_data( $field, $got_status );
437 346 } catch ( Throwable $e ) {
438 - LP_Debug::error_log( __FUNCTION__ . ':' . $e->getMessage() );
347 + LP_Debug::error_log( $e );
439 348 }
440 349
441 350 return $got_status;
442 351 }
@@ -445,23 +354,8 @@
445 354 return ! ! $this->get_user_item_id();
446 355 }
447 356
448 357 /**
449 - * @editor tungnx
450 - * @reason comment - not use
451 - */
452 - /*
453 - public function is_available() {
454 - if ( null === $this->_is_available ) {
455 - $user = $this->get_user();
456 - $order = $user->get_course_order( $this->get_item_id() );
457 - $this->_is_available = $order && ( $order->get_status() === 'completed' ) && $this->is_exists();
458 - }
459 -
460 - return $this->_is_available;
461 - }*/
462 -
463 - /**
464 358 * @param string $return
465 359 *
466 360 * @return LP_User|int
467 361 */
@@ -468,15 +362,22 @@
468 362 public function get_user( $return = '' ) {
469 363 return $this->get_data( 'user_id', 0 );
470 364 }
471 365
472 - public function get_course( $return = '' ) {
473 - $cid = $this->get_data( 'ref_id' );
366 + /**
367 + * Get course.
368 + *
369 + * @param string $return
370 + *
371 + * @return bool|LP_Course|int|mixed
372 + */
373 + public function get_course( string $return = '' ) {
374 + $course_id = $this->get_data( 'ref_id', 0 );
474 375 if ( $return == '' ) {
475 - return $cid ? learn_press_get_course( $cid ) : false;
376 + return $course_id ? learn_press_get_course( $course_id ) : false;
476 377 }
477 378
478 - return $cid;
379 + return $course_id;
479 380 }
480 381
481 382 /**
482 383 * @return int
@@ -680,14 +581,8 @@
680 581 */
681 582 $columns = array();
682 583
683 584 foreach ( $this->get_data() as $k => $v ) {
684 - switch ( $k ) {
685 - case 'start_time':
686 - case 'end_time':
687 - $v = is_a( $v, 'LP_Datetime' ) ? $v->toSql( false ) : $v;
688 - break;
689 - }
690 585 $columns[ $k ] = $v;
691 586 }
692 587
693 588 return $columns;
@@ -743,12 +638,18 @@
743 638
744 639 /**
745 640 * Get graduation
746 641 *
747 - * @return string|null
642 + * @param string $context
643 + *
644 + * @return string
748 645 */
749 - public function get_graduation() {
750 - return $this->get_data( 'graduation', '' );
646 + public function get_graduation( string $context = '' ): string {
647 + $grade = $this->get_data( 'graduation', '' );
648 + if ( ! $grade ) {
649 + return '';
650 + }
651 + return $context == 'display' ? learn_press_course_grade_html( $grade, false ) : $grade;
751 652 }
752 653
753 654 /**
754 655 * Update data from memory to database.
@@ -755,18 +656,11 @@
755 656 *
756 657 * @updated 3.1.0
757 658 *
758 659 * @return bool|mixed
759 - * @throws Exception
760 660 */
761 661 public function update( $force = false, $wp_error = false ) {
762 -
763 - $data = $this->get_mysql_data();
764 -
765 - /**
766 - * @since 3.3.0
767 - * Allow filter to modify data
768 - */
662 + $data = $this->get_mysql_data();
769 663 $data = apply_filters( 'learn-press/update-user-item-data', $data, $this->get_user_item_id() );
770 664 $where = array();
771 665
772 666 if ( $this->get_user_item_id() ) {
@@ -772,48 +666,30 @@
772 666 if ( $this->get_user_item_id() ) {
773 667 $where = array( 'user_item_id' => $this->get_user_item_id() );
774 668 }
775 669
776 - $return = learn_press_update_user_item_field( $data, $where );
670 + $rs = learn_press_update_user_item_field( $data, $where );
777 671
778 672 // Clear cache first status
779 673 $this->get_status( 'status', true );
780 674
781 - if ( $return ) {
782 - foreach ( (array) $return as $k => $v ) {
675 + if ( $rs ) {
676 + foreach ( (array) $rs as $k => $v ) {
783 677 $this->_set_data( $k, $v );
784 678 }
785 679 $this->_changes = array();
786 680 }
787 681
788 - /*$data_course = $this->get_parent();
789 - if ( $data_course ) {
790 - $data_course->calculate_course_results();
791 - }*/
792 -
793 - return $return;
682 + return $rs;
794 683 }
795 684
796 - /**
797 - * @editor tungnx
798 - * @reason commnet - not use
799 - * @modify 4.1.2
800 - */
801 - /*
802 - public function is_course_item() {
803 - return learn_press_is_support_course_item_type( $this->get_data( 'item_type' ) );
804 - }*/
805 -
806 685 public function get_status_label( $status = '' ) {
807 686 $statuses = array(
808 - 'enrolled' => esc_html__( 'In Progress', 'learnpress' ),
809 - 'started' => esc_html__( 'In Progress', 'learnpress' ),
810 - 'in-progress' => esc_html__( 'In Progress', 'learnpress' ),
811 - 'purchased' => esc_html__( 'Not Enrolled', 'learnpress' ),
812 - 'completed' => esc_html__( 'Completed', 'learnpress' ),
813 - 'finished' => esc_html__( 'Finished', 'learnpress' ),
814 - 'passed' => esc_html__( 'Passed', 'learnpress' ),
815 - 'failed' => esc_html__( 'Failed', 'learnpress' ),
687 + LP_COURSE_ENROLLED => esc_html__( 'Enrolled', 'learnpress' ),
688 + LP_COURSE_PURCHASED => esc_html__( 'Purchased', 'learnpress' ),
689 + LP_ITEM_COMPLETED => esc_html__( 'Completed', 'learnpress' ),
690 + LP_ITEM_STARTED => esc_html__( 'Started', 'learnpress' ),
691 + LP_COURSE_FINISHED => esc_html__( 'Finished', 'learnpress' ),
816 692 );
817 693
818 694 if ( ! $status ) {
819 695 $status = $this->get_status();
@@ -826,9 +702,9 @@
826 702 * Get time from user started to ended.
827 703 *
828 704 * @param string $context
829 705 *
830 - * @return bool|float|int
706 + * @return bool|int
831 707 */
832 708 public function get_time_interval( $context = '' ) {
833 709 $start = $this->get_start_time();
834 710 $end = $this->get_end_time();
@@ -839,124 +715,13 @@
839 715
840 716 if ( $start->is_null() || $end->is_null() ) {
841 717 return false;
842 718 }
843 - $interval = $end->getTimestamp() - $start->getTimestamp();
844 719
845 - return $interval;
720 + return $end->getTimestamp() - $start->getTimestamp();
846 721 }
847 722
848 - public function get_history() {
849 - return LP_Object_Cache::get(
850 - sprintf(
851 - 'course-item-%s-%s-%s',
852 - $this->get_user_id(),
853 - $this->get_course( 'id' ),
854 - $this->get_id()
855 - ),
856 - 'learn-press/user-course-items'
857 - );
858 - }
859 -
860 723 /**
861 - * @editor tungnx
862 - * @modify 4.1.2
863 - * @reason comment - not use
864 - */
865 - /*
866 - public function count_history() {
867 - if ( $items = $this->get_history() ) {
868 - return sizeof( $items );
869 - }
870 -
871 - return 0;
872 - }*/
873 -
874 - /**
875 - * @editor tungnx
876 - * @modify 4.1.2
877 - * @reason comment - not use
878 - */
879 - /*
880 - public function remove_user_items_history( $keep = 10 ) {
881 - learn_press_remove_user_items_history(
882 - $this->get_item_id(),
883 - $this->get_course( 'id' ),
884 - $this->get_user_id(),
885 - $keep
886 - );
887 - }*/
888 -
889 - /**
890 - * Return number of seconds has exceeded from the expiration time to now.
891 - * If less than or equals to 0 that means the time is exceeded.
892 - * Otherwise, the time is not exceeded.
893 - *
894 - * @return float|int
895 - * @since 3.3.0
896 - */
897 - public function get_exceeded() {
898 - $time = new LP_Datetime();
899 - $current = $time->getTimestamp( false );
900 - $exceeded = $this->get_expiration_time();
901 -
902 - return false !== $exceeded ? $exceeded->getTimestamp() - $current : false;
903 - }
904 -
905 - /**
906 - * Check if user was finished before the expiration time is exceeded.
907 - * If the expiration-time is NULL that mean the course is not set duration.
908 - *
909 - * @return bool|float|int
910 - * @since 3.3.0
911 - * Todo: check remove function
912 - */
913 - public function is_exceeded() {
914 - $expiration = $this->get_expiration_time();
915 - $end = $this->get_end_time();
916 -
917 - if ( ! $expiration ) {
918 - return false;
919 - }
920 -
921 - // If course is not finished then consider end time is current time
922 - if ( ! $end || 0 >= $end->getTimestamp() ) {
923 - $end = new LP_Datetime();
924 - $end = $end->getTimestamp( false );
925 - } else {
926 - $end = $end->getTimestamp();
927 - }
928 -
929 - return $expiration->getTimestamp() - $end;
930 - }
931 -
932 - /**
933 - * Get time remaining for user item.
934 - *
935 - * @param string $return - Optional. What kind of data to return.
936 - *
937 - * @return LP_Duration
938 - * @since 3.3.0
939 - */
940 - public function get_time_remaining( $return = 'object' ) {
941 - $is_exceeded = $this->is_exceeded();
942 - $time = false;
943 -
944 - if ( false !== $is_exceeded ) {
945 - $time = 0 < $is_exceeded ? absint( $is_exceeded ) : 0;
946 - }
947 -
948 - // return apply_filters( 'learn-press/quiz/time-remaining', $remaining, $this->get_item_id(), $this->get_course_id() );
949 - return apply_filters(
950 - 'learn-press/user-item-time-remaining',
951 - $return === 'object' ? new LP_Duration( $time ) : $time,
952 - $this->get_item_id(),
953 - $this->get_parent_id(),
954 - $this->get_user_id()
955 - );
956 - }
957 -
958 - /**
959 724 * Return true of item is completed/finished
960 725 *
961 726 * @param string $status
962 727 *
@@ -973,37 +738,12 @@
973 738 * @modify 4.1.4.1 - should review to improve
974 739 * @version 4.0.1
975 740 */
976 741 public function complete( $status = 'completed' ) {
977 - global $wpdb;
978 -
979 - // $end_time = new LP_Datetime();
980 - // $null_time = null;
981 -
982 742 try {
983 - // if ( ! $this->get_end_time() ) {
984 - $this->set_end_time( current_time( 'mysql', 1 ) );
985 - // }
986 -
743 + $this->set_end_time( time() );
987 744 $this->set_status( $status );
988 745 $this->update();
989 -
990 - /*
991 - $query = $wpdb->prepare(
992 - "SELECT user_item_id
993 - FROM {$wpdb->prefix}learnpress_user_items
994 - WHERE user_id = %d
995 - AND item_id = %d
996 - AND status = %s
997 - GROUP BY user_item_id DESC
998 - LIMIT 1
999 - ",
1000 - $this->get_user_id(),
1001 - $this->get_item_id(),
1002 - $status
1003 - );
1004 -
1005 - return $wpdb->get_var( $query );*/
1006 746 } catch ( Throwable $e ) {
1007 747 error_log( __FUNCTION__ . ':' . $e->getMessage() );
1008 748 return false;
1009 749 }
@@ -1011,45 +751,8 @@
1011 751 return true;
1012 752 }
1013 753
1014 754 /**
1015 - * @editor tungnx
1016 - * @modify 4.1.2
1017 - * @reason comment - not use
1018 - */
1019 - /*
1020 - public function delete_meta_data( $include = '', $exclude = '' ) {
1021 - global $wpdb;
1022 -
1023 - $where = '';
1024 - if ( $include ) {
1025 - settype( $include, 'array' );
1026 - $format = array_fill( 0, sizeof( $include ), '%s' );
1027 - $where .= $wpdb->prepare( ' AND meta_key IN(' . join( ',', $format ) . ')', $include );
1028 - }
1029 -
1030 - if ( $exclude ) {
1031 - settype( $exclude, 'array' );
1032 - $format = array_fill( 0, sizeof( $exclude ), '%s' );
1033 - $where .= $wpdb->prepare( ' AND meta_key IN(' . join( ',', $format ) . ')', $exclude );
1034 - }
1035 -
1036 - $query = $wpdb->prepare(
1037 - "
1038 - DELETE FROM {$wpdb->learnpress_user_itemmeta}
1039 - WHERE learnpress_user_item_id = %d
1040 - {$where}
1041 - ",
1042 - $this->get_user_item_id()
1043 - );
1044 -
1045 - $wpdb->query( $query );
1046 -
1047 - $this->_meta_data = array();
1048 - update_meta_cache( 'learnpress_user_item', $this->get_user_item_id() );
1049 - }*/
1050 -
1051 - /**
1052 755 * Get post type of item.
1053 756 *
1054 757 * @return string
1055 758 */
@@ -1059,88 +762,33 @@
1059 762
1060 763 /**
1061 764 * @return bool
1062 765 */
1063 - public function is_passed() {
1064 - return 'passed' === $this->get_graduation();
766 + public function is_passed(): bool {
767 + return LP_COURSE_GRADUATION_PASSED === $this->get_graduation();
1065 768 }
1066 769
770 + /**
771 + * @param int $decimal
772 + *
773 + * @return mixed|null
774 + */
1067 775 public function get_percent_result( $decimal = 1 ) {
1068 776 return apply_filters(
1069 777 'learn-press/user/item-percent-result',
1070 - sprintf(
1071 - '%s%%',
1072 - round( $this->get_result( 'result' ), $decimal ),
1073 - $this->get_user_id(),
1074 - $this->get_item_id()
1075 - )
778 + sprintf( '%s%', round( $this->get_result( 'result' ), $decimal ) ),
779 + $this->get_user_id(),
780 + $this->get_item_id()
1076 781 );
1077 782 }
1078 783
1079 - /**
1080 - * Calculate expiration time from the start time and duration.
1081 - *
1082 - * @param int|string|LP_Datetime $duration
1083 - *
1084 - * @return LP_Datetime
1085 - * @since 3.3.0
1086 - */
1087 - public function set_duration( $duration ) {
1088 - if ( $duration instanceof LP_Datetime ) {
1089 - $period = $duration->toSql();
1090 - } else {
1091 - $period = $duration;
1092 - }
1093 -
1094 - return $this->get_expiration_time();
1095 - }
1096 -
1097 - public function is_change() {
1098 -
1099 - $new_data = $this->get_mysql_data();
1100 - ksort( $new_data );
1101 -
1102 - return $this->_data_key !== md5( serialize( $new_data ) );
1103 - }
1104 -
1105 - protected function _set_data_date( $key, $value, $extra = false ) {
1106 - if ( $value instanceof LP_Datetime ) {
1107 - $value = $value->getTimestamp();
1108 - } else {
1109 - $value = is_numeric( $value ) ? $value : strtotime( $value );
1110 - }
1111 - $offset = (int) ( get_option( 'gmt_offset', 0 ) * HOUR_IN_SECONDS );
1112 -
1113 - parent::_set_data_date( $key, $value + $offset, $extra );
1114 - }
1115 -
1116 - /**
1117 - * @param $name
1118 - * @param $arguments
1119 - *
1120 - * @return mixed
1121 - */
1122 - public function __call( $name, $arguments ) {
1123 - if ( ! method_exists( $this, $name ) ) {
1124 - $course = $this->get_course();
1125 -
1126 - if ( $course ) {
1127 - $item = $course->get_item( $this->get_item_id() );
1128 -
1129 - if ( is_callable( array( $item, $name ) ) ) {
1130 - return call_user_func_array( array( $item, $name ), $arguments );
1131 - }
1132 - }
1133 - }
1134 -
1135 - return false;
1136 - }
1137 -
1138 784 public function offsetSet( $offset, $value ) {
785 + _deprecated_function( __METHOD__, '4.2.3.5' );
1139 786 // TODO: Implement offsetSet() method.
1140 787 }
1141 788
1142 789 public function offsetGet( $offset ) {
790 + _deprecated_function( __METHOD__, '4.2.3.5' );
1143 791 if ( is_callable( array( $this, 'get_' . $offset ) ) ) {
1144 792 return call_user_func( array( $this, 'get_' . $offset ) );
1145 793 }
1146 794
@@ -1147,12 +795,14 @@
1147 795 return false;
1148 796 }
1149 797
1150 798 public function offsetUnset( $offset ) {
799 + _deprecated_function( __METHOD__, '4.2.3.5' );
1151 800 // TODO: Implement offsetUnset() method.
1152 801 }
1153 802
1154 803 public function offsetExists( $offset ) {
804 + _deprecated_function( __METHOD__, '4.2.3.5' );
1155 805 // TODO: Implement offsetExists() method.
1156 806 }
1157 807 }
1158 808