/**
     * 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."));
        }
    }
Beispiel #2
0
 public static function getTypes(Zikula_Event $event)
 {
     $types = $event->getSubject();
     // add content types
     $types->add('Content_ContentType_Author');
     $types->add('Content_ContentType_Block');
     $types->add('Content_ContentType_Breadcrumb');
     $types->add('Content_ContentType_Camtasia');
     $types->add('Content_ContentType_ComputerCode');
     $types->add('Content_ContentType_ContentItem');
     $types->add('Content_ContentType_TableOfContents');
     $types->add('Content_ContentType_FlashMovie');
     $types->add('Content_ContentType_Flickr');
     $types->add('Content_ContentType_GoogleMap');
     $types->add('Content_ContentType_Heading');
     $types->add('Content_ContentType_Html');
     $types->add('Content_ContentType_JoinPosition');
     $types->add('Content_ContentType_ModuleFunc');
     $types->add('Content_ContentType_OpenStreetMap');
     $types->add('Content_ContentType_PageNavigation');
     $types->add('Content_ContentType_Quote');
     $types->add('Content_ContentType_Rss');
     $types->add('Content_ContentType_Slideshare');
     $types->add('Content_ContentType_TabNavigation');
     $types->add('Content_ContentType_Unfiltered');
     $types->add('Content_ContentType_Vimeo');
     $types->add('Content_ContentType_YouTube');
     // add layout types
     $types->add('Content_LayoutType_Column1');
     $types->add('Content_LayoutType_Column1woheader');
     $types->add('Content_LayoutType_Column1top');
     $types->add('Content_LayoutType_Column2header');
     $types->add('Content_LayoutType_Column2d2575');
     $types->add('Content_LayoutType_Column2d3070');
     $types->add('Content_LayoutType_Column2d3366');
     $types->add('Content_LayoutType_Column2d3862');
     $types->add('Content_LayoutType_Column2d6238');
     $types->add('Content_LayoutType_Column2d6633');
     $types->add('Content_LayoutType_Column2d7030');
     $types->add('Content_LayoutType_Column2d7525');
     $types->add('Content_LayoutType_Column3header');
     $types->add('Content_LayoutType_Column3d252550');
     $types->add('Content_LayoutType_Column3d255025');
     $types->add('Content_LayoutType_Column3d502525');
     $types->add('Content_LayoutType_Column4d25252525');
     $types->add('Content_LayoutType_Column212');
     $types->add('Content_LayoutType_Column21212');
     $types->add('Content_LayoutType_Column21212rightcol');
     // add Twitter Bootstrap layout types
     $types->add('Content_LayoutType_BootstrapColumn2c6c6');
     $types->add('Content_LayoutType_BootstrapColumn2c8c4');
     $types->add('Content_LayoutType_BootstrapColumn2c4c8');
     $types->add('Content_LayoutType_BootstrapColumn3c4c4c4');
     $types->add('Content_LayoutType_BootstrapColumn3c6c3c3');
     $types->add('Content_LayoutType_BootstrapColumn3c3c6c3');
     $types->add('Content_LayoutType_BootstrapColumn3c3c3c6');
     $types->add('Content_LayoutType_BootstrapColumn4c3c3c3c3');
 }
Beispiel #3
0
 /**
  * Listener for the `module.content.gettypes` event.
  *
  * This event occurs when the Content module is 'searching' for Content plugins.
  * The subject is an instance of Content_Types.
  * You can register custom content types as well as custom layout types.
  *
  * @param Zikula_Event $event The event instance.
  */
 public static function contentGetTypes(Zikula_Event $event)
 {
     // intended is using the add() method to add a plugin like below
     $types = $event->getSubject();
     // plugin for showing a single item
     $types->add('Reviews_ContentType_Item');
     // plugin for showing a list of multiple items
     $types->add('Reviews_ContentType_ItemList');
 }
Beispiel #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
     if (!($event->getSubject() instanceof Users_Api_Admin && $event['modfunc'][1] == 'getlinks')) {
         return;
     }
     if (SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) {
         $event->data[] = array('url' => ModUtil::url('Users', 'admin', 'somelink'), 'text' => __('Here is another link'));
     }
 }
 /**
  * On an module remove hook call this listener
  *
  * Listens for the 'user.account.create' event.
  *
  * @param Zikula_Event $event Event.
  */
 public static function onCreateUser(Zikula_Event $event)
 {
     if (!ModUtil::getVar('Dashboard', 'widgetsnewuser', false)) {
         return;
     }
     $user = $event->getSubject();
     $helper = new Dashboard_Helper_WidgetHelper(ServiceUtil::getService('doctrine.entitymanager'));
     $widgets = $helper->getRegisteredWidgets($user['uid']);
     foreach ($widgets as $widget) {
         Dashboard_Util::addUserWidget($user['uid'], $widget);
     }
 }
