public function listAction() { $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $select = $dbAdapter->select(); $select->from(array('wt' => Workshop::TABLE_NAME), array(Workshop::COL_NAME, Workshop::COL_START_DATE, 'wt.' . Workshop::COL_ID, Workshop::COL_END_DATE, Workshop::COL_USER_ID)); $select->join(array('vl' => ValueList::TABLE_NAME), $dbAdapter->quoteIdentifier('wt.' . Workshop::COL_LOCATION) . '=' . $dbAdapter->quoteIdentifier('vl.' . ValueList::COL_ID), array(ValueList::COL_NAME)); $select->join(array('us' => User::TABLE_NAME), $dbAdapter->quoteIdentifier('wt.' . Workshop::COL_USER_ID) . '=' . $dbAdapter->quoteIdentifier('us.' . User::COL_ID), array(User::COL_USERNAME)); if ($this->myws) { // get user id from current user $userId = AuthQuery::getUserId(); //pushed the join 'part' where to extra where method $select->distinct(); //left join to show ws without CEs, too $select->joinLeft(array('caex' => CalibrationExercise::TABLE_NAME), $dbAdapter->quoteIdentifier('wt.' . Workshop::COL_ID) . '=' . $dbAdapter->quoteIdentifier('caex.' . CalibrationExercise::COL_WORKSHOP_ID), array()); //left join to show ws without CEs, too $select->joinLeft(array('part' => Participant::TABLE_NAME), $dbAdapter->quoteIdentifier('caex.' . CalibrationExercise::COL_ID) . '=' . $dbAdapter->quoteIdentifier('part.' . Participant::COL_CE_ID), array()); //show workshops where you are participant in any CE $select->where('part.' . Participant::COL_USER_ID . '= ?', $userId, 'int'); //show workshops where you are ws-manager $select->orWhere('wt.' . Workshop::COL_USER_ID . '= ?', $userId, 'int'); } $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); $paginator->setHeader(array(array('raw' => ValueList::COL_NAME, 'name' => 'Location'), array('raw' => Workshop::COL_NAME, 'name' => 'Workshopname'), array('raw' => Workshop::COL_START_DATE, 'name' => 'Start date'), array('raw' => Workshop::COL_END_DATE, 'name' => 'End Date'), array('raw' => User::COL_USERNAME, 'name' => 'Manager'))); $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(1000)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy')); //$this->_getParam('pageRange')); $this->view->paginator = $paginator; $this->view->userRole = AuthQuery::getUserRole(); // for the redirect from mywsAction! $this->render('list'); }
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 function listAction() { $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $select = $dbAdapter->select(); $select->from(AttributeDescriptor::TABLE_NAME); /** * Paginator control */ $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); $paginator->setHeader(array(array('raw' => AttributeDescriptor::COL_NAME, 'name' => 'attribute desc.'), array('raw' => AttributeDescriptor::COL_GROUP, 'name' => 'group'), array('raw' => AttributeDescriptor::COL_FORM_TYPE, 'name' => 'formtype'), array('raw' => AttributeDescriptor::COL_UNIT, 'name' => 'unit'), array('raw' => AttributeDescriptor::COL_DESCRIPTION, 'name' => 'description'), array('raw' => AttributeDescriptor::COL_SEQUENCE, 'name' => 'sequence'))); $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(50)->setPageRange(5)->orderBy($this->getRequest()->getParam('orderBy')); //$this->_getParam('pageRange')); $this->view->paginator = $paginator; }
public function newselectavailablekeysAction() { //$this->form = new Ce_Form_Search(); $this->form->addElement(new Default_Form_Element_ExpertiseSelect(CalibrationExercise::COL_EXPERTISE_ID, array('disabled' => 'disabled'))); $this->form->removeElement('submit'); $options = $this->getRequest()->getParams(); $this->form->setDefaults($options); // if ($this->getRequest()->isPost()){ // if ($this->form->isValid($this->getRequest()->getParams())){ // // } else { // //not valid // // } // } else { // //not post // //$this->form->setAction('/ce/new/newtrainselectavailablekeys'); $this->view->form = $this->form; $expId = $options[Expertise::COL_ID]; $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $select2 = $dbAdapter->select(); $select2->from('v_all_annotations', array(KeyTable::COL_ID, KeyTable::COL_NAME, Expertise::COL_ID, 'count_images' => 'COUNT(' . Image::COL_ID . ')', 'sum_ref_ws' => 'SUM(' . Annotations::COL_WS_REF . ')', 'sum_ref_webgr' => 'SUM(' . Annotations::COL_WEBGR_REF . ')')); $select2->where('v_all_annotations.' . CalibrationExercise::COL_EXPERTISE_ID . ' = ?', $expId); $select2->group('v_all_annotations.' . KeyTable::COL_ID); //echo $select2; $paginator = new Ble422_Paginator_Extended($select2, $this->getRequest()); $paginator->setHeader(array(array('raw' => KeyTable::COL_NAME, 'name' => 'protocol name'), array('raw' => 'count_images', 'name' => 'No. of images'), array('raw' => 'sum_ref_ws', 'name' => 'workshop references'), array('raw' => 'sum_ref_webgr', 'name' => 'WebGR references'))); $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; //bilder und referenzen pro key aufsummieren und listen //bilderarray hier schon vorrätig halten //WS ID = TEMP+NAME+.uniqid() //CE Datensatz anlegen NR }
public function searchAction() { $request = $this->getRequest(); $formValues = $this->namespace->formValues; $this->view->callingAction = $this->defaultNamespace->callingAction; // get meta data select for image and fish descriptors $metaData = new Default_MetaData(); $metaData->getSelectForGroups(FALSE); $select = $metaData->addWhereToSelect($formValues); //TODO test with multiple fish / multiple image checked attributes //changed, if images are found, but search was for fish, multiple image attributes would cause multiple entries //TODO error: only first fish without images shown due to this group; if there are many fishes without image, there is only one of them shown in list $select->group('fish.' . Fish::COL_ID); if ($this->defaultNamespace->callingAction == 'annotation/browse/byfish') { $select->joinLeft(array('vaa' => 'v_all_annotations'), 'vaa.' . CeHasImage::COL_IMAGE_ID . ' = ' . 'image.' . Image::COL_ID, array()); //auf cehas_image damit die ausgefiltert werden die keine annotationen haben $select->group('image.' . Image::COL_ID); $resultArray = Zend_Registry::get('DB_CONNECTION1')->fetchAll($select); if ($resultArray != array()) { $resultKey = new Ble422_Guid(); $this->defaultNamespace->{$resultKey} = $resultArray; $redirect = new Zend_Controller_Action_Helper_Redirector(); $redirect->setGotoSimple('start', 'browse', 'annotation', array('resultKey' => $resultKey)); } } else { //select only own fish if ($this->defaultNamespace->callingAction == 'user/edit/myfishes') { $select->where('fish.' . Fish::COL_USER_ID . ' = ?', $this->defaultNamespace->callingActionId); } //new $this->namespace->select = $select; //new /** * Pagination control */ $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); //static + dynamic header array $statArray = array(array('raw' => Fish::COL_SAMPLE_CODE, 'name' => 'Fish sample code')); $dynArray = array(); $i = 0; foreach ($metaData->fishRowSetArray as $fishAttr) { $dynInnerArray = array('raw' => 'ATDE_' . $fishAttr[AttributeDescriptor::COL_ID], 'name' => $fishAttr[AttributeDescriptor::COL_NAME] . '<br>' . $fishAttr['UNIT']); $dynArray[$i] = $dynInnerArray; $i++; } $headerArray = array_merge($statArray, $dynArray); unset($i); unset($dynArray); unset($dynInnerArray); $paginator->setHeader($headerArray); $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; $storage = Zend_Auth::getInstance()->getStorage()->read(); $constUserRole = User::COL_ROLE; $this->view->userRole = $storage->{$constUserRole}; } }
private function process(array $params) { //params-array filters (where) and/or shows more info (joins) $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $select = $dbAdapter->select(); $select->from(array('celist' => View_CeList::NAME), array(View_CeList::COL_WORK_NAME, View_CeList::COL_CAEX_NAME, View_CeList::COL_CAEX_DESC, View_CeList::COL_CAEX_ID, View_CeList::COL_WORK_ID, View_CeList::COL_CAEX_TRAIN, 'images' => new Zend_Db_Expr('count(cehim.' . CeHasImage::COL_ID . ')'))); $select->joinLeft(array('exp' => Expertise::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_EXPE_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_ID)); $select->joinLeft(array('key' => KeyTable::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_KETA_ID) . '=' . $dbAdapter->quoteIdentifier('key.' . KeyTable::COL_ID)); $select->joinLeft(array('cehim' => CeHasImage::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_CAEX_ID) . '=' . $dbAdapter->quoteIdentifier('cehim.' . CeHasImage::COL_CALIBRATION_EXERCISE_ID), array()); $select->joinLeft(array('vali1' => ValueList::TABLE_NAME), $dbAdapter->quoteIdentifier('vali1.' . ValueList::COL_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_SPECIES), array(Expertise::COL_SPECIES => 'vali1.' . ValueList::COL_VALUE)); $select->joinLeft(array('vali2' => ValueList::TABLE_NAME), $dbAdapter->quoteIdentifier('vali2.' . ValueList::COL_ID) . '=' . $dbAdapter->quoteIdentifier('exp.' . Expertise::COL_SUBJECT), array(Expertise::COL_SUBJECT => 'vali2.' . ValueList::COL_VALUE)); $select->group('celist.' . View_CeList::COL_CAEX_ID); $headerArray = array(array('raw' => View_CeList::COL_CAEX_NAME, 'name' => 'CE name'), array('raw' => View_CeList::COL_WORK_NAME, 'name' => 'Workshop name'), array('raw' => Expertise::COL_AREA, 'name' => 'Exp area'), array('raw' => Expertise::COL_SPECIES, 'name' => 'Exp species'), array('raw' => Expertise::COL_SUBJECT, 'name' => 'Exp subject'), array('raw' => KeyTable::COL_FILENAME, 'name' => 'Protocol')); if (array_key_exists(User::COL_ID, $params)) { //filter... $select->joinLeft(array('part' => Participant::TABLE_NAME), $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_CAEX_ID) . '=' . $dbAdapter->quoteIdentifier('part.' . Participant::COL_CE_ID), array('part.' . Participant::COL_ID)); //where i am participant $select->where('part.' . Participant::COL_USER_ID . '=?', $params[User::COL_ID]); $userId = $params[User::COL_ID]; $select->joinLeft(array('work' => Workshop::TABLE_NAME), 'work.' . Workshop::COL_ID . '=' . 'celist.' . View_CeList::COL_WORK_ID, array(Workshop::COL_USER_ID)); //or where i am workshop-manager $select->orWhere('work.' . Workshop::COL_USER_ID . '= ?', $userId); array_push($headerArray, array('raw' => View_CeList::COL_IMAGES, 'name' => 'Images')); } if (array_key_exists(CalibrationExercise::COL_EXPERTISE_ID, $params)) { $select->where('celist.' . CalibrationExercise::COL_EXPERTISE_ID . '=?', $params[CalibrationExercise::COL_EXPERTISE_ID]); // $select->joinLeft(array('cehim'=>CeHasImage::TABLE_NAME), // $dbAdapter->quoteIdentifier('celist.' . View_CeList::COL_CAEX_ID). '=' . $dbAdapter->quoteIdentifier('cehim.' .CeHasImage::COL_CALIBRATION_EXERCISE_ID), // array()); } //Hinzugefügt am 14.10.2009 Tabellenzeilen mit WS name = training exercise //sollten nicht angezeigt werden (im Menüpunkt search calibration exercises) //kompletter if-Zweig wurde hinzugefügt if ($this->getRequest()->getModuleName() == 'ce' && $this->getRequest()->getControllerName() == 'search' && $this->getRequest()->getActionName() == 'list') { $select->where(CalibrationExercise::COL_WORKSHOP_ID . ' is not null'); } //echo $select; /** * Paginator control */ $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); $paginator->setHeader($headerArray); $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(10)->setPageRange(5)->orderBy($this->getRequest()->getParam('orderBy')); //$this->_getParam('pageRange')); Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml'); $detailId = $this->getRequest()->getParam('detailId'); if ($detailId != null) { $detailId = intval($detailId); /** * show wether CE is stopped */ try { if (Default_SimpleQuery::isCeStopped($detailId)) { $this->view->ceInfo = 'CE is <b>STOPPED</b>'; } else { $this->view->ceInfo = 'CE is <b>RUNNING</b>'; } } catch (exception $e) { $this->view->ceInfo = $e->getMessage(); } /** * show Coordinator */ if ($coordinators = Participant::getCoordinators($detailId)) { $this->view->ceCoordinators = $coordinators; } /** * imageset and shown attributes */ $imagesetSelect = $dbAdapter->select(); $imagesetSelect->from('v_imageset_info'); $imagesetSelect->where(CalibrationExercise::COL_ID . '=?', $detailId); $imagesetSelect->group(AttributeDescriptor::COL_NAME); $imagesetArray = $dbAdapter->fetchAll($imagesetSelect); $this->view->imagesetArray = $imagesetArray; $shownAttrSelect = $dbAdapter->select(); $shownAttrSelect->from(array('cehat' => CeHasAttributeDescriptor::TABLE_NAME)); $shownAttrSelect->join(array('attr' => AttributeDescriptor::TABLE_NAME), 'cehat.' . CeHasAttributeDescriptor::COL_ATDE_ID . '= attr.' . AttributeDescriptor::COL_ID); $shownAttrSelect->where(CalibrationExercise::COL_ID . '=?', $detailId); $shownAttrArray = $dbAdapter->fetchAll($shownAttrSelect); $this->view->shownAttrArray = $shownAttrArray; $this->view->detailId = $detailId; } $this->view->userRole = AuthQuery::getUserRole(); $this->view->expeId = $this->getRequest()->getParam(CalibrationExercise::COL_EXPERTISE_ID); $this->view->paginator = $paginator; $this->render('list'); }
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; // } }
public function searchAction() { $request = $this->getRequest(); $formValues = $this->namespace->formValues; $this->view->callingAction = $this->defaultNamespace->callingAction; // get meta data select for image and fish descriptors $metaData = new Default_MetaData(); $metaData->getSelectForGroups(TRUE); $select = $metaData->addWhereToSelect($formValues); if ($this->defaultNamespace->callingAction == 'annotation/browse/byimage') { unset($this->namespace->ceArray); $select->joinLeft(array('vaa' => 'v_all_annotations'), 'vaa.' . CeHasImage::COL_IMAGE_ID . ' = ' . 'image.' . Image::COL_ID, array()); //auf cehas_image damit die ausgefiltert werden die keine annotationen haben $select->where(Annotations::COL_WS_REF . "=? ", 1); $select->orWhere(Annotations::COL_FINAL . " = ? ", 1); $select->orWhere(Annotations::COL_GROUP . "=? ", 1); $select->orWhere(Annotations::COL_WEBGR_REF . "=? ", 1); $select->group('image.' . Image::COL_ID); $resultArray = Zend_Registry::get('DB_CONNECTION1')->fetchAll($select); if ($resultArray != array()) { $resultKey = new Ble422_Guid(); $this->defaultNamespace->{$resultKey} = $resultArray; $redirect = new Zend_Controller_Action_Helper_Redirector(); $redirect->setGotoSimple('start', 'browse', 'annotation', array('resultKey' => $resultKey)); } } else { //select only own images if ($this->defaultNamespace->callingAction == 'user/edit/myimages') { $select->where('image.' . Image::COL_USER_ID . ' = ?', $this->defaultNamespace->callingActionId); } //filter double datasets caused by multiple meta data //$select->group('image.'.Image::COL_ID); //get already assigned datasets for setting disabled in view if ($this->defaultNamespace->callingAction == '/ce/edit/addimages') { $ceId = $this->defaultNamespace->callingActionId; $ceHasIm = new CeHasImage(); $rowSet = $ceHasIm->fetchAll(CeHasImage::COL_CALIBRATION_EXERCISE_ID . '=' . $ceId); if (count($rowSet) > 0) { $assignedImages = array(); foreach ($rowSet as $row) { $assignedImages[$row[CeHasImage::COL_IMAGE_ID]] = TRUE; } $this->view->assignedImages = $assignedImages; } } //echo $select; /** * Pagination control */ $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); // echo $select->__toString(); // die(); //static + dynamic header array $statArray = array(array('raw' => Image::COL_ORIGINAL_FILENAME, 'name' => 'Original file name'), array('raw' => Fish::COL_SAMPLE_CODE, 'name' => 'Fish sample code'), array('raw' => Image::COL_DIM_X, 'name' => 'Width'), array('raw' => Image::COL_DIM_Y, 'name' => 'Height')); $dynArray = array(); $i = 0; foreach ($metaData->fishRowSetArray as $fishAttr) { $dynInnerArray = array('raw' => 'ATDE_' . $fishAttr[AttributeDescriptor::COL_ID], 'name' => $fishAttr[AttributeDescriptor::COL_NAME] . '<br>' . $fishAttr['UNIT']); $dynArray[$i] = $dynInnerArray; $i++; } $headerArray = array_merge($statArray, $dynArray); unset($i); unset($dynArray); unset($dynInnerArray); $i = 0; foreach ($metaData->imageRowSetArray as $imAttr) { $dynInnerArray = array('raw' => 'ATDE_' . $imAttr[AttributeDescriptor::COL_ID], 'name' => $imAttr[AttributeDescriptor::COL_NAME] . '<br>' . $imAttr['UNIT']); $dynArray[$i] = $dynInnerArray; $i++; } $headerArray = array_merge($headerArray, $dynArray); unset($i); unset($dynArray); unset($dynInnerArray); $paginator->setHeader($headerArray); $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; } }