diff --git a/grnet_core/grnet_core.admin.inc b/grnet_core/grnet_core.admin.inc
new file mode 100755
index 0000000..c1cc634
--- /dev/null
+++ b/grnet_core/grnet_core.admin.inc
@@ -0,0 +1,148 @@
+ 'fieldset',
+ '#title' => t('Grnet Global Settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+
+ $form['grnet_settings']['grnet_header_sitename'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Header Site Name'),
+ '#default_value' => variable_get('grnet_header_sitename', ''),
+ '#size' => 90,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 255,
+ '#description' => t('Header Site Name..'),
+ );
+
+
+ $form['grnet_settings']['grnet_mail_verification_duration_in_minutes'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Mail Verification Duration (in minutes)'),
+ '#default_value' => variable_get('grnet_mail_verification_duration_in_minutes', '15'),
+ '#size' => 5,
+ '#maxlength' => 5,
+ '#description' => t('Time in minutes between submittion and mail verification. After that the submition will be deleted!!'),
+ );
+
+ $form['grnet_settings']['grnet_complete_submission_duration_in_days'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Complete Submission Duration (in days)'),
+ '#default_value' => variable_get('grnet_complete_submission_duration_in_days', '10'),
+ '#size' => 5,
+ '#maxlength' => 5,
+ '#description' => t('Days until a user must visit the manager to complete his submission. After that the submition will be deleted even if it\'s in state pending!!'),
+ );
+
+ $form['grnet_settings']['grnet_domain_suffixed_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Base Domain Name (for limit domain suffixed emails if enabled..above)'),
+ '#default_value' => variable_get('grnet_domain_suffixed_emails', $_SERVER['SERVER_NAME']),
+ '#size' => 30,
+ '#maxlength' => 30,
+ '#description' => t('The base domain name that the mails has been constructed and will be permit if above checkbox is set to checked. (Default='.$_SERVER['SERVER_NAME'].')'),
+ );
+
+ $form['grnet_settings']['grnet_limit_domain_suffixed_emails'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Limit domain suffixed emails'),
+ '#default_value' => variable_get('grnet_limit_domain_suffixed_emails', '0'),
+ '#size' => 5,
+ '#maxlength' => 5,
+ '#description' => t('Only permit mails with suffixed domain. (...@domain.xx) '),
+ );
+
+
+
+
+ $form['grnet_manager_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Manager Settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+
+
+ $form['grnet_manager_settings']['grnet_manager_contact_info_name_surname'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Manager Contact Info - Name/Surname'),
+ '#default_value' => variable_get('grnet_manager_contact_info_name_surname', ''),
+ '#size' => 90,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 90,
+ '#description' => t('Manager Contact Info - Name/Surname'),
+ );
+
+ $form['grnet_manager_settings']['grnet_manager_contact_info_phone'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Manager Contact Info - Phone'),
+ '#default_value' => variable_get('grnet_manager_contact_info_phone', ''),
+ '#size' => 90,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 90,
+ '#description' => t('Manager Contact Info - Phone'),
+ );
+
+ $form['grnet_manager_settings']['grnet_manager_contact_info_mobile'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Manager Contact Info - Mobile'),
+ '#default_value' => variable_get('grnet_manager_contact_info_mobile', ''),
+ '#size' => 90,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 90,
+ '#description' => t('Manager Contact Info - Mobile'),
+ );
+
+ $form['grnet_manager_settings']['grnet_manager_contact_info_address'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Manager Contact Info - Address'),
+ '#default_value' => variable_get('grnet_manager_contact_info_address', ''),
+ '#size' => 90,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 90,
+ '#description' => t('Manager Contact Info - Address'),
+ );
+
+ $form['grnet_manager_settings']['grnet_manager_contact_info_email'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Manager Contact Info - Email'),
+ '#default_value' => variable_get('grnet_manager_contact_info_email', variable_get('site_email')),
+ '#size' => 90,
+ '#required' => true,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 90,
+ '#description' => t('Manager Contact Info - Email'),
+ );
+
+ $form['grnet_manager_settings']['grnet_manager_contact_info_other'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Manager Contact Info - Other'),
+ '#default_value' => variable_get('grnet_manager_contact_info_other', ''),
+ '#size' => 90,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 90,
+ '#description' => t('Manager Contact Info - Other'),
+ );
+
+
+
+ return system_settings_form($form);
+}
diff --git a/grnet_core/grnet_core.info b/grnet_core/grnet_core.info
new file mode 100755
index 0000000..0413f9d
--- /dev/null
+++ b/grnet_core/grnet_core.info
@@ -0,0 +1,16 @@
+name = grnet Core
+description = grnet Core module - utility functions..
+core = "7.x"
+package = grnet
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
+scripts[] = js/info-view--hide-show-on-load.js
+scripts[] = js/info-edit--inline-errors.js
+scripts[] = js/info-edit--hide-show-per-click.js
+scripts[] = js/info-edit--hide-show-on-load.js
+scripts[] = js/info-edit--avaliable-states.js
+scripts[] = js/info-edit--double-highlight-diffs.js
+scripts[] = js/info-view--double-highlight-diffs.js
diff --git a/grnet_core/grnet_core.module b/grnet_core/grnet_core.module
new file mode 100755
index 0000000..206b4d9
--- /dev/null
+++ b/grnet_core/grnet_core.module
@@ -0,0 +1,341 @@
+ 'grnet Settings',
+ 'description' => 'grnet Settings',
+ 'position' => 'right',
+ 'page callback' => 'system_admin_menu_block_page',
+ 'access arguments' => array('access administration pages'),
+ 'file' => 'system.admin.inc',
+ 'file path' => drupal_get_path('module', 'system')
+ );
+ $items['admin/config/grnet/global'] = array(
+ 'title' => 'grnet Global settings',
+ 'description' => 'Configure grnet Global Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('grnet_core_admin_settings'),
+ 'access arguments' => array('administer cas'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'grnet_core.admin.inc',
+ );
+
+ $items['admin/config/grnet/global/settings'] = array(
+ 'title' => 'grnet Global Settings',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ return $items;
+}
+function grnet_core_convert($text, $revert=NULL){
+
+ $text_array = array(
+ "_none" => "- Κανένα -",
+
+ "medical" => "Ιατρικό",
+ "nursery" => "Νοσηλευτικό",
+ "administrative" => "Διοικητικό",
+
+ "esy_doctors" => "Γιατροί ΕΣΥ",
+ "academics" => "Πανεπιστημιακοί Γιατροί",
+ "other" => "Άλλοι Επιστήμονες",
+
+ "iatr_tmimata_monades_ana_tomea" => "Τμήματα / Μονάδες ανά Τομέα",
+ "iatr_tmimata_diatomeakou_epipedou" => "Τμήματα Διατομεακού Επιπέδου",
+ "iatr_epikourika_loipa" => "Επικουρικά / Λοιπά",
+ );
+
+ if($revert){
+ return array_search($text, $text_array);
+ }else{
+ return $text_array[$text];
+ }
+
+}
+function grnet_core_create_schGrAcPersonID($uid){
+ $schGrAcPersonID = strtoupper($uid);
+ while( strlen($schGrAcPersonID)<22 ){
+ $schGrAcPersonID .= '0';
+ }
+ return $schGrAcPersonID;
+}
+function grnet_core_get_term_by_rdn($rdn){
+ $temp = str_replace('uniqueIdentifier=','',$rdn);
+ $temp_array = explode(',ou' , $temp);
+ $tid=$temp_array[0];
+ if($tid>0){
+ $term = taxonomy_term_load($tid);
+ }
+ return $term;
+}
+function grnet_core_conver_dias_roles($tid){
+ $term = taxonomy_term_load($tid);
+ $result = $term->field_entitlement;
+ return $result['und']['0']['value'];
+}
+function grnet_core_conver_dias_roles_revert_to_tid($ldap_dias_roles_entitlment){
+ $tid = db_query("SELECT tid FROM field_data_field_entitlement as fdfe JOIN taxonomy_term_data AS ttt on ttt.tid=fdfe.entity_id where fdfe.field_entitlement_value=:entitlement",
+ array(':entitlement' => $ldap_dias_roles_entitlment))->fetchField();
+ return $tid;
+}
+
+function grnet_core_get_backend_name($tid){
+ $term_name = db_query("SELECT field_backend_name_value FROM {field_data_field_backend_name} WHERE entity_id=:entity_id",array(':entity_id' => $tid))->fetchField();
+ return $term_name;
+}
+function grnet_core_user_has_role($rolename){
+ global $user;
+ $current_user = user_load($user->uid);
+ if(array_search($rolename,$current_user->roles)){
+ return TRUE;
+ }else{
+ return FALSE;
+ }
+}
+function grnet_core_entity_has_changed($entity_loaded, $entity_presave){
+
+
+
+ if($entity_loaded->field_ldapregistr_name['und'][0]['value'] <> $entity_presave->field_ldapregistr_name['und'][0]['value']){
+ return TRUE;
+
+ }elseif($entity_loaded->field_ldapregistr_surname['und'][0]['value'] <> $entity_presave->field_ldapregistr_surname['und'][0]['value']){
+ return TRUE;
+
+ }elseif($entity_loaded->field_ldapregistr_amka['und'][0]['value'] <> $entity_presave->field_ldapregistr_amka['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_email['und'][0]['email'] <> $entity_presave->field_ldapregistr_email['und'][0]['email']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_phone['und'][0]['value'] <> $entity_presave->field_ldapregistr_phone['und'][0]['value']){
+ return TRUE;
+
+
+ }elseif($entity_loaded->field_ldapregistr_mobile['und'][0]['value'] <> $entity_presave->field_ldapregistr_mobile['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_personel_categ['und'][0]['value'] <> $entity_presave->field_ldapregistr_personel_categ['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_dicom['und'][0]['value'] <> $entity_presave->field_ldapregistr_dicom['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_personel_type['und'][0]['value'] <> $entity_presave->field_ldapregistr_personel_type['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_speciality['und'][0]['tid'] <> $entity_presave->field_ldapregistr_speciality['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_iatr_top_mon['und'][0]['value'] <> $entity_presave->field_ldapregistr_iatr_top_mon['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_tmim_mon_tomea['und'][0]['tid'] <> $entity_presave->field_ldapregistr_tmim_mon_tomea['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_epikour_loipa['und'][0]['tid'] <> $entity_presave->field_ldapregistr_epikour_loipa['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_iatr_proist['und'][0]['value'] <> $entity_presave->field_ldapregistr_iatr_proist['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_dioik_tmimgraf['und'][0]['tid'] <> $entity_presave->field_ldapregistr_dioik_tmimgraf['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_admin_proist['und'][0]['value'] <> $entity_presave->field_ldapregistr_admin_proist['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_dias_roles['und'][0]['tid'] <> $entity_presave->field_ldapregistr_dias_roles['und'][0]['tid']){
+ return TRUE;
+
+ }else{
+ return FALSE;
+ }
+
+
+}
+function grnet_core_entity_load($entities, $type) {
+ foreach ($entities as $entity) {
+
+
+
+ if(arg(0)=='entityform' && arg(2)=='edit' && $type=='entityform'){
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id] = $entity;
+
+ }
+
+
+
+ if($type=='entityform'){
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+ }
+
+}
+function grnet_core_get_username_by_entity_id($entity_id){
+ $username = db_query("SELECT field_ldapregistr_username_value as username FROM {field_data_field_ldapregistr_username} WHERE entity_id=:entity_id",array(':entity_id' => $entity_id))->fetchField();
+ return $username;
+}
+function grnet_core_get_entity_id_by_username($username){
+ $entity_id = db_query("SELECT entity_id FROM {field_data_field_ldapregistr_username} WHERE field_ldapregistr_username_value=:username",array(':username' => $username))->fetchField();
+ return $entity_id;
+}
+function grnet_core_get_entity_id_by_secretkey($secretkey){
+ $entity_id = db_query("SELECT entity_id FROM {field_data_field_ldapregistr_secretkey} WHERE field_ldapregistr_secretkey_value=:secretkey",array(':secretkey' => $secretkey))->fetchField();
+ return $entity_id;
+}
+function grnet_core_get_ldapinfo_user(){
+ $default_username = 'anonymous';
+ global $user;
+ if($_SESSION['phpCAS']['user']<>''){
+ $username = $_SESSION['phpCAS']['user'];
+ }elseif(grnet_core_user_has_role('manager')){
+
+ if(arg(0)=='requests' && arg(1)=='view' && arg(2)>0){
+ $username = grnet_core_get_username_by_entity_id(arg(2));
+ }elseif(arg(0)=='entityform' && arg(2)=='edit' && arg(1)>0){
+ $username = grnet_core_get_username_by_entity_id(arg(1));
+ }
+ }else{
+ $username = $default_username;
+ }
+
+ return $username;
+}
+function grnet_core_get_ldapuser_hidden_message(){
+ if($_SESSION['phpCAS']['user']<>''){
+ $entity_id = grnet_core_get_entity_id_by_username($_SESSION['phpCAS']['user']);
+ $entity_instance = entity_load('entityform', array($entity_id));
+ $entity_instance = $entity_instance[$entity_id];
+ $hidden_message = $entity_instance->field_ldapregistr_hidden_message['und']['0']['value'];
+ if($hidden_message<>''){
+ if(strpos($hidden_message, 'απορρίφθηκε') !== false){
+ drupal_set_message($hidden_message, 'warning');
+ }else{
+ drupal_set_message($hidden_message);
+ }
+ $entity_instance->field_ldapregistr_hidden_message['und']['0']['value']= '';
+ $entity_instance->save();
+ }
+ }
+}
+function grnet_core_sync_ldapuser_submission_ownership(){
+
+ if($_SESSION['phpCAS']['user']<>''){
+
+
+
+
+
+
+ global $user;
+ if($user->field_submission_ownership_sync['und']['0']['value']<>1){
+
+ $entity_id = grnet_core_get_entity_id_by_username($_SESSION['phpCAS']['user']);
+ $entity_instance = entity_load('entityform', array($entity_id));
+ $entity_instance = $entity_instance[$entity_id];
+
+ if($entity_id==''){
+ drupal_set_message('Δεν βρέθηκε ανώνυμη υποβολή με το username με το οποίο εισήλθατε στο σύστημα μέσω CAS!!' , 'error');
+ }else{
+
+ $entity_instance->uid = $user->uid;
+ $entity_instance->save();
+
+
+ $edit = array(
+ 'field_submission_ownership_sync' => array(
+ 'und' => array(
+ 0 => array(
+ 'value' => 1,
+ ),
+ ),
+ ),
+ );
+ user_save($account, $edit);
+
+
+ drupal_set_message('Η ανώνυμη υποβολή σας, συγχρονίστηκε με τον λογαριασμό σας.');
+ }
+
+
+ }else{
+ }
+
+
+
+ }
+
+}
+function grnet_core_get_manager_contact_info(){
+ $output = '';
+
+ if(variable_get('grnet_manager_contact_info_name_surname')<>''){
+ $output .= variable_get('grnet_manager_contact_info_name_surname');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_phone')<>''){
+ $output .= variable_get('grnet_manager_contact_info_phone');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_mobile')<>''){
+ $output .= variable_get('grnet_manager_contact_info_mobile');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_address')<>''){
+ $output .= variable_get('grnet_manager_contact_info_address');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_email')<>''){
+ $output .= variable_get('grnet_manager_contact_info_email');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_other')<>''){
+ $output .= variable_get('grnet_manager_contact_info_other');
+ $output .= ' ';
+ }
+
+ return $output;
+}
+function grnet_core_isEmailValidDueToDomainSuffixedPolicy($email){
+ if(variable_get('grnet_limit_domain_suffixed_emails')==0){
+ return true;
+
+ }else{
+ if(_endsWith($email, '@'.variable_get('grnet_domain_suffixed_emails'))){
+ return true;
+ }else{
+ return false;
+ }
+
+ }
+}
+function _endsWith($haystack, $needle)
+{
+ $length = strlen($needle);
+ if ($length == 0) {
+ return true;
+ }
+ return (substr($haystack, -$length) === $needle);
+}
+function grnet_core_validateAMKA($amka) {
+ if(!preg_match('/^\d{11}$/' , $amka) || $amka == '000000000'){
+ return false;
+ }
+ $iSum = 0;
+ for ($i=1; $i <= strlen($amka); $i++) {
+ $iDigit = intval($amka[$i-1], 10);
+ if ($i % 2 === 0) {
+ $iDigit *= 2;
+ if ($iDigit > 9) {
+ $iDigit -= 9;
+ }
+ }
+ $iSum += $iDigit;
+ }
+ return ($iSum % 10 === 0);
+}
diff --git a/grnet_core/grnet_core.module~ b/grnet_core/grnet_core.module~
new file mode 100755
index 0000000..2bcbd32
--- /dev/null
+++ b/grnet_core/grnet_core.module~
@@ -0,0 +1,348 @@
+ 'grnet Settings',
+ 'description' => 'grnet Settings',
+ 'position' => 'right',
+ 'page callback' => 'system_admin_menu_block_page',
+ 'access arguments' => array('access administration pages'),
+ 'file' => 'system.admin.inc',
+ 'file path' => drupal_get_path('module', 'system')
+ );
+ $items['admin/config/grnet/global'] = array(
+ 'title' => 'grnet Global settings',
+ 'description' => 'Configure grnet Global Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('grnet_core_admin_settings'),
+ 'access arguments' => array('administer cas'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'grnet_core.admin.inc',
+ );
+
+ $items['admin/config/grnet/global/settings'] = array(
+ 'title' => 'grnet Global Settings',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ return $items;
+}
+function grnet_core_convert($text, $revert=NULL){
+
+ $text_array = array(
+ "_none" => "- Κανένα -",
+
+ "medical" => "Ιατρικό",
+ "nursery" => "Νοσηλευτικό",
+ "administrative" => "Διοικητικό",
+
+ "esy_doctors" => "Γιατροί ΕΣΥ",
+ "academics" => "Πανεπιστημιακοί Γιατροί",
+ "other" => "Άλλοι Επιστήμονες",
+
+ "iatr_tmimata_monades_ana_tomea" => "Τμήματα / Μονάδες ανά Τομέα",
+ "iatr_tmimata_diatomeakou_epipedou" => "Τμήματα Διατομεακού Επιπέδου",
+ "iatr_epikourika_loipa" => "Επικουρικά / Λοιπά",
+ );
+
+ if($revert){
+ return array_search($text, $text_array);
+ }else{
+ return $text_array[$text];
+ }
+
+}
+function grnet_core_create_schGrAcPersonID($uid){
+ $schGrAcPersonID = strtoupper($uid);
+ while( strlen($schGrAcPersonID)<22 ){
+ $schGrAcPersonID .= '0';
+ }
+ return $schGrAcPersonID;
+}
+function grnet_core_get_term_by_rdn($rdn){
+ $temp = str_replace('uniqueIdentifier=','',$rdn);
+ $temp_array = explode(',ou' , $temp);
+ $tid=$temp_array[0];
+ if($tid>0){
+ $term = taxonomy_term_load($tid);
+ }
+ return $term;
+}
+function grnet_core_conver_dias_roles($tid){
+ $term = taxonomy_term_load($tid);
+ $result = $term->field_entitlement;
+ return $result['und']['0']['value'];
+}
+function grnet_core_conver_dias_roles_revert_to_tid($ldap_dias_roles_entitlment){
+ $tid = db_query("SELECT tid FROM field_data_field_entitlement as fdfe JOIN taxonomy_term_data AS ttt on ttt.tid=fdfe.entity_id where fdfe.field_entitlement_value=:entitlement",
+ array(':entitlement' => $ldap_dias_roles_entitlment))->fetchField();
+ return $tid;
+}
+/*
+function grnet_core_get_topothetisi_se_monada($tid){
+ grnet_core_get_term_name_by_rdn($rdn)
+}
+*/
+function grnet_core_get_backend_name($tid){
+ $term_name = db_query("SELECT field_backend_name_value FROM {field_data_field_backend_name} WHERE entity_id=:entity_id",array(':entity_id' => $tid))->fetchField();
+ return $term_name;
+}
+function grnet_core_user_has_role($rolename){
+ global $user;
+ $current_user = user_load($user->uid);
+ if(array_search($rolename,$current_user->roles)){
+ return TRUE;
+ }else{
+ return FALSE;
+ }
+}
+function grnet_core_entity_has_changed($entity_loaded, $entity_presave){
+
+
+
+ if($entity_loaded->field_ldapregistr_name['und'][0]['value'] <> $entity_presave->field_ldapregistr_name['und'][0]['value']){
+ return TRUE;
+
+ }elseif($entity_loaded->field_ldapregistr_surname['und'][0]['value'] <> $entity_presave->field_ldapregistr_surname['und'][0]['value']){
+ return TRUE;
+
+ }elseif($entity_loaded->field_ldapregistr_amka['und'][0]['value'] <> $entity_presave->field_ldapregistr_amka['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_email['und'][0]['email'] <> $entity_presave->field_ldapregistr_email['und'][0]['email']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_phone['und'][0]['value'] <> $entity_presave->field_ldapregistr_phone['und'][0]['value']){
+ return TRUE;
+
+
+ }elseif($entity_loaded->field_ldapregistr_mobile['und'][0]['value'] <> $entity_presave->field_ldapregistr_mobile['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_personel_categ['und'][0]['value'] <> $entity_presave->field_ldapregistr_personel_categ['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_dicom['und'][0]['value'] <> $entity_presave->field_ldapregistr_dicom['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_personel_type['und'][0]['value'] <> $entity_presave->field_ldapregistr_personel_type['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_speciality['und'][0]['tid'] <> $entity_presave->field_ldapregistr_speciality['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_iatr_top_mon['und'][0]['value'] <> $entity_presave->field_ldapregistr_iatr_top_mon['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_tmim_mon_tomea['und'][0]['tid'] <> $entity_presave->field_ldapregistr_tmim_mon_tomea['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_epikour_loipa['und'][0]['tid'] <> $entity_presave->field_ldapregistr_epikour_loipa['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_iatr_proist['und'][0]['value'] <> $entity_presave->field_ldapregistr_iatr_proist['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_dioik_tmimgraf['und'][0]['tid'] <> $entity_presave->field_ldapregistr_dioik_tmimgraf['und'][0]['tid']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_admin_proist['und'][0]['value'] <> $entity_presave->field_ldapregistr_admin_proist['und'][0]['value']){
+ return TRUE;
+ }elseif($entity_loaded->field_ldapregistr_dias_roles['und'][0]['tid'] <> $entity_presave->field_ldapregistr_dias_roles['und'][0]['tid']){
+ return TRUE;
+
+ }else{
+ return FALSE;
+ }
+
+
+}
+function grnet_core_entity_load($entities, $type) {
+ foreach ($entities as $entity) {
+
+
+
+ if(arg(0)=='entityform' && arg(2)=='edit' && $type=='entityform'){
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id] = $entity;
+
+ }
+
+
+
+ if($type=='entityform'){
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+ }
+
+}
+function grnet_core_get_username_by_entity_id($entity_id){
+ $username = db_query("SELECT field_ldapregistr_username_value as username FROM {field_data_field_ldapregistr_username} WHERE entity_id=:entity_id",array(':entity_id' => $entity_id))->fetchField();
+ return $username;
+}
+function grnet_core_get_entity_id_by_username($username){
+ $entity_id = db_query("SELECT entity_id FROM {field_data_field_ldapregistr_username} WHERE field_ldapregistr_username_value=:username",array(':username' => $username))->fetchField();
+ return $entity_id;
+}
+function grnet_core_get_entity_id_by_secretkey($secretkey){
+ $entity_id = db_query("SELECT entity_id FROM {field_data_field_ldapregistr_secretkey} WHERE field_ldapregistr_secretkey_value=:secretkey",array(':secretkey' => $secretkey))->fetchField();
+ return $entity_id;
+}
+function grnet_core_get_ldapinfo_user(){
+ $default_username = 'anonymous';
+ global $user;
+ if($_SESSION['phpCAS']['user']<>''){
+ $username = $_SESSION['phpCAS']['user'];
+ }elseif(grnet_core_user_has_role('manager')){
+
+ if(arg(0)=='requests' && arg(1)=='view' && arg(2)>0){
+ $username = grnet_core_get_username_by_entity_id(arg(2));
+ }elseif(arg(0)=='entityform' && arg(2)=='edit' && arg(1)>0){
+ $username = grnet_core_get_username_by_entity_id(arg(1));
+ }
+ }else{
+ $username = $default_username;
+ }
+
+ return $username;
+}
+function grnet_core_get_ldapuser_hidden_message(){
+ if($_SESSION['phpCAS']['user']<>''){
+ $entity_id = grnet_core_get_entity_id_by_username($_SESSION['phpCAS']['user']);
+ $entity_instance = entity_load('entityform', array($entity_id));
+ $entity_instance = $entity_instance[$entity_id];
+ $hidden_message = $entity_instance->field_ldapregistr_hidden_message['und']['0']['value'];
+ if($hidden_message<>''){
+ if(strpos($hidden_message, 'απορρίφθηκε') !== false){
+ drupal_set_message($hidden_message, 'warning');
+ }else{
+ drupal_set_message($hidden_message);
+ }
+ $entity_instance->field_ldapregistr_hidden_message['und']['0']['value']= '';
+ $entity_instance->save();
+ }
+ }
+}
+function grnet_core_sync_ldapuser_submission_ownership(){
+
+ if($_SESSION['phpCAS']['user']<>''){
+
+
+
+
+
+
+ global $user;
+ if($user->field_submission_ownership_sync['und']['0']['value']<>1){
+
+ $entity_id = grnet_core_get_entity_id_by_username($_SESSION['phpCAS']['user']);
+ $entity_instance = entity_load('entityform', array($entity_id));
+ $entity_instance = $entity_instance[$entity_id];
+
+ if($entity_id==''){
+ drupal_set_message('Δεν βρέθηκε ανώνυμη υποβολή με το username με το οποίο εισήλθατε στο σύστημα μέσω CAS!!' , 'error');
+ }else{
+
+ $entity_instance->uid = $user->uid;
+ $entity_instance->save();
+
+
+ $edit = array(
+ 'field_submission_ownership_sync' => array(
+ 'und' => array(
+ 0 => array(
+ 'value' => 1,
+ ),
+ ),
+ ),
+ );
+ user_save($account, $edit);
+
+
+ drupal_set_message('Η ανώνυμη υποβολή σας, συγχρονίστηκε με τον λογαριασμό σας.');
+ }
+
+
+ }else{
+ }
+
+
+
+ }
+
+}
+function grnet_core_get_manager_contact_info(){
+ $output = '';
+
+ if(variable_get('grnet_manager_contact_info_name_surname')<>''){
+ $output .= variable_get('grnet_manager_contact_info_name_surname');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_phone')<>''){
+ $output .= variable_get('grnet_manager_contact_info_phone');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_mobile')<>''){
+ $output .= variable_get('grnet_manager_contact_info_mobile');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_address')<>''){
+ $output .= variable_get('grnet_manager_contact_info_address');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_email')<>''){
+ $output .= variable_get('grnet_manager_contact_info_email');
+ $output .= ' ';
+ }
+
+ if(variable_get('grnet_manager_contact_info_other')<>''){
+ $output .= variable_get('grnet_manager_contact_info_other');
+ $output .= ' ';
+ }
+
+ return $output;
+}
+function grnet_core_isEmailValidDueToDomainSuffixedPolicy($email){
+/* drupal_set_message(variable_get('grnet_limit_domain_suffixed_emails'));
+ drupal_set_message(variable_get('grnet_domain_suffixed_emails')); */
+
+ if(variable_get('grnet_limit_domain_suffixed_emails')==0){
+ return true;
+
+ }else{
+ if(_endsWith($email, '@'.variable_get('grnet_domain_suffixed_emails'))){
+ return true;
+ }else{
+ return false;
+ }
+
+ }
+}
+function _endsWith($haystack, $needle)
+{
+ $length = strlen($needle);
+ if ($length == 0) {
+ return true;
+ }
+ return (substr($haystack, -$length) === $needle);
+}
+function grnet_core_validateAMKA($amka) {
+ if(!preg_match('/^\d{11}$/' , $amka) || $amka == '000000000'){
+ return false;
+ }
+ $iSum = 0;
+ for ($i=1; $i <= strlen($amka); $i++) {
+ $iDigit = intval($amka[$i-1], 10);
+ if ($i % 2 === 0) {
+ $iDigit *= 2;
+ if ($iDigit > 9) {
+ $iDigit -= 9;
+ }
+ }
+ $iSum += $iDigit;
+ }
+ return ($iSum % 10 === 0);
+}
diff --git a/grnet_core/js/info-edit--avaliable-states.js b/grnet_core/js/info-edit--avaliable-states.js
new file mode 100644
index 0000000..da69926
--- /dev/null
+++ b/grnet_core/js/info-edit--avaliable-states.js
@@ -0,0 +1,71 @@
+(function ($) {
+
+ $(document).ready(function() {
+
+
+
+ if (document.getElementById("ldapregistration-entityform-edit-form")) {
+
+ /* Diaxeirisi Ypobolon - Diathesimes Katastaseis analoga me tin yparxoysa.. (Starts) */
+ if( $("#edit-field-ldapregistr-status-und").val()=="prepending" ){
+ $("#edit-field-ldapregistr-status-und option[value='completed']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='request_for_change']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='declined']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted_minor_fixes']").remove();
+ }else if( $("#edit-field-ldapregistr-status-und").val()=="pending"){
+ $("#edit-field-ldapregistr-status-und option[value='prepending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='request_for_change']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='declined']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted_minor_fixes']").remove();
+ }else if( $("#edit-field-ldapregistr-status-und").val()=="completed"){
+ $("#edit-field-ldapregistr-status-und option[value='prepending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='pending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='request_for_change']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='declined']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted_minor_fixes']").remove();
+ }
+ /* Diaxeirisi Ypobolon - Diathesimes Katastaseis analoga me tin yparxoysa.. (Ends) */
+
+
+
+ /* Diaxeirisi Aitiseon - Diathesimes Katastaseis analoga me tin yparxoysa.. (Starts) */
+ if( $("#edit-field-ldapregistr-status-und").val()=="request_for_change" ){
+ $("#edit-field-ldapregistr-status-und option[value='prepending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='pending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='completed']").remove();
+ }else if( $("#edit-field-ldapregistr-status-und").val()=="declined"){
+ $("#edit-field-ldapregistr-status-und option[value='prepending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='pending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='completed']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='request_for_change']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted_minor_fixes']").remove();
+ }else if( $("#edit-field-ldapregistr-status-und").val()=="accepted"){
+ $("#edit-field-ldapregistr-status-und option[value='prepending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='pending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='completed']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='request_for_change']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='declined']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted_minor_fixes']").remove();
+ }else if( $("#edit-field-ldapregistr-status-und").val()=="accepted_minor_fixes"){
+ $("#edit-field-ldapregistr-status-und option[value='prepending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='pending']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='completed']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='request_for_change']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='accepted']").remove();
+ $("#edit-field-ldapregistr-status-und option[value='declined']").remove();
+ }
+ /* Diaxeirisi Aitiseon - Diathesimes Katastaseis analoga me tin yparxoysa.. (Ends) */
+
+
+ }
+
+
+
+ });
+
+})(jQuery);
+
diff --git a/grnet_core/js/info-edit--double-highlight-diffs.js b/grnet_core/js/info-edit--double-highlight-diffs.js
new file mode 100644
index 0000000..60ae2ac
--- /dev/null
+++ b/grnet_core/js/info-edit--double-highlight-diffs.js
@@ -0,0 +1,126 @@
+(function($) {
+
+ $(document).ready(function() {
+
+
+ if(document.getElementById('ldapinfo-root') && window.location.href.indexOf("entityform") > -1 ){
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-name").html() != $( "#edit-field-ldapregistr-name-und-0-value").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-name").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-name").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-surname").html() != $( "#edit-field-ldapregistr-surname-und-0-value").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-surname").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-surname").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-amka").html() != $( "#edit-field-ldapregistr-amka-und-0-value").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-amka").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-amka").addClass('grnet-highlight');
+ }
+
+ if($( "#ldapinfo-root .grnet-field-ldapregistr-username").html() != $( "#grnet_username_show_field").html()){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-username").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-username").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-email").html() != $( "#edit-field-ldapregistr-email-und-0-email").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-email").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-email").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-phone").html() != $( "#edit-field-ldapregistr-phone-und-0-value").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-phone").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-phone").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-mobile").html() != $( "#edit-field-ldapregistr-mobile-und-0-value").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-mobile").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-mobile").addClass('grnet-highlight');
+ }
+
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-mobile").html() != $( "#edit-field-ldapregistr-mobile-und-0-value").val() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-mobile").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-personel-mobile").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-personel-categ").html() != $( "#edit-field-ldapregistr-personel-categ-und option:selected").text() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-personel-categ").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-personel-categ").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-dicom").html() != $( "#edit-field-ldapregistr-dicom-und-0-value").val() ){
+ ///$( "#ldapinfo-root .views-field-field-ldapregistr-dicom").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-dicom").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-personel-type").html() != $( "#edit-field-ldapregistr-personel-type-und option:selected").text() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-personel-type").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-personel-type").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-speciality").html() != $( "#edit-field-ldapregistr-speciality-und option:selected").text() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-speciality").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-speciality").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-iatr-top-mon").html().trim() != $("input[name='field_ldapregistr_iatr_top_mon[und]']:checked").next('label').text().trim() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-iatr-top-mon").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-iatr-top-mon").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-tmim-mon-tomea").html().trim() != $("input[name='field_ldapregistr_tmim_mon_tomea[und]']:checked").next('label').text().trim() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-tmim-mon-tomea").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-tmim-diato").html() != $( "#edit-field-ldapregistr-tmim-diato-und option:selected").text() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-tmim-diato").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-epikour-loipa").html() != $( "#edit-field-ldapregistr-epikour-loipa-und option:selected").text() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-epikour-loipa").addClass('grnet-highlight');
+ }
+
+
+
+ if( ( $( "#ldapinfo-root .grnet-field-ldapregistr-iatr-proist").html()=='ΝΑΙ' && $("#edit-field-ldapregistr-iatr-proist-und").prop( "checked")==false) ||
+ ( $( "#ldapinfo-root .grnet-field-ldapregistr-iatr-proist").html()=='ΟΧΙ' && $("#edit-field-ldapregistr-iatr-proist-und").prop( "checked")==true)
+ ){
+
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-iatr-proist").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-iatr-proist").addClass('grnet-highlight');
+ }
+
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-dioik-tmimgraf").html().trim() != $("#edit-field-ldapregistr-dioik-tmimgraf-und input[type='radio']:checked").next('label').text().trim() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-dioik-tmimgraf").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-dioik-tmimgraf").addClass('grnet-highlight');
+ }
+
+ if( ( $( "#ldapinfo-root .grnet-field-ldapregistr-admin-proist").html()=='ΝΑΙ' && $("#edit-field-ldapregistr-admin-proist-und").prop( "checked")==false) ||
+ ( $( "#ldapinfo-root .grnet-field-ldapregistr-admin-proist").html()=='ΟΧΙ' && $("#edit-field-ldapregistr-admin-proist-und").prop( "checked")==true)
+ ){
+
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-admin-proist").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-admin-proist").addClass('grnet-highlight');
+ }
+
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-dias-roles").html() != $( "#edit-field-ldapregistr-dias-roles-und option:selected").text() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-dias-roles").addClass('grnet-highlight');
+ $( "#edit-field-ldapregistr-dias-roles").addClass('grnet-highlight');
+ }
+
+ //alert( '#'+$( "#ldapinfo-root .grnet-field-ldapregistr-iatr-proist").html()+'#\n#'+$("#edit-field-ldapregistr-iatr-proist-und").prop( "checked")+'#' );
+
+ }
+ });
+
+
+
+})(jQuery);
\ No newline at end of file
diff --git a/grnet_core/js/info-edit--hide-show-on-load.js b/grnet_core/js/info-edit--hide-show-on-load.js
new file mode 100644
index 0000000..a1b7c36
--- /dev/null
+++ b/grnet_core/js/info-edit--hide-show-on-load.js
@@ -0,0 +1,44 @@
+(function($) {
+
+ $(document).ready(function() {
+
+ // Emfanisi kentrikon katigorion.. (medical/administrative/nosileytiko..(an kai ayto..den iparxei toulaxiston tora..)
+ if ($( "#edit-field-ldapregistr-personel-categ-und").val() == 'medical') {
+ $(".group-ldapregistr-medical").show();
+ //$(".group-ldapregistr-nursery").hide();
+ $(".group-ldapregistr-administrative").hide();
+
+
+ // Emfanisi i oxi tis eidikotitas (Starts)
+ if($( "#edit-field-ldapregistr-personel-type-und").val() == 'esy_doctors' ||
+ $( "#edit-field-ldapregistr-personel-type-und").val() == 'academics'
+ ){
+ $( "#edit-field-ldapregistr-speciality").show();
+ }
+ // Emfanisi i oxi tis eidikotitas (Ends)
+
+ // Emfanisi tis katalilis monades/tmimatos ktl.. (Starts)
+ if( $("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val() == 'iatr_tmimata_monades_ana_tomea'){
+ $("#edit-field-ldapregistr-tmim-mon-tomea").show();
+ }else if( $("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val() == 'iatr_tmimata_diatomeakou_epipedou'){
+ $("#edit-field-ldapregistr-tmim-diato").show();
+ }else if( $("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val() == 'iatr_epikourika_loipa'){
+ $("#edit-field-ldapregistr-epikour-loipa").show();
+ }
+ // Emfanisi tis katalilis monades/tmimatos ktl.. (Ends)
+
+
+ }else if ($( "#edit-field-ldapregistr-personel-categ-und").val() == 'administrative') {
+ $(".group-ldapregistr-medical").hide();
+ //$(".group-ldapregistr-nursery").hide();
+ $(".group-ldapregistr-administrative").show();
+ }
+
+ });
+
+
+
+
+
+
+})(jQuery);
\ No newline at end of file
diff --git a/grnet_core/js/info-edit--hide-show-per-click.js b/grnet_core/js/info-edit--hide-show-per-click.js
new file mode 100644
index 0000000..915d6e4
--- /dev/null
+++ b/grnet_core/js/info-edit--hide-show-per-click.js
@@ -0,0 +1,245 @@
+(function ($) {
+
+ $(".group-ldapregistr-medical").hide();
+
+
+ $("#edit-field-ldapregistr-personel-categ-und").live("change", function () {
+
+ if(this.value=='medical'){
+ $(".group-ldapregistr-medical").show();
+ //$(".group-ldapregistr-nursery").hide();
+ $(".group-ldapregistr-administrative").hide();
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+ $("#edit-field-ldapregistr-dioik-tmimgraf-und-").prop( "checked", true );
+
+ $('#edit-field-ldapregistr-admin-proist-und').prop('checked', false);
+
+
+ // Hide dioik errors.. (Starts)
+ $( "#field-ldapregistr-dioik-tmimgraf_error" ).remove();
+ $( "#edit-field-ldapregistr-dioik-tmimgraf-und").css("border-color", "#cccccc");
+ // Hide dioik errors.. (Starts)
+
+ }else if(this.value=='nursery'){
+ $(".group-ldapregistr-medical").hide();
+ //$(".group-ldapregistr-nursery").show();
+ $(".group-ldapregistr-administrative").hide();
+ //$("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+
+ $('#edit-field-ldapregistr-dicom-und-0-value').val('');
+
+ $('#edit-field-ldapregistr-personel-type-und').val('_none');
+
+ $('#edit-field-ldapregistr-speciality-und').val('_none');
+ $(".field-name-field-ldapregistr-speciality").hide();
+
+ $('#edit-field-ldapregistr-iatr-top-mon-und input:radio').filter('[value=_none]').attr('checked', true);
+
+ $('#edit-field-ldapregistr-iatr-proist-und').removeAttr('checked');
+
+ $("#edit-field-ldapregistr-dioik-tmimgraf-und-").prop( "checked", true );
+
+ $('#edit-field-ldapregistr-admin-proist-und').prop('checked', false);
+
+
+ $('#edit-field-ldapregistr-tmim-mon-tomea-und-').prop( "checked", true );
+ $("#edit-field-ldapregistr-tmim-mon-tomea").hide();
+
+ $('#edit-field-ldapregistr-tmim-diato-und').val('_none');
+ $("#edit-field-ldapregistr-tmim-diato").hide();
+
+ $('#edit-field-ldapregistr-epikour-loipa-und').val('_none');
+ $("#edit-field-ldapregistr-epikour-loipa").hide();
+
+
+
+ // Hide iatr errors.. (Starts)
+ $( "#field-ldapregistr-personel-type_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-type-und").css("border-color", "#cccccc");
+
+ $( "#field-ldapregistr-iatr-top-mon_error" ).remove();
+ $( "#edit-field-ldapregistr-iatr-top-mon-und").css("border-color", "#cccccc");
+ // Hide iatr errors.. (Ends)
+
+
+ // Hide dioik errors.. (Starts)
+ $( "#field-ldapregistr-dioik-tmimgraf_error" ).remove();
+ $( "#edit-field-ldapregistr-dioik-tmimgraf-und").css("border-color", "#cccccc");
+ // Hide dioik errors.. (Starts)
+
+ }else if(this.value=='administrative'){
+
+ $(".group-ldapregistr-medical").hide();
+ //$(".group-ldapregistr-nursery").hide();
+ $(".group-ldapregistr-administrative").show();
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+
+ $('#edit-field-ldapregistr-dicom-und-0-value').val('');
+
+ $('#edit-field-ldapregistr-personel-type-und').val('_none');
+
+ $('#edit-field-ldapregistr-speciality-und').val('_none');
+ $(".field-name-field-ldapregistr-speciality").hide();
+
+
+ $('#edit-field-ldapregistr-iatr-top-mon-und input:radio').filter('[value=_none]').attr('checked', true);
+
+ $('#edit-field-ldapregistr-iatr-proist-und').removeAttr('checked');
+
+
+ $('#edit-field-ldapregistr-tmim-mon-tomea-und-').prop( "checked", true );
+ $("#edit-field-ldapregistr-tmim-mon-tomea").hide();
+
+ $('#edit-field-ldapregistr-tmim-diato-und').val('_none');
+ $("#edit-field-ldapregistr-tmim-diato").hide();
+
+ $('#edit-field-ldapregistr-epikour-loipa-und').val('_none');
+ $("#edit-field-ldapregistr-epikour-loipa").hide();
+
+
+ // Hide iatr errors.. (Starts)
+ $( "#field-ldapregistr-personel-type_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-type-und").css("border-color", "#cccccc");
+
+ $( "#field-ldapregistr-iatr-top-mon_error" ).remove();
+ $( "#edit-field-ldapregistr-iatr-top-mon-und").css("border-color", "#cccccc");
+ // Hide iatr errors.. (Ends)
+
+ }else{
+ $(".group-ldapregistr-medical").hide();
+ //$(".group-ldapregistr-nursery").hide();
+ $(".group-ldapregistr-administrative").hide();
+ //$("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+
+ $('#edit-field-ldapregistr-dicom-und-0-value').val('');
+
+ $('#edit-field-ldapregistr-personel-type-und').val('_none');
+
+ $('#edit-field-ldapregistr-speciality-und').val('_none');
+ $(".field-name-field-ldapregistr-speciality").hide();
+
+ $('#edit-field-ldapregistr-iatr-top-mon-und input:radio').filter('[value=_none]').attr('checked', true);
+
+ $('#edit-field-ldapregistr-iatr-proist-und').removeAttr('checked');
+
+ $("#edit-field-ldapregistr-dioik-tmimgraf-und-").prop( "checked", true );
+
+ $('#edit-field-ldapregistr-admin-proist-und').prop('checked', false);
+
+
+ $('#edit-field-ldapregistr-tmim-mon-tomea-und-').prop( "checked", true );
+ $("#edit-field-ldapregistr-tmim-mon-tomea").hide();
+
+ $('#edit-field-ldapregistr-tmim-diato-und').val('_none');
+ $("#edit-field-ldapregistr-tmim-diato").hide();
+
+ $('#edit-field-ldapregistr-epikour-loipa-und').val('_none');
+ $("#edit-field-ldapregistr-epikour-loipa").hide();
+
+
+
+ // Hide iatr errors.. (Starts)
+ $( "#field-ldapregistr-personel-type_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-type-und").css("border-color", "#cccccc");
+
+ $( "#field-ldapregistr-iatr-top-mon_error" ).remove();
+ $( "#edit-field-ldapregistr-iatr-top-mon-und").css("border-color", "#cccccc");
+ // Hide iatr errors.. (Ends)
+
+
+ // Hide dioik errors.. (Starts)
+ $( "#field-ldapregistr-dioik-tmimgraf_error" ).remove();
+ $( "#edit-field-ldapregistr-dioik-tmimgraf-und").css("border-color", "#cccccc");
+ // Hide dioik errors.. (Starts)
+
+
+ }
+
+
+ });
+
+
+ $("#edit-field-ldapregistr-personel-type-und").live("change", function () {
+
+ if(this.value=='esy_doctors'){
+ $(".field-name-field-ldapregistr-speciality").show();
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+ }else if(this.value=='academics'){
+ $(".field-name-field-ldapregistr-speciality").show();
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+ }else{
+ $('#edit-field-ldapregistr-speciality-und').val('_none');
+ $(".field-name-field-ldapregistr-speciality").hide();
+ }
+
+
+ // Hide iatr errors.. (Starts)
+ $( "#field-ldapregistr-speciality_error" ).remove();
+ $( "#edit-field-ldapregistr-speciality-und").css("border-color", "#cccccc");
+ // Hide iatr errors.. (Ends)
+
+
+ });
+
+
+
+ $("#edit-field-ldapregistr-iatr-top-mon-und input:radio").live("change", function () {
+
+ if(this.value=='iatr_tmimata_monades_ana_tomea'){
+ $("#edit-field-ldapregistr-tmim-mon-tomea").show();
+
+ $('#edit-field-ldapregistr-tmim-diato-und').val('_none');
+ $("#edit-field-ldapregistr-tmim-diato").hide();
+
+ $('#edit-field-ldapregistr-epikour-loipa-und').val('_none');
+ $("#edit-field-ldapregistr-epikour-loipa").hide();
+
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+ }else if(this.value=='iatr_tmimata_diatomeakou_epipedou'){
+ $("#edit-field-ldapregistr-tmim-diato").show();
+
+ $('#edit-field-ldapregistr-tmim-mon-tomea-und-').prop( "checked", true );
+ $("#edit-field-ldapregistr-tmim-mon-tomea").hide();
+
+ $('#edit-field-ldapregistr-epikour-loipa-und').val('_none');
+ $("#edit-field-ldapregistr-epikour-loipa").hide();
+
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+ }else if(this.value=='iatr_epikourika_loipa'){
+ $("#edit-field-ldapregistr-epikour-loipa").show();
+
+ $('#edit-field-ldapregistr-tmim-mon-tomea-und-').prop( "checked", true );
+ $("#edit-field-ldapregistr-tmim-mon-tomea").hide();
+
+ $('#edit-field-ldapregistr-tmim-diato-und').val('_none');
+ $("#edit-field-ldapregistr-tmim-diato").hide();
+
+ $("html, body").animate({ scrollTop: $(document).height() }, 1000);
+
+ }
+
+ // Hide iatr errors.. (Starts)
+ $( "#field-ldapregistr-tmim-mon-tomea_error" ).remove();
+ $( "#edit-field-ldapregistr-tmim-mon-tomea-und").css("border-color", "#cccccc");
+
+ $( "#field-ldapregistr-tmim-diato_error" ).remove();
+ $( "#edit-field-ldapregistr-tmim-diato-und").css("border-color", "#cccccc");
+
+ $( "#field-ldapregistr-epikour-loipa_error" ).remove();
+ $( "#edit-field-ldapregistr-epikour-loipa-und").css("border-color", "#cccccc");
+ // Hide iatr errors.. (Ends)
+
+ });
+
+
+
+})(jQuery);
+
diff --git a/grnet_core/js/info-edit--inline-errors.js b/grnet_core/js/info-edit--inline-errors.js
new file mode 100644
index 0000000..362844a
--- /dev/null
+++ b/grnet_core/js/info-edit--inline-errors.js
@@ -0,0 +1,804 @@
+
+(function($) {
+ $(document).ready(function() {
+
+
+
+ // FORM ON SUBMIT CHECK (Starts)
+
+ // Elegxos formas sto submit (apenergopoieite..i drupal form..an eiani false..)
+ $("#ldapregistration-entityform-edit-form").live("submit", function () {
+ return checkform();
+ })
+
+ // FORM ON SUBMIT CHECK (Ends)
+
+
+
+
+ // FORM REALTIME CHECK (Starts)
+
+
+ // Έλεγχος Όνομα (Starts)
+ $("#edit-field-ldapregistr-name-und-0-value").live("focusout", function () {
+ check_name_field();
+ })
+ // Έλεγχος Όνομα (Ends)
+
+
+ // Έλεγχος Επώνυμο (Starts)
+ $("#edit-field-ldapregistr-surname-und-0-value").live("focusout", function () {
+ check_surname_field();
+ })
+ // Έλεγχος Επώνυμο (Ends)
+
+
+
+ // Έλεγχος AMKA (Starts)
+ $("#edit-field-ldapregistr-amka-und-0-value").live("focusout", function () {
+ check_amka_field();
+ })
+ // Έλεγχος AMKA (Ends)
+
+
+ // Έλεγχος Email (Starts)
+ $("#edit-field-ldapregistr-email-und-0-email").live("focusout", function () {
+ check_email_field();
+ })
+ // Έλεγχος Email (Ends)
+
+
+ // Έλεγχος Κατηγορίας Προσωπικού (Starts)
+ $("#edit-field-ldapregistr-personel-categ-und").live("change", function () {
+ check_personel_categ_field();
+ })
+ // Έλεγχος Κατηγορίας Προσωπικού (Ends)
+
+
+
+ // Iatriko (Starts)
+
+ // Έλεγχος Είδος Προσωπικού (Starts)
+ $("#edit-field-ldapregistr-personel-type-und").live("change", function () {
+ check_personel_type_field();
+ })
+ // Έλεγχος Είδος Προσωπικού (Ends)
+
+
+ // Έλεγχος Ειδικότητα (Starts)
+ $("#edit-field-ldapregistr-speciality-und").live("change", function () {
+ check_speciality_field();
+ })
+ // Έλεγχος Ειδικότητα (Ends)
+
+
+
+ // Τοποθέτηση σε μόναδα (Starts)
+ $("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']").live("change", function () {
+ check_iatr_top_mon_field();
+ })
+ // Τοποθέτηση σε μόναδα (Ends)
+
+
+
+
+ // Τμήματα/Μονάδες ανά τομέα (Starts)
+ $("#edit-field-ldapregistr-tmim-mon-tomea-und input[type='radio']").live("change", function () {
+ check_tmim_mon_tomea_field();
+ })
+ // Τμήματα/Μονάδες ανά τομέα (Ends)
+
+
+ // Τμήματα Διατομεακού Επιπέδου (Starts)
+ $("#edit-field-ldapregistr-tmim-diato-und").live("change", function () {
+ check_tmim_diato_field();
+ })
+ // Τμήματα Διατομεακού Επιπέδου (Ends)
+
+
+ // Επικουρικά / Λοιπά (Starts)
+ $("#edit-field-ldapregistr-epikour-loipa-und").live("change", function () {
+ check_epikour_loipa_field();
+ })
+ // Επικουρικά / Λοιπά (Ends)
+
+
+
+ // Iatriko (Ends)
+
+
+
+ // Dioikitiko (Starts)
+
+ // Έλεγχος Τοποθέτηση σε Τμήμα / Γραφείο (Starts)
+ $("#edit-field-ldapregistr-dioik-tmimgraf-und input[type='radio']").live("change", function () {
+ check_dioik_tmimgraf_field();
+ })
+ // Έλεγχος Τοποθέτηση σε Τμήμα / Γραφείο (Ends)
+
+ // Dioikitiko (Ends)
+
+
+
+ // Έλεχγος "Έχω αποθηκεύσει τον κωδικό μου σε ασφαλές μέρος" (Starts)
+ $("#edit-field-ldapregistr-saved-und").live("change", function () {
+ check_saved_field();
+ })
+ // Έλεχγος "Έχω αποθηκεύσει τον κωδικό μου σε ασφαλές μέρος" (Ends)
+
+
+ // Έλεγχος "Συμφωνώ να...user opt in" (Starts)
+ $("#edit-field-ldapregistr-opt-in-und").live("change", function () {
+ check_opt_in_field();
+ })
+ // Έλεγχος "Συμφωνώ να...user opt in" (Ends)
+
+
+ // FORM REALTIME CHECK (Ends)
+
+
+
+
+
+
+ // FUNCTIONS (Starts)
+
+
+ // Έλεγχος Στοιχείων Φόρμας (για το submit..)
+ function checkform() {
+
+ var returncode = true;
+ var firstErrorField = '';
+
+ // Έλεγχος Όνομα
+ if(!check_name_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-name-und-0-value';}
+ returncode = false;
+ }
+
+
+ // Έλεγχος Επώνυμο
+ if(!check_surname_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-surname-und-0-value';}
+ returncode = false;
+ }
+
+
+ // Έλεγχος ΑΦΜ
+// if(!check_afm_field()){
+// if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-afm-und-0-value';}
+// returncode = false;
+// }
+
+ // Έλεγχος AMKA
+ if(!check_amka_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-amka-und-0-value';}
+ returncode = false;
+ }
+
+ // Έλεγχος username (Starts)
+ if( $('#edit-field-ldapregistr-username-und-0-value').length ){
+ if(!check_username()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-username-und-0-value';}
+ returncode = false;
+ }
+ }
+ // Έλεγχος username (Ends)
+
+
+ // Έλεγχος password (Starts)
+ if( $('#edit-field-ldapregistr-pwd-und-0-password-field').length ){
+ if(!check_password()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-pwd-und-0-password-field';}
+ returncode = false;
+ }
+ }
+ // Έλεγχος password (Ends)
+
+
+ // Έλεγχος password confirm (Starts)
+ if( $('#edit-field-ldapregistr-confirmpwd-und-0-password-field').length ){
+ if(!check_password_confirm()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-confirmpwd-und-0-password-field';}
+ returncode = false;
+ }
+ }
+ // Έλεγχος password confirm (Ends)
+
+
+ // Έλεγχος Email
+ if(!check_email_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-email-und-0-email';}
+ returncode = false;
+ }
+
+
+
+
+ // Έλεγχος Κατηγορίας Προσωπικού
+ if(!check_personel_categ_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-personel-categ-und';}
+ returncode = false;
+ }
+
+
+ // Iatriko (Starts)
+
+ // Είδος προσωπικού (Starts)
+ if($("#edit-field-ldapregistr-personel-categ-und").val()=='medical'){
+ if(!check_personel_type_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-personel-type-und";}
+ returncode = false;
+ }
+ }
+ // Είδος προσωπικού (Ends)
+
+
+ // Ειδικότητες (Starts)
+ if($("#edit-field-ldapregistr-personel-type-und").val()=='esy_doctors' ||
+ $("#edit-field-ldapregistr-personel-type-und").val()=='academics'){
+
+ if(!check_speciality_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-speciality-und";}
+ returncode = false;
+ }
+
+ }
+ // Ειδικότητες (Ends)
+
+
+ // Τοποθέτηση σε μόναδα (Starts)
+ if($("#edit-field-ldapregistr-personel-categ-und").val()=='medical'){
+ if(!check_iatr_top_mon_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-iatr-top-mon-und";}
+ returncode = false;
+ }
+ }
+ // Τοποθέτηση σε μόναδα (Ends)
+
+
+
+ // Τμήματα/Μονάδες ανά τομέα (Starts)
+ if($("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val()=='iatr_tmimata_monades_ana_tomea'){
+ if(!check_tmim_mon_tomea_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-tmim-mon-tomea-und";}
+ returncode = false;
+ }
+ }
+
+ // Τμήματα/Μονάδες ανά τομέα (Ends)
+
+
+ // Τμήματα Διατομεακού Επιπέδου (Starts)
+
+ if($("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val()=='iatr_tmimata_diatomeakou_epipedou'){
+ if(!check_tmim_diato_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-tmim-diato-und";}
+ returncode = false;
+ }
+ }
+
+ // Τμήματα Διατομεακού Επιπέδου (Ends)
+
+
+
+ // Επικουρικά / Λοιπά (Starts)
+ if($("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val()=='iatr_epikourika_loipa'){
+ if(!check_epikour_loipa_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-epikour-loipa-und";}
+ returncode = false;
+ }
+ }
+ // Επικουρικά / Λοιπά (Ends)
+
+
+
+
+ // Iatriko (Ends)
+
+
+
+ // Dioikitiko (Starts)
+
+
+ // Έλεγχος Τοποθέτηση σε Τμήμα / Γραφείο (Starts)
+ if($("#edit-field-ldapregistr-personel-categ-und").val()=='administrative'){
+ if(!check_dioik_tmimgraf_field()){
+ if(firstErrorField == ''){firstErrorField = "edit-field-ldapregistr-dioik-tmimgraf-und";}
+ returncode = false;
+ }
+ }
+ // Έλεγχος Τοποθέτηση σε Τμήμα / Γραφείο (Ends)
+
+
+ // Dioikitiko (Ends)
+
+
+
+ // Έλεχγος "Έχω αποθηκεύσει τον κωδικό μου σε ασφαλές μέρος"
+ if(!check_saved_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-saved-und';}
+ returncode = false;
+ }
+
+
+ // Έλεγχος "Συμφωνώ να...user opt in"
+ if(!check_opt_in_field()){
+ if(firstErrorField == ''){firstErrorField = 'edit-field-ldapregistr-opt-in-und';}
+ returncode = false;
+ }
+
+
+ // An briskomaste sto diaxeirstiko tou manager..i tou ldapuser...iparxei i top menu bar i opoia..kribei to 1o pedio..
+ // pou brisketai..xoris timi...i mpara ayti einai 30 px sinepos..prepei na kanoume scroll alla -30..px gia na fanei..to errorous field sta diaxeristika
+ // ayto simbaieni mono stin epexergasia..kai sinepos..opou to url pattern einai /entitiform/%/edit..sinepos opou iparxei to..entitiform sto url..
+ if(window.location.href.indexOf("entityform") > -1 ){
+ menuheight = 40;
+ }else{
+ menuheight = 10;
+ }
+
+ // Scroll to firstErrorField
+ $('html,body').animate({
+ scrollTop: $("#"+firstErrorField).offset().top-menuheight},
+ 'slow');
+
+
+ return returncode;
+
+ }
+
+
+
+
+
+
+ // Functions - Fields Checks (Starts)
+
+ // Έλεγχος Όνομα
+ function check_name_field(){
+ if ($( "#edit-field-ldapregistr-name-und-0-value").val() == '') {
+ $( "#field-ldapregistr-name_error" ).remove();
+ $( "#edit-field-ldapregistr-name-und-0-value" ).after( "Παρακαλώ, συμπληρώστε το πεδίο 'Όνομα' " );
+ $( "#edit-field-ldapregistr-name-und-0-value").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-name_error" ).remove();
+ $( "#edit-field-ldapregistr-name-und-0-value").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+
+
+ // Έλεγχος Επώνυμο
+ function check_surname_field(){
+ if ($( "#edit-field-ldapregistr-surname-und-0-value").val() == '') {
+ $( "#field-ldapregistr-surname_error" ).remove();
+ $( "#edit-field-ldapregistr-surname-und-0-value" ).after( "Παρακαλώ, συμπληρώστε το πεδίο 'Επώνυμο' " );
+ $( "#edit-field-ldapregistr-surname-und-0-value").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-surname_error" ).remove();
+ $( "#edit-field-ldapregistr-surname-und-0-value").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+
+
+ // Έλεγχος ΑΦΜ
+// function check_afm_field(){
+// if (checkAFM($( "#edit-field-ldapregistr-afm-und-0-value").val()) == false) {
+// $( "#field-ldapregistr-afm_error" ).remove();
+// $( "#edit-field-ldapregistr-afm-und-0-value" ).after( "Παρακαλώ, εισάγεται ένα έγκυρο ΑΦΜ " );
+// $( "#edit-field-ldapregistr-afm-und-0-value").css("border-color", "#ff0000");
+// return false;
+// }else{
+// $( "#field-ldapregistr-afm_error" ).remove();
+// $( "#edit-field-ldapregistr-afm-und-0-value").css("border-color", "#cccccc");
+// return true;
+// }
+// }
+
+
+ // Έλεγχος ΑΜΚΑ
+ function check_amka_field(){
+
+ amka = $("#edit-field-ldapregistr-amka-und-0-value").val();
+
+ if (validateAMKA(amka) == false) {
+ $( "#field-ldapregistr-amka_error" ).remove();
+ $( "#edit-field-ldapregistr-amka-und-0-value" ).after( "Παρακαλώ, εισάγεται ένα έγκυρο ΑΜΚΑ " );
+ $( "#edit-field-ldapregistr-amka-und-0-value").css("border-color", "#ff0000");
+ amkaValid = false;
+ }else{
+
+ $.ajax({
+ url:'/registration/amkainuse/'+amka,
+ async: false,
+ success:function(data) {
+ if($.trim(data) != '0') {
+ $( "#field-ldapregistr-amka_error" ).remove();
+ $( "#edit-field-ldapregistr-amka-und-0-value" ).after( "Το ΑΜΚΑ χρησιμοποιείται ήδη!! " );
+ $( "#edit-field-ldapregistr-amka-und-0-value").css("border-color", "#ff0000");
+ amkaValid= false;
+ //scontinue = false;
+ //returncode = 0;
+ } else {
+ $( "#field-ldapregistr-amka_error" ).remove();
+ $( "#edit-field-ldapregistr-amka-und-0-value").css("border-color", "#cccccc");
+ amkaValid= true;
+ //scontinue = true;
+ //returncode = 1;
+ }
+
+ },
+ error:function(){
+ //alert('username ajax error');
+ $( "#field-ldapregistr-amka_error" ).remove();
+ $( "#edit-field-ldapregistr-amka-und-0-value" ).after( "Δεν μπόρεσε να γίνει επιβεβαίωση εγκυρότητας " );
+ $( "#edit-field-ldapregistr-amka-und-0-value").css("border-color", "#ff0000");
+ amkaValid= false;
+ }
+
+
+ });
+
+
+ }
+
+
+
+ return amkaValid;
+ }
+
+
+
+ //Έλεγχος Email
+ function check_email_field(){
+
+ //emailValid = true;
+
+ email = $("#edit-field-ldapregistr-email-und-0-email").val();
+
+ //scontinue = false;
+
+ // alert('#'+$( "#edit-field-ldapregistr-email-und-0-email").val())+'#');
+
+ if (IsEmail(email) == false) {
+ $( "#field-ldapregistr-email_error" ).remove();
+ $( "#edit-field-ldapregistr-email-und-0-email" ).after( "Παρακαλώ, εισάγεται ένα έγκυρο email " );
+ $( "#edit-field-ldapregistr-email-und-0-email").css("border-color", "#ff0000");
+ emailValid= false;
+
+ }else if (IsEmailInDomain(email) == false) {
+ $( "#field-ldapregistr-email_error" ).remove();
+ $( "#edit-field-ldapregistr-email-und-0-email" ).after( "Παρακαλώ, εισάγεται email που να ανοίκει στο domain του νοσοκομείου. " );
+ $( "#edit-field-ldapregistr-email-und-0-email").css("border-color", "#ff0000");
+ emailValid= false;
+
+ }else{
+
+ $.ajax({
+ url:'/registration/emailinuse/'+email,
+ async: false,
+ success:function(data) {
+ if($.trim(data) != '0') {
+ $( "#field-ldapregistr-email_error" ).remove();
+ $( "#edit-field-ldapregistr-email-und-0-email" ).after( "Το email χρησιμοποιείται ήδη!! " );
+ $( "#edit-field-ldapregistr-email-und-0-email").css("border-color", "#ff0000");
+ emailValid= false;
+ //scontinue = false;
+ //returncode = 0;
+ } else {
+ $( "#field-ldapregistr-email_error" ).remove();
+ $( "#edit-field-ldapregistr-email-und-0-email").css("border-color", "#cccccc");
+ emailValid= true;
+ //scontinue = true;
+ //returncode = 1;
+ }
+
+ },
+ error:function(){
+ //alert('username ajax error');
+ $( "#field-ldapregistr-email_error" ).remove();
+ $( "#edit-field-ldapregistr-email-und-0-email" ).after( "Δεν μπόρεσε να γίνει επιβεβαίωση εγκυρότητας " );
+ $( "#edit-field-ldapregistr-email-und-0-email").css("border-color", "#ff0000");
+ emailValid= false;
+ }
+
+
+ });
+
+ }
+
+
+ return emailValid;
+
+ }
+
+
+
+
+
+ //Έλεγχος Κατηγορίας Προσωπικού
+ function check_personel_categ_field(){
+ if ($( "#edit-field-ldapregistr-personel-categ-und").val() == '_none') {
+ $( "#field-ldapregistr-personel-categ_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-categ-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Κατηγορία Προσωπικού\" " );
+ $( "#edit-field-ldapregistr-personel-categ-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-personel-categ_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-categ-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+
+
+
+
+ // Iatriko (Starts)
+
+ // Είδος Προσωπικού (Starts)
+ function check_personel_type_field(){
+ if($("#edit-field-ldapregistr-personel-type-und").val() == '_none') {
+ $( "#field-ldapregistr-personel-type_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-type-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Είδος Προσωπικού\" " );
+ $( "#edit-field-ldapregistr-personel-type-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-personel-type_error" ).remove();
+ $( "#edit-field-ldapregistr-personel-type-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+ // Είδος Προσωπικού (Ends)
+
+
+
+ // Ειδικότητα (Starts)
+ function check_speciality_field(){
+ if($("#edit-field-ldapregistr-speciality-und").val() == '_none') {
+ $( "#field-ldapregistr-speciality_error" ).remove();
+ $( "#edit-field-ldapregistr-speciality-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Είδος Προσωπικού\" " );
+ $( "#edit-field-ldapregistr-speciality-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-speciality_error" ).remove();
+ $( "#edit-field-ldapregistr-speciality-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+ // Ειδικότητα (Starts)
+
+
+
+
+ // Τοποθέτηση σε μόναδα (Starts)
+ function check_iatr_top_mon_field(){
+
+ if(!$("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").size()>0 ||
+ $("#edit-field-ldapregistr-iatr-top-mon-und input[type='radio']:checked").val()=='_none' ){
+ $( "#field-ldapregistr-iatr-top-mon_error" ).remove();
+ $( "#edit-field-ldapregistr-iatr-top-mon-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Τοποθέτηση σε Τμήμα / Γραφείο\" " );
+ $( "#edit-field-ldapregistr-iatr-top-mon-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-iatr-top-mon_error" ).remove();
+ $( "#edit-field-ldapregistr-iatr-top-mon-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+ // Τοποθέτηση σε μόναδα (Starts) (Ends)
+
+
+
+
+
+
+
+
+
+ // Τμήματα/Μονάδες ανά τομέα (Starts)
+ function check_tmim_mon_tomea_field(){
+
+ if($("#edit-field-ldapregistr-tmim-mon-tomea-und input[type='radio']:checked").val()==''){
+ $( "#field-ldapregistr-tmim-mon-tomea_error" ).remove();
+ $( "#edit-field-ldapregistr-tmim-mon-tomea-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Τμήματα/Μονάδες ανά τομέα\" " );
+ $( "#edit-field-ldapregistr-tmim-mon-tomea-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-tmim-mon-tomea_error" ).remove();
+ $( "#edit-field-ldapregistr-tmim-mon-tomea-und").css("border-color", "#cccccc");
+ return true;
+ }
+
+ }
+ // Τμήματα/Μονάδες ανά τομέα (Ends)
+
+
+
+
+ // Τμήματα Διατομεακού Επιπέδου (Starts)
+ function check_tmim_diato_field(){
+
+ if($("#edit-field-ldapregistr-tmim-diato-und").val() == '_none') {
+ $( "#field-ldapregistr-tmim-diato_error" ).remove();
+ $( "#edit-field-ldapregistr-tmim-diato-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Τμήματα Διατομεακού Επιπέδου\" " );
+ $( "#edit-field-ldapregistr-tmim-diato-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-tmim-diato_error" ).remove();
+ $( "#edit-field-ldapregistr-tmim-diato-und").css("border-color", "#cccccc");
+ return true;
+ }
+
+ }
+ // Τμήματα Διατομεακού Επιπέδου (Ends)
+
+
+
+ // Επικουρικά / Λοιπά (Starts)
+ function check_epikour_loipa_field(){
+
+ if($("#edit-field-ldapregistr-epikour-loipa-und").val() == '_none') {
+ $( "#field-ldapregistr-epikour-loipa_error" ).remove();
+ $( "#edit-field-ldapregistr-epikour-loipa-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Επικουρικά / Λοιπά\" " );
+ $( "#edit-field-ldapregistr-epikour-loipa-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-epikour-loipa_error" ).remove();
+ $( "#edit-field-ldapregistr-epikour-loipa-und").css("border-color", "#cccccc");
+ return true;
+ }
+
+ }
+ // Επικουρικά / Λοιπά (Ends)
+
+
+
+
+
+
+ // Iatriko (Ends)
+
+
+
+
+ // Dioikitiko (Starts)
+
+ // Έλεγχος Τοποθέτηση σε Τμήμα / Γραφείο (Starts)
+ function check_dioik_tmimgraf_field(){
+ if($("#edit-field-ldapregistr-dioik-tmimgraf-und input[type='radio']:checked").val()==''){
+ $( "#field-ldapregistr-dioik-tmimgraf_error" ).remove();
+ $( "#edit-field-ldapregistr-dioik-tmimgraf-und" ).after( "Παρακαλώ, επιλέξτε μια τιμή στο πεδίο \"Τοποθέτηση σε Τμήμα / Γραφείο\" " );
+ $( "#edit-field-ldapregistr-dioik-tmimgraf-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-dioik-tmimgraf_error" ).remove();
+ $( "#edit-field-ldapregistr-dioik-tmimgraf-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+ // Έλεγχος Τοποθέτηση σε Τμήμα / Γραφείο (Ends)
+
+ // Dioikitiko (Ends)
+
+
+
+ //Έλεχγος "Έχω αποθηκεύσει τον κωδικό μου σε ασφαλές μέρος"
+ function check_saved_field(){
+ if ($( "#edit-field-ldapregistr-saved-und").prop( "checked") == false) {
+ $( "#field-ldapregistr-saved_error" ).remove();
+ $( "#edit-field-ldapregistr-saved-und" ).after( "Παρακαλώ, επιλέξτε το πεδίο \"Έχω αποθηκεύσει τον κωδικό μου σε ασφαλές μέρος\" " );
+ $( "#edit-field-ldapregistr-saved-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-saved_error" ).remove();
+ $( "#edit-field-ldapregistr-saved-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+
+
+ //Έλεχγος Έλεγχος "Συμφωνώ να...user opt in"
+ function check_opt_in_field(){
+ if ($( "#edit-field-ldapregistr-opt-in-und").prop( "checked")== false) {
+ $( "#field-ldapregistr-opt-in_error" ).remove();
+ $( "#edit-field-ldapregistr-opt-in-und" ).after( "Παρακαλώ, επιλέξτε το πεδίο:\n\"Αποδέχομαι τους όρους χρήσης \" " );
+ $( "#edit-field-ldapregistr-opt-in-und").css("border-color", "#ff0000");
+ return false;
+ }else{
+ $( "#field-ldapregistr-opt-in_error" ).remove();
+ $( "#edit-field-ldapregistr-opt-in-und").css("border-color", "#cccccc");
+ return true;
+ }
+ }
+
+
+ // Functions - Fields Checks (Ends)
+
+
+
+ // Mixanismos elegxou AFM
+ function checkAFM(afm) {
+ if (!afm.match(/^\d{9}$/) || afm == '000000000')
+ return false;
+
+ var m = 1, sum = 0;
+ for (var i = 7; i >= 0; i--) {
+ m *= 2;
+ sum += afm.charAt(i) * m;
+ }
+
+ return sum % 11 % 10 == afm.charAt(8);
+ }
+
+
+ // Mixanismos elegxou Email Syntax
+ function IsEmail(email) {
+ var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
+ return regex.test(email);
+ }
+
+
+
+ // Mixanismos elegxou gia to kata poso to email anoikei sto domain pou trexei to webapp
+ function IsEmailInDomain(email) {
+
+ var limitDomainSuffixedEmails = Drupal.settings.grnet_registration_form.grnet_limit_domain_suffixed_emails;
+
+ // An prepei na elegxthei...to mail gia to an anoikei sto domain..
+ if(limitDomainSuffixedEmails==1){
+ var domainName = Drupal.settings.grnet_registration_form.grnet_domain_suffixed_emails;
+
+ if(email.indexOf(domainName) > 0)
+ if((email.indexOf(domainName) + domainName.length) == email.length){
+ //do regex checking if any
+ return true;
+ }
+
+ return false;
+
+
+ // An den exei tsekaristei apo to diaxeiristiko..tote..min to elegxeis..kai epestrepse..true..
+ }else{
+ return true;
+ }
+
+
+ }
+
+
+
+ // Greek Social Security Number Validation (AMKA)
+ // Αλγόριθμος ορθότητας ΑΜΚΑ
+ function validateAMKA(amka) {
+ if (!amka.match(/^\d{11}$/) || amka == '00000000000')
+ return false;
+
+ var iSum = 0;
+ for (var i = 1; i <= amka.length; i++) {
+ var iDigit = parseInt(amka.charAt(i - 1), 10);
+ if (i % 2 === 0) {
+ iDigit *= 2;
+ if (iDigit > 9) {
+ iDigit -= 9;
+ }
+ }
+ iSum += iDigit;
+ }
+ return (iSum % 10 === 0);
+ }
+
+
+ // FUNCTIONS (Ends)
+
+
+
+ });
+})(jQuery);
+
+
+
+
diff --git a/grnet_core/js/info-view--double-highlight-diffs.js b/grnet_core/js/info-view--double-highlight-diffs.js
new file mode 100644
index 0000000..eb7e73f
--- /dev/null
+++ b/grnet_core/js/info-view--double-highlight-diffs.js
@@ -0,0 +1,115 @@
+(function($) {
+
+ $(document).ready(function() {
+
+ if(window.location.href.indexOf("requests/view/") > -1 ){
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-name").html() != $( ".grnet-info-view .grnet-field-ldapregistr-name").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-name").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-name").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-surname").html() != $( ".grnet-info-view .grnet-field-ldapregistr-surname").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-surname").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-surname").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-amka").html() != $( ".grnet-info-view .grnet-field-ldapregistr-amka").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-amka").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-amka").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-username").html() != $( ".grnet-info-view .grnet-field-ldapregistr-username").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-username").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-username").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-email").html() != $( ".grnet-info-view .grnet-field-ldapregistr-email").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-email").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-email").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-phone").html() != $( ".grnet-info-view .grnet-field-ldapregistr-phone").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-phone").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-phone").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-mobile").html() != $( ".grnet-info-view .grnet-field-ldapregistr-mobile").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-mobile").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-mobile").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-personel-categ").html() != $( ".grnet-info-view .grnet-field-ldapregistr-personel-categ").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-personel-categ").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-personel-categ").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-dicom").html() != $( ".grnet-info-view .grnet-field-ldapregistr-dicom").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-dicom").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-dicom").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-personel-type").html() != $( ".grnet-info-view .grnet-field-ldapregistr-personel-type").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-personel-type").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-personel-type").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-personel-type").html() != $( ".grnet-info-view .grnet-field-ldapregistr-personel-type").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-personel-type").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-personel-type").addClass('grnet-highlight');
+ }
+
+ // * //
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-speciality").html() != $( ".grnet-info-view .grnet-field-ldapregistr-speciality").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-speciality").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-speciality").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-iatr-top-mon").html() != $( ".grnet-info-view .grnet-field-ldapregistr-iatr-top-mon").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-iatr-top-mon").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-iatr-top-mon").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-tmim-mon-tomea").html() != $( ".grnet-info-view .grnet-field-ldapregistr-tmim-mon-tomea").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-tmim-diato").html() != $( ".grnet-info-view .grnet-field-ldapregistr-tmim-diato").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-tmim-diato").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-epikour-loipa").html() != $( ".grnet-info-view .grnet-field-ldapregistr-epikour-loipa").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-iatr-proist").html() != $( ".grnet-info-view .grnet-field-ldapregistr-iatr-proist").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-iatr-proist").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-iatr-proist").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-dioik-tmimgraf").html() != $( ".grnet-info-view .grnet-field-ldapregistr-dioik-tmimgraf").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-dioik-tmimgraf").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-dioik-tmimgraf").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-admin-proist").html() != $( ".grnet-info-view .grnet-field-ldapregistr-admin-proist").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-admin-proist").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-admin-proist").addClass('grnet-highlight');
+ }
+
+ if( $( "#ldapinfo-root .grnet-field-ldapregistr-dias-roles").html() != $( ".grnet-info-view .grnet-field-ldapregistr-dias-roles").html() ){
+ //$( "#ldapinfo-root .views-field-field-ldapregistr-dias-roles").addClass('grnet-highlight');
+ $( ".grnet-info-view .views-field-field-ldapregistr-dias-roles").addClass('grnet-highlight');
+ }
+
+ //alert($( "#ldapinfo-root .views-field-field-ldapregistr-speciality").attr("style") );
+ }
+
+
+ });
+
+
+})(jQuery);
\ No newline at end of file
diff --git a/grnet_core/js/info-view--hide-show-on-load.js b/grnet_core/js/info-view--hide-show-on-load.js
new file mode 100644
index 0000000..83cf453
--- /dev/null
+++ b/grnet_core/js/info-view--hide-show-on-load.js
@@ -0,0 +1,144 @@
+(function($) {
+
+ $(document).ready(function() {
+
+
+ // ######### Apokripsi stoixeion kartelas (Starts) #########
+
+ // @@@@@ -views- (Starts) @@@@@
+ if($(".grnet-info-view .grnet-field-ldapregistr-personel-categ").html()=='Ιατρικό'){
+ $(".grnet-info-view .views-field-field-ldapregistr-dioik-tmimgraf").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-admin-proist").hide();
+
+ // Emfanisi i oxi tis eidikotitas (Starts)
+ if( $(".grnet-info-view .grnet-field-ldapregistr-personel-type").html()=='Γιατροί ΕΣΥ' ||
+ $(".grnet-info-view .grnet-field-ldapregistr-personel-type").html()=='Πανεπιστημιακοί Γιατροί'
+ ){
+ $(".grnet-info-view .views-field-field-ldapregistr-speciality").show();
+ }else{
+ $(".grnet-info-view .views-field-field-ldapregistr-speciality").hide();
+ }
+ // Emfanisi i oxi tis eidikotitas (Ends)
+
+ // Emfanisi tis katalilis monades/tmimatos ktl.. (Starts)
+ if( $(".grnet-info-view .grnet-field-ldapregistr-iatr-top-mon").html()=='Τμήματα / Μονάδες ανά Τομέα'){
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").show();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-diato").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").hide();
+ }else if( $(".grnet-info-view .grnet-field-ldapregistr-iatr-top-mon").html()=='Τμήματα Διατομεακού Επιπέδου'){
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-diato").show();
+ $(".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").hide();
+ }else if( $(".grnet-info-view .grnet-field-ldapregistr-iatr-top-mon").html()=='Επικουρικά / Λοιπά'){
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-diato").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").show();
+ }else{
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-diato").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").hide();
+ }
+ // Emfanisi tis katalilis monades/tmimatos ktl.. (Ends)
+
+
+ }else if($(".grnet-info-view .grnet-field-ldapregistr-personel-categ").html()=='Νοσηλευτικό'){
+ $(".grnet-info-view .views-field-field-ldapregistr-dicom").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-personel-type").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-speciality").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-iatr-top-mon").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-diato").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-iatr-proist").hide();
+
+ $(".grnet-info-view .views-field-field-ldapregistr-dioik-tmimgraf").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-admin-proist").hide();
+
+
+ }else if($(".grnet-info-view .grnet-field-ldapregistr-personel-categ").html()=='Διοικητικό'){
+ $(".grnet-info-view .views-field-field-ldapregistr-dicom").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-personel-type").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-speciality").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-iatr-top-mon").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-tmim-diato").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-epikour-loipa").hide();
+ $(".grnet-info-view .views-field-field-ldapregistr-iatr-proist").hide();
+ }
+
+ // @@@@@ -views- (Ends) @@@@@
+
+
+
+
+ // @@@@@ -ldapinfo- (Starts) @@@@@
+ if($("#ldapinfo-root .grnet-field-ldapregistr-personel-categ").html()=='Ιατρικό'){
+ $("#ldapinfo-root .views-field-field-ldapregistr-dioik-tmimgraf").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-admin-proist").hide();
+
+ // Emfanisi i oxi tis eidikotitas (Starts)
+ if( $("#ldapinfo-root .grnet-field-ldapregistr-personel-type").html()=='Γιατροί ΕΣΥ' ||
+ $("#ldapinfo-root .grnet-field-ldapregistr-personel-type").html()=='Πανεπιστημιακοί Γιατροί'
+ ){
+ $("#ldapinfo-root .views-field-field-ldapregistr-speciality").show();
+ }else{
+ $("#ldapinfo-root .views-field-field-ldapregistr-speciality").hide();
+ }
+ // Emfanisi i oxi tis eidikotitas (Ends)
+
+ // Emfanisi tis katalilis monades/tmimatos ktl.. (Starts)
+ if( $("#ldapinfo-root .grnet-field-ldapregistr-iatr-top-mon").html()=='Τμήματα / Μονάδες ανά Τομέα'){
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").show();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").hide();
+ }else if( $("#ldapinfo-root .grnet-field-ldapregistr-iatr-top-mon").html()=='Τμήματα Διατομεακού Επιπέδου'){
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").show();
+ $("#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").hide();
+ }else if( $("#ldapinfo-root .grnet-field-ldapregistr-iatr-top-mon").html()=='Επικουρικά / Λοιπά'){
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").show();
+ }else{
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").hide();
+ }
+ // Emfanisi tis katalilis monades/tmimatos ktl.. (Ends)
+
+ }else if($("#ldapinfo-root .grnet-field-ldapregistr-personel-categ").html()=='Νοσηλευτικό'){
+ $("#ldapinfo-root .views-field-field-ldapregistr-dicom").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-personel-type").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-speciality").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-iatr-top-mon").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-iatr-proist").hide();
+
+ $("#ldapinfo-root .views-field-field-ldapregistr-dioik-tmimgraf").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-admin-proist").hide();
+
+ }else if($("#ldapinfo-root .grnet-field-ldapregistr-personel-categ").html()=='Διοικητικό'){
+ $("#ldapinfo-root .views-field-field-ldapregistr-dicom").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-personel-type").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-speciality").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-iatr-top-mon").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-mon-tomea").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-tmim-diato").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-epikour-loipa").hide();
+ $("#ldapinfo-root .views-field-field-ldapregistr-iatr-proist").hide();
+ }
+ // @@@@@ -ldapinfo- (Ends) @@@@@
+
+ // ######### Apokripsi stoixeion kartelas (Ends) #########
+
+
+ });
+
+
+
+
+
+
+})(jQuery);
\ No newline at end of file
diff --git a/grnet_ldap_interconnection/grnet_ldap_interconnection.admin.inc b/grnet_ldap_interconnection/grnet_ldap_interconnection.admin.inc
new file mode 100755
index 0000000..1fe1b87
--- /dev/null
+++ b/grnet_ldap_interconnection/grnet_ldap_interconnection.admin.inc
@@ -0,0 +1,89 @@
+ 'fieldset',
+ '#title' => t('Grnet Ldap Server'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+
+ $form['server']['grnet_ldaphost'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Host'),
+ '#default_value' => variable_get('grnet_ldaphost', ''),
+ '#size' => 30,
+ // Hostnames can be 255 characters long.
+ '#maxlength' => 255,
+ '#description' => t('Hostname or IP Address of the Grnet Ldap server.'),
+ );
+
+ $form['server']['grnet_ldapport'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Port'),
+ '#default_value' => variable_get('grnet_ldapport', '389'),
+ '#size' => 5,
+ // The maximum port number is 65536, 5 digits.
+ '#maxlength' => 5,
+ '#description' => t('389 is the standard ldap port'),
+ );
+
+ $form['server']['grnet_ldapbinddn'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Bind DN'),
+ '#default_value' => variable_get('grnet_ldapbinddn', ''),
+ '#size' => 30,
+ '#description' => t('The Ldap Bind DN...'),
+ );
+
+ $form['server']['grnet_ldappass'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Password'),
+ '#default_value' => variable_get('grnet_ldappass', ''),
+ '#maxlength' => 255,
+ '#description' => t('The Ldap password required to connect...'),
+ );
+
+ $form['server']['grnet_ldapbasedn'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Base DN'),
+ '#default_value' => variable_get('grnet_ldapbasedn', 'dc=domain,dc=gr'),
+ '#maxlength' => 255,
+ '#description' => t('The Ldap Base DN'),
+ );
+
+ $form['server']['grnet_ldapbasedn_people'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Base DN (people)'),
+ '#default_value' => variable_get('grnet_ldapbasedn_people', 'ou=people'),
+ '#maxlength' => 255,
+ '#description' => t('Current value : ').variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn')
+ );
+
+
+ $form['server']['grnet_ldapbasedn_units'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Ldap Base DN (units)'),
+ '#default_value' => variable_get('grnet_ldapbasedn_units', 'ou=units'),
+ '#maxlength' => 255,
+ '#description' => t('Current value : ').variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn')
+ );
+
+
+ return system_settings_form($form);
+}
diff --git a/grnet_ldap_interconnection/grnet_ldap_interconnection.info b/grnet_ldap_interconnection/grnet_ldap_interconnection.info
new file mode 100644
index 0000000..6c05953
--- /dev/null
+++ b/grnet_ldap_interconnection/grnet_ldap_interconnection.info
@@ -0,0 +1,10 @@
+name = grnet Ldap Interconnection
+description = Grnet Ldap Interconnection (Ldap Create / Update)
+configure = admin/config/system/grnet/ldap
+core = "7.x"
+package = grnet
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
diff --git a/grnet_ldap_interconnection/grnet_ldap_interconnection.info~ b/grnet_ldap_interconnection/grnet_ldap_interconnection.info~
new file mode 100644
index 0000000..785a7df
--- /dev/null
+++ b/grnet_ldap_interconnection/grnet_ldap_interconnection.info~
@@ -0,0 +1,10 @@
+name = grnet Ldap Interconnection
+description = Ggrnet Ldap Interconnection (Ldap Create / Update)
+configure = admin/config/system/grnet/ldap
+core = "7.x"
+package = grnet
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
diff --git a/grnet_ldap_interconnection/grnet_ldap_interconnection.module b/grnet_ldap_interconnection/grnet_ldap_interconnection.module
new file mode 100644
index 0000000..b1b1792
--- /dev/null
+++ b/grnet_ldap_interconnection/grnet_ldap_interconnection.module
@@ -0,0 +1,1020 @@
+ 'grnet Ldap settings',
+ 'description' => 'Configure grnet Ldap Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('grnet_ldap_interconnection_admin_settings'),
+ 'access arguments' => array('administer cas'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'grnet_ldap_interconnection.admin.inc',
+ );
+
+ $items['admin/config/grnet/ldap/settings'] = array(
+ 'title' => 'grnet Ldap',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ $items['request/alterinfo/delete/%'] = array(
+ 'title' => 'Request Request for Change Delete',
+ 'page callback' => '_request_alter_info_delete',
+ 'page arguments' => array(3),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+function _request_alter_info_delete($secretkey){
+ if($secretkey<>''){
+ $entity_id = grnet_core_get_entity_id_by_secretkey($secretkey);
+ }
+
+
+ if($entity_id>0){
+ $entity_instance = entity_load('entityform', array($entity_id));
+ $entity_instance = $entity_instance[$entity_id];
+ $entity_instance = _ldap_user_rollback_wrapper($entity_instance,'');
+
+ watchdog('grnet ldap interconnection', 'Ldap user record rolled back succesfully
+ Name/Surname : '.$entity_instance->field_ldapregistr_name['und']['0']['value'].' '.$entity_instance->field_ldapregistr_surname['und']['0']['value'], NULL , WATCHDOG_INFO);
+ $entity_instance->save();
+ }
+
+ drupal_goto("/request/alterinfo");
+
+}
+function grnet_ldap_interconnection_entity_presave($entity, $type) {
+
+
+ if(grnet_core_user_has_role('ldapuser') && $entity->type=='ldapregistration'){
+
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='completed' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='declined' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='accepted' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='accepted_minor_fixes'
+ ){
+
+ $entity_loaded = $_SESSION['grnet']['ldapregistration'][$entity->entityform_id];
+ $entity_presave = $entity;
+
+
+
+ if(grnet_core_entity_has_changed($entity_loaded, $entity_presave)){
+ $entity->field_ldapregistr_status['und']['0']['value']='request_for_change';
+ }else{
+ }
+ }
+
+
+ }
+
+
+
+
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $entity->type=='ldapregistration'
+ ){
+
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='declined'
+ ){
+
+ unset($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]);
+ if($entity->field_ldapregistr_hidden_message['und']['0']['value']<>''){
+ $manager_comments = '| Σχόλια Διαχειριστή : '.$entity->field_ldapregistr_hidden_message['und']['0']['value'];
+ }
+ $entity->field_ldapregistr_hidden_message['und']['0']['value'] = 'Η αίτηση σας απορρίφθηκε.'.$manager_comments;
+
+ _ldap_user_rollback_wrapper($entity,$type);
+ }
+
+
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='accepted'
+ ){
+ if($entity->field_ldapregistr_hidden_message['und']['0']['value']<>''){
+ $manager_comments = '| Σχόλια Διαχειριστή : '.$entity->field_ldapregistr_hidden_message['und']['0']['value'];
+ }
+ $entity->field_ldapregistr_hidden_message['und']['0']['value'] = 'Η αίτηση σας ενεκρίθη.'.$manager_comments;
+
+ }
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='accepted_minor_fixes'
+ ){
+ if($entity->field_ldapregistr_hidden_message['und']['0']['value']<>''){
+ $manager_comments = '| Σχόλια Διαχειριστή : '.$entity->field_ldapregistr_hidden_message['und']['0']['value'];
+ }
+ $entity->field_ldapregistr_hidden_message['und']['0']['value'] = 'Η αίτηση σας ενεκρίθη με μικρές αλλαγές.'.$manager_comments;
+
+ }
+
+
+
+
+
+ }
+
+
+
+
+}
+function grnet_ldap_interconnection_entity_insert($entity, $type) {
+
+ if(grnet_core_user_has_role('administrator') &&
+ $type=='taxonomy_term' &&
+ ($entity->vocabulary_machine_name='iatr_tmimata_monades_ana_tomea' ||
+ $entity->vocabulary_machine_name='iatr_tmimata_diatomeakou_epipedou' ||
+ $entity->vocabulary_machine_name='iatr_epikourika_loipa' ||
+ $entity->vocabulary_machine_name='dioik_tmimata_grafeia' ||
+ $entity->vocabulary_machine_name='specialities'
+ )
+ ){
+ _ldap_unit_create_wrapper($entity,$type);
+ }
+
+}
+function grnet_ldap_interconnection_entity_update($entity, $type) {
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $entity->type=='ldapregistration' &&
+ ( ($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='prepending' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='pending'
+ ) &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='completed'
+ )
+ ){
+ unset($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]);
+ _ldap_user_create_wrapper($entity,$type);
+ }
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $entity->type=='ldapregistration' &&
+ ($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ ($entity->field_ldapregistr_status['und']['0']['value']=='accepted' ||
+ $entity->field_ldapregistr_status['und']['0']['value']=='accepted_minor_fixes'
+ )
+ )
+ ){
+ unset($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]);
+ _ldap_user_update_wrapper($entity,$type);
+ }
+
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $type=='taxonomy_term' &&
+ ($entity->vocabulary_machine_name='iatr_tmimata_monades_ana_tomea' ||
+ $entity->vocabulary_machine_name='iatr_tmimata_diatomeakou_epipedou' ||
+ $entity->vocabulary_machine_name='iatr_epikourika_loipa' ||
+ $entity->vocabulary_machine_name='dioik_tmimata_grafeia' ||
+ $entity->vocabulary_machine_name='specialities')
+ ){
+ _ldap_unit_update_wrapper($entity,$type);
+ }
+
+}
+function grnet_ldap_interconnection_entity_delete($entity_type, $id) {
+
+ if(grnet_core_user_has_role('administrator') && $id=='entityform' &&
+ $entity_type->type='ldapregistration' && $entity_type->field_ldapregistr_username['und'][0]['value']<>''){
+ _ldap_user_delete_wrapper($entity_type);
+ }
+
+ if(grnet_core_user_has_role('administrator') &&
+ $id=='taxonomy_term'
+ ){
+ _ldap_unit_delete_wrapper($entity_type);
+ }
+}
+function _ldap_user_create_wrapper($entity, $type){
+
+
+ $ldapbasedn = variable_get('grnet_ldapbasedn');
+ $distinguishedName = '';
+ $dicomReferringPhysiciansName = '';
+ $description = '';
+ $seealso = '';
+ $proistamenos = '';
+ $eduPersonEntitlement = '';
+
+
+ if($entity->field_ldapregistr_personel_categ['und']['0']['value']=='medical'){
+
+ if($entity->field_ldapregistr_speciality['und']['0']['tid']>0){
+ $distinguishedName = 'uniqueIdentifier='.$entity->field_ldapregistr_speciality['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }
+
+ if($entity->field_ldapregistr_dicom['und']['0']['value']<>''){
+ $dicomReferringPhysiciansName = $entity->field_ldapregistr_dicom['und']['0']['value'];
+ }
+
+
+
+ $description = grnet_core_convert($entity->field_ldapregistr_personel_type['und']['0']['value']);
+
+
+
+ if($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_monades_ana_tomea'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_mon_tomea['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_diatomeakou_epipedou'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_diato['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_epikourika_loipa'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_epikour_loipa['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ }
+
+
+ if($entity->field_ldapregistr_iatr_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='administrative'){
+
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_dioik_tmimgraf['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+
+ if($entity->field_ldapregistr_admin_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='nursery'){
+ }
+
+
+ try{
+
+ $userinfo = array('objectClass' => array( 'top',
+ 'extensibleObject',
+ 'extendedAuthentication',
+ 'grHealthPerson',
+ 'inetOrgPerson'),
+
+ 'cn'=>$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'],
+ 'sn' => $entity->field_ldapregistr_surname['und']['0']['value'],
+ 'schacPersonalUniqueID'=>$entity->field_ldapregistr_amka['und']['0']['value'],
+ 'employeetype'=>grnet_core_convert($entity->field_ldapregistr_personel_categ['und']['0']['value']),
+ 'givenName'=> $entity->field_ldapregistr_name['und']['0']['value'],
+ 'mail'=>$entity->field_ldapregistr_email['und']['0']['email'],
+ 'uid'=>$entity->field_ldapregistr_username['und']['0']['value']
+ );
+
+
+
+ if($entity->field_ldapregistr_mobile['und']['0']['value']<>''){
+ $userinfo['mobile'] = $entity->field_ldapregistr_mobile['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_phone['und']['0']['value']<>''){
+ $userinfo['telephoneNumber'] = $entity->field_ldapregistr_phone['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_dias_roles['und']['0']['tid']>0){
+ $userinfo['eduPersonEntitlement'] = grnet_core_conver_dias_roles($entity->field_ldapregistr_dias_roles['und']['0']['tid']);
+ }
+
+
+
+ if($entity->field_ldapregistr_personel_categ['und']['0']['value']=='medical'){
+
+ if($distinguishedName<>''){
+ $userinfo['distinguishedName'] = $distinguishedName;
+ }
+
+ if($dicomReferringPhysiciansName<>''){
+ $userinfo['dicomReferringPhysiciansName'] = $dicomReferringPhysiciansName;
+ }
+
+ if($proistamenos<>''){
+ $userinfo = array_merge($userinfo , array( 'title'=>$proistamenos));
+ }
+
+ $userinfo = array_merge($userinfo , array( 'description'=> $description,
+ 'seealso'=>$seealso
+ )
+ );
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='administrative'){
+
+ if($proistamenos<>''){
+ $userinfo = array_merge($userinfo , array( 'title'=>$proistamenos));
+ }
+
+ $userinfo = array_merge($userinfo , array( 'seealso'=>$seealso));
+
+ }
+
+
+
+ if(!_ldap_user_exists(array("uid" => $entity->field_ldapregistr_username['und']['0']['value']))){
+ $output = _ldap_user_create($userinfo,$entity->field_ldapregistr_pwd['und']['0']['password_field']['password_field']);
+ if($output==1){
+ watchdog('grnet ldap interconnection', 'Ldap user record created succesfully
+ Name/Surname : '.$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'], NULL , WATCHDOG_INFO);
+ drupal_set_message(t('Ldap user record created succesfully!!'));
+ }
+ }else{
+ }
+
+
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+
+
+
+}
+function grnet_ldap_interconnection_unit_read_wrapper($username , $attributes_array){
+ return _ldap_user_read_wrapper($username , $attributes_array);
+}
+function _ldap_user_read_wrapper($username , $attributes_array=null){
+ $ldapbasedn = variable_get('grnet_ldapbasedn');
+ try{
+ return _ldap_user_read($username , $attributes_array);
+ }catch (exception $e){
+ var_dump($e);
+ }
+}
+
+function _ldap_user_update_wrapper($entity, $type){
+ $ldapbasedn = variable_get('grnet_ldapbasedn');
+
+
+ $mobile = array();
+ $telephoneNumber = array();
+ $distinguishedName = array();
+ $dicomReferringPhysiciansName = array();
+ $description = array();
+ $seealso = array();
+ $proistamenos = array();
+ $eduPersonEntitlement = array();
+
+ if($entity->field_ldapregistr_mobile['und']['0']['value']<>''){
+ $mobile = $entity->field_ldapregistr_mobile['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_phone['und']['0']['value']<>''){
+ $telephoneNumber = $entity->field_ldapregistr_phone['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_dias_roles['und']['0']['tid']>0){
+ $eduPersonEntitlement = grnet_core_conver_dias_roles($entity->field_ldapregistr_dias_roles['und']['0']['tid']);
+ }
+
+
+ if($entity->field_ldapregistr_personel_categ['und']['0']['value']=='medical'){
+ if($entity->field_ldapregistr_speciality['und']['0']['tid']>0){
+ $distinguishedName = 'uniqueIdentifier='.$entity->field_ldapregistr_speciality['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }
+
+ if($entity->field_ldapregistr_dicom['und']['0']['value']<>''){
+ $dicomReferringPhysiciansName = $entity->field_ldapregistr_dicom['und']['0']['value'];
+ }
+ $description = grnet_core_convert($entity->field_ldapregistr_personel_type['und']['0']['value']);
+
+ if($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_monades_ana_tomea'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_mon_tomea['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_diatomeakou_epipedou'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_diato['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_epikourika_loipa'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_epikour_loipa['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }
+
+
+ if($entity->field_ldapregistr_iatr_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='administrative'){
+
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_dioik_tmimgraf['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ if($entity->field_ldapregistr_admin_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='nursery'){
+ }
+
+
+ try{
+
+
+ $userinfo = array(
+ 'cn'=>$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'],
+ 'sn' => $entity->field_ldapregistr_surname['und']['0']['value'],
+ 'schacPersonalUniqueID'=>$entity->field_ldapregistr_amka['und']['0']['value'],
+ 'employeetype'=>grnet_core_convert($entity->field_ldapregistr_personel_categ['und']['0']['value']),
+ 'givenName'=> $entity->field_ldapregistr_name['und']['0']['value'],
+ 'mail'=>$entity->field_ldapregistr_email['und']['0']['email'],
+ 'mobile'=>$mobile,
+ 'telephoneNumber'=>$telephoneNumber,
+ 'eduPersonEntitlement'=>grnet_core_conver_dias_roles($entity->field_ldapregistr_dias_roles['und']['0']['tid']),
+ 'uid'=>$entity->field_ldapregistr_username['und']['0']['value'],
+
+ 'eduPersonEntitlement'=>$eduPersonEntitlement,
+ 'dicomReferringPhysiciansName'=>$dicomReferringPhysiciansName,
+ 'description'=> $description,
+ 'distinguishedName'=>$distinguishedName,
+ 'seealso'=>$seealso
+ );
+
+ if($proistamenos<>''){
+ $userinfo = array_merge($userinfo , array( 'title'=>$proistamenos));
+ }
+
+ if(_ldap_user_exists(array("uid" => $entity->field_ldapregistr_username['und']['0']['value']))){
+ $output = _ldap_user_update($userinfo);
+ if($output==1){
+ watchdog('grnet ldap interconnection', 'Ldap user record updated succesfully
+ Name/Surname : '.$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'], NULL , WATCHDOG_INFO);
+ drupal_set_message(t('Ldap user record updated succesfully!!'));
+ }
+ }else{
+ }
+ }catch (exception $e){
+ var_dump($e);
+ }
+}
+function _ldap_user_delete_wrapper($entity_type){
+
+
+ if(grnet_core_user_has_role('administrator')){
+
+ try{
+ if(_ldap_user_exists(array("uid" => $entity_type->field_ldapregistr_username['und']['0']['value']))){
+ $output = _ldap_user_delete($entity_type->field_ldapregistr_username['und']['0']['value']);
+ if($output==1){
+ watchdog('grnet ldap interconnection', 'Ldap user record deleted succesfully
+ username : '.$entity_type->field_ldapregistr_username['und']['0']['value'], NULL , WATCHDOG_INFO);
+ drupal_set_message(t("Ldap User record deleted succesfully!!"));
+ }
+ }else{
+ }
+ }catch (exception $e){
+ var_dump($e);
+ }
+ }else{
+ }
+
+}
+ /**
+ * Method to rollback changes from a "request for change" an ldapuser ask for
+ * and a manager declined
+ * Technically..drupal database will be updated from the values that are stored in ldap
+ * (in a accepted or accepted with minor changes...sittuation...we have the oposite... The ldap is getting update from the values that are stored in drupal database)
+ *
+ * @access private
+ * @param object $entity
+ * @param string $type
+ * @return void
+ */
+ function _ldap_user_rollback_wrapper($entity, $type){
+
+ $entity->field_ldapregistr_status['und']['0']['value']='declined';
+
+
+ $entity->field_ldapregistr_iatr_top_mon['und'] = array();
+ $entity->field_ldapregistr_dicom['und'] = array();
+ $entity->field_ldapregistr_personel_type['und'] = array();
+
+ $entity->field_ldapregistr_admin_proist['und']['0']['value']='0';
+ $entity->field_ldapregistr_iatr_proist['und']['0']['value']='0';
+
+
+ $entity->field_ldapregistr_speciality['und'] = array();
+ $entity->field_ldapregistr_tmim_mon_tomea = array();
+ $entity->field_ldapregistr_tmim_diato['und'] = array();
+ $entity->field_ldapregistr_epikour_loipa['und'] = array();
+ $entity->field_ldapregistr_dioik_tmimgraf = array();
+ $entity->field_ldapregistr_dias_roles['und'] = array();
+
+
+ $username = grnet_core_get_ldapinfo_user();
+ $ldapinfo_user = grnet_ldap_interconnection_unit_read_wrapper($username);
+
+
+ $entity->field_ldapregistr_name['und']['0']['value'] = $ldapinfo_user["givenname"][0];
+ $entity->field_ldapregistr_surname['und']['0']['value'] = $ldapinfo_user["sn"][0];
+ $entity->field_ldapregistr_amka['und']['0']['value'] = $ldapinfo_user["schacpersonaluniqueid"][0];
+ $entity->field_ldapregistr_email['und']['0']['email'] = $ldapinfo_user["mail"][0];
+ $entity->field_ldapregistr_phone['und']['0']['value'] = $ldapinfo_user["telephonenumber"][0];
+ $entity->field_ldapregistr_mobile['und']['0']['value'] = $ldapinfo_user["mobile"][0];
+$entity->field_ldapregistr_personel_categ['und']['0']['value'] = grnet_core_convert($ldapinfo_user["employeetype"][0],TRUE);
+ if($ldapinfo_user["edupersonentitlement"][0] <> ''){
+ $entity->field_ldapregistr_dias_roles['und']['0']['tid'] = grnet_core_conver_dias_roles_revert_to_tid($ldapinfo_user["edupersonentitlement"][0]);
+ }
+
+
+ if(grnet_core_convert($ldapinfo_user["employeetype"][0],TRUE)=='medical'){
+
+ if($ldapinfo_user["seealso"][0]<>''){
+ $entity->field_ldapregistr_iatr_top_mon['und']['0']['value'] = taxonomy_vocabulary_load(grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid)->machine_name;
+ }
+
+ if($ldapinfo_user["distinguishedname"][0]<>''){
+ $entity->field_ldapregistr_speciality['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["distinguishedname"][0])->tid;
+ }
+
+ if($ldapinfo_user["dicomreferringphysiciansname"][0]<>''){
+ $entity->field_ldapregistr_dicom['und']['0']['value'] = $ldapinfo_user["dicomreferringphysiciansname"][0];
+ }
+
+
+ if($ldapinfo_user["title"][0]=='manager'){
+ $entity->field_ldapregistr_iatr_proist['und']['0']['value']='1';
+ }else{
+ $entity->field_ldapregistr_iatr_proist['und']['0']['value']='0';
+ }
+
+
+ $entity->field_ldapregistr_personel_type['und']['0']['value'] = grnet_core_convert($ldapinfo_user["description"][0],TRUE);
+
+
+ switch (grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid){
+
+ case 2:
+ $entity->field_ldapregistr_tmim_mon_tomea['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+ break;
+
+ case 4:
+ $entity->field_ldapregistr_tmim_diato['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+ break;
+
+ case 5:
+ $entity->field_ldapregistr_epikour_loipa['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+ break;
+ }
+
+
+ }elseif(grnet_core_convert($ldapinfo_user["employeetype"][0],TRUE)=='administrative'){
+ if($ldapinfo_user["title"][0]=='manager'){
+ $entity->field_ldapregistr_admin_proist['und']['0']['value']='1';
+ }else{
+ $entity->field_ldapregistr_admin_proist['und']['0']['value']='0';
+ }
+
+ $entity->field_ldapregistr_dioik_tmimgraf['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+
+ }
+
+
+ return $entity;
+
+}
+function grnet_ldap_interconnection_ldap_user_exists_wrapper($attributes){
+ return _ldap_user_exists($attributes);
+}
+ function _ldap_user_create($user,$password) {
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $res=false;
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uid=".$user['uid'].",$ldapbasedn";
+
+
+
+
+
+
+ module_load_include('module', 'password_field', 'password_field');
+
+
+ $user['userpassword']="{SHA}" . base64_encode( pack( "H*", sha1( password_field_decrypt($password) ) ) );
+
+ $res=ldap_add($conn, $rdn, $user);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+ function _ldap_user_read($username , $attributes_array=null){
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $filter = "(uid=$username)";
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ if(count($attributes_array) > 0){
+ }else{
+ }
+
+
+ $info = ldap_get_entries($conn, $SearchResult);
+
+ if($info['count']>0) {
+ return $info[0];
+ }else{
+ return NULL;
+ }
+
+ }catch(Exception $e)
+ {
+ $log->error($e->getMessage());
+ return false;
+ }
+
+
+ }
+
+
+
+ function _ldap_user_update($userinfo) {
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+
+ $rdn = "uid=".$userinfo['uid'].",$ldapbasedn";
+
+ ldap_close($conn);
+ return $ldap_modify_message;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+ function _ldap_user_delete($username) {
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $res=false;
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uid=".$username.",$ldapbasedn";
+ $res=ldap_delete($conn,$rdn);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+ function _ldap_user_exists($attributes){
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $filter = grnet_ldap_interconnection_construct_filter($attributes);
+
+
+ $returnAttributes = array("uid");
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $info = ldap_get_entries($conn, $SearchResult);
+
+ if($info['count']>0) {
+ return true;
+ }else{
+ return false;
+ }
+
+ }catch(Exception $e)
+ {
+ $log->error($e->getMessage());
+ return false;
+ }
+
+
+ }
+
+
+
+
+
+
+
+ function grnet_ldap_interconnection_unit_create_wrapper($entity){
+ return _ldap_unit_create_wrapper($entity);
+ }
+
+ function _ldap_unit_create_wrapper($entity, $type=NULL){
+
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+
+
+
+ try{
+ $unit = array('objectClass' => array( 'top',
+ 'extensibleObject',
+ 'organization',
+ 'organizationalUnit',
+ 'pilotOrganization'),
+
+ 'o' => $entity->name,
+ 'ou' => $entity->field_backend_name['und']['0']['value'],
+ 'businessCategory' => taxonomy_vocabulary_load($entity->vid)->description,
+ 'uniqueIdentifier' => $entity->tid
+ );
+
+ if(reset($entity->parent)>0) {
+ $unit['seeAlso'] = "uniqueIdentifier=".reset($entity->parent).",ou=Units,".$ldapbasedn;
+ }
+
+ if( !_ldap_unit_exists($entity->tid)){
+ $output = _ldap_unit_create($unit);
+ if($output==1){
+ drupal_set_message(t("Ldap unit record created succesfully!!"));
+ return $output;
+ }
+ }else{
+ drupal_set_message(t("PROBLEM!! Ldap Unit record couldn't be inserted!!"), 'error');
+ }
+
+
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+ function _ldap_unit_update_wrapper($entity, $type){
+
+
+ $unit_values = array();
+ $unit_values['tid'] = $entity->tid;
+ $unit_values['name'] = $entity->name;
+ $unit_values['backend_name'] = $entity->field_backend_name['und']['0']['value'];
+ $unit_values['parent'] = reset($entity->parent);
+
+
+ try{
+ $_SESSION['flafla'] = $type;
+
+ if(_ldap_unit_exists($entity->tid)){
+ $output = _ldap_unit_update($entity);
+ if($output==1){
+ drupal_set_message(t("Ldap unit record updated succesfully!!"));
+ }
+ }else{
+ drupal_set_message(t("PROBLEM!! Ldap Unit record couldn't be updated as it couldn't be found!!"), 'error');
+ drupal_set_message('output = '.$output);
+ }
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+ }
+
+
+ function _ldap_unit_delete_wrapper($entity_type){
+
+ try{
+
+ if(_ldap_unit_exists($entity_type->tid)){
+ $output = _ldap_unit_delete($entity_type->tid);
+ if($output==1){
+ drupal_set_message(t("Ldap Unit record deleted succesfully!!"));
+ }
+ }else{
+ drupal_set_message(t("PROBLEM!! Ldap Unit record couldn't be deleted as it couldn't be found!!"), 'error');
+ drupal_set_message('output = '.$output);
+ }
+
+
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+ function _ldap_unit_create($unit) {
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+ $res=false;
+
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uniqueIdentifier=".$unit['uniqueIdentifier'].",$ldapbasedn";
+
+ $res=ldap_add($conn, $rdn, $unit);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+ function _ldap_unit_exists($tid){
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+
+
+
+ $filter = "(uniqueIdentifier=$tid)";
+ $attributes = array("uniqueIdentifier");
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $info = ldap_get_entries($conn, $SearchResult);
+
+ if($info['count']>0) {
+ return true;
+ }else{
+ return false;
+ }
+
+ }catch(Exception $e)
+ {
+ $log->error($e->getMessage());
+ return false;
+ }
+
+
+ }
+
+ function _ldap_unit_update($unit) {
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+
+
+ $info = array( "o" => $unit->name,
+ "ou" => $unit->field_backend_name['und']['0']['value'],
+ "businessCategory" => taxonomy_vocabulary_load($unit->vid)->description
+ );
+
+ $_SESSION['kko'] = reset($unit->parent);
+ if(reset($unit->parent)<>'0'){
+ $info['seeAlso'] = 'uniqueIdentifier='.reset($unit->parent).",$ldapbasedn";
+ }
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+
+ $rdn = "uniqueIdentifier=".$unit->tid.",$ldapbasedn";
+ $_SESSION['unit_values'] = $info;
+
+ ldap_close($conn);
+ return $ldap_modify_message;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+ function _ldap_unit_delete($tid) {
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+
+
+ $res=false;
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uniqueIdentifier=".$tid.",$ldapbasedn";
+
+ $res=ldap_delete($conn, $rdn);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+
+ function grnet_ldap_interconnection_construct_filter($attributes){
+ $counter=0;
+ $filterTemp ='';
+ $filter='';
+ foreach($attributes as $key => $value){
+
+ $filterTemp .= "($key=$value)";
+ $counter++;
+ }
+
+ if($counter>1){
+ $filter = "(&";
+ }
+
+ $filter .=$filterTemp;
+
+ if($counter>1){
+ $filter .= ")";
+ }
+
+ return $filter;
+ }
+
+?>
diff --git a/grnet_ldap_interconnection/grnet_ldap_interconnection.module~ b/grnet_ldap_interconnection/grnet_ldap_interconnection.module~
new file mode 100644
index 0000000..aae94ee
--- /dev/null
+++ b/grnet_ldap_interconnection/grnet_ldap_interconnection.module~
@@ -0,0 +1,1050 @@
+ 'grnet Ldap settings',
+ 'description' => 'Configure grnet Ldap Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('grnet_ldap_interconnection_admin_settings'),
+ 'access arguments' => array('administer cas'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'grnet_ldap_interconnection.admin.inc',
+ );
+
+ $items['admin/config/grnet/ldap/settings'] = array(
+ 'title' => 'grnet Ldap',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ $items['request/alterinfo/delete/%'] = array(
+ 'title' => 'Request Request for Change Delete',
+ 'page callback' => '_request_alter_info_delete',
+ 'page arguments' => array(3),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+function _request_alter_info_delete($secretkey){
+ if($secretkey<>''){
+ $entity_id = grnet_core_get_entity_id_by_secretkey($secretkey);
+ }
+
+
+ if($entity_id>0){
+ $entity_instance = entity_load('entityform', array($entity_id));
+ $entity_instance = $entity_instance[$entity_id];
+ $entity_instance = _ldap_user_rollback_wrapper($entity_instance,'');
+
+ watchdog('grnet ldap interconnection', 'Ldap user record rolled back succesfully
+ Name/Surname : '.$entity_instance->field_ldapregistr_name['und']['0']['value'].' '.$entity_instance->field_ldapregistr_surname['und']['0']['value'], NULL , WATCHDOG_INFO);
+ $entity_instance->save();
+ }
+
+ drupal_goto("/request/alterinfo");
+
+}
+function grnet_ldap_interconnection_entity_presave($entity, $type) {
+
+
+ if(grnet_core_user_has_role('ldapuser') && $entity->type=='ldapregistration'){
+
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='completed' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='declined' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='accepted' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='accepted_minor_fixes'
+ ){
+
+ $entity_loaded = $_SESSION['grnet']['ldapregistration'][$entity->entityform_id];
+ $entity_presave = $entity;
+
+
+
+ if(grnet_core_entity_has_changed($entity_loaded, $entity_presave)){
+ $entity->field_ldapregistr_status['und']['0']['value']='request_for_change';
+ }else{
+ }
+
+ /*
+ drupal_set_message('elegxos entities diff');
+
+ $_SESSION['prin'] = $_SESSION['grnet']['ldapregistration'][$entity->entityform_id];
+ $_SESSION['meta'] = $entity;
+
+ drupal_set_message('
+ drupal_set_message('@@'.$entity->field_ldapregistr_name['und'][0]['value'].'@@');
+ */
+
+
+
+ }
+
+
+ }
+
+
+
+
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $entity->type=='ldapregistration'
+ ){
+
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='declined'
+ ){
+
+ unset($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]);
+ if($entity->field_ldapregistr_hidden_message['und']['0']['value']<>''){
+ $manager_comments = '| Σχόλια Διαχειριστή : '.$entity->field_ldapregistr_hidden_message['und']['0']['value'];
+ }
+ $entity->field_ldapregistr_hidden_message['und']['0']['value'] = 'Η αίτηση σας απορρίφθηκε.'.$manager_comments;
+
+ _ldap_user_rollback_wrapper($entity,$type);
+ }
+
+
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='accepted'
+ ){
+ if($entity->field_ldapregistr_hidden_message['und']['0']['value']<>''){
+ $manager_comments = '| Σχόλια Διαχειριστή : '.$entity->field_ldapregistr_hidden_message['und']['0']['value'];
+ }
+ $entity->field_ldapregistr_hidden_message['und']['0']['value'] = 'Η αίτηση σας ενεκρίθη.'.$manager_comments;
+
+ }
+ if($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='accepted_minor_fixes'
+ ){
+ if($entity->field_ldapregistr_hidden_message['und']['0']['value']<>''){
+ $manager_comments = '| Σχόλια Διαχειριστή : '.$entity->field_ldapregistr_hidden_message['und']['0']['value'];
+ }
+ $entity->field_ldapregistr_hidden_message['und']['0']['value'] = 'Η αίτηση σας ενεκρίθη με μικρές αλλαγές.'.$manager_comments;
+
+ }
+
+
+
+
+
+ }
+
+
+
+
+}
+function grnet_ldap_interconnection_entity_insert($entity, $type) {
+
+ if(grnet_core_user_has_role('administrator') &&
+ $type=='taxonomy_term' &&
+ ($entity->vocabulary_machine_name='iatr_tmimata_monades_ana_tomea' ||
+ $entity->vocabulary_machine_name='iatr_tmimata_diatomeakou_epipedou' ||
+ $entity->vocabulary_machine_name='iatr_epikourika_loipa' ||
+ $entity->vocabulary_machine_name='dioik_tmimata_grafeia' ||
+ $entity->vocabulary_machine_name='specialities'
+ )
+ ){
+ _ldap_unit_create_wrapper($entity,$type);
+ }
+
+}
+function grnet_ldap_interconnection_entity_update($entity, $type) {
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $entity->type=='ldapregistration' &&
+ ( ($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='prepending' ||
+ $_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='pending'
+ ) &&
+ $entity->field_ldapregistr_status['und']['0']['value']=='completed'
+ )
+ ){
+ unset($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]);
+ _ldap_user_create_wrapper($entity,$type);
+ }
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $entity->type=='ldapregistration' &&
+ ($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]->field_ldapregistr_status['und']['0']['value']=='request_for_change' &&
+ ($entity->field_ldapregistr_status['und']['0']['value']=='accepted' ||
+ $entity->field_ldapregistr_status['und']['0']['value']=='accepted_minor_fixes'
+ )
+ )
+ ){
+ unset($_SESSION['grnet']['ldapregistration'][$entity->entityform_id]);
+ _ldap_user_update_wrapper($entity,$type);
+ }
+
+
+ if( (grnet_core_user_has_role('manager') || grnet_core_user_has_role('administrator')) &&
+ $type=='taxonomy_term' &&
+ ($entity->vocabulary_machine_name='iatr_tmimata_monades_ana_tomea' ||
+ $entity->vocabulary_machine_name='iatr_tmimata_diatomeakou_epipedou' ||
+ $entity->vocabulary_machine_name='iatr_epikourika_loipa' ||
+ $entity->vocabulary_machine_name='dioik_tmimata_grafeia' ||
+ $entity->vocabulary_machine_name='specialities')
+ ){
+ _ldap_unit_update_wrapper($entity,$type);
+ }
+
+}
+function grnet_ldap_interconnection_entity_delete($entity_type, $id) {
+
+ if(grnet_core_user_has_role('administrator') && $id=='entityform' &&
+ $entity_type->type='ldapregistration' && $entity_type->field_ldapregistr_username['und'][0]['value']<>''){
+ _ldap_user_delete_wrapper($entity_type);
+ }
+
+ if(grnet_core_user_has_role('administrator') &&
+ $id=='taxonomy_term'
+ ){
+ _ldap_unit_delete_wrapper($entity_type);
+ }
+}
+function _ldap_user_create_wrapper($entity, $type){
+
+
+ $ldapbasedn = variable_get('grnet_ldapbasedn');
+ $distinguishedName = '';
+ $dicomReferringPhysiciansName = '';
+ $description = '';
+ $seealso = '';
+ $proistamenos = '';
+ $eduPersonEntitlement = '';
+
+
+ if($entity->field_ldapregistr_personel_categ['und']['0']['value']=='medical'){
+
+ if($entity->field_ldapregistr_speciality['und']['0']['tid']>0){
+ $distinguishedName = 'uniqueIdentifier='.$entity->field_ldapregistr_speciality['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }
+
+ if($entity->field_ldapregistr_dicom['und']['0']['value']<>''){
+ $dicomReferringPhysiciansName = $entity->field_ldapregistr_dicom['und']['0']['value'];
+ }
+
+
+
+ $description = grnet_core_convert($entity->field_ldapregistr_personel_type['und']['0']['value']);
+
+
+
+ if($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_monades_ana_tomea'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_mon_tomea['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_diatomeakou_epipedou'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_diato['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_epikourika_loipa'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_epikour_loipa['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ }
+
+
+ if($entity->field_ldapregistr_iatr_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='administrative'){
+
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_dioik_tmimgraf['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+
+ if($entity->field_ldapregistr_admin_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='nursery'){
+ }
+
+
+ try{
+
+ $userinfo = array('objectClass' => array( 'top',
+ 'extensibleObject',
+ 'extendedAuthentication',
+ 'grHealthPerson',
+ 'inetOrgPerson'),
+
+ 'cn'=>$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'],
+ 'sn' => $entity->field_ldapregistr_surname['und']['0']['value'],
+ 'schacPersonalUniqueID'=>$entity->field_ldapregistr_amka['und']['0']['value'],
+ 'employeetype'=>grnet_core_convert($entity->field_ldapregistr_personel_categ['und']['0']['value']),
+ 'givenName'=> $entity->field_ldapregistr_name['und']['0']['value'],
+ 'mail'=>$entity->field_ldapregistr_email['und']['0']['email'],
+ 'uid'=>$entity->field_ldapregistr_username['und']['0']['value']
+ );
+
+
+
+ if($entity->field_ldapregistr_mobile['und']['0']['value']<>''){
+ $userinfo['mobile'] = $entity->field_ldapregistr_mobile['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_phone['und']['0']['value']<>''){
+ $userinfo['telephoneNumber'] = $entity->field_ldapregistr_phone['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_dias_roles['und']['0']['tid']>0){
+ $userinfo['eduPersonEntitlement'] = grnet_core_conver_dias_roles($entity->field_ldapregistr_dias_roles['und']['0']['tid']);
+ }
+
+
+
+ if($entity->field_ldapregistr_personel_categ['und']['0']['value']=='medical'){
+
+ if($distinguishedName<>''){
+ $userinfo['distinguishedName'] = $distinguishedName;
+ }
+
+ if($dicomReferringPhysiciansName<>''){
+ $userinfo['dicomReferringPhysiciansName'] = $dicomReferringPhysiciansName;
+ }
+
+ if($proistamenos<>''){
+ $userinfo = array_merge($userinfo , array( 'title'=>$proistamenos));
+ }
+
+ $userinfo = array_merge($userinfo , array( 'description'=> $description,
+ 'seealso'=>$seealso
+ )
+ );
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='administrative'){
+
+ if($proistamenos<>''){
+ $userinfo = array_merge($userinfo , array( 'title'=>$proistamenos));
+ }
+
+ $userinfo = array_merge($userinfo , array( 'seealso'=>$seealso));
+
+ }
+
+
+
+ if(!_ldap_user_exists(array("uid" => $entity->field_ldapregistr_username['und']['0']['value']))){
+ $output = _ldap_user_create($userinfo,$entity->field_ldapregistr_pwd['und']['0']['password_field']['password_field']);
+ if($output==1){
+ watchdog('grnet ldap interconnection', 'Ldap user record created succesfully
+ Name/Surname : '.$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'], NULL , WATCHDOG_INFO);
+ drupal_set_message(t('Ldap user record created succesfully!!'));
+ }
+ }else{
+ }
+
+
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+
+
+
+}
+function grnet_ldap_interconnection_unit_read_wrapper($username , $attributes_array){
+ return _ldap_user_read_wrapper($username , $attributes_array);
+}
+function _ldap_user_read_wrapper($username , $attributes_array=null){
+ $ldapbasedn = variable_get('grnet_ldapbasedn');
+ try{
+ return _ldap_user_read($username , $attributes_array);
+ }catch (exception $e){
+ var_dump($e);
+ }
+}
+
+function _ldap_user_update_wrapper($entity, $type){
+ $ldapbasedn = variable_get('grnet_ldapbasedn');
+
+
+ $mobile = array();
+ $telephoneNumber = array();
+ $distinguishedName = array();
+ $dicomReferringPhysiciansName = array();
+ $description = array();
+ $seealso = array();
+ $proistamenos = array();
+ $eduPersonEntitlement = array();
+
+ if($entity->field_ldapregistr_mobile['und']['0']['value']<>''){
+ $mobile = $entity->field_ldapregistr_mobile['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_phone['und']['0']['value']<>''){
+ $telephoneNumber = $entity->field_ldapregistr_phone['und']['0']['value'];
+ }
+
+ if($entity->field_ldapregistr_dias_roles['und']['0']['tid']>0){
+ $eduPersonEntitlement = grnet_core_conver_dias_roles($entity->field_ldapregistr_dias_roles['und']['0']['tid']);
+ }
+
+
+ if($entity->field_ldapregistr_personel_categ['und']['0']['value']=='medical'){
+ if($entity->field_ldapregistr_speciality['und']['0']['tid']>0){
+ $distinguishedName = 'uniqueIdentifier='.$entity->field_ldapregistr_speciality['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }
+
+ if($entity->field_ldapregistr_dicom['und']['0']['value']<>''){
+ $dicomReferringPhysiciansName = $entity->field_ldapregistr_dicom['und']['0']['value'];
+ }
+ $description = grnet_core_convert($entity->field_ldapregistr_personel_type['und']['0']['value']);
+
+ if($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_monades_ana_tomea'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_mon_tomea['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_tmimata_diatomeakou_epipedou'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_tmim_diato['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }elseif($entity->field_ldapregistr_iatr_top_mon['und']['0']['value']=='iatr_epikourika_loipa'){
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_epikour_loipa['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+ }
+
+
+ if($entity->field_ldapregistr_iatr_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='administrative'){
+
+ $seealso = 'uniqueIdentifier='.$entity->field_ldapregistr_dioik_tmimgraf['und']['0']['tid'].',ou=Units,'.$ldapbasedn;
+
+ if($entity->field_ldapregistr_admin_proist['und']['0']['value']=='1'){
+ $proistamenos = 'manager';
+ }
+
+
+ }elseif($entity->field_ldapregistr_personel_categ['und']['0']['value']=='nursery'){
+ }
+
+
+ try{
+
+
+ $userinfo = array(
+ 'cn'=>$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'],
+ 'sn' => $entity->field_ldapregistr_surname['und']['0']['value'],
+ 'schacPersonalUniqueID'=>$entity->field_ldapregistr_amka['und']['0']['value'],
+ 'employeetype'=>grnet_core_convert($entity->field_ldapregistr_personel_categ['und']['0']['value']),
+ 'givenName'=> $entity->field_ldapregistr_name['und']['0']['value'],
+ 'mail'=>$entity->field_ldapregistr_email['und']['0']['email'],
+ 'mobile'=>$mobile,
+ 'telephoneNumber'=>$telephoneNumber,
+ 'eduPersonEntitlement'=>grnet_core_conver_dias_roles($entity->field_ldapregistr_dias_roles['und']['0']['tid']),
+ 'uid'=>$entity->field_ldapregistr_username['und']['0']['value'],
+
+ 'eduPersonEntitlement'=>$eduPersonEntitlement,
+ 'dicomReferringPhysiciansName'=>$dicomReferringPhysiciansName,
+ 'description'=> $description,
+ 'distinguishedName'=>$distinguishedName,
+ 'seealso'=>$seealso
+ );
+
+ if($proistamenos<>''){
+ $userinfo = array_merge($userinfo , array( 'title'=>$proistamenos));
+ }
+
+ if(_ldap_user_exists(array("uid" => $entity->field_ldapregistr_username['und']['0']['value']))){
+ $output = _ldap_user_update($userinfo);
+ if($output==1){
+ watchdog('grnet ldap interconnection', 'Ldap user record updated succesfully
+ Name/Surname : '.$entity->field_ldapregistr_name['und']['0']['value'].' '.$entity->field_ldapregistr_surname['und']['0']['value'], NULL , WATCHDOG_INFO);
+ drupal_set_message(t('Ldap user record updated succesfully!!'));
+ }
+ }else{
+ }
+ }catch (exception $e){
+ var_dump($e);
+ }
+}
+function _ldap_user_delete_wrapper($entity_type){
+
+
+ if(grnet_core_user_has_role('administrator')){
+
+ try{
+ if(_ldap_user_exists(array("uid" => $entity_type->field_ldapregistr_username['und']['0']['value']))){
+ $output = _ldap_user_delete($entity_type->field_ldapregistr_username['und']['0']['value']);
+ if($output==1){
+ watchdog('grnet ldap interconnection', 'Ldap user record deleted succesfully
+ username : '.$entity_type->field_ldapregistr_username['und']['0']['value'], NULL , WATCHDOG_INFO);
+ drupal_set_message(t("Ldap User record deleted succesfully!!"));
+ }
+ }else{
+ }
+ }catch (exception $e){
+ var_dump($e);
+ }
+ }else{
+ }
+
+}
+ /**
+ * Method to rollback changes from a "request for change" an ldapuser ask for
+ * and a manager declined
+ * Technically..drupal database will be updated from the values that are stored in ldap
+ * (in a accepted or accepted with minor changes...sittuation...we have the oposite... The ldap is getting update from the values that are stored in drupal database)
+ *
+ * @access private
+ * @param object $entity
+ * @param string $type
+ * @return void
+ */
+ function _ldap_user_rollback_wrapper($entity, $type){
+
+ $entity->field_ldapregistr_status['und']['0']['value']='declined';
+
+
+ $entity->field_ldapregistr_iatr_top_mon['und'] = array();
+ $entity->field_ldapregistr_dicom['und'] = array();
+ $entity->field_ldapregistr_personel_type['und'] = array();
+
+ $entity->field_ldapregistr_admin_proist['und']['0']['value']='0';
+ $entity->field_ldapregistr_iatr_proist['und']['0']['value']='0';
+
+
+ $entity->field_ldapregistr_speciality['und'] = array();
+ $entity->field_ldapregistr_tmim_mon_tomea = array();
+ $entity->field_ldapregistr_tmim_diato['und'] = array();
+ $entity->field_ldapregistr_epikour_loipa['und'] = array();
+ $entity->field_ldapregistr_dioik_tmimgraf = array();
+ $entity->field_ldapregistr_dias_roles['und'] = array();
+
+
+ $username = grnet_core_get_ldapinfo_user();
+ $ldapinfo_user = grnet_ldap_interconnection_unit_read_wrapper($username);
+
+
+ $entity->field_ldapregistr_name['und']['0']['value'] = $ldapinfo_user["givenname"][0];
+ $entity->field_ldapregistr_surname['und']['0']['value'] = $ldapinfo_user["sn"][0];
+ $entity->field_ldapregistr_amka['und']['0']['value'] = $ldapinfo_user["schacpersonaluniqueid"][0];
+ $entity->field_ldapregistr_email['und']['0']['email'] = $ldapinfo_user["mail"][0];
+ $entity->field_ldapregistr_phone['und']['0']['value'] = $ldapinfo_user["telephonenumber"][0];
+ $entity->field_ldapregistr_mobile['und']['0']['value'] = $ldapinfo_user["mobile"][0];
+$entity->field_ldapregistr_personel_categ['und']['0']['value'] = grnet_core_convert($ldapinfo_user["employeetype"][0],TRUE);
+ if($ldapinfo_user["edupersonentitlement"][0] <> ''){
+ $entity->field_ldapregistr_dias_roles['und']['0']['tid'] = grnet_core_conver_dias_roles_revert_to_tid($ldapinfo_user["edupersonentitlement"][0]);
+ }
+
+
+ if(grnet_core_convert($ldapinfo_user["employeetype"][0],TRUE)=='medical'){
+
+ if($ldapinfo_user["seealso"][0]<>''){
+ $entity->field_ldapregistr_iatr_top_mon['und']['0']['value'] = taxonomy_vocabulary_load(grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid)->machine_name;
+ }
+
+ if($ldapinfo_user["distinguishedname"][0]<>''){
+ $entity->field_ldapregistr_speciality['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["distinguishedname"][0])->tid;
+ }
+
+ if($ldapinfo_user["dicomreferringphysiciansname"][0]<>''){
+ $entity->field_ldapregistr_dicom['und']['0']['value'] = $ldapinfo_user["dicomreferringphysiciansname"][0];
+ }
+
+
+ if($ldapinfo_user["title"][0]=='manager'){
+ $entity->field_ldapregistr_iatr_proist['und']['0']['value']='1';
+ }else{
+ $entity->field_ldapregistr_iatr_proist['und']['0']['value']='0';
+ }
+
+
+ $entity->field_ldapregistr_personel_type['und']['0']['value'] = grnet_core_convert($ldapinfo_user["description"][0],TRUE);
+
+
+ switch (grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid){
+
+ case 2:
+ $entity->field_ldapregistr_tmim_mon_tomea['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+ break;
+
+ case 4:
+ $entity->field_ldapregistr_tmim_diato['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+ break;
+
+ case 5:
+ $entity->field_ldapregistr_epikour_loipa['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+ break;
+ }
+
+
+ }elseif(grnet_core_convert($ldapinfo_user["employeetype"][0],TRUE)=='administrative'){
+ if($ldapinfo_user["title"][0]=='manager'){
+ $entity->field_ldapregistr_admin_proist['und']['0']['value']='1';
+ }else{
+ $entity->field_ldapregistr_admin_proist['und']['0']['value']='0';
+ }
+
+ $entity->field_ldapregistr_dioik_tmimgraf['und']['0']['tid'] = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->tid;
+
+ }
+
+
+ return $entity;
+
+}
+function grnet_ldap_interconnection_ldap_user_exists_wrapper($attributes){
+ return _ldap_user_exists($attributes);
+}
+ function _ldap_user_create($user,$password) {
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $res=false;
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uid=".$user['uid'].",$ldapbasedn";
+
+
+
+
+
+
+ module_load_include('module', 'password_field', 'password_field');
+
+
+ $user['userpassword']="{SHA}" . base64_encode( pack( "H*", sha1( password_field_decrypt($password) ) ) );
+
+ $res=ldap_add($conn, $rdn, $user);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+ function _ldap_user_read($username , $attributes_array=null){
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $filter = "(uid=$username)";
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ if(count($attributes_array) > 0){
+ }else{
+ }
+
+
+ $info = ldap_get_entries($conn, $SearchResult);
+
+ if($info['count']>0) {
+ return $info[0];
+ }else{
+ return NULL;
+ }
+
+ }catch(Exception $e)
+ {
+ $log->error($e->getMessage());
+ return false;
+ }
+
+
+ }
+
+
+
+ function _ldap_user_update($userinfo) {
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+
+ $rdn = "uid=".$userinfo['uid'].",$ldapbasedn";
+
+ ldap_close($conn);
+ return $ldap_modify_message;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+ function _ldap_user_delete($username) {
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $res=false;
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uid=".$username.",$ldapbasedn";
+ $res=ldap_delete($conn,$rdn);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+ function _ldap_user_exists($attributes){
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+ $filter = grnet_ldap_interconnection_construct_filter($attributes);
+
+
+ $returnAttributes = array("uid");
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $info = ldap_get_entries($conn, $SearchResult);
+
+ if($info['count']>0) {
+ return true;
+ }else{
+ return false;
+ }
+
+ }catch(Exception $e)
+ {
+ $log->error($e->getMessage());
+ return false;
+ }
+
+
+ }
+
+
+
+
+
+
+
+ function grnet_ldap_interconnection_unit_create_wrapper($entity){
+ return _ldap_unit_create_wrapper($entity);
+ }
+
+ function _ldap_unit_create_wrapper($entity, $type=NULL){
+
+ $ldapbasedn = variable_get('grnet_ldapbasedn_people').','.variable_get('grnet_ldapbasedn');
+
+
+
+
+
+ try{
+ $unit = array('objectClass' => array( 'top',
+ 'extensibleObject',
+ 'organization',
+ 'organizationalUnit',
+ 'pilotOrganization'),
+
+ 'o' => $entity->name,
+ 'ou' => $entity->field_backend_name['und']['0']['value'],
+ 'businessCategory' => taxonomy_vocabulary_load($entity->vid)->description,
+ 'uniqueIdentifier' => $entity->tid
+ );
+
+ if(reset($entity->parent)>0) {
+ $unit['seeAlso'] = "uniqueIdentifier=".reset($entity->parent).",ou=Units,".$ldapbasedn;
+ }
+
+ if( !_ldap_unit_exists($entity->tid)){
+ $output = _ldap_unit_create($unit);
+ if($output==1){
+ drupal_set_message(t("Ldap unit record created succesfully!!"));
+ return $output;
+ }
+ }else{
+ drupal_set_message(t("PROBLEM!! Ldap Unit record couldn't be inserted!!"), 'error');
+ }
+
+
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+ function _ldap_unit_update_wrapper($entity, $type){
+
+
+ $unit_values = array();
+ $unit_values['tid'] = $entity->tid;
+ $unit_values['name'] = $entity->name;
+ $unit_values['backend_name'] = $entity->field_backend_name['und']['0']['value'];
+ $unit_values['parent'] = reset($entity->parent);
+
+
+ try{
+ $_SESSION['flafla'] = $type;
+
+ if(_ldap_unit_exists($entity->tid)){
+ $output = _ldap_unit_update($entity);
+ if($output==1){
+ drupal_set_message(t("Ldap unit record updated succesfully!!"));
+ }
+ }else{
+ drupal_set_message(t("PROBLEM!! Ldap Unit record couldn't be updated as it couldn't be found!!"), 'error');
+ drupal_set_message('output = '.$output);
+ }
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+ }
+
+
+ function _ldap_unit_delete_wrapper($entity_type){
+
+ try{
+
+ if(_ldap_unit_exists($entity_type->tid)){
+ $output = _ldap_unit_delete($entity_type->tid);
+ if($output==1){
+ drupal_set_message(t("Ldap Unit record deleted succesfully!!"));
+ }
+ }else{
+ drupal_set_message(t("PROBLEM!! Ldap Unit record couldn't be deleted as it couldn't be found!!"), 'error');
+ drupal_set_message('output = '.$output);
+ }
+
+
+
+
+ }catch (exception $e){
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+ function _ldap_unit_create($unit) {
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+ $res=false;
+
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uniqueIdentifier=".$unit['uniqueIdentifier'].",$ldapbasedn";
+
+ $res=ldap_add($conn, $rdn, $unit);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+ function _ldap_unit_exists($tid){
+
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+
+
+
+ $filter = "(uniqueIdentifier=$tid)";
+ $attributes = array("uniqueIdentifier");
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $info = ldap_get_entries($conn, $SearchResult);
+
+ if($info['count']>0) {
+ return true;
+ }else{
+ return false;
+ }
+
+ }catch(Exception $e)
+ {
+ $log->error($e->getMessage());
+ return false;
+ }
+
+
+ }
+
+ function _ldap_unit_update($unit) {
+
+ /*
+ $unit_values = array();
+ $unit_values['tid'] = $entity->tid;
+ $unit_values['name'] = $entity->name;
+ $unit_values['backend_name'] = $entity->field_backend_name['und']['0']['value'];
+ $unit_values['parent'] = reset($entity->parent);
+ */
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+
+
+ $info = array( "o" => $unit->name,
+ "ou" => $unit->field_backend_name['und']['0']['value'],
+ "businessCategory" => taxonomy_vocabulary_load($unit->vid)->description
+ );
+
+ $_SESSION['kko'] = reset($unit->parent);
+ if(reset($unit->parent)<>'0'){
+ $info['seeAlso'] = 'uniqueIdentifier='.reset($unit->parent).",$ldapbasedn";
+ }
+
+ try{
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+
+ $rdn = "uniqueIdentifier=".$unit->tid.",$ldapbasedn";
+ $_SESSION['unit_values'] = $info;
+
+ ldap_close($conn);
+ return $ldap_modify_message;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+ function _ldap_unit_delete($tid) {
+
+ $ldaphost = variable_get('grnet_ldaphost');
+ $ldapport = variable_get('grnet_ldapport');
+ $ldapbinddn = variable_get('grnet_ldapbinddn');
+ $ldappass = variable_get('grnet_ldappass');
+ $ldapbasedn = variable_get('grnet_ldapbasedn_units').','.variable_get('grnet_ldapbasedn');
+
+
+ $res=false;
+
+ try{
+ $conn = ldap_connect($ldaphost,$ldapport) or die("Could not connect to server");
+ ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);
+ $r = ldap_bind($conn,$ldapbinddn,$ldappass) or die("Could not bind to server");
+
+ $rdn = "uniqueIdentifier=".$tid.",$ldapbasedn";
+
+ $res=ldap_delete($conn, $rdn);
+ ldap_close($conn);
+ return $res;
+
+ } catch(exception $e) {
+ var_dump($e);
+ }
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+ function grnet_ldap_interconnection_construct_filter($attributes){
+ $counter=0;
+ $filterTemp ='';
+ $filter='';
+ foreach($attributes as $key => $value){
+
+ $filterTemp .= "($key=$value)";
+ $counter++;
+ }
+
+ if($counter>1){
+ $filter = "(&";
+ }
+
+ $filter .=$filterTemp;
+
+ if($counter>1){
+ $filter .= ")";
+ }
+
+ return $filter;
+ }
+
+?>
diff --git a/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.info b/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.info
new file mode 100644
index 0000000..971807e
--- /dev/null
+++ b/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.info
@@ -0,0 +1,11 @@
+name = Grnet Ldap Interconnection Sync
+description = GGrnet Ldap Interconnection Sync (Ldap Create / Update)
+core = "7.x"
+package = Grnet
+
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
+
diff --git a/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.module b/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.module
new file mode 100644
index 0000000..c61f00f
--- /dev/null
+++ b/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.module
@@ -0,0 +1,100 @@
+ 'Ldap Sync',
+ 'page callback' => '_ldap_sync',
+ 'page arguments' => array(1,2),
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+ }
+
+
+ function _ldap_sync($type,$vocabulary){
+ if($type=='units'){
+ if($vocabulary=='all'){
+ return _get_units('all');
+ }else{
+ return _get_units($vocabulary);
+ }
+
+ }
+
+
+ }
+
+ function _get_units($vid=NULL){
+ $output = 'Ξεκινάει ο Συγχρονισμός..';
+ $output .= ' ';
+
+
+
+
+ if($vid=='all'){
+ $sql = "SELECT * FROM {taxonomy_vocabulary} WHERE vid IN (2,3,4,5,6) ";
+
+ }else{
+ $sql = db_query("SELECT * FROM {taxonomy_vocabulary} WHERE vid=:vid",array(':vid' => $vid) );
+ }
+
+
+ $result=db_query($sql);
+
+ foreach ($result as $rec) {
+ $output .= 'ΤΑΞΙΝΟΜΗΣΗ : '.$rec->description.' ';
+
+ $terms_array = taxonomy_get_tree($rec->vid, $parent = 0, $max_depth = NULL, TRUE);
+ foreach ($terms_array as $term) {
+ $output .= 'tid : '.$term->tid.' ';
+ $output .= 'name : '.$term->name.' ';
+ $output .= 'backend_name : '.$term->field_backend_name['und']['0']['value'].' ';
+ if(reset($term->parents) > 0){
+ $output .= 'parent : '.reset($term->parents).' ';
+ }
+
+
+
+
+ $entity = new stdClass();
+ $entity->name = $term->name;
+ $entity->field_backend_name = $term->field_backend_name;
+ $entity->vid = $term->vid;
+ $entity->tid = $term->tid;
+ if(reset($term->parents) > 0){
+ $entity->parent = $term->parents;
+ }
+ $res = grnet_ldap_interconnection_unit_create_wrapper($entity);
+
+ $output .= ' Ldap Status : ';
+ if($res==1){
+ $output .= '[OK]';
+ }else{
+ $output .= ' - ';
+ }
+ $output .= ' ';
+
+
+
+
+ $output .= '------------------------------------ ';
+
+ }
+
+
+ $output .= '
+
+ }
+
+
+
+
+ $output .= ' ';
+ $output .= 'Ο συγχρονισμός ολοκληρώθηκε!!';
+
+ return $output;
+
+ }
+?>
diff --git a/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.module~ b/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.module~
new file mode 100644
index 0000000..b3f47a5
--- /dev/null
+++ b/grnet_ldap_interconnection_sync/grnet_ldap_interconnection_sync.module~
@@ -0,0 +1,101 @@
+ 'Ldap Sync',
+ 'page callback' => '_ldap_sync',
+ 'page arguments' => array(1,2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+ }
+
+
+ function _ldap_sync($type,$vocabulary){
+ if($type=='units'){
+ if($vocabulary=='all'){
+ return _get_units('all');
+ }else{
+ return _get_units($vocabulary);
+ }
+
+ }
+
+
+ }
+
+ function _get_units($vid=NULL){
+ $output = 'Ξεκινάει ο Συγχρονισμός..';
+ $output .= ' ';
+
+
+
+
+ if($vid=='all'){
+ $sql = "SELECT * FROM {taxonomy_vocabulary} WHERE vid IN (2,3,4,5,6) ";
+
+ }else{
+ $sql = db_query("SELECT * FROM {taxonomy_vocabulary} WHERE vid=:vid",array(':vid' => $vid) );
+ }
+
+
+ $result=db_query($sql);
+
+ foreach ($result as $rec) {
+ $output .= 'ΤΑΞΙΝΟΜΗΣΗ : '.$rec->description.' ';
+
+ $terms_array = taxonomy_get_tree($rec->vid, $parent = 0, $max_depth = NULL, TRUE);
+ foreach ($terms_array as $term) {
+ $output .= 'tid : '.$term->tid.' ';
+ $output .= 'name : '.$term->name.' ';
+ $output .= 'backend_name : '.$term->field_backend_name['und']['0']['value'].' ';
+ if(reset($term->parents) > 0){
+ $output .= 'parent : '.reset($term->parents).' ';
+ }
+
+
+
+
+ $entity = new stdClass();
+ $entity->name = $term->name;
+ $entity->field_backend_name = $term->field_backend_name;
+ $entity->vid = $term->vid;
+ $entity->tid = $term->tid;
+ if(reset($term->parents) > 0){
+ $entity->parent = $term->parents;
+ }
+ $res = grnet_ldap_interconnection_unit_create_wrapper($entity);
+
+ $output .= ' Ldap Status : ';
+ if($res==1){
+ $output .= '[OK]';
+ }else{
+ $output .= ' - ';
+ }
+ $output .= ' ';
+
+
+
+
+ $output .= '------------------------------------ ';
+
+ }
+
+
+ $output .= '
+
+ }
+
+
+
+
+ $output .= ' ';
+ $output .= 'Ο συγχρονισμός ολοκληρώθηκε!!';
+
+ return $output;
+
+ }
+?>
diff --git a/grnet_ldapinfo/css/ldapinfo.css b/grnet_ldapinfo/css/ldapinfo.css
new file mode 100644
index 0000000..83583d9
--- /dev/null
+++ b/grnet_ldapinfo/css/ldapinfo.css
@@ -0,0 +1,27 @@
+/*-------- Ta stoixeia mou start ------*/
+#ldapinfo .fieldset-legend {
+ color:#9cb2c0;
+ font-weight:600;
+ margin: 1.2em 0;
+}
+
+fieldset {
+ margin:0;
+}
+
+#ldapinfo .fieldset-wrapper {
+ padding: 0 10px 10px;
+ border-bottom: 1px solid #EEEEEE;
+}
+#ldapinfo .fieldset-wrapper:last-child {
+ border-bottom:none;
+}
+.fleft {
+ float:left;
+}
+
+.mgrow {
+ margin: 0.8em 0!important;
+}
+
+/*-------- Ta stoixeia mou end------*/
diff --git a/grnet_ldapinfo/css/ldapinfo.css~ b/grnet_ldapinfo/css/ldapinfo.css~
new file mode 100644
index 0000000..6c7ed43
--- /dev/null
+++ b/grnet_ldapinfo/css/ldapinfo.css~
@@ -0,0 +1,24 @@
+/*-------- Ta stoixeia mou start ------*/
+ color:
+ font-weight:600;
+ margin: 1.2em 0;
+}
+
+fieldset {
+ margin:0;
+}
+
+ padding: 0 10px 10px;
+ border-bottom: 1px solid
+}
+ border-bottom:none;
+}
+.fleft {
+ float:left;
+}
+
+.mgrow {
+ margin: 0.8em 0!important;
+}
+
+/*-------- Ta stoixeia mou end------*/
diff --git a/grnet_ldapinfo/grnet_ldapinfo.info b/grnet_ldapinfo/grnet_ldapinfo.info
new file mode 100755
index 0000000..784d13b
--- /dev/null
+++ b/grnet_ldapinfo/grnet_ldapinfo.info
@@ -0,0 +1,10 @@
+name = grnet Ldap Info
+description = grnet Ldap Info module - Casified personal info through ldap
+core = "7.x"
+package = grnet
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
+stylesheets[all][] = css/ldapinfo.css
diff --git a/grnet_ldapinfo/grnet_ldapinfo.module b/grnet_ldapinfo/grnet_ldapinfo.module
new file mode 100755
index 0000000..6832198
--- /dev/null
+++ b/grnet_ldapinfo/grnet_ldapinfo.module
@@ -0,0 +1,343 @@
+ 'My personal Info',
+ 'page callback' => 'ldapinfo',
+ /*'page arguments' => array(1),*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+}
+function ldapinfo(){
+
+ $html = '
Τα στοιχεία μου
+
+
+ Αν επιθυμείτε να επεξεργαστείτε τα στοιχεία σας πραγματοποιήστε
+
Αίτημα Μεταβολής Στοιχείων
+
+
+
';
+
+ $html .= grnet_ldapinfo_get_user_info();
+
+ $html .= '
';
+ return $html;
+}
+
+function grnet_ldapinfo_get_user_info(){
+
+ $username = grnet_core_get_ldapinfo_user();
+ $ldapinfo_user = grnet_ldap_interconnection_unit_read_wrapper($username);
+
+ if($ldapinfo_user["edupersonentitlement"][0]<>''){
+ $dias_roles = taxonomy_term_load(grnet_core_conver_dias_roles_revert_to_tid($ldapinfo_user["edupersonentitlement"][0]))->name;
+ }else{
+ $dias_roles = '- Κανένα -';
+ }
+
+
+ if($ldapinfo_user["employeetype"][0]=='Ιατρικό'){
+
+ switch (grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid){
+
+ case 2:
+ $field_ldapregistr_tmim_mon_tomea = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+ $field_ldapregistr_tmim_diato ='';
+ $field_ldapregistr_epikour_loipa ='';
+ break;
+
+ case 4:
+ $field_ldapregistr_tmim_mon_tomea = '';
+ $field_ldapregistr_tmim_diato =grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+ $field_ldapregistr_epikour_loipa ='';
+ break;
+
+ case 5:
+ $field_ldapregistr_tmim_mon_tomea = '';
+ $field_ldapregistr_tmim_diato = '';
+ $field_ldapregistr_epikour_loipa = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+ break;
+ }
+
+ if($ldapinfo_user["title"][0]=='manager'){
+ $field_ldapregistr_iatr_proist = 'ΝΑΙ';
+ }else{
+ $field_ldapregistr_iatr_proist = 'ΟΧΙ';
+ }
+
+
+ }elseif($ldapinfo_user["employeetype"][0]=='Διοικητικό'){
+
+ $field_ldapregistr_dioik_tmimgraf = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+
+ if($ldapinfo_user["title"][0]=='manager'){
+ $field_ldapregistr_admin_proist = 'ΝΑΙ';
+ }else{
+ $field_ldapregistr_admin_proist = 'ΟΧΙ';
+ }
+
+ }
+
+
+
+
+
+
+
+ $output ='
+
+
+
+
+
+
+
+
+
+ Προσωπικά Στοιχεία
+
+
+
+
Όνομα
+
'.$ldapinfo_user["givenname"][0].'
+
+
+
Επώνυμο
+
'.$ldapinfo_user["sn"][0].'
+
+
+
ΑΜΚΑ
+
'.$ldapinfo_user["schacpersonaluniqueid"][0].'
+
+
+
+
+
+ Όνομα χρήστη και κωδικός πρόσβασης
+
+
+
+
Όνομα Χρήστη
+
'.$ldapinfo_user["uid"][0].'
+
+
+
Κωδικός πρόσβασης
+
';
+
+ if(arg(0)=='ldapinfo'){
+ $output .= '
Διαχείριση κωδικού ';
+ }elseif(arg(0)=='requests' || arg(0)=='entityform'){
+ $output .= '**********';
+ }
+
+ $output .='
+
+
+
+
+
+
+ Στοιχεία Επικοινωνίας
+
+
+
+
email
+
'.$ldapinfo_user["mail"][0].'
+
+
+
Τηλέφωνο
+
'.$ldapinfo_user["telephonenumber"][0].'
+
+
+
Κινητό
+
'.$ldapinfo_user["mobile"][0].'
+
+
+
+
+
+ Προσωπικό
+
+
+
+
Κατηγορία Προσωπικού
+
'.$ldapinfo_user["employeetype"][0].'
+
';
+
+
+ $output .='
+
+
DICOM - Όνομα
+
'.$ldapinfo_user["dicomreferringphysiciansname"][0].'
+
+
+
Είδος Προσωπικού
+
'.$ldapinfo_user["description"][0].'
+
+
+
Ειδικότητα
+
'.grnet_core_get_term_by_rdn($ldapinfo_user["distinguishedname"][0])->name.'
+
+
+
Τοποθέτηση σε μόναδα
+
'.taxonomy_vocabulary_load(grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid)->description.'
+
';
+
+ $output .='
+
+
Τμήματα/Μονάδες ανά τομέα
+
'.$field_ldapregistr_tmim_mon_tomea.'
+
';
+
+
+ $output .='
+
+
Τμήματα Διατομεακού Επιπέδου
+
'.$field_ldapregistr_tmim_diato.'
+
';
+
+
+ $output .='
+
+
Επικουρικά / Λοιπά
+
'.$field_ldapregistr_epikour_loipa.'
+
';
+
+
+ $output .='
+
+
Προϊστάμενος τμήματος / μονάδας
+
'.$field_ldapregistr_iatr_proist.'
+
';
+
+
+ $output .='
+
+
Τοποθέτηση σε Τμήμα / Γραφείο
+
'.$field_ldapregistr_dioik_tmimgraf.'
+
';
+
+
+
+ $output .='
+
+
Προϊστάμενος τμήματος / μονάδας
+
'.$field_ldapregistr_admin_proist.'
+
+
+
+
+
+ Σύστημα ΔΙΑΣ
+
+
+
+
Ρόλος (ΔΙΑΣ)
+
'.$dias_roles.'
+
+
+
+
+
+
+
+
+
+
+
+ ';
+
+ if(arg(0)=='requests'){
+ $output .= '';
+ }
+
+ return $output;
+}
+
+function grnet_ldapinfo_getUserSid() {
+ $sid = db_query("SELECT entity_id as sid
+ FROM field_data_field_ldapregistr_username
+ WHERE field_ldapregistr_username_value= :username",array(':username' => $_SESSION['phpCAS']['user'])
+ )->fetchField();
+ return $sid;
+}
+function grnet_ldapinfo_show_both() {
+ return TRUE;
+}
+function grnet_ldapinfo_block_info() {
+ $blocks = array();
+ $blocks['my_block'] = array(
+ 'info' => t('Ldap User Info '),
+ );
+ /*
+ $blocks['my_block2'] = array(
+ 'info' => t('Ldap User Info2 '),
+ );
+ */
+
+ return $blocks;
+}
+/**
+ * Implements hook_block_configure().
+ */
+function grnet_ldapinfo_block_configure($delta='') {
+ $form = array();
+
+ switch($delta) {
+
+ }
+ return $form;
+}
+/**
+ * Implements hook_block_save().
+ */
+function grnet_ldapinfo_block_save($delta = '', $edit = array()) {
+ switch($delta) {
+
+ }
+}
+/**
+ * Implements hook_block_view().
+ */
+function grnet_ldapinfo_block_view($delta='') {
+ $block = array();
+
+ switch($delta) {
+ case 'my_block' :
+ $block['content'] = my_block_view();
+ break;
+ }
+
+ return $block;
+}
+/**
+ * Custom function to assemble renderable array for block content.
+ * Returns a renderable array with the block content.
+ * @return
+ * returns a renderable array of block content.
+ */
+function my_block_view() {
+ $block = array();
+
+ $block = array(
+
+ 'message' => array(
+ '
+ '
+ '
+ ),
+ );
+ return $block;
+}
diff --git a/grnet_ldapinfo/grnet_ldapinfo.module~ b/grnet_ldapinfo/grnet_ldapinfo.module~
new file mode 100755
index 0000000..1d0de1f
--- /dev/null
+++ b/grnet_ldapinfo/grnet_ldapinfo.module~
@@ -0,0 +1,440 @@
+ 'My personal Info',
+ 'page callback' => 'ldapinfo',
+ /*'page arguments' => array(1),*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+}
+function ldapinfo(){
+
+ $html = ' Τα στοιχεία μου
+
+
+ Αν επιθυμείτε να επεξεργαστείτε τα στοιχεία σας πραγματοποιήστε
+
Αίτημα Μεταβολής Στοιχείων
+
+
+
';
+
+ $html .= grnet_ldapinfo_get_user_info();
+
+ $html .= '
';
+ return $html;
+}
+
+function grnet_ldapinfo_get_user_info(){
+
+ $username = grnet_core_get_ldapinfo_user();
+ $ldapinfo_user = grnet_ldap_interconnection_unit_read_wrapper($username);
+
+ if($ldapinfo_user["edupersonentitlement"][0]<>''){
+ $dias_roles = taxonomy_term_load(grnet_core_conver_dias_roles_revert_to_tid($ldapinfo_user["edupersonentitlement"][0]))->name;
+ }else{
+ $dias_roles = '- Κανένα -';
+ }
+
+
+ if($ldapinfo_user["employeetype"][0]=='Ιατρικό'){
+
+ switch (grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid){
+
+ case 2:
+ $field_ldapregistr_tmim_mon_tomea = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+ $field_ldapregistr_tmim_diato ='';
+ $field_ldapregistr_epikour_loipa ='';
+ break;
+
+ case 4:
+ $field_ldapregistr_tmim_mon_tomea = '';
+ $field_ldapregistr_tmim_diato =grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+ $field_ldapregistr_epikour_loipa ='';
+ break;
+
+ case 5:
+ $field_ldapregistr_tmim_mon_tomea = '';
+ $field_ldapregistr_tmim_diato = '';
+ $field_ldapregistr_epikour_loipa = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+ break;
+ }
+
+ if($ldapinfo_user["title"][0]=='manager'){
+ $field_ldapregistr_iatr_proist = 'ΝΑΙ';
+ }else{
+ $field_ldapregistr_iatr_proist = 'ΟΧΙ';
+ }
+
+
+ }elseif($ldapinfo_user["employeetype"][0]=='Διοικητικό'){
+
+ $field_ldapregistr_dioik_tmimgraf = grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->name;
+
+ if($ldapinfo_user["title"][0]=='manager'){
+ $field_ldapregistr_admin_proist = 'ΝΑΙ';
+ }else{
+ $field_ldapregistr_admin_proist = 'ΟΧΙ';
+ }
+
+ }
+
+
+
+
+
+
+
+ $output ='
+
+
+
+
+
+
+
+
+
+ Προσωπικά Στοιχεία
+
+
+
+
Όνομα
+
'.$ldapinfo_user["givenname"][0].'
+
+
+
Επώνυμο
+
'.$ldapinfo_user["sn"][0].'
+
+
+
ΑΜΚΑ
+
'.$ldapinfo_user["schacpersonaluniqueid"][0].'
+
+
+
+
+
+ Όνομα χρήστη και κωδικός πρόσβασης
+
+
+
+
Όνομα Χρήστη
+
'.$ldapinfo_user["uid"][0].'
+
+
+
Κωδικός πρόσβασης
+
';
+
+ if(arg(0)=='ldapinfo'){
+ $output .= '
Διαχείριση κωδικού ';
+ }elseif(arg(0)=='requests' || arg(0)=='entityform'){
+ $output .= '**********';
+ }
+
+ $output .='
+
+
+
+
+
+
+ Στοιχεία Επικοινωνίας
+
+
+
+
email
+
'.$ldapinfo_user["mail"][0].'
+
+
+
Τηλέφωνο
+
'.$ldapinfo_user["telephonenumber"][0].'
+
+
+
Κινητό
+
'.$ldapinfo_user["mobile"][0].'
+
+
+
+
+
+ Προσωπικό
+
+
+
+
Κατηγορία Προσωπικού
+
'.$ldapinfo_user["employeetype"][0].'
+
';
+
+
+ $output .='
+
+
DICOM - Όνομα
+
'.$ldapinfo_user["dicomreferringphysiciansname"][0].'
+
+
+
Είδος Προσωπικού
+
'.$ldapinfo_user["description"][0].'
+
+
+
Ειδικότητα
+
'.grnet_core_get_term_by_rdn($ldapinfo_user["distinguishedname"][0])->name.'
+
+
+
Τοποθέτηση σε μόναδα
+
'.taxonomy_vocabulary_load(grnet_core_get_term_by_rdn($ldapinfo_user["seealso"][0])->vid)->description.'
+
';
+
+ $output .='
+
+
Τμήματα/Μονάδες ανά τομέα
+
'.$field_ldapregistr_tmim_mon_tomea.'
+
';
+
+
+ $output .='
+
+
Τμήματα Διατομεακού Επιπέδου
+
'.$field_ldapregistr_tmim_diato.'
+
';
+
+
+ $output .='
+
+
Επικουρικά / Λοιπά
+
'.$field_ldapregistr_epikour_loipa.'
+
';
+
+
+ $output .='
+
+
Προϊστάμενος τμήματος / μονάδας
+
'.$field_ldapregistr_iatr_proist.'
+
';
+
+
+ $output .='
+
+
Τοποθέτηση σε Τμήμα / Γραφείο
+
'.$field_ldapregistr_dioik_tmimgraf.'
+
';
+
+
+
+ $output .='
+
+
Προϊστάμενος τμήματος / μονάδας
+
'.$field_ldapregistr_admin_proist.'
+
+
+
+
+
+ Σύστημα ΔΙΑΣ
+
+
+
+
Ρόλος (ΔΙΑΣ)
+
'.$dias_roles.'
+
+
+
+
+
+
+
+
+
+
+
+ ';
+
+ if(arg(0)=='requests'){
+ $output .= '';
+ }
+
+ return $output;
+}
+
+function grnet_ldapinfo_getUserSid() {
+ $sid = db_query("SELECT entity_id as sid
+ FROM field_data_field_ldapregistr_username
+ WHERE field_ldapregistr_username_value= :username",array(':username' => $_SESSION['phpCAS']['user'])
+ )->fetchField();
+ return $sid;
+}
+function grnet_ldapinfo_show_both() {
+ return TRUE;
+}
+function grnet_ldapinfo_block_info() {
+ $blocks = array();
+ $blocks['my_block'] = array(
+ 'info' => t('Ldap User Info '),
+ );
+ /*
+ $blocks['my_block2'] = array(
+ 'info' => t('Ldap User Info2 '),
+ );
+ */
+
+ return $blocks;
+}
+/**
+ * Implements hook_block_configure().
+ */
+function grnet_ldapinfo_block_configure($delta='') {
+ $form = array();
+
+ switch($delta) {
+ /*
+ case 'my_block' :
+ $form['text_body'] = array(
+ '
+ '
+ '
+ );
+ $form['file'] = array(
+ '
+ '
+ '
+ '
+ '
+ '
+ '
+ 'file_validate_extensions' => array('gif png jpg jpeg'),
+ ),
+ );
+ break;
+
+
+ /*
+ case 'my_block2' :
+ $form['file'] = array(
+ '
+ '
+ '
+ '
+ '
+ '
+ '
+ 'file_validate_extensions' => array('gif png jpg jpeg'),
+ ),
+ );
+
+
+ $form['text_body'] = array(
+ '
+ '
+ '
+ );
+ break;
+ */
+
+
+ }
+ return $form;
+}
+/**
+ * Implements hook_block_save().
+ */
+function grnet_ldapinfo_block_save($delta = '', $edit = array()) {
+ switch($delta) {
+
+ /*
+ case 'my_block' :
+ variable_set('text_variable', $edit['text_body']['value']);
+ $file = file_load($edit['file']);
+ $file->status = FILE_STATUS_PERMANENT;
+ file_save($file);
+ $block = block_load('custom_block', $delta);
+ file_usage_add($file, 'custom_block', 'block', $block->bid);
+ variable_set('block_image_fid', $file->fid);
+ break;
+ */
+
+ /*
+ case 'my_block2' :
+ variable_set('text_variable', $edit['text_body']['value']);
+ $file = file_load($edit['file']);
+ $file->status = FILE_STATUS_PERMANENT;
+ file_save($file);
+ $block = block_load('custom_block', $delta);
+ file_usage_add($file, 'custom_block', 'block', $block->bid);
+ variable_set('block_image_fid', $file->fid);
+ break;
+ */
+
+ }
+}
+/**
+ * Implements hook_block_view().
+ */
+function grnet_ldapinfo_block_view($delta='') {
+ $block = array();
+
+ switch($delta) {
+ case 'my_block' :
+ $block['content'] = my_block_view();
+ break;
+
+ /*
+ case 'my_block2' :
+ $block['content'] = my_block_view2();
+ break;
+ */
+
+ }
+
+ return $block;
+}
+/**
+ * Custom function to assemble renderable array for block content.
+ * Returns a renderable array with the block content.
+ * @return
+ * returns a renderable array of block content.
+ */
+function my_block_view() {
+ $block = array();
+ /*
+ $image_file = file_load(variable_get('block_image_fid', ''));
+ $image_path = '';
+ if (isset($image_file->uri)) {
+ $image_path = $image_file->uri;
+ }
+ $image = theme_image(array(
+ 'path' => ($image_path),
+ 'alt' => t('Image description here.'),
+ 'title' => t('This is our block image.'),
+ 'attributes' => array('class' => 'class_name'),
+ ));
+ $text = variable_get('text_variable', '');
+ */
+
+ $block = array(
+
+ /*
+ 'image' => array(
+ '
+ '
+ '
+ ),
+ */
+
+ 'message' => array(
+ '
+ '
+ '
+ ),
+ );
+ return $block;
+}
\ No newline at end of file
diff --git a/grnet_password_generator/grnet_password_generator.admin.inc b/grnet_password_generator/grnet_password_generator.admin.inc
new file mode 100755
index 0000000..724d37c
--- /dev/null
+++ b/grnet_password_generator/grnet_password_generator.admin.inc
@@ -0,0 +1,91 @@
+ 'fieldset',
+ '#title' => t('Password Strength'),
+ '#collapsible' => TRUE
+ );
+
+
+ $form['passwordStrength']['passwordStrength_minLen'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Length'),
+ '#default_value' => variable_get('passwordStrength_minLen', '6'),
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#description' => t('Minimum Length of password.'),
+ );
+
+ $form['passwordStrength']['passwordStrength_minUniq'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Unique'),
+ '#default_value' => variable_get('passwordStrength_minUniq', '5'),
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#description' => t('Password minimum unique different characters.'),
+ );
+
+
+ $form['passwordStrength']['passwordStrength_nonAlpha'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Non Alpha'),
+ '#default_value' => variable_get('passwordStrength_nonAlpha', '2'),
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#description' => t('How many non alpharithmetic characters a password must contains at least.'),
+ );
+
+
+ $form['passwordStrength']['passwordStrength_minCons'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Consecutive Numbers'),
+ '#default_value' => variable_get('passwordStrength_minCons', '3'),
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#description' => t('How many non sequencial numbers (in any order)..a password must not contain the most.'),
+ );
+
+
+ $form['passwordStrength']['passwordStrength_minCons'] = array(
+ '#type' => 'textfield',
+ '#title' => t('minCons'),
+ '#default_value' => variable_get('passwordStrength_minCons', ''),
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#description' => t('How many non sequencial numbers (in any order)..a password must not contain the most.'),
+ );
+
+
+ $form['passwordStrength']['passwordStrength_levenshtein'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Levenshtein'),
+ '#default_value' => variable_get('passwordStrength_levenshtein', '2'),
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#description' => t('levenshtein...'),
+ );
+
+
+ $form['passwordStrength']['passwordStrength_minLcs'] = array(
+ '#type' => 'textfield',
+ '#title' => t('minLcs'),
+ '#default_value' => variable_get('passwordStrength_minLcs', '40'),
+ '#size' => 3,
+ '#maxlength' => 3,
+ '#description' => t('minLCS..'),
+ );
+
+
+ return system_settings_form($form);
+}
diff --git a/grnet_password_generator/grnet_password_generator.info b/grnet_password_generator/grnet_password_generator.info
new file mode 100755
index 0000000..2e65720
--- /dev/null
+++ b/grnet_password_generator/grnet_password_generator.info
@@ -0,0 +1,10 @@
+name = grnet Password Generator
+description = grnet Password Generator module
+core = "7.x"
+package = grnet
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
+scripts[] = js/script.js
\ No newline at end of file
diff --git a/grnet_password_generator/grnet_password_generator.module b/grnet_password_generator/grnet_password_generator.module
new file mode 100755
index 0000000..4a50a3a
--- /dev/null
+++ b/grnet_password_generator/grnet_password_generator.module
@@ -0,0 +1,45 @@
+ 'grnet Password Strength',
+ 'description' => 'Configure grnet Password Strength Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('grnet_password_generator_admin_settings'),
+ 'access arguments' => array('administer cas'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'grnet_password_generator.admin.inc',
+ );
+
+ $items['admin/config/grnet/password_strength/settings'] = array(
+ 'title' => 'grnet Password Strength',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+
+
+ $items['grnet/password_generator/check_strength'] = array(
+ 'title' => 'Check Password Strength',
+ 'page callback' => 'grnet_password_generator_check_password_strength',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK
+ );
+
+ return $items;
+}
+function grnet_password_generator_generate_passes() {
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_password_generator').'/lib/grnet_password_generator_library.inc');
+
+ $passes = array();
+ for($i = 1; $i <= 8; $i++) {
+ $passes[] = trim(grnet_password_generator_uoa_generate_password());
+ }
+ return $passes;
+}
+function grnet_password_generator_check_password_strength($password = null,$hide = null){
+
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_password_generator').'/lib/grnet_password_generator_check_strength.inc');
+ return $internal_output;
+}
diff --git a/grnet_password_generator/js/script.js b/grnet_password_generator/js/script.js
new file mode 100644
index 0000000..b187141
--- /dev/null
+++ b/grnet_password_generator/js/script.js
@@ -0,0 +1,22 @@
+(function ($) {
+
+ $(document).ready(function() {
+
+ $('#generate_password').click(function() {
+ $.ajax({url: "http://hidm.collab/password_generator", success: function(result){
+ $("#passwords").html(result);
+ }});
+
+ });
+
+
+ $('#passwords').click(function() {
+ $("#edit-field-ldapregistr-username-und-0-value").val($('#passwords').html());
+
+ });
+
+
+
+ });
+
+})(jQuery);
\ No newline at end of file
diff --git a/grnet_password_generator/lib/grnet_password_generator_check_strength.inc b/grnet_password_generator/lib/grnet_password_generator_check_strength.inc
new file mode 100644
index 0000000..7c31a26
--- /dev/null
+++ b/grnet_password_generator/lib/grnet_password_generator_check_strength.inc
@@ -0,0 +1,97 @@
+''){
+ $password = $_POST['pwd'];
+ }
+
+
+
+ $all_messages = array(
+ 'consecutivenumbersTest'=>'valid',
+ 'similarityTest'=>'valid',
+ 'regexpTest'=>'valid',
+ 'lengthTest'=>'valid',
+ 'uniqueTest'=>'valid',
+ );
+
+
+
+ $password_strength_policy = array(
+ 'PW_CHECK_LEVENSHTEIN' => variable_get('passwordStrength_levenshtein', '2'),
+ 'PW_CHECK_MIN_LEN' => variable_get('passwordStrength_minLen', '6'),
+ 'PW_CHECK_MIN_UNIQ' => variable_get('passwordStrength_minUniq', '5'),
+ 'PW_CHECK_MIN_LCS' => variable_get('passwordStrength_minLcs', '40'),
+ 'PW_CHECK_MIN_NON_ALPHA' => variable_get('passwordStrength_nonAlpha', '2'),
+ 'PW_MIN_CONSECUTIVE_NUMBERS' => variable_get('passwordStrength_minCons', '3'),
+ );
+
+
+ $check = new passwordStrengthCheck($password_strength_policy);
+
+
+ $tests = array('regexpTest', 'consecutivenumbersTest', 'lengthTest', 'similarityTest', 'uniqueTest');
+
+ //run tests
+ $check->runTests(array($username, $password), $tests);
+
+ $successful_tests_count = $check->successfulTestsCount();
+ $enabled_tests_count = $check->enabledTestsCount();
+
+ if($successful_tests_count == $enabled_tests_count) {
+
+ if($hide){
+ $internal_output = true;
+ }else{
+ echo '0';
+ }
+
+
+ } else{
+
+ $failedtests = $check->retrieveFailedTests();
+
+ foreach($failedtests as $ftest){
+ $all_messages[$ftest] = 'not_valid';
+ }
+
+ $actual_result = array();
+ foreach($all_messages as $key=>$message){
+ $actual_result[] = array('tname'=>$key, 'tstatus'=>$message);
+ }
+
+ if($hide){
+ $internal_output = false;
+ }else{
+ echo json_encode($actual_result);
+ }
+
+ }
+
+
+
+?>
diff --git a/grnet_password_generator/lib/grnet_password_generator_check_strength.inc~ b/grnet_password_generator/lib/grnet_password_generator_check_strength.inc~
new file mode 100644
index 0000000..20a1aec
--- /dev/null
+++ b/grnet_password_generator/lib/grnet_password_generator_check_strength.inc~
@@ -0,0 +1,112 @@
+''){
+ $password = $_POST['pwd'];
+ }
+
+
+
+ //$ins = Flight::get('ins');
+ //$username = 'mitsos';
+ //$password = 'alek';
+
+ $all_messages = array(
+ 'consecutivenumbersTest'=>'valid',
+ 'similarityTest'=>'valid',
+ 'regexpTest'=>'valid',
+ 'lengthTest'=>'valid',
+ 'uniqueTest'=>'valid',
+ );
+
+ /*
+ $conf= new Zend\Config\Config(include '../config/config.php');
+ //get policy and test from config
+ $password_strength_policy = $conf->institution[$ins]->password_strength_policy->toArray();
+ */
+
+
+ $password_strength_policy = array(
+ 'PW_CHECK_LEVENSHTEIN' => variable_get('passwordStrength_levenshtein', '2'),
+ 'PW_CHECK_MIN_LEN' => variable_get('passwordStrength_minLen', '6'),
+ 'PW_CHECK_MIN_UNIQ' => variable_get('passwordStrength_minUniq', '5'),
+ 'PW_CHECK_MIN_LCS' => variable_get('passwordStrength_minLcs', '40'),
+ 'PW_CHECK_MIN_NON_ALPHA' => variable_get('passwordStrength_nonAlpha', '2'),
+ 'PW_MIN_CONSECUTIVE_NUMBERS' => variable_get('passwordStrength_minCons', '3'),
+ );
+
+
+ $check = new passwordStrengthCheck($password_strength_policy);
+ //$tests = $conf->institution[$ins]->password_strength_tests->toArray();
+
+ $tests = array('regexpTest', 'consecutivenumbersTest', 'lengthTest', 'similarityTest', 'uniqueTest');
+
+ //run tests
+ $check->runTests(array($username, $password), $tests);
+
+ $successful_tests_count = $check->successfulTestsCount();
+ $enabled_tests_count = $check->enabledTestsCount();
+
+ if($successful_tests_count == $enabled_tests_count) {
+ // An i klisi einai server side..min epistrepseis..tipota..
+ if($hide){
+ $internal_output = true;
+ }else{
+ echo '0';
+ }
+
+
+ } else{
+
+ $failedtests = $check->retrieveFailedTests();
+ //var_dump($failedtests);
+ foreach($failedtests as $ftest){
+ $all_messages[$ftest] = 'not_valid';
+ }
+
+ $actual_result = array();
+ foreach($all_messages as $key=>$message){
+ $actual_result[] = array('tname'=>$key, 'tstatus'=>$message);
+ }
+
+ //var_dump($actual_result);
+
+ // An i klisi einai server side..min epistrepseis..tipota..
+ if($hide){
+ $internal_output = false;
+ }else{
+ echo json_encode($actual_result);
+ }
+ //$failed_tests_msgs = $check->retrieveFailedTestsMessages();
+ //$message = implode( "", $failed_tests_msgs);
+ //echo $message;
+ }
+
+
+
+?>
diff --git a/grnet_password_generator/lib/grnet_password_generator_library.inc b/grnet_password_generator/lib/grnet_password_generator_library.inc
new file mode 100644
index 0000000..df28396
--- /dev/null
+++ b/grnet_password_generator/lib/grnet_password_generator_library.inc
@@ -0,0 +1,132 @@
+'ntrsldicmzp','b'=>'euloayribsj','c'=>'oheaktirulc',
+ 'd'=>'eiorasydlun','e'=>'nrdsaltevcm','f'=>'ioreafltuyc',
+ 'g'=>'aeohrilunsg','h'=>'eiaotruykms','i'=>'ntscmledorg',
+ 'j'=>'ueoairhjklm','k'=>'eiyonashlus','l'=>'eoiyaldsfut',
+ 'm'=>'eaoipsuybmn','n'=>'goeditscayl','o'=>'fnrzmwtovls',
+ 'p'=>'earolipuths','q'=>'uuuuaecdfok','r'=>'eoiastydgnm',
+ 's'=>'eothisakpuc','t'=>'hoeiarzsuly','u'=>'trsnlpgecim',
+ 'v'=>'eiaosnykrlu','w'=>'aiheonrsldw','x'=>'ptciaeuohnq',
+ 'y'=>'oesitabpmwc','z'=>'eaiozlryhmt');
+ $a=range('a','z');
+ $l%=50; $f%=11;
+ $p=strtolower(ereg_replace("[^a-zA-Z]","",substr($p,0,$l-1))) or
+ $p=$a[rand(0,sizeof($a)-1)];
+ while(strlen($p)<$l) {
+ $ff = $f;
+ while(substr_count($p,substr($p,strlen($p)-1,1).
+ ($k=substr($d[substr($p,strlen($p)-1,1)],rand(0,$ff%11),1))))
+ if(++$ff>10) break;
+ $p.=$k;
+ }
+ return $p;
+}
+
+function _password_generate_random($length = 8, $use_mix = false, $use_num = true, $use_let = true) {
+ $allowable_characters = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz23456789";
+
+ if ($use_mix && $use_num && $use_let) {
+ $ps_st = 0;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if (!$use_mix && $use_num && $use_let) {
+ $ps_st = 24;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if ($use_mix && !$use_num && $use_let) {
+ $ps_st = 0;
+ $ps_len = 47;
+ }
+
+ if ($use_mix && $use_num && !$use_let) {
+ $ps_st = 48;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if (!$use_mix && !$use_num && $use_let) {
+ $ps_st = 24;
+ $ps_len = 47;
+ }
+
+ if (!$use_mix && $use_num && !$use_let) {
+ $ps_st = 48;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if ($use_mix && !$use_num && !$use_let) {
+ $ps_st = 0;
+ $ps_len = 1;
+ }
+
+ if (!$use_mix && !$use_num && !$use_let) {
+ $ps_st = 0;
+ $ps_len = 1;
+ }
+
+ mt_srand((double)microtime()*1000000);
+
+ $pass = "";
+
+ for($i = 0; $i < $length; $i++) {
+ $pass .= $allowable_characters[mt_rand($ps_st, $ps_len - 1)];
+ }
+
+ return $pass;
+}
+
+function _password_generate_totally_random($length=16){
+ mt_srand((double)microtime()*1000000);
+ $newstring="";
+
+ if($length>0){
+ while(strlen($newstring)<$length){
+ switch(mt_rand(1,3)){
+ case 1: $newstring.=chr(mt_rand(48,57)); break; // 0-9
+ case 2: $newstring.=chr(mt_rand(65,90)); break; // A-Z
+ case 3: $newstring.=chr(mt_rand(97,122)); break; // a-z
+ }
+ }
+ }
+ return $newstring;
+}
+
diff --git a/grnet_password_generator/lib/grnet_password_generator_library.inc~ b/grnet_password_generator/lib/grnet_password_generator_library.inc~
new file mode 100644
index 0000000..7fc0e0b
--- /dev/null
+++ b/grnet_password_generator/lib/grnet_password_generator_library.inc~
@@ -0,0 +1,173 @@
+
+ * @author Stefanos Stamatis
+ * @package components
+ * @subpackage password_generator
+ * @version $Id: password_generator.inc.php 2627 2008-06-05 08:01:34Z avel $
+ */
+
+/**
+ * Katsika Generate Password wrapper.
+ * This will reflect the current generator that is in use, or combine different
+ * generators.
+ *
+ * @return string
+ */
+
+
+function grnet_password_generator_uoa_generate_password() {
+ // 1) generate an easy-to-say string
+ $easy = _password_generate_really_easy_to_say();
+ // 2) generate a totally random part
+ $hard_len = rand(2,3);
+ $hard = _password_generate_random($hard_len, false, true, false);
+ // 3) Concatenate them
+ if($flag = rand(0,1)) {
+ return $easy.$hard;
+ } else {
+ return $hard.$easy;
+ }
+}
+
+/**
+ * Nice function that generates an easy-to-pronounce string.
+ * @author stef
+ */
+function _password_generate_really_easy_to_say() {
+ $makepass="";
+ $syllables="er,in,tia,wol,fe,pre,vet,jo,nes,al,len,son,cha,ir,ler,bo,ok,tio,nar,sim,ple,bla,ten,toe,cho,co,lat,spe,ak,er,po,c
+o,lor,pen,cil,li,ght,wh,at,the,he,ck,is,mam,bo,no,fi,ve,any,way,pol,iti,cs,ra,dio,sou,rce,sea,rch,pa,per,com,bo,sp,eak,st,fi,rst,
+gr,oup,boy,ea,gle,tr,ail,bi,ble,brb,pri,dee,kay,en,be,se";
+ $syllable_array=explode(",", $syllables);
+ srand((double)microtime()*1000000);
+ while(strlen($makepass)<8) {
+ if (rand()%10 == 1) {
+ $makepass .= sprintf("%0.0f",(rand()%50)+1);
+ } else {
+ $makepass .= sprintf("%s",$syllable_array[rand()%62]);
+ }
+ }
+ return(substr(str_replace("\n", '', $makepass),0,8));
+}
+
+/**
+ * Gen_Password -- Easy-to-Say passwords generator
+ *
+ * @param $p string Predefined part of password ("" upto 10 chars but less than $l)
+ * @param $l int - password length (1-49, def: 8)
+ * @param $f int Fuzzy (0-10, def: 3)
+ * @return string
+ * @author Ell Gree
+ */
+function _password_generate_easy_to_say($p="", $l=8, $f=4) {
+ $d=array('a'=>'ntrsldicmzp','b'=>'euloayribsj','c'=>'oheaktirulc',
+ 'd'=>'eiorasydlun','e'=>'nrdsaltevcm','f'=>'ioreafltuyc',
+ 'g'=>'aeohrilunsg','h'=>'eiaotruykms','i'=>'ntscmledorg',
+ 'j'=>'ueoairhjklm','k'=>'eiyonashlus','l'=>'eoiyaldsfut',
+ 'm'=>'eaoipsuybmn','n'=>'goeditscayl','o'=>'fnrzmwtovls',
+ 'p'=>'earolipuths','q'=>'uuuuaecdfok','r'=>'eoiastydgnm',
+ 's'=>'eothisakpuc','t'=>'hoeiarzsuly','u'=>'trsnlpgecim',
+ 'v'=>'eiaosnykrlu','w'=>'aiheonrsldw','x'=>'ptciaeuohnq',
+ 'y'=>'oesitabpmwc','z'=>'eaiozlryhmt');
+ $a=range('a','z');
+ $l%=50; $f%=11;
+ $p=strtolower(ereg_replace("[^a-zA-Z]","",substr($p,0,$l-1))) or
+ $p=$a[rand(0,sizeof($a)-1)];
+ while(strlen($p)<$l) {
+ $ff = $f;
+ while(substr_count($p,substr($p,strlen($p)-1,1).
+ ($k=substr($d[substr($p,strlen($p)-1,1)],rand(0,$ff%11),1))))
+ if(++$ff>10) break;
+ $p.=$k;
+ }
+ return $p;
+}
+
+
+/**
+ * Generate password based on given params.
+ *
+ * Originally written by:
+ * hitech-password.php - a PHP Message board script
+ * (c) Hitech Scripts 2003
+ * For more information, visit http://www.hitech-scripts.com
+ * @return string
+ */
+function _password_generate_random($length = 8, $use_mix = false, $use_num = true, $use_let = true) {
+ $allowable_characters = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz23456789";
+
+ if ($use_mix && $use_num && $use_let) {
+ $ps_st = 0;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if (!$use_mix && $use_num && $use_let) {
+ $ps_st = 24;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if ($use_mix && !$use_num && $use_let) {
+ $ps_st = 0;
+ $ps_len = 47;
+ }
+
+ if ($use_mix && $use_num && !$use_let) {
+ $ps_st = 48;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if (!$use_mix && !$use_num && $use_let) {
+ $ps_st = 24;
+ $ps_len = 47;
+ }
+
+ if (!$use_mix && $use_num && !$use_let) {
+ $ps_st = 48;
+ $ps_len = strlen($allowable_characters);
+ }
+
+ if ($use_mix && !$use_num && !$use_let) {
+ $ps_st = 0;
+ $ps_len = 1;
+ }
+
+ if (!$use_mix && !$use_num && !$use_let) {
+ $ps_st = 0;
+ $ps_len = 1;
+ }
+
+ mt_srand((double)microtime()*1000000);
+
+ $pass = "";
+
+ for($i = 0; $i < $length; $i++) {
+ $pass .= $allowable_characters[mt_rand($ps_st, $ps_len - 1)];
+ }
+
+ return $pass;
+}
+
+/**
+ * Totally random string or something. (probably useless and obsolete).
+ */
+function _password_generate_totally_random($length=16){
+ mt_srand((double)microtime()*1000000);
+ $newstring="";
+
+ if($length>0){
+ while(strlen($newstring)<$length){
+ switch(mt_rand(1,3)){
+ case 1: $newstring.=chr(mt_rand(48,57)); break; // 0-9
+ case 2: $newstring.=chr(mt_rand(65,90)); break; // A-Z
+ case 3: $newstring.=chr(mt_rand(97,122)); break; // a-z
+ }
+ }
+ }
+ return $newstring;
+}
+
diff --git a/grnet_password_generator/lib/password_strength_check/functions.inc.php b/grnet_password_generator/lib/password_strength_check/functions.inc.php
new file mode 100644
index 0000000..fe4299b
--- /dev/null
+++ b/grnet_password_generator/lib/password_strength_check/functions.inc.php
@@ -0,0 +1,58 @@
+= $LCS_Length_Table[$i][$j-1])
+ $LCS_Length_Table[$i][$j] = $LCS_Length_Table[$i-1][$j];
+ else
+ $LCS_Length_Table[$i][$j] = $LCS_Length_Table[$i][$j-1];
+ }
+ }
+ return $LCS_Length_Table[$m][$n];
+}
+/**
+ * LCS functions ripped from the php manual.
+ */
+function str_lcsfix($s)
+{
+ $s = str_replace(" ","",$s);
+ $s = preg_replace("/[éèêëËÊÉÈ]/","e", $s);
+ $s = preg_replace("/[àáâãäåÄÅÃÂÁÀ]/","a", $s);
+ $s = preg_replace("/[ìíîïÏÎÍÌ]/","i", $s);
+ $s = preg_replace("/[òóôõöÖÕÔÓ]/","o", $s);
+ $s = preg_replace("/[ÜÛÚÙùúûü]/","u", $s);
+ $s = preg_replace("/[Ç]/","c", $s);
+ return $s;
+}
+
+/**
+ * LCS functions ripped from the php manual.
+ */
+function get_lcs($s1, $s2)
+{
+ $s1 = strtolower(str_lcsfix($s1));
+ $s2 = strtolower(str_lcsfix($s2));
+ $ms = (strlen($s1) + strlen($s2)) / 2;
+ return (($lcs*100)/$ms);
+}
diff --git a/grnet_password_generator/lib/password_strength_check/password_strength_check.class.php b/grnet_password_generator/lib/password_strength_check/password_strength_check.class.php
new file mode 100644
index 0000000..3eff279
--- /dev/null
+++ b/grnet_password_generator/lib/password_strength_check/password_strength_check.class.php
@@ -0,0 +1,152 @@
+$a = $config[$a];
+ } else {
+ $this->$a = false;
+ }
+ }
+ $this->_pwd_regexps['/[^0-9]/'] = dgettext('password_strength_check', "The password must not consist only of numbers");
+ if($this->PW_CHECK_MIN_NON_ALPHA > 1) {
+
+ $this->_pwd_regexps_counts['/[^A-z]/'] = sprintf(
+ dgettext('password_strength_check', "At least %s non-alpha characters (numbers or symbols), must appear in password"),
+ $this->PW_CHECK_MIN_NON_ALPHA
+ );
+ } elseif($this->PW_CHECK_MIN_NON_ALPHA == 1){
+ $this->_pwd_regexps['/[^A-z]/'] = dgettext('password_strength_check', "At least one non-alpha character, i.e. number or symbol, must appear in password");
+
+ }
+ if($this->PW_CHECK_MIN_NON_ALPHA > 1) {
+ $this->_messages['regexp'] = array(
+ sprintf( _("At least %s non-alpha characters (numbers or symbols), must appear in password"), $this->PW_CHECK_MIN_NON_ALPHA),
+ sprintf( _("At least %s non-alpha characters (numbers or symbols), must appear in password"), $this->PW_CHECK_MIN_NON_ALPHA)
+ );
+ } elseif($this->PW_CHECK_MIN_NON_ALPHA == 1){
+ $this->_messages['regexp'] = array(
+ _("Password must contain a number or symbol."),
+ ''
+ );
+ }
+ $this->_messages['length'] = array(
+ sprintf( _("Password must be at least %s characters long."), $this->PW_CHECK_MIN_LEN) ,
+ sprintf( _("Password must be at least %s characters long."), $this->PW_CHECK_MIN_LEN)
+ );
+ $this->_messages['unique'] = array(
+ sprintf( _("Password must have at least %s different characters."), $this->PW_CHECK_MIN_UNIQ) ,
+ sprintf( _("Password must have at least %s different characters."), $this->PW_CHECK_MIN_UNIQ)
+ );
+ $this->_messages['similarity'] = array(
+ _("Password should not be very similar to the username."),
+ ''
+ );
+ $this->_messages['consecutivenumbers'] = array(
+ _("Password should not contain more than 3 ascending or descending numbers in succession") ,
+ _("Password should not contain more than 3 ascending or descending numbers in succession")
+ );
+
+ if($prev_text_domain) textdomain($prev_text_domain);
+ }
+
+ function regexpTest($data) {
+ foreach ($this->_pwd_regexps as $exp => $msg) {
+ if( preg_match ($exp, $data[1]) == FALSE)
+ return $msg;
+ }
+ foreach ($this->_pwd_regexps_counts as $exp => $msg) {
+ $ret = preg_match_all($exp, $data[1]);
+ if($ret < $this->PW_CHECK_MIN_NON_ALPHA) {
+ return $msg;
+ }
+ }
+ foreach ($this->_uid_regexps as $exp => $msg) {
+ if( preg_match ($exp, $data[0]) == FALSE)
+ return $msg;
+ }
+ }
+
+ function lengthTest($data) {
+ if ($this->PW_CHECK_MIN_LEN and strlen($data[1]) < $this->PW_CHECK_MIN_LEN) {
+ return $this->_messages['length'][1];
+ }
+ }
+
+ function uniqueTest($data) {
+ if ($this->PW_CHECK_MIN_UNIQ and strlen (count_chars ($data[1], 3)) < $this->PW_CHECK_MIN_UNIQ) {
+ return $this->_messages['unique'][1];
+ }
+ }
+
+ function similarityTest($data) {
+ if ($this->PW_CHECK_LEVENSHTEIN and levenshtein($data[0], $data[1]) < $this->PW_CHECK_LEVENSHTEIN) {
+ return dgettext('password_strength_check', "Password should not be too much like the username.");
+ }
+ if ($this->PW_CHECK_MIN_LCS and get_lcs($data[0], $data[1]) >= $this->PW_CHECK_MIN_LCS) {
+ return sprintf( dgettext('password_strength_check', "Password should not contain more than %s percent of Username."),
+ $this->PW_CHECK_MIN_LCS);
+ }
+ }
+
+ function consecutivenumbersTest($data)
+ {
+ if(!$this->PW_MIN_CONSECUTIVE_NUMBERS) {
+ return;
+ }
+ $flag = 0;
+ $prev = false;
+ $sign = 0;
+
+ for($i=0; $i= $this->PW_MIN_CONSECUTIVE_NUMBERS) {
+ return sprintf($this->_messages['consecutivenumbers'][1], $flag);
+ }
+ } else {
+ $flag = 0;
+ $sign = 0;
+ $i--;
+ }
+ } else {
+ $flag++;
+ }
+ $prev = $data[1][$cur];
+ } else {
+ $flag = 0;
+ $sign = 0;
+ $prev = false;
+ }
+ }
+ }
+}
diff --git a/grnet_password_generator/lib/password_strength_check/password_strength_check.class.php~ b/grnet_password_generator/lib/password_strength_check/password_strength_check.class.php~
new file mode 100644
index 0000000..150f67e
--- /dev/null
+++ b/grnet_password_generator/lib/password_strength_check/password_strength_check.class.php~
@@ -0,0 +1,202 @@
+
+ * @author Alexandros Vellis
+ */
+/**
+ * The checkpassword class performs a series of strength checks on a password
+ * string.
+ */
+class passwordStrengthCheck extends passwordStrengthCheckCollection
+{
+ /**
+ * @var array Active regural expression checks for passwords.
+ */
+ private $_pwd_regexps = array();
+ private $_pwd_regexps_counts = array();
+ /**
+ * @var array Active regural expression checks for username.
+ */
+ private $_uid_regexps = array();
+
+ private $_messages = array();
+ private $PW_CHECK_LEVENSHTEIN = 2;
+ private $PW_CHECK_MIN_LEN = 6;
+ private $PW_CHECK_MIN_UNIQ = 5;
+ private $PW_CHECK_MIN_LCS = 40;
+ private $PW_CHECK_MIN_NON_ALPHA = 2;
+ private $PW_MIN_CONSECUTIVE_NUMBERS = 3;
+ /**
+ * Constructor function that initializes the environment & arguments for the tests.
+ * @param $config array Injected configuration
+ */
+ function __construct($config)
+ {
+ $prev_text_domain = textdomain(null);
+ textdomain('password_strength_check');
+
+ $arr = array('PW_CHECK_LEVENSHTEIN','PW_CHECK_MIN_LEN','PW_CHECK_MIN_UNIQ','PW_CHECK_MIN_LCS', 'PW_CHECK_MIN_NON_ALPHA');
+ foreach($arr as $a) {
+ if(isset($config[$a])) {
+ $this->$a = $config[$a];
+ } else {
+ $this->$a = false;
+ }
+ }
+ $this->_pwd_regexps['/[^0-9]/'] = dgettext('password_strength_check', "The password must not consist only of numbers");
+ if($this->PW_CHECK_MIN_NON_ALPHA > 1) {
+
+ $this->_pwd_regexps_counts['/[^A-z]/'] = sprintf(
+ dgettext('password_strength_check', "At least %s non-alpha characters (numbers or symbols), must appear in password"),
+ $this->PW_CHECK_MIN_NON_ALPHA
+ );
+ } elseif($this->PW_CHECK_MIN_NON_ALPHA == 1){
+ $this->_pwd_regexps['/[^A-z]/'] = dgettext('password_strength_check', "At least one non-alpha character, i.e. number or symbol, must appear in password");
+
+ }
+ if($this->PW_CHECK_MIN_NON_ALPHA > 1) {
+ $this->_messages['regexp'] = array(
+ sprintf( _("At least %s non-alpha characters (numbers or symbols), must appear in password"), $this->PW_CHECK_MIN_NON_ALPHA),
+ sprintf( _("At least %s non-alpha characters (numbers or symbols), must appear in password"), $this->PW_CHECK_MIN_NON_ALPHA)
+ );
+ } elseif($this->PW_CHECK_MIN_NON_ALPHA == 1){
+ $this->_messages['regexp'] = array(
+ _("Password must contain a number or symbol."),
+ ''
+ );
+ }
+ $this->_messages['length'] = array(
+ sprintf( _("Password must be at least %s characters long."), $this->PW_CHECK_MIN_LEN) ,
+ sprintf( _("Password must be at least %s characters long."), $this->PW_CHECK_MIN_LEN)
+ );
+ $this->_messages['unique'] = array(
+ sprintf( _("Password must have at least %s different characters."), $this->PW_CHECK_MIN_UNIQ) ,
+ sprintf( _("Password must have at least %s different characters."), $this->PW_CHECK_MIN_UNIQ)
+ );
+ $this->_messages['similarity'] = array(
+ _("Password should not be very similar to the username."),
+ ''
+ );
+ $this->_messages['consecutivenumbers'] = array(
+ _("Password should not contain more than 3 ascending or descending numbers in succession") ,
+ _("Password should not contain more than 3 ascending or descending numbers in succession")
+ );
+
+ if($prev_text_domain) textdomain($prev_text_domain);
+ }
+ /**
+ * Regexp Check.
+ *
+ * @param array $data
+ * @return mixed An error message if there was a failure, or void on
+ * success.
+ */
+ function regexpTest($data) {
+ foreach ($this->_pwd_regexps as $exp => $msg) {
+ if( preg_match ($exp, $data[1]) == FALSE)
+ return $msg;
+ }
+ foreach ($this->_pwd_regexps_counts as $exp => $msg) {
+ $ret = preg_match_all($exp, $data[1]);
+ if($ret < $this->PW_CHECK_MIN_NON_ALPHA) {
+ return $msg;
+ }
+ }
+ foreach ($this->_uid_regexps as $exp => $msg) {
+ if( preg_match ($exp, $data[0]) == FALSE)
+ return $msg;
+ }
+ }
+ /**
+ * Length Test
+ *
+ * @param array $data
+ * @return mixed An error message if there was a failure, or void on
+ * success.
+ */
+ function lengthTest($data) {
+ if ($this->PW_CHECK_MIN_LEN and strlen($data[1]) < $this->PW_CHECK_MIN_LEN) {
+ return $this->_messages['length'][1];
+ }
+ }
+ /**
+ * Uniqueness test. Password should have at least some different
+ * characters.
+ *
+ * @param array $data
+ * @return mixed An error message if there was a failure, or void on
+ * success.
+ */
+ function uniqueTest($data) {
+ if ($this->PW_CHECK_MIN_UNIQ and strlen (count_chars ($data[1], 3)) < $this->PW_CHECK_MIN_UNIQ) {
+ return $this->_messages['unique'][1];
+ }
+ }
+ /**
+ * Similarity with username.
+ *
+ * @param array $data
+ * @return mixed An error message if there was a failure, or void on
+ * success.
+ */
+ function similarityTest($data) {
+ if ($this->PW_CHECK_LEVENSHTEIN and levenshtein($data[0], $data[1]) < $this->PW_CHECK_LEVENSHTEIN) {
+ return dgettext('password_strength_check', "Password should not be too much like the username.");
+ }
+ if ($this->PW_CHECK_MIN_LCS and get_lcs($data[0], $data[1]) >= $this->PW_CHECK_MIN_LCS) {
+ return sprintf( dgettext('password_strength_check', "Password should not contain more than %s percent of Username."),
+ $this->PW_CHECK_MIN_LCS);
+ }
+ }
+ /**
+ * Check if password has n consecutive numbers that are ascending or descending.
+ *
+ * @param array $data
+ * @return mixed An error message if there was a failure, or void on
+ * success.
+ */
+ function consecutivenumbersTest($data)
+ {
+ if(!$this->PW_MIN_CONSECUTIVE_NUMBERS) {
+ return;
+ }
+ $flag = 0;
+ $prev = false;
+ $sign = 0;
+
+ for($i=0; $i= $this->PW_MIN_CONSECUTIVE_NUMBERS) {
+ return sprintf($this->_messages['consecutivenumbers'][1], $flag);
+ }
+ } else {
+ $flag = 0;
+ $sign = 0;
+ $i--;
+ }
+ } else {
+ $flag++;
+ }
+ $prev = $data[1][$cur];
+ } else {
+ $flag = 0;
+ $sign = 0;
+ $prev = false;
+ }
+ }
+ }
+}
diff --git a/grnet_password_generator/lib/password_strength_check/password_strength_check_collection.class.php b/grnet_password_generator/lib/password_strength_check/password_strength_check_collection.class.php
new file mode 100644
index 0000000..3f49cfc
--- /dev/null
+++ b/grnet_password_generator/lib/password_strength_check/password_strength_check_collection.class.php
@@ -0,0 +1,80 @@
+_enabled_tests = $this->enabledTests($desired_tests);
+ else
+ $this->_enabled_tests = $desired_tests;
+ foreach($this->_enabled_tests as $test) {
+
+ $tmp = $this->$test($data);
+ $results[$test] = $tmp;
+ if($tmp) {
+ $this->_failed_tests[] = $test;
+ $this->_failed_tests_msgs[] = $tmp;
+ } else {
+ $this->_successful_tests[] = $test;
+ }
+ }
+ }
+
+ public function enabledTests($desired_tests) {
+ foreach(get_class_methods($this) as $test) {
+ if (strcasecmp(substr($test,-4), 'test') == 0 &&
+ ($desired_tests === true || in_array(strtolower($test),$desired_tests))) {
+ $_enabled_tests[] = $test;
+ }
+ }
+ return $_enabled_tests;
+ }
+
+ public function allTestMessages($desired_tests = true) {
+ $all_messages = array();
+ $_enabled_tests = $this->enabledTests($desired_tests);
+ foreach($_enabled_tests as $test) {
+ $t = substr($test, 0, -4);
+ if(isset($this->messages[$t]) && !empty($this->messages[$t][0])) {
+ $all_messages[$test] = $this->messages[$t][0];
+ }
+ }
+ return $all_messages;
+ }
+
+ public function retrieveEnabledTests() {
+ return $this->_enabled_tests;
+ }
+
+ public function retrieveFailedTests() {
+ return $this->_failed_tests;
+ }
+
+ public function retrieveFailedTestsMessages() {
+ return $this->_failed_tests_msgs;
+ }
+
+
+ public function retrieveSuccessfulTests() {
+ return $this->_successful_tests;
+ }
+
+ public function enabledTestsCount() {
+ return count($this->_enabled_tests);
+ }
+
+ public function failedTestsCount() {
+ return count($this->_failed_tests);
+ }
+
+ public function successfulTestsCount() {
+ return count($this->_successful_tests);
+ }
+}
diff --git a/grnet_password_generator/lib/password_strength_check/password_strength_check_collection.class.php~ b/grnet_password_generator/lib/password_strength_check/password_strength_check_collection.class.php~
new file mode 100644
index 0000000..5755c3a
--- /dev/null
+++ b/grnet_password_generator/lib/password_strength_check/password_strength_check_collection.class.php~
@@ -0,0 +1,134 @@
+
+ * @author Alexandros Vellis
+ * @todo reinstate some OO private/public declarations after complete switch to PHP5... (see r2641)
+ */
+/**
+ * Base class for running multiple tests with the same data.
+ *
+ * Child classses must define functions that accept some form
+ * of test data and return NULL on success or an explanation of
+ * the error.
+ *
+ */
+class passwordStrengthCheckCollection
+{
+ protected $_enabled_tests = array();
+ protected $_failed_tests = array();
+ protected $_failed_tests_msgs = array();
+ protected $_successful_tests = array();
+ /**
+ * Function that runs all test methods with specified data.
+ * @param mixed $data
+ * @param mixed $desired_tests Tests to enable. If true, all tests will be
+ * on. Otherwise it will be an array of the test names to enable.
+ * E.g. array('retypetest', 'lcstest')
+ *
+ * @return array An array of the tests that failed.
+ */
+ public function runTests($data, $desired_tests = true) {
+ $results = array();
+ if($desired_tests===true)
+ $this->_enabled_tests = $this->enabledTests($desired_tests);
+ else
+ $this->_enabled_tests = $desired_tests;
+ foreach($this->_enabled_tests as $test) {
+
+ $tmp = $this->$test($data);
+ $results[$test] = $tmp;
+ if($tmp) {
+ $this->_failed_tests[] = $test;
+ $this->_failed_tests_msgs[] = $tmp;
+ } else {
+ $this->_successful_tests[] = $test;
+ }
+ }
+ }
+ /**
+ * Which tests are enabled?
+ * @return array
+ */
+ public function enabledTests($desired_tests) {
+ foreach(get_class_methods($this) as $test) {
+ if (strcasecmp(substr($test,-4), 'test') == 0 &&
+ ($desired_tests === true || in_array(strtolower($test),$desired_tests))) {
+ $_enabled_tests[] = $test;
+ }
+ }
+ return $_enabled_tests;
+ }
+ /**
+ * Retrieve All Messages (Information messages)
+ *
+ * @param mixed $desired_tests Tests to get messages for, or boolean true to get
+ * all messages
+ * @return array Associative array, key: name of test, value: message
+ */
+ public function allTestMessages($desired_tests = true) {
+ $all_messages = array();
+ $_enabled_tests = $this->enabledTests($desired_tests);
+ foreach($_enabled_tests as $test) {
+ $t = substr($test, 0, -4);
+ if(isset($this->messages[$t]) && !empty($this->messages[$t][0])) {
+ $all_messages[$test] = $this->messages[$t][0];
+ }
+ }
+ return $all_messages;
+ }
+ /**
+ * Getter: enabled tests
+ * @return array
+ */
+ public function retrieveEnabledTests() {
+ return $this->_enabled_tests;
+ }
+ /**
+ * Getter: failed tests
+ * @return array
+ */
+ public function retrieveFailedTests() {
+ return $this->_failed_tests;
+ }
+ /**
+ * Getter: failed tests with error messages
+ * @return array
+ */
+ public function retrieveFailedTestsMessages() {
+ return $this->_failed_tests_msgs;
+ }
+
+ /**
+ * Getter: tests that succeeded
+ * @return array
+ */
+ public function retrieveSuccessfulTests() {
+ return $this->_successful_tests;
+ }
+ /**
+ * Getter: number of enabled tests
+ * @return int
+ */
+ public function enabledTestsCount() {
+ return count($this->_enabled_tests);
+ }
+ /**
+ * Getter: number of failed tests
+ * @return int
+ */
+ public function failedTestsCount() {
+ return count($this->_failed_tests);
+ }
+ /**
+ * Getter: number of successful tests
+ * @return int
+ */
+ public function successfulTestsCount() {
+ return count($this->_successful_tests);
+ }
+}
diff --git a/grnet_registration/grnet_registration.info b/grnet_registration/grnet_registration.info
new file mode 100755
index 0000000..476a38e
--- /dev/null
+++ b/grnet_registration/grnet_registration.info
@@ -0,0 +1,12 @@
+name = Grnet Registration
+description = Grnet Registration
+core = "7.x"
+package = Grnet
+
+; Information added by drupal.org packaging script on 2013-05-20
+version = "7.x-1.0"
+core = "7.x"
+project = "grnet_core"
+datestamp = "1369041918"
+
+scripts[] = js/main.js
\ No newline at end of file
diff --git a/grnet_registration/grnet_registration.module b/grnet_registration/grnet_registration.module
new file mode 100755
index 0000000..af65140
--- /dev/null
+++ b/grnet_registration/grnet_registration.module
@@ -0,0 +1,609 @@
+ 'Confirm Email',
+ 'page callback' => '_confirm_email',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['registration/emailinuse/%'] = array(
+ 'title' => 'Email in Use',
+ 'page callback' => '_emailInUse',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['registration/amkainuse/%'] = array(
+ 'title' => 'ΑΜΚΑ in Use',
+ 'page callback' => '_amkaInUse',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['registration/check_username/%'] = array(
+ 'title' => 'Check Username',
+ 'page callback' => '_check_username',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+function _emailInUse($email){
+
+ $default_email = '';
+
+
+ global $user;
+
+
+ if($_SESSION['phpCAS']['user']<>''){
+ $username = $_SESSION['phpCAS']['user'];
+ $entity_id = grnet_core_get_entity_id_by_username($username);
+ $entity_username = $_SESSION['phpCAS']['user'];
+ $entity_email = grnet_registration_get_email($entity_id);
+
+
+ }elseif(grnet_core_user_has_role('manager')){
+
+
+ $temp = explode("/entityform/", $_SERVER["HTTP_REFERER"]);
+ $temp = explode("/edit/", $temp[1]);
+ $entity_id = $temp[0];
+ $entity_username = grnet_registration_get_username($entity_id);
+ $entity_email = grnet_registration_get_email($entity_id);
+
+
+ }else{
+ $entity_email = $default_email;
+ }
+
+
+
+
+
+
+ if($entity_email ==''){
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_email} WHERE (field_ldapregistr_email_email=:email)",array(':email' => $email) )->fetchField();
+
+ if($result==0){
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("mail" => $email))){
+ $result = $result+100;
+ }
+ }
+
+
+ }else{
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_email} WHERE (field_ldapregistr_email_email<>:entity_email AND field_ldapregistr_email_email=:email)",array(':entity_email' => $entity_email , ':email' => $email) )->fetchField();
+
+ if($result==0){
+
+ if(!grnet_ldap_interconnection_ldap_user_exists_wrapper(array("uid" => $entity_username , "mail" => $email))){
+
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("mail" => $email))){
+ $result = $result+100;
+ }
+
+
+ }
+
+ }
+
+
+ }
+
+ echo $result;
+
+}
+function _amkaInUse($amka){
+ $default_amka = '';
+ global $user;
+ if($_SESSION['phpCAS']['user']<>''){
+ $username = $_SESSION['phpCAS']['user'];
+ $entity_id = grnet_core_get_entity_id_by_username($username);
+ $entity_username = $_SESSION['phpCAS']['user'];
+ $entity_amka = grnet_registration_get_amka($entity_id);
+ }elseif(grnet_core_user_has_role('manager')){
+ $temp = explode("/entityform/", $_SERVER["HTTP_REFERER"]);
+ $temp = explode("/edit/", $temp[1]);
+ $entity_id = $temp[0];
+ $entity_username = grnet_registration_get_username($entity_id);
+ $entity_amka = grnet_registration_get_amka($entity_id);
+ }else{
+ $entity_amka = $default_amka;
+ }
+ if($entity_amka ==''){
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_amka} WHERE (field_ldapregistr_amka_value=:amka)",array(':amka' => $amka) )->fetchField();
+
+ if($result==0){
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("schacPersonalUniqueID" => $amka))){
+ $result = $result+100;
+ }
+ }
+ }else{
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_amka} WHERE (field_ldapregistr_amka_value<>:entity_amka AND field_ldapregistr_amka_value=:amka)",array(':entity_amka' => $entity_amka , ':amka' => $amka) )->fetchField();
+ if($result==0){
+
+ if(!grnet_ldap_interconnection_ldap_user_exists_wrapper(array("uid" => $entity_username , "schacPersonalUniqueID" => $amka))){
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("schacPersonalUniqueID" => $amka))){
+ $result = $result+100;
+ }
+ }
+
+ }
+ }
+ echo $result;
+}
+function grnet_registration_check_name($name){
+ $result = true;
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_registration').'/includes/policy/name.inc');
+ if(!$result_policy){
+ $result=false;
+ }
+ return $result;
+}
+function grnet_registration_check_surname($surname){
+ $result = true;
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_registration').'/includes/policy/surname.inc');
+ if(!$result_policy){
+ $result=false;
+ }
+ return $result;
+}
+function grnet_registration_check_username($username){
+ $result = _check_username($username,true);
+ if($result=='0'){
+ return true;
+ }else{
+ return false;
+ }
+
+}
+function _check_username($username,$hide=null){
+ $return_message = 'Το όνομα '.$username. ' δεν είναι διαθέσιμο';
+ $result = true;
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_registration').'/includes/policy/username.inc');
+ if(!$result_policy){
+ $result=false;
+ }
+
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("uid" => $username)))
+ $result=false;
+ if(grnet_core_get_entity_id_by_username($username)>0){
+ $result=false;
+ }
+
+ if($result == true ){
+ $final_return_message = '0';
+ }else{
+ $final_return_message = $return_message;
+ }
+
+ if($hide){
+ return $final_return_message;
+ }else{
+ echo $final_return_message;
+ }
+
+
+
+}
+function _confirm_email($secretkey){
+ $entity_id = grnet_registration_get_entity_id($secretkey);
+
+ if($entity_id>0){
+ $status = grnet_registration_get_submission_status($entity_id);
+ if($status=='prepending'){
+ _set_submission_status($entity_id,'pending');
+ $status_changed_to_pending = 1;
+ $status = 'pending';
+ }else{
+ $status_changed_to_pending = 0;
+ }
+ if ($status=='completed'){
+ drupal_set_message("Η εγγραφή σας ολοκληρώθηκε επιτυχώς (Κατάσταση : ".t('completed').")");
+ }
+ return _display_message($status, $status_changed_to_pending, $entity_id);
+
+ }else{
+ drupal_set_message("Η σελίδα που προσπαθείτε να προσπελάσεται δεν αναγνωρίζεται!!","error");
+ return '';
+ }
+}
+function grnet_registration_get_entity_id($secretkey){
+ $entity_id = db_query("SELECT {entity_id} FROM {field_data_field_ldapregistr_secretkey} WHERE (field_ldapregistr_secretkey_value=:secretkey)",array(':secretkey' => $secretkey) )->fetchField();
+ return $entity_id;
+}
+function grnet_registration_get_submission_status($entity_id){
+ if($entity_id>0){
+ $status = db_query("SELECT {field_ldapregistr_status_value} FROM {field_data_field_ldapregistr_status} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $status;
+ }else{
+ return '';
+ }
+}
+function _get_username($entity_id){
+ $username = db_query("SELECT {field_ldapregistr_username_value} FROM {field_data_field_ldapregistr_username} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $username;
+}
+function _set_submission_status($entity_id,$new_status){
+ db_query("update {field_data_field_ldapregistr_status} SET field_ldapregistr_status_value=:status WHERE (entity_id=:entity_id)",array(':status' => $new_status, ':entity_id' => $entity_id ) );
+ db_query("update {field_revision_field_ldapregistr_status} SET field_ldapregistr_status_value=:status WHERE (entity_id=:entity_id)",array(':status' => $new_status, ':entity_id' => $entity_id ) );
+
+ $email = db_query("SELECT {field_ldapregistr_email_email} FROM {field_data_field_ldapregistr_email} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ drupal_flush_all_caches();
+}
+function grnet_registration_get_username($entity_id){
+ $username = db_query("SELECT {field_ldapregistr_username_value} FROM {field_data_field_ldapregistr_username} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $username;
+}
+function grnet_registration_get_email($entity_id){
+ $email = db_query("SELECT {field_ldapregistr_email_email} FROM {field_data_field_ldapregistr_email} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $email;
+}
+function grnet_registration_get_amka($entity_id){
+ $amka = db_query("SELECT {field_ldapregistr_amka_value} FROM {field_data_field_ldapregistr_amka} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $amka;
+}
+function grnet_registration_get_submission_create_timestamp($entity_id){
+ $create_date = db_query("SELECT {created} FROM {entityform} WHERE (entityform_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $create_date;
+}
+function grnet_registration_get_expiration_date($entity_id,$duration_in_seconds){
+ $expiration_timestamp = grnet_registration_get_submission_create_timestamp($entity_id)+$duration_in_seconds;
+ return $expiration_timestamp;
+}
+function _display_message($status,$status_changed_to_pending,$entity_id){
+ $html = '
+
';
+
+ if($status_changed_to_pending==1){
+ $html .= '
+ Απαιτείται ενεργοποίηση του λογαριασμού σας από το διαχειριστή
+
';
+ }
+ if ($status=='prepending' || $status=='pending'){
+ $html .= '
+ Η αίτηση εγγραφής υποβλήθηκε επιτυχώς! Για την ενεργοποίηση του λογαριασμού σας επισκεφθείτε τον διαχειριστή.
+
';
+ }
+ $html .= '
+ Κατάσταση αίτησης: '.t($status).'
+
+
+
+ Όνομα χρήστη (username): '._get_username($entity_id).'
+ Αριθμός αίτησης: '.$entity_id.'
+
+ ';
+
+ if ($status=='prepending' || $status=='pending'){
+ $html .='
+
+
+ ΠΡΟΣΟΧΗ:
Για να ενεργοποιηθεί ο λογαριασμός σας, θα πρέπει να επισκεφθείτε
+ τον διαχειριστή του συστήματος
το αργότερο μέχρι τις '.date("d/n/Y" , grnet_registration_get_expiration_date($entity_id,variable_get('grnet_complete_submission_duration_in_days')*86400)).'.
+
+
+ Παρακαλούμε εκτυπώστε ή αποθηκεύστε τα παραπάνω στοιχεία.
+
+
+
+
+
+ Στοιχεία Διαχειριστή
+ '.grnet_core_get_manager_contact_info().'
+
+
+
+ Όνομα χρήστη και κωδικός πρόσβασης
+
+
+
+
+ Όνομα Χρήστη *
+ '.grnet_core_get_username_by_entity_id(arg(1)).'
+
+
+
+
+
Κωδικός πρόσβασης
+
**********
+
+
+ ';
+ $form['field_ldapregistr_username']['
+ }
+
+
+
+ $form['field_ldapregistr_username']['
+
+
Κωδικός πρόσβασης
+
**********
+
';
+ $form['field_ldapregistr_pwd']['
+ $form['field_ldapregistr_confirmpwd']['
+
+ $form['
+
+ }else{
+
+
+ $form['required-fields group-ldapregistr-personaldata field-group-fieldset form-wrapper']['
+
+ Όνομα χρήστη και κωδικός πρόσβασης
+
+
+
+
+ Όνομα Χρήστη *
+ '.grnet_core_get_username_by_entity_id(arg(1)).'
+
+
+
+
+
+ ';
+
+
+ $form['field_ldapregistr_username']['
+ $form['field_ldapregistr_pwd']['
+ $form['field_ldapregistr_confirmpwd']['
+
+ $form['
+
+ }
+
+ }
+}
+function _ldapregistration_validation_anonymous($form, &$form_state) {
+ $name = $form['field_ldapregistr_name'][und][0]['value']['
+ if(!grnet_registration_check_name($name)){
+ form_set_error('field_ldapregistr_name', 'Στο Όνομα επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+
+ $surname = $form['field_ldapregistr_surname'][und][0]['value']['
+ if(!grnet_registration_check_surname($surname)){
+ form_set_error('field_ldapregistr_surname', 'Στο Επώνυμο επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+ $amka = $form['field_ldapregistr_amka'][und][0]['value']['
+ if(!grnet_core_validateAMKA($amka)){
+ form_set_error('field_ldapregistr_amka', 'Εισάγεται ένα έγκυρο ΑΜΚΑ.');
+ }
+
+
+ $email = $form['field_ldapregistr_email'][und][0]['email']['
+ if(!grnet_core_isEmailValidDueToDomainSuffixedPolicy($email)){
+ form_set_error('field_ldapregistr_email', 'Το email σας πρέπει να έχει κατάληξη ίδια με το domain του νοσοκομείου. (@'.variable_get('grnet_domain_suffixed_emails').')');
+ }
+
+
+ $username = $form['field_ldapregistr_username'][und][0]['value']['
+ if(!grnet_registration_check_username($username)){
+ form_set_error('field_ldapregistr_pwd', 'Το όνομα χρήστη δεν πληρεί της πολιτικές ασφαλείας.');
+ }
+
+ $password = $form['field_ldapregistr_pwd'][und][0][password_field]['
+ $confirmation_password = $form['field_ldapregistr_confirmpwd'][und][0][password_field]['
+
+ if(!grnet_password_generator_check_password_strength($password,true)){
+ form_set_error('field_ldapregistr_pwd', 'Ο κωδικός πρόσβασης δεν πληρεί της πολιτικές ασφαλείας.');
+ }else{
+ if($password<>$confirmation_password){
+ form_set_error('field_ldapregistr_pwd', '');
+ form_set_error('field_ldapregistr_confirmpwd', 'Οι κωδικοί δεν είναι ίδιοι!!');
+ }
+ }
+ return false;
+}
+function _ldapregistration_validation_ldapuser($form, &$form_state) {
+ $name = $form['field_ldapregistr_name'][und][0]['value']['
+ if(!grnet_registration_check_name($name)){
+ form_set_error('field_ldapregistr_name', 'Στο Όνομα επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+ $surname = $form['field_ldapregistr_surname'][und][0]['value']['
+ if(!grnet_registration_check_surname($surname)){
+ form_set_error('field_ldapregistr_surname', 'Στο Επώνυμο επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+ $amka = $form['field_ldapregistr_amka'][und][0]['value']['
+ if(!grnet_core_validateAMKA($amka)){
+ form_set_error('field_ldapregistr_amka', 'Εισάγεται ένα έγκυρο ΑΜΚΑ.');
+ }
+ $email = $form['field_ldapregistr_email'][und][0]['email']['
+ if(!grnet_core_isEmailValidDueToDomainSuffixedPolicy($email)){
+ form_set_error('field_ldapregistr_email', 'Το email σας πρέπει να έχει κατάληξη ίδια με το domain του νοσοκομείου. (@'.variable_get('grnet_domain_suffixed_emails').')');
+ }
+ return false;
+}
+function _ldapregistration_validation_manager($form, &$form_state) {
+ if( grnet_core_user_has_role('manager') &&
+ ($form["field_ldapregistr_status"]['und']['
+ $form["field_ldapregistr_status"]['und']['
+ $form["field_ldapregistr_status"]['und']['
+ $form["field_ldapregistr_status"]['und']['
+ )
+ ){
+
+ form_set_error('field_ldapregistr_status', 'Η κατάσταση της αίτησης τροποποιήθηκε ή δεν επιτρέπεται η αποθήκευση από αυτή την κατάσταση!! Πατήστε εδώ για επιστροφή στα αιτήματα μεταβολής.');
+ }
+
+ $name = $form['field_ldapregistr_name'][und][0]['value']['
+ if(!grnet_registration_check_name($name)){
+ form_set_error('field_ldapregistr_name', 'Στο Όνομα επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+
+ $surname = $form['field_ldapregistr_surname'][und][0]['value']['
+ if(!grnet_registration_check_surname($surname)){
+ form_set_error('field_ldapregistr_surname', 'Στο Επώνυμο επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+
+ $amka = $form['field_ldapregistr_amka'][und][0]['value']['
+ if(!grnet_core_validateAMKA($amka)){
+ form_set_error('field_ldapregistr_amka', 'Εισάγεται ένα έγκυρο ΑΜΚΑ.');
+ }
+
+
+ $email = $form['field_ldapregistr_email'][und][0]['email']['
+
+ if(!grnet_core_isEmailValidDueToDomainSuffixedPolicy($email)){
+ form_set_error('field_ldapregistr_email', 'Το email σας πρέπει να έχει κατάληξη ίδια με το domain του νοσοκομείου. (@'.variable_get('grnet_domain_suffixed_emails').')');
+ }
+
+ return false;
+}
+function grnet_registration_cron(){
+
+
+
+
+ $period_in_seconds = variable_get('grnet_mail_verification_duration_in_minutes')*60;
+ $timestamp_barrier = time()-$period_in_seconds;
+
+
+
+ $result = db_query("SELECT entfrm.entityform_id as ent_id
+ FROM {entityform} AS entfrm
+ JOIN {field_data_field_ldapregistr_status} as entfrm_st
+ ON (entfrm.entityform_id = entfrm_st.entity_id)
+ WHERE
+ entfrm_st.field_ldapregistr_status_value = 'prepending' AND
+ entfrm.created < :timestamp_barrier",array(':timestamp_barrier' => $timestamp_barrier));
+
+
+
+ foreach ($result as $rec) {
+
+ $entity_instance = entity_load('entityform', array($rec->ent_id));
+ $entity_instance = $entity_instance[$rec->ent_id];
+
+ $ent_id = $rec->ent_id;
+ $ent_name = $entity_instance->field_ldapregistr_name['und'][0]['value'];
+ $ent_surname = $entity_instance->field_ldapregistr_surname['und'][0]['value'];
+ $ent_email = $entity_instance->field_ldapregistr_email['und'][0]['email'];
+ $ent_amka = $entity_instance->field_ldapregistr_amka['und'][0]['value'];
+
+
+
+ watchdog('grnet registration prepending', 'Submission Cron Deleted
+ id : '.$ent_id.'
+ Όνομα : '.$ent_name.'
+ Επώνυμο : '.$ent_surname.'
+ Email : '.$ent_email.'
+ ΑΜΚΑ : '.$ent_amka, NULL , WATCHDOG_WARNING);
+
+ entity_delete('entityform', $ent_id);
+
+ }
+
+
+
+
+
+
+
+ $period_in_seconds = variable_get('grnet_complete_submission_duration_in_days')*86400;
+ $timestamp_barrier = time()-$period_in_seconds;
+
+
+
+ $result = db_query("SELECT entfrm.entityform_id as ent_id
+ FROM {entityform} AS entfrm
+ JOIN {field_data_field_ldapregistr_status} as entfrm_st
+ ON (entfrm.entityform_id = entfrm_st.entity_id)
+ WHERE
+ entfrm_st.field_ldapregistr_status_value = 'pending' AND
+ entfrm.created < :timestamp_barrier",array(':timestamp_barrier' => $timestamp_barrier));
+
+
+
+ foreach ($result as $rec) {
+
+ $entity_instance = entity_load('entityform', array($rec->ent_id));
+ $entity_instance = $entity_instance[$rec->ent_id];
+
+ $ent_id = $rec->ent_id;
+ $ent_name = $entity_instance->field_ldapregistr_name['und'][0]['value'];
+ $ent_surname = $entity_instance->field_ldapregistr_surname['und'][0]['value'];
+ $ent_email = $entity_instance->field_ldapregistr_email['und'][0]['email'];
+ $ent_amka = $entity_instance->field_ldapregistr_amka['und'][0]['value'];
+
+
+
+ watchdog('grnet registration pending', 'Submission Cron Deleted
+ id : '.$ent_id.'
+ Όνομα : '.$ent_name.'
+ Επώνυμο : '.$ent_surname.'
+ Email : '.$ent_email.'
+ ΑΜΚΑ : '.$ent_amka, NULL , WATCHDOG_WARNING);
+
+ entity_delete('entityform', $ent_id);
+
+ }
+
+
+
+
+}
diff --git a/grnet_registration/grnet_registration.module~ b/grnet_registration/grnet_registration.module~
new file mode 100755
index 0000000..21b54d4
--- /dev/null
+++ b/grnet_registration/grnet_registration.module~
@@ -0,0 +1,622 @@
+ 'Confirm Email',
+ 'page callback' => '_confirm_email',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['registration/emailinuse/%'] = array(
+ 'title' => 'Email in Use',
+ 'page callback' => '_emailInUse',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['registration/amkainuse/%'] = array(
+ 'title' => 'ΑΜΚΑ in Use',
+ 'page callback' => '_amkaInUse',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['registration/check_username/%'] = array(
+ 'title' => 'Check Username',
+ 'page callback' => '_check_username',
+ 'page arguments' => array(2),
+ /*'access callback' => 'user_access',*/
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+function _emailInUse($email){
+
+ $default_email = '';
+
+
+ global $user;
+
+
+ if($_SESSION['phpCAS']['user']<>''){
+ $username = $_SESSION['phpCAS']['user'];
+ $entity_id = grnet_core_get_entity_id_by_username($username);
+ $entity_username = $_SESSION['phpCAS']['user'];
+ $entity_email = grnet_registration_get_email($entity_id);
+
+
+ }elseif(grnet_core_user_has_role('manager')){
+
+
+ $temp = explode("/entityform/", $_SERVER["HTTP_REFERER"]);
+ $temp = explode("/edit/", $temp[1]);
+ $entity_id = $temp[0];
+ $entity_username = grnet_registration_get_username($entity_id);
+ $entity_email = grnet_registration_get_email($entity_id);
+
+
+ }else{
+ $entity_email = $default_email;
+ }
+
+
+
+
+
+
+ if($entity_email ==''){
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_email} WHERE (field_ldapregistr_email_email=:email)",array(':email' => $email) )->fetchField();
+
+ if($result==0){
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("mail" => $email))){
+ $result = $result+100;
+ }
+ }
+
+
+ }else{
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_email} WHERE (field_ldapregistr_email_email<>:entity_email AND field_ldapregistr_email_email=:email)",array(':entity_email' => $entity_email , ':email' => $email) )->fetchField();
+
+ if($result==0){
+
+ if(!grnet_ldap_interconnection_ldap_user_exists_wrapper(array("uid" => $entity_username , "mail" => $email))){
+
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("mail" => $email))){
+ $result = $result+100;
+ }
+
+
+ }
+
+ }
+
+
+ }
+
+ echo $result;
+
+}
+function _amkaInUse($amka){
+ $default_amka = '';
+ global $user;
+ if($_SESSION['phpCAS']['user']<>''){
+ $username = $_SESSION['phpCAS']['user'];
+ $entity_id = grnet_core_get_entity_id_by_username($username);
+ $entity_username = $_SESSION['phpCAS']['user'];
+ $entity_amka = grnet_registration_get_amka($entity_id);
+ }elseif(grnet_core_user_has_role('manager')){
+ $temp = explode("/entityform/", $_SERVER["HTTP_REFERER"]);
+ $temp = explode("/edit/", $temp[1]);
+ $entity_id = $temp[0];
+ $entity_username = grnet_registration_get_username($entity_id);
+ $entity_amka = grnet_registration_get_amka($entity_id);
+ }else{
+ $entity_amka = $default_amka;
+ }
+ if($entity_amka ==''){
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_amka} WHERE (field_ldapregistr_amka_value=:amka)",array(':amka' => $amka) )->fetchField();
+
+ if($result==0){
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("schacPersonalUniqueID" => $amka))){
+ $result = $result+100;
+ }
+ }
+ }else{
+ $result = db_query("SELECT count(*) FROM {field_data_field_ldapregistr_amka} WHERE (field_ldapregistr_amka_value<>:entity_amka AND field_ldapregistr_amka_value=:amka)",array(':entity_amka' => $entity_amka , ':amka' => $amka) )->fetchField();
+ if($result==0){
+
+ if(!grnet_ldap_interconnection_ldap_user_exists_wrapper(array("uid" => $entity_username , "schacPersonalUniqueID" => $amka))){
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("schacPersonalUniqueID" => $amka))){
+ $result = $result+100;
+ }
+ }
+
+ }
+ }
+ echo $result;
+}
+function grnet_registration_check_name($name){
+ $result = true;
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_registration').'/includes/policy/name.inc');
+ if(!$result_policy){
+ $result=false;
+ }
+ return $result;
+}
+function grnet_registration_check_surname($surname){
+ $result = true;
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_registration').'/includes/policy/surname.inc');
+ if(!$result_policy){
+ $result=false;
+ }
+ return $result;
+}
+function grnet_registration_check_username($username){
+ $result = _check_username($username,true);
+ if($result=='0'){
+ return true;
+ }else{
+ return false;
+ }
+
+}
+function _check_username($username,$hide=null){
+ $return_message = 'Το όνομα '.$username. ' δεν είναι διαθέσιμο';
+ $result = true;
+ include_once(DRUPAL_ROOT.'/'.drupal_get_path('module', 'grnet_registration').'/includes/policy/username.inc');
+ if(!$result_policy){
+ $result=false;
+ }
+
+ if(grnet_ldap_interconnection_ldap_user_exists_wrapper(array("uid" => $username)))
+ $result=false;
+ if(grnet_core_get_entity_id_by_username($username)>0){
+ $result=false;
+ }
+
+ if($result == true ){
+ $final_return_message = '0';
+ }else{
+ $final_return_message = $return_message;
+ }
+
+ if($hide){
+ return $final_return_message;
+ }else{
+ echo $final_return_message;
+ }
+
+
+
+}
+function _confirm_email($secretkey){
+ $entity_id = grnet_registration_get_entity_id($secretkey);
+
+ if($entity_id>0){
+ $status = grnet_registration_get_submission_status($entity_id);
+ if($status=='prepending'){
+ _set_submission_status($entity_id,'pending');
+ $status_changed_to_pending = 1;
+ $status = 'pending';
+ }else{
+ $status_changed_to_pending = 0;
+ }
+ if ($status=='completed'){
+ drupal_set_message("Η εγγραφή σας ολοκληρώθηκε επιτυχώς (Κατάσταση : ".t('completed').")");
+ }
+ return _display_message($status, $status_changed_to_pending, $entity_id);
+
+ }else{
+ drupal_set_message("Η σελίδα που προσπαθείτε να προσπελάσεται δεν αναγνωρίζεται!!","error");
+ return '';
+ }
+}
+function grnet_registration_get_entity_id($secretkey){
+ $entity_id = db_query("SELECT {entity_id} FROM {field_data_field_ldapregistr_secretkey} WHERE (field_ldapregistr_secretkey_value=:secretkey)",array(':secretkey' => $secretkey) )->fetchField();
+ return $entity_id;
+}
+function grnet_registration_get_submission_status($entity_id){
+ if($entity_id>0){
+ $status = db_query("SELECT {field_ldapregistr_status_value} FROM {field_data_field_ldapregistr_status} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $status;
+ }else{
+ return '';
+ }
+}
+function _get_username($entity_id){
+ $username = db_query("SELECT {field_ldapregistr_username_value} FROM {field_data_field_ldapregistr_username} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $username;
+}
+function _set_submission_status($entity_id,$new_status){
+ db_query("update {field_data_field_ldapregistr_status} SET field_ldapregistr_status_value=:status WHERE (entity_id=:entity_id)",array(':status' => $new_status, ':entity_id' => $entity_id ) );
+ db_query("update {field_revision_field_ldapregistr_status} SET field_ldapregistr_status_value=:status WHERE (entity_id=:entity_id)",array(':status' => $new_status, ':entity_id' => $entity_id ) );
+
+ $email = db_query("SELECT {field_ldapregistr_email_email} FROM {field_data_field_ldapregistr_email} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ drupal_flush_all_caches();
+}
+function grnet_registration_get_username($entity_id){
+ $username = db_query("SELECT {field_ldapregistr_username_value} FROM {field_data_field_ldapregistr_username} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $username;
+}
+function grnet_registration_get_email($entity_id){
+ $email = db_query("SELECT {field_ldapregistr_email_email} FROM {field_data_field_ldapregistr_email} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $email;
+}
+function grnet_registration_get_amka($entity_id){
+ $amka = db_query("SELECT {field_ldapregistr_amka_value} FROM {field_data_field_ldapregistr_amka} WHERE (entity_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $amka;
+}
+function grnet_registration_get_submission_create_timestamp($entity_id){
+ $create_date = db_query("SELECT {created} FROM {entityform} WHERE (entityform_id=:entity_id)",array(':entity_id' => $entity_id) )->fetchField();
+ return $create_date;
+}
+function grnet_registration_get_expiration_date($entity_id,$duration_in_seconds){
+ $expiration_timestamp = grnet_registration_get_submission_create_timestamp($entity_id)+$duration_in_seconds;
+ return $expiration_timestamp;
+}
+function _display_message($status,$status_changed_to_pending,$entity_id){
+ $html = '
+
';
+
+ if($status_changed_to_pending==1){
+ $html .= '
+ Απαιτείται ενεργοποίηση του λογαριασμού σας από το διαχειριστή
+
';
+ }
+ if ($status=='prepending' || $status=='pending'){
+ $html .= '
+ Η αίτηση εγγραφής υποβλήθηκε επιτυχώς! Για την ενεργοποίηση του λογαριασμού σας επισκεφθείτε τον διαχειριστή.
+
';
+ }
+ $html .= '
+ Κατάσταση αίτησης: '.t($status).'
+
+
+
+ Όνομα χρήστη (username): '._get_username($entity_id).'
+ Αριθμός αίτησης: '.$entity_id.'
+
+ ';
+
+ if ($status=='prepending' || $status=='pending'){
+ $html .='
+
+
+ ΠΡΟΣΟΧΗ:
Για να ενεργοποιηθεί ο λογαριασμός σας, θα πρέπει να επισκεφθείτε
+ τον διαχειριστή του συστήματος
το αργότερο μέχρι τις '.date("d/n/Y" , grnet_registration_get_expiration_date($entity_id,variable_get('grnet_complete_submission_duration_in_days')*86400)).'.
+
+
+ Παρακαλούμε εκτυπώστε ή αποθηκεύστε τα παραπάνω στοιχεία.
+
+
+
+
+
+ Στοιχεία Διαχειριστή
+ '.grnet_core_get_manager_contact_info().'
+
+
+
+ Όνομα χρήστη και κωδικός πρόσβασης
+
+
+
+
+ Όνομα Χρήστη *
+ '.grnet_core_get_username_by_entity_id(arg(1)).'
+
+
+
+
+
Κωδικός πρόσβασης
+
**********
+
+
+ ';
+ $form['field_ldapregistr_username']['
+ }
+
+
+
+ $form['field_ldapregistr_username']['
+
+
Κωδικός πρόσβασης
+
**********
+
';
+ $form['field_ldapregistr_pwd']['
+ $form['field_ldapregistr_confirmpwd']['
+
+ $form['
+
+ }else{
+
+
+ $form['required-fields group-ldapregistr-personaldata field-group-fieldset form-wrapper']['
+
+ Όνομα χρήστη και κωδικός πρόσβασης
+
+
+
+
+ Όνομα Χρήστη *
+ '.grnet_core_get_username_by_entity_id(arg(1)).'
+
+
+
+
+
+ ';
+
+
+ $form['field_ldapregistr_username']['
+ $form['field_ldapregistr_pwd']['
+ $form['field_ldapregistr_confirmpwd']['
+
+ $form['
+
+ }
+
+ }
+}
+function _ldapregistration_validation_anonymous($form, &$form_state) {
+ $name = $form['field_ldapregistr_name'][und][0]['value']['
+ if(!grnet_registration_check_name($name)){
+ form_set_error('field_ldapregistr_name', 'Στο Όνομα επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+
+ $surname = $form['field_ldapregistr_surname'][und][0]['value']['
+ if(!grnet_registration_check_surname($surname)){
+ form_set_error('field_ldapregistr_surname', 'Στο Επώνυμο επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+ $amka = $form['field_ldapregistr_amka'][und][0]['value']['
+ if(!grnet_core_validateAMKA($amka)){
+ form_set_error('field_ldapregistr_amka', 'Εισάγεται ένα έγκυρο ΑΜΚΑ.');
+ }
+
+
+ $email = $form['field_ldapregistr_email'][und][0]['email']['
+ if(!grnet_core_isEmailValidDueToDomainSuffixedPolicy($email)){
+ form_set_error('field_ldapregistr_email', 'Το email σας πρέπει να έχει κατάληξη ίδια με το domain του νοσοκομείου. (@'.variable_get('grnet_domain_suffixed_emails').')');
+ }
+
+
+ $username = $form['field_ldapregistr_username'][und][0]['value']['
+ if(!grnet_registration_check_username($username)){
+ form_set_error('field_ldapregistr_pwd', 'Το όνομα χρήστη δεν πληρεί της πολιτικές ασφαλείας.');
+ }
+
+ $password = $form['field_ldapregistr_pwd'][und][0][password_field]['
+ $confirmation_password = $form['field_ldapregistr_confirmpwd'][und][0][password_field]['
+
+ if(!grnet_password_generator_check_password_strength($password,true)){
+ form_set_error('field_ldapregistr_pwd', 'Ο κωδικός πρόσβασης δεν πληρεί της πολιτικές ασφαλείας.');
+ }else{
+ if($password<>$confirmation_password){
+ form_set_error('field_ldapregistr_pwd', '');
+ form_set_error('field_ldapregistr_confirmpwd', 'Οι κωδικοί δεν είναι ίδιοι!!');
+ }
+ }
+ return false;
+}
+function _ldapregistration_validation_ldapuser($form, &$form_state) {
+ $name = $form['field_ldapregistr_name'][und][0]['value']['
+ if(!grnet_registration_check_name($name)){
+ form_set_error('field_ldapregistr_name', 'Στο Όνομα επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+ $surname = $form['field_ldapregistr_surname'][und][0]['value']['
+ if(!grnet_registration_check_surname($surname)){
+ form_set_error('field_ldapregistr_surname', 'Στο Επώνυμο επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+ $amka = $form['field_ldapregistr_amka'][und][0]['value']['
+ if(!grnet_core_validateAMKA($amka)){
+ form_set_error('field_ldapregistr_amka', 'Εισάγεται ένα έγκυρο ΑΜΚΑ.');
+ }
+ $email = $form['field_ldapregistr_email'][und][0]['email']['
+ if(!grnet_core_isEmailValidDueToDomainSuffixedPolicy($email)){
+ form_set_error('field_ldapregistr_email', 'Το email σας πρέπει να έχει κατάληξη ίδια με το domain του νοσοκομείου. (@'.variable_get('grnet_domain_suffixed_emails').')');
+ }
+ return false;
+}
+function _ldapregistration_validation_manager($form, &$form_state) {
+ if( grnet_core_user_has_role('manager') &&
+ ($form["field_ldapregistr_status"]['und']['
+ $form["field_ldapregistr_status"]['und']['
+ $form["field_ldapregistr_status"]['und']['
+ $form["field_ldapregistr_status"]['und']['
+ )
+ ){
+
+ form_set_error('field_ldapregistr_status', 'Η κατάσταση της αίτησης τροποποιήθηκε ή δεν επιτρέπεται η αποθήκευση από αυτή την κατάσταση!! Πατήστε εδώ για επιστροφή στα αιτήματα μεταβολής.');
+ }
+
+ $name = $form['field_ldapregistr_name'][und][0]['value']['
+ if(!grnet_registration_check_name($name)){
+ form_set_error('field_ldapregistr_name', 'Στο Όνομα επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+
+ $surname = $form['field_ldapregistr_surname'][und][0]['value']['
+ if(!grnet_registration_check_surname($surname)){
+ form_set_error('field_ldapregistr_surname', 'Στο Επώνυμο επιτρέπονται μόνο αλφαβητικοί χαρακτήρες από 1 έως 50 χαρακτήρες!!');
+ }
+
+
+ $amka = $form['field_ldapregistr_amka'][und][0]['value']['
+ if(!grnet_core_validateAMKA($amka)){
+ form_set_error('field_ldapregistr_amka', 'Εισάγεται ένα έγκυρο ΑΜΚΑ.');
+ }
+
+
+ $email = $form['field_ldapregistr_email'][und][0]['email']['
+
+ if(!grnet_core_isEmailValidDueToDomainSuffixedPolicy($email)){
+ form_set_error('field_ldapregistr_email', 'Το email σας πρέπει να έχει κατάληξη ίδια με το domain του νοσοκομείου. (@'.variable_get('grnet_domain_suffixed_emails').')');
+ }
+
+ return false;
+}
+function grnet_registration_cron(){
+
+ /*
+
+ WATCHDOG_EMERGENCY: Emergency, system is unusable.
+ WATCHDOG_ALERT: Alert, action must be taken immediately.
+ WATCHDOG_CRITICAL: Critical conditions.
+ WATCHDOG_ERROR: Error conditions.
+ WATCHDOG_WARNING: Warning conditions.
+ WATCHDOG_NOTICE: (default) Normal but significant conditions.
+ WATCHDOG_INFO: Informational messages.
+ WATCHDOG_DEBUG: Debug-level messages.
+ */
+
+
+
+
+
+ $period_in_seconds = variable_get('grnet_mail_verification_duration_in_minutes')*60;
+ $timestamp_barrier = time()-$period_in_seconds;
+
+
+
+ $result = db_query("SELECT entfrm.entityform_id as ent_id
+ FROM {entityform} AS entfrm
+ JOIN {field_data_field_ldapregistr_status} as entfrm_st
+ ON (entfrm.entityform_id = entfrm_st.entity_id)
+ WHERE
+ entfrm_st.field_ldapregistr_status_value = 'prepending' AND
+ entfrm.created < :timestamp_barrier",array(':timestamp_barrier' => $timestamp_barrier));
+
+
+
+ foreach ($result as $rec) {
+
+ $entity_instance = entity_load('entityform', array($rec->ent_id));
+ $entity_instance = $entity_instance[$rec->ent_id];
+
+ $ent_id = $rec->ent_id;
+ $ent_name = $entity_instance->field_ldapregistr_name['und'][0]['value'];
+ $ent_surname = $entity_instance->field_ldapregistr_surname['und'][0]['value'];
+ $ent_email = $entity_instance->field_ldapregistr_email['und'][0]['email'];
+ $ent_amka = $entity_instance->field_ldapregistr_amka['und'][0]['value'];
+
+
+
+ watchdog('grnet registration prepending', 'Submission Cron Deleted
+ id : '.$ent_id.'
+ Όνομα : '.$ent_name.'
+ Επώνυμο : '.$ent_surname.'
+ Email : '.$ent_email.'
+ ΑΜΚΑ : '.$ent_amka, NULL , WATCHDOG_WARNING);
+
+ entity_delete('entityform', $ent_id);
+
+ }
+
+
+
+
+
+
+
+ $period_in_seconds = variable_get('grnet_complete_submission_duration_in_days')*86400;
+ $timestamp_barrier = time()-$period_in_seconds;
+
+
+
+ $result = db_query("SELECT entfrm.entityform_id as ent_id
+ FROM {entityform} AS entfrm
+ JOIN {field_data_field_ldapregistr_status} as entfrm_st
+ ON (entfrm.entityform_id = entfrm_st.entity_id)
+ WHERE
+ entfrm_st.field_ldapregistr_status_value = 'pending' AND
+ entfrm.created < :timestamp_barrier",array(':timestamp_barrier' => $timestamp_barrier));
+
+
+
+ foreach ($result as $rec) {
+
+ $entity_instance = entity_load('entityform', array($rec->ent_id));
+ $entity_instance = $entity_instance[$rec->ent_id];
+
+ $ent_id = $rec->ent_id;
+ $ent_name = $entity_instance->field_ldapregistr_name['und'][0]['value'];
+ $ent_surname = $entity_instance->field_ldapregistr_surname['und'][0]['value'];
+ $ent_email = $entity_instance->field_ldapregistr_email['und'][0]['email'];
+ $ent_amka = $entity_instance->field_ldapregistr_amka['und'][0]['value'];
+
+
+
+ watchdog('grnet registration pending', 'Submission Cron Deleted
+ id : '.$ent_id.'
+ Όνομα : '.$ent_name.'
+ Επώνυμο : '.$ent_surname.'
+ Email : '.$ent_email.'
+ ΑΜΚΑ : '.$ent_amka, NULL , WATCHDOG_WARNING);
+
+ entity_delete('entityform', $ent_id);
+
+ }
+
+
+
+
+}
diff --git a/grnet_registration/includes/html/NewFile.html b/grnet_registration/includes/html/NewFile.html
new file mode 100644
index 0000000..505ec37
--- /dev/null
+++ b/grnet_registration/includes/html/NewFile.html
@@ -0,0 +1,9 @@
+
+
+
+
+Insert title here
+
+
+
+
\ No newline at end of file
diff --git a/grnet_registration/includes/html/field_ldapregistr_confirmpwd/prefix_html.php b/grnet_registration/includes/html/field_ldapregistr_confirmpwd/prefix_html.php
new file mode 100644
index 0000000..30cdfb8
--- /dev/null
+++ b/grnet_registration/includes/html/field_ldapregistr_confirmpwd/prefix_html.php
@@ -0,0 +1,4 @@
+
+ ';
\ No newline at end of file
diff --git a/grnet_registration/includes/html/field_ldapregistr_confirmpwd/suffix_html.php b/grnet_registration/includes/html/field_ldapregistr_confirmpwd/suffix_html.php
new file mode 100644
index 0000000..fd1781b
--- /dev/null
+++ b/grnet_registration/includes/html/field_ldapregistr_confirmpwd/suffix_html.php
@@ -0,0 +1,5 @@
+
+
+ ';
\ No newline at end of file
diff --git a/grnet_registration/includes/html/field_ldapregistr_pwd/prefix_html.php b/grnet_registration/includes/html/field_ldapregistr_pwd/prefix_html.php
new file mode 100644
index 0000000..2eb27bb
--- /dev/null
+++ b/grnet_registration/includes/html/field_ldapregistr_pwd/prefix_html.php
@@ -0,0 +1,3 @@
+';
+?>
\ No newline at end of file
diff --git a/grnet_registration/includes/html/field_ldapregistr_pwd/suffix_html.php b/grnet_registration/includes/html/field_ldapregistr_pwd/suffix_html.php
new file mode 100644
index 0000000..37dfc90
--- /dev/null
+++ b/grnet_registration/includes/html/field_ldapregistr_pwd/suffix_html.php
@@ -0,0 +1,21 @@
+
+
';
+foreach($outputmessages as $key => $value){
+ $field_ldapregistr_pwd_suffix_html .= ''.$value.' ';
+}
+$field_ldapregistr_pwd_suffix_html .='
+
+
+
+ ';
\ No newline at end of file
diff --git a/grnet_registration/includes/html/field_ldapregistr_username/prefix_html.php b/grnet_registration/includes/html/field_ldapregistr_username/prefix_html.php
new file mode 100644
index 0000000..82ce1f1
--- /dev/null
+++ b/grnet_registration/includes/html/field_ldapregistr_username/prefix_html.php
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/grnet_registration/includes/html/field_ldapregistr_username/suffix_html.php b/grnet_registration/includes/html/field_ldapregistr_username/suffix_html.php
new file mode 100644
index 0000000..d1ca141
--- /dev/null
+++ b/grnet_registration/includes/html/field_ldapregistr_username/suffix_html.php
@@ -0,0 +1,9 @@
+
+ Πρέπει να περιέχει γράμματα και αριθμούς
+ εκτός από σημεία στίξης και ειδικούς χαρακτήρες (*,&,-,/@,
+ κλπ)
+
+';
+?>
\ No newline at end of file
diff --git a/grnet_registration/includes/html/wrapper/prefix_html.php b/grnet_registration/includes/html/wrapper/prefix_html.php
new file mode 100644
index 0000000..80f4b93
--- /dev/null
+++ b/grnet_registration/includes/html/wrapper/prefix_html.php
@@ -0,0 +1,64 @@
+
+
+
+
+
+ Προτεινόμενα passwords:
+
+
+
';
+$counter=0;
+foreach($passes as $pass){
+ if($counter%2==0){
+ $fopass = $pass;
+ }
+
+ if($counter%2==1){
+ $wrapper_prefix_html .= '
+
';
+ }
+ $counter++;
+}
+$wrapper_prefix_html .= '
+
+
+
+
Επιλέξτε με click
+
+
+
+
+
+
+
+
+
+
+
+ ';
diff --git a/grnet_registration/includes/html/wrapper/suffix_html.php b/grnet_registration/includes/html/wrapper/suffix_html.php
new file mode 100644
index 0000000..aa369ee
--- /dev/null
+++ b/grnet_registration/includes/html/wrapper/suffix_html.php
@@ -0,0 +1,5 @@
+
+
+';
\ No newline at end of file
diff --git a/grnet_registration/includes/policy/name.inc b/grnet_registration/includes/policy/name.inc
new file mode 100644
index 0000000..8405612
--- /dev/null
+++ b/grnet_registration/includes/policy/name.inc
@@ -0,0 +1,8 @@
+
diff --git a/grnet_registration/includes/policy/surname.inc b/grnet_registration/includes/policy/surname.inc
new file mode 100644
index 0000000..04f010d
--- /dev/null
+++ b/grnet_registration/includes/policy/surname.inc
@@ -0,0 +1,8 @@
+
diff --git a/grnet_registration/includes/policy/username.inc b/grnet_registration/includes/policy/username.inc
new file mode 100644
index 0000000..81d216b
--- /dev/null
+++ b/grnet_registration/includes/policy/username.inc
@@ -0,0 +1,13 @@
+
diff --git a/grnet_registration/js/main.js b/grnet_registration/js/main.js
new file mode 100755
index 0000000..0f4a9ea
--- /dev/null
+++ b/grnet_registration/js/main.js
@@ -0,0 +1,545 @@
+//var scontinue = false;
+var usernameValid = false;
+var passwordValid = false;
+var passwordSame = false;
+var afmerror = false;
+var emailValid = false;
+var amkaValid = false;
+
+//var validpin=true;
+
+
+
+
+(function ($) {
+
+
+
+ // FUNCTIONS (Starts)
+
+
+ // Username Check Function (Starts)
+ window.check_username = function check_username(){
+
+ username = $("#edit-field-ldapregistr-username-und-0-value").val();
+ //scontinue = false;
+
+ if(username == ''){
+ $("#usererror").html('Παρακαλώ συμπληρώστε το πεδίο');
+ $("#usererror").addClass('not_valid');
+ usernameValid = false;
+ $("#edit-field-ldapregistr-username-und-0-value").addClass('error');
+ //scontinue = false;
+ //returncode = 0;
+ }else{
+
+ $.ajax({
+ url:'registration/check_username/'+username,
+ success:function(data) {
+ if($.trim(data) != '0') {
+ $("#edit-field-ldapregistr-username-und-0-value").val('');
+ $("#usererror").html(data);
+ $("#usererror").addClass('not_valid');
+ usernameValid = false;
+ //scontinue = false;
+ //returncode = 0;
+ } else {
+ reset_usererrors();
+ usernameValid = true;
+ //scontinue = true;
+ //returncode = 1;
+ }
+
+ },
+ error:function(){
+ //alert('username ajax error');
+ $("#usererror").html('Δεν μπόρεσε να γίνει επιβεβαίωση εγκυρότητας ονόματος');
+ $("#usererror").addClass('not_valid');
+ usernameValid = false;
+ scontinue = false;
+ //returncode = 0;
+ }
+ });
+
+
+ }
+
+ return usernameValid;
+
+ }
+ // Username Check Function (Ends)
+
+
+
+ // Password Check Function (Starts)
+ window.check_password = function check_password(){
+
+ //$('#edit-field-ldapregistr-confirmpwd-und-0-password-field').trigger('focusout');
+ var pass = $("#edit-field-ldapregistr-pwd-und-0-password-field").val();
+ var confpass = $("#edit-field-ldapregistr-confirmpwd-und-0-password-field").val();
+ var username = $("#edit-field-ldapregistr-username-und-0-value").val();
+
+
+
+ if(pass==''){
+ $("#passerror").html('Παρακαλώ συμπληρώστε το πεδίο');
+ $("#passerror").addClass('not_valid');
+ passwordValid = false;
+ return false;
+ }
+
+
+ //now that the username is valid and the password is not empty, request for password strength
+ //var dataString = $('ldapregistration-entityform-edit-form').serialize();
+ var dataString = 'username='+$("#edit-field-ldapregistr-username-und-0-value").val()+'&pwd='+$("#edit-field-ldapregistr-pwd-und-0-password-field").val();
+
+ $.ajax({
+ type:'POST',
+ data:dataString,
+ url:'grnet/password_generator/check_strength',
+ success:function(data) {
+ if($.trim(data) != '0') {
+ $.each($.parseJSON($.trim(data)), function(idx, obj) {
+ $("#"+obj.tname).addClass(obj.tstatus);
+ });
+ passwordValid = false;
+ //scontinue = false;
+ //return false;
+ } else {
+ reset_passerrors();
+ set_password_valid();
+ passwordValid = true;
+
+ check_password_confirm();
+
+ //scontinue = true;
+ //return true;
+ }
+
+ },
+ error:function(){
+ //alert('pwd ajax error');
+ $("#passerror").html('Δεν μπόρεσε να γίνει επιβεβαίωση εγκυρότητας');
+ $("#passerror").addClass('not_valid');
+ passwordValid = false;
+ //scontinue = false;
+ //return false;
+ }
+ });
+
+
+ return passwordValid;
+
+ }
+ // Password Check Function (Ends)
+
+
+ // Password Confirmation Check Function (Starts)
+ window.check_password_confirm = function check_password_confirm(){
+ //$('#edit-field-ldapregistr-confirmpwd-und-0-password-field').trigger('focusout');
+ var pass = $("#edit-field-ldapregistr-pwd-und-0-password-field").val();
+ var confpass = $("#edit-field-ldapregistr-confirmpwd-und-0-password-field").val();
+
+ if(pass!=confpass){
+ passwordSame = false;
+ //scontinue = false;
+ $("#confirmerror").html('Οι κωδικοί δεν είναι ίδιοι');
+ $("#confirmerror").addClass('not_valid');
+ //return false;
+ }else{
+ passwordSame = true;
+ $("#confirmerror").html('');
+ //$("#confirmerror").addClass('not_valid');
+ }
+
+ return passwordSame;
+
+ }
+ // Confirmation Password Check Function (Ends)
+
+
+ // Other Helpfull Functions (Starts)
+ function reset_usererrors(){
+ $("#usererror").html('');
+ $("#usererror").removeClass('not_valid');
+ $("#edit-field-ldapregistr-username-und-0-value").removeClass('error');
+ }
+
+
+
+ function set_password_valid(){
+ $("#consecutivenumbersTest").addClass('valid');
+ $("#similarityTest").addClass('valid');
+ $("#regexpTest").addClass('valid');
+ $("#lengthTest").addClass('valid');
+ $("#uniqueTest").addClass('valid');
+ passwordValid = true;
+ //scontinue = true;
+ }
+
+
+
+ function reset_passerrors(){
+ $("#passerror").html('');
+ $("#passerror").removeClass('not_valid');
+ $("#confirmerror").html('');
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").removeClass('error');
+
+ }
+ // Other Helpfull Functions (Ends)
+
+
+ // FUNCTIONS (Ends)
+
+
+ $(document).ready(function() {
+
+
+
+
+
+
+
+$("#bubblepass").hide();
+
+function strength_checks_ok(){
+
+ var theresult = true;
+
+ if($("#consecutivenumbersTest").hasClass('not_valid')){
+ theresult = false;
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").addClass('error');
+ }
+
+ if($("#similarityTest").hasClass('not_valid')){
+ theresult = false;
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").addClass('error');
+ }
+
+ if($("#regexpTest").hasClass('not_valid')){
+ theresult = false;
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").addClass('error');
+ }
+
+ if($("#lengthTest").hasClass('not_valid')){
+ theresult = false;
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").addClass('error');
+ }
+
+ if($("#uniqueTest").hasClass('not_valid')){
+ theresult = false;
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").addClass('error');
+ }
+ return theresult;
+}
+
+
+function reset_strengtherrors(){
+ $("#consecutivenumbersTest").removeClass('not_valid');
+ $("#similarityTest").removeClass('not_valid');
+ $("#regexpTest").removeClass('not_valid');
+ $("#lengthTest").removeClass('not_valid');
+ $("#uniqueTest").removeClass('not_valid');
+ $("#consecutivenumbersTest").removeClass('valid');
+ $("#similarityTest").removeClass('valid');
+ $("#regexpTest").removeClass('valid');
+ $("#lengthTest").removeClass('valid');
+ $("#uniqueTest").removeClass('valid');
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").removeClass('error');
+
+}
+
+
+
+//highlight selected password and insert into form
+$('div[id^="sugg_pass_"]').click(function() {
+ $('div[id^="sugg_pass_"]').removeClass('highlighted_password');
+ $(this).addClass('highlighted_password');
+ thenewpass = $(this).text().trim();
+ reset_strengtherrors();
+ reset_passerrors();
+ $("#edit-field-ldapregistr-pwd-und-0-password-field").val(thenewpass);
+ $("#edit-field-ldapregistr-confirmpwd-und-0-password-field").val(thenewpass);
+ set_password_valid();
+});
+
+
+$('#afm').click(function(){
+ $("#afmError").hide();
+ afmerror = false;
+});
+
+
+
+//clear usererrors
+$('#edit-field-ldapregistr-username-und-0-value').click(function(){
+ reset_usererrors();
+ $("#bubblepass").hide();
+});
+
+//clear password errors
+$('#edit-field-ldapregistr-pwd-und-0-password-field').click(function(){
+ reset_passerrors();
+ reset_strengtherrors();
+ $("#bubble_div").show();
+ $("#bubblepass").show();
+
+});
+
+$('#edit-field-ldapregistr-confirmpwd-und-0-password-field').click(function(){
+ if(strength_checks_ok())
+ $("#bubblepass").hide();
+});
+
+
+
+
+
+$("#afm").keyup(function(e) {
+ afm = $("#afm").val();
+ if( afm.length > 8 && checkAFM(afm)==false){
+ afmerror = true;
+ $("#afmError").css('display', 'inline-block');
+ }else {
+ afmerror = false;
+ $("#afmError").css('display', 'none');
+ }
+
+});
+
+$("#afm").focusout(function(e) {
+ afm = $("#afm").val();
+ if(!checkAFM(afm)){
+ afmerror = true;
+ $("#afmError").css('display', 'inline-block');
+ }
+});
+
+
+
+//ajax call to check username
+$("#edit-field-ldapregistr-username-und-0-value").focusout(function(e) {
+ check_username();
+});
+
+
+
+
+
+
+//ajax call to check password strength
+$("#edit-field-ldapregistr-pwd-und-0-password-field").focusout(function(e) {
+ check_password();
+});
+
+
+
+
+$("#edit-field-ldapregistr-confirmpwd-und-0-password-field").focusout(function(e) {
+ check_password_confirm();
+});
+
+
+
+
+
+
+ $('#subbutton').click(function(e) {
+
+ //maybe username is prefilled please check and se usernameValid = true
+ var username_readonly = $('#edit-field-ldapregistr-username-und-0-value').prop('readonly');
+ var uid = $('#edit-field-ldapregistr-username-und-0-value').val();
+ if(username_readonly && uid!='')
+ usernameValid = true;
+
+ $('#edit-field-ldapregistr-confirmpwd-und-0-password-field').trigger('focusout');
+
+ if($('#doyouagree').prop('checked')) {
+ $("#agreeerror").hide();
+ if(usernameValid==true && passwordValid==true && passwordSame==true){
+
+ var r=confirm("Οι λογαριασμοί είναι αυστηρά προσωπικοί και οι κωδικοί πρέπει να φυλάσσονται με ασφάλεια");
+ if (r==true){
+ $("#passer").submit();
+ }else{
+ return false;
+ }
+
+ }
+ } else {
+ $("#agreeerror").show();
+ return false;
+ }
+
+
+ });
+
+
+$('#doyouagree').change(function(){
+ if ($('#doyouagree').prop('checked'))
+ $("#agreeerror").hide();
+ else
+ $("#agreeerror").show();
+
+});
+
+
+
+$('#bothempty').hide();
+
+//remove error message on click in one of two inputs
+ $('#email').click(function(e) {
+ $('#bothempty').hide();
+ });
+
+ $('#mobile').click(function(e) {
+ $('#bothempty').hide();
+ });
+
+
+//check one of two fields mandatory
+ $("#masterform").submit(function(e) {
+
+ var themail = $("#email").val();
+ var themobile = $("#mobile").val();
+
+ if(themail=='' && themobile==''){
+ $('#bothempty').show();
+ e.preventDefault();
+ } else
+ $('#bothempty').hide();
+
+ if(afmerror==true) {
+ e.preventDefault();
+ }
+ });
+
+
+ $('#thepin').click(function(e) {
+ $("#thenote").css('color','#85898F');
+ $('#pinsuccess').hide();
+ $('#pinerror').hide();
+ });
+
+
+ $('#thepin').keydown(function(e) {
+ if (e.keyCode == 13) {
+ $('#valbbutton').trigger('click');
+ // alert('not like this');
+ return false;
+ }
+ });
+
+
+ $('#valbbutton').click(function(e) {
+
+ $('#pinsuccess').hide();
+ $('#pinerror').hide();
+ $("#thenote").css('color','#85898F');
+ $("#pinmessage").html('');
+ $("#pin-result").html('');
+
+ //here check with ajax
+ var pin = $("#thepin").val();
+ var afm = $("#afm").val();
+ var amka = $("#amka").val();
+
+ if(pin==''){
+ $("#thenote").css('color','red');
+ //validpin = false;
+ return false;
+ } else {
+ var dataString = $('#pinform').serialize()+'&afm='+afm+'&amka='+amka;
+ $.ajax({
+ type:'POST',
+ data:dataString,
+ url:'includes/check_pin.php',
+ success:function(data) {
+ if(data != '0') {
+ $('#pinerrormessage').html('Ο κωδικός PIN που εισαγάγατε είναι λανθασμένος ή έχει λήξει. Παρακαλούμε προσπαθήστε να τον εισάγετε ξανά ή επιλέξτε
"Αποστολή νέου κωδικού" για να σας αποσταλεί νέος.');
+ $('#pinerror').show();
+ //validpin = false;
+ return false;
+ } else {
+ $("#pinmessage").html('');
+ $("#pin-result").html('');
+ $('#pinerror').hide();
+ //validpin = true;
+ $("#pinform").submit();
+ return true;
+ }
+
+ },
+ error:function(){
+ $("#pinmessage").html('Δεν μπόρεσε να γίνει επιβεβαίωση εγκυρότητας');
+ $("#pin-result").html('
');
+ //validpin = false;
+ return false;
+ }
+ });
+
+ }
+
+ });
+
+
+
+
+
+
+
+
+
+$('#resend_pin').click(function(e) {
+ $('#pinerror').hide();
+ $('#pinsuccess').hide();
+
+ $.ajax({
+ type:'POST',
+ //data:dataString,
+ url:'includes/resend_pin.php',
+ success:function(data) {
+ if(data != '0') {
+ //$('#example-hide').trigger('click');
+ $('#pinerrormessage').text('Δεν μπόρεσε να αποσταλεί νέο PIN, λόγω χρονικού περιορισμού. Παρακαλώ δοκιμάστε αργότερα');
+ $('#pinerror').show();
+
+ } else {
+ $('#example-hide').trigger('click');
+ $('#pinsuccessmessage').text('Σας έχει αποσταλεί νέο PIN');
+ $('#pinerror').hide();
+ $('#pinsuccess').show();
+ }
+
+ },
+ error:function(){
+ $('#pinerrormessage').text('Πρόβλημα στην αποστολή PIN.');
+ $('#pinerror').show();
+ }
+ });
+
+});
+
+
+
+function checkAFM(afm) {
+ if (!afm.match(/^\d{9}$/) || afm == '000000000')
+ return false;
+
+ var m = 1, sum = 0;
+ for (var i = 7; i >= 0; i--) {
+ m *= 2;
+ sum += afm.charAt(i) * m;
+ }
+
+ return sum % 11 % 10 == afm.charAt(8);
+}
+
+
+
+
+
+ });
+
+})(jQuery);
+