# firebox/1.0.6/Inc/Core/FB/Assignments.php

FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin &amp; Cart Abandonment, version 1.0.6. 146 lines.

- Page: https://pluginprobe.com/plugins/firebox/1.0.6/code/Inc/Core/FB/Assignments.php
- Raw: https://pluginprobe.com/plugins/firebox/1.0.6/raw/Inc/Core/FB/Assignments.php
- Modified: 2021-10-22T10:30:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/firebox/1.0.6/code/Inc/Core/FB/Assignments.php#L10-L20`.

```php
<?php
/**
 * @package         FireBox
 * @version         1.0.6 Free
 * 
 * @author          FirePlugins <info@fireplugins.com>
 * @link            https://www.fireplugins.com
 * @copyright       Copyright © 2021 FirePlugins All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/

namespace FireBox\Core\FB;

if (!defined('ABSPATH'))
{
	exit; // Exit if accessed directly.
}

use FPFramework\Libs\Registry;

class Assignments
{
    /**
	 *  Box
	 *
	 *  @var  Box
	 */
    private $box;

    /**
	 *  Box Settings
	 *
	 *  @var  object
	 */
    private $boxSettings;
    
    /**
	 *  Factory
	 *
	 *  @var  object
	 */
	protected $factory;

	/**
	 *  Local assignments list
	 *
	 *  @var  array
	 */
	private $assignments = [
		'cookietype|local',
        
    ];

	/**
	 *  Class Constructor
	 *
	 *  @param  object  $item  The object to be checked
	 */
	public function __construct($box, $factory = null)
	{
        if (!$box)
        {
            return;
        }
        $this->box = $box;
        $this->boxSettings = $this->box->getBoxSettings();
        
        if (!$factory)
        {
            $factory = new \FPFramework\Base\Factory();
        }
        $this->factory = $factory;
    }

    /**
     *  Pass all checks
     *
     *  @return  boolean  Returns true if all assignments pass
     */
    public function passAll()
    {
        $pass = true;
        
        foreach ($this->assignments as $key => $assignment)
        {
            // Break if not passed
            if (!$pass)
            {
                break;
            }

            $assignmentData = explode('|', $assignment);

            $assignment = $assignmentData[0];
            $type = isset($assignmentData[1]) ? $assignmentData[1] : '';

            $method = 'pass' . $assignment;

            // Skip item if there is no assosiated method
            if (!method_exists($this, $method))
            {
                continue;
            }
            
            $prefix = empty($type) ? 'assignments.' : '';

            $assign = $prefix . 'assign_' . $assignment;
            
            // Skip item if assignment is missing
            if (!$this->boxSettings->params->exists($assign) && !$this->boxSettings->params->exists($assign . '_param_type'))
            {
                continue;
            }
            
            $pass = $this->$method();
        }
        
        return $pass;
    }
    
    /**
     *  Pass Check for Box Cookie
     *
     *  @return  bool
     */
    private function passCookieType()
    {
        // Skip if assignment is disabled
        if ($this->boxSettings->params->get('assign_cookietype') == 'never')
        {
            return true;
        }

        // Skip if box is on Test Mode and a Super User is logged in
        if ($this->boxSettings->params->get('testmode') && is_user_logged_in() && current_user_can('manage_options'))
        {
            return true;
        }

        $cookie = $this->box->getCookie($this->boxSettings->ID);

        return !$cookie->exist();
    }

    
}
```