Beispiel #6
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();
 }
Beispiel #7
0
 /**
  * Listener for the `user.account.delete` event.
  *
  * Occurs after a user is deleted from the system.
  * All handlers are notified.
  * The full user record deleted is available as the subject.
  * This is a storage-level event, not a UI event. It should not be used for UI-level actions such as redirects.
  * The subject of the event is set to the user record that is being deleted.
  *
  * @param Zikula_Event $event The event instance.
  */
 public static function delete(Zikula_Event $event)
 {
     ModUtil::initOOModule('Reviews');
     $userRecord = $event->getSubject();
     $uid = $userRecord['uid'];
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repo = $entityManager->getRepository('Reviews_Entity_Review');
     // delete all reviews created by this user
     $repo->deleteCreator($uid);
     // note you could also do: $repo->updateCreator($uid, 2);
     // set last editor to admin (2) for all reviews updated by this user
     $repo->updateLastEditor($uid, 2);
     // note you could also do: $repo->deleteLastEditor($uid);
 }
Beispiel #8
0
 /**
  * Event handler.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function handler(Zikula_Event $event)
 {
     // subject must be an instance of Theme class.
     $theme = $event->getSubject();
     if (!$theme instanceof Theme) {
         return;
     }
     // register output filter to add MultiHook environment if requried
     if (ModUtil::available('MultiHook')) {
         $modinfo = ModUtil::getInfoFromName('MultiHook');
         if (version_compare($modinfo['version'], '5.0', '>=') == 1) {
             $theme->load_filter('output', 'multihook');
             ModUtil::apiFunc('MultiHook', 'theme', 'preparetheme');
         }
     }
 }
Beispiel #9
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();
 }
Beispiel #10
0
    /**
     * Respond to 'get.pending_content' events with registration requests pending approval.
     *
     * When a 'get.pending_content' event is fired, the Users module will respond with the
     * number of registration requests that are pending administrator approval. The number
     * pending may not equal the total number of outstanding registration requests, depending
     * on how the 'moderation_order' module configuration variable is set, and whether e-mail
     * address verification is required.
     *
     * If the 'moderation_order' variable is set to require approval after e-mail verification
     * (and e-mail verification is also required) then the number of pending registration
     * requests will equal the number of registration requested that have completed the
     * verification process but have not yet been approved. For other values of
     * 'moderation_order', the number should equal the number of registration requests that
     * have not yet been approved, without regard to their current e-mail verification state.
     * If moderation of registrations is not enabled, then the value will always be 0.
     *
     * In accordance with the 'get_pending_content' conventions, the count of pending
     * registrations, along with information necessary to access the detailed list, is
     * assemped as a {@link Zikula_Provider_AggregateItem} and added to the event
     * subject's collection.
     *
     * @param Zikula_Event $event The event that was fired, a 'get_pending_content' event.
     *
     * @return void
     */
    public static function pendingContentListener(Zikula_Event $event)
    {
        if (SecurityUtil::checkPermission('Users::', '::', ACCESS_MODERATE)) {
            $approvalOrder = ModUtil::getVar(self::$modname, 'moderation_order', Users_Constant::APPROVAL_ANY);
            if ($approvalOrder == Users_Constant::APPROVAL_AFTER) {
                $numPendingApproval = ModUtil::apiFunc(self::$modname, 'registration', 'countAll', array('filter' => array('approved_by' => 0, 'isverified' => true)));
            } else {
                $numPendingApproval = ModUtil::apiFunc(self::$modname, 'registration', 'countAll', array('filter' => array('approved_by' => 0)));
            }

            if (!empty($numPendingApproval)) {
                $collection = new Zikula_Collection_Container(self::$modname);
                $collection->add(new Zikula_Provider_AggregateItem('registrations', __('Registrations pending approval'), $numPendingApproval, 'admin', 'viewRegistrations'));
                $event->getSubject()->add($collection);
            }
        }
    }
