Beispiel #1
0
 /**
  * Handles twitter Settings
  */
 function index()
 {
     $this->template->content = new View('admin/settings/twitter/main');
     $this->template->content->title = Kohana::lang('ui_admin.settings');
     // setup and initialize form field names
     $form = array('twitter_api_key' => '', 'twitter_api_key_secret' => '', 'twitter_token' => '', 'twitter_token_secret' => '', 'twitter_hashtags' => '');
     //	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) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $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('twitter_api_key', 'required', 'length[1,150]');
         $post->add_rules('twitter_api_key_secret', 'required', 'length[1,150]');
         $post->add_rules('twitter_token', 'required', 'length[1,150]');
         $post->add_rules('twitter_token_secret', 'required', 'length[1,150]');
         $post->add_rules('twitter_hashtags', 'length[1,150]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             Settings_Model::save_setting('twitter_api_key', $post->twitter_api_key);
             Settings_Model::save_setting('twitter_api_key_secret', $post->twitter_api_key_secret);
             Settings_Model::save_setting('twitter_token', $post->twitter_token);
             Settings_Model::save_setting('twitter_token_secret', $post->twitter_token_secret);
             Settings_Model::save_setting('twitter_hashtags', $post->twitter_hashtags);
             // Delete Settings Cache
             $this->cache->delete('settings');
             $this->cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         $form = array('twitter_api_key' => Settings_Model::get_setting('twitter_api_key'), 'twitter_api_key_secret' => Settings_Model::get_setting('twitter_api_key_secret'), 'twitter_token' => Settings_Model::get_setting('twitter_token'), 'twitter_token_secret' => Settings_Model::get_setting('twitter_token_secret'), 'twitter_hashtags' => Settings_Model::get_setting('twitter_hashtags'));
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     // Javascript Header
     $this->themes->js = new View('admin/settings/twitter/twitter_js');
 }
Beispiel #2
0
 /**
  * Render all the active blocks
  *
  * @return string block html
  */
 public static function render()
 {
     // Get Active Blocks
     $active_blocks = Settings_Model::get_setting('blocks');
     $active_blocks = array_filter(explode("|", $active_blocks));
     foreach ($active_blocks as $block) {
         $block = new $block();
         $block->block();
     }
 }
Beispiel #3
0
 function index()
 {
     $this->template->content = new View('admin/addons/themes');
     $this->template->content->title = 'Addons';
     // setup and initialize form field names
     $form = array('site_style' => '');
     //  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) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $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('site_style', 'length[1,50]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             Settings_Model::save_setting('site_style', $post->site_style);
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         $site_style = Settings_Model::get_setting('site_style');
         // Retrieve Current Settings
         $form = array('site_style' => !empty($site_style) ? $site_style : 'default');
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $themes = addon::get_addons('theme');
     foreach ($themes as $key => $theme) {
         // We want to hide checkin themes if checkins is not enabled
         if (!Kohana::config('settings.checkins') and $theme['Checkins'] == 1) {
             unset($themes[$key]);
         }
     }
     $this->template->content->themes = $themes;
 }
Beispiel #4
0
 /**
  * Upgrade page.
  *
  */
 public function index()
 {
     $this->template->content = new View('admin/upgrade/upgrade');
     $form_action = "";
     $this->template->content->title = Kohana::lang('ui_admin.upgrade_ushahidi');
     //$this->template->content->db_version =  Kohana::config('
     //	  settings.db_version');
     $this->template->content->db_version = Kohana::config('settings.db_version');
     //Setup and initialize form fields names
     $form = array('chk_db_backup_box' => '');
     //check if form has been submitted
     if ($_POST) {
         // For sanity sake, validate the data received from users.
         $post = Validation::factory(array_merge($_POST, $_FILES));
         // Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('chk_db_backup_box', 'between[0,1]');
         if ($post->validate()) {
             $this->upgrade->logger("STARTED UPGRADE\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
             $this->template->content = new View('admin/upgrade/upgrade_status');
             $this->themes->js = new View('admin/upgrade/upgrade_status_js');
             $this->themes->js->backup = $post->chk_db_backup_box;
             $this->template->content->title = Kohana::lang('ui_admin.upgrade_ushahidi_status');
             $this->session->set('ftp_server', $post->ftp_server);
             $this->session->set('ftp_user_name', $post->ftp_user_name);
             $this->session->set('ftp_user_pass', $post->ftp_user_pass);
             Settings_Model::save_setting('ftp_server', $post->ftp_server);
             Settings_Model::save_setting('ftp_user_name', $post->ftp_user_name);
             // Log file location
             $this->themes->js->log_file = url::site() . "admin/upgrade/logfile?f=" . $this->session->get('upgrade_session') . ".txt";
         } else {
             $this->themes->js = new View('admin/upgrade/upgrade_js');
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = $post->errors('upgrade');
             $form_error = TRUE;
         }
     } else {
         $this->themes->js = new View('admin/upgrade/upgrade_js');
     }
     $this->template->content->ftp_server = Settings_Model::get_setting('ftp_server');
     $this->template->content->ftp_user_name = Settings_Model::get_setting('ftp_user_name');
     $this->template->content->form_action = $form_action;
     $this->template->content->current_version = Kohana::config('settings.ushahidi_version');
     $this->template->content->current_db_version = Kohana::config('settings.db_version');
     $this->template->content->environment = $this->_environment();
     $this->template->content->release_version = is_object($this->release) == true ? $this->release->version : "";
     $this->template->content->release_db_version = is_object($this->release) == true ? $this->release->version_db : "";
     $this->template->content->changelogs = is_object($this->release) == true ? $this->release->changelog : array();
     $this->template->content->download = is_object($this->release) == true ? $this->release->download : "";
     $this->template->content->critical = is_object($this->release) == true ? $this->release->critical : "";
 }
    /**
     * Creates the required database tables for the sharing module
     */
    public function run_install()
    {
        // Create the database tables
        // Include the table_prefix
        $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_site`\n\t\t\t(\n\t\t\t\t`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`site_name` varchar(150) NOT NULL COMMENT 'name that appears on the front end',\n\t\t\t\t`site_url` varchar(255) NOT NULL COMMENT 'url of the deployment to share with',\n\t\t\t\t`site_color` varchar(20) DEFAULT 'CC0000' COMMENT 'color that shows the shared reports',\n\t\t\t\t`site_active` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'sharing active or inactive ',\n\t\t\t\t`share_categories` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'sharing active or inactive ',\n\t\t\t\t`share_reports` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'sharing active or inactive ',\n\t\t\t\t`site_username` varchar(150) NOT NULL COMMENT 'username for the remote site',\n\t\t\t\t`site_password` varchar(150) NOT NULL COMMENT 'password for the remote site',\n\t\t\t\tPRIMARY KEY (id)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Stores sites we are getting shared reports from'\n\t\t\t");
        $result = $this->db->query("SHOW COLUMNS FROM `sharing_site` LIKE 'site_username';");
        if ($result->count() == 0) {
            $this->db->query('
					ALTER TABLE `sharing_site`
						ADD COLUMN `site_username` varchar(150) NOT NULL COMMENT \'username for the remote site\',
						ADD COLUMN `site_password` varchar(150) NOT NULL COMMENT \'password for the remote site\'
				');
        }
        $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident`\n\t\t\t(\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`location_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t`sharing_site_id` INT UNSIGNED NOT NULL,\n\t\t\t\t`remote_incident_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`updated` datetime DEFAULT NULL,\n\t\t\t\t`incident_title` varchar(255) NOT NULL COMMENT 'title of the report',\n\t\t\t\t`incident_description` longtext,\n\t\t\t\t`incident_date` datetime DEFAULT NULL,\n\t\t\t\t`incident_mode` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1 - WEB, 2 - SMS, 3 - EMAIL, 4 - TWITTER',\n\t\t\t\t`incident_active` tinyint(4) NOT NULL DEFAULT '0',\n\t\t\t\t`incident_verified` tinyint(4) NOT NULL DEFAULT '0',\n\t\t\t\tPRIMARY KEY (id),\n\t\t\t\tKEY `location_id` (`location_id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Stores shared reports'\n\t\t\t");
        $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident_category` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `sharing_incident_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `category_id` int(11) unsigned NOT NULL DEFAULT '5',\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  UNIQUE KEY `sharing_incident_category_ids` (`sharing_incident_id`,`category_id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Stores shared reports categories'\n\t\t\t");
        $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident_media` (\n\t\t\t  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `sharing_incident_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `media_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  UNIQUE KEY `sharing_incident_media_ids` (`sharing_incident_id`,`media_id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Stores shared reports media'\n\t\t\t");
        $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_incident_comment` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `sharing_incident_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `comment_id` int(11) unsigned NOT NULL DEFAULT '5',\n\t\t\t  PRIMARY KEY (`id`),\n\t\t\t  UNIQUE KEY `sharing_incident_comment_ids` (`sharing_incident_id`,`comment_id`)\n\t\t\t) ENGINE=MyISAM AUTO_INCREMENT=14064 DEFAULT CHARSET=utf8 COMMENT='Stores shared reports comments'\n\t\t\t");
        $this->db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `" . Kohana::config('database.default.table_prefix') . "sharing_category`\n\t\t\t(\n\t\t\t\t`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`sharing_site_id` INT UNSIGNED NOT NULL,\n\t\t\t\t`category_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`remote_category_id` BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\t`updated` datetime DEFAULT NULL,\n\t\t\t\tPRIMARY KEY (id),\n\t\t\t  UNIQUE KEY `category_id` (`category_id`),\n\t\t\t  UNIQUE KEY `remote_category_id` (`sharing_site_id`,`remote_category_id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Stores shared categories'\n\t\t\t");
        // Create view for querying
        $this->db->query("\n\t\t\tCREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY INVOKER VIEW `sharing_combined_incident` AS\n\t\t\t\tSELECT `incident`.`id` AS `id`,\n\t\t\t\t\t`incident`.`incident_title` AS `incident_title`,\n\t\t\t\t\t`incident`.`incident_description` AS `incident_description`,\n\t\t\t\t\t`incident`.`incident_date` AS `incident_date`,\n\t\t\t\t\t`incident`.`incident_mode` AS `incident_mode`,\n\t\t\t\t\t`incident`.`location_id` AS `location_id`,\n\t\t\t\t\t`incident`.`incident_active` AS `incident_active`,\n\t\t\t\t\t`incident`.`incident_verified` AS `incident_verified`,\n\t\t\t\t\t'main' AS `source`,\n\t\t\t\t\tNULL AS `source_url`\n\t\t\t\tFROM `incident`\n\t\t\t\tUNION\n\t\t\t\tSELECT\n\t\t\t\t\t`sharing_incident`.`id` AS `id`,\n\t\t\t\t\t`sharing_incident`.`incident_title` AS `incident_title`,\n\t\t\t\t\t`sharing_incident`.`incident_description` AS `incident_description`,\n\t\t\t\t\t`sharing_incident`.`incident_date` AS `incident_date`,\n\t\t\t\t\t`sharing_incident`.`incident_mode` AS `incident_mode`,\n\t\t\t\t\t`sharing_incident`.`location_id` AS `location_id`,\n\t\t\t\t\t`sharing_incident`.`incident_active` AS `incident_active`,\n\t\t\t\t\t`sharing_incident`.`incident_verified` AS `incident_verified`,\n\t\t\t\t\t`sharing_incident`.`sharing_site_id` AS `source`,\n\t\t\t\t\t`sharing_site`.`site_url` AS `source_url`\n\t\t\t\tFROM `sharing_incident`\n\t\t\t\tLEFT JOIN `sharing_site`\n\t\t\t\t\tON (`sharing_incident`.`sharing_site_id` = `sharing_site`.`id`)\n\t\t\t");
        $this->db->query("\n\t\t\tCREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY INVOKER VIEW `sharing_combined_incident_category` AS\n\t\t\t\tSELECT `incident_category`.`incident_id` AS `incident_id`,\n\t\t\t\t\tNULL AS `sharing_incident_id`,\n\t\t\t\t\t`incident_category`.`category_id` AS `category_id`\n\t\t\t\tFROM `incident_category`\n\t\t\t\tUNION\n\t\t\t\tSELECT\n\t\t\t\t\tNULL AS `incident_id`,\n\t\t\t\t\t`sharing_incident_category`.`sharing_incident_id` AS `sharing_incident_id`,\n                  `sharing_incident_category`.`category_id` AS `category_id`\n\t\t\t\tFROM `sharing_incident_category`\n\t\t\t");
        //Dump the sharing scheduler item from bundled SQL dump file
        $this->db->query("DELETE FROM `" . Kohana::config('database.default.table_prefix') . "scheduler` where scheduler_name = 'Sharing' ");
        // Add sharing in to scheduler table
        $this->db->query("INSERT IGNORE INTO `" . Kohana::config('database.default.table_prefix') . "scheduler`\n\t\t\t\t(`scheduler_name`,`scheduler_last`,`scheduler_weekday`,`scheduler_day`,`scheduler_hour`,`scheduler_minute`,`scheduler_controller`,`scheduler_active`) VALUES\n\t\t\t\t('Sharing','0','-1','-1','-1','-1','s_sharing','1')");
        // Add Other category to the categories list (if it doesn't exist already)
        $categoryname = "Other";
        $other_category = ORM::factory('category')->where('category_title', $categoryname)->where('parent_id', 0)->find();
        $current_other_category_id = Settings_Model::get_setting('sharing_other_category_id');
        if ($other_category->loaded && empty($current_other_category_id)) {
            // We already have a category "Other", save setting
            Settings_Model::save_setting('sharing_other_category_id', $other_category->id);
        } else {
            // No category named "Other". Do we have an id save though (maybe it's been renamed)
            $category = ORM::factory('Category', Settings_Model::get_setting('sharing_other_category_id'));
            if (!$category->loaded) {
                $this->notices[] = Kohana::lang('import.new_category') . $categoryname;
                $category = new Category_Model();
                $category->category_title = $categoryname;
                // We'll use grey for now. Maybe something random?
                $category->category_color = '000000';
                $category->category_visible = 1;
                // FIXIT: We need to make this zero for non-central deployments?
                $category->category_trusted = 1;
                // Trusted - can't delete
                $category->category_description = "Category with reports that couldn't be categorised from other deployments";
                //FIXIT: need to l10n this;
                $category->category_position = ORM::factory('category')->count_all();
                $category->save();
                Settings_Model::save_setting('sharing_other_category_id', $category->id);
            }
        }
    }
Beispiel #6
0
 function index()
 {
     $this->template->content = new View('admin/addons/themes');
     $this->template->content->title = 'Addons';
     // setup and initialize form field names
     $form = array('site_style' => '');
     //  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) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $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('site_style', 'length[1,50]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             Settings_Model::save_setting('site_style', $post->site_style);
             //add details to application/config/email.php
             //$this->_add_email_settings($settings);
             // Delete Settings Cache
             $cache = Cache::instance();
             $cache->delete('settings');
             $cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         // Retrieve Current Settings
         $form = array('site_style' => Settings_Model::get_setting('site_style'));
     }
     $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->themes = $this->_get_themes();
 }
Beispiel #7
0
 public function index()
 {
     $this->template->content = new View('admin/stats/hits');
     $this->template->content->title = Kohana::lang('ui_admin.statistics');
     // Retrieve Current Settings
     $stat_id = Settings_Model::get_setting('stat_id');
     if ($stat_id === NULL or $stat_id == 0) {
         $sitename = Settings_Model::get_setting('site_name');
         $url = url::base();
         $this->template->content->stat_id = Stats_Model::create_site($sitename, $url);
     }
     // Show the hits page since stats are already set up
     $this->hits();
 }
Beispiel #8
0
 public function index()
 {
     $this->template = "";
     $this->auto_render = FALSE;
     // grab the necessary keys consumer key, secret, token, token secret
     $consumer_key = Settings_Model::get_setting('twitter_api_key');
     $consumer_secret = Settings_Model::get_setting('twitter_api_key_secret');
     $oauth_token = Settings_Model::get_setting('twitter_token');
     $oauth_token_secret = Settings_Model::get_setting('twitter_token_secret');
     $_SESSION['access_token'] = array('oauth_token' => $oauth_token, 'oauth_token_secret' => $oauth_token_secret);
     $access_token = $_SESSION['access_token'];
     $connection = new Twitter_Oauth($consumer_key, $consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
     $connection->decode_json = FALSE;
     $connection->get('account/verify_credentials');
     if ($connection->http_code == 200) {
         echo json_encode(array("status" => "success", "message" => Kohana::lang('ui_main.success')));
     } else {
         echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_main.error') . " - " . Kohana::lang('ui_admin.error_twitter')));
     }
 }
Beispiel #9
0
 public function index()
 {
     // Grabbing tweets requires cURL so we will check for that here.
     if (!function_exists('curl_exec')) {
         throw new Kohana_Exception('twitter.cURL_not_installed');
         return false;
     }
     // Retrieve Last Stored Twitter ID
     $last_tweet_id = "";
     $tweets = ORM::factory('message')->with('reporter')->where('service_id', '3')->orderby('service_messageid', 'desc')->find();
     if ($tweets->loaded == true) {
         $last_tweet_id = "&since_id=" . $tweets->service_messageid;
     }
     // Perform Hashtag Search
     $twitter_hashtags = Settings_Model::get_setting('twitter_hashtags');
     $hashtags = explode(',', $twitter_hashtags);
     foreach ($hashtags as $hashtag) {
         if (!empty($hashtag)) {
             $page = 1;
             $have_results = TRUE;
             //just starting us off as true, although there may be no results
             while ($have_results == TRUE and $page <= 2) {
                 //This loop is for pagination of rss results
                 $hashtag = rawurlencode(trim(str_replace('#', '', $hashtag)));
                 $twitter_url = 'http://search.twitter.com/search.json?q=%23' . $hashtag . '&rpp=100&page=' . $page;
                 //.$last_tweet_id;
                 $curl_handle = curl_init();
                 curl_setopt($curl_handle, CURLOPT_URL, $twitter_url);
                 curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 4);
                 //Since Twitter is down a lot, set timeout to 4 secs
                 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
                 //Set curl to store data in variable instead of print
                 $buffer = curl_exec($curl_handle);
                 curl_close($curl_handle);
                 $have_results = $this->add_hash_tweets($buffer);
                 //if FALSE, we will drop out of the loop
                 $page++;
             }
         }
     }
 }
Beispiel #10
0
 public function index()
 {
     // Grab all the twitter credentials - tokens and keys
     $consumer_key = Settings_Model::get_setting('twitter_api_key');
     $consumer_secret = Settings_Model::get_setting('twitter_api_key_secret');
     $oauth_token = Settings_Model::get_setting('twitter_token');
     $oauth_token_secret = Settings_Model::get_setting('twitter_token_secret');
     $_SESSION['access_token'] = array('oauth_token' => $oauth_token, 'oauth_token_secret' => $oauth_token_secret);
     /* Get user access tokens out of the session. */
     $access_token = $_SESSION['access_token'];
     /* Create a TwitterOauth object with consumer/user tokens. */
     $connection = new Twitter_Oauth($consumer_key, $consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
     $connection->decode_json = FALSE;
     // Retrieve Last Stored Twitter ID
     $last_tweet_id = "";
     $tweets = ORM::factory('message')->with('reporter')->where('service_id', '3')->orderby('service_messageid', 'desc')->find();
     if ($tweets->loaded == true) {
         $last_tweet_id = "&since_id=" . $tweets->service_messageid;
     }
     // Perform Hashtag Search
     $twitter_hashtags = Settings_Model::get_setting('twitter_hashtags');
     $hashtags = explode(',', $twitter_hashtags);
     foreach ($hashtags as $hashtag) {
         if (!empty($hashtag)) {
             $page = 1;
             $have_results = TRUE;
             //just starting us off as true, although there may be no results
             while ($have_results == TRUE and $page <= 2) {
                 //This loop is for pagination of twitter results
                 $hashtag = rawurlencode(trim($hashtag));
                 $twitter_url = $connection->get('search/tweets', array('count' => 100, 'q' => $hashtag));
                 $have_results = $this->add_hash_tweets($twitter_url);
                 $page++;
             }
         }
     }
 }
Beispiel #11
0
 /**
  * Geonames Feeds GeoCoding (RSS to GEORSS)
  * Due to limitations, this returns only 20 items
  *
  * @param   string location / address
  * @return  string raw georss data
  */
 function geocode_feed($feed_url = NULL)
 {
     $base_url = "http://" . GEOCODER_GEONAMES . "/rssToGeoRSS?";
     // Only requests service if we have an user
     $geocode_username = Settings_Model::get_setting('feed_geolocation_user');
     if ($feed_url && !empty($geocode_username)) {
         // First check to make sure geonames webservice is running
         $geonames_status = @remote::status($base_url);
         if ($geonames_status == "200") {
             // Successful
             $request_url = $base_url . "&feedUrl=" . urlencode($feed_url) . "&username=" . $geocode_username;
         } else {
             // Down perhaps?? Use direct feed
             $request_url = $feed_url;
         }
         $request = new HttpClient($request_url);
         if (!($georss = $request->execute($request_url))) {
             // If the request failed, something may be wrong with the GEOCODER_GEONAMES service
             return false;
         }
         //$georss = utf8_encode($georss);
         // Lez verify this we got a good reply from the geocoder before proceeding
         $data = new SimplePie();
         $data->set_raw_data($georss);
         $data->init();
         $data->handle_content_type();
         // Feed no good - get outta here!
         if ($data->error()) {
             Kohana::log('error', $data->error() . $request_url);
             return false;
         }
         return trim($georss);
     } else {
         return false;
     }
 }
Beispiel #12
0
 /**
  * Manage Public Listing for External Applications
  */
 public function publiclisting()
 {
     $this->template->content = new View('admin/manage/publiclisting');
     $this->template->content->encoded_stat_id = base64_encode(Settings_Model::get_setting('stat_id'));
     $this->template->content->encoded_stat_key = base64_encode(Settings_Model::get_setting('stat_key'));
 }
Beispiel #13
0
 static function get_hit_countries($range = 30, $dp1 = NULL, $dp2 = NULL)
 {
     $stat_id = Settings_Model::get_setting('stat_id');
     $stat_key = Settings_Model::get_setting('stat_key');
     $twodates = '';
     if ($dp1 !== NULL and $dp2 !== NULL) {
         $twodates = '&twodates=' . urlencode($dp1 . ',' . $dp2);
     }
     $stat_url = Kohana::config('config.external_site_protocol') . '://tracker.ushahidi.com/px.php?stat_key=' . $stat_key . '&task=stats&siteid=' . urlencode($stat_id) . '&period=day&range=' . urlencode($range) . $twodates;
     // Ignore errors since we are error checking later
     $response = @simplexml_load_string(self::_curl_req($stat_url));
     // If we encounter an error, return false
     if (isset($response->result->error[0]) or isset($response->error[0]) or !isset($response->countries->result)) {
         Kohana::log('error', "Error on stats request");
         return false;
     }
     $data = array();
     foreach ($response->countries->result as $res) {
         $date = (string) $res['date'];
         foreach ($res->row as $row) {
             $code = (string) $row->code;
             $data[$date][$code]['label'] = (string) $row->label;
             $data[$date][$code]['uniques'] = (string) $row->nb_uniq_visitors;
             $logo = (string) $row->logo;
             $data[$date][$code]['logo'] = Kohana::config('core.site_protocol') . '://tracker.ushahidi.com/piwik/' . $logo;
         }
     }
     return $data;
 }
Beispiel #14
0
 public function sort()
 {
     $this->auto_render = FALSE;
     $this->template = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         $post->add_rules('blocks', 'required');
         if ($post->validate()) {
             $active_blocks = Settings_Model::get_setting('blocks');
             $active_blocks = array_filter(explode("|", $active_blocks));
             $blocks = array_map('trim', explode(',', $_POST['blocks']));
             $block_check = array();
             foreach ($blocks as $block) {
                 if (in_array($block, $active_blocks)) {
                     $block_check[] = $block;
                 }
             }
             Settings_Model::save_setting('blocks', implode("|", $block_check));
             echo 'success';
             return;
         }
     }
     echo 'failure';
     return;
 }
 /**
  * Use remote Ushahidi deployments API to get Incident Data
  * Limit to 20 not to kill remote server
  */
 private function _process_site_reports($site)
 {
     $limit = 20;
     $since_id = 0;
     $count = 0;
     $modified_ids = array();
     // this is an array of our primary keys
     $more_reports_to_pull = TRUE;
     // @todo grab new reports first
     while ($more_reports_to_pull == TRUE) {
         $UshApiLib_Site_Info = new UshApiLib_Site_Info(sharing_helper::clean_url($site->site_url) . "/api", $site->site_username, $site->site_password);
         $params = new UshApiLib_Incidents_Task_Parameter();
         $params->setBy(UshApiLib_Incidents_Bys::INCIDENTS_SINCE_ID);
         $params->setLimit($limit);
         $params->setId($since_id);
         $params->setOrderField(UshApiLib_Task_Base::INCIDENT_ID_INDEX);
         $params->setSort(0);
         if (isset($_GET['debug']) and $_GET['debug'] == 1) {
             echo "<strong>Query String:</strong> " . Kohana::debug($params->get_query_string()) . "<br/><br/>";
         }
         $task = new UshApiLib_Incidents_Task($params, $UshApiLib_Site_Info);
         $response = $task->execute();
         if ($response->getError_code()) {
             if (isset($_GET['debug']) and $_GET['debug'] == 1) {
                 $json = json_decode($task->getJson(), TRUE);
                 // Check for error code 007 - no results
                 if ($json['error']['code'] == '007') {
                     echo "No results.<BR /><BR />";
                 } else {
                     echo "Error Code: " . $response->getError_code() . " Message: " . $response->getError_message() . "<BR /><BR />";
                     var_dump($task->getJson());
                 }
             }
             return;
         }
         // Grab existing items
         $existing_items = ORM::factory('sharing_incident')->where('sharing_site_id', $site->id)->find_all();
         // Build array of existing items, key'd by remote id
         $array = array();
         foreach ($existing_items as $item) {
             $array[$item->remote_incident_id] = $item;
         }
         $existing_items = $array;
         $self_url_parsed = parse_url(URL::site());
         // Parse Incidents Into Database
         $count = 0;
         foreach ($response->getIncidents() as $remote_incident_id => $incident_json) {
             if (isset($_GET['debug']) and $_GET['debug'] == 1) {
                 echo "Importing report {$remote_incident_id} : " . $incident_json["incident"]->incident_title . "<br/>";
             }
             $orm_incident = $incident_json['incident'];
             $json_incident = $incident_json['original']['incident'];
             // Was this report originally from this site?
             // Using parse_url so we don't get fooled by tralining slashes or other url crazy bits
             if (!empty($incident_json['original']['incident']['sharingsourceurl'])) {
                 $source_url_parsed = parse_url($incident_json['original']['incident']['sharingsourceurl']);
             } else {
                 $source_url_parsed = array("host" => NULL);
             }
             // Kohana::log('sharing2import', "[" . $site->id . "] " . $source_url_parsed["host"] . " - " . $self_url_parsed["host"]);
             if ($source_url_parsed["host"] == $self_url_parsed["host"]) {
                 // Update counts and skip
                 $since_id = $remote_incident_id;
                 $count++;
                 continue;
             }
             // Check if we've saved this before.
             if (isset($existing_items[$remote_incident_id])) {
                 $sharing_incident = $existing_items[$remote_incident_id];
             } else {
                 $sharing_incident = ORM::factory('sharing_incident');
             }
             // Find and save categories
             $category_titles = array(null);
             foreach ($incident_json['categories'] as $category) {
                 $category_titles[] = $category->category_title;
             }
             // If matching categories, load them up
             $categories = ORM::factory('category')->in('category_title', $category_titles)->find_all();
             // Otherwise default to "Other" category
             if ($categories->count() == 0) {
                 $categories = array(ORM::factory('Category', Settings_Model::get_setting('sharing_other_category_id')));
             }
             // Handle location
             $existing_location = $sharing_incident->location;
             if ($existing_location->loaded) {
                 $existing_location->delete();
             }
             $incident_json['location']->save();
             $sharing_incident->location_id = $incident_json['location']->id;
             $date = $orm_incident->incident_date;
             // if the API sent us a unix timestamp, use it instead
             if (!empty($json_incident["incidentudate"])) {
                 $date = date("Y-m-d H:i:s", $json_incident["incidentudate"]);
             }
             $sharing_incident->incident_title = $orm_incident->incident_title;
             $sharing_incident->incident_description = $orm_incident->incident_description;
             $sharing_incident->incident_date = $date;
             $sharing_incident->incident_mode = $orm_incident->incident_mode;
             $sharing_incident->incident_active = $orm_incident->incident_active;
             $sharing_incident->incident_verified = $orm_incident->incident_verified;
             $sharing_incident->sharing_site_id = $site->id;
             $sharing_incident->remote_incident_id = $remote_incident_id;
             $sharing_incident->updated = date("Y-m-d H:i:s", time());
             $sharing_incident->save();
             // Save media
             ORM::factory('sharing_incident_media')->where('sharing_incident_id', $sharing_incident->id)->delete_all();
             foreach ($incident_json['media'] as $media) {
                 $media->save();
                 $new_sharing_incident_media = ORM::factory('sharing_incident_media');
                 $new_sharing_incident_media->media_id = $media->id;
                 $new_sharing_incident_media->sharing_incident_id = $sharing_incident->id;
                 $new_sharing_incident_media->save();
             }
             // Save categories
             ORM::factory('sharing_incident_category')->where('sharing_incident_id', $sharing_incident->id)->delete_all();
             foreach ($categories as $category) {
                 $new_sharing_incident_category = ORM::factory('sharing_incident_category');
                 $new_sharing_incident_category->category_id = $category->id;
                 $new_sharing_incident_category->sharing_incident_id = $sharing_incident->id;
                 $new_sharing_incident_category->save();
             }
             // Save the primary key of the row we touched. We will be deleting ones that weren't touched.
             $modified_ids[] = $sharing_incident->id;
             // Save the highest pulled incident id so we can grab the next set from that id on
             $since_id = $remote_incident_id;
             // Save count so we know if we need to pull any more reports or not
             $count++;
         }
         if ($count < $limit) {
             $more_reports_to_pull = FALSE;
         }
     }
     // Delete the reports that are no longer being displayed on the shared site
     if (count($modified_ids) > 0) {
         $sharing_incidents = ORM::factory('sharing_incident')->notin('id', $modified_ids)->where('sharing_site_id', $site->id)->find_all();
         if ($sharing_incidents->count() > 0) {
             ORM::factory('sharing_incident_category')->in('sharing_incident_id', $sharing_incidents->primary_key_array())->delete_all();
             ORM::factory('sharing_incident_media')->in('sharing_incident_id', $sharing_incidents->primary_key_array())->delete_all();
             ORM::factory('sharing_incident_comment')->in('sharing_incident_id', $sharing_incidents->primary_key_array())->delete_all();
             // @todo delete associated categories/location/media
             $sharing_incidents = ORM::factory('sharing_incident')->notin('id', $modified_ids)->where('sharing_site_id', $site->id)->delete_all();
         }
     }
 }
Beispiel #16
0
 public function sort()
 {
     $this->auto_render = FALSE;
     $this->template = "";
     if ($_POST) {
         if (isset($_POST['blocks']) and !empty($_POST['blocks'])) {
             $active_blocks = Settings_Model::get_setting('blocks');
             $active_blocks = array_filter(explode("|", $active_blocks));
             $blocks = array_map('trim', explode(',', $_POST['blocks']));
             $block_check = array();
             foreach ($blocks as $block) {
                 if (in_array($block, $active_blocks)) {
                     $block_check[] = $block;
                 }
             }
             Settings_Model::save_setting('blocks', implode("|", $active_blocks));
         }
     }
 }
Beispiel #17
0
 /**
  * Handles SMS Settings
  */
 public function sms()
 {
     $this->template->content = new View('admin/settings/sms');
     $this->template->content->title = Kohana::lang('ui_admin.settings');
     // setup and initialize form field names
     $form = array('sms_provider' => '', 'sms_no1' => '', 'sms_no2' => '', 'sms_no3' => '', 'sms_alert_url' => '');
     //	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) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $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('sms_provider', 'length[1,100]');
         $post->add_rules('sms_no1', 'numeric', 'length[1,30]');
         $post->add_rules('sms_no2', 'numeric', 'length[1,30]');
         $post->add_rules('sms_no3', 'numeric', 'length[1,30]');
         $post->add_rules('sms_alert_url', 'required', 'between[0,1]');
         // HT: new setting for url on sms
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             if (!Settings_Model::get_setting('sms_alert_url')) {
                 Settings_Model::save_setting('sms_alert_url', $post->sms_alert_url);
             }
             // Yes! everything is valid
             Settings_Model::save_all($post);
             // Delete Settings Cache
             $this->cache->delete('settings');
             $this->cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         $settings = Settings_Model::get_settings(array_keys($form));
         $settings['sms_alert_url'] = isset($settings['sms_alert_url']) ? $settings['sms_alert_url'] : 0;
         // HT: might not be in database so calling manually return NULL if not exist
         // Retrieve Current Settings
         $form = array('sms_provider' => $settings['sms_provider'], 'sms_no1' => $settings['sms_no1'], 'sms_no2' => $settings['sms_no2'], 'sms_no3' => $settings['sms_no3'], 'sms_alert_url' => $settings['sms_alert_url']);
     }
     $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->alert_url_array = array('1' => Kohana::lang('ui_admin.yes'), '0' => Kohana::lang('ui_admin.no'));
     $this->template->content->sms_provider_array = array_merge(array("" => "-- Select One --"), plugin::get_sms_providers());
 }
Beispiel #18
0
 /**
  * Map Settings
  */
 public function index($saved = false)
 {
     // Display all maps
     $this->themes->api_url = Kohana::config('settings.api_url_all');
     // Current Default Country
     $current_country = Kohana::config('settings.default_country');
     $this->template->content = new View('admin/settings/main');
     $this->template->content->title = Kohana::lang('ui_admin.settings');
     // setup and initialize form field names
     $form = array('default_map' => '', 'api_google' => '', 'api_live' => '', 'default_country' => '', 'multi_country' => '', 'default_lat' => '', 'default_lon' => '', 'default_zoom' => '', 'default_map_all' => '', 'allow_clustering' => '', 'default_map_all_icon' => '', 'default_map_all_icon_id' => '', 'delete_default_map_all_icon' => '', 'enable_timeline' => '');
     //	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 = $saved == 'saved';
     // 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)->pre_filter('trim', TRUE)->add_rules('default_country', 'required', 'numeric', 'length[1,4]')->add_rules('multi_country', 'numeric', 'length[1,1]')->add_rules('default_map', 'required', 'length[0,100]')->add_rules('default_zoom', 'required', 'between[0,21]')->add_rules('default_lat', 'required', 'between[-85,85]')->add_rules('default_lon', 'required', 'between[-180,180]')->add_rules('allow_clustering', 'required', 'between[0,1]')->add_rules('default_map_all', 'required', 'alpha_numeric', 'length[6,6]')->add_rules('api_google', 'length[0,200]')->add_rules('api_live', 'length[0,200]')->add_rules('enable_timeline', 'numeric', 'length[1,1]');
         // Add rules for file upload
         $files = Validation::factory($_FILES);
         $files->add_rules('default_map_all_icon', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[250K]');
         // Test to see if things passed the rule checks
         if ($post->validate() and $files->validate(FALSE)) {
             // Save all the settings
             Settings_Model::save_all($post);
             // E.Kala 20th April 2012
             // Ghetto workaround prevent resetting og Bing Maps API Key
             // Soon to be addressed conclusively
             if (isset($post['api_live']) and !empty($post['api_live'])) {
                 Settings_Model::save_setting('api_live', $post->api_live);
             }
             // Deal with default category icon now
             // Check if deleting or updating a new image (or doing nothing)
             if (isset($post->delete_default_map_all_icon) and $post->delete_default_map_all_icon == 1) {
                 // Delete old badge image
                 ORM::factory('media')->delete(Settings_Model::get_setting('default_map_all_icon_id'));
                 // Remove from DB table
                 Settings_Model::save_setting('default_map_all_icon_id', NULL);
             } else {
                 // We aren't deleting, so try to upload if we are uploading an image
                 $filename = upload::save('default_map_all_icon');
                 if ($filename) {
                     $new_filename = "default_map_all_" . time();
                     $file_type = strrev(substr(strrev($filename), 0, 4));
                     // Large size
                     $l_name = $new_filename . $file_type;
                     Image::factory($filename)->save(Kohana::config('upload.directory', TRUE) . $l_name);
                     // Medium size
                     $m_name = $new_filename . "_m" . $file_type;
                     Image::factory($filename)->resize(32, 32, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $m_name);
                     // Thumbnail
                     $t_name = $new_filename . "_t" . $file_type;
                     Image::factory($filename)->resize(16, 16, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $t_name);
                     // Name the files for the DB
                     $media_link = $l_name;
                     $media_medium = $m_name;
                     $media_thumb = $t_name;
                     // Okay, now we have these three different files on the server, now check to see
                     //   if we should be dropping them on the CDN
                     if (Kohana::config("cdn.cdn_store_dynamic_content")) {
                         $media_link = cdn::upload($media_link);
                         $media_medium = cdn::upload($media_medium);
                         $media_thumb = cdn::upload($media_thumb);
                         // We no longer need the files we created on the server. Remove them.
                         $local_directory = rtrim(Kohana::config('upload.directory', TRUE), '/') . '/';
                         unlink($local_directory . $l_name);
                         unlink($local_directory . $m_name);
                         unlink($local_directory . $t_name);
                     }
                     // Remove the temporary file
                     unlink($filename);
                     // Save image in the media table
                     $media = new Media_Model();
                     $media->media_type = 1;
                     // Image
                     $media->media_link = $media_link;
                     $media->media_medium = $media_medium;
                     $media->media_thumb = $media_thumb;
                     $media->media_date = date("Y-m-d H:i:s", time());
                     $media->save();
                     // Save new image in settings
                     Settings_Model::save_setting('default_map_all_icon_id', $media->id);
                 }
             }
             // Delete Settings Cache
             $this->cache->delete('settings');
             $this->cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // Action::map_settings_modified - Map settings have changed
             Event::run('ushahidi_action.map_settings_modified');
             // Redirect to reload everything over again
             url::redirect('admin/settings/index/saved');
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         // Retrieve Current Settings
         $settings = Settings_Model::get_settings(array_keys($form));
         $form = array('default_map' => $settings['default_map'], 'api_google' => $settings['api_google'], 'api_live' => $settings['api_live'], 'default_country' => $settings['default_country'], 'multi_country' => $settings['multi_country'], 'default_lat' => $settings['default_lat'], 'default_lon' => $settings['default_lon'], 'default_zoom' => $settings['default_zoom'], 'allow_clustering' => $settings['allow_clustering'], 'default_map_all' => $settings['default_map_all'], 'default_map_all_icon_id' => $settings['default_map_all_icon_id'], 'enable_timeline' => $settings['enable_timeline']);
     }
     // Get default category image
     if (($default_map_all_icon_id = Settings_Model::get_setting('default_map_all_icon_id')) !== NULL) {
         $icon = ORM::factory('media')->find($default_map_all_icon_id);
         $this->template->content->default_map_all_icon = url::convert_uploaded_to_abs($icon->media_link);
         $this->template->content->default_map_all_icon_m = url::convert_uploaded_to_abs($icon->media_medium);
         $this->template->content->default_map_all_icon_t = url::convert_uploaded_to_abs($icon->media_thumb);
     } else {
         $this->template->content->default_map_all_icon = NULL;
         $this->template->content->default_map_all_icon_m = NULL;
         $this->template->content->default_map_all_icon_t = NULL;
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     // 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, 30) . "...";
         }
         $countries[$country->id] = $this_country;
     }
     $this->template->content->countries = $countries;
     // Zoom Array for Slider
     $default_zoom_array = array();
     for ($i = Kohana::config('map.minZoomLevel'); $i < Kohana::config('map.minZoomLevel') + Kohana::config('map.numZoomLevels'); $i++) {
         $default_zoom_array[$i] = $i;
     }
     $this->template->content->default_zoom_array = $default_zoom_array;
     // Get Map API Providers
     $layers = map::base();
     $map_array = array();
     foreach ($layers as $layer) {
         $map_array[$layer->name] = $layer->title;
     }
     $this->template->content->map_array = $map_array;
     $this->template->content->yesno_array = array('1' => utf8::strtoupper(Kohana::lang('ui_main.yes')), '0' => utf8::strtoupper(Kohana::lang('ui_main.no')));
     // Javascript Header
     $this->themes->map_enabled = TRUE;
     $this->themes->colorpicker_enabled = TRUE;
     $this->themes->js = new View('admin/settings/settings_js');
     $this->themes->js->default_map = $form['default_map'];
     $this->themes->js->default_zoom = $form['default_zoom'];
     $this->themes->js->default_lat = $form['default_lat'];
     $this->themes->js->default_lon = $form['default_lon'];
     $this->themes->js->all_maps_json = $this->_generate_settings_map_js();
 }