Ejemplo n.º 1
0
/**
 * utf8::ucfirst
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _ucfirst($str)
{
    if (utf8::is_ascii($str)) {
        return ucfirst($str);
    }
    preg_match('/^(.?)(.*)$/us', $str, $matches);
    return utf8::strtoupper($matches[1]) . $matches[2];
}
 /**
  * Method that allows sending any kind of HTTP request to remote url
  *
  * @param string $method
  * @param string $url
  * @param array $headers
  * @param array $data
  * @return HTTP_Response
  */
 public static function request($method, $url, $headers = array(), $data = array())
 {
     $valid_methods = array('POST', 'GET', 'PUT', 'DELETE');
     $method = utf8::strtoupper($method);
     if (!valid::url($url, 'http')) {
         return FALSE;
     }
     if (!in_array($method, $valid_methods)) {
         return FALSE;
     }
     // Get the hostname and path
     $url = parse_url($url);
     if (empty($url['path'])) {
         // Request the root document
         $url['path'] = '/';
     }
     // Open a remote connection
     $remote = fsockopen($url['host'], 80, $errno, $errstr, 5);
     if (!is_resource($remote)) {
         return FALSE;
     }
     // Set CRLF
     $CRLF = "\r\n";
     $path = $url['path'];
     if ($method == 'GET' and !empty($url['query'])) {
         $path .= '?' . $url['query'];
     }
     $headers_default = array('Host' => $url['host'], 'Connection' => 'close', 'User-Agent' => 'Ushahidi Scheduler (+http://ushahidi.com/)');
     $body_content = '';
     if ($method != 'GET') {
         $headers_default['Content-Type'] = 'application/x-www-form-urlencoded';
         if (count($data) > 0) {
             $body_content = http_build_query($data);
         }
         $headers_default['Content-Length'] = strlen($body_content);
     }
     $headers = array_merge($headers_default, $headers);
     // Send request
     $request = $method . ' ' . $path . ' HTTP/1.0' . $CRLF;
     foreach ($headers as $key => $value) {
         $request .= $key . ': ' . $value . $CRLF;
     }
     // Send one more CRLF to terminate the headers
     $request .= $CRLF;
     if ($body_content) {
         $request .= $body_content . $CRLF;
     }
     fwrite($remote, $request);
     $response = '';
     while (!feof($remote)) {
         // Get 1K from buffer
         $response .= fread($remote, 1024);
     }
     // Close the connection
     fclose($remote);
     return new HTTP_Response($response, $method);
 }
Ejemplo n.º 3
0
 function __construct($filehandle)
 {
     $this->filehandle = $filehandle;
     // 1000 chars is max line length
     if (($fields = fgetcsv($filehandle, 1000)) !== FALSE) {
         $colnum = 0;
         foreach ($fields as $field) {
             $this->colnames[utf8::strtoupper($field)] = $colnum;
             $colnum++;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Function: index
  *
  * Description: This is the function that renders and stores the settings for the enhanced map
  *
  * Params(POST)
  * - adminmap_height - CSS specification of the height of the map
  * - adminmap_width - CSS specification of the width of the map
  * - enable_bigmap - Is the front end big map enabled?
  * - enable_printmap - Is the print map enabled
  * - enable_iframemap - Is the iframe map enabled
  * - adminmap_height - The height of the admin map
  * - show_unapproved_backend - Should unapproved reports be shown on the back end map
  * - show_unapproved_frontend - Should unapproved reports be shown on the front end map
  * - show_hidden_categories_backend - Should hidden categories be shown on the back end map
  *
  * Views: enhancedmap/enhancedmap_settings
  *
  * Results: Enhanced map settings are updated.
  */
 public function index()
 {
     $this->template->content = new View('enhancedmap/enhancedmap_settings');
     $this->template->content->errors = array();
     $this->template->content->form_saved = false;
     $this->template->content->yesno_array = array('true' => utf8::strtoupper(Kohana::lang('ui_main.yes')), 'false' => utf8::strtoupper(Kohana::lang('ui_main.no')));
     $form = array();
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         //print_r($_POST);
         //echo "<br><br/>";
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('adminmap_height', 'required', 'length[1,99]');
         $post->add_rules('adminmap_width', 'required', 'length[1,99]');
         /*
         $post->add_rules('enable_bigmap','required','in_array["true", "false"]');
         $post->add_rules('enable_printmap','required','in_array[\'true\', \'false\']');
         $post->add_rules('enable_iframemap','required','in_array[\'true\', \'false\']');
         $post->add_rules('adminmap_height','required','in_array[\'true\', \'false\']');
         $post->add_rules('show_unapproved_backend','required','in_array[\'true\', \'false\']');
         $post->add_rules('show_unapproved_frontend','required','in_array[\'true\', \'false\']');
         $post->add_rules('show_hidden_categories_backend','required','in_array[\'true\', \'false\']');
         */
         if ($post->validate()) {
             // Yes! everything is valid
             //load in the settings from the DB
             //load up all the settings
             $settings = ORM::factory('enhancedmap_settings')->find_all();
             foreach ($settings as $setting) {
                 $setting->value = $_POST[$setting->key];
                 $setting->save();
             }
             $form = $_POST;
             $this->template->content->form_saved = true;
         } else {
             // repopulate the form fields
             $form = $_POST;
             // populate the error fields, if any
             $this->template->content->errors = $post->errors('settings');
         }
     } else {
         //load up all the settings
         $settings = ORM::factory('enhancedmap_settings')->find_all();
         foreach ($settings as $setting) {
             $form[$setting->key] = $setting->value;
         }
     }
     $this->template->content->form = $form;
 }
Ejemplo n.º 5
0
 /**
  * Lists the checkins
  */
 function index()
 {
     $this->template->content = new View('admin/checkins/main');
     $this->template->content->title = Kohana::lang('ui_admin.checkins');
     // check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = '';
     $filter = '1=1';
     // Form submission wizardry
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('message_id.*', 'required', 'numeric');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             if ($post->action == 'd') {
                 foreach ($post->checkin_id as $checkin_id) {
                     // Delete Checkin
                     ORM::factory('checkin')->delete($checkin_id);
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             }
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('checkin'));
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => $this->items_per_page, 'total_items' => ORM::factory('checkin')->join('users', 'checkin.user_id', 'users.id', 'INNER')->where($filter)->count_all()));
     $checkins = ORM::factory('checkin')->join('users', 'checkin.user_id', 'users.id', 'INNER')->where($filter)->orderby('checkin_date', 'desc')->find_all($this->items_per_page, $pagination->sql_offset);
     $this->template->content->checkins = $checkins;
     $this->template->content->pagination = $pagination;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $this->template->content->total_items = $pagination->total_items;
     // Javascript Header
     $this->themes->js = new View('admin/checkins/checkins_js');
 }
Ejemplo n.º 6
0
 /**
  * Generates a new Captcha challenge.
  *
  * @return string The challenge answer
  */
 public function generate_challenge()
 {
     // Load words from the current language and randomize them
     $words = Kohana::config('captcha.words');
     shuffle($words);
     // Loop over each word...
     foreach ($words as $word) {
         // ...until we find one of the desired length
         if (abs(Captcha::$config['complexity'] - utf8::strlen($word)) < 2) {
             return utf8::strtoupper($word);
         }
     }
     // Return any random word as final fallback
     return utf8::strtoupper($words[array_rand($words)]);
 }