Beispiel #11
0
 /**
  * Listener for the `user.account.delete` event.
  *
  * Occurs after a user is deleted from the system.
  * All handlers are notified.
  * The full user record deleted is available as the subject.
  * This is a storage-level event, not a UI event. It should not be used for UI-level actions such as redirects.
  * The subject of the event is set to the user record that is being deleted.
  *
  * @param Zikula_Event $event The event instance.
  */
 public static function delete(Zikula_Event $event)
 {
     ModUtil::initOOModule('MUVideo');
     $userRecord = $event->getSubject();
     $uid = $userRecord['uid'];
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repo = $entityManager->getRepository('MUVideo_Entity_Collection');
     // set creator to admin (2) for all collections created by this user
     $repo->updateCreator($uid, 2);
     // set last editor to admin (2) for all collections updated by this user
     $repo->updateLastEditor($uid, 2);
     $repo = $entityManager->getRepository('MUVideo_Entity_Movie');
     // set creator to admin (2) for all movies created by this user
     $repo->updateCreator($uid, 2);
     // set last editor to admin (2) for all movies updated by this user
     $repo->updateLastEditor($uid, 2);
 }
 /**
  * On an module remove hook call this listener
  *
  * Listens for the 'user.account.delete' event.
  *
  * @param Zikula_Event $event Event.
  */
 public static function onRemoveUser(Zikula_Event $event)
 {
     $user = $event->getSubject();
     Dashboard_Util::removeUserWidgets($user['uid']);
 }
Beispiel #13
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();
    }
Beispiel #14
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();
 }
Beispiel #15
0
 /**
  * Listener for the `module.users.ui.login.succeeded` event.
  *
  * Occurs right after a successful attempt to log in, and just prior to redirecting the user to the desired page.
  * All handlers are notified.
  *
  * The event subject contains the user's user record (from `UserUtil::getVars($event['uid'])`).
  * The arguments of the event are as follows:
  *     `'authentication_module'` an array containing the authenticating module name (`'modname'`) and method (`'method'`)
  *       used to log the user in.
  *     `'redirecturl'` will contain the value of the 'returnurl' parameter, if one was supplied, or an empty
  *       string. This can be modified to change where the user is redirected following the login.
  *
  * __The `'redirecturl'` argument__ controls where the user will be directed at the end of the log-in process.
  * Initially, it will be the value of the returnurl parameter provided to the log-in process, or blank if none was provided.
  *
  * The action following login depends on whether WCAG compliant log-in is enabled in the Users module or not. If it is enabled,
  * then the user is redirected to the returnurl immediately. If not, then the user is first displayed a log-in landing page,
  * and then meta refresh is used to redirect the user to the returnurl.
  *
  * If a `'redirecturl'` is specified by any entity intercepting and processing the `module.users.ui.login.succeeded` event, then
  * the URL provided replaces the one provided by the returnurl parameter to the login process. If it is set to an empty
  * string, then the user is redirected to the site's home page. An event handler should carefully consider whether
  * changing the `'redirecturl'` argument is appropriate. First, the user may be expecting to return to the page where
  * he was when he initiated the log-in process. Being redirected to a different page might be disorienting to the user.
  * Second, all event handlers are being notified of this event. This is not a `notify()` event. An event handler
  * that was notified prior to the current handler may already have changed the `'redirecturl'`.
  *
  * Finally, this event only fires in the event of a "normal" UI-oriented log-in attempt. A module attempting to log in
  * programmatically by directly calling the core functions will not see this event fired.
  */
 public static function succeeded(Zikula_Event $event)
 {
     $user = $event->getSubject();
     $uid = $user['uid'];
     MUBoard_Util_View::actualUser($uid, 1);
     MUBoard_Util_View::actualPostings($uid);
 }
Beispiel #16
0
 /**
  * Listener for the `moduleplugin.ckeditor.externalplugins` event.
  *
  * Adds external plugin to CKEditor.
  *
  * @param Zikula_Event $event The event instance.
  */
 public static function getCKEditorPlugins(Zikula_Event $event)
 {
     // intended is using the add() method to add a plugin like below
     $plugins = $event->getSubject();
     $plugins->add(array('name' => 'muvideo', 'path' => 'modules/MUVideo/docs/scribite/plugins/CKEditor/vendor/ckeditor/plugins/muvideo/', 'file' => 'plugin.js', 'img' => 'ed_muvideo.gif'));
 }
