/** * fetch the best conversion profile for the partner - depending on the data in the DB only (no hint from the user) */ public static function retrieveByPartner($partner_id) { $c = new Criteria(); $c->addDescendingOrderByColumn(self::UPDATED_AT); // make sure the first profile is the most updated // $c->addAnd ( self::PROFILE_TYPE, $profile_type); if ($partner_id) { $crit = $c->getNewCriterion(self::PARTNER_ID, ConversionProfile::GLOBAL_PARTNER_PROFILE, Criteria::EQUAL); $crit->addOr($c->getNewCriterion(self::PARTNER_ID, $partner_id, Criteria::EQUAL)); $c->add($crit); } else { $c->add(self::PARTNER_ID, $partner_id, Criteria::EQUAL); } $conv_list = self::doSelect($c); if ($conv_list == null) { return null; } foreach ($conv_list as $conv) { // select the first conversion profile that matchs the partner if ($conv->getPartnerId() == $partner_id) { return $conv; } } // if no conv_prof found for partner - use the global ones return $conv_list[0]; // first profile returned }
public function execute($request) { parent::execute($request); $this->permissions = array(); if (null != $this->resource->id) { // Get term permissions for this group $criteria = new Criteria(); $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN); $criteria->add(QubitAclPermission::GROUP_ID, $this->resource->id); $c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL); $c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitTerm'); $c1->addOr($c2); $criteria->add($c1); $criteria->addAscendingOrderByColumn(QubitAclPermission::CONSTANTS); $criteria->addAscendingOrderByColumn(QubitAclPermission::OBJECT_ID); if (0 < count($permissions = QubitAclPermission::get($criteria))) { $this->permissions = $permissions; } } // List of actions without create or translate $this->basicActions = QubitAcl::$ACTIONS; unset($this->basicActions['read']); unset($this->basicActions['translate']); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $this->processForm(); $this->redirect(array($this->resource, 'module' => 'aclGroup', 'action' => 'indexTermAcl')); } } }
public function executeSearchSchools(sfWebRequest $request) { $this->getResponse()->setContentType('application/json'); if (strlen(trim($q = $request->getParameter('q'))) > 2) { $c = new Criteria(); $crit = $c->getNewCriterion(OriginSchoolPeer::NAME, "%{$q}%", Criteria::LIKE); $crit->addOr($c->getNewCriterion(OriginSchoolPeer::ADDRESS, "%{$q}%", Criteria::LIKE)); $crit->addOr($c->getNewCriterion(OriginSchoolPeer::CUE, "%{$q}%", Criteria::LIKE)); $c->add($crit); $c->setLimit(20); $results = array(); foreach ($matches = OriginSchoolPeer::doSelect($c) as $match) { $results[] = array('id' => $match->getId(), 'text' => $match->__toString()); } return $this->renderText(json_encode(array('results' => $results))); } else { if ($request->getParameter('id') !== null) { $match = OriginSchoolPeer::retrieveByPK($request->getParameter('id')); $result = null; if ($match !== null) { $result = array('id' => $match->getId(), 'text' => strval($match)); } return $this->renderText(json_encode($result)); } } return $this->renderText('{}'); }
public function executeBusquedaDocente() { // inicializando variables $aDocente = array(); // tomando los datos del formulario $txt = $this->getRequestParameter('txt'); /* $organizacion_id = $this->getUser()->getAttribute('fk_organizacion_id'); $criteria = new Criteria(); $criteria->add(DocentePeer::FK_ORGANIZACION_ID, $organizacion_id); */ if ($this->getRequest()->getMethod() == sfRequest::POST) { // buscando alumnos $criteria = new Criteria(); if ($txt) { $cton1 = $criteria->getNewCriterion(DocentePeer::NOMBRE, "%{$txt}%", Criteria::LIKE); $cton2 = $criteria->getNewCriterion(DocentePeer::APELLIDO, "%{$txt}%", Criteria::LIKE); $cton1->addOr($cton2); $criteria->add($cton1); } $aDocente = DocentePeer::doSelect($criteria); if (count($aDocente) == 1) { $this->redirect('calendario/horarioSegunDocente?id=' . $aDocente[0]->getId()); } } // asignando variables para ser usadas en el template //$this->organizacion_id = $organizacion_id; $this->txt = $txt; $this->aDocente = $aDocente; }
public static function retrievePagerByUser($user_id, $page = 1, $max = null) { if ($max == null) { $max = sfConfig::get('app_pager_project_max'); } sfContext::getInstance()->getLogger()->info('Begin project retrieval by user_id'); $c = new Criteria(); $positions = ProjectUserPeer::retrieveFilledByUserId($user_id); $projects = array(); foreach ($positions as $position) { $projects[] = $position->getProjectPosition()->getProjectId(); } if (count($projects) > 0) { $c->add(self::ID, $projects, Criteria::IN); } $crit0 = $c->getNewCriterion(self::CREATED_BY, $user_id); $crit1 = $c->getNewCriterion(self::OWNER_ID, $user_id); $crit0->addOr($crit1); $c->add($crit0); $pager = new sfPropelPager('Project', $max); $pager->setCriteria($c); $pager->setPage($page); $pager->init(); return $pager; }
/** * returns the groups in the given ramo (and for the given legislatura) and include the zero value, if given * * @param string $ramo * @param int $legislatura * @param string $include_zero * @return an associative array, with id and name as key => value * @author Guglielmo Celata */ public static function getAllGroups($ramo, $legislatura, $include_zero = false) { $c = new Criteria(); if ($ramo == 'camera') { $c->add(OppCaricaPeer::TIPO_CARICA_ID, 1); } else { $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(4, 5), Criteria::IN); } $c->addJoin(OppGruppoPeer::ID, OppCaricaHasGruppoPeer::GRUPPO_ID); $c->addJoin(OppCaricaPeer::ID, OppCaricaHasGruppoPeer::CARICA_ID); $c_or_leg = $c->getNewCriterion(OppCaricaPeer::LEGISLATURA, $legislatura); $c_or_leg->addOr($c->getNewCriterion(OppCaricaPeer::LEGISLATURA, null, Criteria::ISNULL)); $c->add($c_or_leg); $c->clearSelectColumns(); $c->addSelectColumn(OppGruppoPeer::ID); $c->addSelectColumn(OppGruppoPeer::NOME); $c->setDistinct(); $rs = OppGruppoPeer::doSelectRS($c); if ($include_zero) { $all_groups = array('0' => $include_zero); } else { $all_groups = array(); } while ($rs->next()) { $all_groups[$rs->getInt(1)] = $rs->getString(2); } return $all_groups; }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitUser(); if (isset($this->getRoute()->resource)) { $this->resource = $this->getRoute()->resource; } // Always include root actor permissions $this->actors = array(QubitActor::ROOT_ID => null); // Get actor permissions for this group $criteria = new Criteria(); $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN); $criteria->add(QubitAclPermission::USER_ID, $this->resource->id); $c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL); $c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitActor'); $c1->addOr($c2); $criteria->add($c1); if (null !== ($permissions = QubitAclPermission::get($criteria))) { foreach ($permissions as $item) { $this->actors[$item->objectId][$item->action] = $item; } } // List of actions without translate $this->basicActions = QubitAcl::$ACTIONS; unset($this->basicActions['translate']); }
function getCalendarCriterias($filter, $start, $limit) { $Criteria = new Criteria('workflow'); $Criteria->clearSelectColumns(); $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID); if ($filter != '') { $Criteria->add($Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE))); } $Criteria->add(CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID); $oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_NAME); $oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_CREATE_DATE); $oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UPDATE_DATE); $oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_DESCRIPTION); $oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_STATUS); if ($filter != '') { $oCriteria->add($oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE))); } $oCriteria->add(CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL); $oCriteria->setLimit($limit); $oCriteria->setOffset($start); $criterias = array(); $criterias['COUNTER'] = $Criteria; $criterias['LIST'] = $oCriteria; return $criterias; }
public static function search($query_string, $sf_user, $limit = 12) { $query_string = trim($query_string); if (!is_null($query_string) && !empty($query_string) && '' != $query_string && strlen($query_string) > 3) { $criteria = new Criteria(); $criteria->setIgnoreCase(true); $criteria->setLimit($limit); $criteria->add(SchoolYearStudentPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); $criteria->addJoin(SchoolYearStudentPeer::STUDENT_ID, self::ID); $criteria->addJoin(self::PERSON_ID, PersonPeer::ID, Criteria::INNER_JOIN); $criteria->addAscendingOrderByColumn(PersonPeer::LASTNAME); if (is_numeric($query_string)) { // Search by identification number $criteria->add(PersonPeer::IDENTIFICATION_NUMBER, $query_string . '%', Criteria::LIKE); } else { // Search by firstname or lastname $criterion = $criteria->getNewCriterion(PersonPeer::FIRSTNAME, $query_string . '%', Criteria::LIKE); $criterion->addOr($criteria->getNewCriterion(PersonPeer::LASTNAME, $query_string . '%', Criteria::LIKE)); $criteria->add($criterion); } if ($sf_user->isPreceptor()) { PersonalPeer::joinWithStudents($criteria, $sf_user->getGuardUser()->getId()); } elseif ($sf_user->isTeacher()) { TeacherPeer::joinWithStudents($criteria, $sf_user->getGuardUser()->getId()); } //FALTA HEAD PRECEPTOR return self::doSelectActive($criteria); } return array(); }
public function execute($request) { parent::execute($request); // Always include root actor permissions $this->actors = array(QubitActor::ROOT_ID => null); // Get actor permissions for this resource $criteria = new Criteria(); $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN); $criteria->add(QubitAclPermission::GROUP_ID, $this->resource->id); $c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL); $c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitActor'); $c1->addOr($c2); $criteria->add($c1); if (null !== ($permissions = QubitAclPermission::get($criteria))) { foreach ($permissions as $p) { $this->actors[$p->objectId][$p->action] = $p; } } // List of actions without translate $this->basicActions = QubitAcl::$ACTIONS; unset($this->basicActions['translate']); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $this->processForm(); $this->redirect(array($this->resource, 'module' => 'aclGroup', 'action' => 'indexActorAcl')); } } }
function detectHungJobs() { // optimized query to select only possibly hung jobs... $c = new Criteria(); $cStatusRunning = $c->getNewCriterion($this->options['jobStatusColName'], JQManagedJob::STATUS_RUNNING); $cStatusWaitAsync = $c->getNewCriterion($this->options['jobStatusColName'], JQManagedJob::STATUS_WAIT_ASYNC); $cStatusRunning->addOr($cStatusWaitAsync); $c->add($cStatusRunning); $c->add($this->options['jobMaxRuntimeSecondsColName'], NULL, Criteria::ISNOTNULL); $c->add($this->options['jobMaxRuntimeSecondsColName'], "{$this->options['jobStartDtsColName']} + ({$this->options['jobMaxRuntimeSecondsColName']}||' seconds')::interval < now()", Criteria::CUSTOM); $possiblyHungJobs = call_user_func(array("{$this->propelClassName}Peer", 'doSelect'), $c, $this->con); foreach ($possiblyHungJobs as $possiblyHungJob) { // @todo This is a bit ugly; we probably need something like a JQStore::performWithMutex($jobId, $f) where we can wrap f internally in a try/catch to do this more cleanly $this->con->beginTransaction(); try { $mJob = $this->getWithMutex($possiblyHungJob->getJobId()); if ($mJob->isPastMaxRuntimeSeconds()) { $mJob->retry(true); $runningTime = time() - $mJob->getStartDts()->format('U'); print "Retrying job:{$mJob->getJobId()} after running for: {$runningTime} seconds job maxRunTimeSeconds: {$mJob->getMaxRuntimeSeconds()}\n"; } $this->clearMutex($mJob->getJobId()); $this->con->commit(); } catch (JQStore_JobNotFoundException $e) { // the job already finished, continue the loop print "job not found, continue\n"; $this->abort(); continue; } catch (Exception $e) { $this->abort(); throw $e; } } }
public function serversideAction() { $request = $this->getRequest(); if ($request->isPost()) { //EL MAPEO DE NUESTRA TABALA $table_map = array(0 => 'expediente_folio', 1 => 'expediente_fechainicio', 2 => 'expediente_tipo', 3 => 'expediente_consignatario', 4 => 'expediente_embarcador', 5 => 'expediente_estatus'); $post_data = $request->getPost(); //NUESTRA QUERY $query = new \ExpedienteQuery(); $query->joinCliente()->withColumn('cliente_razonsocial'); $query->joinProveedorcliente()->withColumn('proveedorcliente_nombre'); //ORDER if (isset($post_data['order'])) { $order = $table_map[$post_data['order'][0]['column']]; $dir = $post_data['order'][0]['dir']; $query->orderBy($order, $dir); } else { $query->orderByIdexpediente(\Criteria::DESC); } if (!empty($post_data['search']['value'])) { $search = $post_data['search']['value']; $c = new \Criteria(); $c1 = $c->getNewCriterion('expediente.expediente_folio', '%' . $search . '%', \Criteria::LIKE); //$c2= $c->getNewCriterion('expediente.expediente_fechainicio', '%'.$search.'%', \Criteria::LIKE); $c3 = $c->getNewCriterion('expediente.expediente_tipo', '%' . $search . '%', \Criteria::LIKE); $c4 = $c->getNewCriterion('expediente.expediente_estatus', '%' . $search . '%', \Criteria::LIKE); $c5 = $c->getNewCriterion('cliente.cliente_razonsocial', '%' . $search . '%', \Criteria::LIKE); $c6 = $c->getNewCriterion('proveedorcliente.proveedorcliente_nombre', '%' . $search . '%', \Criteria::LIKE); $c1->addOr($c3)->addOr($c4)->addOr($c5)->addOr($c6); $query->addAnd($c1); } //EL TOTAL DE LA BUSQUEDA $recordsFiltered = $query->count(); //LIMIT $query->setOffset((int) $post_data['start']); $query->setLimit((int) $post_data['length']); //DAMOS EL FORMATO CORRECTO $data = array(); $value = new \Expediente(); foreach ($query->find() as $value) { $tmp['DT_RowId'] = $value->getIdexpediente(); $tmp['expediente_folio'] = $value->getExpedienteFolio('d/m/Y'); $tmp['expediente_fechainicio'] = $value->getExpedienteFechainicio('d/m/Y'); $tmp['expediente_tipo'] = $value->getExpedienteTipo(); $tmp['expediente_estatus'] = ucfirst($value->getExpedienteEstatus()); if ($value->getExpedienteTipo() == 'importacion') { $tmp['expediente_consignatario'] = $value->getCliente()->getClienteRazonsocial(); $tmp['expediente_embarcador'] = $value->getProveedorcliente()->getProveedorclienteNombre(); } else { $tmp['expediente_embarcador'] = $value->getCliente()->getClienteRazonsocial(); $tmp['expediente_consignatario'] = $value->getProveedorcliente()->getProveedorclienteNombre(); } $tmp['expediente_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/clientes/ver/' . $value->getIdcliente() . '/expedientes/ver/' . $value->getIdexpediente() . '"><i class="fa fa-pencil"></i></a><a class="delete" data-toggle="tooltip" data-placement="left" title="Eliminar" href="javascript:void(0)"><i class="fa fa-trash-o"></i></a>'; $data[] = $tmp; } //El arreglo que regresamos $json_data = array("draw" => (int) $post_data['draw'], "recordsFiltered" => $recordsFiltered, "data" => $data, "page" => $post_data['url_params']['page']); return $this->getResponse()->setContent(json_encode($json_data)); } }
public function delete($connection = null) { // Cascade delete descendants if (0 < count($children = $this->getChildren())) { foreach ($children as $child) { $child->delete($connection); } } // Delete relations $criteria = new Criteria(); $cton1 = $criteria->getNewCriterion(QubitRelation::OBJECT_ID, $this->id); $cton2 = $criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $this->id); $cton1->addOr($cton2); $criteria->add($cton1); if (0 < count($relations = QubitRelation::get($criteria))) { foreach ($relations as $relation) { $relation->delete($connection); } } // Delete relation to objects $criteria = new Criteria(); $criteria->add(QubitObjectTermRelation::TERM_ID, $this->id); if (0 < count($otRelations = QubitObjectTermRelation::get($criteria))) { foreach ($otRelations as $otRelation) { $otRelation->delete($connection); } } parent::delete($connection); }
public static function getReviewsByUser($userId, $f = false, $page = 1, $numberOfResults = BaseSfReviewManager::NUM_REVIEWS) { $culture = sfContext::getInstance()->getUser()->getCulture(); $criteria = new Criteria(); $criteria->add(SfReviewPeer::IS_ACTIVE, true); // Filter entities by culture. Must have 'culture' column and 'culturized' column in sf_review_type must be checked $criteria->addJoin(SfReviewPeer::SF_REVIEW_TYPE_ID, SfReviewTypePeer::ID, Criteria::LEFT_JOIN); $cultureCriterion = $criteria->getNewCriterion(SfReviewTypePeer::CULTURIZED, false); $cultureCriterion->addOr($criteria->getNewCriterion(SfReviewPeer::CULTURE, $culture)); $criteria->add($cultureCriterion); $criteria->add(SfReviewPeer::SF_GUARD_USER_ID, $userId); $criteria->add(SfReviewPeer::ANONYMOUS, false); $criteria->addDescendingOrderByColumn("IFNULL(" . SfReviewPeer::MODIFIED_AT . "," . SfReviewPeer::CREATED_AT . ")"); if ($f) { if (preg_match('/\\.0/', $f)) { $criteria->add(SfReviewPeer::SF_REVIEW_TYPE_ID, null, Criteria::ISNULL); } else { if (preg_match('/[0-9]/', $f)) { $criteria->add(SfReviewPeer::SF_REVIEW_TYPE_ID, $f); } } $criteria->add(SfReviewPeer::IS_ACTIVE, true); } $pager = new sfPropelPager('SfReview', $numberOfResults); $pager->setCriteria($criteria); $pager->setPage($page); $pager->init(); return $pager; }
/** * Retrieve all records larger than the id * * @param array $servers<SphinxLogServer> * @param int $gap * @param int $limit * @param array $handledEntries * @param PropelPDO $con the connection to use * @return SphinxLog */ public static function retrieveByLastId(array $servers, $gap = 0, $limit = 1000, array $handledEntries = null, PropelPDO $con = null) { $criteria = new Criteria(); $criterions = null; if (count($servers)) { $criterions = $criteria->getNewCriterion(SphinxLogPeer::ID, null, Criteria::ISNULL); } foreach ($servers as $server) { $dc = $server->getDc(); $crit = $criteria->getNewCriterion(SphinxLogPeer::ID, $server->getLastLogId() - $gap, Criteria::GREATER_THAN); $crit->addAnd($criteria->getNewCriterion(SphinxLogPeer::DC, $dc)); if (!is_null($handledEntries)) { $crit->addAnd($criteria->getNewCriterion(SphinxLogPeer::ID, $handledEntries[$dc], Criteria::NOT_IN)); } $criterions->addOr($crit); } if ($criterions) { $criteria->addAnd($criterions); } $disabledPartnerIds = kConf::get('disable_sphinx_indexing_partners', 'local', array()); if ($disabledPartnerIds) { $criteria->add(SphinxLogPeer::PARTNER_ID, $disabledPartnerIds, Criteria::NOT_IN); } $criteria->addAscendingOrderByColumn(SphinxLogPeer::ID); $criteria->setLimit($limit); return SphinxLogPeer::doSelect($criteria, $con); }
public function executeList() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); $c->add(JobPeer::CODE, $this->getModuleName()); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); if (!$acl) { $this->forward('default', 'error404'); } $this->can_edit = $acl->getEditPriv() == 1; $this->can_remove = $acl->getRemovePriv() == 1; $c = new Criteria(); $dept = $this->getContext()->getUser()->getAttribute('department', null, 'bo'); $c->add(AcademicCalendarPeer::DEPARTMENT_ID, $dept->getChildRecurs(), Criteria::IN); $c->addJoin(StudentPeer::ACADEMIC_CALENDAR_ID, AcademicCalendarPeer::ID); // filter out graduated alumni $cton1 = $c->getNewCriterion(StudentPeer::STATUS, Student::STATUS_GRADUATE, Criteria::EQUAL); $cton2 = $c->getNewCriterion(StudentPeer::STATUS, Student::STATUS_OVERDUE, Criteria::EQUAL); $cton1->addOr($cton2); $c->add($cton1); $this->sort($c); if ($this->getRequest()->hasParameter('filters')) { $filters = $this->getRequestParameter('filters'); if ($filters == 'clear') { $this->filters = null; } else { $defined_filter = false; foreach ($filters as $f) { if (is_array($f)) { if (strlen($f['from']) > 0 || strlen($f['to']) > 0) { $defined_filter = true; break; } } else { if ($f != null && $f != '') { $defined_filter = true; break; } } } if ($defined_filter) { $this->filters = $filters; $this->filter($c, $this->getRequestParameter('filters')); } } } $rpp = $this->getRequestParameter('max_per_page', $this->getUser()->getAttribute('max_per_page', ParamsPeer::retrieveByCode('row_per_page')->getValue(), 'alumni')); $this->getUser()->setAttribute('max_per_page', $rpp, 'alumni'); $pager = new sfPropelPager('Student', $rpp); $pager->setCriteria($c); $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'alumni')); $this->getUser()->setAttribute('page', $page, 'student'); $pager->setPage($page); $pager->init(); $this->pager = $pager; $actions = array(array('name' => 'filter', 'color' => 'white')); #if ($acl->getAddPriv()) array_unshift($actions, array('name'=>'add','url'=>'student/create', 'color'=>'green')); $this->actions = $actions; }
/** * estrae tutti i gruppi di un ramo, attivi alla data passata * * @param string $ramo * @param string $data * @return array di OppGruppoRamo, join con OppGruppo * @author Guglielmo Celata */ public static function getGruppiRamo($ramo, $data = null, $con = null) { $c = new Criteria(); if (!is_null($data)) { $crit0 = $c->getNewCriterion(self::DATA_FINE, $data, Criteria::GREATER_EQUAL); $crit1 = $c->getNewCriterion(self::DATA_FINE, null, Criteria::ISNULL); $crit0->addOr($crit1); $crit2 = $c->getNewCriterion(self::DATA_INIZIO, $data, Criteria::LESS_EQUAL); $crit0->addAnd($crit2); $c->add($crit0); /* $c->add(self::RAMO, $ramo); $c_or_data_fine = $c->getNewCriterion(self::DATA_FINE, $data, Criteria::GREATER_EQUAL); $c_or_data_fine->addOr(self::DATA_FINE, null, Criteria::ISNULL); $c_data = $c->getNewCriterion(self::DATA_INIZIO, $data, Criteria::LESS_EQUAL); $c_data->addAnd($c_or_data_fine); $c->add($c_data); */ } else { $c->add(self::DATA_FINE, null, Criteria::ISNULL); } $c->add(self::RAMO, $ramo); return self::doSelectJoinOppGruppo($c, $con); }
/** * Builds a {@link Criterion} object for the specified search term. * Requires that {@link $searchColumns} contains at least one element. * * @param Criteria $c * @param string $term * @param array $searchColumns * @return Criterion * @see addSearchCriteria() */ private static function getSearchTermCriterion(Criteria $c, $term, array $searchColumns) { $searchCriterion = $c->getNewCriterion(array_shift($searchColumns), '%' . $term . '%', Criteria::LIKE)->setIgnoreCase(true); foreach ($searchColumns as $columnName) { $searchCriterion->addOr($c->getNewCriterion($columnName, '%' . $term . '%', Criteria::LIKE)->setIgnoreCase(true)); } return $searchCriterion; }
public function addWordColumnCriteria(Criteria $criteria, $field, $value) { $value = "%{$value}%"; $criteria->setIgnoreCase(true); $criterion = $criteria->getNewCriterion(SubjectPeer::NAME, $value, Criteria::LIKE); $criterion->addOr($criteria->getNewCriterion(SubjectPeer::FANTASY_NAME, $value, Criteria::LIKE)); $criteria->add($criterion); }
public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) { $c1 = $criteria->getNewCriterion(TablaPeer::BORRADO, null, Criteria::ISNULL); $c2 = $criteria->getNewCriterion(TablaPeer::BORRADO, false, Criteria::EQUAL); $c1->addOr($c2); $criteria->addAnd($c1); return parent::doSelectStmt($criteria, $con); }
public function execute($request) { $this->resource = $this->getRoute()->resource; // Except for administrators, only allow users to see their own profile if (!$this->context->user->hasCredential('administrator')) { if ($this->resource->id != $this->context->user->getAttribute('user_id')) { $this->redirect('admin/secure'); } } // Get user's groups $this->userGroups = array(); if (0 < count($aclUserGroups = $this->resource->aclUserGroups)) { foreach ($aclUserGroups as $aclUserGroup) { $this->userGroups[] = $aclUserGroup->groupId; } } else { // User is *always* part of authenticated group $this->userGroups = array(QubitAclGroup::AUTHENTICATED_ID); } // Table width $this->tableCols = count($this->userGroups) + 3; // Get access control permissions $criteria = new Criteria(); $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN); $c1 = $criteria->getNewCriterion(QubitAclPermission::USER_ID, $this->resource->id); // Add group criteria if (1 == count($this->userGroups)) { $c2 = $criteria->getNewCriterion(QubitAclPermission::GROUP_ID, $this->userGroups[0]); } else { $c2 = $criteria->getNewCriterion(QubitAclPermission::GROUP_ID, $this->userGroups, Criteria::IN); } $c1->addOr($c2); // Add info object criteria $c3 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitInformationObject'); $c4 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL); $c3->addOr($c4); $c1->addAnd($c3); $criteria->add($c1); // Sort $criteria->addAscendingOrderByColumn(QubitAclPermission::CONSTANTS); $criteria->addAscendingOrderByColumn(QubitAclPermission::OBJECT_ID); $criteria->addAscendingOrderByColumn(QubitAclPermission::USER_ID); $criteria->addAscendingOrderByColumn(QubitAclPermission::GROUP_ID); // Add user as final "group" $this->userGroups[] = $this->resource->username; // Build ACL $this->acl = array(); if (0 < count($permissions = QubitAclPermission::get($criteria))) { foreach ($permissions as $item) { // In this context permissions for all objects (null) and root actor // object are equivalent $objectId = QubitInformationObject::ROOT_ID != $item->objectId ? $item->objectId : null; // Use username as "group" for permissions specific to user $groupKey = null !== $item->groupId ? $item->groupId : $this->resource->username; $this->acl[$item->getConstants(array('name' => 'repositoryId'))][$objectId][$item->action][$groupKey] = $item; } } }
public static function getAllNonDescendantsPathsCriteria($folder) { $c = new Criteria(); $criterion1 = $c->getNewCriterion(self::TREE_LEFT, $folder->getLeftValue(), Criteria::LESS_THAN); $criterion2 = $c->getNewCriterion(self::TREE_RIGHT, $folder->getRightValue(), Criteria::GREATER_THAN); $criterion1->addOr($criterion2); $c->add($criterion1); return $c; }
public static function getCriteriaForAutocomplete($q) { $c = new Criteria(); $crit0 = $c->getNewCriterion(PhotographerPeer::NAME, "%" . $q . "%", Criteria::LIKE); $crit1 = $c->getNewCriterion(PhotographerPeer::EMAIL, "%" . $q . "%", Criteria::LIKE); $crit0->addOr($crit1); $c->add($crit0); return $c; }
public static function doFiltered() { $criteria = new Criteria(); $cton1 = $criteria->getNewCriterion(GradeComponentPeer::GRADE_SPEC_ID, 21, Criteria::NOT_IN); $cton2 = $criteria->getNewCriterion(GradeComponentPeer::GRADE_SPEC_ID, 39, Criteria::NOT_IN); $cton1->addAnd($cton2); $criteria->add($cton1); return GradeComponentPeer::doSelect($criteria); }
public function countValidCourseSubjectStudentMarks() { $c = new Criteria(); $criterion = $c->getNewCriterion(CourseSubjectStudentMarkPeer::IS_FREE, true, Criteria::EQUAL); $criterion->addOr($c->getNewCriterion(CourseSubjectStudentMarkPeer::IS_CLOSED, true, Criteria::EQUAL)); $criterion->addOr($c->getNewCriterion(CourseSubjectStudentMarkPeer::MARK, null, Criteria::ISNOTNULL)); $c->addOr($criterion); return $this->countCourseSubjectStudentMarks($c); }
public static function doSelectFiltered() { $ct = new Criteria(); $cton1 = $ct->getNewCriterion(Cur13KiPeer::ID, ScoreRule::ONE, Criteria::NOT_IN); $cton2 = $ct->getNewCriterion(Cur13KiPeer::ID, ScoreRule::TWO, Criteria::NOT_IN); $cton1->addAnd($cton2); $ct->add($cton1); return Cur13KiPeer::doSelect($ct); }
protected static function buildCriteriaForTimeWindow($time_window) { $to = time(); $from = strtotime("-{$time_window} seconds"); $criteria = new Criteria(); $cri = $criteria->getNewCriterion(self::FAILED_AT, $from, Criteria::GREATER_EQUAL); $cri->addAnd($criteria->getNewCriterion(self::FAILED_AT, $to, Criteria::LESS_EQUAL)); $criteria->add($cri); return $criteria; }
function runComplexQuery($i) { $c = new Criteria(); $cton1 = $c->getNewCriterion(AuthorPeer::ID, $this->authors[array_rand($this->authors)], Criteria::GREATER_THAN); $cton2 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, '(' . AuthorPeer::FIRST_NAME . '||' . AuthorPeer::LAST_NAME . ') =' . $this->con->quote('John Doe'), Criteria::CUSTOM); $cton1->addOr($cton2); $c->add($cton1); $c->setLimit(5); AuthorPeer::doCount($c, $this->con); }
/** * Function returns the default criteria of the partner class * @return Criteria */ public static function getDefaultCriteria() { $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id; $c = new Criteria(); $subCriterion1 = $c->getNewCriterion(PartnerPeer::PARTNER_PARENT_ID, $partnerId); $subCriterion2 = $c->getNewCriterion(PartnerPeer::ID, $partnerId); $subCriterion1->addOr($subCriterion2); $c->add($subCriterion1); return $c; }
/** * Retorna els missatges locals i globals actius. * @param Criteria $C * @param Site_id $idS * */ static function getCriteriaActiu($C, $idS) { $C->add(self::ACTIU, true); $C->add(self::ACTIU, true); $C1 = $C->getNewCriterion(self::ISGLOBAL, true); $C2 = $C->getNewCriterion(self::SITE_ID, $idS); $C1->addOr($C2); $C->add($C1); return $C; }