Ejemplo n.º 1
0
 /**
  * A method to determine if the delivery limitation stored will prevent an
  * ad from delivering or not, given a time/date.
  *
  * @abstract
  * @param object $oDate PEAR:Date, represeting the time/date to test if the ACL would
  *                      block delivery at that point in time.
  * @return mixed A boolean (true if the ad is BLOCKED (i.e. will NOT deliver), false
  *               if the ad is NOT BLOCKED (i.e. WILL deliver), or a PEAR::Error.
  */
 function deliveryBlocked($oDate)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     if (!is_a($oDate, 'Date')) {
         return MAX::raiseError('Parameter passed to OA_Maintenance_Priority_DeliveryLimitation_Common is not a PEAR::Date object', MAX_ERROR_INVALIDARGS);
     }
     $aParts = OX_Component::parseComponentIdentifier($this->type);
     if (!empty($aParts) && count($aParts) == 3) {
         $fileName = MAX_PATH . $aConf['pluginPaths']['plugins'] . join('/', $aParts) . '.delivery.php';
         $funcName = "MAX_check{$aParts[1]}_{$aParts[2]}";
         $callable = function_exists($funcName);
         if (!$callable && file_exists($fileName)) {
             require_once $fileName;
             $callable = true;
         }
         $aParams = array('timestamp' => $oDate->getDate(DATE_FORMAT_UNIXTIME));
         if ($callable) {
             // Return non-delivery
             return !$funcName($this->data, $this->comparison, $aParams);
         }
     }
     return MAX::raiseError('Limitation parameter passed to OA_Maintenance_Priority_DeliveryLimitation_Common is not correct', MAX_ERROR_INVALIDARGS);
 }
Ejemplo n.º 2
0
 function test_parseComponentIdentifier()
 {
     $aComponent = OX_Component::parseComponentIdentifier('testExtension1:testGroup1:testComponent1');
     $this->assertIsA($aComponent, 'array');
     $this->assertEqual(count($aComponent), 3);
     $this->assertEqual($aComponent['0'], 'testExtension1');
     $this->assertEqual($aComponent['1'], 'testGroup1');
     $this->assertEqual($aComponent['2'], 'testComponent1');
 }
Ejemplo n.º 3
0
/**
 * Extracts the package and name of the plugin from its type, creates a plugin
 * object and returns the reference to it.
 *
 * @param string $type
 * @return Plugins_DeliveryLimitations
 */
function &OA_aclGetComponentFromType($type)
{
    $aComponentIdentifier = OX_Component::parseComponentIdentifier($type);
    if (count($aComponentIdentifier) == 2) {
        array_unshift($aComponentIdentifier, 'deliveryLimitations');
    }
    list($extension, $group, $name) = $aComponentIdentifier;
    return OX_Component::factory($extension, $group, $name);
}