Beispiel #17
0
 /**
  * Deletes the user in forum database, if deleted in Zikula Users.
  *
  * @param Zikula_Event $event The event that triggered this handler.
  *
  * @return void
  */
 public static function deleteAccountListener(Zikula_Event $event)
 {
     $userObj = $event->getSubject();
     if (is_array($userObj) && $userObj['uid'] > 0) {
         $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
         $stmt = $connection->prepare("DELETE FROM " . self::getTableUsers() . " WHERE user_id=" . $userObj['uid']);
         $stmt->execute();
     }
 }
Beispiel #18
0
 /**
  * ContentType discovery event handler.
  * 
  * @param Zikula_Event $event
  */
 public static function getContentTypes(Zikula_Event $event)
 {
     $types = $event->getSubject();
     // add content types with add('classname')
     $types->add('AddressBook_ContentType_Address');
 }
Beispiel #19
0
 /**
  * Listener which modifies the Theme Renderer.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function initRenderer(Zikula_Event $event)
 {
     $view = $event->getSubject();
     $view->debugging = true;
     $view->register_outputfilter(array($this, 'smartyViewoutputfilter'));
 }
Beispiel #20
0
    /**
     * Respond to a `module.users.ui.process_edit` event to store profile data gathered when editing or creating a user account.
     * 
     * Parameters passed in via POST:
     * ------------------------------
     * array dynadata An array containing the profile items to store for the user.
     *
     * @param Zikula_Event $event The event that triggered this function call, containing the id of the user for which profile information should be stored.
     * 
     * @return void
     */
    public function processEdit(Zikula_Event $event)
    {
        if ($this->request->isPost()) {
            if ($this->validation && !$this->validation->hasErrors()) {
                $user = $event->getSubject();
                $dynadata = $this->request->getPost()->has('dynadata') ? $this->request->getPost()->get('dynadata') : array();

                foreach ($dynadata as $dudName => $dudItem) {
                    UserUtil::setVar($dudName, $dudItem, $user['uid']);
                }
            }
        }
    }
