public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $super = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $super;
     $jim = UserTestHelper::createBasicUser('jim');
     $values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
     $customFieldData = CustomFieldData::getByName('ImportTestDropDown');
     $customFieldData->serializedData = serialize($values);
     $saved = $customFieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('Multi 1', 'Multi 2', 'Multi 3');
     $customFieldData = CustomFieldData::getByName('ImportTestMultiDropDown');
     $customFieldData->serializedData = serialize($values);
     $saved = $customFieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('Cloud 1', 'Cloud 2', 'Cloud 3');
     $customFieldData = CustomFieldData::getByName('ImportTestTagCloud');
     $customFieldData->serializedData = serialize($values);
     $saved = $customFieldData->save();
     assert($saved);
     // Not Coding Standard
     //Ensure the external system id column is present.
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     RedBeanColumnTypeOptimizer::externalIdColumn(User::getTableName('User'), $columnName);
     $userTableName = User::getTableName('User');
     R::exec("update " . $userTableName . " set {$columnName} = 'A' where id = {$super->id}");
     R::exec("update " . $userTableName . " set {$columnName} = 'B' where id = {$jim->id}");
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem::getTableName('ImportModelTestItem'), $columnName);
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem2::getTableName('ImportModelTestItem2'), $columnName);
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem3::getTableName('ImportModelTestItem3'), $columnName);
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem4::getTableName('ImportModelTestItem4'), $columnName);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $super = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $super;
     $jim = UserTestHelper::createBasicUser('jim');
     $values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
     $customFieldData = CustomFieldData::getByName('ImportTestDropDown');
     $customFieldData->serializedData = serialize($values);
     $saved = $customFieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('Multi 1', 'Multi 2', 'Multi 3');
     $customFieldData = CustomFieldData::getByName('ImportTestMultiDropDown');
     $customFieldData->serializedData = serialize($values);
     $saved = $customFieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('Cloud 1', 'Cloud 2', 'Cloud 3');
     $customFieldData = CustomFieldData::getByName('ImportTestTagCloud');
     $customFieldData->serializedData = serialize($values);
     $saved = $customFieldData->save();
     assert($saved);
     // Not Coding Standard
     //Ensure the external system id column is present.
     $userTableName = User::getTableName();
     ExternalSystemIdUtil::addExternalIdColumnIfMissing($userTableName);
     ExternalSystemIdUtil::updateByModel($super, 'A');
     ExternalSystemIdUtil::updateByModel($jim, 'B');
     ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem::getTableName());
     ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem2::getTableName());
     ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem3::getTableName());
     ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem4::getTableName());
 }
 public static function getUserExternalSystemIds()
 {
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     RedBeanColumnTypeOptimizer::externalIdColumn(User::getTableName('User'), $columnName);
     $sql = 'select ' . $columnName . ' from ' . User::getTableName('User');
     return R::getCol($sql);
 }
 public function indexAction()
 {
     $this->defaultNamespace = new Zend_Session_Namespace('default');
     $this->myNamespace = new Zend_Session_Namespace('editParticipants');
     $ceId = $this->defaultNamespace->callingActionId;
     $this->view->callingActionId = $ceId;
     if ($this->getRequest()->isPost()) {
         //save form params to namespace
         $this->myNamespace->params = $this->getRequest()->getParams();
         //check which submit button has been clicked
         if ($this->getRequest()->getParam('Check_all') != NULL) {
             $this->myNamespace->checkAll = TRUE;
             $this->redirectTo('index');
         }
         if ($this->getRequest()->getParam('Uncheck_all') != NULL) {
             $this->myNamespace->checkAll = FALSE;
             $this->redirectTo('index');
         }
         if ($this->getRequest()->getParam('Remove_from_participants') != NULL) {
             $success = $this->deleteParticipants();
             if (!$success) {
                 //XXX show error
             }
             $this->redirectTo('index');
         }
         if ($this->getRequest()->getParam('Apply_to_selected') != NULL) {
             $success = $this->applySettingsToParticipants();
             if (!$success) {
                 ///XXX show error
             }
             $this->redirectTo('index');
         }
     } else {
         //not post
         //TODO getCaliExName and display in header
         $userTable = new User();
         $participantsTable = new Participant();
         $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
         $select = $dbAdapter->select();
         $select->from(array('user' => $userTable->getTableName()), array(User::COL_LASTNAME, User::COL_FIRSTNAME, User::COL_USERNAME));
         $select->join(array('part' => $participantsTable->getTableName()), $dbAdapter->quoteIdentifier('user.' . User::COL_ID) . '=' . $dbAdapter->quoteIdentifier('part.' . Participant::COL_USER_ID), array(Participant::COL_ID, Participant::COL_NUMBER, Participant::COL_EXPERTISE_LEVEL, Participant::COL_STOCK_ASSESSMENT, Participant::COL_ROLE));
         $select->where($dbAdapter->quoteInto('part.' . Participant::COL_CE_ID . ' = ?', $ceId));
         //echo $select;
         $paginator = new Ble422_Paginator_Extended($select, $this->getRequest());
         $paginator->setHeader(array(array('raw' => User::COL_LASTNAME, 'name' => 'Last name'), array('raw' => User::COL_FIRSTNAME, 'name' => 'First name'), array('raw' => User::COL_USERNAME, 'name' => 'User name'), array('raw' => Participant::COL_NUMBER, 'name' => 'Reader no.'), array('raw' => Participant::COL_EXPERTISE_LEVEL, 'name' => 'Expertise level'), array('raw' => Participant::COL_STOCK_ASSESSMENT, 'name' => 'Stock assess.'), array('raw' => Participant::COL_ROLE, 'name' => 'Role')));
         $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(50)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy'));
         //$this->_getParam('pageRange'));
         Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml');
         $this->view->paginator = $paginator;
         $this->defaultNamespace->callingAction = "ce/editparticipants/index";
         //callingActionId stays the same
         $this->view->callingAction = $this->defaultNamespace->callingAction;
         $this->view->callingActionId = $ceId;
         $this->view->ceName = Default_SimpleQuery::getCeName($ceId);
         $this->view->checkAll = $this->myNamespace->checkAll;
         unset($this->myNamespace->checkAll);
         //TODO partTable.phtml wird schon auf this->checkAll geprüft, vom Controller übergeben, ebenso reload bei uncheck all
     }
 }
 public static function getUserExternalSystemIds()
 {
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     $userTableName = User::getTableName();
     ExternalSystemIdUtil::addExternalIdColumnIfMissing($userTableName);
     $sql = 'select ' . $columnName . ' from ' . $userTableName;
     return ZurmoRedBean::getCol($sql);
 }
