Example #1
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (!in_array($request->getModuleName(), $this->modules)) {
         return;
     }
     $authInstance = Zend_Auth::getInstance();
     //SAML login:
     if (isset($_SERVER['eppn'])) {
         //lookup user with this eduPersonPrincipalName:
         $model = new OpenSKOS_Db_Table_Users();
         $user = $model->fetchRow($model->select()->where('eppn=?', $_SERVER['eppn']));
         if (null !== $user) {
             if ($user->active != 'Y') {
                 Zend_Auth::getInstance()->clearIdentity();
                 Zend_Session::forgetMe();
                 Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('error')->addMessage(_('Your account is blocked.'));
                 Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'index', 'website');
             }
             $login = new Editor_Models_Login();
             $login->getStorage()->write($user);
             return;
         }
     }
     $resource = $request->getControllerName();
     $actionName = $request->getActionName();
     if ($authInstance->hasIdentity()) {
         if ($authInstance->getIdentity()->active != 'Y') {
             Zend_Auth::getInstance()->clearIdentity();
             Zend_Session::forgetMe();
             Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('error')->addMessage(_('Your account is blocked.'));
             Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'index', 'website');
         }
     } else {
         if ($request->getControllerName() != 'login') {
             Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'login', 'editor');
         }
     }
 }
 /**
  * @return Editor_Forms_SearchOptions
  */
 protected function buildUserInteraction()
 {
     $modelUsers = new OpenSKOS_Db_Table_Users();
     $users = $modelUsers->fetchAll($modelUsers->select()->where('tenant=?', $this->_getCurrentTenant()->code));
     $roles = OpenSKOS_Db_Table_Users::getUserRoles();
     $rolesOptions = array_combine($roles, $roles);
     $userData = array();
     foreach ($users as $user) {
         $userData[$user->id] = $user->name;
     }
     $userInteractionTypes = array();
     if (isset($this->_searchOptions['interactiontypes'])) {
         $userInteractionTypes = $this->_searchOptions['interactiontypes'];
     }
     $this->addElement('hidden', 'userInteractionTypeLabel', array('label' => _('Created, modified or approved'), 'disabled' => true));
     $this->addElement('multiCheckbox', 'userInteractionType', array('label' => '', 'multiOptions' => $userInteractionTypes));
     $this->addElement('multiselect', 'interactionByRoles', array('label' => _('Roles'), 'multiOptions' => $rolesOptions));
     $this->addElement('multiselect', 'interactionByUsers', array('label' => _('Users'), 'multiOptions' => $userData));
     $this->buildDateInput('interaction');
     $this->addDisplayGroup(array('userInteractionType', 'interactionByRoles', 'interactionByUsers', 'interactionDateFrom', 'interactionDateTo'), 'interaction', array('legend' => _('Created, modified or approved'), 'disableDefaultDecorators' => true, 'decorators' => array('FormElements', array('HtmlTag', array('tag' => 'div', 'id' => 'interaction')))));
     return $this;
 }
Example #3
0
 /**
  * Builds query for search by users and by users from specific role.
  * All the users from the specified role will be added with OR to the query of users.
  * If the final query of users includes all users - an empty string is returned - the query should not be applied.
  *
  * @param string $field The field to search by.
  * @param string $usersOption The option in $this->_searchOptions to use as users to search by
  * @param string $usersRoleOption The option in $this->_searchOptions to use as role to search by
  * @return string
  */
 protected function _buildUsersAndUserRolesQuery($field, $usersOption, $usersRoleOption, $allUsers)
 {
     $searchUsers = array();
     if (isset($this->_searchOptions[$usersRoleOption]) && !empty($this->_searchOptions[$usersRoleOption])) {
         $modelUsers = new OpenSKOS_Db_Table_Users();
         $usersByRole = $modelUsers->fetchAll($modelUsers->select()->where('tenant=?', $this->_tenant->code)->where('role IN (?)', $this->_searchOptions[$usersRoleOption])->group('id'));
         foreach ($usersByRole as $user) {
             $searchUsers[] = $user->id;
         }
     }
     if (isset($this->_searchOptions[$usersOption]) && !empty($this->_searchOptions[$usersOption])) {
         $searchUsers = array_merge($searchUsers, $this->_searchOptions[$usersOption]);
         $searchUsers = array_unique($searchUsers);
     }
     $query = '';
     // If not all users are selected - adds each of them to the query.
     if (count($allUsers) != count($searchUsers)) {
         foreach ($searchUsers as $user) {
             $query .= !empty($query) ? ' OR ' : '';
             $query .= $field . ':' . $user;
             if ($field == 'created_by') {
                 $query .= ' OR ';
                 $query .= 'dcterms_creator:"' . $allUsers[$user] . '"';
             }
         }
     }
     return $query;
 }