示例#1
0
 /**
  * Labeller for title:
  * Returns a field title
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $output  'text' or: 'html', 'htmledit', (later 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist')
  * @param  string      $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @return string
  */
 public function getFieldTitle(&$field, &$user, $output, $reason)
 {
     $title = '';
     $byAge = ($output == 'html' || $output == 'rss') && $field->params->get('field_display_by', 0) > 0 || $reason == 'search' && $field->params->get('field_search_by', 0) == 1;
     if ($byAge) {
         $title = $field->params->get('duration_title');
     }
     if ($title != '') {
         if ($output === 'text') {
             return strip_tags(cbReplaceVars($title, $user));
         } else {
             return cbReplaceVars($title, $user);
         }
     } else {
         return parent::getFieldTitle($field, $user, $output, $reason);
     }
 }
	private function getFieldAjaxError( &$field, &$user, $reason  )
	{
		global $_PLUGINS;

		$errors	=	$_PLUGINS->getErrorMSG( false );
		$title	=	cbFieldHandler::getFieldTitle( $field, $user, 'text', $reason );

		if ( $errors ) foreach ( $errors as $error ) {
			if ( stristr( $error, $title ) ) {
				return str_replace( $title . ' : ', '', $error );
			}
		}

		return null;
	}
示例#3
0
	/**
	 * @param cbFieldHandler $fieldHandler
	 * @param FieldTable     $field
	 * @param UserTable      $user
	 * @param string         $output
	 * @param string         $reason
	 * @param string         $tag
	 * @param string         $type
	 * @param string         $value
	 * @param string         $additional
	 * @param string         $allValues
	 * @param bool           $displayFieldIcons
	 * @param bool           $required
	 * @return null|string
	 */
	public function fieldIcons( &$fieldHandler, &$field, &$user, $output, $reason, $tag, $type, $value, $additional, $allValues, $displayFieldIcons, $required )
	{
		global $_CB_fieldIconDisplayed;

		static $fieldsPrivacyDisplayed							=	array();

		$return													=	null;

		if ( in_array( $reason, array( 'edit', 'register' ) ) ) {
			if ( $field instanceof FieldTable && $field->get( 'profile' ) ) {
				$userId											=	(int) $user->get( 'id' );
				$fieldId										=	(int) $field->get( 'fieldid' );

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

					$display									=	$field->params->get( 'cbprivacy_display', '0' );

					if ( ( $reason == 'register' ) && ( ! $field->params->get( 'cbprivacy_display_reg', '1' ) ) ) {
						$display								=	'0';
					}

					if ( ( $display == 1 ) || ( ( $display == 2 ) && cbprivacyClass::checkUserModerator() ) ) {
						$privacy								=	new cbprivacyPrivacyTable();

						$privacy->load( array( 'user_id' => (int) $userId, 'type' => 'profile', 'subtype' => 'field', 'item' => (int) $fieldId ) );

						$fieldsPrivacyDisplayed[$fieldId]		=	true;

						$return									=	cbprivacyClass::getPrivacyInput( 'privacy_field_' . $fieldId, $privacy->get( 'rule', $field->params->get( 'cbprivacy_default', '0' ) ) );

						if ( ! isset( $_CB_fieldIconDisplayed[$fieldId] ) ) {
							$_CB_fieldIconDisplayed[$fieldId]	=	true;

							if ( $displayFieldIcons ) {
								$return							.=	' ' . getFieldIcons( null, $required, null, $fieldHandler->getFieldDescription( $field, $user, $output, $reason ), $fieldHandler->getFieldTitle( $field, $user, $output, $reason ), false, $field->params->get( 'fieldLayoutIcons', null ) );
							}
						}
					}
				}
			}
		}

		return $return;
	}