'Terminos y condiciones de los portales', 'description' => 'Terminos y condiciones de los portales', 'page callback' => 'drupal_get_form', 'page arguments' => array('terms_and_conditions_admin'), 'access arguments' => array('access user profiles'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implements hook_block_info(). * */ if (module_exists('visitors')) { function igac_innova_block_info() { $blocks['igac_visitor'] = array( // info: The name of the block. 'info' => t('Visitantes Igac'), ); $blocks['igac_copy'] = array( // info: The name of the block. 'info' => t('Copyright'), ); return $blocks; } } /** * Implements hook_block_view(). * */ /* function igac_innova_block_view($delta = '') { switch ($delta) { case 'igac_visitor': // Construyo el bloque para los vistantes usando la base de datos de visitor. // Traigo el totales de los visitantes y la fecha de inicio del contador. $query = 'SELECT COUNT(*) FROM visitors'; // $count = db_select('visitors')->countQuery()->execute()->fetchField(); //$count = db_query($query); $contador = "
© ' . date('Y') . ' Derechos Reservados | Política de privacidad y condiciones de uso.
'; break; } return $block; } */ if (module_exists('visitors')) { function igac_innova_block_view($delta = '') { switch ($delta) { case 'igac_visitor': // Cache Block $cache = cache_get('igac_visitor', 'cache_block'); if (!empty($cache) && isset($cache->data) && !empty($cache->data) && $cache->expire >= time()) { return $cache->data; } else { // Construyo el bloque para los vistantes usando la base de datos de visitor. // Traigo el totales de los visitantes y la fecha de inicio del contador. $contador = "© ' . date('Y') . ' Derechos Reservados | Política de privacidad y condiciones de uso.
'; break; } return $block; } function _igac_get_visitors() { //$query = 'SELECT COUNT(*) FROM {visitors}'; $query = 'SELECT visitors_id FROM {visitors} ORDER BY visitors_id DESC LIMIT 1'; $count = db_query($query)->fetchField(); return $count; } function _igac_get_last_visitor() { $query = 'SELECT visitors_date_time FROM {visitors} ORDER BY visitors_date_time ASC'; $since_date = db_query_range($query, 0, 1)->fetchField(); return $since_date; } /** * Get timestamp and prints formated date * * @return * A formatted date for the last updated time if there are published nodes, * FALSE otherwise. */ function _igac_innova_show_time_visitors($fecha, $div) { $dia = date('j', $fecha); $mes = date("F", $fecha); $ano = date("Y", $fecha); // el mes sale en inglés entonces lo paso a español. if ($mes == "January") $mes = "Enero"; if ($mes == "February") $mes = "Febrero"; if ($mes == "March") $mes = "Marzo"; if ($mes == "April") $mes = "Abril"; if ($mes == "May") $mes = "Mayo"; if ($mes == "June") $mes = "Junio"; if ($mes == "July") $mes = "Julio"; if ($mes == "August") $mes = "Agosto"; if ($mes == "September") $mes = "Setiembre"; if ($mes == "October") $mes = "Octubre"; if ($mes == "November") $mes = "Noviembre"; if ($mes == "December") $mes = "Diciembre"; if ($div == 'ultima') { return $dia . ' ' . $mes . ' ' . $ano; } if ($div == 'inicio') { return $dia . ' ' . $mes . ' de ' . $ano; } } } /** * Get the last updated date for nodes. * * @return * A formatted date for the last updated time if there are published nodes, * FALSE otherwise. */ if (module_exists('visitors')) { function _igac_innova_last_updated() { // Pull from cache if available if ($cache = cache_get('igac_innova_last_updated')) { $last_updated = $cache->data; } else { // Otherwise, find the timestamp for the latest node record $last_updated = db_select('node', 'n') ->fields('n', array('changed')) ->condition('status', 0, '>') // only published nodes count ->orderBy('changed', 'DESC') ->range(0, 1) ->execute() ->fetchField(); // If nothing found, return FALSE. if (!$last_updated) { return false; } // Otherwise, save the data to cache for one hour. cache_set('igac_innova_last_updated', $last_updated, 'cache', time() + 3600); } return $last_updated; } } /* * Implement hook_form_alter * */ function igac_innova_form_alter(&$form, &$form_state, $form_id) { global $user; if (strpos($form_id, 'simplenews_block') !== false) { $form['mail']['#attributes']['placeholder'] = t('Enter your email'); $form['accept'] = array( '#type' => 'checkbox', '#title' => t('I agree to receive information to registered mail.'), '#required' => true, '#default_value' => true, ); $form['captcha']['#after_build'][] = 'custom_captcha_placeholder'; } elseif ($form_id == 'views_exposed_form') { if (arg(0) == 'search') { $form['search_api_views_fulltext']['#value'] = arg(2); } } } /* * Form to configure terms and conditions file * * */ function terms_and_conditions_admin() { $form = array(); $form['tc_file'] = array( '#type' => 'managed_file', '#title' => 'Archivo para términos y condiciones de los portales', '#default_value' => variable_get('tc_file', ''), '#upload_location' => 'public://tyc', '#required' => true, ); $form["#submit"][] = "terms_and_conditions_admin_submit"; $form['#attributes'] = array('enctype' => "multipart/form-data"); return system_settings_form($form); } function terms_and_conditions_admin_submit($form, &$form_state) { if (isset($form_state['values']['tc_file'])) { $dir = drupal_get_path('module', 'igac_innova'); $f = file_load($form_state['values']['tc_file']); $f->status = FILE_STATUS_PERMANENT; file_save($f); $url = file_create_url($f->uri); $fichero = $dir . '/tyc.txt'; file_put_contents($fichero, $url); } } /* * return the url to T&C file general to all sites * * */ function _get_terms_and_conditions_file() { $dir = drupal_get_path('module', 'igac_innova'); $fichero = $dir . '/tyc.txt'; $url = file_get_contents($fichero); return $url; } function custom_captcha_placeholder(&$element) { $element['captcha_widgets']['captcha_response']['#attributes']['placeholder'] = t('Response'); return $element; } function _get_header_date() { global $language; if ($language->language == 'es') { $dias = array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado"); $meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); return $dias[date('w')] . ", " . date('d') . " de " . $meses[date('n') - 1] . " de " . date('Y'); } else { $dias = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $meses = array("January", "February", "March", "April", "May", "June", "July", "August ", "September", "October", "November", "December"); return $dias[date('w')] . ", " . date('d') . " of " . $meses[date('n') - 1] . " of " . date('Y'); } } if (module_exists('ldap_servers')) { function igac_innova_user_login(&$edit, $account) { $name = $account->name; // Get all enabled enabled servers. if ($ldap_servers = ldap_servers_get_servers(null, 'enabled')) { // Get first server. $ldap_server = current($ldap_servers); // Run a search. if ($results = $ldap_server->search('dc=DCIGAC,dc=LOCAL', 'uid=' . $name)) { if (isset($results[0]['memberof'])) { $isAdmin = false; $isEditor = false; foreach ($results[0]['memberof'] as $group) { if (strpos($group, 'drupalAdministradores')) { $isAdmin = true; } elseif (strpos($group, 'DrupalEditores')) { $isEditor = true; } } $uid = $account->uid; // User ID of user that you want to add role to. $role_admin = 'administrator'; // The name of the role to add. $rolea = user_role_load_by_name($role_admin); $role_editor = 'Editor'; // The name of the role to add. $rolee = user_role_load_by_name($role_editor); if ($isAdmin) { if ($rolea) { if (!user_has_role($rolea->rid, $account)) { user_multiple_role_edit(array($uid), 'add_role', $rolea->rid); } } } else { if (user_has_role($rolea->rid, $account)) { user_multiple_role_edit(array($uid), 'remove_role', $rolea->rid); } } if ($isEditor) { if ($rolee) { if (!user_has_role($rolee->rid, $account)) { user_multiple_role_edit(array($uid), 'add_role', $rolee->rid); } } } else { if (user_has_role($rolee->rid, $account)) { user_multiple_role_edit(array($uid), 'remove_role', $rolee->rid); } } } } else { drupal_set_message(t('No results for that email.')); } } else { drupal_set_message(t('LDAP connection error. Please contact an Administrator.')); } } } // Alter Form Address Field tiendavirtual.igac.gov.co /*function igac_innova_form_alter (&$form, &$form_state, $form_id) { }*/