Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitForm($form, $form_state);
     $this->entity->delete();
     drupal_set_message(t('The custom name format %label has been deleted.', array('%label' => $this->entity->label())));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $settings = array('types' => $form_state->getValue('types'));
     $this->currentBundle->setAssignmentSettings(self::METHOD_ID, $settings)->save();
     $this->setRedirect($form_state);
     drupal_set_message($this->t('Package assignment configuration saved.'));
 }
Ejemplo n.º 3
0
/**
 * Preprocessor for theme('page').
 */
function rubik_preprocess_page(&$vars)
{
    // Show a warning if base theme is not present.
    if (!function_exists('tao_theme') && user_access('administer site configuration')) {
        drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://code.developmentseed.org/tao'))), 'warning');
    }
    // Set a page icon class.
    $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ', _rubik_icon_classes($item['href'])) : '';
    // Help pages. They really do need help.
    if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) {
        $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup']));
    }
    // Clear out help text if empty.
    if (empty($vars['help']) || !strip_tags($vars['help'])) {
        $vars['help'] = '';
    }
    // Process local tasks. Only do this processing if the current theme is
    // indeed Rubik. Subthemes must reimplement this call.
    global $theme;
    if ($theme === 'rubik') {
        _rubik_local_tasks($vars);
    }
    // Overlay is enabled.
    $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
}
  function edit() {
    $form_state = array(
      'display' => &$this->display,
      'renderer' => &$this,
      'content_types' => $this->cache->content_types,
      'no_redirect' => TRUE,
      'display_title' => !empty($this->cache->display_title),
      'cache key' => $this->display->cache_key,
    );

    $output = drupal_build_form('panels_edit_display_form', $form_state);
    if (empty($form_state['executed']) || !empty($form_state['clicked_button']['preview'])) {
      return $output;
    }

    if (!empty($form_state['clicked_button']['#save-display'])) {
      drupal_set_message(t('Panel content has been updated.'));
      panels_save_display($this->display);
    }
    else {
      drupal_set_message(t('Your changes have been discarded.'));
    }

    panels_cache_clear('display', $this->display->did);
    return $this->display;
  }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->page->removeAccessCondition($this->accessCondition->getConfiguration()['uuid']);
     $this->page->save();
     drupal_set_message($this->t('The access condition %name has been removed.', ['%name' => $this->accessCondition->getPluginDefinition()['label']]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $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())));
     $this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
