function load($sh, $c_query = null) { $db = DB::Instance(); $qb = new QueryBuilder($db, $this->_doname); if ($sh instanceof SearchHandler) { if ($this->_templateobject->isAccessControlled()) { if (isModuleAdmin()) { $cc = new ConstraintChain(); $cc->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID)); $cc->add(new Constraint('id', '=', EGS_COMPANY_ID), 'OR'); $sh->addConstraintChain($cc); $qb->setDistinct(); } else { $cc = new ConstraintChain(); $cc->add(new Constraint('usernameaccess', '=', EGS_USERNAME)); $cc->add(new Constraint('owner', '=', EGS_USERNAME), 'OR'); $cc2 = new ConstraintChain(); $cc2->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID)); $sh->addConstraintChain($cc); $sh->addConstraintChain($cc2); $qb->setDistinct(); } } $this->sh = $sh; } $this->_load($sh, $qb, $c_query); }
function update($fields, $values, $sh, $c_query = null) { if (!is_array($fields)) { $fields = array($fields); } if (!is_array($values)) { $values = array($values); } $db = DB::Instance(); $qb = new QueryBuilder($db, $this->_templateobject); // Collection may be based on a view so need to get the base table // of the DataObject model associated with this DataObjectCollection $this->_tablename = $this->getModel()->getTableName(); $table_columns = $db->MetaColumnNames($this->_tablename); if (in_array('lastupdated', $table_columns) && !in_array('lastupdated', $fields)) { $fields[] = 'lastupdated'; $values[] = 'now()'; } if (in_array('alteredby', $table_columns) && !in_array('alteredby', $fields)) { $fields[] = 'alteredby'; $values[] = EGS_USERNAME; } if ($sh instanceof SearchHandler) { if ($this->_templateobject->isAccessControlled()) { if (isModuleAdmin()) { $qb->setDistinct(); } else { $sh->addConstraintChain($this->_templateobject->getAccessConstraint('write')); } } $this->sh = $sh; } return $this->_update($fields, $values, $sh, $qb, $c_query); }