function testQuote() { $insDb = jf::db(); $this->assertEquals("\\'quote-test\\'", $insDb->quote("'quote-test'")); }
function setUp() { $this->resettime(); jf::db()->Initialize(); jf::$Session->Refresh(); }
protected function Unlock() { jf::db()->query("UNLOCK TABLES"); }
/** * Checks whether a user has a permission or not. * * @param string|integer $Permission you can provide a path like /some/permission, a title, or the permission ID. * in case of ID, don't forget to provide integer (not a string containing a number) * @param string|integer $User optional, username or ID of user or null which evaluates current user * @throws RBACPermissionNotFoundException * @throws RBACUserNotFoundException * @return boolean */ function Check($Permission, $UserID = null) { //convert permission and user to ID if (is_int($Permission)) { $PermissionID = $Permission; } else { if (substr($Permission, 0, 1) == "/") { $PermissionID = $this->Permissions->PathID($Permission); } else { $PermissionID = $this->Permissions->TitleID($Permission); } } if ($UserID === null) { $UserID = jf::CurrentUser(); } elseif (!is_int($UserID)) { $UserID = jf::$User->UserID($UserID); } //if invalid, throw exception if ($PermissionID === null) { throw new RBACPermissionNotFoundException("The permission '{$Permission}' not found."); } if ($UserID === null) { throw new RBACUserNotFoundException("The user '{$UserID}' provided to RBAC::Check function not found."); } if ($this->ps_Check === null) { $this->ps_Check = jf::db()->prepare("SELECT COUNT(*) AS Result\n\t\t\tFROM\n\t\t\t\t{$this->TablePrefix()}rbac_userroles AS TUrel\n\n\t\t\t\tJOIN {$this->TablePrefix()}rbac_roles AS TRdirect ON (TRdirect.ID=TUrel.RoleID)\n\t\t\t\tJOIN {$this->TablePrefix()}rbac_roles AS TR ON ( TR.Lft BETWEEN TRdirect.Lft AND TRdirect.Rght)\n\t\t\t\t/* we join direct roles with indirect roles to have all descendants of direct roles */\n\t\t\t\tJOIN\n\t\t\t\t(\t{$this->TablePrefix()}rbac_permissions AS TPdirect\n\t\t\t\tJOIN {$this->TablePrefix()}rbac_permissions AS TP ON ( TPdirect.Lft BETWEEN TP.Lft AND TP.Rght)\n\t\t\t\t/* direct and indirect permissions */\n\t\t\t\tJOIN {$this->TablePrefix()}rbac_rolepermissions AS TRel ON (TP.ID=TRel.PermissionID)\n\t\t\t\t/* joined with role/permissions on roles that are in relation with these permissions*/\n\t\t\t\t) ON ( TR.ID = TRel.RoleID)\n\t\t\t\tWHERE\n\t\t\t\t/* TU.ID=? */\n\t\t\t\tTUrel.UserID=?\n\t\t\t\tAND\n\t\t\t\tTPdirect.ID=?\n\t\t\t"); } $this->ps_Check->execute($UserID, $PermissionID); $Res = $this->ps_Check->fetchAll(); return $Res[0]['Result'] >= 1; }
</tr> <?php } DumpResultRows($result->failures(), "red", "white", "Tests Failed"); DumpResultRows($result->errors(), "#FF7700", "white", "Tests Have Errors"); DumpResultRows($result->notImplemented(), "yellow", "blue", "Tests Not Implemented", true); DumpResultRows($result->skipped(), "gray", "white", "Tests Skipped", true); ?> <tr style='background-color:black;color:white;text-align:right;'> <td colspan='4'> <span style='float:left;'>Time: <?php echo $profiler->Timer(); ?> seconds <span style='color:gray;'>(<?php printf("%.3fs on %d SQL queries", jf::db()->QueryTime(), jf::db()->QueryCount()); ?> )</span></span> Total: <?php echo $result->count(); ?> Tests in <?php echo count(\jf\TestLauncher::$TestFiles); ?> Files </td> </tr> </table>
/** * This function loads a setting * It expects to get at least 2 parameters * @param string $Name * @param integer $UserID * @return mixed loaded item * */ private function _Load($Name, $UserID = 0) { $this->_Sweep(); if (!isset($this->PreparedLoadStatement[$this->dbIndex()]) or $this->PreparedLoadStatement[$this->dbIndex()] === null) { $this->PreparedLoadStatement[$this->dbIndex()] = jf::db()->prepare("SELECT * FROM {$this->TablePrefix()}options WHERE Name=? AND UserID=?"); } $this->PreparedLoadStatement[$this->dbIndex()]->execute($Name, $UserID); $Res = $this->PreparedLoadStatement[$this->dbIndex()]->fetchAll(); if ($Res === null) { return null; } else { return unserialize($Res[0]['Value']); } }
/** * {@inheritdoc} */ public function stopQuery() { \jf::db()->QueryEnd(); }
function testFetch() { $insDb = jf::db(); $r = jf::SQL("SELECT * FROM {$this->TablePrefix()}users;"); $myStatement = $insDb->prepare("SELECT * FROM {$this->TablePrefix()}users;"); $myStatement->execute(); $this->assertEquals($r[0], $myStatement->fetch()); }