Skip to content

Commit

Permalink
- Implemented page redirection based on language switch
Browse files Browse the repository at this point in the history
- Fixed "Filter redundant emails in teams": https://www.labdoo.org/content/filter-redundant-mails-team-messages
- Fixed "Generated links of dootrips still keep old data even data was updated": https://www.labdoo.org/content/generated-links-dootrips-still-keep-old-data-even-data-was-updated
- Fixed a bug which prevented other teams to receive messages when multiple teams were selected in a conversation
- Increased page size to display dashboard results from 50 to 250
- Improved view of dashboards for small devices like mobile phone and tablets
- Added new/improved descriptions and links to the dashboard to help users zoom into and get more detail out of them.
- Made some descriptions translatable
  • Loading branch information
jrosgiralt committed Aug 2, 2017
1 parent 0b0663b commit 3c088d5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 24 deletions.
48 changes: 43 additions & 5 deletions modules/custom/labdoo_lib/labdoo_lib.module
Expand Up @@ -2120,7 +2120,6 @@ function labdoo_lib_node_access($node, $op, $account) {
return NODE_ACCESS_IGNORE;
}


/**
* Implements hook_node_view
*
Expand All @@ -2129,6 +2128,8 @@ function labdoo_lib_node_view($node, $view_mode) {
global $language;
global $user;

$path = drupal_get_path_alias(current_path());

// TODO DE-COLORBOX: temporary fix. This forces a redirect of all photo galleries in German language
// to the default language English, because there is a bug that prevents them from loading the
// colorbox slideshow. We also add a URL parameter 'lan=de' so that the links in the photo album
Expand All @@ -2137,9 +2138,27 @@ function labdoo_lib_node_view($node, $view_mode) {
// See also https://www.labdoo.org/content/slideshow-feature-does-not-work-german-de-language
if($language->language == 'de' && $node->type == 'node_gallery_gallery' && $view_mode == 'full' && arg(0) == 'node') {
$options = array('query' => array('lan' => 'de'));
drupal_goto('../' . drupal_get_path_alias("node/" . $node->nid), $options);
drupal_goto('../' . $path, $options);
}

// Add to this table any necessary redirects.
// Follow the examples to add new entries.
$labdoo_lib_page_redirects = [
"ca/content/about-labdoo" => "content/sobre-labdoo", // per language redirect
"de/content/about-labdoo" => "content/zu-labdoo",
"content/zu-labdoo" => "LabdooD" // redirect for all languages
];

// Perform any page redirect if needed
if($language->language == "en")
$extended_path = $path;
else
$extended_path = $language->language . "/" . $path;
if(array_key_exists($extended_path, $labdoo_lib_page_redirects))
drupal_goto($labdoo_lib_page_redirects[$extended_path]);
else if(array_key_exists($path, $labdoo_lib_page_redirects))
drupal_goto($labdoo_lib_page_redirects[$path]);

if($node->type == 'laptop') {
$method = '';
$dooject = '';
Expand Down Expand Up @@ -2169,7 +2188,6 @@ function labdoo_lib_node_view($node, $view_mode) {
// Handle page redirects here

$languages = language_list();
$path = drupal_get_path_alias(current_path());

if(($node->type == 'edoovillage') && (strcmp($path, "edoovillage") != 0) && ($view_mode == 'full')) {
drupal_goto('edoovillage', array('language' => $languages[$language->language], 'query' => array('e' => $node->nid)));
Expand Down Expand Up @@ -4336,11 +4354,31 @@ function labdoo_lib_cron() {
/*
* Converts a string into an HTML link
*
* @param string The string
* @return The html code
* @param string $link
* The link
* @return string
* The HTML code
*
*/
function labdoo_lib_convert_html_link($link) {
return "<a href=$link>" . $link . "</a>";
}


/*
* Generates an HTML link of a node from its ID
*
* @param integer $nid
* The node ID
* @param string $text
* The text to display in the HTML link
* @return string
* The HTML code of the link
*
*/

function labdoo_lib_generate_html_link_from_nid($nid, $text) {
$url = url('node/'. $nid, array('absolute' => TRUE, 'alias' => TRUE));
return "<a href=$url>" . $text . "</a>";
}