Example #6
0
 public function postLists()
 {
     User::onlyHas('user-view');
     $jqgrid = new jQgrid(User::getTableName());
     return $jqgrid->populate(function ($start, $limit) {
         return User::select(User::getField('id'), User::getField('username'), User::getField('email'))->skip($start)->take($limit)->get();
     });
 }
Example #7
0
 /**
  * @param string $username
  * @throws NotFoundException
  */
 public static function getByUsername($username)
 {
     assert('is_string($username)');
     assert('$username != ""');
     $bean = R::findOne('_user', "username = :username ", array(':username' => $username));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     }
     RedBeansCache::cacheBean($bean, User::getTableName('User') . $bean->id);
     return self::makeModel($bean);
 }
Example #8
0
 public static function getNotes($start = '', $page_size = '')
 {
     $db = self::__instance();
     $limit = "";
     if ($page_size) {
         $limit = " limit {$start},{$page_size} ";
     }
     $sql = "select " . self::$columns . " ,coalesce(u.user_name,'已删除') as owner_name from " . self::getTableName() . " q left join " . User::getTableName() . " u on q.owner_id =  u.user_id order by q.note_id desc {$limit}";
     $list = $db->query($sql)->fetchAll();
     if ($list) {
         return $list;
     }
     return array();
 }
