function channel_server_start() { $db = sr_pdo(); $result = array(); try { $room_list = Room::fetchAll(); foreach ($room_list as $room) { channel_destroyed_log($room); } $participant_list = Participant::fetchAll(); foreach ($participant_list as $p) { channel_client_disconnected_log($p); } Room::delete_all($db); Participant::delete_all($db); $result['result'] = 0; echo json_encode($result); } catch (PDOException $e) { $result['result'] = 1; $result['msg'] = 'Server error. ' . $e->getMessage(); echo json_encode($result); } }
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; // } }
private function countParticipants() { $parti = new Participant(); $where = $parti->getAdapter()->quoteInto(Participant::COL_CE_ID . ' = ?', $this->callingCeId); $rowSet = $parti->fetchAll($where); return count($rowSet); }