Ejemplo n.º 7
0
 /**
  * Lists the checkins.
  * @param int $page
  */
 public function index($page = 1)
 {
     $this->template->content = new View('members/checkins');
     $this->template->content->title = Kohana::lang('ui_admin.my_checkins');
     // check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //	 Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('checkin_id.*', 'required', 'numeric');
         if ($post->validate()) {
             if ($post->action == 'd') {
                 foreach ($post->checkin_id as $item) {
                     $update = ORM::factory('checkin')->where('user_id', $this->user->id)->find($item);
                     if ($update->loaded) {
                         $checkin_id = $update->id;
                         $update->delete();
                         // Delete Media
                         ORM::factory('media')->where('checkin_id', $checkin_id)->delete_all();
                     }
                 }
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             }
             $form_saved = TRUE;
         } else {
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page_admin'), 'total_items' => ORM::factory('checkin')->where('user_id', $this->user->id)->count_all()));
     $checkins = ORM::factory('checkin')->where('user_id', $this->user->id)->orderby('checkin_date', 'desc')->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset);
     $this->template->content->checkins = $checkins;
     $this->template->content->pagination = $pagination;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     // Total Reports
     $this->template->content->total_items = $pagination->total_items;
     // Javascript Header
     $this->themes->map_enabled = TRUE;
     $this->themes->js = new View('members/checkins_js');
 }
 /**
  * Lists the reports.
  * @param int $page
  */
 public function index($page = 1)
 {
     $this->template->content = new View('members/reports');
     $this->template->content->title = Kohana::lang('ui_admin.reports');
     if (!empty($_GET['status'])) {
         $status = $_GET['status'];
         if (strtolower($status) == 'a') {
             $filter = 'incident_active = 0';
         } elseif (strtolower($status) == 'v') {
             $filter = 'incident_verified = 0';
         } else {
             $status = "0";
             $filter = '1=1';
         }
     } else {
         $status = "0";
         $filter = "1=1";
     }
     // Get Search Keywords (If Any)
     if (isset($_GET['k'])) {
         // Brute force input sanitization
         // Phase 1 - Strip the search string of all non-word characters
         $keyword_raw = preg_replace('/[^\\w+]\\w*/', '', $_GET['k']);
         // Strip any HTML tags that may have been missed in Phase 1
         $keyword_raw = strip_tags($keyword_raw);
         // Phase 3 - Invoke Kohana's XSS cleaning mechanism just incase an outlier wasn't caught
         // in the first 2 steps
         $keyword_raw = $this->input->xss_clean($keyword_raw);
         $filter .= " AND (" . $this->_get_searchstring($keyword_raw) . ")";
     } else {
         $keyword_raw = "";
     }
     // Check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         // Setup validation
         $post = Validation::factory($_POST);
         //	 Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('incident_id.*', 'required', 'numeric');
         if ($post->validate()) {
             // Delete Action
             if ($post->action == 'd') {
                 foreach ($post->incident_id as $item) {
                     $update = ORM::factory('incident')->where('user_id', $this->user->id)->find($item);
                     if ($update->loaded == true) {
                         $incident_id = $update->id;
                         $location_id = $update->location_id;
                         $update->delete();
                     }
                 }
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             }
             $form_saved = TRUE;
         } else {
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => intval(Kohana::config('settings.items_per_page_admin')), 'total_items' => ORM::factory('incident')->join('location', 'incident.location_id', 'location.id', 'INNER')->where($filter)->where('user_id', $this->user->id)->count_all()));
     $incidents = ORM::factory('incident')->join('location', 'incident.location_id', 'location.id', 'INNER')->where($filter)->where('user_id', $this->user->id)->orderby('incident_dateadd', 'desc')->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset);
     $location_ids = array();
     $country_ids = array();
     foreach ($incidents as $incident) {
         $location_ids[] = $incident->location_id;
     }
     // Check if location_ids is not empty
     if (count($location_ids) > 0) {
         $locations_result = ORM::factory('location')->in('id', implode(',', $location_ids))->find_all();
         $locations = array();
         foreach ($locations_result as $loc) {
             $locations[$loc->id] = $loc->location_name;
             $country_ids[$loc->id]['country_id'] = $loc->country_id;
         }
     } else {
         $locations = array();
     }
     $this->template->content->locations = $locations;
     $this->template->content->country_ids = $country_ids;
     // GET countries
     $countries = array();
     foreach (ORM::factory('country')->orderby('country')->find_all() as $country) {
         // Create a list of all categories
         $this_country = $country->country;
         if (strlen($this_country) > 35) {
             $this_country = substr($this_country, 0, 35) . "...";
         }
         $countries[$country->id] = $this_country;
     }
     $this->template->content->countries = $countries;
     $this->template->content->incidents = $incidents;
     $this->template->content->pagination = $pagination;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     // Total Reports
     $this->template->content->total_items = $pagination->total_items;
     // Status Tab
     $this->template->content->status = $status;
     // Javascript Header
     $this->themes->js = new View('admin/reports/reports_js');
 }
Ejemplo n.º 9
0
    $description = $role->description;
    $access_level = $role->access_level;
    $role_permissions = array();
    foreach ($role->permissions as $perm) {
        $role_permissions[] = $perm->name;
    }
    ?>
									<tr>
										
										<td class="col-1">
											&nbsp;
										</td>
										<td class="col-2">
											<div class="post">
												<h4><?php 
    echo utf8::strtoupper($name);
    ?>
</h4>
												<p><?php 
    echo $description;
    ?>
</p>
											</div>
										</td>
										<td class="col-3">&nbsp;</td>
										<td class="col-4">
											<?php 
    if ($role_id == 1 or $role_id == 3 or $role_id == 4) {
        echo "&nbsp;";
    } else {
        ?>
Ejemplo n.º 10
0
 /**
  * Verifies a previously sent alert confirmation code
  */
 public function verify()
 {
     // Define error codes for this view.
     define("ER_CODE_VERIFIED", 0);
     define("ER_CODE_NOT_FOUND", 1);
     define("ER_CODE_ALREADY_VERIFIED", 3);
     $code = (isset($_GET['c']) and !empty($_GET['c'])) ? $_GET['c'] : "";
     $email = (isset($_GET['e']) and !empty($_GET['e'])) ? $_GET['e'] : "";
     // HT: Mobile verification by url
     $mobile = (isset($_GET['m']) and !empty($_GET['m'])) ? $_GET['m'] : "";
     // INITIALIZE the content's section of the view
     $this->template->content = new View('alerts/verify');
     $this->template->header->this_page = 'alerts';
     $filter = " ";
     $missing_info = FALSE;
     if ($_POST and isset($_POST['alert_code']) and !empty($_POST['alert_code'])) {
         if (isset($_POST['alert_mobile']) and !empty($_POST['alert_mobile'])) {
             $filter = "alert.alert_type=1 AND alert_code='" . Database::instance()->escape_str(utf8::strtoupper($_POST['alert_code'])) . "' AND alert_recipient='" . Database::instance()->escape_str($_POST['alert_mobile']) . "' ";
         } elseif (isset($_POST['alert_email']) and !empty($_POST['alert_email'])) {
             $filter = "alert.alert_type=2 AND alert_code='" . Database::instance()->escape_str($_POST['alert_code']) . "' AND alert_recipient='" . Database::instance()->escape_str($_POST['alert_email']) . "' ";
         } else {
             $missing_info = TRUE;
         }
     } else {
         //if (empty($code) OR empty($email))
         if (empty($code) or empty($email) and empty($mobile)) {
             $missing_info = TRUE;
         } else {
             if (!empty($email)) {
                 // HT: condition to check email alert
                 $filter = "alert.alert_type=2 AND alert_code='" . Database::instance()->escape_str($code) . "' AND alert_recipient='" . Database::instance()->escape_str($email) . "' ";
             } elseif (!empty($mobile)) {
                 // HT: condition to check mobile alert
                 $filter = "alert.alert_type=1 AND alert_code='" . Database::instance()->escape_str(utf8::strtoupper($code)) . "' AND alert_recipient='" . Database::instance()->escape_str($mobile) . "' ";
             }
         }
     }
     if (!$missing_info) {
         $alert_check = ORM::factory('alert')->where($filter)->find();
         // IF there was no result
         if (!$alert_check->loaded) {
             $this->template->content->errno = ER_CODE_NOT_FOUND;
         } elseif ($alert_check->alert_confirmed) {
             $this->template->content->errno = ER_CODE_ALREADY_VERIFIED;
         } else {
             // SET the alert as confirmed, and save it
             $alert_check->set('alert_confirmed', 1)->save();
             $this->template->content->errno = ER_CODE_VERIFIED;
         }
     } else {
         $this->template->content->errno = ER_CODE_NOT_FOUND;
     }
 }
Ejemplo n.º 11
0
    }
    ?>
		</ul>
	</div>
	<?php 
}
?>
	<div class="categories report_category">
	<h2><?php 
echo Kohana::lang('ui_main.categories');
?>
</h2>
		
		<div style="clear: left; width: 100%; float: left;">
			<input type="checkbox" id="category_all" name="category_all" onclick="CheckAll(this.id, 'category')"/><strong><?php 
