User ID | Username | Teacher name | Schools Name | Postcode | Country | School type | Age/Subject | No. students | Registered | Last Access | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
".$u->uid." | \n"; print "".$u->name." | \n"; print "".$u->mail." | \n"; print "".$tchnm[$u->uid]->field_name_value." | \n"; print "".$schnm[$u->uid]->field_school_name_value." | \n"; print "".$schpc[$u->uid]->field_school_postcode_value." | \n"; // Add a new line to the CSV variable $_l = '"'.$u->uid.'","'.str_replace(['"',"'"],'', $u->name).'","'.str_replace(['"',"'"],'', $u->mail).'","'.str_replace(['"',"'"],'', $tchnm[$u->uid]->field_name_value).'","'.str_replace(['"',"'"],'', $schnm[$u->uid]->field_school_name_value).'","'.str_replace(['"',"'"],'', $schpc[$u->uid]->field_school_postcode_value).'","'; if(array_key_exists($u->uid, $ukeire)) { print "".$ukeire[$u->uid]->field_country_value." | \n"; $_l = $_l . str_replace(['"',"'"],'', $ukeire[$u->uid]->field_country_value).'","'; } else if(array_key_exists($u->uid, $othcry)) { print "".$othcry[$u->uid]->field_other_country_iso2." | \n"; $_l = $_l . str_replace(['"',"'"],'',$othcry[$u->uid]->field_other_country_iso2 ).'","'; } else { print "\n"; $_l = $_l . '","'; } print " | ".$schtyp[$u->uid]->field_school_type_value." | \n"; $_l = $_l . str_replace(['"',"'"],'', $schtyp[$u->uid]->field_school_type_value).'","'; // Loop over all the age/subject ones as there can be multiple ones print ""; $n = 0; foreach ($agesub as $as) { if($as->uid == $u->uid) { if($n != 0) { print ", "; $_l = $_l . ','; } print $as->field_age_subject_value; $_l = $_l . str_replace(['"',"'"],'', $as->field_age_subject_value); $n += 1; } } $_l = $_l . '","'; print " | \n"; // Count the number of students for this user. $q = "SELECT COUNT(entity_id) FROM {field_data_field_manager} WHERE field_manager_value='".$u->uid."'"; $nstud = db_query($q)->fetchField(); print "".$nstud." | \n"; $_l = $_l . $nstud . '","'; // Created date $dt = new DateTime(); $dt = DateTime::createFromFormat('U', $u->created); $dtst = $dt->format('Y-m-d H:i:s'); print "".$dtst." | \n"; $_l = $_l . $dtst . '","'; // Last access greatest of login or access $n = max($u->access, $u->login); $dt = DateTime::createFromFormat('U', $n); $dtst = $dt->format('Y-m-d H:i:s'); print "".$dtst." | \n"; $_l = $_l . $dtst . '"'; print "