function MAX_displayAcls($acls, $aParams) { $tabindex =& $GLOBALS['tabindex']; $page = basename($_SERVER['SCRIPT_NAME']); $conf = $GLOBALS['_MAX']['CONF']; echo "<form action='{$page}' method='post'>"; echo "<label><img src='" . OX::assetPath() . "/images/icon-acl-add.gif' align='absmiddle'> " . $GLOBALS['strACLAdd'] . ": "; echo "<select name='type' accesskey='{$GLOBALS['keyAddNew']}' tabindex='" . $tabindex++ . "'>"; $deliveryLimitations = OX_Component::getComponents('deliveryLimitations', null, false); foreach ($deliveryLimitations as $pluginName => $plugin) { if ($plugin->isAllowed($page)) { echo "<option value='{$pluginName}'>" . $plugin->getName() . "</option>"; } } echo "</select></label>"; echo " "; echo "<input type='submit' class='flat' name='action[new]' value='" . $GLOBALS['strAdd'] . "'"; phpAds_ShowBreak(); echo "<br />"; $aErrors = OX_AclCheckInputsFields($acls, $page); if (!empty($GLOBALS['action'])) { // We are part way through making changes, show a message //echo "<br>"; echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/warning.gif' align='absmiddle'>"; echo "<span class='tab-s'>{$GLOBALS['strUnsavedChanges']}</span><br>"; echo "</div>"; } elseif (!MAX_AclValidate($page, $aParams)) { echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/warning.gif' align='absmiddle'>"; echo "<span class='tab-r'>{$GLOBALS['strDeliveryLimitationsDisagree']}</span><br>"; echo "</div>"; } if ($aErrors !== true) { echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/warning.gif' align='absmiddle'>"; echo "<span class='tab-s'>{$GLOBALS['strDeliveryLimitationsInputErrors']}</span><br><ul>"; foreach ($aErrors as $error) { echo "<li><span class='tab-s'>{$error}</span><br></li>"; } echo "</ul></div>"; } foreach ($aParams as $name => $value) { echo "<input type='hidden' name='{$name}' value='{$value}' />"; } echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>"; echo "<tr><td height='25' colspan='4' bgcolor='#FFFFFF'><b>{$GLOBALS['strDeliveryLimitations']}</b></td></tr>"; echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>"; if (empty($acls)) { echo "<tr><td height='24' colspan='4' bgcolor='#F6F6F6'> {$GLOBALS['strNoLimitations']}</td></tr>"; echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>"; } else { echo "<tr><td height='25' colspan='4' bgcolor='#F6F6F6'> {$GLOBALS['strOnlyDisplayWhen']}</td></tr>"; echo "<tr><td colspan='4'><img src='" . OX::assetPath() . "/images/break-el.gif' width='100%' height='1'></td></tr>"; foreach ($acls as $aclId => $acl) { if ($deliveryLimitationPlugin = OA_aclGetComponentFromRow($acl)) { $deliveryLimitationPlugin->init($acl); $deliveryLimitationPlugin->count = count($acls); if ($deliveryLimitationPlugin->isAllowed($page)) { $deliveryLimitationPlugin->display(); } } } } echo "<tr><td height='30' colspan='2'>"; if (!empty($acls)) { $url = $page . '?'; foreach ($aParams as $name => $value) { $url .= "{$name}={$value}&"; } $url .= "action[clear]=true"; echo "<img src='" . OX::assetPath() . "/images/icon-recycle.gif' border='0' align='absmiddle'> \n <a href='{$url}'>{$GLOBALS['strRemoveAllLimitations']}</a> \n "; } echo "</td><td height='30' colspan='2' align='{$GLOBALS['phpAds_TextAlignRight']}'>"; echo "</td></tr>"; echo "</table>"; }
function test_OA_aclGetComponentFromRow() { $row = array('type' => 'Dummy:Dummy', 'logical' => 'and', 'data' => 'AaAaA'); $plugin =& OA_aclGetComponentFromRow($row); $this->assertTrue(is_a($plugin, 'Plugins_DeliveryLimitations_Dummy_Dummy')); $this->assertEqual('and', $plugin->logical); $this->assertEqual('AaAaA', $plugin->data); }
/** * Do check on all ACL inputs values * * @param array $aAcls * @return boolean array of strings with errors messages if inputs aren't correct, true if is correct */ function OX_AclCheckInputsFields($aAcls, $page) { $aErrors = array(); foreach ($aAcls as $aclId => $acl) { if ($deliveryLimitationPlugin = OA_aclGetComponentFromRow($acl)) { $deliveryLimitationPlugin->init($acl); if ($deliveryLimitationPlugin->isAllowed($page)) { $checkResult = $deliveryLimitationPlugin->checkComparison($acl); if ($checkResult !== true) { $aErrors[] = $checkResult; } $checkResult = $deliveryLimitationPlugin->checkInputData($acl); if ($checkResult !== true) { $aErrors[] = $checkResult; } } } } if (count($aErrors) > 0) { return $aErrors; } return true; }