echo utf8::strtoupper(Kohana::lang('ui_main.select_all'));
?>
</strong>
		</div>
		<?php 
$selected_categories = (!empty($form['incident_category']) and is_array($form['incident_category'])) ? $selected_categories = $form['incident_category'] : array();
if (method_exists('category', 'form_tree')) {
    echo category::form_tree('category', $selected_categories, 2, TRUE);
} elseif (Kohana::config('settings.ushahidi_version') >= 2.4 and Kohana::config('settings.ushahidi_version') <= 2.5) {
    echo category::tree(ORM::factory('category')->find_all(), TRUE, $selected_categories, 'category', 2, TRUE);
} elseif (Kohana::config('settings.ushahidi_version') < 2.4) {
    echo category::tree(ORM::factory('category')->find_all(), $selected_categories, 'category', 2, TRUE);
}
?>
	</div>
	<div>
Ejemplo n.º 12
0
        ?>
            								            <span><?php 
        echo utf8::strtoupper(Kohana::lang('ui_admin.banip_action'));
        ?>
</span>
            								        <?php 
    }
    ?>
            								    </li>
            								    <li>
            								        <a href="#" class="del" onclick="apiLogAction('d','DELETE', '<?php 
    echo $api_log_id;
    ?>
');">
            								            <?php 
    echo utf8::strtoupper(Kohana::lang('ui_admin.delete_action'));
    ?>
            								        </a>
            								    </li>
            								</ul>
            							</td>
            						</tr>
            					<?php 
}
?>
            			</tbody>
            		</table>
            	</div>
            	<?php 
print form::close();
?>
Ejemplo n.º 13
0
"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.approved'));
    ?>
:</a></li>
									<li><a href="#" class="<?php 
    echo $incident_verified;
    ?>
"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.verified'));
    ?>
:</a></li>
									<li class="last"><a href="#" class="<?php 
    echo $submit_mode;
    ?>
"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.source'));
    ?>
:</a></li>
								</ul>
								<h4><strong><?php 
    echo $incident_date;
    ?>
</strong><a href="<?php 
    echo url::site() . 'members/reports/edit/' . $incident_id;
    ?>
"><?php 
    echo $incident_title;
    ?>
</a></h4>
								<p><?php 
    echo $incident_description;
Ejemplo n.º 14
0
 /**
  * Lists the forms.
  */
 public function index()
 {
     $this->template->content = new View('admin/manage/forms/main');
     // Setup and initialize form field names
     $form = array('action' => '', 'form_id' => '', 'form_title' => '', 'form_description' => '', 'form_active' => '', 'field_type' => '');
     // Copy the form as errors, so the errors will be stored with keys
     // corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     $form_id = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         if ($post->action == 'a') {
             // Add some rules, the input field, followed by a list of checks, carried out in order
             $post->add_rules('form_title', 'required', 'length[1,1000]');
             $post->add_rules('form_description', 'required');
         } elseif ($post->action == 'd') {
             if ($_POST['form_id'] == 1) {
                 // Default Form Cannot Be Deleted
                 $post->add_error('form_id', 'default');
             }
         }
         if ($post->validate()) {
             $form_id = $post->form_id;
             $custom_form = new Form_Model($form_id);
             if ($post->action == 'd') {
                 // Delete Action
                 $custom_form->delete($form_id);
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             } elseif ($post->action == 'h') {
                 // Active/Inactive Action
                 if ($custom_form->loaded) {
                     // @todo Doesn't make sense, find out what the logic for this is
                     // Customary values for active and inactive are 1 and 0 respectively
                     $custom_form->form_active = $custom_form->form_active == 1 ? 0 : 1;
                     $custom_form->save();
                     $form_saved = TRUE;
                     $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
                 }
             } else {
                 // Save Action
                 $custom_form->form_title = $post->form_title;
                 $custom_form->form_description = $post->form_description;
                 $custom_form->save();
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.created_edited'));
             }
             // Empty $form array
             array_fill_keys($form, '');
         } else {
             // Repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // Populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('form'));
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => $this->items_per_page, 'total_items' => ORM::factory('form')->count_all()));
     $forms = ORM::factory('form')->orderby('id', 'asc')->find_all($this->items_per_page, $pagination->sql_offset);
     // Form Field Types
     $form_field_types = array('' => Kohana::lang('ui_admin.select_field_type'), 1 => Kohana::lang('ui_admin.text_field'), 2 => Kohana::lang('ui_admin.free_text_field'), 3 => Kohana::lang('ui_admin.date_field'), 5 => Kohana::lang('ui_admin.radio_field'), 6 => Kohana::lang('ui_admin.checkbox_field'), 7 => Kohana::lang('ui_admin.dropdown_field'), 8 => Kohana::lang('ui_admin.divider_start_field'), 9 => Kohana::lang('ui_admin.divider_end_field'));
     $this->template->content->form = $form;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $this->template->content->pagination = $pagination;
     $this->template->content->total_items = $pagination->total_items;
     $this->template->content->forms = $forms;
     $this->template->content->form_field_types = $form_field_types;
     $this->template->content->errors = $errors;
     // Javascript Header
     $this->template->js = new View('admin/manage/forms/forms_js');
     $this->template->js->form_id = $form_id;
     $this->template->form_error = $form_error;
 }
Ejemplo n.º 15
0
<?php 
Event::run('ushahidi_action.admin_checkins_custom_layout');
?>
	
