/**
  * Event handler here.
  *
  * @param Zikula_Event $event Event handler.
  *
  * @return void
  */
 public function handler(Zikula_Event $event)
 {
     if (array_key_exists($event->data, $this->overrideMap)) {
         $event->data = $this->overrideMap[$event->data];
         $event->stop();
     }
 }
    /**
     * Vetos (denies) a login attempt, and forces the user to change his password.
     *
     * This handler is triggered by the 'user.login.veto' event.  It vetos (denies) a
     * login attempt if the users's account record is flagged to force the user to change
     * his password maintained by the Users module. If the user does not maintain a
     * password on his Users account (e.g., he registered with and logs in with a Google
     * Account or an OpenID, and never established a Users password), then this handler
     * will not trigger a change of password.
     *
     * @param Zikula_Event $event The event that triggered this handler.
     *
     * @return void
     */
    public static function forcedPasswordChangeListener(Zikula_Event $event)
    {
        $userObj = $event->getSubject();

        $userMustChangePassword = UserUtil::getVar('_Users_mustChangePassword', $userObj['uid'], false);

        if ($userMustChangePassword && ($userObj['pass'] != Users_Constant::PWD_NO_USERS_AUTHENTICATION)) {
            $event->stop();
            $event->setData(array(
                'redirect_func'  => array(
                    'modname'   => self::$modname,
                    'type'      => 'user',
                    'func'      => 'changePassword',
                    'args'      => array(
                        'login'     => true,
                    ),
                    'session'   => array(
                        'var'       => 'Users_Controller_User_changePassword',
                        'namespace' => 'Zikula_Users',
                    )
                ),
            ));

            LogUtil::registerError(__("Your log-in request was not completed. You must change your web site account's password first."));
        }
    }
Esempio n. 3
0
 /**
  * Add 'anotherfunction' Event handler .
  *
  * @param Zikula_Event $event Handler.
  *
  * @return void
  */
 public function anotherfunction(Zikula_Event $event)
 {
     // check if this is for this handler
     $subject = $event->getSubject();
     if (!($event['method'] == 'anotherfunction' && $subject instanceof Users_Controller_Admin)) {
         return;
     }
     if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     $view = Zikula_View_plugin::getModulePluginInstance($this->moduleName, $this->pluginName);
     $event->setData($view->fetch('anotherfunction.tpl'));
     $event->stop();
 }
Esempio n. 4
0
 /**
  * Event handler here.
  *
  * @param Zikula_Event $event Event handler.
  *
  * @return void
  */
 public function handler(Zikula_Event $event)
 {
     // check if this is for this handler
     $subject = $event->getSubject();
     if (!($event['method'] == 'extensions' && $subject instanceof Users_Controller_Admin)) {
         return;
     }
     if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     // Zikula Modules and Themes versions
     $view = Zikula_View::getInstance('Users');
     $view->assign('mods', ModuleUtil::getModules());
     $view->assign('themes', ThemeUtil::getAllThemes());
     $event->setData($view->fetch('users_admin_extensions.tpl'));
     $event->stop();
 }
