コード例 #1
0
	/**
	 * prepare frontend event edit render
	 *
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function showEventEdit( $id, $user )
	{
		global $_CB_framework;

		$row					=	CBGroupJiveEvents::getEvent( (int) $id );
		$isModerator			=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$groupId				=	$this->input( 'group', null, GetterInterface::INT );

		if ( $groupId === null ) {
			$group				=	$row->group();
		} else {
			$group				=	CBGroupJive::getGroup( $groupId );
		}

		$returnUrl				=	$_CB_framework->pluginClassUrl( $this->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) );

		if ( ! CBGroupJive::canAccessGroup( $group, $user ) ) {
			cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' );
		} elseif ( ! $isModerator ) {
			if ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'events' ) ) ) {
				cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to schedule an event in this group.' ), 'error' );
			} elseif ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) && ( CBGroupJive::getGroupStatus( $user, $group ) < 2 ) ) {
				cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this event.' ), 'error' );
			}
		}

		CBGroupJive::getTemplate( 'event_edit', true, true, $this->element );

		$input					=	array();

		$publishedTooltip		=	cbTooltip( null, CBTxt::T( 'Select publish state of this event. Unpublished events will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['published']		=	moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . $publishedTooltip, (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) );

		$titleTooltup			=	cbTooltip( null, CBTxt::T( 'Input the event title. This is the title that will distinguish this event from others. Suggested to input something to uniquely identify your event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['title']			=	'<input type="text" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="form-control required" size="35"' . $titleTooltup . ' />';

		$event					=	$_CB_framework->displayCmsEditor( 'event', $this->input( 'post/event', $row->get( 'event' ), GetterInterface::HTML ), '100%', null, 40, 10, false );

		$input['event']			=	cbTooltip( null, CBTxt::T( 'Input a detailed description about this event.' ), null, null, null, $event, null, 'style="display:block;"' );

		$locationTooltup		=	cbTooltip( null, CBTxt::T( 'Input the location for this event (e.g. My House, The Park, Restaurant Name, etc..).' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['location']		=	'<input type="text" id="location" name="location" value="' . htmlspecialchars( $this->input( 'post/location', $row->get( 'location' ), GetterInterface::STRING ) ) . '" class="form-control required" size="35"' . $locationTooltup . ' />';

		$addressTooltup			=	cbTooltip( null, CBTxt::T( 'Optionally input the address for this event or click the map button to attempt to find your current location.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['address']		=	'<input type="text" id="address" name="address" value="' . htmlspecialchars( $this->input( 'post/address', $row->get( 'address' ), GetterInterface::STRING ) ) . '" class="form-control" size="45"' . $addressTooltup . ' />';

		$calendars				=	new cbCalendars( 1 );
		$minYear				=	(int) Application::Date( ( $row->get( 'id' ) ? $row->get( 'start' ) : 'now' ), 'UTC' )->format( 'Y' );

		$startTooltup			=	cbTooltip( null, CBTxt::T( 'Select the date and time this event starts.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['start']			=	$calendars->cbAddCalendar( 'start', null, true, $this->input( 'post/start', $row->get( 'start' ), GetterInterface::STRING ), false, true, $minYear, ( $minYear + 30 ), $startTooltup );

		$endTooltup				=	cbTooltip( null, CBTxt::T( 'Optionally select the end date and time for this event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['end']			=	$calendars->cbAddCalendar( 'end', null, false, $this->input( 'post/end', $row->get( 'end' ), GetterInterface::STRING ), false, true, $minYear, ( $minYear + 30 ), $endTooltup );

		$limitTooltip			=	cbTooltip( null, CBTxt::T( 'Optionally input a guest limit for this event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['limit']			=	'<input type="text" id="limit" name="limit" value="' . (int) $this->input( 'post/limit', $row->get( 'limit' ), GetterInterface::INT ) . '" class="digits form-control" size="6"' . $limitTooltip . ' />';

		$ownerTooltip			=	cbTooltip( null, CBTxt::T( 'Input the event owner id. Event owner determines the creator of the event specified as User ID.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['user_id']		=	'<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $this->input( 'user', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . $ownerTooltip . ' />';

		HTML_groupjiveEventEdit::showEventEdit( $row, $input, $group, $user, $this );
	}
コード例 #2
0
ファイル: cb.core.php プロジェクト: bobozhangshao/HeartCare
 /**
  * Returns a field in specified format
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string      $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int         $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed
  */
 public function getField(&$field, &$user, $output, $reason, $list_compare_types)
 {
     global $_CB_framework;
     $value = $user->get($field->get('name'));
     $return = null;
     switch ($output) {
         case 'html':
         case 'rss':
             if ($value != null && $value != '' && $value != '0000-00-00 00:00:00' && $value != '0000-00-00') {
                 $offset = (int) $field->params->get('date_offset', $field->get('type') == 'datetime' ? 1 : 0);
                 switch ((int) $field->params->get('field_display_by', 0)) {
                     case 1:
                         // Age
                         $dateDiff = $_CB_framework->getUTCDateDiff('now', $value);
                         $age = null;
                         if ($dateDiff) {
                             $age = $dateDiff->y;
                             if ($age < 0) {
                                 $age = null;
                             }
                         }
                         $return = $this->formatFieldValueLayout($age, $reason, $field, $user);
                         break;
                     case 2:
                         // Timeago, with Ago
                         $return = $this->formatFieldValueLayout(cbFormatDate($value, $offset, 'timeago'), $reason, $field, $user, false);
                         break;
                     case 6:
                         // Timeago, without Ago
                         $return = $this->formatFieldValueLayout(cbFormatDate($value, $offset, 'exacttimeago'), $reason, $field, $user, false);
                         break;
                     case 3:
                         // Birthdate
                         // Offset based off the profile owners timezone:
                         $timeZone = JFactory::getUser((int) $user->get('id'))->getParam('timezone');
                         if (!$timeZone) {
                             // If no profile timezone specified then offset based off site:
                             $timeZone = JFactory::getConfig()->get('offset');
                         }
                         $return = $this->formatFieldValueLayout(htmlspecialchars(cbFormatDate($value, $offset, $field->get('type') == 'datetime' ? true : false, 'F d', ' g:i A', $timeZone)), $reason, $field, $user);
                         break;
                     case 4:
                         // Date
                         $return = $this->formatFieldValueLayout(htmlspecialchars(cbFormatDate($value, $offset, false)), $reason, $field, $user);
                         break;
                     case 5:
                         // Custom
                         $dateFormat = $field->params->get('custom_date_format', 'Y-m-d');
                         $timeFormat = $field->params->get('custom_time_format', 'H:i:s');
                         $return = $this->formatFieldValueLayout(htmlspecialchars(cbFormatDate($value, $offset, $field->get('type') == 'datetime' ? true : false, $dateFormat, $timeFormat)), $reason, $field, $user);
                         break;
                     default:
                         // Date/Datetime
                         $return = $this->formatFieldValueLayout(htmlspecialchars(cbFormatDate($value, $offset, $field->get('type') == 'datetime' ? true : false)), $reason, $field, $user);
                         break;
                 }
             } else {
                 $return = $this->formatFieldValueLayout('', $reason, $field, $user);
             }
             break;
         case 'htmledit':
             global $_CB_framework;
             $offset = (int) $field->params->get('date_offset', $field->get('type') == 'datetime' ? 1 : 0);
             $displayBy = (int) $field->params->get('field_display_by', 0);
             if ($displayBy == 1) {
                 // Age
                 $offset = 0;
             }
             $calendars = new cbCalendars($_CB_framework->getUi());
             $translatedTitle = $this->getFieldTitle($field, $user, 'html', $reason);
             $htmlDescription = $this->getFieldDescription($field, $user, 'htmledit', $reason);
             $trimmedDescription = trim(strip_tags($htmlDescription));
             $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, 'data-hascbtooltip="true"') : null;
             if ($reason == 'search') {
                 $minNam = $field->get('name') . '__minval';
                 $maxNam = $field->get('name') . '__maxval';
                 $minVal = $user->get($minNam);
                 $maxVal = $user->get($maxNam);
                 $searchBy = $field->params->get('field_search_by', 0);
                 list($yMin, $yMax) = $this->_yearsRange($field, $searchBy);
                 if ($searchBy == 1) {
                     // Search by age range:
                     $choices = array();
                     for ($i = $yMin; $i <= $yMax; $i++) {
                         $choices[] = moscomprofilerHTML::makeOption($i, $i);
                     }
                     if ($minVal === null) {
                         $minVal = $yMin;
                     }
                     if ($maxVal === null) {
                         $maxVal = $yMax;
                     }
                     $additional = ' class="form-control"' . (trim($tooltip) ? ' ' . $tooltip : null);
                     $minHtml = moscomprofilerHTML::selectList($choices, $minNam, $additional, 'text', 'value', $minVal, 2);
                     $maxHtml = moscomprofilerHTML::selectList($choices, $maxNam, $additional, 'text', 'value', $maxVal, 2);
                 } else {
                     if ($minVal !== null) {
                         if ($field->get('type') == 'datetime') {
                             $minVal = $_CB_framework->getUTCDate('Y-m-d H:i:s', $minVal);
                         } else {
                             $minVal = $_CB_framework->getUTCDate('Y-m-d', $minVal);
                         }
                     }
                     if ($maxVal !== null) {
                         if ($field->get('type') == 'datetime') {
                             $maxVal = $_CB_framework->getUTCDate('Y-m-d H:i:s', $maxVal);
                         } else {
                             $maxVal = $_CB_framework->getUTCDate('Y-m-d', $maxVal);
                         }
                     }
                     // Search by date range:
                     $minHtml = $calendars->cbAddCalendar($minNam, CBTxt::Th('UE_SEARCH_FROM', 'Between') . ' ' . $this->getFieldTitle($field, $user, 'text', $reason), false, $minVal, false, $field->get('type') == 'datetime' ? true : false, $yMin, $yMax, $tooltip, $offset);
                     $maxHtml = $calendars->cbAddCalendar($maxNam, CBTxt::Th('UE_SEARCH_TO', 'and') . ' ' . $this->getFieldTitle($field, $user, 'text', $reason), false, $maxVal, false, $field->get('type') == 'datetime' ? true : false, $yMin, $yMax, $tooltip, $offset);
                 }
                 $return = $this->_fieldSearchRangeModeHtml($field, $user, $output, $reason, $value, $minHtml, $maxHtml, $list_compare_types);
             } elseif (!in_array($field->get('name'), array('registerDate', 'lastvisitDate', 'lastupdatedate'))) {
                 $timeZone = null;
                 if ($displayBy == 3) {
                     // Birthdate
                     // Offset based off the profile owners timezone:
                     $timeZone = JFactory::getUser((int) $user->get('id'))->getParam('timezone');
                     if (!$timeZone) {
                         // If no profile timezone specified then offset based off site:
                         $timeZone = JFactory::getConfig()->get('offset');
                     }
                 }
                 list($yMin, $yMax) = $this->_yearsRange($field, 0);
                 $return = $this->formatFieldValueLayout($calendars->cbAddCalendar($field->get('name'), $this->getFieldTitle($field, $user, 'text', $reason), $this->_isRequired($field, $user, $reason), $value, $this->_isReadOnly($field, $user, $reason), $field->get('type') == 'datetime' ? true : false, $yMin, $yMax, $tooltip, $offset, $timeZone), $reason, $field, $user) . $this->_fieldIconsHtml($field, $user, $output, $reason, null, $field->get('type'), $value, 'input', null, true, $this->_isRequired($field, $user, $reason) && !$this->_isReadOnly($field, $user, $reason));
             }
             break;
         case 'json':
         case 'php':
         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
             $return = parent::getField($field, $user, $output, $reason, $list_compare_types);
             break;
     }
     return $return;
 }