<?php 
// Kill the rest of the page if this event has been utilized by a plugin
if (!Event::has_run('ushahidi_action.admin_checkins_custom_layout')) {
    ?>

	<!-- tabs -->
	<div class="tabs">
		<!-- tab -->
		<div class="tab">
			<ul>
				<li><a href="#" onClick="checkinsAction('d', 'DELETE', '')"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.delete'));
    ?>
</a></li>
			</ul>
		</div>
	</div>
	<?php 
    if ($form_error) {
        ?>
		<!-- red-box -->
		<div class="red-box">
			<h3><?php 
        echo Kohana::lang('ui_main.error');
        ?>
</h3>
			<ul><?php 
Ejemplo n.º 16
0
 public function index()
 {
     $this->template->content = new View('admin/profile');
     // setup and initialize form field names
     $form = array('current_password' => '', 'new_password' => '', 'password_again' => '', 'name' => '', 'email' => '', 'notify' => '');
     //  Copy the form as errors, so the errors will be stored with keys
     //  corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('name', 'required', 'length[3,100]');
         $post->add_rules('email', 'required', 'email', 'length[4,64]');
         $post->add_rules('current_password', 'required');
         $post->add_callbacks('email', array($this, 'email_exists_chk'));
         $post->add_callbacks('current_password', array($this, 'current_pw_valid_chk'));
         // If Password field is not blank
         if (!empty($post->new_password)) {
             $post->add_rules('new_password', 'required', 'length[' . Kohana::config('auth.password_length') . ']', 'matches[password_again]');
         }
         //for plugins that'd like to know what the user has to say about their profile
         Event::run('ushahidi_action.profile_add_admin', $post);
         if ($post->validate()) {
             $user = ORM::factory('user', $this->user_id);
             if ($user->loaded) {
                 $user->name = $post->name;
                 $user->email = $post->email;
                 $user->notify = $post->notify;
                 if ($post->new_password != '') {
                     $user->password = $post->new_password;
                 }
                 $user->save();
                 Event::run('ushahidi_action.profile_edit', $user);
                 // We also need to update the RiverID server with the new password if
                 //    we are using RiverID and a password is being passed
                 if (kohana::config('riverid.enable') == TRUE and !empty($user->riverid) and $post->new_password != '') {
                     $riverid = new RiverID();
                     $riverid->email = $user->email;
                     $riverid->password = $post->current_password;
                     $riverid->new_password = $post->new_password;
                     if ($riverid->changepassword() == FALSE) {
                         // TODO: Something went wrong. Tell the user.
                     }
                 }
             }
             $form_saved = TRUE;
             // Repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             $form['new_password'] = "";
             $form['password_again'] = "";
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('auth'));
             $form_error = TRUE;
         }
     } else {
         $user = ORM::factory('user', $this->user_id);
         $form['username'] = $user->email;
         $form['name'] = $user->name;
         $form['email'] = $user->email;
         $form['notify'] = $user->notify;
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->yesno_array = array('1' => utf8::strtoupper(Kohana::lang('ui_main.yes')), '0' => utf8::strtoupper(Kohana::lang('ui_main.no')));
     // Javascript Header
 }
Ejemplo n.º 17
0
				</div>

				<div class="well">
					<div id="panel" class="olControlEditingToolbar"></div>
					<div class="map-btns">
						<ul class="unstyled">
							<li><a href="#" class="btn btn-info btn-mini"><?php 
echo utf8::strtoupper(Kohana::lang('ui_main.delete_last'));
?>
</a></li>
							<li><a href="#" class="btn btn-info btn-mini"><?php 
echo utf8::strtoupper(Kohana::lang('ui_main.delete_selected'));
?>
</a></li>
							<li><a href="#" class="btn btn-info btn-mini"><?php 
echo utf8::strtoupper(Kohana::lang('ui_main.clear_map'));
?>
</a></li>
						</ul>
					</div>
					
					<div class="report_row">
						<div class="input-append">
							<?php 
print form::input('location_find', '', ' title="' . Kohana::lang('ui_main.location_example') . '" class="findtext span3"');
?>
							<input type="button" name="button" id="button" value="<?php 
echo Kohana::lang('ui_main.find_location');
?>
" class="btn btn-inverse">
						</div>
Ejemplo n.º 18
0
echo Kohana::lang('ui_admin.save_settings');
?>
" />
					</div>
					<!-- column -->
		
					<div class="sms_holder">
						<?php 
if (!$form_error and !empty($form['twitter_api_key']) and !empty($form['twitter_api_key_secret']) and !empty($form['twitter_token']) and !empty($form['twitter_token_secret'])) {
    ?>
							<div class="test_settings">
								<div class="tab">
									<ul>
										<li><a
										href="javascript:twitterTest();"><?php 
    echo utf8::strtoupper(Kohana::lang('settings.test_settings'));
    ?>
</a></li>
										<li id="test_loading"></li>
										<li id="test_status"></li>
									</ul>
								</div>
							</div>
						<?php 
}
?>

						<div class="row">
							<h4><?php 
echo Kohana::lang('settings.twitter.description');
?>
Ejemplo n.º 19
0
 /**
  * Edit a user
  * @param bool|int $user_id The id no. of the user
  * @param bool|string $saved
  */
 public function edit($user_id = FALSE, $saved = FALSE)
 {
     $this->template->content = new View('admin/users/edit');
     if ($user_id) {
         $user_exists = ORM::factory('user')->find($user_id);
         if (!$user_exists->loaded) {
             // Redirect
             url::redirect(url::site() . 'admin/users/');
         }
     }
     // Setup and initialize form field names
     $form = array('username' => '', 'name' => '', 'email' => '', 'password' => '', 'notify' => '', 'role' => '');
     $this->template->content->user_id = $user_id;
     if ($user_id == FALSE) {
         // Tack this on when adding a new user
         $form['password'] = '';
         $form['password_again'] = '';
     }
     // Copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     $user = "";
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Get the submitted data
         $post = $_POST;
         // Add the user_id to the $_POST data
         $user_id = $user_id ? $user_id : NULL;
         $post = array_merge($post, array('user_id' => $user_id));
         if (User_Model::custom_validate($post)) {
             $user = ORM::factory('user', $user_id);
             $user->name = $post->name;
             $user->email = $post->email;
             $user->notify = $post->notify;
             if ($user_id == NULL) {
                 $user->password = $post->password;
             }
             // We can only set a new password if we are using the standard ORM method,
             //    otherwise it won't actually change the password used for authentication
             if (isset($post->new_password) and Kohana::config('riverid.enable') == FALSE and strlen($post->new_password) > 0) {
                 $user->password = $post->new_password;
             }
             // Existing User??
             if ($user->loaded) {
                 // Prevent modification of the main admin account username or role
                 if ($user->id != 1) {
                     $user->username = $post->username;
                     // Remove Old Roles
                     foreach ($user->roles as $role) {
                         $user->remove($role);
                     }
                     // Add New Roles
                     if ($post->role != 'none') {
                         $user->add(ORM::factory('role', 'login'));
                         $user->add(ORM::factory('role', $post->role));
                     }
                 }
             } else {
                 $user->username = $post->username;
                 // Add New Roles
                 if ($post->role != 'none') {
                     $user->add(ORM::factory('role', 'login'));
                     $user->add(ORM::factory('role', $post->role));
                 }
             }
             $user->save();
             //Event for adding user admin details
             Event::run('ushahidi_action.users_add_admin', $post);
             Event::run('ushahidi_action.user_edit', $user);
             // Redirect
             url::redirect(url::site() . 'admin/users/');
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('auth'));
             $form_error = TRUE;
         }
     } else {
         if ($user_id) {
             // Retrieve Current Incident
             $user = ORM::factory('user', $user_id);
             if ($user->loaded) {
                 // Some users don't have roles so we have this "none" role
                 $role = 'none';
                 foreach ($user->roles as $user_role) {
                     $role = $user_role->name;
                 }
                 $form = array('user_id' => $user->id, 'username' => $user->username, 'name' => $user->name, 'email' => $user->email, 'notify' => $user->notify, 'role' => $role);
             }
         }
     }
     $roles = ORM::factory('role')->where('id != 1')->orderby('name', 'asc')->find_all();
     foreach ($roles as $role) {
         $role_array[$role->name] = utf8::strtoupper($role->name);
     }
     // Add one additional role for users with no role
     $role_array['none'] = utf8::strtoupper(Kohana::lang('ui_main.none'));
     $this->template->content->id = $user_id;
     $this->template->content->display_roles = $this->display_roles;
     $this->template->content->user = $user;
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->yesno_array = array('1' => utf8::strtoupper(Kohana::lang('ui_main.yes')), '0' => utf8::strtoupper(Kohana::lang('ui_main.no')));
     $this->template->content->role_array = $role_array;
 }
