});
		$('#ccm-tab-content-redirect-by-usergroup a[data-button=assign-groups]').dialog();
	});
	</script>
</div>


<div class="ccm-tab-content" id="ccm-tab-content-redirect-by-ip">
	<?php 
foreach (array(array('redirectIPs', t('Redirect these IP addresses')), array('dontRedirectIPs', t('Never redirect these IP addresses'))) as $info) {
    $varName = $info[0];
    $value = isset(${$varName}) ? implode("\n", preg_split('/[\\s,]+/', str_replace('|', ' ', ${$varName}), -1, PREG_SPLIT_NO_EMPTY)) : '';
    ?>
	    <div class="form-group">
	    	<?php 
    echo $form->label($varName, $info[1], array('class' => 'launch-tooltip', 'data-placement' => 'right', 'data-html' => 'true', 'title' => t("Separate multiple values by spaces, new lines or commas.<br />IPv4 and IPv6 addresses are supported.<br />You can specify single IP addresses as well as ranges (examples: %s)", \Punic\Misc::join(array('<code>100.200.*.*</code>', '<code>100.200.0.0/16</code>', '<code>1:2::0/8</code>', '<code>1:2::*:*</code>)')))));
    ?>
        	<?php 
    echo $form->textarea($varName, $value, array('rows' => '5', 'style' => 'resize: vertical;'));
    ?>
	    </div>
	    <?php 
}
if ($ip !== '') {
    ?>
<div class="text-muted"><?php 
    echo t('Your IP address is %s', "<code>{$ip}</code>");
    ?>
</div><?php 
}
?>
 /**
  * Describe an interval between two dates (eg '2 days and 4 hours').
  * @param \DateTime $dateEnd The first date
  * @param \DateTime|null $dateStart The final date (if it has a timezone different than $dateEnd, we'll use the one of $dateEnd)
  * @param int $maxParts = 2 The maximim parts (eg with 2 you may have '2 days and 4 hours', with 3 '2 days, 4 hours and 24 minutes')
  * @param string $width = 'short' The format name; it can be 'long' (eg '3 seconds'), 'short' (eg '3 s') or 'narrow' (eg '3s')
  * @param string $locale = '' The locale to use. If empty we'll use the default locale set in \Punic\Data
  * @return string
  * @throws Exception\BadArgumentType
  */
 public static function describeInterval($dateEnd, $dateStart = null, $maxParts = 2, $width = 'short', $locale = '')
 {
     if (!is_a($dateEnd, '\\DateTime')) {
         throw new Exception\BadArgumentType($dateEnd, '\\DateTime');
     }
     if (empty($dateStart) && $dateStart !== 0 && $dateStart !== '0') {
         $dateStart = new \DateTime('now', $dateEnd->getTimezone());
     }
     if (!is_a($dateStart, '\\DateTime')) {
         throw new Exception\BadArgumentType($dateStart, '\\DateTime');
     }
     if ($dateStart->getOffset() !== $dateEnd->getOffset()) {
         $dateStart->setTimezone($dateEnd->getTimezone());
     }
     $utc = new \DateTimeZone('UTC');
     $dateEndUTC = new \DateTime($dateEnd->format('Y-m-d H:i:s'), $utc);
     $dateStartUTC = new \DateTime($dateStart->format('Y-m-d H:i:s'), $utc);
     $parts = array();
     $data = \Punic\Data::get('dateFields', $locale);
     if ($dateEndUTC->getTimestamp() == $dateStartUTC->getTimestamp()) {
         $parts[] = $data['second']['relative-type-0'];
     } else {
         $diff = $dateStartUTC->diff($dateEndUTC, true);
         $mostFar = 0;
         $maxDistance = 3;
         if ($mostFar < $maxDistance && $diff->y > 0) {
             $parts[] = \Punic\Unit::format($diff->y, 'duration/year', $width, $locale);
             $mostFar = 0;
         } elseif (!empty($parts)) {
             $mostFar++;
         }
         if ($mostFar < $maxDistance && $diff->m > 0) {
             $parts[] = \Punic\Unit::format($diff->m, 'duration/month', $width, $locale);
             $mostFar = 0;
         } elseif (!empty($parts)) {
             $mostFar++;
         }
         if ($mostFar < $maxDistance && $diff->d > 0) {
             $parts[] = \Punic\Unit::format($diff->d, 'duration/day', $width, $locale);
             $mostFar = 0;
         } elseif (!empty($parts)) {
             $mostFar++;
         }
         if ($mostFar < $maxDistance && $diff->h > 0) {
             $parts[] = \Punic\Unit::format($diff->h, 'duration/hour', $width, $locale);
             $mostFar = 0;
         } elseif (!empty($parts)) {
             $mostFar++;
         }
         if ($mostFar < $maxDistance && $diff->i > 0) {
             $parts[] = \Punic\Unit::format($diff->i, 'duration/minute', $width, $locale);
             $mostFar = 0;
         } elseif (!empty($parts)) {
             $mostFar++;
         }
         if (empty($parts) || $diff->s > 0) {
             $parts[] = \Punic\Unit::format($diff->s, 'duration/second', $width, $locale);
         }
         if (count($parts) > $maxParts) {
             $parts = array_slice($parts, 0, $maxParts);
         }
     }
     switch ($width) {
         case 'narrow':
         case 'short':
             $joined = \Punic\Misc::joinUnits($parts, $width, $locale);
             break;
         default:
             $joined = \Punic\Misc::join($parts, $locale);
             break;
     }
     return $joined;
 }