{
if (!self::$_supportedSpecs) {
self::$_supportedSpecs = self::$_defaultSpecs;
- if (function_exists('nl_langinfo')) { self::$_supportedSpecs .= 'bBpxX'; }
+ if (function_exists('nl_langinfo')) {
+ self::$_supportedSpecs .= 'bBpxX';
+ }
}
if (func_num_args() > 2) {
public function toDays()
{
if (function_exists('GregorianToJD')) {
- return GregorianToJD($this->_month, $this->_mday, $this->_year);
+ return gregoriantojd($this->_month, $this->_mday, $this->_year);
}
$day = $this->_mday;
$this->_mday = 1;
$first = $this->dayOfWeek();
- if ($weekday < $first) {
+ if ($weekday < $first) {
$this->_mday = 8 + $weekday - $first;
} else {
$this->_mday = $weekday - $first + 1;
*
* @var Horde_Date
*/
- var $start;
+ public $start;
/**
* The end date of the recurrence interval.
*
* @var Horde_Date
*/
- var $recurEnd = null;
+ public $recurEnd = null;
/**
* The number of recurrences.
*
* @var integer
*/
- var $recurCount = null;
+ public $recurCount = null;
/**
* The type of recurrence this event follows. RECUR_* constant.
*
* @var integer
*/
- var $recurType = self::RECUR_NONE;
+ public $recurType = self::RECUR_NONE;
/**
* The length of time between recurrences. The time unit depends on the
*
* @var integer
*/
- var $recurInterval = 1;
+ public $recurInterval = 1;
/**
* Any additional recurrence data.
*
* @var integer
*/
- var $recurData = null;
+ public $recurData = null;
/**
* All the exceptions from recurrence for this event.
*
* @var array
*/
- var $exceptions = array();
+ public $exceptions = array();
/**
* All the dates this recurrence has been marked as completed.
*
* @var array
*/
- var $completions = array();
+ public $completions = array();
/**
* Constructor.
$rrule = 'W' . $this->recurInterval;
$vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- for ($i = 0; $i <= 7 ; ++$i) {
+ for ($i = 0; $i <= 7; ++$i) {
if ($this->recurOnDay(pow(2, $i))) {
$rrule .= ' ' . $vcaldays[$i];
}
$rrule = 'FREQ=WEEKLY;INTERVAL=' . $this->recurInterval . ';BYDAY=';
$vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- for ($i = $flag = 0; $i <= 7 ; ++$i) {
+ for ($i = $flag = 0; $i <= 7; ++$i) {
if ($this->recurOnDay(pow(2, $i))) {
if ($flag) {
$rrule .= ',';
return false;
}
- $this->setRecurInterval((int) $hash['interval']);
+ $this->setRecurInterval((int)$hash['interval']);
$parse_day = false;
$set_daymask = false;
case 'weekday':
$this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
- $nth_weekday = (int) $hash['daynumber'];
+ $nth_weekday = (int)$hash['daynumber'];
$hash['daynumber'] = 1;
$parse_day = true;
$update_daynumber = true;
}
$this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
- $nth_weekday = (int) $hash['daynumber'];
+ $nth_weekday = (int)$hash['daynumber'];
$hash['daynumber'] = 1;
$parse_day = true;
$update_month = true;
return false;
}
- $this->setRecurCount((int) $hash['range']);
+ $this->setRecurCount((int)$hash['range']);
break;
case 'date':
'sunday' => Horde_Date::MASK_SUNDAY,
);
$days = array();
- foreach($bits as $name => $bit) {
+ foreach ($bits as $name => $bit) {
if ($this->recurOnDay($bit)) {
$days[] = $name;
}
{
parent::this($context);
- if ($context == 'none') { $context = 'future'; }
+ if ($context == 'none') {
+ $context = 'future';
+ }
return $this->next($context);
}
*/
public static function createExisting($dn, array $attrs = array())
{
- $entry = Horde_Ldap_Entry::createFresh($dn, $attrs);
+ $entry = self::createFresh($dn, $attrs);
$entry->markAsNew(false);
return $entry;
}
{
// Substitute named operators with logical operators.
switch ($operator) {
- case 'and': $operator = '&'; break;
- case 'or': $operator = '|'; break;
- case 'not': $operator = '!'; break;
+ case 'and':
+ $operator = '&';
+ break;
+ case 'or':
+ $operator = '|';
+ break;
+ case 'not':
+ $operator = '!';
+ break;
}
// Tests for sane operation.
if (!is_array($filters) || count($filters) < 2) {
throw new Horde_Ldap_Exception('Parameter $filters is not an array or contains less than two Horde_Ldap_Filter objects');
}
- break;
+ break;
default:
throw new Horde_Ldap_Exception('Logical operator is unknown');
public static function build(array $params, $operator = 'and')
{
if (!empty($params['filter'])) {
- return Horde_Ldap_Filter::parse($params['filter']);
+ return self::parse($params['filter']);
}
if (!is_array($params['objectclass'])) {
- return Horde_Ldap_Filter::create('objectclass', 'equals', $params['objectclass']);
+ return self::create('objectclass', 'equals', $params['objectclass']);
}
$filters = array();
foreach ($params['objectclass'] as $objectclass) {
- $filters[] = Horde_Ldap_Filter::create('objectclass', 'equals', $objectclass);
+ $filters[] = self::create('objectclass', 'equals', $objectclass);
}
if (count($filters) == 1) {
return $filters[0];
}
- return Horde_Ldap_Filter::combine($operator, $filters);
+ return self::combine($operator, $filters);
}
/**
// Denotes the current bracket level we are, >1 is too deep, 1 is ok, 0
// is outside any subcomponent.
$level = 0;
- for ($curpos = 0; $curpos < strlen($filter); $curpos++) {
+ for ($curpos = 0, $len = strlen($filter); $curpos < $len; $curpos++) {
$cur_char = $filter{$curpos};
// Rise/lower bracket level.
$oldpos = $s_pos;
}
- // Some error checking...
- if (count($subfilters) == 1) {
- // Only one subfilter found.
- } elseif (count($subfilters) > 1) {
+ if (count($subfilters) > 1) {
// Several subfilters found.
if ($operator == '!') {
throw new Horde_Ldap_Exception('Invalid filter syntax: NOT operator detected but several arguments given');
}
- } else {
+ } elseif (!count($subfilters)) {
// This should not happen unless the user specified a wrong filter.
throw new Horde_Ldap_Exception('Invalid filter syntax: got operator ' . $operator . ' but no argument');
}
}
// Test for illegal content char.
- for ($i = 0; $i < strlen($value); $i++) {
+ for ($i = 0, $len = strlen($value); $i < $len; $i++) {
$char_ord = ord(substr($value, $i, 1));
if ($char_ord >= 127 || in_array($char_ord, $unsafe)) {
$binary = true;
$tokens = array();
// Number of tokens (full pattern match).
- for ($i = 0; $i < count($matches[0]); $i++) {
+ for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
// Each subpattern.
for ($j = 1; $j < 4; $j++) {
// Pattern match in this subpattern.
*/
public static function asc2hex32($string)
{
- for ($i = 0; $i < strlen($string); $i++) {
+ for ($i = 0, $len = strlen($string); $i < $len; $i++) {
$char = substr($string, $i, 1);
if (ord($char) < 32) {
$hex = dechex(ord($char));