]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17806 fixed sql_bit_and use which returns number and that is why it is not suitab...
authorskodak <skodak>
Wed, 7 Jan 2009 18:55:32 +0000 (18:55 +0000)
committerskodak <skodak>
Wed, 7 Jan 2009 18:55:32 +0000 (18:55 +0000)
Fixed DML docs too.

admin/report/security/lib.php
lib/dml/moodle_database.php

index 7cb17c060fc4fcd0cd2c78d7f51dda822bbf4383..7232e5f3232efeaac327b628a298bd928038dfc3 100644 (file)
@@ -481,7 +481,7 @@ function report_security_check_riskxss($detailed=false) {
                 JOIN {context} sc ON (sc.path = c.path OR sc.path LIKE ".$DB->sql_concat('c.path', "'/%'").")
                 JOIN {role_assignments} ra ON (ra.contextid = sc.id AND ra.roleid = rc.roleid)
                 JOIN {user} u ON u.id = ra.userid
-               WHERE ".$DB->sql_bitand('cap.riskbitmask', RISK_XSS)."
+               WHERE ".$DB->sql_bitand('cap.riskbitmask', RISK_XSS)." <> 0
                      AND rc.permission = :capallow
                      AND u.deleted = 0";
 
@@ -540,7 +540,7 @@ function report_security_check_defaultuserrole($detailed=false) {
     $sql = "SELECT COUNT(DISTINCT rc.contextid)
               FROM {role_capabilities} rc
               JOIN {capabilities} cap ON cap.name = rc.capability
-             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))."
+             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))." <> 0
                    AND rc.permission = :capallow
                    AND rc.roleid = :roleid";
 
@@ -619,7 +619,7 @@ function report_security_check_guestrole($detailed=false) {
     $sql = "SELECT COUNT(DISTINCT rc.contextid)
               FROM {role_capabilities} rc
               JOIN {capabilities} cap ON cap.name = rc.capability
-             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))."
+             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))." <> 0
                    AND rc.permission = :capallow
                    AND rc.roleid = :roleid";
 
@@ -695,7 +695,7 @@ function report_security_check_frontpagerole($detailed=false) {
     $sql = "SELECT COUNT(DISTINCT rc.contextid)
               FROM {role_capabilities} rc
               JOIN {capabilities} cap ON cap.name = rc.capability
-             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))."
+             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))." <> 0
                    AND rc.permission = :capallow
                    AND rc.roleid = :roleid";
 
@@ -784,7 +784,7 @@ function report_security_check_defaultcourserole($detailed=false) {
     $sql = "SELECT DISTINCT rc.contextid
               FROM {role_capabilities} rc
               JOIN {capabilities} cap ON cap.name = rc.capability
-             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))."
+             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))." <> 0
                    AND rc.permission = :capallow
                    AND rc.roleid = :roleid";
 
@@ -901,7 +901,7 @@ function report_security_check_courserole($detailed=false) {
     $sql = "SELECT rc.roleid, rc.contextid
               FROM {role_capabilities} rc
               JOIN {capabilities} cap ON cap.name = rc.capability
-             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))."
+             WHERE ".$DB->sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))." <> 0
                    AND rc.permission = :capallow
                    AND rc.roleid $inroles
           GROUP BY rc.roleid, rc.contextid
index 658de1c41250621085766a40c84862bc6adf5245..5e72d65d34bf93d515049689d26f84a07e9ada53 100644 (file)
@@ -1400,9 +1400,13 @@ abstract class moodle_database {
     /**
      * Returns the SQL text to be used in order to perform one bitwise AND operation
      * between 2 integers.
+     *
+     * NOTE: The SQL result is a number and can not be used directly in
+     *       SQL condition, please compare it to some number to get a bool!!
+     *
      * @param integer int1 first integer in the operation
      * @param integer int2 second integer in the operation
-     * @return string the piece of SQL code to be used in your statement.
+     * @return string the piece of SQL code to be used in your statement
      */
     public function sql_bitand($int1, $int2) {
         return '((' . $int1 . ') & (' . $int2 . '))';
@@ -1423,6 +1427,9 @@ abstract class moodle_database {
      * Returns the SQL text to be used in order to perform one bitwise OR operation
      * between 2 integers.
      *
+     * NOTE: The SQL result is a number and can not be used directly in
+     *       SQL condition, please compare it to some number to get a bool!!
+     *
      * @param integer int1 first integer in the operation
      * @param integer int2 second integer in the operation
      * @return string the piece of SQL code to be used in your statement.
@@ -1435,6 +1442,9 @@ abstract class moodle_database {
      * Returns the SQL text to be used in order to perform one bitwise XOR operation
      * between 2 integers.
      *
+     * NOTE: The SQL result is a number and can not be used directly in
+     *       SQL condition, please compare it to some number to get a bool!!
+     *
      * @param integer int1 first integer in the operation
      * @param integer int2 second integer in the operation
      * @return string the piece of SQL code to be used in your statement.