Ejemplo n.º 7
0
function notificationForm_submit($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $OID = $params['OID'];
    // generate the notification
    $notification = getFields(array('dateTargeted', 'message'), $form_state['values']);
    $notification = stripTags($notification);
    // allow some tags
    $notification['dateTargeted'] = dbDatePHP2SQL(strtotime($notification['dateTargeted']));
    $notification['bttnTitle'] = 'View Outreach';
    $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
    $notification['OID'] = $OID;
    $notification['TID'] = dbGetTeamForOutreach($OID);
    $notification['dateCreated'] = dbDatePHP2SQL(time());
    foreach ($form_state['values']['UID'] as $UID) {
        if ($UID != null) {
            $notification['UID'] = $UID;
            $result = dbAddNotification($notification);
        }
    }
    if ($result) {
        drupal_set_message('Notification added!');
        drupal_goto('manageNotifications', array('query' => array('OID' => $OID)));
    } else {
        drupal_set_message('There was an error.', 'error');
    }
}
 /**
  * @see LTIToolProviderOutcomesResourceEntityControllerInterface::save
  */
 public function save($entity)
 {
     $transaction = db_transaction();
     try {
         $entity->is_new = empty($enity->lti_tool_provider_outcomes_resource_id);
         if (empty($entity->lti_tool_provider_outcomes_resource_timestamp_created)) {
             $entity->lti_tool_provider_outcomes_resource_timestamp_created = REQUEST_TIME;
         }
         field_attach_presave('lti_tool_provider_outcomes_resource', $entity);
         $primary_key = $entity->lti_tool_provider_outcomes_resource_id ? 'lti_tool_provider_outcomes_resource_id' : array();
         if (empty($primary_key)) {
             drupal_write_record('lti_tool_provider_outcomes_resource', $entity);
             field_attach_insert('lti_tool_provider_outcomes_resource', $entity);
             $op = 'insert';
         } else {
             drupal_write_record('lti_tool_provider_outcomes_resource', $entity, $primary_key);
             $op = 'update';
         }
         $function = 'field_attach_' . $op;
         $function('lti_tool_provider_outcomes_resource', $entity);
         module_invoke_all('entity_' . $op, $entity, 'lti_tool_provider_outcomes_resource');
         unset($entity->is_new);
         db_ignore_slave();
         return $entity;
     } catch (Exception $e) {
         $transaction->rollback();
         drupal_set_message(t('%e', array('%e' => $entity->{$e})));
         watchdog_exception('lti_tool_provider_outcomes_resource', $e, NULL, WATCHDOG_ERROR);
         return FALSE;
     }
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->page->removeVariant($this->displayVariant->id());
     $this->page->save();
     drupal_set_message($this->t('The display variant %name has been removed.', ['%name' => $this->displayVariant->label()]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function submit(array $form, array &$form_state)
 {
     // Delete and set message
     $this->entity->delete();
     drupal_set_message($this->t('The siren mapper @label has been deleted', array('@label' => $this->entity->name)));
     $form_state['redirect_route'] = $this->getCancelRoute();
 }
Ejemplo n.º 12
0
 public function fetch()
 {
     $this->query = $this->url . '?pid=' . $this->pid . '&noredirect=true&format=unixref&id=doi%3A' . $this->doi;
     $request_options = array('method' => 'POST');
     $result = drupal_http_request($this->query, $request_options);
     if ($result->code != 200) {
         drupal_set_message(t('HTTP error: !error when trying to contact crossref.org for XML input', array('!error' => $result->code)), 'error');
         return;
     }
     if (empty($result->data)) {
         drupal_set_message(t('Did not get any data from crossref.org'), 'error');
         return;
     }
     $sxml = @simplexml_load_string($result->data);
     if ($error = (string) $sxml->doi_record->crossref->error) {
         drupal_set_message($error, 'error');
         return;
     }
     $this->nodes = array();
     $this->parser = drupal_xml_parser_create($result->data);
     // use case-folding so we are sure to find the tag in
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, FALSE);
     xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, TRUE);
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, 'unixref_startElement', 'unixref_endElement');
     xml_set_character_data_handler($this->parser, 'unixref_characterData');
     if (!xml_parse($this->parser, $result->data)) {
         drupal_set_message(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)), 'error');
     }
     xml_parser_free($this->parser);
     return $this->node;
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $account = $this->entity;
     $account->save();
     $form_state->setValue('uid', $account->id());
     drupal_set_message($this->t('The changes have been saved.'));
 }
Ejemplo n.º 14
0
 /**
  * 'upload_zip' upload field must refer to a zip file containing 
  *   all files for the pubnode (may be at top-level or inside a subdirectory)
  */
 public function import(&$form_state, $docid = NULL)
 {
     $validators = array('file_validate_extensions' => array('zip'), 'file_validate_size' => array(100000000, 0));
     if ($file = file_save_upload($this->fieldname, $validators, file_directory_temp(), FILE_EXISTS_REPLACE)) {
         $zip = new ZipArchive();
         if ($zip->open($file->filepath) !== TRUE) {
             form_set_error(t("Cannot open !file", array("!file" => $file->filename)), 'error');
             return FALSE;
         }
         // else
         if (empty($docid)) {
             $docid = $this->hashFile($file->filepath);
         }
         $pubpath = $this->constructPubPath($docid);
         //drupal_set_message("PUBPATH: " . $pubpath);
         file_check_directory($pubpath, FILE_CREATE_DIRECTORY);
         $zip->extractTo($pubpath);
         drupal_set_message(t("Extracted !num files to directory !dir", array('!num' => $zip->numFiles, '!dir' => $pubpath)));
         $zip->close();
         $this->pubpath = $pubpath;
         return TRUE;
     }
     // else validations failed and error message will be set by upload function
     return FALSE;
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $_SESSION['dblog_overview_filter'] = array();
     $this->connection->delete('watchdog')->execute();
     drupal_set_message($this->t('Database log cleared.'));
     $form_state['redirect_route'] = $this->getCancelRoute();
 }
Ejemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\quiz\Entity\Quiz */
     /* @var $question \Drupal\quiz\Entity\Question */
     /* @var $answer \Drupal\quiz\Entity\Answer */
     /* @var $state \Drupal\quiz\Entity\UserQuizStatus */
     $entity = $this->entity;
     $questions = $entity->getQuestions();
     $answerCount = 0;
     $questionCount = 0;
     $stateCount = 0;
     foreach ($questions as $question) {
         $answers = $question->getAnswers();
         foreach ($answers as $answer) {
             $answerCount++;
             $answer->delete();
         }
         $questionCount++;
         $question->delete();
     }
     $states = $entity->getStatuses();
     foreach ($states as $state) {
         $stateCount++;
         $state->delete();
     }
     $this->entity->delete();
     drupal_set_message($this->t('Deleted Quiz @label, @answers answers, @questions questions and @states quiz attempts.', ['@label' => $this->entity->label(), '@answers' => $answerCount, '@questions' => $questionCount, '@states' => $stateCount]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
Ejemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     $this->entity->delete();
     $this->logger('user')->notice('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->setRedirectUrl($this->getCancelUrl());
 }
 /**
  * Form submit handler for mollom_report_form().
  */
 public function submit($form, &$form_state)
 {
     if ($form_state['values']['confirm']) {
         $entity = $form_state['values']['entity'];
         $id = $form_state['values']['id'];
         // Load the Mollom session data.
         $data = mollom_data_load($entity, $id);
         // Send feedback to Mollom, if we have session data.
         if ((!empty($data->contentId) || !empty($data->captchaId)) && !empty($form_state['values']['mollom']['feedback'])) {
             if (_mollom_send_feedback($data, $form_state['values']['mollom']['feedback'], 'moderate', 'mollom_report_form_submit')) {
                 drupal_set_message(t('The content was successfully reported as inappropriate.'));
             }
         }
         // Delete the content. The callback should take care of proper deletion and
         // cache clearing on its own.
         foreach (mollom_form_list() as $form_id => $info) {
             if (!isset($info['entity']) || $info['entity'] != $entity) {
                 continue;
             }
             // If there is a 'report delete callback', invoke it.
             if (isset($info['report delete callback']) && function_exists($info['report delete callback'])) {
                 $function = $info['report delete callback'];
                 $function($entity, $id);
                 break;
             }
         }
         $form_state['redirect'] = '<front>';
     }
 }
function shareaholic_advanced_settings_form_submit($form, &$form_state)
{
    if (ShareaholicUtilities::has_tos_and_apikey()) {
        ShareaholicUtilities::update_options(array('disable_og_tags' => $form_state['values']['disable_og_tags'] === 1 ? 'on' : 'off', 'disable_internal_share_counts_api' => $form_state['values']['disable_internal_share_counts_api'] === 1 ? 'on' : 'off'));
        drupal_set_message(t('Settings Saved: please clear your cache.'), 'status');
    }
}
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $modules = array_filter($form_state['values']['list']);
     $this->moduleHandler->uninstall($modules, FALSE);
     $this->moduleHandler->install($modules, FALSE);
     drupal_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules))));
 }