Example #9
0
    public static function adWithAllFields($id)
    {
        self::dbConnect();
        $query = 'SELECT ' . static::$table . '.*, username, keyword_id, keyword, category, image_id, image_url FROM ' . static::$table . ' LEFT JOIN ' . User::getTableName() . ' ON users.id = ' . static::$table . '.user_id 
			LEFT JOIN categories ON ' . static::$table . '.category_id = categories.id
			LEFT JOIN ad_image ON ' . static::$table . '.id = ad_image.ad_id
			LEFT JOIN images ON ad_image.image_id = images.id 
			LEFT JOIN ad_keyword ON ' . static::$table . '.id = ad_keyword.ad_id 
			LEFT JOIN ' . Keyword::getTableName() . ' ON ad_keyword.keyword_id = keywords.id 
			WHERE ' . static::$table . '.id = :id';
        $stmt = self::$dbc->prepare($query);
        $stmt->bindValue(':id', $id, PDO::PARAM_INT);
        $stmt->execute();
        while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $results['id'] = $result['id'];
            $results['username'] = $result['username'];
            $results['title'] = $result['title'];
            $results['description'] = $result['description'];
            $results['price'] = $result['price'];
            $results['date_posted'] = $result['date_posted'];
            $results['category'] = $result['category'];
            $results['keywords'][$result['keyword_id']] = $result['keyword'];
            $results['image_urls'][$result['image_id']] = $result['image_url'];
        }
        $instance = null;
        if ($results) {
            $instance = new static();
            $instance->attributes = $results;
        }
        return $instance;
    }
Example #10
0
 /**
  * Test model table name
  *
  * @return null
  */
 public function testModelTableName()
 {
     $this->assertEquals("users", User::getTableName());
 }
 public static function getGroupUsers($group_id)
 {
     $db = self::__instance();
     $sql = "select " . self::$columns . " ,u.user_id as user_id,u.user_name as user_name,u.real_name as real_name from " . self::getTableName() . " g," . User::getTableName() . " u where g.group_id = {$group_id} and g.group_id = u.user_group order by g.group_id,u.user_id";
     $list = $db->query($sql)->fetchAll();
     if ($list) {
         return $list;
     }
     return array();
 }
<?php

require_once 'Model.php';
require_once 'User.php';
echo User::getTableName();
Example #13
0
 /**
  * Test model table name
  *
  * @return null
  */
 public function testModelTableName()
 {
     $this->assertEquals("users", User::getTableName());
     $this->assertEquals("users", Test\User::getTableName());
     Test\User::setTableName('mydata');
     $this->assertEquals("mydata", Test\User::getTableName());
 }
 public function testSanitizeValueBySanitizerTypesForUserTypeThatIsRequired()
 {
     $billy = UserTestHelper::createBasicUser('billy');
     $jimmy = UserTestHelper::createBasicUser('jimmy');
     $sally = UserTestHelper::createBasicUser('sally');
     //Update the external system id.
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     RedBeanColumnTypeOptimizer::externalIdColumn(User::getTableName('User'), $columnName);
     $externalSystemIdColumnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     R::exec("update " . User::getTableName('User') . " set {$externalSystemIdColumnName} = 'K' where id = {$jimmy->id}");
     //Test a required user with no value or default value.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID)));
     $sanitizerUtilTypes = UserAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'owner', null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertNull($sanitizedValue);
     $this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(1, count($messages));
     $compareMessage = 'Import - Owner Id is required and was not specified.';
     $this->assertEquals($compareMessage, $messages[0]);
     //Test a required string with no value, but a valid default value, a user id.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => $billy->id), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID)));
     $sanitizerUtilTypes = UserAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'owner', null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($billy, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a required string with a valid user id.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID)));
     $sanitizerUtilTypes = UserAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'owner', $billy->id, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($billy, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a required string with a valid external system user id.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::EXTERNAL_SYSTEM_USER_ID)));
     $sanitizerUtilTypes = UserAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'owner', 'K', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($jimmy, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a required string with a valid username.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USERNAME)));
     $sanitizerUtilTypes = UserAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'owner', 'sally', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($sally, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
 }
 public function testGetGenericResultSanitizePartialName()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $this->assertTrue(ZurmoRedBean::$writer->doesTableExist(User::getTableName()));
     AccountTestHelper::createAccountByNameForOwner('Test account', $super);
     AccountTestHelper::createAccountByNameForOwner('Test account 2', $super);
     $term = "Test%');drop TABLE _user-- ";
     $data = ModelAutoCompleteUtil::getByPartialName('Account', $term, 5);
     $this->assertTrue(ZurmoRedBean::$writer->doesTableExist(User::getTableName()));
     $this->assertEmpty($data);
 }
Example #16
0
 public static function withRole($role)
 {
     return UserRole::join(Role::getTableName(), Role::getField('id'), '=', UserRole::getField('role_id'))->join(User::getTableName(), User::getField('id'), '=', UserRole::getField('user_id'))->select(User::getField('*'))->where(Role::getField('key'), $role)->get();
 }
