/** * getter na vsechny XT roles v systemu, krome roli, ktere jsou vyhrazene jako superrole * @param bool $superAdmin - with superadmin roles * @return XTRolesRecords * @throws Exception */ public static function getXTRoles($superAdmin = false) { try { if ($superAdmin) { $where = NULL; } else { //$where = $superAdmin ? NULL : "name != '". self::XT_ROLE_NAME_SUPERADMIN ."'"; $where = new QueryBuilderWhere(); $where->addConditionColumn("name", self::XT_ROLE_NAME_SUPERADMIN, -3); $where->addConditionColumn($pidColName, "<<NULL>>", 0, 1); } return new XTRolesRecords(false, array("id" => 0), false, $where); } catch (Exception $e) { throw $e; } }
/** * returns prior set where instance * @return QueryBuilderWhere */ protected function getWhere() { try { if ($this->where instanceof QueryBuilderWhere) { return $this->where; } $itemType = $this->getClassVar("itemType"); $where = new QueryBuilderWhere(); $passwordColNames = eval("return {$itemType}::\$passwordColNames;"); @reset($this->filter); $fcur = @current($this->filter); if (!empty($fcur) || (int) $fcur === 0) { if ($this->filter !== false) { foreach ((array) $this->filter as $column => $value) { // password columns if (in_array($column, $passwordColNames)) { $value = md5($value); } $where->addConditionColumn($column, $value); } } } // add whereAdd addition if ($this->whereAdd instanceof QueryBuilderWhere) { $where->addWhere($this->whereAdd); } return $this->where = $where; } catch (Exception $e) { throw $e; } }
/** * return descendants count * @return int * @throws Exception */ public function getDescendantsCount() { try { $tableName = $this->getClassVar("tableName"); $idColName = $this->getClassVar("idColName"); $treeColNames = $this->getClassVar("treeColNames"); $lftColName = $treeColNames[0]; $rgtColName = $treeColNames[1]; $bidColName = $treeColNames[3]; $myLft = $this->params[$lftColName]; $myRgt = $this->params[$rgtColName]; $myBid = $this->params[$bidColName]; $where = new QueryBuilderWhere(); $where->addConditionColumn($lftColName, $myLft, 2); $where->addConditionColumn($rgtColName, $myRgt, -2); $where->addConditionColumn($bidColName, $myBid); $sql = $this->getQueryBuilder()->getSelectCount($tableName, $where); // var_dump(__CLASS__ ."::". __LINE__ .": ". $this->getQueryBuilder()->getSelectCount($tableName, $where)); $result = $this->getDb()->initiateQuery($this->getQueryBuilder()->getSelectCount($tableName, $where)); return (int) $result->count; } catch (Exception $e) { throw $e; } }