/** * @param FieldTable $field * @param UserTable $user * @param array $postdata * @param string $reason */ public function commitFieldDataSave( &$field, &$user, &$postdata, $reason ) { if ( in_array( $reason, array( 'edit', 'register' ) ) ) { $value = implode( '|*|', cbprivacyClass::validatePrivacy( $this->input( $field->get( 'name' ), '0', GetterInterface::RAW ) ) ); if ( $value != '' ) { $privacy = new cbprivacyPrivacyTable(); $query = 'SELECT *' . "\n FROM " . $privacy->getDbo()->NameQuote( $privacy->getTableName() ) . "\n WHERE " . $privacy->getDbo()->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . "\n AND " . $privacy->getDbo()->NameQuote( 'type' ) . " = " . $privacy->getDbo()->Quote( 'profile' ) . "\n AND ( " . $privacy->getDbo()->NameQuote( 'subtype' ) . " IS NULL OR " . $privacy->getDbo()->NameQuote( 'subtype' ) . " = " . $privacy->getDbo()->Quote( '' ) . " )"; $privacy->getDbo()->setQuery( $query, 0, 1 ); $privacy->getDbo()->loadObject( $privacy ); if ( ( ! $privacy->get( 'id' ) ) || ( $privacy->get( 'rule' ) != $value ) ) { if ( ! $privacy->get( 'id' ) ) { $privacy->set( 'user_id', (int) $user->get( 'id' ) ); $privacy->set( 'type', 'profile' ); } $privacy->set( 'rule', $value ); $privacy->store(); } } } }