示例#1
0
 function categories()
 {
     $crud = new grocery_CRUD();
     $crud->set_theme('flexigrid');
     $crud->set_table('categories');
     $crud->unset_texteditor('description');
     # maybe don't unset this one
     $crud->unset_texteditor('status_notes', 'keywords');
     $crud->required_fields('category_id', 'category_name');
     $crud->set_rules('category_id', 'Category Identifier', 'trim|alpha_numeric');
     if (!($this->ion_auth->is_admin() || is_config_true($this->config->item('can_edit_categories')))) {
         $crud->unset_delete();
         $crud->unset_add();
         $crud->unset_edit();
     } else {
         $crud->callback_edit_field('keywords', array($this, '_text_keywords_field'));
     }
     $crud->set_subject('Open311 category');
     $output = $crud->render();
     $this->_admin_output($output);
 }
示例#2
0
    echo 'off';
}
?>
">
        Open311 server is
        <?php 
if (is_config_true(config_item('enable_open311_server'))) {
    echo 'on';
} else {
    echo 'off';
}
?>
      </a>
    </div>
    <?php 
if (is_config_true(config_item('enable_open311_server'))) {
    ?>
      <div class="open311-error-link">
        <a href="<?php 
    echo site_url('admin/errors');
    ?>
">
          Open311 errors
        </a>
      </div>
    <?php 
}
?>
    <?php 
