Beispiel #1
0
 protected function getErrorText($error)
 {
     $errors = new am4_Settings_Error();
     $template = $errors->getTextByName($error);
     if (!is_null($template)) {
         return do_shortcode($template);
     }
     return __('Template not found:', 'am4-plugin') . $template;
 }
Beispiel #2
0
 function run($atts = array(), $content = '')
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     if (am4PluginsManager::skipProtection()) {
         return do_shortcode($content);
     }
     if (array_key_exists('notactive', $atts)) {
         return $this->getPlugin()->getShortCodeByName('am4guest')->run($atts, $content);
     }
     $errors = new am4_Settings_Error();
     if (!am4PluginsManager::getAPI()->isLoggedIn()) {
         return do_shortcode($errors->getTextByName(@$atts['guest_error']));
     }
     if (!am4PluginsManager::getAPI()->isUserActive()) {
         return do_shortcode($errors->getTextByName(@$atts['user_error']));
     }
     $access = new am4UserAccess();
     //User is logged in let's check his access level;
     if (!empty($atts['have'])) {
         $records = $this->convertToAccessRequirement(@$atts['have']);
         if (!$access->anyTrue($records)) {
             return do_shortcode($errors->getTextByName(@$atts['user_error']));
         }
     }
     if (!empty($atts['not_have'])) {
         $records = $this->convertToAccessRequirement(@$atts['not_have']);
         if (!$access->allFalse($records)) {
             return do_shortcode($errors->getTextByName(@$atts['user_error']));
         }
     }
     return do_shortcode($content);
 }