示例#1
0
文件: mpm.php 项目: verbazend/AWFA
  public function visibility_clause($key, $field, $string = false, $keyword = " WHERE ", $return = "string") {
    
    $clause = "";
    $not = false;
    $all = true;
    $values = "";
    $csv = "";
    
    $vis = $this->visibility;
    
    if (isset($vis)) {
      
      if (isset($vis[$key])) {

        $vt = $vis[$key];

        if ($vt == "") {
          $clause = $keyword." 0 = 1 "; // don't want any values
        }
      
        if ($vt != "*") { // if it is a wildcard we don't want a WHERE clause, just return all of them
          
          $values = $vt;
          
          if ($string) {
            $csv = MPM::csv_sql($vt);
          } else {
            $csv = $vt;
          }
          
          $all = false;
          
          $clause = $keyword." `".$field."` IN ( ".$csv." ) ";
        }
      } else {
      
        if (isset($vis["not_".$key])) {
          
          $vtn = $vis["not_".$key];
        
          if ($vtn != "") { // we don't need a where clause if the denial is blank

            $values = $vtn;

            if ($string) {
              $csv = MPM::csv_sql($vtn);
            } else {
              $csv = $vtn;
            }
        
            $all = false;
        
            $not = true;
        
            $clause = $keyword." `".$field."` NOT IN ( ".$csv." ) ";
          }
        }
      }
  
    }
    
    if ($return == "string") {
      return $clause;
    } else {
      return array(
        "clause" => $clause,
        "not" => $not,
        "all" => $all,
        "values" => $values,
        "csv" => $csv
      );
    }
  
  }