Пример #1
0
	/**
	 * Copy the named array or object content into this object as vars
	 * only existing vars of object are filled.
	 * When undefined in array, object variables are kept.
	 *
	 * WARNING: DOES addslashes / escape BY DEFAULT
	 *
	 * Can be overridden or overloaded.
	 *
	 * @param  array|object  $array         The input array or object
	 * @param  string        $ignore        Fields to ignore
	 * @param  string        $prefix        Prefix for the array keys
	 * @return boolean                      TRUE: ok, FALSE: error on array binding
	 */
	public function bind( $array, $ignore = '', $prefix = null )
	{
		$bind								=	parent::bind( $array, $ignore, $prefix );

		// Bind the custom duration to duration if it exists
		if ( $bind ) {
			if ( is_array( $array ) && isset( $array['_custom_duration'] ) ) {
				$this->_custom_duration		=	$array['_custom_duration'];
			} elseif ( isset( $array->_custom_duration ) ) {
				$this->_custom_duration		=	$array->_custom_duration;
			}

			if ( $this->_custom_duration !== null ) {
				$this->duration				=	$this->_custom_duration;
				$this->_custom_duration		=	null;
			}
		}

		return $bind;
	}
Пример #2
0
	/**
	 * get or set the kunena post object
	 *
	 * @param \KunenaForumMessage|null $post
	 * @return \KunenaForumMessage|null
	 */
	public function post( $post = null )
	{
		if ( $post !== null ) {
			$this->_post		=	$post;

			$data				=	array();

			foreach ( $this->_post as $k => $v ) {
				switch ( $k ) {
					case 'userid':
						$k		=	'user_id';
						break;
					case 'catid':
						$k		=	'category';
						break;
					case 'time':
						$k		=	'date';
						$v		=	Application::Date( $v, 'UTC' )->format( 'Y-m-d H:i:s' );
						break;
					case 'hold':
						$k		=	'published';
						$v		=	( $v == 0 ? 1 : 0 );
						break;
				}

				$data[$k]		=	$v;
			}

			parent::bind( $data );
		}

		return $this->_post;
	}
Пример #3
0
	/**
	 * get or set the kunena category object
	 *
	 * @param \KunenaForumCategory|null $category
	 * @return \KunenaForumCategory|null
	 */
	public function category( $category = null )
	{
		if ( $category !== null ) {
			$this->_category	=	$category;

			$data				=	array();

			foreach ( $this->_category as $k => $v ) {
				if ( $k == 'parent_id' ) {
					$k			=	'parent';
				}

				$data[$k]		=	$v;
			}

			parent::bind( $data );
		}

		return $this->_category;
	}