Ejemplo n.º 1
0
	/**
	 * Constructor
	 *
	 *	@param string      $table  name of the table in the db schema relating to child class
	 *	@param string      $key    name of the primary key field in the table
	 *	@param CBdatabase  $db     CB Database object
	 */
	public function __construct( $table, $key, &$db = null ) {
		parent::__construct( $table, $key, $db );
	}
Ejemplo n.º 2
0
	/**
	 * Converts the validity of a timed item into the most appropriate unit period:
	 * Days, Weeks, Months or Years in 1-90 D, 1-52 W, 1-24 M, 1-5 Y
	 *
	 * @param  cbpaidTimed  $cbpaidTimed   object for validity
	 * @param  string       $varName       name of variable ( 'validity' or 'first_validity')
	 * @return string                      XX D, XX W, XX M, X Y as appropriate
	 */
	private function validityToYmwdPeriod( &$cbpaidTimed, $varName ) {
		list($y, $c, $d, $h, $m, $s) = $cbpaidTimed->getValidity( $varName );
		if ( ( $s == 0 ) && ( $m == 0 ) && ( ( $h % 24 ) == 0 ) ) {
			$d	= $d + ( (int) ( $h / 24 ) );
			if ( ( $d && $c ) || ( $c && $y ) || ( $y && $d ) ) {
				trigger_error('trying to subscribe ARB to subscriptions of mixed days and months duration.', E_USER_WARNING );
			}
		} else {
			trigger_error('trying to subscribe ARB to subscriptions of non-day-multiple duration.', E_USER_WARNING );
		}
		if ( $d && ( ( $d % 7 ) == 0 ) ) {
			$w	=	$d / 7;
			$d	=	0;
		} else {
			$w	=	0;
		}
		if ( $d ) {
			$ymwd = $d . ' D';
		} elseif ( $w ) {
			$ymwd = $w . ' W';
		} elseif ( $c ) {
			$ymwd = $c . ' M';
		} elseif ( $y ) {
			$ymwd = $y . ' Y';
		} else {
			$ymwd = '0 D';
		}
		return $ymwd;
	}