本文整理汇总了PHP中kohana::config方法的典型用法代码示例。如果您正苦于以下问题:PHP kohana::config方法的具体用法?PHP kohana::config怎么用?PHP kohana::config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kohana
的用法示例。
在下文中一共展示了kohana::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log_error
/**
* Standardise the dumping of an exception message into the kohana log. E.g.
* try {
* ... code that throws exception ...
* } catch (Exception $e) {
* error::log_error('Error occurred whilst running some code', $e);
* }
*
* @param string $msg A description of where the error occurred.
* $param object $e The exception object.
*/
public static function log_error($msg, $e)
{
kohana::log('error', '#' . $e->getCode() . ': ' . $msg . '. ' . $e->getMessage() . ' at line ' . $e->getLine() . ' in file ' . $e->getFile());
// Double check the log threshold to avoid unnecessary work.
if (kohana::config('config.log_threshold') == 4) {
$trace = $e->getTrace();
$output = "Stack trace:\n";
for ($i = 0; $i < count($trace); $i++) {
if (array_key_exists('file', $trace[$i])) {
$file = $trace[$i]['file'];
} else {
$file = 'Unknown file';
}
if (array_key_exists('line', $trace[$i])) {
$line = $trace[$i]['line'];
} else {
$line = 'Unknown';
}
if (array_key_exists('function', $trace[$i])) {
$function = $trace[$i]['function'];
} else {
$function = 'Unknown function';
}
$output .= "\t" . $file . ' - line ' . $line . ' - ' . $function . "\n";
}
kohana::log('debug', $output);
}
}
示例2: __construct
/**
* 构造方法
*/
public function __construct($img_dir_name = '')
{
$upload_path = kohana::config('upload.directory');
$this->img_dir_name = $img_dir_name ? $img_dir_name : $this->img_dir_name;
$this->dir_name = $upload_path . '/' . $this->img_dir_name . '/';
$this->no_img_file = $upload_path . '/no_img.gif';
}
示例3: create_nonce
/**
* Method to create a nonce, either from a service call (when the caller type is a website) or from the Warehouse
* (when the caller type is an Indicia user.
*/
public static function create_nonce($type, $website_id)
{
$nonce = sha1(time() . ':' . rand() . $_SERVER['REMOTE_ADDR'] . ':' . kohana::config('indicia.private_key'));
$cache = new Cache();
$cache->set($nonce, $website_id, $type, Kohana::config('indicia.nonce_life'));
return $nonce;
}
示例4: notify_admins
public function notify_admins($subject = NULL, $message = NULL)
{
// Don't show the exceptions for this operation to the user. Log them
// instead
try {
if ($subject && $message) {
$settings = kohana::config('settings');
$from = array();
$from[] = $settings['site_email'];
$from[] = $settings['site_name'];
$users = ORM::factory('user')->where('notify', 1)->find_all();
foreach ($users as $user) {
if ($user->has(ORM::factory('role', 'admin'))) {
$address = $user->email;
$message .= "\n\n\n\n~~~~~~~~~~~~\n" . Kohana::lang('notifications.admin_footer') . "\n" . url::base() . "\n\n" . Kohana::lang('notifications.admin_login_url') . "\n" . url::base() . "admin";
if (!email::send($address, $from, $subject, $message, FALSE)) {
Kohana::log('error', "email to {$address} could not be sent");
}
}
}
} else {
Kohana::log('error', "email to {$address} could not be sent\n\t\t\t\t - Missing Subject or Message");
}
} catch (Exception $e) {
Kohana::log('error', "An exception occured " . $e->__toString());
}
}
示例5: _send_email_alert
/**
* Sends an email alert
*/
public static function _send_email_alert($post)
{
// Email Alerts, Confirmation Code
$alert_email = $post->alert_email;
$alert_lon = $post->alert_lon;
$alert_lat = $post->alert_lat;
$alert_radius = $post->alert_radius;
$alert_code = text::random('alnum', 20);
$settings = kohana::config('settings');
$to = $alert_email;
$from = array();
$from[] = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email'];
$from[] = $settings['site_name'];
$subject = $settings['site_name'] . " " . Kohana::lang('alerts.verification_email_subject');
$message = Kohana::lang('alerts.confirm_request') . url::site() . 'alerts/verify?c=' . $alert_code . "&e=" . $alert_email;
if (email::send($to, $from, $subject, $message, TRUE) == 1) {
$alert = ORM::factory('alert');
$alert->alert_type = self::EMAIL_ALERT;
$alert->alert_recipient = $alert_email;
$alert->alert_code = $alert_code;
$alert->alert_lon = $alert_lon;
$alert->alert_lat = $alert_lat;
$alert->alert_radius = $alert_radius;
if (isset($_SESSION['auth_user'])) {
$alert->user_id = $_SESSION['auth_user']->id;
}
$alert->save();
self::_add_categories($alert, $post);
return TRUE;
}
return FALSE;
}
示例6: insertMapSquares
/**
* Code for the insertMapSquaresFor... methods, which takes the table alias as a parameter in order to be generic.
*/
private static function insertMapSquares($ids, $alias, $size, $db = null)
{
if (count($ids) > 0) {
static $srid;
if (!isset($srid)) {
$srid = kohana::config('sref_notations.internal_srid');
}
if (!$db) {
$db = new Database();
}
$idlist = implode(',', $ids);
// Seems much faster to break this into small queries than one big left join.
$smpInfo = $db->query("SELECT DISTINCT s.id, st_astext(coalesce(s.geom, l.centroid_geom)) as geom, o.confidential, GREATEST(o.sensitivity_precision, s.privacy_precision, {$size}) as size, \n coalesce(s.entered_sref_system, l.centroid_sref_system) as entered_sref_system,\n round(st_x(st_centroid(reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, GREATEST(o.sensitivity_precision, s.privacy_precision, {$size}), s.entered_sref_system)))) as x,\n round(st_y(st_centroid(reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, GREATEST(o.sensitivity_precision, s.privacy_precision, {$size}), s.entered_sref_system)))) as y\n FROM samples s\n JOIN occurrences o ON o.sample_id=s.id\n LEFT JOIN locations l on l.id=s.location_id AND l.deleted=false\n WHERE {$alias}.id IN ({$idlist})")->result_array(TRUE);
$km = $size / 1000;
foreach ($smpInfo as $s) {
$existing = $db->query("SELECT id FROM map_squares WHERE x={$s->x} AND y={$s->y} AND size={$s->size}")->result_array(FALSE);
if (count($existing) === 0) {
$qry = $db->query("INSERT INTO map_squares (geom, x, y, size)\n VALUES (reduce_precision(st_geomfromtext('{$s->geom}', {$srid}), '{$s->confidential}', {$s->size}, '{$s->entered_sref_system}'), {$s->x}, {$s->y}, {$s->size})");
$msqId = $qry->insert_id();
} else {
$msqId = $existing[0]['id'];
}
$db->query("UPDATE cache_occurrences co SET map_sq_{$km}km_id={$msqId} WHERE sample_id={$s->id}");
}
}
}
示例7: auto_verify_scheduled_task
/**
* Hook into the task scheduler. When run, the system checks the cache_occurrences table for records where the data cleaner has marked
* the record as data_cleaner_info "pass", record_status="C", the system then sets the record to verified automatically.
* @param string $last_run_date Date last run, or null if never run
* @param object $db Database object.
*/
function auto_verify_scheduled_task($last_run_date, $db)
{
$autoVerifyNullIdDiff = kohana::config('auto_verify.auto_accept_occurrences_with_null_id_difficulty');
global $processOldData;
$processOldData = kohana::config('auto_verify.process_old_data');
if (empty($autoVerifyNullIdDiff)) {
print_r("Unable to automatically verify occurrences when the auto_accept_occurrences_with_null_id_difficulty entry is empty.<br>");
kohana::log('error', 'Unable to automatically verify occurrences when the auto_accept_occurrences_with_null_id_difficulty configuration entry is empty.');
return false;
}
//Do we need to consider old data (probably as a one-off run) or just newly changed data.
$subQuery = "\n SELECT co.id";
if (!empty($processOldData) && $processOldData === 'true') {
$subQuery .= " \n FROM cache_occurrences co";
} else {
$subQuery .= " \n FROM occdelta od\n JOIN cache_occurrences co on co.id=od.id";
}
$subQuery .= "\n JOIN surveys s on s.id = co.survey_id AND s.auto_accept=true AND s.deleted=false\n LEFT JOIN cache_taxon_searchterms cts on cts.taxon_meaning_id = co.taxon_meaning_id \n WHERE co.data_cleaner_info='pass' AND co.record_status='C' AND co.record_substatus IS NULL\n AND ((" . $autoVerifyNullIdDiff . "=false AND cts.identification_difficulty IS NOT NULL AND cts.identification_difficulty<=s.auto_accept_max_difficulty) \n OR (" . $autoVerifyNullIdDiff . "=true AND (cts.identification_difficulty IS NULL OR cts.identification_difficulty<=s.auto_accept_max_difficulty)))";
$verificationTime = gmdate("Y\\/m\\/d H:i:s");
//Need to update cache_occurrences, as this table has already been built at this point.
$query = "\n INSERT INTO occurrence_comments (comment, generated_by, occurrence_id,record_status,record_substatus,created_by_id,updated_by_id,created_on,updated_on,auto_generated)\n SELECT 'Accepted based on automatic checks', 'system', id,'V','2',1,1,'" . $verificationTime . "','" . $verificationTime . "',true\n FROM occurrences\n WHERE id in\n (" . $subQuery . ");\n \n UPDATE occurrences\n SET \n record_status='V',\n record_substatus='2',\n release_status='R',\n verified_by_id=1,\n verified_on='" . $verificationTime . "',\n record_decision_source='M'\n WHERE id in\n (" . $subQuery . ");\n \n UPDATE cache_occurrences\n SET \n record_status='V',\n record_substatus='2',\n release_status='R',\n verified_on='" . $verificationTime . "',\n verifier='admin, core'\n WHERE id in\n (" . $subQuery . ");";
$results = $db->query($query)->result_array(false);
//Query to return count of records, as I was unable to pursuade the above query to output the number of updated
//records correctly.
$query = "\n SELECT count(id)\n FROM cache_occurrences co\n WHERE co.verified_on='" . $verificationTime . "';";
$results = $db->query($query)->result_array(false);
if (!empty($results[0]['count']) && $results[0]['count'] > 1) {
echo $results[0]['count'] . ' occurrence records have been automatically verified.</br>';
} elseif (!empty($results[0]['count']) && $results[0]['count'] === "1") {
echo '1 occurrence record has been automatically verified.</br>';
} else {
echo 'No occurrence records have been auto-verified.</br>';
}
}
示例8: importConfigRoutes
public static function importConfigRoutes()
{
$outboundPatterns = kohana::config('simpleroute.outbound_patterns');
if (!is_array($outboundPatterns)) {
return;
}
// This is the second work arround for the double loading issue... hmmm
$createdPatterns = array();
$simpleRoutes = array();
foreach ($outboundPatterns as $outboundPattern) {
if (empty($outboundPattern['name'])) {
continue;
}
if (in_array($outboundPattern['name'], $createdPatterns)) {
continue;
}
$createdPatterns[] = $outboundPattern['name'];
if (empty($outboundPattern['patterns'])) {
continue;
}
if (!is_array($outboundPattern['patterns'])) {
$outboundPattern['patterns'] = array($outboundPattern['patterns']);
}
$simpleRoute =& $simpleRoutes[];
$simpleRoute['name'] = $outboundPattern['name'];
$simpleRoute['patterns'] = $outboundPattern['patterns'];
}
return $simpleRoutes;
}
示例9: prepare_connection
/**
* Hook to prepare the database connection. Performs 2 tasks.
* 1) Initialises the search path, unless configured not to do this (e.g. if this is set at db level).
* 2) If this is a report request, sets the connection to read only.
*/
public static function prepare_connection()
{
$uri = URI::instance();
// we havent to proceed futher if a setup call was made
if ($uri->segment(1) == 'setup_check') {
return;
}
// continue to init the system
//
// add schema to the search path
//
$_schema = Kohana::config('database.default.schema');
$query = '';
if (!empty($_schema) && kohana::config('indicia.apply_schema') !== false) {
$query = "SET search_path TO {$_schema}, public, pg_catalog;\n";
}
// Force a read only connection for reporting.
if ($uri->segment(1) == 'services' && $uri->segment(2) == 'report') {
$query .= "SET default_transaction_read_only TO true;\n";
}
if (!empty($query)) {
$db = Database::instance();
$db->query($query);
}
}
示例10: _send_email_alert
/**
* Sends an email alert
*
* @param Validation_Core $post
* @param Alert_Model $alert
* @return bool
*/
public static function _send_email_alert($post, $alert)
{
if (!$post instanceof Validation_Core and !$alert instanceof Alert_Model) {
throw new Kohana_Exception('Invalid parameter types');
}
// Email Alerts, Confirmation Code
$alert_email = $post->alert_email;
$alert_code = text::random('alnum', 20);
$settings = kohana::config('settings');
$to = $alert_email;
$from = array();
$from[] = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email'];
$from[] = $settings['site_name'];
$subject = $settings['site_name'] . " " . Kohana::lang('alerts.verification_email_subject');
$message = Kohana::lang('alerts.confirm_request') . url::site() . 'alerts/verify?c=' . $alert_code . "&e=" . $alert_email;
if (email::send($to, $from, $subject, $message, TRUE) == 1) {
$alert->alert_type = self::EMAIL_ALERT;
$alert->alert_recipient = $alert_email;
$alert->alert_code = $alert_code;
if (isset($_SESSION['auth_user'])) {
$alert->user_id = $_SESSION['auth_user']->id;
}
$alert->save();
self::_add_categories($alert, $post);
return TRUE;
}
return FALSE;
}
示例11: import_progress
/**
* Controller method for the import_progress path. Displays the upload template with
* progress bar and status message, which then initiates the actual import.
*/
public function import_progress()
{
if (file_exists(kohana::config('upload.directory') . '/' . $_GET['file'])) {
$this->template->content = new View('taxon_designation/upload');
$this->template->title = 'Uploading designations';
}
}
示例12: __construct
public function __construct()
{
// Hook into routing, but not if running unit tests
if (!in_array(MODPATH . 'phpUnit', kohana::config('config.modules'))) {
Event::add('system.routing', array($this, 'check'));
}
}
示例13: createExtension
public static function createExtension()
{
Event::$data += array('voicemail_password' => self::generatePin(), 'voicemail_timezone' => kohana::config('locale.timezone'), 'voicemail_email_all_messages' => empty(Event::$data['user']['email_address']) ? 0 : 1, 'voicemail_delete_file' => 0, 'voicemail_attach_audio_file' => 1, 'voicemail_email_address' => empty(Event::$data['user']['email_address']) ? '' : Event::$data['user']['email_address']);
extract(Event::$data);
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
$name_append = '';
if (!empty($owner_name)) {
$name_append = ' for ' . $owner_name;
}
try {
$voicemail = new Voicemail();
$voicemail['name'] = 'VM ' . $extension . $name_append;
$voicemail['mailbox'] = $extension;
$voicemail['password'] = $voicemail_password;
$voicemail['account_id'] = $account_id;
$voicemail['plugins'] = array('timezone' => array('timezone' => $voicemail_timezone));
$voicemail['registry'] = array('email_all_messages' => $voicemail_email_all_messages, 'delete_file' => $voicemail_delete_file, 'attach_audio_file' => $voicemail_attach_audio_file, 'email_address' => $voicemail_email_address);
$voicemail->save();
$plugin = array('voicemail' => array('mwi_box' => $voicemail['voicemail_id']));
$device['plugins'] = arr::merge($device['plugins'], $plugin);
} catch (Exception $e) {
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
kohana::log('error', 'Unable to generate voicemail for device: ' . $e->getMessage());
throw $e;
}
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
}
示例14: _setup_check
/**
* If not in the setup pages, but the indicia config file is missing, go to system setup.
*/
public static function _setup_check()
{
$uri = URI::instance();
$isOk = $uri->segment(1) == 'setup' || $uri->segment(1) == 'setup_check' || kohana::config('indicia.private_key', false, false) !== null;
if (!$isOk) {
url::redirect('setup_check');
}
}
示例15: index
public function index()
{
$db = new Database();
$incidents = $db->query("SELECT incident.id, incident_title, \n\t\t\t\t\t\t\t\t incident_description, incident_verified, \n\t\t\t\t\t\t\t\t location.latitude, location.longitude, alert_sent.incident_id\n\t\t\t\t\t\t\t\t FROM incident INNER JOIN location ON incident.location_id = location.id\n\t\t\t\t\t\t\t\t LEFT OUTER JOIN alert_sent ON incident.id = alert_sent.incident_id");
$config = kohana::config('alerts');
$sms_from = NULL;
$settings = ORM::factory('settings', 1);
if ($settings->loaded == true) {
// Get SMS Numbers
if (!empty($settings->sms_no3)) {
$sms_from = $settings->sms_no3;
} elseif (!empty($settings->sms_no2)) {
$sms_from = $settings->sms_no2;
} elseif (!empty($settings->sms_no1)) {
$sms_from = $settings->sms_no1;
} else {
$sms_from = "000";
}
// User needs to set up an SMS number
}
foreach ($incidents as $incident) {
if ($incident->incident_id != NULL) {
continue;
}
$verified = (int) $incident->incident_verified;
if ($verified) {
$latitude = (double) $incident->latitude;
$longitude = (double) $incident->longitude;
$proximity = new Proximity($latitude, $longitude);
$alertees = $this->_get_alertees($proximity);
foreach ($alertees as $alertee) {
$alert_type = (int) $alertee->alert_type;
if ($alert_type == 1) {
$sms = new Eflyer();
$sms->user = $settings->eflyer_username;
$sms->password = $settings->eflyer_password;
$sms->use_ssl = false;
$sms->sms();
$message = $incident->incident_description;
if ($sms->send($alertee->alert_recipient, $message) == "OK") {
$db->insert('alert_sent', array('alert_id' => $alertee->id, 'incident_id' => $incident->id, 'alert_date' => date("Y-m-d H:i:s")));
$db->clear_cache(true);
}
} elseif ($alert_type == 2) {
$to = $alertee->alert_recipient;
$from = $config['alerts_email'];
$subject = $incident->incident_title;
$message = $incident->incident_description;
if (email::send($to, $from, $subject, $message, TRUE) == 1) {
$db->insert('alert_sent', array('alert_id' => $alertee->id, 'incident_id' => $incident->id, 'alert_date' => date("Y-m-d H:i:s")));
$db->clear_cache(true);
}
}
}
}
}
}