示例#1
0
 /**
  * Copy the named array or object content into this object as vars
  * All $arr values are filled in vars of $this->_cbuser
  *
  * @access private this is just to be usable by UserTable::loadUsersMatchingIdIntoList()
  *
  * @param  array               $arr    The input array
  */
 public function bindThisUserFromDbArray($arr)
 {
     $this->_cbuser = new UserTable($this->_db);
     $this->_cbuser->bindThisUserFromDbArray($arr);
 }
示例#2
0
	/**
	 * @param UserTable  $user
	 * @param CBuser     $cbUser
	 * @param FieldTable $field
	 * @param string     $reason
	 * @param bool       $forceNoPost
	 * @return array|mixed|string
	 */
	private function getFieldValue( $user, $cbUser, $field, $reason, $forceNoPost = false )
	{
		global $_PLUGINS;

		static $values											=	array();

		$fieldId												=	(int) $field->get( 'fieldid' );
		$userId													=	(int) $user->get( 'id' );

		if ( ! isset( $values[$fieldId][$userId][$reason][$forceNoPost] ) ) {
			if ( ! ( $field->params instanceof ParamsInterface ) ) {
				$field->params									=	new Registry( $field->params );
			}

			$fieldValue											=	null;

			$values[$fieldId][$userId][$reason][$forceNoPost]	=	$fieldValue;

			$post												=	$this->getInput()->getNamespaceRegistry( 'post' );

			if ( ( ! $forceNoPost ) && in_array( $reason, array( 'register', 'edit' ) ) && ( $post->count() && in_array( $this->input( 'view', null, GetterInterface::STRING ), array( 'saveregisters', 'saveuseredit' ) ) ) ) {
				$postUser										=	new UserTable();

				foreach ( array_keys( get_object_vars( $user ) ) as $k ) {
					if ( substr( $k, 0, 1 ) != '_' ) {
						$postUser->set( $k, $user->get( $k ) );
					}
				}

				if ( ! $post->get( $field->get( 'name' ) ) ) {
					$post->set( $field->get( 'name' ), null );
				}

				$postUser->bindThisUserFromDbArray( $post->asArray() );

				$fieldValue										=	$postUser->get( $field->get( 'name' ) );

				if ( is_array( $fieldValue ) ) {
					$fieldValue									=	implode( '|*|', $fieldValue );
				}

				if ( $fieldValue === null ) {
					$field->set( '_noCondition', true );

					$fieldValue									=	$_PLUGINS->callField( $field->get( 'type' ), 'getFieldRow', array( &$field, &$postUser, 'php', 'none', 'profile', 0 ), $field );

					$field->set( '_noCondition', false );

					if ( is_array( $fieldValue ) ) {
						$fieldValue								=	array_shift( $fieldValue );

						if ( is_array( $fieldValue ) ) {
							$fieldValue							=	implode( '|*|', $fieldValue );
						}
					}

					if ( $fieldValue === null ) {
						$fieldValue								=	$this->getFieldValue( $user, $cbUser, $field, $reason, true );
					}
				}
			} else {
				$fieldValue										=	$user->get( $field->get( 'name' ) );

				if ( is_array( $fieldValue ) ) {
					$fieldValue									=	implode( '|*|', $fieldValue );
				}

				if ( $fieldValue === null ) {
					$field->set( '_noCondition', true );

					$fieldValue									=	$_PLUGINS->callField( $field->get( 'type' ), 'getFieldRow', array( &$field, &$user, 'php', 'none', 'profile', 0 ), $field );

					$field->set( '_noCondition', false );

					if ( is_array( $fieldValue ) ) {
						$fieldValue								=	array_shift( $fieldValue );

						if ( is_array( $fieldValue ) ) {
							$fieldValue							=	implode( '|*|', $fieldValue );
						}
					}
				}
			}

			$values[$fieldId][$userId][$reason][$forceNoPost]	=	$fieldValue;
		}

		return $values[$fieldId][$userId][$reason][$forceNoPost];
	}