roles) || in_array('Faculty',$user->roles) ) { $ret = FALSE; } } return($ret); } /************************************************************ uploads2links ------------- Returns an array of links of the uploaded files ************************************************************/ function uploads2links($up) { $links = array(); if(isset($up) ) { foreach($up as $upload) { $url = file_create_url($upload['uri']); $href = "" . $upload['filename'] . ""; array_push($links,"
" . $href . "
\n"); } } return($links); } /************************************************************ uploaded_hp_files ----------------- ************************************************************/ function uploaded_hp_files($up) { $html = ''; if(count($up) > 0) { $html = '
Project Files
'; foreach($up as $upload) { $url = file_create_url($upload['uri']); $href = "" . $upload['filename'] . ""; $html .= "
" . $href . "
\n"; } } return($html); } /************************************************************ scs_form_user_profile_form_alter -------------------------------- ************************************************************/ function scs_form_user_profile_form_alter(&$form, &$form_state, $form_id) { global $user; //hide($form['account']['current_pass']); if(in_array('Honours Project', $user->roles)) { // Disable change of password in user profile $form['account']['pass']['#disabled'] = TRUE; // Hide the change password field hide($form['account']['pass']); //hide($form['account']); } } /************************************************************ scs_preprocess_views_view ------------------------- ************************************************************/ function scs_preprocess_views_view(&$vars) { //comment("preprocess_views_view"); //print_r($vars); //comment("GET"); //print_r($_GET); } /************************************************************ link_module_output ------------------ ************************************************************/ function link_module_output($link) { $out = ''; $alt = 'SCS'; if(isset($link[0]['url']) ) { $url = $link[0]['url']; if(isset($link[0]['title'])) { $title = $link[0]['title']; } else { $title = $url; } $out = "$title"; } return($out); } /************************************************************ array_link2ul -------------- ************************************************************/ function array_link2ul($a) { $html = ''; if(! empty($a)) { $html = ""; } return($html); } /************************************************************ build_link ---------- ************************************************************/ function build_link($val) { $url = ''; if(isset($val['title'])) { $title = $val['title']; if(isset($val['url'])) { $url = "$title"; } else { $url = $title; } } return($url); } /************************************************************ array_value2ul -------------- ************************************************************/ function array_value2ul($a) { $html = ''; if(! empty($a)) { $html = ""; } return($html); } /************************************************************ Hook for the styling the login window ************************************************************/ function scs_theme() { $items = array(); $items['user_login'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'scs') . '/templates', 'template' => 'user-login', 'preprocess functions' => array( 'scs_preprocess_user_login' ), ); $items['user_register'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'scs') . '/templates', 'template' => 'user-register', 'preprocess functions' => array( 'scs_preprocess_user_register' ), ); $items['user_pass'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'scs') . '/templates', 'template' => 'user-pass', 'preprocess functions' => array( 'scs_preprocess_user_pass' ), ); /* $items['honours_project_node_form'] = array( 'arguments' => array('form' => NULL), 'template' => 'honours_project-node-form', 'render element' => 'form', ); */ return $items; } /************************************************************/ function scs_preprocess_user_login(&$vars) { $vars['intro_text'] = t('This is my awesome login form'); $vars['title'] = 'SCS Drupal Login'; $vars['form']['name']['#size'] = 30; $vars['form']['pass']['#size'] = 30; } function scs_preprocess_user_register(&$vars) { $vars['intro_text'] = t('This is my super awesome reg form'); } function scs_preprocess_user_pass(&$vars) { $vars['intro_text'] = t('This is my super awesome reg form'); } /********************************************************************** scs_form_alter -------------- **********************************************************************/ function scs_form_alter(&$form, &$form_state, $form_id) { //$form['field_co_supervisor'][0]['#validate']['scs_form_validate'] = array(); //$form['submit']['#validate'][] = 'scs_form_validate'; //dsm("Hello again ABC"); if ($form_id == 'user_register') { drupal_set_title(t('Create new account')); } elseif ($form_id == 'user_pass') { drupal_set_title(t('Request new password')); } elseif ($form_id == 'user_login') { drupal_set_title(t('Welcome to the SCS Drupal Log in')); } elseif ($form_id == 'honours_project') { $form['#validate'][]='scs_form_validate'; } else if(strcmp($form_id,'views_exposed_form') == 0) { // Set the default value for the course outline exposed filter if( empty($_GET['field_course_term_value'])) { scs_course_year_term($year,$term); $form_state['input']['field_course_term_value'] = $term; } if(empty($_GET["field_course_year_value"])) { if(! isset($year)) { scs_course_year_term($year,$term); } $form_state['input']['field_course_year_value'] = $year; } // Used by honours projects if( empty($_GET['field_term_value']) ) { scs_previous_year_term($year,$term); $form_state['input']['field_term_value'] = $term; } if( empty($_GET['field_year_value']) ) { scs_previous_year_term($year,$term); $form_state['input']['field_year_value'] = $year; } } else { } } /********************************************************************** course_number ------------- Build course number **********************************************************************/ function course_number($row) { $course_number = extract_course_number($row); if( (! empty($course_number)) && isset($row->nid) ) { $url = '/node/' . $row->nid; $course_number = "$course_number\n"; } return($course_number); } /********************************************************************** extract_course_number ------------- Build course number **********************************************************************/ function extract_course_number($row) { $course_number = ''; if(isset($row->field_field_course_number[0])) { $number = $row->field_field_course_number[0]['raw']['value']; $institution = 'COMP'; $section = ''; $alt_number = ''; if( isset($row->_field_data['nid']['entity']) ) { $entity = $row->_field_data['nid']['entity']; if(isset($entity->field_institution['und'][0]['value']) ) { $institution = $entity->field_institution['und'][0]['value']; } if(isset($entity->field_course_section['und'][0]['value']) && is_string($entity->field_course_section['und'][0]['value'])) { $section = $entity->field_course_section['und'][0]['value']; } if(isset($entity->field_alternate_course_number['und'][0]['safe_value']) ) { $alt_number = $entity->field_alternate_course_number['und'][0]['safe_value']; } } // Build course number $course_number = $institution . ' ' . $number . $section; if(! empty($alt_number)) { $course_number .= '
' . $alt_number; } } return($course_number); } /************************************************************ alt_course_number ----------------- ************************************************************/ function alt_course_number($alt) { $ret = ''; if( preg_match("/^[A-Za-z]{3,4}/",$alt)) { if(preg_match("/^[A-Za-z]{3,4}/",$alt,$match)) { $ret = strtoupper($match[0]); } if(preg_match("/\d{3,4}$/",$alt,$match)) { $ret .= ' ' . $match[0]; } } return($ret); } /************************************************************ show_field_value_array ---------------------- ************************************************************/ function show_field_value_array($field) { $html = ''; foreach($field as $val) { if( isset($val['value']) ) { if(! empty($html)) { $html .= '
'; } $html .= $val['value']; } } return($html); } /************************************************************ office_hour ------------ ************************************************************/ function office_hour($hrs) { $day = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); $html = ''; if(isset($hrs['day'])) { $index = $hrs['day']; $html .= $day[$index]; } if(isset($hrs['starthours'])) { $html .= ' ' . int2hrs($hrs['starthours']); } if(isset($hrs['endhours'])) { $html .= ' until ' . int2hrs($hrs['endhours']); } return($html); } /************************************************************ int2hrs ------- ************************************************************/ function int2hrs($num) { $hrs = floor($num/100); $min = $num - $hrs * 100; if($min < 10) { $min = '0' . $min; } return($hrs . ':' . $min); } /************************************************************ office_hours_html ----------------- ************************************************************/ function office_hours_html($oh) { $html = ''; foreach($oh as $hrs) { if(!empty($html)) { $html .= '
'; } $html .= office_hour($hrs); } return($html); } /************************************************************ array_year_term --------------- ************************************************************/ function array_year_term() { $start = 2012; $end = date("Y") + 1; $ret = array(); $terms = array('Fall','Winter','Summer'); for($i=$start;$i<$end;$i++) { foreach($terms as $t) { array_push($ret,$t . ' ' . $i); } } return($ret); } /************************************************************ scs_course_year_term --------------------- Automatically determines the current year and term. Checks get parameters. ************************************************************/ function scs_course_year_term( &$year, &$term ) { if( isset($_GET['field_course_term_value']) && isset($_GET['field_course_year_value']) ) { $term = $_GET['field_course_term_value']; $year = $_GET['field_course_year_value']; } else { scs_current_year_term( $year, $term ); } } /************************************************************ scs_current_year_term --------------------- Automatically determines the current year and term. ************************************************************/ function scs_current_year_term( &$year, &$term ) { $time = time(); $ret = scs_year_term($year,$term,$time); return($ret); } /************************************************************ scs_hp_year_term --------------------- Automatically determines the Honours Project year and term. ************************************************************/ function scs_hp_year_term( &$year, &$term ) { $month = date("n"); $year = date("Y"); // To do list } /************************************************************ scs_previous_year_term --------------------- Automatically determines the previous year and term. ************************************************************/ function scs_previous_year_term( &$year, &$term ) { $time = time(); $ret = scs_year_term($year,$term,$time); if( strcasecmp($term,'Winter')==0) { $term = 'Fall'; $year--; } else if(strcasecmp($term,'Fall')==0) { $term = 'Summer'; } else { $term = 'Winter'; } return($ret); } /************************************************************ scs_current_year_term --------------------- Automatically determines the current year and term. ************************************************************/ function scs_year_term( &$year, &$term , $time) { $ret = 0; $day = date("d",$time); $month = date("M",$time); $year = date("Y",$time); if(( strcmp($month,"Jan") == 0 ) || ( strcmp($month,"Feb") == 0 ) || ( strcmp($month,"Mar") == 0 ) || ( strcmp($month,"Apr") == 0 )) { $term = "Winter"; } else if(( strcmp($month,"May") == 0 ) || ( strcmp($month,"Jun") == 0 ) || ( strcmp($month,"Jul") == 0 ) || ( (strcmp($month,"Aug") == 0) && ($day < 28) )) { $term = "Summer"; } else { $term = "Fall"; } return($ret); } /************************************************************ scs_select_box_default ---------------------- Generates a select box given names and values and you can specify the font size in pixels. The auto option allows you to choose the item without the use of a button. auto = 0 enables no-click feature 1 disables no-click feature default_list = 1 searches for default in values array otherwise searches for default in names array ************************************************************/ function scs_select_box_default($names,$values,$label,$default,$default_list,$auto,$font_size) { $count = count($names); $auto_select = ''; if($auto == 0) { $auto_select = " onchange=\"this.form.submit()\""; } // Set the default font size if(($font_size <= 4) || ($font_size > 64)) { $font_size = 10; } // Identify position of default value $d_index = 0; if((! empty($default)) && ($count > 1)) { if($default_list==1) { $temp = array_search($default,$values); } else { $temp = array_search($default,$names); } if($temp !== False) { $d_index = $temp; } } $html = "\n\n"; return($html); } /************************************************************ selectbox_float_auto ---------------------- Generic selection box with integers listed from start to end auto=0 => auto select drop down box (java script) otherwise => drop down box (html) inc => counter increment ************************************************************/ function selectbox_float_auto($name, $font_size, $selected, $default, $auto, $start, $end, $inc) { $auto_select = ''; if($auto == 0) { $auto_select = " onchange=\"this.form.submit()\""; } $html = "\n\n"; return($html); } /************************************************************ tr_authors ---------- Format authors ************************************************************/ function tr_authors($data) { $authors = ''; $size = count($data); if($size == 1) { $authors = $data[0]['value']; } else if($size <= 0) { } else if($size == 2) { $authors = $data[0]['value'] . " & " . $data[1]['value']; } else { foreach($data as $val) { if(empty($authors)) { $authors = $val['value']; } else { $authors .= ', ' . $val['value']; } } } return($authors); } /************************************************************ tr_author_display ----------------- ************************************************************/ function tr_author_display($data) { $authors = ''; $size = count($data); if($size == 1) { $authors = $data[0]['raw']['value']; } else if($size <= 0) { } else if($size == 2) { $authors = $data[0]['raw']['value'] . " & " . $data[1]['raw']['value']; } else { foreach($data as $val) { if(empty($authors)) { $authors = $val['raw']['value']; } else { $authors .= ', ' . $val['raw']['value']; } } } return($authors); } /************************************************************ scs_spam_proof_email ------------------- Spam proof the email address using an '@' png image. Date: Jul. 7, 2006 Updated: Jul. 18, 2012 Font pt sizes are: 6,8,10,12,14,16 ************************************************************/ function scs_spam_proof_email( $email , $size) { $eproof = "-"; $atsign = "/images/atsign/at10sign.png"; if( isset($size) ) { // Choose the at sign size if( $size == 6 ) { $atsign = "/images/atsign/at6sign.png"; } else if( $size == 8 ) { $atsign = "/images/atsign/at8sign.png"; } else if( $size == 10 ) { $atsign = "/images/atsign/at10sign.png"; } else if( $size == 12 ) { $atsign = "/images/atsign/at12sign.png"; } else if( $size == 14 ) { $atsign = "/images/atsign/at14sign.png"; } else if( $size == 16 ) { $atsign = "/images/atsign/at16sign.png"; } else { $atsign = "/images/atsign/at10sign.png"; } } $eproof = $email; // Insert the '@' png image if( strpos($email,'@') !== false ) { $parts = preg_split('/@/',$email); if( isset($parts[1]) ) { $eproof = $parts[0] . "\"atsign\"" . $parts[1]; } } return($eproof); } /************************************************************ people_name ----------- ************************************************************/ function people_name($firstname,$lastname,$title) { $name = ''; $name .= "\n"; $name .= "
\n"; $name .= "
$title
\n"; $name .= "
$firstname
\n"; $name .= "
$lastname
\n"; $name .= "
"; $name .= "
\n\n"; return($name); } /************************************************************ build_name ----------- ************************************************************/ function build_name($field_firstname,$field_lastname,$field_name_title) { $name = ''; if( isset($field_firstname[0]['value']) && (! empty($field_firstname) )) { $name = $field_firstname[0]['value']; } if( isset($field_lastname[0]['value']) && (! empty($field_lastname) )) { $name .= ' ' . $field_lastname[0]['value']; } if( isset($field_name_title[0]['value']) && (! empty($field_name_title) )) { $name = $field_name_title[0]['value'] . ' ' . $name; } return($name); } /************************************************************ field_value ----------- ************************************************************/ function field_value($field,&$value) { $ret = False; $value = ''; if( isset($field[0]) && isset($field[0]['value']) ) { $value = $field[0]['value']; $ret = True; } return($ret); } /************************************************************ format_phone_number ------------------- ************************************************************/ function format_phone_number($phone) { $num = 0; if( isset($phone[0]) ) { if( isset($phone[0]['number']) ) { $size = strlen($phone[0]['number']); if($size == 10) { $area_code = substr($phone[0]['number'],0,-7); $region = substr($phone[0]['number'],3,-4); $number = substr($phone[0]['number'],6); // Put the number back together $num = $area_code . '-' . $region . '-' . $number; } } if( empty($num) ) { $num = $phone[0]['number']; } if( isset($phone[0]['extension']) && (!empty($phone[0]['extension']))) { $num .= ' x' . $phone[0]['extension']; } } return($num); } /********************************************************************** oneline_value ------------- Format array using raw-value's on one line delimit **********************************************************************/ function oneline_value($a,$delim) { $ret = ''; foreach($a as $var) { if(isset($var['value']) ) { if(!empty($ret)) { $ret .= $delim . $var['value']; } else { $ret .= $var['value']; } } } return($ret); } /********************************************************************** oneline_raw ----------- Format array using raw-value's on one line delimit **********************************************************************/ function oneline_raw($a,$delim) { $ret = ''; foreach($a as $var) { if(isset($var['raw']['value']) ) { if(!empty($ret)) { $ret .= $delim . $var['raw']['value']; } else { $ret .= $var['raw']['value']; } } } return($ret); } /************************************************************ area_of_interest ---------------- ************************************************************/ function area_of_interest($a) { // Used by node templates $ret = oneline_value($a,' / '); // used by fields templates if(empty($ret)) { $ret = oneline_raw($a,' / '); } if( strcmp($ret,'N/A')==0) { $ret = ''; } return($ret); } /************************************************************ comment ------- ************************************************************/ function comment($msg) { if(is_string($msg)) { print("

$msg

\n"); } else { print("
\n");  
     print_r($msg);
     print("\n
\n\n"); } } /************************************************************ scs_breadcrumb -------------- Customize the breadcrump bar ************************************************************/ function scs_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; if (!empty($breadcrumb)) { // Adding the title of the current page to the breadcrumb. //$breadcrumb[] = drupal_get_title(); // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. Make the heading invisible with .element-invisible. $output = '

' . t('You are here') . '

'; $output .= ''; return $output; } } /************************************************************ set_current_breadcrumb ---------------------- ************************************************************/ function set_current_breadcrumb() { global $base_url; $breadcrumb[] = l('Home', null); $breadcrumb[] .= l(drupal_get_title(), $base_url.$_SERVER['REQUEST_URI']); drupal_set_breadcrumb($breadcrumb); } /************************************************************ not_expired ----------- ************************************************************/ function not_expired($date) { $ret = True; if(! empty($date)) { $time = strtotime($date); $now = time(); if(($time-$now) < 0) { $ret = False; } } return($ret); } /************************************************************ multi_instructor ---------------- ************************************************************/ function multi_instructor($instructor) { $ret = ''; foreach($instructor as $inst) { if( isset($inst['value']) ) { if(empty($ret)) { $ret = $inst['value']; } else { $ret .= ' & ' . $inst['value']; } } } return($ret); } /************************************************************/ Page not found 404 | www.scs.carleton.ca
School of
Computer Science

Page not found 404

Sorry, the page that you are looking for is not found on our server.

Try: http://scs.carleton.ca