Beispiel #21
0
 /**
  * Listener for the `module.content.gettypes` event.
  *
  * This event occurs when the Content module is 'searching' for Content plugins.
  * The subject is an instance of Content_Types.
  */
 public static function contentGetTypes(Zikula_Event $event)
 {
     // intended is using the add() method to add a plugin like below
     $types = $event->getSubject();
     $types->add('MUBoard_ContentType_ItemList');
 }
 /**
  * Configure Doctrine 1.x instance.
  *
  * Listens for 'doctrine.configure' events.
  * Subject is either Doctrine_Manager, Doctrine_Connection or Doctrine_Table.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function configureDoctrine(Zikula_Event $event)
 {
     $object = $event->getSubject();
     if ($object instanceof Doctrine_Manager) {
         // Cross-DBMS portability options
         // Modes are bitwised, so they can be combined using | and removed using ^.
         // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#portability:portability-mode-attributes
         // Turn on all portability features (commented out as this is the default setting)
         $object->setAttribute('portability', Doctrine_Core::PORTABILITY_ALL);
         // Turn off identifier quoting, as it causes more problems than it solves
         // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#identifier-quoting
         $object->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, false);
         // What should be exported when exporting classes to the db
         // Modes are bitwised, so they can be combined using | and removed using ^.
         // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#exporting
         $object->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL);
         // Validation attributes (default is VALIDATE_NONE)
         // Modes are bitwised, so they can be combined using | and removed using ^.
         // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#naming-convention-attributes:validation-attributes
         // Turn on all validation functionality, at least while we are in development mode
         $object->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
         // naming convention of database related elements
         // affect importing schemas from the database to classes
         // as well as exporting classes into database tables.
         // Index names (default: [name]_idx)
         $object->setAttribute(Doctrine_Core::ATTR_IDXNAME_FORMAT, '%s');
         // Sequence names (default: [name]_seq)
         // $object->setAttribute(Doctrine_Core::ATTR_SEQNAME_FORMAT, '%s_sequence');
         // Database names
         // $object->setAttribute(Doctrine_Core::ATTR_DBNAME_FORMAT, 'myframework_%s');
         // Allow overriding of accessors
         $object->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
         // Enable auto loading of custom Doctrine_Table classes in addition to Doctrine_Record
         $object->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true);
         // Set model loading strategy to conservative
         // see http://www.doctrine-project.org/documentation/manual/1_2/en/introduction-to-models#autoloading-models
         $object->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
         //$object->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
         // enable dql hooks (used by Categorisable doctrine template)
         $object->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
         $object->registerHydrator(DoctrineUtil::HYDRATE_SINGLE_SCALAR_ARRAY, 'Zikula_Doctrine_Hydrator_SingleScalarArray');
         // tell doctrine our extended Doctrine_Query class (Doctrine_Query::create() returns a Zikula_Doctrine_Query instance)
         $object->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS, 'Zikula_Doctrine_Query');
         return;
     }
     if ($object instanceof Doctrine_Connection) {
         // set connection options
         // fetch / hydration mode
         //            $object->setAttribute(Doctrine_Core::ATTR_FETCHMODE, Doctrine_Core::FETCH_ASSOC);
         //            $object->setAttribute(Doctrine_Core::ATTR_HYDRATE_OVERWRITE, Doctrine_Core::HYDRATE_RECORD);
         // default column options
         //            $object->setAttribute(Doctrine_Core::ATTR_DEFAULT_COLUMN_OPTIONS,
         //                                            array('type' => 'string',
         //                                                  'length' => 255,
         //                                                  'notnull' => true));
         // properties of default added primary key in models
         // %s is replaced with the table name
         //            $object->setAttribute(Doctrine_Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS,
         //                                            array('name' => '%s_id',
         //                                                  'type' => 'string',
         //                                                  'length' => 16));
         return;
     } elseif ($object instanceof Doctrine_Table) {
         // set table options
         return;
     }
     throw new Exception(get_class($object) . ' is not valid in configureDoctrine()');
 }
Beispiel #23
0
 /**
  * Dynamically add menu links to administration for system services.
  *
  * Listens for 'module_dispatch.postexecute' events.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function addServiceLink(Zikula_Event $event)
 {
     // check if this is for this handler
     if (!($event['modfunc'][1] == 'getLinks' && $event['type'] == 'admin' && $event['api'] == true)) {
         return;
     }
     // notify EVENT here to gather any system service links
     $args = array('modname' => $event->getArgument('modname'));
     $localevent = new \Zikula\Core\Event\GenericEvent($event->getSubject(), $args);
     $this->eventManager->dispatch('module_dispatch.service_links', $localevent);
     $sublinks = $localevent->getData();
     if (!empty($sublinks)) {
         $event->data[] = array('url' => $this->getContainer()->get('router')->generate('zikulaextensionsmodule_admin_moduleservices', array('moduleName' => $event['modname'])), 'text' => __('Services'), 'icon' => 'cogs', 'links' => $sublinks);
     }
 }
Beispiel #24
0
 public static function getTypes(Zikula_Event $event) {
     $types = $event->getSubject();
     $types->add('News_ContentType_NewsArticles');
 }
Beispiel #25
0
    /**
     * Responds to process_edit hook-like event notifications.
     *
     * @param Zikula_Event $event The event that triggered this function call.
     *
     * @return void
     *
     * @throws Zikula_Exception_Fatal Thrown if a user account does not exist for the uid specified by the event.
     */
    public function processEdit(Zikula_Event $event)
    {
        $activePolicies = $this->helper->getActivePolicies();
        $eventName = $event->getName();

        if (isset($this->validation) && !$this->validation->hasErrors()) {
            $user = $event->getSubject();
            $uid = $user['uid'];

            if (!UserUtil::isLoggedIn()) {
                if (($eventName == 'module.users.ui.process_edit.login_screen') || ($eventName == 'module.users.ui.process_edit.login_block')) {
                    $policiesAcceptedAtLogin = $this->validation->getObject();

                    $nowUTC = new DateTime('now', new DateTimeZone('UTC'));
                    $nowUTCStr = $nowUTC->format(DateTime::ISO8601);

                    if ($activePolicies['termsOfUse'] && $policiesAcceptedAtLogin['termsOfUse']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['privacyPolicy'] && $policiesAcceptedAtLogin['privacyPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['agePolicy'] && $policiesAcceptedAtLogin['agePolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['cancellationRightPolicy'] && $policiesAcceptedAtLogin['cancellationRightPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['tradeConditions'] && $policiesAcceptedAtLogin['tradeConditions']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid);
                    }

                    // Force the reload of the user record
                    $user = UserUtil::getVars($uid, true);
                } else {
                    $isRegistration = UserUtil::isRegistration($uid);

                    $user = UserUtil::getVars($uid, false, 'uid', $isRegistration);
                    if (!$user) {
                        throw new Zikula_Exception_Fatal(__('A user account or registration does not exist for the specified uid.', $this->domain));
                    }

                    $policiesAcceptedAtRegistration = $this->validation->getObject();

                    $nowUTC = new DateTime('now', new DateTimeZone('UTC'));
                    $nowUTCStr = $nowUTC->format(DateTime::ISO8601);

                    if ($activePolicies['termsOfUse'] && $policiesAcceptedAtRegistration['termsOfUse']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['privacyPolicy'] && $policiesAcceptedAtRegistration['privacyPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['agePolicy'] && $policiesAcceptedAtRegistration['agePolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['cancellationRightPolicy'] && $policiesAcceptedAtRegistration['cancellationRightPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['tradeConditions'] && $policiesAcceptedAtRegistration['tradeConditions']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid);
                    }

                    // Force the reload of the user record
                    $user = UserUtil::getVars($uid, true, 'uid', $isRegistration);
                }
            } else {
                $isRegistration = UserUtil::isRegistration($uid);

                $user = UserUtil::getVars($uid, false, 'uid', $isRegistration);
                if (!$user) {
                    throw new Zikula_Exception_Fatal(__('A user account or registration does not exist for the specified uid.', $this->domain));
                }

                $policiesAcceptedAtRegistration = $this->validation->getObject();
                $editablePolicies = $this->helper->getEditablePolicies();

                $nowUTC = new DateTime('now', new DateTimeZone('UTC'));
                $nowUTCStr = $nowUTC->format(DateTime::ISO8601);

                if ($activePolicies['termsOfUse'] && $editablePolicies['termsOfUse']) {
                    if ($policiesAcceptedAtRegistration['termsOfUse']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid);
                    } elseif (($policiesAcceptedAtRegistration['termsOfUse'] === 0) || ($policiesAcceptedAtRegistration['termsOfUse'] === "0")) {
                        UserUtil::delVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $uid);
                    }
                }

                if ($activePolicies['privacyPolicy'] && $editablePolicies['privacyPolicy']) {
                    if ($policiesAcceptedAtRegistration['privacyPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    } elseif (($policiesAcceptedAtRegistration['privacyPolicy'] === 0) || ($policiesAcceptedAtRegistration['termsOfUse'] === "0")) {
                        UserUtil::delVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $uid);
                    }
                }

                if ($activePolicies['agePolicy'] && $editablePolicies['agePolicy']) {
                    if ($policiesAcceptedAtRegistration['agePolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid);
                    } elseif (($policiesAcceptedAtRegistration['agePolicy'] === 0) || ($policiesAcceptedAtRegistration['termsOfUse'] === "0")) {
                        UserUtil::delVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $uid);
                    }
                }

                if ($activePolicies['cancellationRightPolicy'] && $editablePolicies['cancellationRightPolicy']) {
                    if ($policiesAcceptedAtRegistration['cancellationRightPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    } elseif (($policiesAcceptedAtRegistration['cancellationRightPolicy'] === 0) || ($policiesAcceptedAtRegistration['cancellationRightPolicy'] === "0")) {
                        UserUtil::delVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $uid);
                    }
                }

                if ($activePolicies['tradeConditions'] && $editablePolicies['tradeConditions']) {
                    if ($policiesAcceptedAtRegistration['tradeConditions']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid);
                    } elseif (($policiesAcceptedAtRegistration['tradeConditions'] === 0) || ($policiesAcceptedAtRegistration['tradeConditions'] === "0")) {
                        UserUtil::delVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $uid);
                    }
                }

                // Force the reload of the user record
                $user = UserUtil::getVars($uid, true, 'uid', $isRegistration);
            }
        }
    }
Beispiel #26
0
 /**
  * Registers Imagine smarty plugins dir.
  *
  * @param Zikula_Event $event
  */
 public function registerPlugins(Zikula_Event $event)
 {
     $event->getSubject()->addPluginDir("{$this->baseDir}/templates/plugins");
 }
Beispiel #27
0
 /**
  * Event listener for controller_api.method_not_found.
  *
  * @param Zikula_Event $event Event.
  *
  * @return void
  */
 public function logModControllerAPINotFound(Zikula_Event $event)
 {
     $this->_log[] = array('type' => Zikula_AbstractErrorHandler::EMERG, 'errstr' => 'Execute Controller API method failed: Method not found ' . get_class($event->getSubject()) . '->' . $event['method']);
 }
Beispiel #28
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));
                }
            }
        }
    }