Esempio n. 5
0
    public static function moduleservices(Zikula_Event $event)
    {
        // check if this is for this handler
        $subject = $event->getSubject();
        if (!($event['method'] == 'moduleservices' && strrpos(get_class($subject), '_Controller_Admin'))) {
           return;
        }

        $moduleName = $subject->getName();
        if (!SecurityUtil::checkPermission($moduleName.'::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        $view = Zikula_View::getInstance('Extensions', false);
        $view->assign('currentmodule', $moduleName);

        // notify EVENT here to gather any system service links
        $localevent = new Zikula_Event('module_dispatch.service_links', $subject, array('modname' => $moduleName));
        EventUtil::notify($localevent);
        $sublinks = $localevent->getData();
        $view->assign('sublinks', $sublinks);

        $event->setData($view->fetch('extensions_hookui_moduleservices.tpl'));
        $event->stop();
    }
Esempio n. 6
0
 /**
  * Listens for 'bootstrap.getconfig'
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function getConfigFile(Zikula_Event $event)
 {
     if (is_readable('config/config.php')) {
         include 'config/config.php';
     }
     if (is_readable('config/personal_config.php')) {
         include 'config/personal_config.php';
     }
     if (is_readable('config/multisites_config.php')) {
         include 'config/multisites_config.php';
     }
     foreach ($GLOBALS['ZConfig'] as $config) {
         $event->getSubject()->getServiceManager()->loadArguments($config);
     }
     $event->stop();
 }
Esempio n. 7
0
 /**
  * Template override handler for 'zikula_view.template_override'.
  *
  * @param Zikula_Event $event Event handler.
  *
  * @return void
  */
 public function _templateOverride(Zikula_Event $event)
 {
     if (array_key_exists($event->data, $this->_overrideMap)) {
         $event->data = $this->_overrideMap[$event->data];
         $event->stop();
     }
 }
Esempio n. 8
0
    /**
     * Checks if the user is member of clients group and if it should be member of it
     * @author Albert Pérez Monfort
     * @return bool true authetication succesful
     */
    public static function sendMail(Zikula_Event $event) {
        $args = $event->getArgs();
/*
        $args['html'] = FormUtil::getPassedValue('html', isset($args['html']) ? $args['html'] : 0, 'POST');
        $args['toaddress'] = FormUtil::getPassedValue('toaddress', isset($args['toaddress']) ? $args['toaddress'] : null, 'POST');
        $args['cc'] = FormUtil::getPassedValue('cc', isset($args['cc']) ? $args['cc'] : null, 'POST');
        $args['bcc'] = FormUtil::getPassedValue('bcc', isset($args['bcc']) ? $args['bcc'] : null, 'POST');
        $args['subject'] = FormUtil::getPassedValue('subject', isset($args['subject']) ? $args['subject'] : null, 'POST');
        $args['body'] = FormUtil::getPassedValue('body', isset($args['body']) ? $args['body'] : null, 'POST');
        $args['attachments'] = FormUtil::getPassedValue('attachments', isset($args['attachments']) ? $args['attachments'] : array(), 'POST');
        $args['stringattachments'] = FormUtil::getPassedValue('stringattachments', isset($args['stringattachments']) ? $args['stringattachments'] : array(), 'POST');
        $args['embeddedimages'] = FormUtil::getPassedValue('embeddedimages', isset($args['embeddedimages']) ? $args['embeddedimages'] : array(), 'POST');
*/
        // include php mailsender class file
        if (file_exists($file = "modules/SiriusXtecMailer/includes/mailsender.class.php")) {
            require_once($file);
        } else {
            return false;
        }

        // include php message class file
        if (file_exists($file = "modules/SiriusXtecMailer/includes/message.class.php")) {
            require_once($file);
        } else {
            return false;
        }

        $enabled = ModUtil::getVar('SiriusXtecMailer', 'enabled');

        if ($enabled == 0) {
            // Add processed flag
            //$args['processed'] = 1;
            //$result = ModUtil::apiFunc('Mailer', 'user', 'sendmessage', $args);
            //return $result;
            return false;
        }

        $idApp = ModUtil::getVar('SiriusXtecMailer', 'idApp');
        $replyAddress = ModUtil::getVar('SiriusXtecMailer', 'replyAddress');
        $sender = ModUtil::getVar('SiriusXtecMailer', 'sender');
        $environment = ModUtil::getVar('SiriusXtecMailer','environment');
        $log = ModUtil::getVar('SiriusXtecMailer', 'log');
        $debug = ModUtil::getVar('SiriusXtecMailer', 'debug');
        $logpath = ModUtil::getVar('SiriusXtecMailer', 'logpath');

        $mail = new mailsender($idApp, $replyAddress, $sender, $environment, $log, $debug, $logpath);

        // add body content type
        $contenttypes = ModUtil::func('SiriusXtecMailer', 'admin', 'getContentTypes');

        // set HTML mail if required
        if (isset($args['html']) && is_bool($args['html'])) {
            if ($args['html']) {
                $bodyType = 'text/html';
            } else {
                $bodyType = TEXTPLAIN;
            }
        } else {
            $bodyType = $contenttypes[ModUtil::getVar('SiriusXtecMailer', 'contenttype')];
        }

        $message = new message($bodyType, $log, $debug, $logpath);

        // add any to addresses
        if (is_array($args['toaddress'])) {
            foreach ($args['toaddress'] as $to) {
                $message->set_to($to);
            }
        } else {
            // $toaddress is not an array -> old logic
            // process multiple names entered in a single field separated by commas (#262)
            foreach (explode(',', $args['toaddress']) as $to) {
                $message->set_to($to);
            }
        }

        // add any cc addresses
        if (isset($args['cc']) && is_array($args['cc'])) {
            foreach ($args['cc'] as $cc) {
                $message->set_cc($cc['address']);
            }
        }

        // add any bcc addresses
        if (isset($args['bcc']) && is_array($args['bcc'])) {
            foreach ($args['bcc'] as $bcc) {
                $message->set_bcc($bcc['address']);
            }
        }

        // add message subject and body
        $subject = $args['subject'];
        $message->set_subject($subject);
        $body = $args['body'];
        $message->set_bodyContent($body);

        // add attachments
        if (isset($args['attachments']) && !empty($args['attachments'])) {
            foreach ($args['attachments'] as $attachment) {
                if (is_array($attachment)) {
                    if (count($attachment) != 4) {
                        // skip invalid arrays
                        continue;
                    }
                    $message->set_attachByPathOnAppServer($attachment[1], $attachment[0]);
                } else {
                    $message->set_attachByPathOnAppServer(basename($attachment[0]), $attachment[0]);
                }
            }
        }

        // add string attachments.
        if (isset($args['stringattachments']) && !empty($args['stringattachments'])) {
            foreach ($args['stringattachments'] as $attachment) {
                if (is_array($attachment) && count($attachment) == 4) {
                    $message->set_attachByContent($attachment[1], $attachment[0], $attachment[3]);
                }
            }
        }

        // add embedded images
        if (isset($args['embeddedimages']) && !empty($args['embeddedimages'])) {
            foreach ($args['embeddedimages'] as $embeddedimage) {
                $message->set_attachByPathOnAppServer(basename($embeddedimage), $embeddedimage);
            }
        }

        //add message to mailsender
        if (!$mail->add($message)) {
            // message not added
            return LogUtil::registerError(__f('Error! A problem occurred while adding an e-mail message to \'%1$s\' (%2$s) with subject \'%3$s\'', array($args['toname'], $args['toaddress'][0], $args['subject'])));
        }

        // send message
        if (!$mail->send_mail()) {
            // message not sent
            return LogUtil::registerError(__f('Error! A problem occurred while sending an e-mail message to \'%1$s\' (%2$s) with subject \'%3$s\'', array($args['toname'], $args['toaddress'][0], $args['subject'])));
        }
		$event->stop();
		$event->setData(true);
        return true; // message sent    
    }
Esempio n. 9
0
    /**
     * Vetos (denies) a login attempt, and forces the user to accept policies.
     *
     * This handler is triggered by the 'user.login.veto' event.  It vetos (denies) a
     * login attempt if the users's Legal record is flagged to force the user to accept
     * one or more legal agreements.
     *
     * @param Zikula_Event $event The event that triggered this handler.
     *
     * @return void
     */
    public static function acceptPoliciesListener(Zikula_Event $event)
    {
        $domain = ZLanguage::getModuleDomain(Legal_Constant::MODNAME);

        $termsOfUseActive               = ModUtil::getVar(Legal_Constant::MODNAME, Legal_Constant::MODVAR_TERMS_ACTIVE, false);
        $privacyPolicyActive            = ModUtil::getVar(Legal_Constant::MODNAME, Legal_Constant::MODVAR_PRIVACY_ACTIVE, false);
        $agePolicyActive                = (ModUtil::getVar(Legal_Constant::MODNAME, Legal_Constant::MODVAR_MINIMUM_AGE, 0) > 0);
        $cancellationRightPolicyActive  = ModUtil::getVar(Legal_Constant::MODNAME, Legal_Constant::MODVAR_CANCELLATIONRIGHTPOLICY_ACTIVE, false);
        $tradeConditionsActive          = ModUtil::getVar(Legal_Constant::MODNAME, Legal_Constant::MODVAR_TRADECONDITIONS_ACTIVE, false);

        if ($termsOfUseActive || $privacyPolicyActive || $agePolicyActive || $cancellationRightPolicyActive || $tradeConditionsActive) {
            $userObj = $event->getSubject();

            if (isset($userObj) && ($userObj['uid'] > 2)) {
                if ($termsOfUseActive) {
                    $termsOfUseAcceptedDateTimeStr = UserUtil::getVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $userObj['uid'], false);
                    $termsOfUseAccepted = isset($termsOfUseAcceptedDateTimeStr) && !empty($termsOfUseAcceptedDateTimeStr);
                } else {
                    $termsOfUseAccepted = true;
                }

                if ($privacyPolicyActive) {
                    $privacyPolicyAcceptedDateTimeStr = UserUtil::getVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $userObj['uid'], false);
                    $privacyPolicyAccepted = isset($privacyPolicyAcceptedDateTimeStr) && !empty($privacyPolicyAcceptedDateTimeStr);
                } else {
                    $privacyPolicyAccepted = true;
                }

                if ($agePolicyActive) {
                    $agePolicyAcceptedDateTimeStr = UserUtil::getVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $userObj['uid'], false);
                    $agePolicyAccepted = isset($agePolicyAcceptedDateTimeStr) && !empty($agePolicyAcceptedDateTimeStr);
                } else {
                    $agePolicyAccepted = true;
                }

                if ($cancellationRightPolicyActive) {
                    $cancellationRightPolicyAcceptedDateTimeStr = UserUtil::getVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $userObj['uid'], false);
                    $cancellationRightPolicyAccepted = isset($cancellationRightPolicyAcceptedDateTimeStr) && !empty($cancellationRightPolicyAcceptedDateTimeStr);
                } else {
                    $cancellationRightPolicyAccepted = true;
                }

                if ($tradeConditionsActive) {
                    $tradeConditionsAcceptedDateTimeStr = UserUtil::getVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $userObj['uid'], false);
                    $tradeConditionsAccepted = isset($tradeConditionsAcceptedDateTimeStr) && !empty($tradeConditionsAcceptedDateTimeStr);
                } else {
                    $tradeConditionsAccepted = true;
                }

                if (!$termsOfUseAccepted || !$privacyPolicyAccepted || !$agePolicyAccepted || !$cancellationRightPolicyAccepted || !$tradeConditionsAccepted) {
                    $event->stop();
                    $event->data['redirect_func']  = array(
                            'modname'   => Legal_Constant::MODNAME,
                            'type'      => 'user',
                            'func'      => 'acceptPolicies',
                            'args'      => array(
                                'login'     => true,
                            ),
                            'session'   => array(
                                'var'       => 'Legal_Controller_User_acceptPolicies',
                                'namespace' => Legal_Constant::MODNAME,
                            )
                        );
                    LogUtil::registerError(__('Your log-in request was not completed. You must review and confirm your acceptance of one or more site policies prior to logging in.', $domain));
                }
            }
        }
    }