Exemple #1
0
 function __toString()
 {
     $value = '';
     if ($this->id) {
         switch ($this->type) {
             case am4Access::PRODUCT:
                 $titles = am4PluginsManager::getAMProducts();
                 break;
             case am4Access::CATEGORY:
                 $titles = am4PluginsManager::getAMCategories();
                 break;
             default:
                 throw new Exception('Unknown record type!');
         }
         if ($this->id == -1) {
             $value = "<b>" . _('Any Product') . "</b> ";
         } else {
             $value = "<b>" . $titles[$this->id] . "</b> ";
         }
         $value .= _(' from ') . ($this->start == 0 ? _('start') : $this->start . 'd') . _(' to ') . (in_array(am4Access::EXPIRED, $this->status) ? _(' forever ') : ($this->stop == PHP_INT_MAX ? _('expiration') : $this->stop . 'd'));
         return $value;
     }
     return $value;
 }
Exemple #2
0
    function resourceAccess($id, $access = array(), $varname = 'access', $text = null, $without_period = false)
    {
        if (!$text) {
            $text = __('Choose Products and/or Product Categories that allows access', 'am4-plugin');
        }
        $uniqid = uniqid('amw-');
        ?>
                
                <div class="resourceaccess <?php 
        echo $uniqid;
        ?>
" id="<?php 
        echo $id;
        ?>
" data-varname='<?php 
        echo $varname;
        ?>
'><?php 
        _e($text);
        ?>
<br/>
                                <input type='hidden' class='resourceaccess-init' value='<?php 
        if ($access) {
            $this->e(aMemberJson::init($this->addProductTitle($access)));
        } else {
            print '{}';
        }
        ?>
' />
                                <select class='category' size=1>
                                    <option value='' ><?php 
        _e('Please select an item...', 'am4-plugin');
        ?>
</option>
                                    <optgroup class='category' label='<?php 
        _e('Product Categories', 'am4-plugin');
        ?>
'>
                                    <option value='-1' style='font-weight: bold'><?php 
        _e('Any Product', 'am4-plugin');
        ?>
</option>
                                        <?php 
        $this->options(am4PluginsManager::getAMCategories());
        ?>
                                    </optgroup>
                                    <optgroup class='product' label='<?php 
        _e('Products', 'am4-plugin');
        ?>
'>
                                        <?php 
        $this->options(am4PluginsManager::getAMProducts());
        ?>
                                    </optgroup>
                                </select>
                            <div class='category-list'></div>
                            <div class='product-list'></div>
                            <br />                        
                </div>        
                <script type="text/javascript">
                    jQuery(document).ready(function ($){
                        jQuery('.<?php 
        echo $uniqid;
        ?>
').resourceAccess({without_period: <?php 
        echo $without_period ? 'true' : 'false';
        ?>
});
                    });
                </script>
                <?php 
    }