コード例 #3
0
 /**
  * Returns a field in specified format
  *
  * @param  moscomprofilerFields  $field
  * @param  moscomprofilerUser    $user
  * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed                
  */
 function getField(&$field, &$user, $output, $reason, $list_compare_types)
 {
     $value = $user->get($field->name);
     switch ($output) {
         case 'html':
         case 'rss':
             if ($value != '' && $value != '0000-00-00 00:00:00' && $value != '0000-00-00') {
                 $display_by = $field->params->get('field_display_by', 0);
                 if ($display_by == 1) {
                     // display by years:
                     list($yb, $cb, $db) = sscanf($value, '%d-%d-%d');
                     list($yn, $cn, $dn) = sscanf(date('Y-m-d'), '%d-%d-%d');
                     $age = (int) ($yn - $yb);
                     if ($cb > $cn || $cb == $cn && $db > $dn) {
                         $age -= 1;
                     }
                     if ($age < 0) {
                         $age = null;
                     }
                     return $field->params->get('field_display_years_text', 1) ? sprintf(_UE_AGE_YEARS, $age) : $age;
                 } elseif ($display_by == 2) {
                     // display by ago:
                     return $this->_ago($value, $field->params->get('field_display_ago_text', 1), true);
                 } elseif ($display_by == 3) {
                     // display birthday without the year:
                     global $ueConfig;
                     if ($value != '' && $value != null && $value != '0000-00-00 00:00:00' && $value != '0000-00-00') {
                         if (strlen($value) > 10) {
                             $value = _old_cbFormatDate($value, "%m-%d");
                             // offsets datetime with server offset setting
                         }
                         $value = substr($value, 5, 5);
                         $month = substr($value, 0, 2);
                         if (defined('_UE_MONTHS_' . (int) $month)) {
                             $value = 'MM' . substr($value, 2);
                         }
                         $convert = array('Y/m/d' => 'm/d', 'd/m/y' => 'd/m', 'y/m/d' => 'm/d', 'd/m/Y' => 'd/m', 'm/d/y' => 'm/d', 'm/d/Y' => 'm/d', 'Y-m-d' => 'm/d', 'd-m-y' => 'd/m', 'y-m-d' => 'm/d', 'd-m-Y' => 'd/m', 'm-d-y' => 'm/d', 'm-d-Y' => 'm/d', 'Y.m.d' => 'm/d', 'd.m.y' => 'd/m', 'y.m.d' => 'm/d', 'd.m.Y' => 'd/m', 'm.d.y' => 'm/d', 'm.d.Y' => 'm/d');
                         if (isset($convert[$ueConfig['date_format']])) {
                             $format = $convert[$ueConfig['date_format']];
                         } else {
                             $format = 'm/d';
                         }
                         $value = dateConverter($value, 'm-d', $format);
                         if (defined('_UE_MONTHS_' . (int) $month)) {
                             $value = str_replace(array('MM', '/'), array(constant('_UE_MONTHS_' . (int) $month), ' '), $value);
                         }
                         return $value;
                     } else {
                         return '';
                     }
                 } else {
                     $date_time = $field->params->get('show_date_time', 0);
                     return htmlspecialchars(cbFormatDate($value, 1, $date_time == 1 ? false : true));
                 }
             } else {
                 return '';
             }
             break;
         case 'htmledit':
             global $_CB_framework;
             $calendars = new cbCalendars($_CB_framework->getUi());
             if ($reason == 'search') {
                 $minNam = $field->name . '__minval';
                 $maxNam = $field->name . '__maxval';
                 $minVal = $user->get($minNam);
                 $maxVal = $user->get($maxNam);
                 $search_by = $field->params->get('field_search_by', 0);
                 list($yMin, $yMax) = $this->_yearsRange($field, $search_by);
                 if ($search_by == 1) {
                     // Search by age range:
                     $choices = array();
                     $choices = array();
                     for ($i = $yMin; $i <= $yMax; $i++) {
                         $choices[] = moscomprofilerHTML::makeOption($i, $i);
                     }
                     if ($minVal === null) {
                         $minVal = $yMin;
                     }
                     if ($maxVal === null) {
                         $maxVal = $yMax;
                     }
                     $additional = ' class="inputbox"';
                     $minHtml = moscomprofilerHTML::selectList($choices, $minNam, $additional, 'text', 'value', $minVal, 2);
                     $maxHtml = moscomprofilerHTML::selectList($choices, $maxNam, $additional, 'text', 'value', $maxVal, 2);
                 } else {
                     if ($minVal !== null) {
                         $minVal = date('Y-m-d', strtotime($minVal));
                     }
                     if ($maxVal !== null) {
                         $maxVal = date('Y-m-d', strtotime($maxVal));
                     }
                     // Search by date range:
                     $minHtml = $calendars->cbAddCalendar($minNam, _UE_SEARCH_FROM . ' ' . $this->getFieldTitle($field, $user, 'text', $reason), false, $minVal, false, false, $yMin, $yMax);
                     $maxHtml = $calendars->cbAddCalendar($maxNam, _UE_SEARCH_TO . ' ' . $this->getFieldTitle($field, $user, 'text', $reason), false, $maxVal, false, false, $yMin, $yMax);
                 }
                 $html = $this->_fieldSearchRangeModeHtml($field, $user, $output, $reason, $value, $minHtml, $maxHtml, $list_compare_types);
                 return $html;
             } elseif (!in_array($field->name, array('registerDate', 'lastvisitDate', 'lastupdatedate'))) {
                 list($yMin, $yMax) = $this->_yearsRange($field, 0);
                 $html = $calendars->cbAddCalendar($field->name, $this->getFieldTitle($field, $user, 'text', $reason), $this->_isRequired($field, $user, $reason), $value, $this->_isReadOnly($field, $user, $reason), false, $yMin, $yMax) . $this->_fieldIconsHtml($field, $user, $output, $reason, null, $field->type, $value, 'input', null, true, $this->_isRequired($field, $user, $reason) && !$this->_isReadOnly($field, $user, $reason));
             } else {
                 $html = null;
             }
             return $html;
             break;
         case 'json':
         case 'php':
         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
             return parent::getField($field, $user, $output, $reason, $list_compare_types);
             break;
     }
     return '*' . CBTxt::T('Unknown Output Format') . '*';
 }
