/**
 * Render "Email-based identity confirmation" settings.
 *
 * Callback for rendering the "Email-based identity confirmation"
 *  section settings on the plugin's page.
 *
 * @return void
 */
function rublon2factor_render_protection_types()
{
    echo '<p class="rublon-settings-desc">' . __('Every user is protected via email by default. You can turn this off for selected roles. For more security, you can also require selected roles to use the Rublon mobile app.', 'rublon') . '</p>';
    echo '<p class="rublon-settings-desc"><strong>' . __('Notice:', 'rublon') . ' </strong>' . __('Users of the Rublon mobile app are always protected, regardless of this setting. Users with no minimum protection can turn on protection via email themselves in their profile. Users with any level of minimum protection cannot turn it off.', 'rublon') . '</p>';
    $settings = RublonHelper::getSettings('additional');
    // Retrieve the roles used on this site.
    $roles = RublonHelper::getUserRoles();
    $role_ids = array();
    echo '<div class="rublon-settings-setting-name">';
    echo '  <div class="rublon-settings-setting-label"></div>';
    echo '  <div class="rublon-setting-header"><strong>' . __('Minimum Protection', 'rublon') . '</strong></div>';
    echo '</div>';
    foreach ($roles as $role) {
        $checked = '';
        // Prepare role IDs used as the option keys.
        $role_id = RublonHelper::prepareRoleId($role);
        $role_ids[] = '\'' . $role_id . '\'';
        if (!empty($settings[$role_id])) {
            $mobileSelected = '';
            $emailSelected = '';
            $noneSelected = '';
            $lock1Visibility = '';
            $lock2Visibility = '';
            $lock3Visibility = '';
            // 			switch ($settings[$role_id]) {
            switch (RublonRolesProtection::getRoleProtectionType($role)) {
                case RublonHelper::PROTECTION_TYPE_MOBILE_EVERYTIME:
                    $mobileEverytimeSelected = ' selected';
                    $lock1Visibility = 'hidden';
                    $lock2Visibility = 'visible';
                    $lock3Visibility = 'visible';
                    $lock4Visibility = 'visible';
                    break;
                case RublonHelper::PROTECTION_TYPE_MOBILE:
                    $mobileSelected = ' selected';
                    $lock1Visibility = 'hidden';
                    $lock2Visibility = 'visible';
                    $lock3Visibility = 'visible';
                    $lock4Visibility = 'hidden';
                    break;
                case RublonHelper::PROTECTION_TYPE_EMAIL:
                    $emailSelected = ' selected';
                    $lock1Visibility = 'hidden';
                    $lock2Visibility = 'visible';
                    $lock3Visibility = 'hidden';
                    $lock4Visibility = 'hidden';
                    break;
                case RublonHelper::PROTECTION_TYPE_NONE:
                    $noneSelected = ' selected';
                    $lock1Visibility = 'visible';
                    $lock2Visibility = 'hidden';
                    $lock3Visibility = 'hidden';
                    $lock4Visibility = 'hidden';
                    break;
            }
        }
        if (!empty($settings[$role_id]) && $settings[$role_id] == 'on') {
            $checked = ' checked';
        }
        echo '<div class="rublon-settings-setting-name">';
        echo '	<label for="rublon-role-' . $role_id . '-dropdown" class="rublon-settings-setting-label"><div class="rublon-settings-setting-label">' . translate_user_role(before_last_bar($role)) . '</div></label>';
        echo '	<select id="rublon-role-' . $role_id . '-dropdown" name="' . RublonHelper::RUBLON_ADDITIONAL_SETTINGS_KEY . '[' . $role_id . ']">';
        $forceMobileApp = RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_FORCE_MOBILE_APP);
        if ($forceMobileApp and RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_IGNORE_TRUSTED_DEVICE)) {
            echo '		<option value="mobileEverytime"' . $mobileEverytimeSelected . '>' . __('Mobile app everytime', 'rublon') . '</option>';
        }
        if ($forceMobileApp) {
            echo '		<option value="mobile"' . $mobileSelected . '>' . __('Mobile app', 'rublon') . '</option>';
        }
        echo '		<option value="email"' . $emailSelected . '>' . __('Email', 'rublon') . '</option>';
        echo '		<option value="none"' . $noneSelected . '>' . __('None', 'rublon') . '</option>';
        echo '	</select>';
        echo '<label class="rublon-label rublon-label-' . $role_id . '" for="rublon-role-' . $role_id . '-dropdown">';
        echo '	<div class="rublon-lock-container rublon-unlocked-container rublon-' . $role_id . '-unlocked ' . $lock1Visibility . '"><img class="rublon-lock rublon-unlocked" src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/unlocked.png" /></div>';
        echo '	<div class="rublon-lock-container rublon-locked-container rublon-' . $role_id . '-locked ' . $lock2Visibility . '"><img class="rublon-lock rublon-locked" src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/locked.png" /></div>';
        echo '	<div class="rublon-lock-container rublon-locked-container rublon-' . $role_id . '-locked2 ' . $lock3Visibility . '"><img class="rublon-lock rublon-locked" src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/locked.png" /></div>';
        echo '	<div class="rublon-lock-container rublon-locked-container rublon-' . $role_id . '-locked3 ' . $lock4Visibility . '"><img class="rublon-lock rublon-locked" src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/locked.png" /></div>';
        echo '</label>';
        echo '</div>';
    }
    echo '<script>//<![CDATA[
		if (RublonWP) {
			RublonWP.roles = [' . implode(', ', $role_ids) . '];
			RublonWP.setUpRoleProtectionTypeChangeListener();  
		}
	//]]></script>';
}
 function isConfirmationRequired()
 {
     return RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_OPERATION_CONFIRMATION) and (!$this->hasAdminUI() or in_array($this->getAction(), RublonConfirmations::getSettings()));
 }
 /**
  * Check if given protection type is available for this consumer.
  * 
  * @param string $type
  * @return boolean
  */
 static function isProtectionTypeAvailable($type)
 {
     $forceMobileApp = RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_FORCE_MOBILE_APP);
     switch ($type) {
         case RublonHelper::PROTECTION_TYPE_MOBILE:
             return $forceMobileApp;
         case RublonHelper::PROTECTION_TYPE_MOBILE_EVERYTIME:
             return $forceMobileApp and RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_IGNORE_TRUSTED_DEVICE);
         default:
             return true;
     }
 }
Example #4
0
 /**
  * Check if this is a Business Edition.
  * 
  * @return boolean
  */
 static function isBusinessEdition()
 {
     return RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_FLAG_BUSINESS_EDITION);
 }