CICool Builder – CRUD and more…. My findings so far.

I decided I wanted to speed up my site development time. I was spending way too much time creating my own frameworks and UI’s. So I started looking around for a good looking CRUD framework…

First I looked at XCrud… It looked good in the demo, but the back end code was not what I needed… Down 12 bucks.

Next I looked at Sximo. It was beautiful, had lots of features. I bought it and, ultimately, it disappointed. Not much documentation, very fragile and rigid. Down 16 bucks.

Total: 28 bucks down.

Then I found CICool Builder. Not only did it have a CRUD generator, it has a form generator, page generator, fine grained user permissions, database table generated selects and more. AND it was beautiful.

I bought it and couldn’t be happier. It cost me 24 bucks. To get to a great CRUD system, I spent 52 dollars. I just wish I could have given that 52 to the CICool developers.

Documentation, rock solid code, decent community, tutorial videos, it has it all. It took me about 4 hours to create a full fledged data management site which includes 10 tables, including lookups, as well as an About page, a contact page, etc.

SO…. All this is a preamble to the reason I am posting. One thing that IS lacking is users contributing what they find while working with CICool. I have made a number of customizations to the code and want to put them out there for other users to find and benefit from.

One note: I am finding and fixing issues as I am working on a project. I have pointed out where the solutions are “hacky”. When time permits I will go back and make cleaner solutions

Here we go:

HARD CODED LOCALHOST (v2.3.0 only)

Not sure of the impact, but I saw that localhost was being used to include a script.

I resolved this by making a change in …/application/views/core_template/page/page_html_formatter.php

Line 78 (ish), change from:

<script src="http://localhost:80/ci-lte-generator/asset/js/custom.js"></script>

To

<script src="<?= BASE_ASSET; ?>/asset/js/custom.js"></script>

DEMO MODE TOGGLING (v2.3.0 only)

The 2.3.0 release introduces a Demo mode. I am not sure if this was inadvertently left in by the developer but I created a way to toggle it…

In: …/cc-content/extensions/cicool-demo-clean-data/clean-data.php, starting after

define('DIRNAME', basename(__DIR__));

Add:

if (app()->cc_app->getOption('demomode') == '1')
{

Then close the if statement with a }

Now, demo mode is off unless you add a row in cc_options with the key ‘demomode’ and the value ‘1’

PREVENT CICOOL FROM STORING PLAINTEXT PASSWORDS IN LOGS

(v2.3.0 only)

As of the 2.3.0 release, by default, all logins are logged in cc_log. This includes a JSON section which contains the username and password in plain text. This made me a little nervous so I made this change (granted, it is a hacky change):

[NOTE: This may cause issues when someone is blocked. If so, just remove the line entirely.]

In …/cc-content/extensions/cicool-demo-mode/demo-mode.php

Search for :

    'param_post' => json_encode($_POST),

Change that line to only store the user, not the password:

     'param_post' => $_POST['username'],

ERROR WHEN INSTALLING AUGUST RELEASE

(v2.3.0 only)

When I installed the 2.3.0 release, I was getting a DB error during the wizard. It appeared that it was attempting to set permissions in the DB. These settings, when done this way are NOT saved after a restart of the server so I doubt this will affect day to day CICool usage, only the install.

In …/application/migrations/001_cicool.php

At around line 2000, Change:

 $this->db->query(" 
 set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 ");

To:

 // $this->db->query(" 
 // set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 // ");

 

CHANGE REDIRECT AFTER LOGIN

By default, CICool redirects users to the home page after login. If you want them to be redirected to their dashboard, do the following:

Change line 37 of .../application/controllers/administrator/Auth.php to :

redirect('administrator/dashboard','refresh');

EDIT FRONT PAGES

Front end pages are located in:

.../cc-content/themes/cicool/views

EDIT DASHBOARD

Dashboard page is located at:

.../application/views/backend/standart/dashboard.php

ONLY SHOW USERS THEIR OWN RECORDS

Note: This should work with the v2.3.0 release but I have seen some strange errors after the changes. I would recommend using 2.0 until this all gets worked out.

If you want to limit all custom CRUD’s to only show the currently logged in User’s data, you need to do a few things:

  1. Every custom table needs an “owner” column (varchar)
  2. Every custom table needs to have a prefix that makes custom tables unique, e.g. aap
  3. In these files:
    1. …/application/views/core_template/crud/builder_model.php
    2. …/application/views/core_template/form/form_model.php
    3. …/application/views/core_template/rest/builder_model.php
  4. Update functions count_all and get, replacing the line $this->db->where($where); to:
            if (substr( $this->table_name, 0, 3 ) === "aap")        
            {            
                $this->db->where($where)->where($this->table_name . '.owner', get_user_data('id'));
            }        
            else        
            {            
                $this->db->where($where);
            }


SELECT CONTROLS ONLY SHOW CURR USERS DATA

In …/application/helpers/app_helper.php, you need to replace the function db_get_all_data with the following. NOTE: This follows the same convention of needing all user focused tables to be prefixed. In this example, with ‘aap’ and have a varchar column named owner which is a varchar :

    if(!function_exists('db_get_all_data')) 
    { 
        function db_get_all_data($table_name = null, $where = false) 
        { 
            if (strncmp($table_name, "aap", 3) === 0) 
            {    
                $ci =& get_instance();    
                if ($where) 
                {              
                    $ci->db->where($where)->where($table_name . '.owner', get_user_data('id'));    
                }    
                else    
                {        
                    $ci->db->where($table_name . '.owner', get_user_data('id'));    
                }      
                $query = $ci->db->get($table_name);            
                return $query->result(); 
            } 
            else 
            {    
                $ci =& get_instance();    
                if ($where) 
                {    
                    $ci->db->where($where);    
                }          
                $query = $ci->db->get($table_name);        
                return $query->result();      
            } 
        }
    }

1 thought on “CICool Builder – CRUD and more…. My findings so far.

  1. I have using cicool, when i create a form from cicool form builder, there is have component to upload file, have problem to upload and download. The problem like this:
    ex. from the page (http: //localhost /ciccol3temp/administrator/form_upload) link to download file:
    http://localhost/ciccol3temp/administrator/file/download/form_upload_file/20170814113821-2017-08-14form_upload_berkas113814.xls
    when download and open only show on excel C:\…\ciccol3temp\/uploads/siswa/20170814113821-2017-08-14form_upload_berkas113814.xls

    and then using from the page (http: //localhost/ciccol3temp /administrator/form_upload/view /1) link to download file:
    http://localhost/ciccol3temp/administrator/file/download/form_upload_file/20170814113821-2017-08-14form_upload_berkas113814.xls
    when download and open still show on excel C:\…\ciccol3temp\/uploads/siswa/20170814113821-2017-08-14form_upload_berkas113814.xls

Leave a Reply

Your email address will not be published. Required fields are marked *