Ejemplo n.º 21
0
 function list_form(&$form, &$form_state)
 {
     ctools_include('stylizer');
     parent::list_form($form, $form_state);
     $all = array('all' => t('- All -'));
     if (empty($this->base_types)) {
         // Give a warning about the missing base styles.
         drupal_set_message($this->plugin['strings']['message']['missing base type'], 'warning');
     }
     $types = $all;
     foreach ($this->base_types as $module => $info) {
         foreach ($info as $key => $base_type) {
             $types[$module . '-' . $key] = $base_type['title'];
         }
     }
     $form['top row']['type'] = array('#type' => 'select', '#title' => t('Type'), '#options' => $types, '#default_value' => 'all', '#weight' => -10, '#attributes' => array('class' => array('ctools-auto-submit')));
     $plugins = ctools_get_style_bases();
     $form_state['style_plugins'] = $plugins;
     $options = $all;
     // @todo base should use $module . '-' . $name
     foreach ($plugins as $name => $plugin) {
         $options[$name] = $plugin['title'];
     }
     $form['top row']['base'] = array('#type' => 'select', '#title' => t('Base'), '#options' => $all + $options, '#default_value' => 'all', '#weight' => -9, '#attributes' => array('class' => array('ctools-auto-submit')));
 }
 /**
  * Purges cache tags on CloudFlare.
  *
  * @todo Once https://github.com/d8-contrib-modules/cloudflare/issues/16 is
  *   done, this should disappear.
  *
  * @param string[] $tags
  *   The list of tags for which to invalidate cache items.
  */
 public function purgeTags(array $tags)
 {
     $config = \Drupal::config('cloudflare.settings');
     $api_key = $config->get('apikey');
     $email = $config->get('email');
     $zone = $config->get('zone');
     // If the module is not yet configured, don't attempt to purge.
     // @todo Improve the rest of the architecture of this module so this check
     //   is not necessary anymore.
     if (!isset($api_key)) {
         return;
     }
     try {
         $this->zoneApi = new ZoneApi($api_key, $email);
         // @todo rethink how to handle cloudflare zones in Drupal.
         if (is_null($zone)) {
             $zones = $this->zoneApi->listZones();
             $zone = $zones[0]->getZoneId();
         }
         $this->zoneApi->purgeTags($zone, $tags);
     } catch (CloudFlareHttpException $e) {
         drupal_set_message("Unable to clear zone cache. " . $e->getMessage(), 'error');
         \Drupal::logger('cloudflare')->error($e->getMessage());
         return;
     } catch (CloudFlareApiException $e) {
         drupal_set_message("Unable to clear zone cache. " . $e->getMessage(), 'error');
         \Drupal::logger('cloudflare')->error($e->getMessage());
         return;
     }
     // If no exceptions have been thrown then the request has been successful.
 }
Ejemplo n.º 23
0
 /**
  * The basic functionality of drupal_set_message().
  */
 public function testDrupalSetMessage()
 {
     drupal_set_message(t('A message: @foo', ['@foo' => 'bar']));
     $messages = drupal_get_messages();
     $this->assertInstanceOf('Drupal\\Core\\Render\\Markup', $messages['status'][0]);
     $this->assertEquals('A message: bar', (string) $messages['status'][0]);
 }
Ejemplo n.º 24
0
/**
 * Initialize theme settings if needed
 */
function fusion_core_initialize_theme_settings($theme_name)
{
    $theme_settings = theme_get_settings($theme_name);
    if (!isset($theme_settings['primary_menu_dropdown']) || $theme_settings['rebuild_registry'] == 1) {
        static $registry_rebuilt = false;
        // avoid multiple rebuilds per page
        // Rebuild theme registry & notify user
        if (isset($theme_settings['rebuild_registry']) && $theme_settings['rebuild_registry'] == 1 && !$registry_rebuilt) {
            drupal_rebuild_theme_registry();
            drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning');
            $registry_rebuilt = true;
        }
        // Retrieve saved or site-wide theme settings
        $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings');
        $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings();
        // Skip toggle_node_info_ settings
        if (module_exists('node')) {
            foreach (node_get_types() as $type => $name) {
                unset($settings['toggle_node_info_' . $type]);
            }
        }
        // Combine default theme settings from .info file & theme-settings.php
        $theme_data = list_themes();
        // get theme data for all themes
        $info_theme_settings = $theme_name ? $theme_data[$theme_name]->info['settings'] : array();
        $defaults = array_merge(fusion_core_default_theme_settings(), $info_theme_settings);
        // Set combined default & saved theme settings
        variable_set($theme_setting_name, array_merge($defaults, $settings));
        // Force theme settings refresh
        theme_get_setting('', TRUE);
    }
}
 /**
  * {@inheritdoc}
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     $this->entity->delete();
     drupal_set_message($this->t('Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label())));
     $this->logger('responsive_image')->notice('Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label()));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
Ejemplo n.º 26
0
/**
 * Initialize theme settings if needed
 */