30 changes: 16 additions & 14 deletions modules/custom/lbd_communicate/lbd_communicate.module
Expand Up @@ -90,6 +90,10 @@ function _partition_email_params($emailString) {
function lbd_communicate_mail_send($email_params) {
global $user;

// Remove email address duplicates
if(array_key_exists('headers', $email_params) && array_key_exists('Bcc', $email_params['headers']))
$email_params['headers']['Bcc'] = implode(',', array_unique(explode(',', $email_params['headers']['Bcc'])));

if(array_key_exists('headers', $email_params) && array_key_exists('Bcc', $email_params['headers'])) {
// Throttle the amount of email sent out to a maximum of LBD_COMM_MAX_EMAILS_BATCH emails
// and have the rest be processed in the next cron job.
Expand Down Expand Up @@ -311,10 +315,9 @@ function _email_laptop_event($node) {
$params["STATUS"] = $statusLabels[$newStatus] . $extraInfo;
$params["LAPTOP_URL"] = url(drupal_get_path_alias('content/'. $laptopId), array('absolute' => TRUE));
$params["LAPTOP_URL"] = labdoo_lib_convert_html_link($params["LAPTOP_URL"]);
$params["EDOOVILLAGE_URL"] = url(drupal_get_path_alias('node/'. $edoovillageNid), array('absolute' => TRUE));
$params["EDOOVILLAGE_URL"] = labdoo_lib_convert_html_link($params["EDOOVILLAGE_URL"]);
$params["EDOOVILLAGE_URL"] = labdoo_lib_generate_html_link_from_nid($edoovillageNid, lbd_nodeid2title($edoovillageNid));
$params["CONTACT_EMAIL"] = variable_get('site_mail', '');
$params["DASHBOARD_URL"] = $base_url . '/content/dashboard-slider';
$params["DASHBOARD_URL"] = $base_url . '/content/getting-started';
$params["DASHBOARD_URL"] = labdoo_lib_convert_html_link($params["DASHBOARD_URL"]);
$body = $bodyTemplate;
_body_do_parameters($params, $body);
Expand Down Expand Up @@ -420,10 +423,9 @@ function _email_dootrip_event($node, $eventType) {
$subject = preg_replace('/^\[Labdoo\] - /', '[Labdoo] ', trim($subject));

$params["DOOTRIP_TITLE"] = $dootripTitle;
$params["DOOTRIP_URL"] = url(drupal_get_path_alias('node/' . $dootripNid), array('absolute' => TRUE));
$params["DOOTRIP_URL"] = labdoo_lib_convert_html_link($params["DOOTRIP_URL"]);
$params["DOOTRIP_URL"] = labdoo_lib_generate_html_link_from_nid($dootripNid, $dootripTitle);
$params["CONTACT_EMAIL"] = variable_get('site_mail', '');
$params["DASHBOARD_URL"] = $base_url . '/content/dashboard-slider';
$params["DASHBOARD_URL"] = $base_url . '/content/getting-started';
$params["DASHBOARD_URL"] = labdoo_lib_convert_html_link($params["DASHBOARD_URL"]);
$body = $bodyTemplate;
_body_do_parameters($params, $body);
Expand Down Expand Up @@ -451,10 +453,9 @@ function _email_dootrip_event($node, $eventType) {
$bodyTemplate = file_get_contents($bodyFileName);

$params["NOTTYPE"] = "dootrip_announce";
$params["DOOTRIP_URL"] = url(drupal_get_path_alias('node/' . $dootripNid), array('absolute' => TRUE));
$params["DOOTRIP_URL"] = labdoo_lib_convert_html_link($params["DOOTRIP_URL"]);
$params["DOOTRIP_URL"] = labdoo_lib_generate_html_link_from_nid($dootripNid, $dootripTitle);
$params["CONTACT_EMAIL"] = variable_get('site_mail', '');
$params["DASHBOARD_URL"] = $base_url . '/content/dashboard-slider';
$params["DASHBOARD_URL"] = $base_url . '/content/getting-started';
$params["DASHBOARD_URL"] = labdoo_lib_convert_html_link($params["DASHBOARD_URL"]);
$body = $bodyTemplate;
_body_do_parameters($params, $body);
Expand Down Expand Up @@ -534,8 +535,9 @@ function _email_team_event($node, $comment = NULL) {
}
$activityTitle = $node->title;
$teamId = labdoo_lib_get_field($node, 'og_group_ref', 'node', 'target_id');
$teamIdAll = labdoo_lib_get_field_all($node, 'og_group_ref', 'node', 'target_id') +
labdoo_lib_get_field_all($node, 'field_additional_teams', 'node', 'target_id');
$teamIdAll = labdoo_lib_get_field_all($node, 'og_group_ref', 'node', 'target_id');
if(property_exists($node, 'field_additional_teams'))
$teamIdAll = array_merge($teamIdAll, labdoo_lib_get_field_all($node, 'field_additional_teams', 'node', 'target_id'));

$team = node_load($teamId);
$teamName = $team->title;
Expand Down Expand Up @@ -589,6 +591,7 @@ function _email_team_event($node, $comment = NULL) {
$emailsList = $emailsList . ", " . $userObj->mail;
}
}

// Add additional users based on the 'send to' field
if(property_exists($node, $sendToFieldName)) {
if($node->$sendToFieldName) {
Expand Down Expand Up @@ -765,7 +768,7 @@ function lbd_communicate_user_insert(&$edit, $account, $category) {
$subject = $subjectTemplate;

$params["LABDOOUSER"] = $edit['name'];
$params["DASHBOARD_URL"] = $base_url . '/content/dashboard-slider';
$params["DASHBOARD_URL"] = $base_url . '/content/getting-started';
$body = $bodyTemplate;
_body_do_parameters($params, $body);

Expand Down Expand Up @@ -955,8 +958,7 @@ function lbd_communicate_cron() {
$subject = preg_replace('/^- /', '', trim($subject));

$params["DOOTRIP_TITLE"] = $dootripTitle;
$params["DOOTRIP_URL"] = url(drupal_get_path_alias('node/' . $dootripNid), array('absolute' => TRUE));
$params["DOOTRIP_URL"] = labdoo_lib_convert_html_link($params["DOOTRIP_URL"]);
$params["DOOTRIP_URL"] = labdoo_lib_generate_html_link_from_nid($dootripNid, $dootripTitle);
$params["CONTACT_EMAIL"] = variable_get('site_mail', '');
$body = $bodyTemplate;
_body_do_parameters($params, $body);
Expand Down
22 changes: 18 additions & 4 deletions modules/custom/lbd_visualize/lbd_visualize.module
Expand Up @@ -1134,7 +1134,7 @@ var table = new google.visualization.ChartWrapper({
'allowHtml': true,
'showRowNumber': true,
'page': 'enable',
'pageSize' : 50,
'pageSize' : 250,
'sortColumn' : 0,
'sortAscending' : false,
'sort' : 'enable'
Expand Down Expand Up @@ -1527,7 +1527,10 @@ function lbd_display_slider_edoovilage_doojects($edoovillageId = NULL) {
if($loadedNode->type != "edoovillage")
return;

print("<a href='content/about-dootronics' target='_blank'>[Click here for help about dootronics]</a><br/><hr/>");
print("<a href='content/about-dootronics' target='_blank'>" . t("[Click here for help about dootronics]") . "</a><br/><hr/>");
print("<a href='content/dootronics-dashboard?e=$edoovillageId' target='_blank'>" .
t("[Click here to see in detail all the dootronics for this edoovillage]") . "</a><br/><hr/>");


// Render the download button
$viewResult = views_get_view_result('slider_dashboard', 'block_edoovillage_doojects', $edoovillageId);
Expand Down Expand Up @@ -1560,6 +1563,10 @@ function lbd_display_slider_edoovilage_metrics($edoovillageId) {
return;

print("<a href='content/visualization-dashboards' target='_blank'>[Click here to learn more about visualizing metrics]</a><br/><hr/>");
print("<a href='content/dootronics-dashboard?e=$edoovillageId' target='_blank'>" .
t("[Click here to expand the results of this dashboard]") . "</a><br/><hr/>");


lbd_display_dashboard_doojects(NULL, NULL, $edoovillageId, NULL, FALSE);

return;
Expand Down Expand Up @@ -1804,7 +1811,10 @@ function lbd_display_slider_hub_edoovillages($hubId) {
if($loadedNode->type != "hub")
return;

print("<a href='content/managing-edoovillages' target='_blank'>[Click here for help about edoovillages]</a><br/><hr/>");
print("<a href='content/managing-edoovillages' target='_blank'>" . t("[Click here for help about edoovillages]") . "</a><br/><hr/>");
print("<a href='content/edoovillages-dashboard?h=$hubId' target='_blank'>" .
t("[Click here to see in detail all the edoovillages managed by this hub]") . "</a><br/><hr/>");


// Render the download button
$viewResult = views_get_view_result('slider_dashboard', 'block_hub_edoovillages', $hubId);
Expand Down Expand Up @@ -1843,7 +1853,9 @@ function lbd_display_slider_hub_doojects($hubId) {

$block = module_invoke('views', 'block_view', 'slider_dashboard-block_hub_doojects');

print("<a href='content/about-dootronics' target='_blank'>[Click here for help about dootronics]</a><br/><hr/>");
print("<a href='content/about-dootronics' target='_blank'>" . t("[Click here for help about dootronics]") . "</a><br/><hr/>");
print("<a href='content/dootronics-dashboard?h=$hubId' target='_blank'>" .
t("[Click here to see in detail all the dootronics for this hub]") . "</a><br/><hr/>");

// Render the download button
$viewResult = views_get_view_result('slider_dashboard', 'block_hub_doojects', $hubId);
Expand Down Expand Up @@ -1875,6 +1887,8 @@ function lbd_display_slider_hub_metrics($hubId) {
return;

print("<a href='content/visualization-dashboards' target='_blank'>[Click here to learn more about visualizing metrics]</a><br/><hr/>");
print("<a href='content/dootronics-dashboard?h=$hubId' target='_blank'>" .
t("[Click here to expand the results of this dashboard]") . "</a><br/><hr/>");
lbd_display_dashboard_doojects(NULL, $hubId, NULL, NULL, FALSE);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap1/css/style.css
Expand Up @@ -70,7 +70,7 @@ h2.block-title {

#dashboard_slider_body
{
height: 7500px;
/* height: 7500px; */
}

.actions-feed-time
Expand Down

0 comments on commit 3c088d5

Please sign in to comment.