/** * Wrapper for ModUtil::isCapable(). * * Param takes 'modules' and 'capability' keys. * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string Translation if it was available. */ function smarty_function_iscapable($params, Zikula_View $view) { if (!isset($params['module'])) { $view->trigger_error(__('Error! "module" parameter must be specified.')); } if (!isset($params['capability'])) { $view->trigger_error(__('Error! "module" parameter must be specified.')); } $result = ModUtil::isCapable($module, $params['capability']); // assign or return if (isset($params['assign'])) { $view->assign($params['assign'], $result); } else { return $result; } }
/** * Is a module subscriber capable. * * @param string $module Module name. * * @return boolean */ public static function isSubscriberCapable($module) { return ModUtil::isCapable($module, self::SUBSCRIBER_CAPABLE); }
/** * Retrieve the form fields for the login form that are appropriate for the selected authentication method. * * Parameters passed via POST: * --------------------------- * string form_type An indicator of the type of form the fields will appear on. * array authentication_method An array containing the authentication module name ('modname') and authentication method name ('method'). * * @return Zikula_Response_Ajax An AJAX response containing the form field contents, and the module name and method name of the selected authentication method. * * @throws Zikula_Exception_Fatal Thrown if the authentication module name or method name are not valid. */ public function getLoginFormFields() { $this->checkAjaxToken(); $formType = $this->request->request->get('form_type', false); $selectedAuthenticationMethod = $this->request->request->get('authentication_method', array()); $modname = (isset($selectedAuthenticationMethod['modname']) && !empty($selectedAuthenticationMethod['modname']) ? $selectedAuthenticationMethod['modname'] : false); $method = (isset($selectedAuthenticationMethod['method']) && !empty($selectedAuthenticationMethod['method']) ? $selectedAuthenticationMethod['method'] : false); if (empty($modname) || !is_string($modname)) { throw new Zikula_Exception_Fatal($this->__('An invalid authentication module name was received.')); } elseif (!ModUtil::available($modname)) { throw new Zikula_Exception_Fatal($this->__f('The \'%1$s\' module is not in an available state.', array($modname))); } elseif (!ModUtil::isCapable($modname, 'authentication')) { throw new Zikula_Exception_Fatal($this->__f('The \'%1$s\' module is not an authentication module.', array($modname))); } $loginFormFields = ModUtil::func($modname, 'Authentication', 'getLoginFormFields', array( 'form_type' => $formType, 'method' => $method, )); return new Zikula_Response_Ajax(array( 'content' => $loginFormFields, 'modname' => $modname, 'method' => $method, )); }
/** * Sets the authentication module name for this method. * * @param string $modname The name of the authentication module that defines this method. * * @return void * * @throws Zikula_Exception_Fatal Thrown if the module name is not valid. */ private function setModule($modname) { $modname = trim($modname); if (System::isInstalling() && ($modname == 'Users')) { $this->modname = $modname; } elseif (!empty($modname) && is_string($modname) && ModUtil::available($modname, true) && ModUtil::isCapable($modname, 'authentication')) { $this->modname = $modname; } else { throw new Zikula_Exception_Fatal($this->__f('An invalid \'%1$s\' parameter was received (\'%2$s\').', array( 'modname', empty($modname) ? 'NULL' : $modname) )); } }