コード例 #4
0
function getFieldEntry($ui, $oldCalendars, $oType, $oName, $oDescription, $oTitle, $oValue, $oReq, $oLabel, $oID, $oSize, $oMaxLen, $oCols, $oRows, $oProfile, $rowFieldValues = null, $oReadOnly = 0, $field = null)
{
    global $_CB_framework, $_PLUGINS;
    if ($oSize > 0) {
        $pSize = " size='" . $oSize . "' ";
    } else {
        $pSize = "";
    }
    if ($oMaxLen > 0) {
        $pMax = " maxlength='" . $oMaxLen . "' ";
    } else {
        $pMax = "";
    }
    if ($oCols > 0) {
        $pCols = " cols='" . $oCols . "' ";
    } else {
        $pCols = "";
    }
    if ($oRows > 0) {
        $pRows = " rows='" . $oRows . "' ";
    } else {
        $pRows = "";
    }
    if ($oReadOnly > 0) {
        $pReadOnly = " disabled=\"disabled\" ";
        $oReq = 0;
    } else {
        $pReadOnly = "";
    }
    $mosReq = "mosReq=\"" . $oReq . "\"";
    $displayFieldIcons = true;
    switch ($oType) {
        //		CASE 'text':
        //			$oReturn = "<input class=\"inputbox\" $pReadOnly $mosReq mosLabel=\"". htmlspecialchars( getLangDefinition($oLabel) ) ."\" $pSize $pMax type=\"text\" name=\"".$oName."\" id=\"".$oName."\" value=\"".htmlspecialchars($oValue)."\" />";
        //		break;
        case 'textarea':
            $oReturn = "<textarea class=\"inputbox\" {$pReadOnly} {$mosReq} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" {$pCols} {$pRows}  name=\"" . $oName . "\" id=\"" . $oName . "\">" . htmlspecialchars($oValue) . "</textarea>";
            //TBD: limit by pmax using JS
            break;
        case 'editorta':
            if (!($oReadOnly > 0)) {
                $oReturn = $_CB_framework->displayCmsEditor($oName, $oValue, 600, 350, $oCols, $oRows);
                $_CB_framework->outputCbJQuery('document.adminForm.' . $oName . ".setAttribute('mosReq'," . $oReq . "); document.adminForm." . $oName . ".setAttribute('mosLabel','" . addslashes(getLangDefinition($oLabel)) . "');");
            } else {
                $oReturn = $oValue;
            }
            break;
        case 'select':
        case 'multiselect':
        case 'radio':
        case 'multicheckbox':
            $oReturn = $rowFieldValues;
            break;
        case 'checkbox':
            $checked = '';
            if ($oValue != '' && $oValue != null && $oValue == 1) {
                $checked = " checked=\"checked\"";
            }
            $oReturn = "<input {$pReadOnly} {$mosReq} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"checkbox\" {$checked} name=\"" . $oName . "\" id=\"" . $oName . "\" value=\"1\" />";
            break;
        case 'hidden':
            $oReturn = "<input {$pReadOnly} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"hidden\" name=\"" . $oName . "\" id=\"" . $oName . "\" value=\"" . htmlspecialchars($oValue) . "\" />";
            break;
        case 'password':
            $oReturn = "<input class=\"inputbox\" {$pReadOnly} {$mosReq} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"password\" name=\"" . $oName . "\" id=\"" . $oName . "\" value=\"" . htmlspecialchars($oValue) . "\" />";
            break;
        case 'date':
            $calendars = new cbCalendars($_CB_framework->getUi());
            $oReturn = $calendars->cbAddCalendar($oName, $oLabel, $oReq, $oValue, $oReadOnly);
            break;
        case 'emailaddress':
            $oReturn = "<input class=\"inputbox\" {$pReadOnly} {$pMax} {$mosReq} {$pSize} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"text\" name=\"" . $oName . "\" id=\"" . $oName . "\" value=\"" . htmlspecialchars($oValue) . "\" />";
            break;
        case 'webaddress':
            if ($oRows != 2) {
                $oReturn = "<input class=\"inputbox\" {$pReadOnly} {$pMax} {$pSize} {$mosReq} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"text\" name=\"" . $oName . "\" id=\"" . $oName . "\" value=\"" . htmlspecialchars($oValue) . "\" />";
            } else {
                $oValuesArr = array();
                $oValuesArr = explode("|*|", $oValue);
                if (count($oValuesArr) < 2) {
                    $oValuesArr[1] = "";
                }
                $oReturn = "<span class=\"webUrlSpan\">";
                $oReturn .= "<span class=\"subTitleSpan\">" . _UE_WEBURL . ":</span>";
                $oReturn .= "<span class=\"subFieldSpan\"><input class=\"inputbox\" {$pReadOnly} {$pMax} {$pSize} {$mosReq} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"text\" name=\"" . $oName . "\" id=\"" . $oName . "\" value=\"" . htmlspecialchars($oValuesArr[0]) . "\" />";
                $oReturn .= getFieldIcons($ui, $oReq, $oProfile, $oDescription, $oTitle) . "</span>";
                $displayFieldIcons = false;
                $oReturn .= "</span><span class=\"webTextSpan\">";
                $oReturn .= "<span class=\"subTitleSpan\">" . _UE_WEBTEXT . ":</span>";
                $oReturn .= "<span class=\"subFieldSpan\"><input class=\"inputbox\" {$pReadOnly} {$pMax} {$pSize} {$mosReq} mosLabel=\"" . htmlspecialchars(getLangDefinition($oLabel)) . "\" type=\"text\" name=\"" . $oName . "Text\" id=\"" . $oName . "Text\" value=\"" . htmlspecialchars($oValuesArr[1]) . "\" /></span>";
                $oReturn .= "</span>";
            }
            break;
        case 'delimiter':
            $oReturn = '';
            break;
        case 'text':
        default:
            if ($field != null) {
                $fieldReq = $field->required;
                $field->required = $oReq;
                $args = array(&$field, null, 'htmledit', 'edit');
                $oReturn = $_PLUGINS->callField($oType, 'getField', $args, $field);
                $field->required = $fieldReq;
            } else {
                $oReturn = 'FIELD TYPE NOT IMPLEMENTED FOR INPUT';
            }
    }
    if ($oReturn && $displayFieldIcons) {
        $oReturn .= getFieldIcons($ui, $oReq, $oProfile, $oDescription, $oTitle);
    }
    return $oReturn;
}
コード例 #5
0
	/**
	 * Displays block user page
	 *
	 * @param int         $id
	 * @param string      $type
	 * @param UserTable   $user
	 * @param null|string $message
	 * @param null|string $messageType
	 */
	public function showBlock( $id, $type, $user, $message = null, $messageType = 'error' )
	{
		global $_CB_framework;

		$profileUrl				=	$_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $this->_tab );

		if ( ! $user->get( 'id' ) ) {
			cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
		}

		$ipAddress				=	cbantispamClass::getUserIP( $user );
		$value					=	null;

		switch ( $type ) {
			case 'user':
				$value			=	(int) $user->get( 'id' );
				break;
			case 'ip':
				$value			=	$ipAddress;
				break;
			case 'email':
				$value			=	$user->get( 'email' );
				break;
			case 'domain':
				$emailParts		=	explode( '@', $user->get( 'email' ) );

				if ( count( $emailParts ) > 1 ) {
					$value		=	array_pop( $emailParts );
				}
				break;
		}

		$row					=	new cbantispamBlockTable();

		if ( $id ) {
			$row->load( (int) $id );
		}

		$js						=	"$( '#durations' ).on( 'change', function() {"
								.		"var value = $( this ).val();"
								.		"if ( value ) {"
								.			"$( '#duration' ).attr( 'value', value ).focus();"
								.			"$( this ).attr( 'value', '' );"
								.		"}"
								.	"});"
								.	"$( '#type' ).on( 'change', function() {"
								.		"if ( $( this ).val() == 'user' ) {"
								.			"$( '#banUsr,#blockUsr' ).show();"
								.			"$( '#ban_user' ).trigger( 'change' );"
								.		"} else {"
								.			"$( '#banUsr,#blockUsr,#banUsrReason' ).hide();"
								.		"}"
								.	"});"
								.	"$( '#ban_user' ).on( 'change', function() {"
								.		"if ( $( this ).val() == 1 ) {"
								.			"$( '#banUsrReason' ).show();"
								.		"} else {"
								.			"$( '#banUsrReason' ).hide();"
								.		"}"
								.	"});"
								.	"$( '#type' ).change();";

		$_CB_framework->outputCbJQuery( $js );

		cbantispamClass::getTemplate( 'block' );

		$input					=	array();

		$listType				=	array();
		$listType[]				=	moscomprofilerHTML::makeOption( 'user', CBTxt::T( 'User' ) );
		$listType[]				=	moscomprofilerHTML::makeOption( 'ip', CBTxt::T( 'IP Address' ) );
		$listType[]				=	moscomprofilerHTML::makeOption( 'email', CBTxt::T( 'Email Address' ) );
		$listType[]				=	moscomprofilerHTML::makeOption( 'domain', CBTxt::T( 'Email Domain' ) );

		$type					=	$this->input( 'post/type', $row->get( 'type', $type ), GetterInterface::STRING );
		$typeTooltip			=	cbTooltip( null, CBTxt::T( 'Select the block type. Type determines what value should be supplied.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['type']			=	moscomprofilerHTML::selectList( $listType, 'type', 'class="form-control required"' . ( $typeTooltip ? ' ' . $typeTooltip : null ), 'value', 'text', $type, 1, true, false, false );

		$valueTooltip			=	cbTooltip( null, CBTxt::T( 'Input block value in relation to the type. User type use the users user_id (e.g. 42). IP Address type use a full valid IP Address (e.g. 192.168.0.1). Email type use a fill valid email address (e.g. invalid@cb.invalid). Email Domain type use a full email address domain after @ (e.g. example.com).' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['value']			=	'<input type="text" id="value" name="value" value="' . htmlspecialchars( $this->input( 'post/value', $row->get( 'value', $value ), GetterInterface::STRING ) ) . '" class="form-control required" size="25"' . ( $valueTooltip ? ' ' . $valueTooltip : null ) . ' />';

		$calendar				=	new cbCalendars( 1 );
		$dateTooltip			=	cbTooltip( null, CBTxt::T( 'Select the date and time the block should go in affect. Note date and time always functions in UTC.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['date']			=	$calendar->cbAddCalendar( 'date', null, true, $this->input( 'post/date', $row->get( 'date' ), GetterInterface::STRING ), false, true, null, null, $dateTooltip );

		$durationTooltip		=	cbTooltip( null, CBTxt::T( 'Input the strtotime relative date (e.g. +1 Day). This duration will be added to the datetime specified above. Leave blank for a forever duration.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['duration']		=	'<input type="text" id="duration" name="duration" value="' . htmlspecialchars( $this->input( 'post/duration', $row->get( 'duration' ), GetterInterface::STRING ) ) . '" class="form-control" size="25"' . ( $durationTooltip ? ' ' . $durationTooltip : null ) . ' />';

		$listDurations			=	array();
		$listDurations[]		=	moscomprofilerHTML::makeOption( '', CBTxt::T( '- Select Duration -' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'MIDNIGHT', CBTxt::T( 'Midnight' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'NOON', CBTxt::T( 'Noon' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'TOMORROW', CBTxt::T( 'Tomorrow' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'NEXT WEEK', CBTxt::T( 'Next Week' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'NEXT MONTH', CBTxt::T( 'Next Month' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'NEXT YEAR', CBTxt::T( 'Next Year' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF THIS MONTH', CBTxt::T( 'Last Day of This Month' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF NEXT MONTH', CBTxt::T( 'First Day of Next Month' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF NEXT MONTH', CBTxt::T( 'Last Day of Next Month' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF THIS YEAR', CBTxt::T( 'Last Day of This Year' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF NEXT YEAR', CBTxt::T( 'First Day of Next Year' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF NEXT YEAR', CBTxt::T( 'Last Day of Next Year' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF JANUARY', CBTxt::T( 'First Day of January' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF JANUARY', CBTxt::T( 'Last Day of January' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF FEBRUARY', CBTxt::T( 'First Day of February' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF FEBRUARY', CBTxt::T( 'Last Day of February' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF MARCH', CBTxt::T( 'First Day of March' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF MARCH', CBTxt::T( 'Last Day of March' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF APRIL', CBTxt::T( 'First Day of Apil' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF APRIL', CBTxt::T( 'Last Day of Apil' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF MAY', CBTxt::T( 'First Day of May' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF MAY', CBTxt::T( 'Last Day of May' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF JUNE', CBTxt::T( 'First Day of June' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF JUNE', CBTxt::T( 'Last Day of June' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF JULY', CBTxt::T( 'First Day of July' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF JULY', CBTxt::T( 'Last Day of July' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF AUGUST', CBTxt::T( 'First Day of August' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF AUGUST', CBTxt::T( 'Last Day of August' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF SEPTEMBER', CBTxt::T( 'First Day of September' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF SEPTEMBER', CBTxt::T( 'Last Day of September' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF OCTOBER', CBTxt::T( 'First Day of October' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF OCTOBER', CBTxt::T( 'Last Day of October' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF NOVEMBER', CBTxt::T( 'First Day of November' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF NOVEMBER', CBTxt::T( 'Last Day of November' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'FIRST DAY OF DECEMBER', CBTxt::T( 'First Day of December' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( 'LAST DAY OF DECEMBER', CBTxt::T( 'Last Day of December' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+30 MINUTES', CBTxt::T( '30 Minutes' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+1 HOUR', CBTxt::T( '1 Hour' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+3 HOURS', CBTxt::T( '3 Hours' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+6 HOURS', CBTxt::T( '6 Hours' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+12 HOURS', CBTxt::T( '12 Hours' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+1 DAY', CBTxt::T( '1 Day' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+3 DAYS', CBTxt::T( '3 Days' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+6 DAYS', CBTxt::T( '6 Days' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+12 DAYS', CBTxt::T( '12 Days' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+1 WEEK', CBTxt::T( '1 Week' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+2 WEEKS', CBTxt::T( '2 Weeks' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+3 WEEKS', CBTxt::T( '3 Weeks' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+1 MONTH', CBTxt::T( '1 Month' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+3 MONTHS', CBTxt::T( '3 Months' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+6 MONTHS', CBTxt::T( '6 Months' ) );
		$listDurations[]		=	moscomprofilerHTML::makeOption( '+1 YEAR', CBTxt::T( '1 Year' ) );
		$input['durations']		=	moscomprofilerHTML::selectList( $listDurations, 'durations', 'class="form-control"', 'value', 'text', null, 0, true, false, false );

		$reasonTooltip			=	cbTooltip( null, CBTxt::T( 'Optionally input block reason. If left blank will default to spam.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['reason']		=	'<textarea id="reason" name="reason" class="form-control" cols="40" rows="5"' . ( $reasonTooltip ? ' ' . $reasonTooltip : null ) . '>' . htmlspecialchars( $this->input( 'post/reason', $row->get( 'reason' ), GetterInterface::STRING ) ) . '</textarea>';

		$banUserTooltip			=	cbTooltip( null, CBTxt::T( 'Optionally ban the users profile using Community Builder moderator ban feature. Note normal ban notification will be sent with the ban.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['ban_user']		=	moscomprofilerHTML::yesnoSelectList( 'ban_user', 'class="form-control"' . ( $banUserTooltip ? ' ' . $banUserTooltip : null ), $this->input( 'post/ban_user', 0, GetterInterface::INT ) );

		$banReasonTooltip		=	cbTooltip( null, CBTxt::T( 'Optionally input reason for profile ban.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['ban_reason']	=	'<textarea id="ban_reason" name="ban_reason" class="form-control" cols="40" rows="5"' . ( $banReasonTooltip ? ' ' . $banReasonTooltip : null ) . '>' . htmlspecialchars( $this->input( 'post/ban_reason', null, GetterInterface::STRING ) ) . '</textarea>';

		$blockUserTooltip		=	cbTooltip( null, CBTxt::T( 'Optionally block the users profile using Joomla block state.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['block_user']	=	moscomprofilerHTML::yesnoSelectList( 'block_user', 'class="form-control"' . ( $blockUserTooltip ? ' ' . $blockUserTooltip : null ), $this->input( 'post/block_user', 0, GetterInterface::INT ) );

		if ( $message ) {
			$_CB_framework->enqueueMessage( $message, $messageType );
		}

		HTML_cbantispamBlock::showBlock( $row, $input, $type, $this->_tab, $user, $this );
	}