Ejemplo n.º 20
0
 public function index($service_id = 1)
 {
     $this->template->content = new View('admin/reporters/main');
     $this->template->content->title = Kohana::lang('ui_admin.reporters');
     // setup and initialize form field names
     $form = array('reporter_id' => '', 'level_id' => '', 'service_name' => '', 'service_account' => '', 'location_id' => '', 'location_name' => '', 'latitude' => '', 'longitude' => '');
     //  copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('reporter_id.*', 'required', 'numeric');
         if ($post->action == 'l') {
             $post->add_rules('level_id', 'required', 'numeric');
         } elseif ($post->action == 'a') {
             $post->add_rules('level_id', 'required', 'numeric');
             // If any location data is provided, require all location parameters
             if ($post->latitude or $post->longitude or $post->location_name) {
                 $post->add_rules('latitude', 'required', 'between[-90,90]');
                 // Validate for maximum and minimum latitude values
                 $post->add_rules('longitude', 'required', 'between[-180,180]');
                 // Validate for maximum and minimum longitude values
                 $post->add_rules('location_name', 'required', 'length[3,200]');
             }
         }
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             if ($post->action == 'd') {
                 foreach ($post->reporter_id as $item) {
                     // Delete Reporters Messages
                     ORM::factory('message')->where('reporter_id', $item)->delete_all();
                     // Delete Reporter
                     $reporter = ORM::factory('reporter')->find($item);
                     $reporter->delete($item);
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             } elseif ($post->action == 'l') {
                 foreach ($post->reporter_id as $item) {
                     // Update Reporter Level
                     $reporter = ORM::factory('reporter')->find($item);
                     if ($reporter->loaded) {
                         $reporter->level_id = $post->level_id;
                         $reporter->save();
                     }
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
             } else {
                 if ($post->action == 'a') {
                     foreach ($post->reporter_id as $item) {
                         $reporter = ORM::factory('reporter')->find($item);
                         // SAVE Reporter only if loaded
                         if ($reporter->loaded) {
                             $reporter->level_id = $post->level_id;
                             // SAVE Location if available
                             if ($post->latitude and $post->longitude) {
                                 $location = new Location_Model($post->location_id);
                                 $location->location_name = $post->location_name;
                                 $location->latitude = $post->latitude;
                                 $location->longitude = $post->longitude;
                                 $location->location_date = date("Y-m-d H:i:s", time());
                                 $location->save();
                                 $reporter->location_id = $location->id;
                             }
                             $reporter->save();
                             $form_saved = TRUE;
                             $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
                         }
                     }
                 }
             }
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('reporters'));
             $form_error = TRUE;
         }
     }
     // Start building query
     $filter = '1=1 ';
     // Default search type to service id
     $search_type = isset($_GET['s']) ? intval($_GET['s']) : intval($service_id);
     if ($search_type > 0) {
         $filter .= 'AND service_id = ' . intval($search_type) . ' ';
     }
     // Get Search Keywords (If Any)
     $keyword = '';
     if (isset($_GET['k']) and !empty($_GET['k'])) {
         $keyword = $_GET['k'];
         $filter .= 'AND service_account LIKE \'%' . Database::instance()->escape_str($_GET['k']) . '%\' ';
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => $this->items_per_page, 'total_items' => ORM::factory('reporter')->where($filter)->count_all()));
     $reporters = ORM::factory('reporter')->where($filter)->orderby('service_account', 'asc')->find_all($this->items_per_page, $pagination->sql_offset);
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $this->template->content->pagination = $pagination;
     $this->template->content->total_items = $pagination->total_items;
     $this->template->content->reporters = $reporters;
     $this->template->content->service_id = $service_id;
     $this->template->content->search_type = $search_type;
     $search_type_array = Service_Model::get_array();
     $search_type_array[0] = "All";
     asort($search_type_array);
     $this->template->content->search_type_array = $search_type_array;
     $this->template->content->keyword = $keyword;
     $levels = ORM::factory('level')->orderby('level_weight')->find_all();
     $this->template->content->levels = $levels;
     // Level and Service Arrays
     $this->template->content->level_array = Level_Model::get_array();
     $this->template->content->service_array = Service_Model::get_array();
     // Javascript Header
     $this->themes->map_enabled = TRUE;
     $this->themes->js = new View('admin/reporters/reporters_js');
     $this->themes->js->default_map = Kohana::config('settings.default_map');
     $this->themes->js->default_zoom = Kohana::config('settings.default_zoom');
     $this->themes->js->latitude = Kohana::config('settings.default_lat');
     $this->themes->js->longitude = Kohana::config('settings.default_lon');
     $this->themes->js->form_error = $form_error;
 }
Ejemplo n.º 21
0
 private function _qualification($source_qual = 0, $info_qual = 0)
 {
     $sourcequal_array = array();
     $sourcequal_array[1] = "A";
     $sourcequal_array[2] = "B";
     $sourcequal_array[3] = "C";
     $sourcequal_array[4] = "D";
     $sourcequal_array[5] = "E";
     $sourcequal_array[6] = "F";
     if ($source_qual >= 1 and $source_qual <= 6 and $info_qual >= 1 and $info_qual <= 6) {
         return utf8::strtoupper($sourcequal_array[$source_qual] . $info_qual);
     } else {
         return "--";
     }
 }
 /**
  * Displays a report.
  * @param boolean $id If id is supplied, a report with that id will be
  * retrieved.
  */
 public function view($id = FALSE)
 {
     $this->template->header->this_page = 'reports';
     $this->template->content = new View('reports/detail');
     // Load Akismet API Key (Spam Blocker)
     $api_akismet = Kohana::config('settings.api_akismet');
     // Sanitize the report id before proceeding
     $id = intval($id);
     if ($id > 0) {
         $incident = ORM::factory('sharing_incident')->where('id', $id)->where('incident_active', 1)->find();
         // Not Found
         if (!$incident->loaded) {
             url::redirect('reports/');
         }
         // Comment Post?
         // Setup and initialize form field names
         $form = array('comment_author' => '', 'comment_description' => '', 'comment_email' => '', 'comment_ip' => '', 'captcha' => '');
         $captcha = Captcha::factory();
         $errors = $form;
         $form_error = FALSE;
         // Check, has the form been submitted, if so, setup validation
         if ($_POST and Kohana::config('settings.allow_comments')) {
             // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
             $post = Validation::factory($_POST);
             // Add some filters
             $post->pre_filter('trim', TRUE);
             // Add some rules, the input field, followed by a list of checks, carried out in order
             if (!$this->user) {
                 $post->add_rules('comment_author', 'required', 'length[3,100]');
                 $post->add_rules('comment_email', 'required', 'email', 'length[4,100]');
             }
             $post->add_rules('comment_description', 'required');
             $post->add_rules('captcha', 'required', 'Captcha::valid');
             // Test to see if things passed the rule checks
             if ($post->validate()) {
                 // Yes! everything is valid
                 if ($api_akismet != "") {
                     // Run Akismet Spam Checker
                     $akismet = new Akismet();
                     // Comment data
                     $comment = array('website' => "", 'body' => $post->comment_description, 'user_ip' => $_SERVER['REMOTE_ADDR']);
                     if ($this->user) {
                         $comment['author'] = $this->user->name;
                         $comment['email'] = $this->user->email;
                     } else {
                         $comment['author'] = $post->comment_author;
                         $comment['email'] = $post->comment_email;
                     }
                     $config = array('blog_url' => url::site(), 'api_key' => $api_akismet, 'comment' => $comment);
                     $akismet->init($config);
                     if ($akismet->errors_exist()) {
                         if ($akismet->is_error('AKISMET_INVALID_KEY')) {
                             // throw new Kohana_Exception('akismet.api_key');
                         } elseif ($akismet->is_error('AKISMET_RESPONSE_FAILED')) {
                             // throw new Kohana_Exception('akismet.server_failed');
                         } elseif ($akismet->is_error('AKISMET_SERVER_NOT_FOUND')) {
                             // throw new Kohana_Exception('akismet.server_not_found');
                         }
                         $comment_spam = 0;
                     } else {
                         $comment_spam = $akismet->is_spam() ? 1 : 0;
                     }
                 } else {
                     // No API Key!!
                     $comment_spam = 0;
                 }
                 $comment = new Comment_Model();
                 $comment->incident_id = 0;
                 if ($this->user) {
                     $comment->user_id = $this->user->id;
                     $comment->comment_author = $this->user->name;
                     $comment->comment_email = $this->user->email;
                 } else {
                     $comment->comment_author = strip_tags($post->comment_author);
                     $comment->comment_email = strip_tags($post->comment_email);
                 }
                 $comment->comment_description = strip_tags($post->comment_description);
                 $comment->comment_ip = $_SERVER['REMOTE_ADDR'];
                 $comment->comment_date = date("Y-m-d H:i:s", time());
                 // Activate comment for now
                 if ($comment_spam == 1) {
                     $comment->comment_spam = 1;
                     $comment->comment_active = 0;
                 } else {
                     $comment->comment_spam = 0;
                     $comment->comment_active = Kohana::config('settings.allow_comments') == 1 ? 1 : 0;
                 }
                 $comment->save();
                 // link comment to sharing_incident
                 $incident_comment = ORM::factory('sharing_incident_comment');
                 $incident_comment->comment_id = $comment->id;
                 $incident_comment->sharing_incident_id = $incident->id;
                 $incident_comment->save();
                 // Event::comment_add - Added a New Comment
                 Event::run('ushahidi_action.comment_add', $comment);
                 // Notify Admin Of New Comment
                 $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . utf8::strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/sharing/view/' . $id);
                 // Redirect
                 url::redirect('reports/sharing/view/' . $id);
             } else {
                 // No! We have validation errors, we need to show the form again, with the errors
                 // Repopulate the form fields
                 $form = arr::overwrite($form, $post->as_array());
                 // Populate the error fields, if any
                 $errors = arr::overwrite($errors, $post->errors('comments'));
                 $form_error = TRUE;
             }
         }
         // Filters
         $incident_title = $incident->incident_title;
         $incident_description = $incident->incident_description;
         Event::run('ushahidi_filter.report_title', $incident_title);
         Event::run('ushahidi_filter.report_description', $incident_description);
         $this->template->header->page_title .= $incident_title . Kohana::config('settings.title_delimiter');
         // Add Features
         // hardcode geometries to empty
         $this->template->content->features_count = 0;
         $this->template->content->features = array();
         $this->template->content->incident_id = $incident->id;
         $this->template->content->incident_title = $incident_title;
         $this->template->content->incident_description = $incident_description;
         $this->template->content->incident_location = $incident->location->location_name;
         $this->template->content->incident_latitude = $incident->location->latitude;
         $this->template->content->incident_longitude = $incident->location->longitude;
         $this->template->content->incident_date = date('M j Y', strtotime($incident->incident_date));
         $this->template->content->incident_time = date('H:i', strtotime($incident->incident_date));
         $this->template->content->incident_category = ORM::factory('sharing_incident_category')->where('sharing_incident_id', $incident->id)->find_all();
         // Incident rating
         $rating = ORM::factory('rating')->join('incident', 'incident.id', 'rating.incident_id', 'INNER')->where('rating.incident_id', $incident->id)->find();
         $this->template->content->incident_rating = $rating->rating == '' ? 0 : $rating->rating;
         // Retrieve Media
         $incident_news = array();
         $incident_video = array();
         $incident_photo = array();
         foreach ($incident->media as $media) {
             if ($media->media_type == 4) {
                 $incident_news[] = $media->media_link;
             } elseif ($media->media_type == 2) {
                 $incident_video[] = $media->media_link;
             } elseif ($media->media_type == 1) {
                 $incident_photo[] = array('large' => url::convert_uploaded_to_abs($media->media_link), 'thumb' => url::convert_uploaded_to_abs($media->media_thumb));
             }
         }
         $this->template->content->incident_verified = $incident->incident_verified;
         // Retrieve Comments (Additional Information)
         $this->template->content->comments = "";
         if (Kohana::config('settings.allow_comments')) {
             $this->template->content->comments = new View('reports/comments');
             $incident_comments = array();
             if ($id) {
                 $incident_comments = Sharing_Incident_Model::get_comments($id);
             }
             $this->template->content->comments->incident_comments = $incident_comments;
         }
     } else {
         url::redirect('reports');
     }
     // Add extra info to meta
     Event::add('ushahidi_action.report_display_media', array($this, 'report_display_media'));
     // Add Neighbors
     $this->template->content->incident_neighbors = Sharing_Incident_Model::get_neighbouring_incidents($id, TRUE, 0, 5);
     // News Source links
     $this->template->content->incident_news = $incident_news;
     // Video links
     $this->template->content->incident_videos = $incident_video;
     // Images
     $this->template->content->incident_photos = $incident_photo;
     // Create object of the video embed class
     $video_embed = new VideoEmbed();
     $this->template->content->videos_embed = $video_embed;
     // Javascript Header
     $this->themes->map_enabled = TRUE;
     $this->themes->photoslider_enabled = TRUE;
     $this->themes->videoslider_enabled = TRUE;
     $this->themes->js = new View('reports/view_js');
     $this->themes->js->incident_id = $incident->id;
     $this->themes->js->incident_json_url = 'json/share/single/' . $incident->id;
     $this->themes->js->default_map = Kohana::config('settings.default_map');
     $this->themes->js->default_zoom = Kohana::config('settings.default_zoom');
     $this->themes->js->latitude = $incident->location->latitude;
     $this->themes->js->longitude = $incident->location->longitude;
     $this->themes->js->incident_zoom = null;
     //$incident->incident_zoom;
     $this->themes->js->incident_photos = $incident_photo;
     // Initialize custom field array
     $this->template->content->custom_forms = new View('reports/detail_custom_forms');
     $form_field_names = customforms::get_custom_form_fields($id, 1, FALSE, "view");
     $this->template->content->custom_forms->form_field_names = $form_field_names;
     // Are we allowed to submit comments?
     $this->template->content->comments_form = "";
     if (Kohana::config('settings.allow_comments')) {
         $this->template->content->comments_form = new View('reports/comments_form');
         $this->template->content->comments_form->user = $this->user;
         $this->template->content->comments_form->form = $form;
         $this->template->content->comments_form->form_field_names = $form_field_names;
         $this->template->content->comments_form->captcha = $captcha;
         $this->template->content->comments_form->errors = $errors;
         $this->template->content->comments_form->form_error = $form_error;
     }
     // If the Admin is Logged in - Allow for an edit link
     $this->template->content->logged_in = $this->logged_in;
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
     $this->template->footer->footer_block = $this->themes->footer_block();
 }
