コード例 #1
0
 /**
  * returns whether user can filter by Educator in current controller
  * @return boolean
  */
 public static function canFilterByEducator()
 {
     if (Easol_AuthorizationRoles::hasAccess(['System Administrator', 'Data Administrator'])) {
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * @param array | string $allowedRoles
  * $allowedRoles * for grant all access, @ for all logged in users, [] for specific user
  * @return bool|void
  */
 protected function authorize($allowedRoles = [])
 {
     if ($allowedRoles == '@' && !Easol_Authentication::isLoggedIn()) {
         return redirect('home');
     }
     if (Easol_AuthorizationRoles::hasAccess($allowedRoles)) {
         if (!($this->router->fetch_class() == 'schools' && $this->router->fetch_method() == 'choose') && Easol_AuthorizationRoles::hasAccess(['System Administrator', 'Data Administrator']) && Easol_Authentication::userdata('SchoolId') == false) {
             return redirect('schools/choose');
         } else {
             return true;
         }
     }
     return redirect('home/accessdenied');
 }
コード例 #3
0
ファイル: view.php プロジェクト: EASOL/easol-docker
			<?php 
        }
        ?>
		    </select>
		</div>

                <?php 
        continue;
        ?>
        <?php 
    }
    ?>

        
        <?php 
    if ($field['label'] == 'Educator' && !Easol_AuthorizationRoles::hasAccess(['System Administrator', 'Data Administrator'])) {
    } else {
        ?>
        <?php 
        if ($field['type'] == 'dropdown') {
            ?>
          <div class="form-group">
                <label for="filter-<?php 
            echo $key;
            ?>
"><?php 
            echo $field['label'];
            ?>
</label>

                <select class="form-control" name="filter[<?php 
コード例 #4
0
ファイル: main.php プロジェクト: EASOL/easol-docker
        ?>
                            <li><p class="navbar-text"><?php 
        echo Easol_Authentication::userdata('SchoolName');
        ?>
</p></li>
                        <?php 
    }
    ?>

                        <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                                <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                            <?php 
    if (Easol_AuthorizationRoles::hasAccess(['System Administrator', 'Data Administrator'])) {
        ?>
                                <li <?php 
        echo $this->router->class == "admin" ? 'class="active-menu"' : '';
        ?>
>
                                    <a href="<?php 
        echo site_url("/admin");
        ?>
">Administration</a>
                                </li>
                            <?php 
    }
    ?>
                            <?php 
    if ($this->session->userdata('logged_in') == true) {
コード例 #5
0
 public function setDbQuery()
 {
     $filterOrderBy = [];
     $bindValues = [];
     //die(print_r($this->filter['bindIndex']));
     //$queryBuilder
     if ($this->filter != null && isset($this->filter['dataBind']) && $this->filter['dataBind'] == true) {
         $_valI = 0;
         foreach ($this->filter['bindIndex'] as $index => $options) {
             if ($this->filter['fields'][$index]['default'] != '') {
                 if ($_valI == 0 && $this->filter['queryWhere'] == true) {
                     $options['glue'] = ' WHERE ';
                 }
                 $this->query .= ' ' . $options['glue'] . ' ' . $this->filter['fields'][$index]['queryBuilderColumn'] . ' = ?';
                 $bindValues[] = $this->filter['fields'][$index]['default'];
                 $_valI++;
             }
         }
         foreach ($this->filter['fields'] as $key => $field) {
             if (array_key_exists('fieldType', $field)) {
                 if ($field['fieldType'] == 'pageSize') {
                     //$this->pagination['pageSize'] = $field['range']['set'][($this->input->get('filter[' . $key . ']') && $this->input->get('filter[' . $key . ']') < sizeof($field['range']['set']) && $this->input->get('filter[' . $key . ']') >=0 ) ? $this->input->get('filter[' . $key . ']')  :0];
                     if (array_key_exists($field['default'], $field['range']['set'])) {
                         $this->pagination['pageSize'] = $field['range']['set'][$field['default']];
                     }
                 } elseif ($field['fieldType'] == 'dataSort') {
                     if (array_key_exists($this->input->get('filter[' . $key . '][column]'), $field['columns']) && array_key_exists($this->input->get('filter[' . $key . '][type]'), $field['sortTypes'])) {
                         $filterOrderBy[] = $this->input->get('filter[' . $key . '][column]') . ' ' . $this->input->get('filter[' . $key . '][type]');
                     }
                 }
             }
         }
     } elseif ($this->filter != null && array_key_exists('filter', $_GET)) {
         $queryAddition = [];
         foreach ($this->filter['fields'] as $key => $field) {
             if (array_key_exists('access', $field) && !Easol_AuthorizationRoles::hasAccess($field['access'])) {
                 continue;
             }
             if ($field['bindDatabase'] == true && $field['type'] == 'dropdown' && $this->input->get('filter[' . $key . ']') != "") {
                 $queryAddition[] = $field['searchColumn'] . "=" . $this->db->escape($this->input->get('filter[' . $key . ']')) . " ";
             } elseif (array_key_exists('fieldType', $field)) {
                 if ($field['fieldType'] == 'pageSize') {
                     $this->pagination['pageSize'] = $field['range']['set'][$this->input->get('filter[' . $key . ']')];
                 } elseif ($field['fieldType'] == 'dataSort') {
                     if (array_key_exists($this->input->get('filter[' . $key . '][column]'), $field['columns']) && array_key_exists($this->input->get('filter[' . $key . '][type]'), $field['sortTypes'])) {
                         $filterOrderBy[] = $this->input->get('filter[' . $key . '][column]') . ' ' . $this->input->get('filter[' . $key . '][type]');
                     }
                 }
             }
         }
         if (count($queryAddition) > 0) {
             $this->query = "SELECT * FROM (" . $this->query . ") as a WHERE " . implode(' AND ', $queryAddition);
         }
         //$this->query=str_replace('/*@filter*/',$queryAddition,$this->query);
         //die($this->query);
     }
     if ($this->colGroupBy != null && is_array($this->colGroupBy)) {
         $this->query .= ' GROUP BY ' . implode(",", $this->colGroupBy);
     }
     if ($this->pagination != null && $this->input->get("downloadcsv") != 'y') {
         //die(print_r($bindValues));
         $totalCount = $this->db->query("SELECT  count(*) as tot FROM\n              (" . $this->query . ") as b", $bindValues)->row();
         //die(print_r($totalCount));
         $this->pagination['totalElements'] = $totalCount->tot;
     }
     if (count($filterOrderBy) > 0) {
         $this->query .= ' ORDER BY ' . implode(" , ", $filterOrderBy) . ' ';
     } else {
         $this->query .= ' ORDER BY ' . implode(" , ", $this->colOrderBy) . ' ';
     }
     if ($this->pagination != null && $this->input->get("downloadcsv") != 'y') {
         $this->query .= '  OFFSET ? ROWS FETCH NEXT ? ROWS ONLY';
         $bindValues[] = abs($this->pagination['currentPage'] - 1) * $this->pagination['pageSize'];
         $bindValues[] = $this->pagination['pageSize'];
         $this->dbQuery = $this->db->query($this->query, $bindValues);
         //$dbQuery= $this->db->query($this->query,[abs($this->pagination['currentPage']-1)*$this->pagination['pageSize'],$this->pagination['pageSize']]);
     } else {
         $this->dbQuery = $this->db->query($this->query, $bindValues);
     }
 }