Example #17
0
 public function searchAction()
 {
     //display only active users with their assigned expertise
     $request = $this->getRequest();
     $params = $this->namespace->searchParams;
     $formValues = $this->namespace->formValues;
     $userTable = new User();
     $valueTable1 = new ValueList();
     $valueTable2 = new ValueList();
     $select = $userTable->getAdapter()->select();
     $tableAdapter = $userTable->getAdapter();
     $select->from(array('user' => $userTable->getTableName()));
     //XXX remove leftJoin, only Alpha
     $select->joinLeft(array('val1' => ValueList::TABLE_NAME), 'user.' . User::COL_INSTITUTION . '=' . 'val1.' . ValueList::COL_ID, array('Institution' => ValueList::COL_NAME));
     $select->joinLeft(array('val2' => ValueList::TABLE_NAME), 'user.' . User::COL_COUNTRY . '=' . 'val2.' . ValueList::COL_ID, array('Country' => ValueList::COL_NAME));
     $select->joinLeft(array('userHasExpe' => UserHasExpertise::TABLE_NAME), 'user.' . User::COL_ID . '=' . 'userHasExpe.' . UserHasExpertise::COL_USER_ID, array('expertiseId' => UserHasExpertise::COL_EXPE_ID));
     $select->joinLeft(array('expe' => Expertise::TABLE_NAME), 'userHasExpe.' . UserHasExpertise::COL_EXPE_ID . '=' . 'expe.' . Expertise::COL_ID, array('eSpec' => Expertise::COL_SPECIES, 'eArea' => Expertise::COL_AREA, 'eSubj' => Expertise::COL_SUBJECT));
     $select->where('user.' . User::COL_ACTIVE . ' = ?', 1);
     //echo $select.'<br>';
     //list details
     //handle multi select/multi checkbox values
     //concatenate strings and decorate with HTML tags for list presentation
     if ($params['listDetails'] == 1) {
         $rowSet = $tableAdapter->fetchAll($select);
         if (count($rowSet) > 0) {
             $userHasExpAsArray = array();
             foreach ($rowSet as $row) {
                 if (!isset($userHasExpAsArray[$row[User::COL_ID]])) {
                     $userHasExpAsArray[$row[User::COL_ID]] = '';
                 }
                 if ($row['expertiseId'] != NULL) {
                     //$attrConcat = '<td>'.$row['eSpec'].','.$row['eArea'].','.$row['eSubj'].'</td>';
                     $attrConcat = '<li>' . $row['eSpec'] . ',' . $row['eArea'] . ',' . $row['eSubj'] . '</li>';
                     $userHasExpAsArray[$row[User::COL_ID]] = $userHasExpAsArray[$row[User::COL_ID]] . $attrConcat;
                 }
             }
             foreach ($userHasExpAsArray as &$expList) {
                 //$expList = "<table border = 'solid'><tr>".$expList.'</tr></table>';
                 $expList = '<ul>' . $expList . '</ul>';
             }
             $this->view->userHasExpAsArray = $userHasExpAsArray;
         }
     }
     //handle AND/OR search
     if ($params['kind'] == 'and') {
         foreach ($formValues as $key => $value) {
             if ($key != null && $value != null && $key != 'kind' && $key != 'submit' && $key != 'listDetails') {
                 if ($key == UserHasExpertise::COL_EXPE_ID) {
                     //$tableRow = $tableAdapter->quoteIdentifier($key);
                     $partStatement = $tableAdapter->quoteInto('userHasExpe.' . UserHasExpertise::COL_EXPE_ID . ' = ?', $value);
                     $select->where($partStatement);
                 } elseif ($key == User::COL_COUNTRY || $key == User::COL_INSTITUTION) {
                     $tableRow = $tableAdapter->quoteIdentifier($key);
                     $partStatement = $tableAdapter->quoteInto($tableRow . ' = ?', $value);
                     $select->where($partStatement);
                 } else {
                     $tableRow = $tableAdapter->quoteIdentifier($key);
                     $partStatement = $tableAdapter->quoteInto($tableRow . ' LIKE ?', '%' . $value . '%');
                     $select->where($partStatement);
                 }
             }
         }
     }
     if ($params['kind'] == 'or') {
         $orWhere = '';
         foreach ($formValues as $key => $value) {
             if ($key != null && $value != null && $key != 'kind' && $key != 'submit' && $key != 'listDetails') {
                 if ($key == UserHasExpertise::COL_EXPE_ID) {
                     //$tableRow = $tableAdapter->quoteIdentifier($key);
                     $partStatement = $tableAdapter->quoteInto('userHasExpe.' . UserHasExpertise::COL_EXPE_ID . ' = ?', $value);
                 } elseif ($key == User::COL_COUNTRY || $key == User::COL_INSTITUTION) {
                     $tableRow = $tableAdapter->quoteIdentifier($key);
                     $partStatement = $tableAdapter->quoteInto($tableRow . ' = ?', $value);
                 } else {
                     $tableRow = $tableAdapter->quoteIdentifier($key);
                     $partStatement = $tableAdapter->quoteInto($tableRow . ' LIKE ?', '%' . $value . '%');
                 }
                 //append the where to the "where or where" container
                 if (isset($partStatement)) {
                     if ($orWhere == '') {
                         $orWhere = $partStatement;
                     } else {
                         $orWhere = $orWhere . ' OR ' . $partStatement;
                     }
                 }
                 unset($partStatement);
             }
         }
         //finally append the where to the select(whole metadata)
         if ($orWhere != '') {
             $select->where($orWhere);
         }
     }
     //filter double datasets caused by multiple meta data
     $select->group('user.' . User::COL_ID);
     //for setting ws-manager filter low user roles
     if ($this->defaultNamespace->callingAction == 'workshop/edit/update') {
         $select->where('(user.' . User::COL_ROLE . ' = ?', 'ws-manager');
         $select->orWhere('user.' . User::COL_ROLE . ' = ?)', 'admin');
     }
     //echo $select;
     //get already assigned datasets for setting disabled in view
     if ($this->defaultNamespace->callingAction == 'ce/editparticipants/index') {
         $ceId = $this->defaultNamespace->callingActionId;
         $part = new Participant();
         $rowSet = $part->fetchAll(Participant::COL_CE_ID . '=' . $ceId);
         if (count($rowSet) > 0) {
             $participants = array();
             foreach ($rowSet as $row) {
                 $participants[$row[Participant::COL_USER_ID]] = TRUE;
             }
             $this->view->participants = $participants;
         }
     }
     /**
      * Pagination control
      */
     $paginator = new Ble422_Paginator_Extended($select, $this->getRequest());
     $paginator->setHeader(array(array('raw' => User::COL_USERNAME, 'name' => 'Username'), array('raw' => User::COL_ROLE, 'name' => 'User role'), array('raw' => User::COL_FIRSTNAME, 'name' => 'First name'), array('raw' => User::COL_LASTNAME, 'name' => 'Last name'), array('raw' => User::COL_EMAIL, 'name' => 'E-mail'), array('raw' => 'Institution', 'name' => 'Institution'), array('raw' => User::COL_STREET, 'name' => 'Street'), array('raw' => User::COL_CITY, 'name' => 'City'), array('raw' => 'Country', 'name' => 'Country')));
     $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(1000)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy'));
     //$this->_getParam('pageRange'));
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml');
     $this->view->paginator = $paginator;
     // TODO im Plugin in die registry setzen, leichterer Aufruf
     // Get user_role
     $auth = Zend_Auth::getInstance();
     $storage = $auth->getStorage();
     $constUserRole = User::COL_ROLE;
     $userRole = $storage->read()->{$constUserRole};
     $this->view->userRole = $userRole;
     $this->view->callingAction = $this->defaultNamespace->callingAction;
     $this->view->callingActionId = $this->defaultNamespace->callingActionId;
     //		}
 }
<?php

require_once 'user.php';
echo User::getTableName() . PHP_EOL;
Example #19
0
 public function getIndex()
 {
     User::onlyHas('log-view');
     $this->data['list'] = LogModel::leftJoin(User::getTableName(), User::getField('id'), '=', LogModel::getField('user_id'))->orderBy('event_date', 'desc')->get();
     $this->layout->content = View::make('sections.log.list', $this->data);
 }
Example #20
0
 /**
  * Given a language, is it in use as a default language by any of the users.
  * @param string $language
  * @return true if in use, otherwise returns false.
  */
 protected function isLanguageADefaultLanguageForAnyUsers($language)
 {
     assert('is_string($language)');
     $tableName = User::getTableName('User');
     $beans = R::find($tableName, "language = '{$language}'");
     if (count($beans) > 0) {
         return true;
     }
     return false;
 }