Ejemplo n.º 23
0
 function index()
 {
     $this->template->content = new View('admin/manage/scheduler/main');
     // Check if we should be running the scheduler and then do it
     if (isset($_GET['run_scheduler'])) {
         // Get all active scheduled items
         foreach (ORM::factory('scheduler')->where('scheduler_active', '1')->find_all() as $scheduler) {
             $s_controller = $scheduler->scheduler_controller;
             try {
                 $dispatch = Dispatch::controller($s_controller, "scheduler/");
                 if ($dispatch instanceof Dispatch) {
                     $run = $dispatch->method('index', '');
                 }
             } catch (Exception $e) {
                 $run = FALSE;
             }
             if ($run !== FALSE) {
                 // Set last time of last execution
                 $schedule_time = time();
                 $scheduler->scheduler_last = $schedule_time;
                 $scheduler->save();
                 // Record Action to Log
                 $scheduler_log = new Scheduler_Log_Model();
                 $scheduler_log->scheduler_id = $scheduler->id;
                 $scheduler_log->scheduler_status = "200";
                 $scheduler_log->scheduler_date = $schedule_time;
                 $scheduler_log->save();
             }
         }
     }
     // setup and initialize form field names
     $form = array('action' => '', 'schedule_id' => '', 'scheduler_weekday' => '', 'scheduler_day' => '', 'scheduler_hour' => '', 'scheduler_minute' => '', 'scheduler_active' => '');
     //  copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         //print_r($_POST);
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         if ($post->action == 'a') {
             // Add some rules, the input field, followed by a list of checks, carried out in order
             $post->add_rules('scheduler_weekday', 'required', 'between[1,7]');
             $post->add_rules('scheduler_day', 'required', 'between[-1,31]');
             $post->add_rules('scheduler_hour', 'required', 'between[-1,23]');
             $post->add_rules('scheduler_minute', 'required', 'between[-1,59]');
         }
         if ($post->validate()) {
             $scheduler_id = $post->scheduler_id;
             $scheduler = new Scheduler_Model($scheduler_id);
             if ($post->action == 'v') {
                 // Active/Inactive Action
                 if ($scheduler->loaded == TRUE) {
                     $scheduler->scheduler_active = $scheduler->scheduler_active == 1 ? 0 : 1;
                     $scheduler->save();
                     $form_saved = TRUE;
                     $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
                 }
             } else {
                 // SAVE Schedule
                 $scheduler->scheduler_weekday = $post->scheduler_weekday;
                 $scheduler->scheduler_day = $post->scheduler_day;
                 $scheduler->scheduler_hour = $post->scheduler_hour;
                 $scheduler->scheduler_minute = $post->scheduler_minute;
                 $scheduler->save();
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.edited'));
             }
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('scheduler'));
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => $this->items_per_page, 'total_items' => ORM::factory('scheduler')->count_all()));
     $schedules = ORM::factory('scheduler')->orderby('scheduler_name', 'asc')->find_all($this->items_per_page, $pagination->sql_offset);
     $this->template->content->weekday_array = array("-1" => "ALL", "0" => "Sunday", "1" => "Monday", "2" => "Tuesday", "3" => "Wednesday", "4" => "Thursday", "5" => "Friday", "6" => "Saturday");
     for ($i = 0; $i <= 31; $i++) {
         $day_array = $i;
     }
     $this->template->content->day_array = $day_array;
     $day_array = array();
     $day_array[-1] = "ALL";
     for ($i = 1; $i <= 31; $i++) {
         $day_array[] = $i;
     }
     $this->template->content->day_array = $day_array;
     $hour_array = array();
     $hour_array[-1] = "ALL";
     for ($i = 0; $i <= 23; $i++) {
         $hour_array[] = $i;
     }
     $this->template->content->hour_array = $hour_array;
     $minute_array = array();
     $minute_array[-1] = "ALL";
     for ($i = 0; $i <= 59; $i++) {
         $minute_array[] = $i;
     }
     $this->template->content->minute_array = $minute_array;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $this->template->content->pagination = $pagination;
     $this->template->content->total_items = $pagination->total_items;
     $this->template->content->schedules = $schedules;
     $this->template->content->errors = $errors;
     // Javascript Header
     $this->themes->js = new View('admin/manage/scheduler/scheduler_js');
 }
