Exemplo n.º 1
0
 public static function assign($role_id, $access_type, $access_id)
 {
     $result = false;
     //if (!self::barredRole($role)) {
     if (!is_numeric($role_id)) {
         $role_id = Role::retrieve($role_id);
         $role_id = $role_id['id'];
     }
     $params = array(':role_id' => $role_id, ':access_type' => $access_type, ':access_id' => $access_id);
     $query = new SelectQuery('Assignment');
     $query->filter('`role_id`= :role_id')->filter('`access_type` = :access_type')->filter('`access_id` = :access_id');
     $id = $query->fetchColumn($params);
     if ($id) {
         $result = true;
     } else {
         $keys = array('role_id', 'access_type', 'access_id');
         $data = array_combine($keys, array_values($params));
         $query = new InsertQuery('Assignment');
         $query->data($data);
         $result = $query->execute() ? true : false;
     }
     //}
     return $result;
 }