/** * Respond to a parsed message failing authentification. * * @param array $message * The mail message Feeds was trying to parse. */ function hook_mailhandler_auth_failed($message) { // Log the failure to Recent Log Entries. watchdog('mailhandler', 'User could not be authenticated. Please check your Mailhandler authentication plugin settings.', array(), WATCHDOG_WARNING); // Alert the user. drupal_set_message(t('Oops, not able to authenticate mail.', array(), 'warning')); }
function submitForm(array &$form, array &$form_state) { BdContactStorage::delete($this->id); watchdog('bd_contact', 'Deleted BD Contact Submission with id %id.', array('%id' => $this->id)); drupal_set_message(t('BD Contact submission %id has been deleted.', array('%id' => $this->id))); $form_state['redirect'] = 'admin/content/bd_contact'; }
/** * {@inheritdoc} */ public function save(array $form, array &$form_state) { $this->termStorage->resetWeights($this->entity->id()); drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); }
/** * Receive and process a ping from Recurly.com. * * Any module wishing to respond to a change in a subscription should implement * this hook. This hook is called after every ping from Recurly, including the * following events: * - A new account has been created. * - A new subscription has been created for an account. * - A subscription is canceled/terminated. * - A subscription has its plan changed. * - A subscription has been invoiced. * * @param $subdomain * The Recurly subdomain for which this notification was received. * @param $notification * The XML Recurly notification. This is a raw SimpleXMl parsing of the * notification. See https://docs.recurly.com/api/push-notifications. */ function hook_recurly_process_push_notification($subdomain, $notification) { // Reset the monthly limits upon account renewals. if ($notification->type === 'renewed_subscription_notification') { $account_code = $notification->account->account_code; if ($local_account = recurly_account_load(array('account_code' => $account_code), TRUE)) { // These notifications are SimpleXML objects rather than Recurly objects. $next_reset = new DateTime($notification->subscription->current_period_ends_at[0]); $next_reset->setTimezone(new DateTimeZone('UTC')); $next_reset = $next_reset->format('U'); mymodule_reset_billing_limits($local_account->entity_id, $next_reset); } else { watchdog('recurly', 'Recurly received a Push notification, but was unable to locate the account in the local database. The push notification contained the following information: @notification', array('@notification' => print_r($notification, 1)), WATCHDOG_ALERT); } } // Upgrade/downgrade notifications. if ($notification->type === 'updated_subscription_notification' || $notification->type === 'new_subscription_notification') { $account_code = $notification->account->account_code; if ($local_account = recurly_account_load(array('account_code' => $account_code), TRUE)) { // Upgrade the account by assigning roles, changing fields, etc. } else { watchdog('recurly', 'Recurly received a Push notification, but was unable to locate the account in the local database. The push notification contained the following information: @notification', array('@notification' => print_r($notification, 1)), WATCHDOG_ALERT); } } }
/** * Performs a request. * * @param string $url * @param array $params * @param string $method * * @throws \Exception */ protected function request($url, $params = array(), $method = 'GET') { $data = ''; if (count($params) > 0) { if ($method == 'GET') { $url .= '?' . http_build_query($params, '', '&'); } else { $data = http_build_query($params, '', '&'); } } $headers = array(); $headers['Authorization'] = 'Oauth'; $headers['Content-type'] = 'application/x-www-form-urlencoded'; $response = $this->doRequest($url, $headers, $method, $data); if (!isset($response->error)) { return $response->data; } else { $error = $response->error; if (!empty($response->data)) { $data = $this->parse_response($response->data); if (isset($data->error)) { $error = $data->error; } elseif (isset($data->meta)) { $error = new Exception($data->meta->error_type . ': ' . $data->meta->error_message, $data->meta->code); } } watchdog('instagram_block', $error); } }
function brukar_client_oauth_callback() { require_once drupal_get_path('module', 'brukar_common') . '/OAuth.php'; $method = new OAuthSignatureMethod_HMAC_SHA1(); $consumer = new OAuthConsumer(variable_get('brukar_consumer_key'), variable_get('brukar_consumer_secret')); if (isset($_SESSION['auth_oauth']) && $_SESSION['auth_oauth']['oauth_token'] == $_GET['oauth_token']) { unset($_GET['oauth_token']); $tmp = new OAuthToken($_SESSION['auth_oauth']['oauth_token'], $_SESSION['auth_oauth']['oauth_token_secret']); $req = OAuthRequest::from_consumer_and_token($consumer, $tmp, 'GET', variable_get('brukar_url') . 'server/oauth/access_token', array()); $req->sign_request($method, $consumer, $tmp); parse_str(trim(file_get_contents($req->to_url())), $token); unset($_SESSION['auth_oauth']); if (count($token) > 0) { $_SESSION['_brukar_access_token'] = array('token' => $token['oauth_token'], 'token_secret' => $token['oauth_token_secret']); $token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']); $req = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', variable_get('brukar_url') . 'server/oauth/user', array()); $req->sign_request($method, $consumer, $token); brukar_client_login((array) json_decode(trim(file_get_contents($req->to_url())))); } } $debug_data = array('cookie' => $_COOKIE, 'request_uri' => request_uri(), 'auth_oauth' => isset($_SESSION['auth_oauth']) ? $_SESSION['auth_oauth'] : 'no auth_oauth'); watchdog('brukar_client', 'User login failed.<br/>Debug data:<br/><pre>!debug_data</pre><br/>', array('!debug_data' => print_r($debug_data, TRUE)), WATCHDOG_ERROR); drupal_set_message(t('Noe gikk feil under innlogging.'), 'warning'); drupal_goto('<front>'); }
/** * Do CURL request directly into sendinblue. * * @param array $data * A data of curl request. * @return array * An associate array with respond data. */ private function doRequestDirect($data) { if (!function_exists('curl_init')) { $msg = 'SendinBlue requires CURL module'; watchdog('sendinblue', $msg, NULL, WATCHDOG_ERROR); return NULL; } $url = 'http://ws.mailin.fr/'; $ch = curl_init(); $paramData = ''; $data['source'] = 'Drupal'; if (is_array($data)) { foreach ($data as $key => $value) { $paramData .= $key . '=' . urlencode($value) . '&'; } } else { $paramData = $data; } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $paramData); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); return $data; }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Deleted vocabulary %name.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->getCancelRoute(); }
public function unresolveDependencies($subset = false, $subtype = false) { // Create a clone of the definition so we don't muck up the entity cache. $this->unresolved_definition = $subset === false ? $this->entity->definition : $subset; if (!is_object($this->unresolved_definition)) { $this->unresolved_definition = (object) $this->unresolved_definition; } // Generate the list of handlers for each of the fields. $handlers = DefinitionHandlerRegistry::getFieldHandlers($this->entity, $this->unresolved_definition, $subtype); foreach ($handlers as $field_name => $handler) { if (!isset($this->unresolved_definition->{$field_name})) { continue; } foreach ($handler['handlers'] as $single_handler) { if (!$single_handler instanceof DefinitionHandlerBase) { continue; } try { $single_handler->entity =& $this->entity; $single_handler->unresolved_definition =& $this->unresolved_definition; $single_handler->unhandleField($this->entity->type(), $handler['type'], $field_name, $this->unresolved_definition->{$field_name}); } catch (\Exception $ex) { $message = t('Error processing field "@fieldName" - "@message"', array('@fieldName' => $field_name, '@message' => $ex->getMessage())); \watchdog('publisher', $message, array(), WATCHDOG_WARNING); $this->errors[] = $ex; } } } }
/** * Gets a form submitted via #ajax during an Ajax callback. * * This will load a form from the form cache used during Ajax operations. It * pulls the form info from the request body. * * @param \Symfony\Component\HttpFoundation\Request $request * The current request object. * * @return array * An array containing the $form and $form_state. Use the list() function * to break these apart: * @code * list($form, $form_state, $form_id, $form_build_id) = $this->getForm(); * @endcode * * @throws Symfony\Component\HttpKernel\Exception\HttpExceptionInterface */ protected function getForm(Request $request) { $form_state = \Drupal::formBuilder()->getFormStateDefaults(); $form_build_id = $request->request->get('form_build_id'); // Get the form from the cache. $form = form_get_cache($form_build_id, $form_state); if (!$form) { // If $form cannot be loaded from the cache, the form_build_id must be // invalid, which means that someone performed a POST request onto // system/ajax without actually viewing the concerned form in the browser. // This is likely a hacking attempt as it never happens under normal // circumstances. watchdog('ajax', 'Invalid form POST data.', array(), WATCHDOG_WARNING); throw new BadRequestHttpException(); } // Since some of the submit handlers are run, redirects need to be disabled. $form_state['no_redirect'] = TRUE; // When a form is rebuilt after Ajax processing, its #build_id and #action // should not change. // @see \Drupal\Core\Form\FormBuilderInterface::rebuildForm() $form_state['rebuild_info']['copy']['#build_id'] = TRUE; $form_state['rebuild_info']['copy']['#action'] = TRUE; // The form needs to be processed; prepare for that by setting a few internal // variables. $form_state['input'] = $request->request->all(); $form_id = $form['#form_id']; return array($form, $form_state, $form_id, $form_build_id); }
/** * This function is handles the callback from Box API. * @return string */ function _soc_boxauth_get_code_from_box_handler() { // get query string parameters $qs = drupal_get_query_parameters(); watchdog(SOC_BOXAUTH_MODULENAME, "Got code back from Box", $qs, WATCHDOG_INFO); // Stage post data and create http query $post_data = ['grant_type' => 'authorization_code', 'code' => $qs['code'], 'client_id' => variable_get(SOC_BOXAUTH_CLIENTID_VARIABLE), 'client_secret' => variable_get(SOC_BOXAUTH_CLIENTSECRET_VARIABLE)]; $result = BoxFolderOperations::doPost('https://api.box.com/oauth2/token', $post_data, 'Content-type: application/x-www-form-urlencoded', 'QUERY'); // save to session. Decoded json object into php array $_SESSION['box'] = drupal_json_decode($result); $_SESSION['box']['expires_time'] = time() + SOC_BOXAUTH_EXPIREOFFSET; // If successful, the ['box']['access_token'] will exists. Log and report // to user. if (isset($_SESSION['box']['access_token'])) { drupal_set_message(t(variable_get(SOC_BOXAUTH_SUCCESSMESSAGE_VARIABLE))); watchdog(SOC_BOXAUTH_MODULENAME, 'Successful box access_token'); $next_steps = variable_get(SOC_BOXAUTH_NEXTSTEPS_VARIABLE, ['value' => t('Next steps...')]); return $next_steps['value']; } else { $message = t(variable_get(SOC_BOXAUTH_FAILUREMESSAGE_VARIABLE)); drupal_set_message($message, 'error'); watchdog(SOC_BOXAUTH_MODULENAME, 'Failed box access_token'); return $message; } }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label())); drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label()))); $form_state['redirect_route'] = new Url('aggregator.sources'); }
/** * Returns emails. * * @param array|string $fields * A table column or an array of columns to return. * @param null|string $mailkey * Filter the results by mail key. * @param null|string $subject * Filter the results by subject. * * @return array * An array of emails. * * @throws \Exception */ public static function get($fields = array(), $mailkey = NULL, $subject = NULL) { if (!module_exists('redtest_helper_mail_logger')) { throw new \Exception('Please enable Red Test Help Mail Logger module.'); } $test_token = getenv('TEST_TOKEN'); $test_token_exists = isset($test_token); $original_fields = $fields; if (is_string($fields)) { $fields = array($fields); } elseif (is_array($fields) && sizeof($fields) == 1) { $original_fields = $fields[0]; } $query = db_select('mail_logger', 'm'); if (sizeof($fields)) { $query->fields('m', $fields); } else { $query->fields('m'); } if ($test_token_exists) { $query->condition('m.test_token', $test_token); } if (!is_null($mailkey)) { $query->condition('m.mailkey', $mailkey); } if (!is_null($subject)) { $query->condition('m.subject', $subject); } watchdog('query', $query); $result = $query->execute(); if (is_string($original_fields)) { return $result->fetchCol(); } return $result->fetchAssoc(); }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Category %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('contact', 'Category %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->getCancelRoute(); }
/** * Tests the integration. */ public function testIntegration() { // Remove the watchdog entries added by the potential batch process. $this->container->get('database')->truncate('watchdog')->execute(); $entries = array(); // Setup a watchdog entry without tokens. $entries[] = array('message' => $this->randomMachineName(), 'variables' => array(), 'link' => l('Link', 'node/1')); // Setup a watchdog entry with one token. $entries[] = array('message' => '@token1', 'variables' => array('@token1' => $this->randomMachineName()), 'link' => l('Link', 'node/2')); // Setup a watchdog entry with two tokens. $entries[] = array('message' => '@token1 !token2', 'variables' => array('@token1' => $this->randomMachineName(), '!token2' => $this->randomMachineName()), 'link' => l('<object>Link</object>', 'node/2', array('html' => TRUE))); foreach ($entries as $entry) { $entry += array('type' => 'test-views', 'severity' => WATCHDOG_NOTICE); watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']); } $view = Views::getView('test_dblog'); $this->executeView($view); $view->initStyle(); foreach ($entries as $index => $entry) { $this->assertEqual($view->style_plugin->getField($index, 'message'), String::format($entry['message'], $entry['variables'])); $this->assertEqual($view->style_plugin->getField($index, 'link'), Xss::filterAdmin($entry['link'])); } // Disable replacing variables and check that the tokens aren't replaced. $view->destroy(); $view->initHandlers(); $this->executeView($view); $view->initStyle(); $view->field['message']->options['replace_variables'] = FALSE; foreach ($entries as $index => $entry) { $this->assertEqual($view->style_plugin->getField($index, 'message'), $entry['message']); } }
function blackberry_2016_preprocess_html(&$vars) { if (isset($_POST['token'])) { watchdog('slack access', 'token POST: ' . $_POST['token']); $vars['theme_hook_suggestions'][] = 'html__headless'; } }
/** * 生成签名 * @param req 需要签名的要素 * @return 签名结果字符串 */ function buildSignature($req) { $prestr = createLinkstring($req, true, false); watchdog('back para', 'back para1111:<pre>@para</pre>', array('@para' => print_r($prestr, TRUE))); $prestr = $prestr . upmp_config::QSTRING_SPLIT . md5(upmp_config::$security_key); return md5($prestr); }
function createImageObject($obj_specimen_pid, $obj_jp2URL, $obj_rft_id, $obj_sourceURL, $obj_width, $obj_height, $obj_jpeg_datastream_url, $obj_label) { $this->pid = $this->getNextImagePid(); $this->specimen_pid = $obj_specimen_pid; $this->jp2URL = $obj_jp2URL; $this->rft_id = $obj_rft_id; $this->sourceURL = $obj_sourceURL; $this->width = $obj_width; $this->height = $obj_height; $this->jpeg_datastream_url = $obj_jpeg_datastream_url; if ($obj_label != null && $obj_label != '') { $this->label = $obj_label; } else { $this->label = $this->pid; //We may use something other than the pid for the label eventually } //create relationships $pid_base = 'image'; if ($this->startFOXML()) { if (!$this->addImage_RELS_EXT_datastream()) { echo 'Unable to addImage_RELS_EXT_datastream.<br>'; } if (!$this->addDC_datastream()) { echo 'Unable to addDC_datastream.<br>'; } list($this->width, $this->height) = getimagesize($this->jp2URL); if (!$this->addImageMetadata_datastream()) { echo 'Unable to addImageMetadata_datastream.<br>'; } if (!$this->addJPEG_datastream()) { echo 'Unable to addJPEG_datastream.<br>'; } try { $foxml_file = str_replace(':', '_', $this->pid); $foxml_file = '/var/www/drupal/sites/default/files/apiary_datastreams/' . $foxml_file . '.xml'; if (file_exists($foxml_file)) { unlink($foxml_file); } $this->dom->save($foxml_file); if ($object = ingest_object_from_FOXML($this->dom)) { $this->msg = "{$this->pid} successfully created."; include_once drupal_get_path('module', 'apiary_project') . '/workflow/include/search.php'; $search_instance = new search(); $search_instance->index($this->pid); return true; } else { $this->msg = "Unable to ingest image FOXML dom document."; return false; } } catch (exception $e) { drupal_set_message(t('Error Ingesting Image Object! ') . $e->getMessage(), 'error'); watchdog(t("Fedora_Repository"), "Error Ingesting Image Object!" . $e->getMessage(), WATCHDOG_ERROR); return false; } } else { $this->msg = "Unable to start image FOXML file for create image object."; return false; } return true; }
/** * Render a 403 access denied page for authorize.php */ function authorize_access_denied_page() { drupal_add_http_header('Status', '403 Forbidden'); watchdog('access denied', 'authorize.php', NULL, WATCHDOG_WARNING); drupal_set_title('Access denied'); return t('You are not allowed to access this page.'); }
protected function sendRequest($identifiers) { $ids = array(); foreach ($identifiers as $i) { $ids = array_merge($ids, array_values($i)); } $authInfo = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password); if (preg_match('/moreinfo.addi.dk/', $this->wsdlUrl)) { // New moreinfo service. $client = new SoapClient($this->wsdlUrl . '/moreinfo.wsdl'); $method = 'moreInfo'; } else { // Legacy additionalInformation service. $client = new SoapClient($this->wsdlUrl); $method = 'additionalInformation'; } $startTime = explode(' ', microtime()); $response = $client->{$method}(array('authentication' => $authInfo, 'identifier' => $identifiers)); $stopTime = explode(' ', microtime()); $time = floatval($stopTime[1] + $stopTime[0] - ($startTime[1] + $startTime[0])); //Drupal specific code - consider moving this elsewhere if (variable_get('addi_enable_logging', false)) { watchdog('addi', 'Completed request (' . round($time, 3) . 's): Ids: %ids', array('%ids' => implode(', ', $ids)), WATCHDOG_DEBUG, 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); } if ($response->requestStatus->statusEnum != 'ok') { throw new AdditionalInformationServiceException($response->requestStatus->statusEnum . ': ' . $response->requestStatus->errorText); } if (!is_array($response->identifierInformation)) { $response->identifierInformation = array($response->identifierInformation); } return $response; }
/** * Execute operations before OAuth2 Server sends a token response. * * @param \OAuth2Server|NULL $server * @param \OAuth2\Request $request * @param \OAuth2\Response $response */ function hook_oauth2_server_token($server, \OAuth2\Request $request, \OAuth2\Response $response) { // Example: if the response is not successful, log a message. if ($response->getStatusCode() != 200) { watchdog('mymodule', 'Failed token response from server @server: @code @body', array('@server' => $server ? $server->name : NULL, '@code' => $response->getStatusCode(), '@body' => $response->getResponseBody())); } }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); watchdog('user', 'Role %name has been deleted.', array('%name' => $this->entity->label())); drupal_set_message($this->t('Role %name has been deleted.', array('%name' => $this->entity->label()))); $form_state['redirect_route'] = $this->getCancelUrl(); }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('responsive_image', 'Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->getCancelRoute(); }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label())); drupal_set_message($this->t('Action %action was deleted', array('%action' => $this->entity->label()))); $form_state['redirect_route'] = $this->getCancelUrl(); }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->taxonomyTerm->delete(); drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label()))); watchdog('forum', 'forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->getCancelUrl(); }
/** * Calls a transaction request */ function ideal_payment_api_transreq_call($order) { //Get user ID global $user; if ($user) { $user_id = $user->uid; } $path_module = drupal_get_path('module', 'ideal_payment_api'); require_once $path_module . '/lib/iDEALConnector.php'; $iDEALConnector = new iDEALConnector(); $order['description'] = check_plain($order['description']); if (drupal_strlen($order['description']) > 32) { //@TODO: run this trough a general error handler. $order['description_orig'] = $order['description']; $order['description'] = drupal_substr($order['description'], 0, 32); watchdog('ideal_api', t('iDEAL decription too long. Changed from %orig to %shortened', array('%orig' => $order['description_orig'], '%shortened' => $order['description']))); } //issuerid is min. 4 chars, add leading 0's $order['issuer_id'] = str_pad($order['issuer_id'], 4, '0', STR_PAD_LEFT); //Send TransactionRequest $response = $iDEALConnector->RequestTransaction($order['issuer_id'], $order['order_id'], $order['amount'], $order['description'], $order['order_id'], $iDEALConnector->config['EXPIRATIONPERIOD'], $iDEALConnector->config['MERCHANTRETURNURL']); if (!$response->errCode) { return $response; } else { watchdog('ideal_api', $response->errCode . ': ' . $response->errMsg, NULL, WATCHDOG_ERROR); return $response; } }
function solrmlt_suggestions($block_id, $nid) { try { $solr = apachesolr_get_solr(); $fields = array('mlt.mintf', 'mlt.mindf', 'mlt.minwl', 'mlt.maxwl', 'mlt.maxqt', 'mlt.boost', 'mlt.qf'); $block = apachesolr_mlt_load_block($block_id); $params = array('qt' => 'mlt', 'fl' => 'nid,title,url', 'mlt.fl' => implode(',', $block['mlt_fl'])); foreach ($fields as $field) { $drupal_fieldname = str_replace('.', '_', $field); if (!empty($block[$drupal_fieldname])) { $params[$field] = check_plain($block[$drupal_fieldname]); } } $query = apachesolr_drupal_query('id:' . apachesolr_document_id($nid)); // This hook allows modules to modify the query and params objects. apachesolr_modify_query($query, $params, 'apachesolr_mlt'); if (empty($query)) { return; } $response = $solr->search($query->get_query_basic(), 0, $block['num_results'], $params); if ($response->response) { $docs = (array) end($response->response); } return $docs; } catch (Exception $e) { watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR); } }
/** * {@inheritdoc} */ public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('block_content', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = new Url('block_content.list'); }
public static function log($msg, $data = NULL, $depth = 0, $severity = WATCHDOG_NOTICE, $tag = '') { if ($severity == WATCHDOG_WARNING && variable_get('lingotek_warning_log', self::getDefault())) { return; } else { if (strcasecmp($tag, 'api') == 0 && !variable_get('lingotek_api_debug', self::getDefault())) { return; } } $backtrace = debug_backtrace(); $location = $backtrace[$depth]['file'] . ':' . $backtrace[$depth]['line']; $function = $backtrace[$depth + 1]['function']; $args = @json_encode($backtrace[$depth + 1]['args']); $data_output = ""; if (isset($data)) { $data_output = json_encode($data); } $suffix = is_string($tag) && strlen($tag) ? ' - ' . $tag : ''; $data_array = array(); if (is_array($data)) { foreach ($data as $k => $v) { $data_array[$k] = LingotekLog::format($v); } } watchdog('lingotek' . $suffix, t($msg, $data_array) . ' <div style="word-break: break-all; padding-top: 10px; color: #666;"><b>FUNCTION:</b> %function<br /><b>ARGS:</b> %args<br /><b>FILE:</b> %location<br /><b>MESSAGE:</b> %msg <br /><b>DATA:</b> %data <br /></div>', array('%msg' => $msg, '%data' => $data_output, '%location' => $location, '%function' => $function, '%args' => $args), $severity); if (variable_get('lingotek_error_log', FALSE)) { error_log("FUNCTION: {$function} ARGS: {$args} FILE: {$location} MESSAGE: {$msg} DATA: {$data_output} "); } }
function error_httpd() { global $REDIRECT_STATUS, $REDIRECT_URL, $HTTP_REFERER, $HTTP_USER_AGENT; switch ($REDIRECT_STATUS) { case 500: $message = "500 error - internal server error"; break; case 404: $message = "404 error - `{$REDIRECT_URL}' not found"; break; case 403: $message = "403 error - access denied - forbidden"; break; case 401: $message = "401 error - authorization required"; break; case 401: $message = "400 error - bad request"; break; default: $message = "unknown error"; } watchdog("error", "message: `{$message}' - requested url: {$REDIRECT_URL} - referring url: {$HTTP_REFERER} - user agent: {$HTTP_USER_AGENT}"); print "<PRE>\n"; print "<H1>Oops, an error occured!</H1>\n"; print "<B>Processed output:</B><BR>\n"; print " * {$message}<BR>\n"; print " * Return to the <A HREF=\"index.php\">main page</A>.\n"; print "</PRE>\n"; }