Ejemplo n.º 24
0
 /**
  * Lists the messages.
  * @param int $service_id
  */
 public function index($service_id = 1)
 {
     // If a table prefix is specified
     $db_config = Kohana::config('database.default');
     $table_prefix = $db_config['table_prefix'];
     $this->template->content = new View('admin/messages/main');
     // Get Title
     $service = ORM::factory('service', $service_id);
     $this->template->content->title = $service->service_name;
     // Display Reply to Option?
     $this->template->content->reply_to = TRUE;
     if (!Kohana::config("settings.sms_provider")) {
         // Hide Reply to option
         $this->template->content->reply_to = FALSE;
     }
     // Is this an Inbox or Outbox Filter?
     if (!empty($_GET['type'])) {
         $type = $_GET['type'];
         if ($type == '2') {
             // OUTBOX
             $filter = 'message.message_type = 2';
         } else {
             // INBOX
             $type = "1";
             $filter = 'message.message_type = 1';
         }
     } else {
         $type = "1";
         $filter = 'message.message_type = 1';
     }
     // Do we have a reporter ID?
     if (isset($_GET['rid']) and !empty($_GET['rid'])) {
         $filter .= ' AND message.reporter_id=\'' . intval($_GET['rid']) . '\'';
     }
     // ALL / Trusted / Spam
     $level = '0';
     if (isset($_GET['level']) and !empty($_GET['level'])) {
         $level = $_GET['level'];
         if ($level == 4) {
             $filter .= " AND ( " . $table_prefix . "reporter.level_id = '4' OR " . $table_prefix . "reporter.level_id = '5' ) " . "AND ( " . $table_prefix . "message.message_level != '99' ) ";
         } elseif ($level == 2) {
             $filter .= " AND ( " . $table_prefix . "message.message_level = '99' ) ";
         }
     }
     // Check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     // Check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('message_id.*', 'required', 'numeric');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             if ($post->action == 'd') {
                 foreach ($post->message_id as $item) {
                     // Delete Message
                     $message = ORM::factory('message')->find($item);
                     $message->message_type = 3;
                     // Tag As Deleted/Trash
                     $message->save();
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             } elseif ($post->action == 'n') {
                 // Not Spam
                 foreach ($post->message_id as $item) {
                     // Update Message Level
                     $message = ORM::factory('message')->find($item);
                     if ($message->loaded) {
                         $message->message_level = '1';
                         $message->save();
                     }
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
             } elseif ($post->action == 's') {
                 // Spam
                 foreach ($post->message_id as $item) {
                     // Update Message Level
                     $message = ORM::factory('message')->find($item);
                     if ($message->loaded) {
                         $message->message_level = '99';
                         $message->save();
                     }
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
             }
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('message'));
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => $this->items_per_page, 'total_items' => ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where($filter)->where('service_id', $service_id)->count_all()));
     $messages = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service_id)->where($filter)->orderby('message_date', 'desc')->find_all($this->items_per_page, $pagination->sql_offset);
     // Get Message Count
     // ALL
     $this->template->content->count_all = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service_id)->where('message_type', 1)->count_all();
     // Trusted
     $this->template->content->count_trusted = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service_id)->where('message_type', 1)->where("message.message_level != '99' AND ( " . $table_prefix . "reporter.level_id = '4' OR " . $table_prefix . "reporter.level_id = '5' )")->count_all();
     // Spam
     $this->template->content->count_spam = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service_id)->where('message_type', 1)->where("message.message_level = '99'")->count_all();
     //Reporters
     $this->template->content->count_reporters = ORM::factory('reporter')->where('service_id', $service_id)->count_all();
     $this->template->content->messages = $messages;
     $this->template->content->service_id = $service_id;
     $this->template->content->services = ORM::factory('service')->find_all();
     $this->template->content->pagination = $pagination;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $levels = ORM::factory('level')->orderby('level_weight')->find_all();
     $this->template->content->levels = $levels;
     // Total Reports
     $this->template->content->total_items = $pagination->total_items;
     // Message Type Tab - Inbox/Outbox
     $this->template->content->type = $type;
     $this->template->content->level = $level;
     // Javascript Header
     $this->template->js = new View('admin/messages/messages_js');
 }
Ejemplo n.º 25
0
					<td><?php 
print form::checkbox('data_include[]', '6', in_array(6, $form['data_include']));
echo Kohana::lang('ui_main.include_custom_fields');
?>
</td>
					<td><?php 
print form::checkbox('data_include[]', '5', in_array(5, $form['data_include']));
echo Kohana::lang('ui_main.include_longitude');
?>
</td>
				</tr>
				<tr>
					<td><?php 
print form::checkbox('data_include[]', '7', in_array(7, $form['data_include']));
echo Kohana::lang('ui_main.include_personal_info');
?>
</td>
					<td></td>
				</tr>
			</table>
			<input id="save_only" type="submit" value="<?php 
echo utf8::strtoupper(Kohana::lang('ui_main.download'));
?>
" class="save-rep-btn" />
			<?php 
print form::close();
?>
		</div>
	</div>
</div>
Ejemplo n.º 26
0
?>
</a></li>
									<li><a href="#" class="btn_save_add_new"><?php 
echo utf8::strtoupper(Kohana::lang('ui_main.save_add_new'));
?>
</a></li>
								<?php 
if ($id) {
    echo "<li><a href=\"#\" class=\"btn_delete btns_red\">" . utf8::strtoupper(Kohana::lang('ui_main.delete_report')) . "</a></li>";
}
?>
								<li><a href="<?php 
echo url::site() . 'admin/reports/';
?>
" class="btns_red"><?php 
echo utf8::strtoupper(Kohana::lang('ui_main.cancel'));
?>
</a></li>
							</ul>
						</div>						
					</div>
				<?php 
print form::close();
?>
				<?php 
if ($id) {
    // Hidden Form to Perform the Delete function
    print form::open(url::site() . 'admin/reports/', array('id' => 'reportMain', 'name' => 'reportMain'));
    $array = array('action' => 'd', 'incident_id[]' => $id);
    print form::hidden($array);
    print form::close();
Ejemplo n.º 27
0
 /**
  * Lists the private messages.
  * @param int $page
  */
 public function index($page = 1)
 {
     $this->template->content = new View('members/private');
     $this->template->content->title = Kohana::lang('ui_admin.private_messages');
     // Is this an Inbox or Outbox Filter?
     if (!empty($_GET['type'])) {
         $type = $_GET['type'];
         if ($type == '2') {
             // OUTBOX
             $filter = 'from_user_id';
         } else {
             // INBOX
             $type = "1";
             $filter = 'user_id';
         }
     } else {
         $type = "1";
         $filter = 'user_id';
     }
     // check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         //	Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('message_id.*', 'required', 'numeric');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             if ($post->action == 'd') {
                 foreach ($post->message_id as $item) {
                     // Delete Message
                     $message = ORM::factory('private_message')->where("user_id", $this->user->id)->find($item);
                     $message->delete();
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             } elseif ($post->action == 'r') {
                 foreach ($post->message_id as $item) {
                     // Update Message Level
                     $message = ORM::factory('private_message')->where("user_id", $this->user->id)->find($item);
                     if ($message->loaded) {
                         $message->private_message_new = '0';
                         $message->save();
                     }
                 }
                 $form_saved = TRUE;
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.modified'));
             }
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('private_message'));
             $form_error = TRUE;
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page_admin'), 'total_items' => ORM::factory('private_message')->where($filter, $this->user->id)->count_all()));
     $messages = ORM::factory('private_message')->where($filter, $this->user->id)->orderby('private_message_date', 'desc')->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset);
     $this->template->content->messages = $messages;
     $this->template->content->pagination = $pagination;
     $this->template->content->type = $type;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $this->template->content->user_id = $this->user->id;
     // Total Messages
     $this->template->content->total_items = $pagination->total_items;
     // Javascript Header
     $this->themes->js = new View('members/private_js');
 }