function fusion_core_initialize_theme_settings($theme_name)
{
    $theme_settings = theme_get_settings($theme_name);
    if (is_null($theme_settings['theme_font_size']) || $theme_settings['rebuild_registry'] == 1) {
        // Rebuild theme registry & notify user
        if ($theme_settings['rebuild_registry'] == 1) {
            drupal_rebuild_theme_registry();
            drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning');
        }
        // Retrieve saved or site-wide theme settings
        $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings');
        $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings();
        // Skip toggle_node_info_ settings
        if (module_exists('node')) {
            foreach (node_get_types() as $type => $name) {
                unset($settings['toggle_node_info_' . $type]);
            }
        }
        // Retrieve default theme settings
        $defaults = fusion_core_default_theme_settings();
        // Set combined default & saved theme settings
        variable_set($theme_setting_name, array_merge($defaults, $settings));
        // Force theme settings refresh
        theme_get_setting('', TRUE);
    }
}
Ejemplo n.º 27
0
 /**
  * Remove the record IF there are no records referencing this user.
  */
 function updateDatabase($form, $myvalues)
 {
     //Perform some data quality checks now.
     if (!isset($myvalues['protocol_shortname'])) {
         die("Cannot delete record because missing protocol_shortname in array!\n" . var_dump($myvalues));
     }
     $updated_dt = date("Y-m-d H:i", time());
     $protocol_shortname = $myvalues['protocol_shortname'];
     //Backup all the existing records.
     $this->m_oPageHelper->copyProtocolLibToReplacedTable($protocol_shortname);
     $this->m_oPageHelper->copyKeywordsToReplacedTable($protocol_shortname);
     $this->m_oPageHelper->copyTemplateValuesToReplacedTable($protocol_shortname);
     //Delete all the records.
     $num_deleted = db_delete('raptor_protocol_lib')->condition('protocol_shortname', $protocol_shortname)->execute();
     $num_deleted = db_delete('raptor_protocol_keywords')->condition('protocol_shortname', $protocol_shortname)->execute();
     $num_deleted = db_delete('raptor_protocol_template')->condition('protocol_shortname', $protocol_shortname)->execute();
     //Success?
     if ($num_deleted == 1) {
         $feedback = 'The ' . $protocol_shortname . ' protocol has been succesfully deleted.';
         drupal_set_message($feedback);
         return 1;
     }
     //We are here because we failed.
     $feedback = 'Trouble deleting ' . $protocol_shortname . ' protocol!';
     error_log($feedback . ' delete reported ' . $num_deleted);
     drupal_set_message($feedback, 'warning');
     return 0;
 }