if ($auth->logged_in()) {
    ?>
示例#3
0
    function index()
    {
        $problems = array();
        $details = array();
        $title = 'FMS-endpoint';
        $is_open311_enabled = false;
        $this->load->helper('fms_endpoint');
        if ($this->config->item('base_url') == '') {
            array_push($problems, 'The config setting <b>base_url</b> needs to be set.');
            array_push($details, 'Edit the <span class="code">$config[\'base_url\']</span> setting on line 14 of <span class="code">codeigniter/fms_endpoint/config/config.php</span>.');
        }
        $this->load->database();
        $err_no = $this->db->_error_number();
        if ($err_no != 0) {
            //=====================[ failed to connect to database ]=====================//
            log_message('debug', '$load database yields error no.: ' . $err_no);
            $msg = <<<END_OF_HTML
\tCheck that: 
\t<ol>
\t  <li> you've created the database</li>
\t  <li> your database server is running</li>
\t  <li> you've updated <span class='code'>codeigniter/fms_endpoint/config/database.php</span> with the correct values</li>
\t</ol>
END_OF_HTML;
            array_push($problems, "Can't connect to database: make sure your database configuration is correct");
            array_push($details, $msg);
        } else {
            // not checking category_attributes, because we're not using it yet (?)
            $TABLES_TO_CHECK = array('api_keys', 'categories', 'config_settings', 'groups', 'priorities', 'reports', 'statuses', 'users', 'users_groups');
            $bad_tables = array();
            foreach ($TABLES_TO_CHECK as $tab) {
                $query = $this->db->get($tab);
                $err_no = $this->db->_error_number();
                if ($err_no != 0) {
                    array_push($bad_tables, $tab);
                }
            }
            if (count($bad_tables) > 0) {
                //=====================[ some tables missing ]=====================//
                if (count($bad_tables) == count($TABLES_TO_CHECK)) {
                    array_push($problems, "Can't find <i>any</i> tables in the database: expected <b>" . implode(", ", $bad_tables) . "</b>.");
                } elseif (count($bad_tables) == 1) {
                    array_push($problems, "The <b>" . $bad_tables[0] . "</b> table is missing from the database.");
                } else {
                    array_push($problems, "The following tables are missing from the database: <b>" . implode(", ", $bad_tables) . "</b>");
                }
                array_push($details, "Use the SQL in <span class='code'>db/fms-endpoint-initial.sql</span> to create and populate the tables.");
            } else {
                //=====================[ database sound, so check some key settings ]=====================//
                $config_query = $this->db->get('config_settings');
                $err_no = $this->db->_error_number();
                if ($err_no != 0 || $config_query->num_rows() == 0) {
                    // table should not be empty
                    log_message('warning', 'attempting to read from database table config_settings yields error no.: ' . $err_no);
                    array_push($problems, "The <b>config_settings</b> table is not populated yet.");
                    array_push($details, "Run the SQL in <span class='code'>db/fms-endpoint-initial.sql</span> to create and populate the tables.");
                    if ($err_no == 0) {
                        $query = $this->db->get('reports');
                        if ($query->num_rows() > 1) {
                            // ...but there is data (beyond the expected example) in the reports table, which is unexpected
                            array_push($problems, "<b>Note</b> It looks like you've got data (possibly live reports) in your database, " . "which seems odd when other tables are empty.");
                            array_push($details, "Running the <span class='code'>db/fms-endpoint-initial.sql</span> won't delete any reports data.");
                        }
                    }
                } else {
                    // database seems OK
                    foreach ($config_query->result() as $setting) {
                        $this->config->set_item($setting->name, trim($setting->value));
                    }
                    $query = $this->db->get('users');
                    $err_no = $this->db->_error_number();
                    if ($err_no != 0 || $query->num_rows() == 0) {
                        if ($err_no != 0) {
                            array_push($problems, "Can't find the <b>user</b> table in the database.");
                        } else {
                            array_push($problems, "Found the <b>user</b> table in the database, but it is empty.");
                        }
                        array_push($details, "See the SQL in <span class='code'>db/fms-endpoint-initial.sql</span> to create and populate the user tables." . " You need the user tables to be populated (which will create the default admin user you can use to log in initially).");
                    } else {
                        $query = $this->db->get_where('users', array('email' => '*****@*****.**'));
                        if ($query->num_rows() == 1) {
                            array_push($problems, 'You need to configure your administrator user.');
                            $msg = <<<END_OF_HTML
\tChange the administrator user's details.
\t<ol>
\t\t<li>Connect directly to your database and edit the <span class='code'>USERS</span> table</li>
\t\t<li>Update the data (e.g., name, email address). Don't edit the password field, because it needs to be encrypted.</li>
\t\t<li>Then <a href='auth/login'>login with that email</a>.</li>
\t\t<li>Go to <a href="auth/change_password">the change password page</a>.</li>
\t\t<li>Enter the default password (it's in the README), and then your new one. Submit the form to change the password.</li>
\t</ol>
END_OF_HTML;
                            array_push($details, $msg);
                        }
                    }
                }
                $name = $this->config->item('organisation_name');
                if ($name == 'Example Department' || $name == '') {
                    array_push($problems, 'The configuration setting <b>organisation_name</b> needs to be set.');
                    array_push($details, "Login as the administrator, and change the <b>organisation_name</b> setting in <a href='admin/settings/edit/organisation_name'>config settings</a>.");
                } else {
                    $title = $name;
                }
                $is_open311_enabled = is_config_true($this->config->item('enable_open311_server'));
            }
        }
        if ($this->config->item('redirect_root_page')) {
            $this->load->helper('url');
            redirect($this->config->item('redirect_root_page'));
        } else {
            $data = array('problems' => $problems, 'details' => $details, 'title' => $title, 'is_open311_enabled' => $is_open311_enabled);
            $this->load->view('welcome_message', $data);
        }
    }
示例#4
0
 function _get_source_client_from_api($api_key)
 {
     if (is_config_true(config_item('open311_use_api_keys'))) {
         if (empty($api_key)) {
             show_error_xml("You must provide an API key to submit reports to this server.", OPEN311_SERVICE_BAD_API_KEY);
         } else {
             $api_key_lookup = $this->db->get_where('api_keys', array('api_key' => $api_key));
             if ($api_key_lookup->num_rows() == 0) {
                 show_error_xml("The API key you provided (\"{$api_key}\") is not valid for this server.", OPEN311_SERVICE_BAD_API_KEY);
             } else {
                 return $api_key_lookup->row()->client_id;
             }
         }
     }
 }
示例#5
0
if ($auth->is_admin()) {
    ?>
				<span class="admin-inline-text">
					<a href="settings/edit/open311_use_api_keys">change&nbsp;this</a>
					|
					<a href="api_keys">see&nbsp;keys</a>
				</span>
			<?php 
}
?>
		</li>
		<li>
			<strong>
				Submit requests 
				<?php 
if (is_config_true(config_item('open311_use_external_id'))) {
    ?>
					must provide an external report ID 
				<?php 
} else {
    ?>
					can optionally provide an external report ID
				<?php 
}
?>
				as 
				<span class="code">attrib[<?php 
echo config_item('open311_use_external_name');
?>
]</span>
				
 function open311_enabled_or_error()
 {
     $CI =& get_instance();
     $config_result = $CI->db->get_where('config_settings', array('name' => 'enable_open311_server'), 1);
     if (!is_config_true($config_result->row()->value)) {
         show_error('This Open311 server is currently disabled', 404);
     }
 }
示例#7
0
 function category_attributes()
 {
     $crud = new grocery_CRUD();
     $crud->set_theme('twitter-bootstrap');
     $crud->set_table('category_attributes');
     //$crud->set_model('attributes_join');
     $crud->set_relation('category_id', 'categories', 'category_name', null, 'category_name ASC');
     $crud->display_as('category_id', "Category");
     $crud->unset_texteditor('datatype_description', 'description', 'values');
     $crud->field_type('order', 'integer');
     $crud->field_type('description', 'string');
     $crud->field_type('datatype_description', 'string');
     $crud->field_type('variable', 'dropdown', array('true' => 'True', 'false' => 'False'));
     $crud->field_type('required', 'dropdown', array('true' => 'True', 'false' => 'False'));
     $crud->field_type('datatype', 'dropdown', array('string' => 'Text', 'text' => 'Textbox', 'number' => 'Number', 'datetime' => 'Date Picker', 'singlevaluelist' => 'Dropdown Menu', 'multivaluelist' => 'Multi-select List'));
     $crud->required_fields('category_id', 'attribute_id', 'variable', 'datatype', 'required', 'description', 'order', 'description');
     if (!($this->ion_auth->is_admin() || is_config_true($this->config->item('can_edit_categories')))) {
         $crud->unset_delete();
         $crud->unset_add();
         $crud->unset_edit();
     } else {
         $crud->callback_edit_field('keywords', array($this, '_text_keywords_field'));
     }
     $crud->set_subject('Open311 Service Definition');
     $output = $crud->render();
     $this->_admin_output($output);
 }
//         <status>OPEN</status>
//         <updated_datetime>2010-04-14T10:37:38-01:00</updated_datetime>
//         <description>This problem has been scheduled for inspection</description>
//     </request_update>
// </service_request_updates>
$this->load->helper('xml');
$dom = xml_dom();
$request_updates = xml_add_child($dom, 'service_request_updates');
function dateformat($datetime)
{
    $datetime = $datetime == '0000-00-00 00:00:00' ? '' : date("Y-m-d\\TH:i:s\\Z", strtotime($datetime));
    return $datetime;
}
foreach ($query->result() as $row) {
    $update = xml_add_child($request_updates, 'request_update');
    xml_add_child($update, 'update_id', $row->id);
    xml_add_child($update, 'service_request_id', $row->report_id);
    if (is_config_true($this->config->item('open311_simple_status_only'))) {
        xml_add_child($update, 'status', $row->is_closed ? "CLOSED" : "OPEN");
    } else {
        xml_add_child($update, 'status', strtoupper($row->status_name));
    }
    xml_add_child($update, 'updated_datetime', dateformat($row->updated_at));
    xml_add_child($update, 'description', $row->update_desc);
}
xml_print($dom);
?>