Ejemplo n.º 28
0
    ?>
</strong>
											<br/><a href="<?php 
    echo $app->url;
    ?>
"><?php 
    echo $app->url;
    ?>
</a>

										</td>
										<td class="col-4" style="width:120px;">

											<ul>
												<li><a href="javascript:appAction('d','<?php 
    echo utf8::strtoupper(html::escape(Kohana::lang('ui_main.remove') . ' ' . $app->name));
    ?>
','<?php 
    echo rawurlencode($app->id);
    ?>
')" class="del"><?php 
    echo Kohana::lang('ui_main.remove');
    ?>
</a></li>
											</ul>

										</td>
									</tr>
							<?php 
}
?>
Ejemplo n.º 29
0
									<?php 
    }
    ?>
							</tbody>
						</table>
					</div>
				<?php 
    print form::close();
    ?>
				<div class="tabs">
					<div class="tab">
						<ul>
							<li><a href="#" onClick="messagesAction('d', 'DELETE', '')"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.delete'));
    ?>
</a></li>
							<li><a href="#" onClick="messagesAction('s', 'SPAM', '')"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.spam'));
    ?>
</a></li>
							<li><a href="#" onClick="messagesAction('n', 'NOT SPAM', '')"><?php 
    echo utf8::strtoupper(Kohana::lang('ui_main.not_spam'));
    ?>
</a></li>
						</ul>
					</div>
				</div>
			</div>

<?php 
}
Ejemplo n.º 30
0
 /**
  * Lists the reports.
  *
  * @param int $page
  */
 public function index($page = 1)
 {
     // If user doesn't have access, redirect to dashboard
     if (!$this->auth->has_permission("reports_view")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     $this->template->content = new View('admin/reports/main');
     $this->template->content->title = Kohana::lang('ui_admin.reports');
     // Database table prefix
     $table_prefix = Kohana::config('database.default.table_prefix');
     // Hook into the event for the reports::fetch_incidents() method
     Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_incident_filters'));
     $status = "0";
     if (!empty($_GET['status'])) {
         $status = $_GET['status'];
         if (strtolower($status) == 'a') {
             array_push($this->params, 'i.incident_active = 0');
         } elseif (strtolower($status) == 'v') {
             array_push($this->params, 'i.incident_verified = 0');
         } elseif (strtolower($status) == 'o') {
             array_push($this->params, '(ic.category_id IS NULL)');
         } elseif (strtolower($status) != 'search') {
             $status = "0";
         }
     }
     // Get Search Keywords (If Any)
     if (isset($_GET['k'])) {
         //	Brute force input sanitization
         // Phase 1 - Strip the search string of all non-word characters
         $keyword_raw = isset($_GET['k']) ? preg_replace('#/\\w+/#', '', $_GET['k']) : "";
         // Strip any HTML tags that may have been missed in Phase 1
         $keyword_raw = strip_tags($keyword_raw);
         // Phase 3 - Invoke Kohana's XSS cleaning mechanism just incase an outlier wasn't caught
         // in the first 2 steps
         $keyword_raw = $this->input->xss_clean($keyword_raw);
         $filter = " (" . $this->_get_searchstring($keyword_raw) . ")";
         array_push($this->params, $filter);
     } else {
         $keyword_raw = "";
     }
     $this->template->content->search_form = $this->_search_form();
     $this->template->content->search_form->keywords = $keyword_raw;
     // Handler sort/order fields
     $order_field = 'date';
     $sort = 'DESC';
     if (isset($_GET['order'])) {
         $order_field = html::escape($_GET['order']);
     }
     if (isset($_GET['sort'])) {
         $sort = strtoupper($_GET['sort']) == 'ASC' ? 'ASC' : 'DESC';
     }
     // Check, has the form been submitted?
     $form_error = FALSE;
     $errors = array();
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //	Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks,
         // carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('incident_id.*', 'required', 'numeric');
         if (in_array($post->action, array('a', 'u')) and !Auth::instance()->has_permission('reports_approve')) {
             $post->add_error('action', 'permission');
         }
         if ($post->action == 'v' and !Auth::instance()->has_permission('reports_verify')) {
             $post->add_error('action', 'permission');
         }
         if ($post->action == 'd' and !Auth::instance()->has_permission('reports_edit')) {
             $post->add_error('action', 'permission');
         }
         if ($post->action == 'a') {
             // sanitize the incident_ids
             $post->incident_id = array_map('intval', $post->incident_id);
             // Query to check if this report is uncategorized i.e categoryless
             $query = "SELECT i.* FROM " . $table_prefix . "incident i " . "LEFT JOIN " . $table_prefix . "incident_category ic ON i.id=ic.incident_id " . "LEFT JOIN " . $table_prefix . "category c ON c.id = ic.category_id " . "WHERE c.id IS NULL " . "AND i.id IN :incidentids";
             $result = Database::instance()->query($query, array(':incidentids' => $post->incident_id));
             // We enly approve the report IF it's categorized
             // throw an error if any incidents aren't categorized
             foreach ($result as $incident) {
                 $post->add_error('incident_id', 'categories_required', $incident->incident_title);
             }
         }
         if ($post->validate()) {
             // Approve Action
             if ($post->action == 'a') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     if ($update->loaded == TRUE) {
                         $update->incident_active = '1';
                         // Tag this as a report that needs to be sent out as an alert
                         if ($update->incident_alert_status != '2') {
                             // 2 = report that has had an alert sent
                             $update->incident_alert_status = '1';
                         }
                         $update->save();
                         // Record 'Verified By' Action
                         reports::verify_approve($update);
                         // Action::report_approve - Approve a Report
                         Event::run('ushahidi_action.report_approve', $update);
                     }
                     $form_action = utf8::strtoupper(Kohana::lang('ui_admin.approved'));
                 }
             } elseif ($post->action == 'u') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     if ($update->loaded == TRUE) {
                         $update->incident_active = '0';
                         // If Alert hasn't been sent yet, disable it
                         if ($update->incident_alert_status == '1') {
                             $update->incident_alert_status = '0';
                         }
                         $update->save();
                         // Record 'Verified By' Action
                         reports::verify_approve($update);
                         // Action::report_unapprove - Unapprove a Report
                         Event::run('ushahidi_action.report_unapprove', $update);
                     }
                 }
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.unapproved'));
             } elseif ($post->action == 'v') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     $verify = new Verify_Model();
                     if ($update->loaded == TRUE) {
                         if ($update->incident_verified == '1') {
                             $update->incident_verified = '0';
                             $verify->verified_status = '0';
                         } else {
                             $update->incident_verified = '1';
                             $verify->verified_status = '2';
                         }
                         $update->save();
                         // Record 'Verified By' Action
                         reports::verify_approve($update);
                     }
                 }
                 // Set the form action
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.verified_unverified'));
             } elseif ($post->action == 'd') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     if ($update->loaded) {
                         $update->delete();
                     }
                 }
                 $form_action = utf8::strtoupper(Kohana::lang('ui_admin.deleted'));
             }
             $form_saved = TRUE;
         } else {
             // Repopulate the form fields
             //$form = arr::overwrite($form, $post->as_array());
             // Populate the error fields, if any
             $errors = $post->errors('reports');
             $form_error = TRUE;
         }
     }
     // Fetch all incidents
     $incidents = reports::fetch_incidents(TRUE, Kohana::config('settings.items_per_page_admin'));
     Event::run('ushahidi_filter.filter_incidents', $incidents);
     $this->template->content->countries = Country_Model::get_countries_list();
     $this->template->content->incidents = $incidents;
     $this->template->content->pagination = reports::$pagination;
     $this->template->content->form_error = $form_error;
     $this->template->content->errors = $errors;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     // Total Reports
     $this->template->content->total_items = reports::$pagination->total_items;
     // Status Tab
     $this->template->content->status = $status;
     $this->template->content->order_field = $order_field;
     $this->template->content->sort = $sort;
     $this->themes->map_enabled = TRUE;
     $this->themes->json2_enabled = TRUE;
     $this->themes->treeview_enabled = TRUE;
     // Javascript Header
     $this->themes->js = new View('admin/reports/reports_js');
 }