Ejemplo n.º 28
0
function update_script_selection_form($form, &$form_state)
{
    $count = 0;
    $incompatible_count = 0;
    $form['start'] = array('#tree' => TRUE, '#type' => 'fieldset', '#collapsed' => TRUE, '#collapsible' => TRUE);
    // Ensure system.module's updates appear first.
    $form['start']['system'] = array();
    $updates = update_get_update_list();
    $starting_updates = array();
    $incompatible_updates_exist = FALSE;
    foreach ($updates as $module => $update) {
        if (!isset($update['start'])) {
            $form['start'][$module] = array('#title' => $module, '#item' => $update['warning'], '#prefix' => '<div class="warning">', '#suffix' => '</div>');
            $incompatible_updates_exist = TRUE;
            continue;
        }
        if (!empty($update['pending'])) {
            $starting_updates[$module] = $update['start'];
            $form['start'][$module] = array('#type' => 'hidden', '#value' => $update['start']);
            $form['start'][$module . '_updates'] = array('#theme' => 'item_list', '#items' => $update['pending'], '#title' => $module . ' module');
        }
        if (isset($update['pending'])) {
            $count = $count + count($update['pending']);
        }
    }
    // Find and label any incompatible updates.
    foreach (update_resolve_dependencies($starting_updates) as $function => $data) {
        if (!$data['allowed']) {
            $incompatible_updates_exist = TRUE;
            $incompatible_count++;
            $module_update_key = $data['module'] . '_updates';
            if (isset($form['start'][$module_update_key]['#items'][$data['number']])) {
                $text = $data['missing_dependencies'] ? 'This update will been skipped due to the following missing dependencies: <em>' . implode(', ', $data['missing_dependencies']) . '</em>' : "This update will be skipped due to an error in the module's code.";
                $form['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
            }
            // Move the module containing this update to the top of the list.
            $form['start'] = array($module_update_key => $form['start'][$module_update_key]) + $form['start'];
        }
    }
    // Warn the user if any updates were incompatible.
    if ($incompatible_updates_exist) {
        drupal_set_message('Some of the pending updates cannot be applied because their dependencies were not met.', 'warning');
    }
    if (empty($count)) {
        drupal_set_message(t('No pending updates.'));
        unset($form);
        $form['links'] = array('#markup' => theme('item_list', array('items' => update_helpful_links())));
    } else {
        $form['help'] = array('#markup' => '<p>The version of Drupal you are updating from has been automatically detected.</p>', '#weight' => -5);
        if ($incompatible_count) {
            $form['start']['#title'] = format_plural($count, '1 pending update (@number_applied to be applied, @number_incompatible skipped)', '@count pending updates (@number_applied to be applied, @number_incompatible skipped)', array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count));
        } else {
            $form['start']['#title'] = format_plural($count, '1 pending update', '@count pending updates');
        }
        $form['has_js'] = array('#type' => 'hidden', '#default_value' => FALSE);
        $form['actions'] = array('#type' => 'actions');
        $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Apply pending updates');
    }
    return $form;
}
Ejemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     uc_payment_enter($form_state->getValue('order_id'), 'check', $form_state->getValue('amount'), $this->currentUser()->id(), '', $form_state->getValue('comment'));
     db_insert('uc_payment_check')->fields(array('order_id' => $form_state->getValue('order_id'), 'clear_date' => mktime(12, 0, 0, $form_state->getValue('clear_month'), $form_state->getValue('clear_day'), $form_state->getValue('clear_year'))))->execute();
     drupal_set_message($this->t('Check received, expected clear date of @date.', ['@date' => uc_date_format($form_state->getValue('clear_month'), $form_state->getValue('clear_day'), $form_state->getValue('clear_year'))]));
     $form_state->setRedirect('uc_order.admin_view', ['uc_order' => $form_state->getValue('order_id')]);
 }
Ejemplo n.º 30
0
/**
 * Preprocessor for theme('page').
 */
function rubik_preprocess_page(&$vars)
{
    // Show a warning if base theme is not present.
    if (!function_exists('tao_theme') && user_access('administer site configuration')) {
        drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://code.developmentseed.org/tao'))), 'warning');
    }
    // Split page content & content blocks.
    $vars['content_region'] = theme('blocks_content', TRUE);
    // Set a page icon class.
    $vars['page_icon_class'] = ($item = menu_get_item()) ? _rubik_icon_classes($item['href']) : '';
    // Add body class for theme.
    $vars['attr']['class'] .= ' rubik';
    // Body class for admin module.
    $vars['attr']['class'] .= ' admin-static';
    // Help pages. They really do need help.
    if (strpos($_GET['q'], 'admin/help/') === 0) {
        $vars['content'] = theme('help_page', $vars['content']);
    }
    // Display user account links.
    $vars['user_links'] = _rubik_user_links();
    // Help text toggler link.
    $vars['help_toggler'] = l(t('Help'), $_GET['q'], array('attributes' => array('id' => 'help-toggler', 'class' => 'toggler'), 'fragment' => 'help-text'));
    // Clear out help text if empty.
    if (empty($vars['help']) || !strip_tags($vars['help'])) {
        $vars['help'] = '';
    }
}