示例#1
0
 /**
  * Get all accounts with the els_student role.
  */
 public static function getStudents()
 {
     $idm = PSU::get('idmobject');
     $search = array(array('pa.attribute' => 'els_student'), array('pa.type_id' => '2'));
     $return = 'i.pid,i.psu_id,i.username,i.first_name,i.last_name,l.start_date,l.end_date';
     $students = $idm->getUsersByAttribute($search, 'AND', $return);
     array_walk($students, array('ELS', 'dates2timestamp'));
     array_walk($students, array('ELS', 'load_psuperson'));
     usort($students, array('ELS', 'student_sort'));
     return $students;
 }
 function testShortcutsReflection()
 {
     PSU::get()->add_shortcut('shortcut_foo_r1', array('shortcut_foo', '__construct'));
     PSU::get()->add_shortcut('shortcut_foo_r2', array('shortcut_foo', 'shortcut_foo'));
     $a = PSU::get('shortcut_foo_r1/1Joe12');
     $b = PSU::get('shortcut_foo_r1/1Joe12');
     $c = PSU::get('shortcut_foo_r1/1Joe13');
     $this->assertSame($a, $b);
     $this->assertNotSame($a, $c);
     $a = PSU::get('shortcut_foo_r2/1Joe14');
     $b = PSU::get('shortcut_foo_r2/1Joe14');
     $c = PSU::get('shortcut_foo_r2/1Joe15');
     $this->assertSame($a, $b);
     $this->assertNotSame($a, $c);
 }
示例#3
0
 /**
  * sight
  *
  * Function called to loop over an array of users and mark them as 
  * sighted in moodle in Banner.
  *
  * @param array $args (Optional) args for population selection
  */
 public static function sight($args = NULL)
 {
     $defaults = array('timestamp' => time(), 'termcode' => \PSU\Student::getCurrentTerm('UG'));
     $args = \PSU::params($args, $defaults);
     $BannerStudent = new \BannerStudent(\PSU::db('banner'));
     $successes = array();
     foreach ((array) self::get_active_users($args) as $idnumber) {
         $pidm = \PSU::get('idmobject')->getIdentifier($idnumber, 'psu_id', 'pid');
         if (\PSU::db('psc1')->GetOne("SELECT 1 FROM v_student_active WHERE pidm = :pidm", array('pidm' => $pidm))) {
             if ($BannerStudent->sightStudent($pidm, 'MC')) {
                 $successes[] = $idnumber;
             }
             //end if
         }
         //end if
     }
     //end foreach
     return $successes;
 }
 /**
  * Get a specific applicant.
  *
  * @param int $pidm the pidm to get deets for
  * @return array
  */
 function getApplicant($pidm)
 {
     if (!isset($GLOBALS['BannerGeneral'])) {
         require_once 'BannerGeneral.class.php';
         $GLOBALS['BannerGeneral'] = new BannerGeneral(PSU::db('banner'));
     }
     $return = array();
     $return['email'] = self::getApplicantEmail($pidm);
     $return['name_first'] = ucwords(PSU::get('idmobject')->getName($pidm, 'f'));
     $return['username'] = PSU::get('idmobject')->getIdentifier($pidm, 'pid', 'login_name');
     $return['ldap_user'] = PSU::get('idmobject')->getIdentifier($pidm, 'pid', 'username');
     if (preg_match('/^app\\./i', $return['username'])) {
         $return['username'] = preg_replace('/^app\\./i', '', $return['username']);
         $return['password'] = $GLOBALS['BannerGeneral']->getPin($pidm);
     }
     $return['psuid'] = PSU::get('idmobject')->getIdentifier($pidm, 'pidm', 'id');
     $return['pidm'] = $pidm;
     $v_ug_app = PSU::db('banner')->GetRow('SELECT * FROM v_ug_app WHERE pidm = :pidm', compact('pidm'));
     $return['term_code_entry'] = $v_ug_app['term_code_entry'];
     $return['apdc_code'] = $v_ug_app['apdc_code'];
     return $return;
 }
示例#5
0
$GLOBALS['ITS4'] = PSUDatabase::connect('mysql/data_mart-admin');
$GLOBALS['CALLLOG'] = PSUDatabase::connect('mysql/calllog');
$GLOBALS['USER_DB'] = PSUDatabase::connect('mysql/user_info-admin');
//$GLOBALS['EPO'] = PSUDatabase::connect('mssql/epo_mercury');
$GLOBALS['ASTER'] = PSUDatabase::connect('mysql/aster-misuser');
$GLOBALS['MYPLYMOUTH'] = PSUDatabase::connect('mysql/myplymouth');
/*******************[End Database Connections]*****************/
// which portal we are working in, for now there is only one, and we hardcode it!
$GLOBALS['Workflow'] = new Workflow();
$GLOBALS['BannerGeneral'] = new BannerGeneral($GLOBALS['BANNER']);
$GLOBALS['BannerStudent'] = new BannerStudent($GLOBALS['BANNER']);
$GLOBALS['PWMAN'] = new PasswordManager($GLOBALS['MYPLYMOUTH'], $_ = false, $GLOBALS['USER_DB']);
$GLOBALS['LOG'] = new PSULog('ape', $_SESSION['username']);
$GLOBALS['ZimbraAdmin'] = new zimbraAdmin();
/*******************[Authorization Stuff]*****************/
$GLOBALS['user_roles'] = PSU::get('idmobject')->getAllBannerRoles($_SESSION['username']);
$path_parts = pathinfo($_SERVER['SCRIPT_FILENAME']);
if (!IDMObject::authZ('role', 'staff') && !IDMObject::authZ('role', 'ape') && !APEAuthZ::infodesk() && !APEAuthZ::family() && !APEAuthZ::student() && !APEAuthZ::advancement() && !$_SESSION['impersonate']) {
    echo 'You (' . $_SESSION['username'] . ') do not have access to use this application.  If ' . $_SESSION['username'] . ' is not your username, please log in to <a href="http://go.plymouth.edu/logout">myPlymouth</a> and try again.';
    exit;
}
//end if
/*******************[End Authorization Stuff]*****************/
if ($_GET['mobile']) {
    $_SESSION['psu_mobile'] = true;
} elseif ($_GET['nomobile']) {
    $_SESSION['psu_mobile'] = false;
}
//end else
$GLOBALS['myuser'] = new PSUPerson($_SESSION['username']);
// first-time init. of error and message vars
 /**
  * Allow a user to view another person's layout.
  */
 public function set_layout($wp_id = null)
 {
     $this->_force_admin();
     if ($wp_id === null) {
         $wp_id = $_REQUEST['wp_id'];
     }
     //
     // is this user too privileged to be simulated?
     //
     $p = new PSUPerson($wp_id);
     if (PSU::get('idmobject')->hasAttribute($person->pidm, 'role', 'myplymouth')) {
         $_SESSION['errors'][] = "You cannot login as a portal administrator.";
         PSU::redirect($GLOBALS['BASE_URL'] . '/admin');
     }
     $session_stashed = $_SESSION;
     $_SESSION['wp_id'] = $wp_id;
     // if editing the default layout (i.e. $wp_id = 0), make sure the username and pidm are both 0
     $_SESSION['username'] = $p->username ?: 0;
     $_SESSION['pidm'] = $p->pidm ?: 0;
     $_SESSION['portal']['session_stashed'] = $session_stashed;
     $_SESSION['messages'][] = "You are now logged in as {$wp_id}.";
     PSU::redirect($GLOBALS['BASE_URL']);
 }
示例#7
0
<?php

PSU::get()->banner = PSU::db('psc1');
respond('/?', function ($request, $response, $app) {
    $ecommerce_running = shell_exec('ps ef | grep ecommerce_process.php | grep -v grep');
    if ($ecommerce_running) {
        $_SESSION['messages'][] = 'The ECommerce processing script is currently running. Reload to check the status.';
        $app->tpl->assign('ecommerce_processing', true);
    }
    //end if
    $app->tpl->assign('ecommerce_pending_files', \PSU\Ecommerce::pending_files());
    $app->tpl->assign('ecommerce_pending', \PSU\Ecommerce::pending());
    $app->tpl->assign('ecommerce_files', \PSU\Ecommerce::file_info());
    $app->tpl->assign('ecommerce_report', \PSU\Ecommerce::report());
    $app->tpl->display('ecommerce.tpl');
});
respond('/process', function ($request, $response, $app) {
    $user = PSU::isDev() ? 'nrporter' : 'webguru';
    if (PSU::isDev() && !IDMObject::authN('mis')) {
        return;
    }
    //end if
    $command = '~' . $user . '/scripts/ecommerce_process.php --instance=' . strtolower(PSU::db('banner')->database) . ' &';
    exec($command);
    $_SESSION['successes'][] = 'The ECommerce processing script has begun.  Please check back shortly.';
    PSU::redirect($GLOBALS['BASE_URL']);
});
        foreach ((array) $_SESSION['AUTHZ']['permission'] as $key => $value) {
            if (strpos($key, 'ape_') === 0) {
                unset($_SESSION['AUTHZ']['permission'][$key]);
            }
            //end if
        }
        //end foreach
        $message = 'Now impersonating: ' . $_SESSION['username'] . ' (' . $_SESSION['wp_id'] . ')';
        $_SESSION['messages'][] = $message;
    } elseif ($action == 'cancel') {
        if (isset($_SESSION['impersonate'])) {
            $GLOBALS['LOG']->write('Finished impersonating account', $_SESSION['username']);
            $_SESSION['wp_id'] = $_SESSION['impersonate_store']['wp_id'];
            $_SESSION['username'] = $_SESSION['impersonate_store']['username'];
            $_SESSION['pidm'] = $_SESSION['impersonate_store']['pidm'];
            $_SESSION['fullname'] = $_SESSION['impersonate_store']['fullname'];
            $_SESSION['phpCAS']['user'] = $_SESSION['impersonate_store']['username'];
            unset($_SESSION['AUTHZ']);
            PSU::get('idmobject')->loadAuthZ($_SESSION['pidm']);
            unset($_SESSION['impersonate_store'], $_SESSION['impersonate']);
        }
        //end if
        PSU::redirect($_SERVER['HTTP_REFERER']);
    } else {
        throw new Exception('Stop trying to sneak in here!!!');
    }
    //end else
} catch (Exception $e) {
    $_SESSION['errors'][] = sprintf("%s (%d)", $e->GetMessage(), $e->GetCode());
}
PSUHTML::redirect($GLOBALS['BASE_URL'] . '/user/' . $redirect_id);
示例#9
0
 public static function simple_search($search, $type = 'all')
 {
     global $db;
     $phonebook_search = array('all', 'name_first', 'name_last', 'email', 'phone');
     $search_data = array();
     $search_data['search_string'] = $_SESSION['search_string'] = stripslashes($search);
     $search_data['search_type'] = $_SESSION['search_type'] = $type;
     if (in_array($type, $phonebook_search)) {
         $search_results = phonebookSearch($search, $type);
     }
     switch ($search_data['search_type']) {
         case 'closed':
             $sql = "\n\t\t\t\t\tSELECT * \n\t\t\t\t\t\tFROM call_view \n\t\t\t\t\t WHERE caller_username = ?\n\t\t\t\t\t\t AND current='1' \n\t\t\t\t\t\t AND call_status = 'closed' \n\t\t\t\t\t ORDER BY call_date DESC, \n\t\t\t\t\t\t\t\t call_time DESC\n\t\t\t\t";
             $results = $db->GetAll($sql, array($search_data['search_string']));
             foreach ($results as $key) {
                 $key['comments'] = substr($key['comments'], 0, 23) . '...';
                 $search_data['results'][] = array('key' => $key, 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             }
             $search_data['fields'][1] = 'Call ID';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Call Date';
             $search_data['fields'][4] = 'Call Time';
             $search_data['fields'][5] = 'Comments';
             $search_data['search_results_text'] = 'Calls By';
             break;
         case 'computer':
             $hardware = searchHardwareInformation($search_data['search_string']);
             $username = explode("@", $hardware[0]['email']);
             $username = $username[0];
             foreach ($hardware as $hardware_info) {
                 $search_data['results'][] = array('HW_Key' => $hardware_info['id'], 'HW_IPName' => $hardware_info['computer_name'], 'HW_Username' => $username, 'MACAddress' => $hardware_info['mac_address'], 'IPAddress' => $hardware_info['ip_address'], 'search_string' => $search_data['search_string'], 'location' => $hardware_info['NodeName'], 'search_type' => $search_data['search_type']);
             }
             $search_data['fields'][1] = 'Computer Name';
             $search_data['fields'][2] = 'MAC Address';
             $search_data['fields'][3] = 'IP Address';
             $search_data['fields'][4] = 'Location';
             $search_data['search_results_text'] = 'Computer Name';
             break;
         case 'ip':
             $HardwareInfo = $db->GetAll("SELECT * FROM hardware_inventory WHERE ip_address = ?", array($search_data['search_string']));
             $username = explode("@", $HardwareInfo[0]['email']);
             $username = $username[0];
             $search_results = phonebookSearch($username);
             $search_results = current($search_results);
             $search_data['results'][] = array('HW_Key' => $HardwareInfo[0]['id'], 'HW_IPName' => $HardwareInfo[0]['computer_name'], 'HW_Username' => $search_results['email'], 'HW_Name' => $search_results['name_full'], 'MACAddress' => $HardwareInfo[0]['mac_address'], 'IPAddress' => $HardwareInfo[0]['ip_address'], 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             $search_data['fields'][1] = 'IP Address';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Username';
             $search_data['fields'][4] = 'MAC Address';
             $search_data['fields'][5] = 'Computer Name';
             $search_data['search_results_text'] = 'IP Address';
             break;
         case 'mac':
             $HardwareInfo = $db->GetAll("SELECT * FROM hardware_inventory WHERE upper(mac_address) = ?", array(strtoupper($search_data['search_string'])));
             $username = explode("@", $HardwareInfo[0]['email']);
             $username = $username[0];
             $search_results = phonebookSearch($username);
             $search_results = current($search_results);
             $search_data['results'][] = array('HW_Key' => $HardwareInfo[0]['id'], 'HW_IPName' => $HardwareInfo[0]['computer_name'], 'HW_Username' => $search_results['email'], 'HW_Name' => $search_results['name_full'], 'MACAddress' => $HardwareInfo[0]['mac_address'], 'IPAddress' => $HardwareInfo[0]['ip_address'], 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             $search_data['fields'][1] = 'MAC Address';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Username';
             $search_data['fields'][4] = 'Computer Name';
             $search_data['search_results_text'] = 'MAC Address';
             break;
         case 'ticket':
             $ticket_number_results = searchTicketNumber($search_data['search_string']);
             if ($ticket_number_results['call_id'] != '') {
                 $search_data['results'][] = array('call_id' => $ticket_number_results['call_id'], 'caller_username' => $ticket_number_results['caller_username'], 'caller_first_name' => $ticket_number_results['caller_first_name'], 'caller_last_name' => $ticket_number_results['caller_last_name'], 'caller_phone_number' => $ticket_number_results['caller_phone_number'], 'call_date' => $ticket_number_results['call_date'], 'call_time' => $ticket_number_results['call_time'], 'calllog_username' => $ticket_number_results['calllog_username'], 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type'], $search_data['search_type'] . '_selected' => 'SELECTED');
             } else {
                 $tpl->assign('no_ticket', 'NO TICKET FOUND');
                 $tpl->parse('main.searchResults.no_ticket');
             }
             $search_data['fields'][1] = 'Call ID';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Username';
             $search_data['fields'][4] = 'Call Date/Time';
             $search_data['fields'][5] = 'Call Log User';
             $search_data['search_results_text'] = 'Ticket #';
             break;
         case 'user':
             $results = $db->GetAll("SELECT * FROM call_log, call_history WHERE call_log.call_id = call_history.call_id AND call_log.calllog_username = '******'search_string']}' AND current='1' ORDER BY call_date DESC, call_time DESC");
             foreach ($results as $key) {
                 if ($key['comments'] != "") {
                     $key['comments'] = substr($key['comments'], 0, 23) . '...';
                 } else {
                     $key['comments'] = "Closed on Submit";
                 }
                 $search_data['results'][] = array('key' => $key, 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             }
             $search_data['fields'][1] = 'Call ID';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Call Date';
             $search_data['fields'][4] = 'Call Time';
             $search_data['fields'][5] = 'Comments';
             $search_data['search_results_text'] = 'Calls By';
             break;
         case 'wp_id':
         case 'all':
         case 'name_last':
         case 'name_first':
         case 'email':
         case 'phone':
             if ($search_data['search_type'] == 'wp_id') {
                 $sql = "\n\t\t\t\t\t\tSELECT * \n\t\t\t\t\t\t\tFROM wp_users \n\t\t\t\t\t\t WHERE user_login LIKE ?\n\t\t\t\t\t";
                 $search_results = PSU::db('connect')->GetAll($sql, array($search_data['search_string'] . '%'));
                 foreach ($search_results as &$record) {
                     $person = new PSUPerson($record['user_login']);
                     $record['identifier'] = $record['wp_id'] = $person->wp_id;
                     $record['name_full'] = $person->formatName('f l');
                     $record['email'] = $person->username;
                     $record['dept'] = 'Family Portal';
                     $person->destroy();
                     unset($person);
                 }
                 //end foreach
             }
             //end if
             foreach ($search_results as $k => $key) {
                 $class_prepend = '';
                 if ($key['email']) {
                     $display = "user_info";
                     if (!$key['identifier']) {
                         $key['identifier'] = $key['email'];
                     }
                     //end if
                 } else {
                     $display = "no_username";
                     if (!$key['identifier']) {
                         $key['identifier'] = $key['pidm'];
                     }
                     //end if
                 }
                 //end else
                 $portal_roles = PSU::get('idmobject')->GetAllBannerRoles($key['pidm']);
                 if (is_array($portal_roles) && in_array('alumni', $portal_roles)) {
                     $class_prepend = 'Alumni' . ($class_prepend ? '/ ' . $class_prepend : '');
                 }
                 //end if
                 if (is_array($portal_roles) && in_array('student_account_active', $portal_roles)) {
                     $class_prepend = 'Student' . ($class_prepend ? '/ ' . $class_prepend : '');
                 }
                 //end if
                 $key['dept'] = $class_prepend . ($key['dept'] ? '/ ' . $key['dept'] : '');
                 if ($key['pidm'] || $key['username'] || $key['wp_id']) {
                     $where = array();
                     $args = array();
                     if ($key['pidm']) {
                         $where[] = "call_log.pidm = ?";
                         $args[] = $key['pidm'];
                     }
                     //end if
                     if ($key['username']) {
                         $where[] = "call_log.caller_username = ?";
                         $args[] = $key['username'];
                     }
                     //end if
                     if ($key['wp_id']) {
                         $where[] = "call_log.wp_id = ?";
                         $args[] = $key['wp_id'];
                     }
                     //end if
                     $where = implode(" OR ", $where);
                     $getOpenCallInfo = $db->GetOne("SELECT * FROM call_log, call_history WHERE call_log.call_id = call_history.call_id AND call_history.call_status = 'open' AND ({$where}) AND call_history.current='1'", $args);
                     $num_open_calls = $db->GetOne("SELECT count(*) FROM call_log, call_history WHERE call_log.call_id = call_history.call_id AND call_history.call_status = 'open' AND ({$where}) AND call_history.current='1'", $args);
                     if ($num_open_calls >= 1) {
                         $key['call_id'] = $getOpenCallInfo;
                         $key['open_call'] = "(" . $num_open_calls . " Open)";
                     }
                     //end if
                     if ($key['major'] && $key['title']) {
                         $key['major_title'] = substr($key['major'] . ' / ' . $key['title'], 0, 20);
                         $key['major_title_full'] = $key['major'] . ' / ' . $key['title'];
                     } else {
                         $key['major_title'] = substr($key['major'] . ' ' . $key['title'], 0, 20);
                         $key['major_title_full'] = $key['major'] . ' ' . $key['title'];
                     }
                     //end else
                 }
                 //end if
                 $search_data['results'][] = array('key' => $key, 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             }
             // end foreach
             $search_data['fields'][1] = 'Name';
             $search_data['fields'][2] = 'Username';
             $search_data['fields'][3] = 'Phone';
             $search_data['fields'][4] = 'Major/Title';
             $search_data['fields'][5] = 'Class/Dept';
             switch ($search_data['search_type']) {
                 case 'email':
                     $search_data['search_results_text'] = 'User Name';
                     $search_data['five_selected'] = 'SELECTED';
                     break;
                 case 'name_last':
                     $search_data['search_results_text'] = 'Last Name';
                     $search_data['2_selected'] = 'SELECTED';
                     break;
                 case 'name_first':
                     $search_data['search_results_text'] = 'First Name';
                     $search_data['1_selected'] = 'SELECTED';
                     break;
             }
             //end switch
             break;
     }
     //end switch
     return $search_data;
 }
示例#10
0
 /**
  * Send mail, similar to PHP's mail.
  *
  * @section multipart Sending HTML mail
  *
  * To send a multipart message with text and HTML parts, set <var>$message</var> to <code>array($text, $html)</code>. To
  * send HTML only, set <code>$message = 'some html'</code>, and include a <var>$header</var> where <code>array('Content-type' => 'text/html')</code>.
  *
  * @since 1.11.0
  *
  * @param $to Email address to send message
  * @param $subject Email subject
  * @param $message Message contents
  * @param  $headers Optional. Additional headers.
  * @param  $attachments Optional. Files to attach.
  * @return True if mail was sent, false otherwise.
  */
 public static function mail($to, $subject, $message, $headers = '', $attachments = array())
 {
     if (!is_array($attachments)) {
         $attachments = explode("\n", $attachments);
     }
     $phpmailer = PSU::get('phpmailer');
     // Headers
     if (empty($headers)) {
         $headers = array();
     } elseif (!is_array($headers)) {
         // Explode the headers out, so this function can take both
         // string headers and an array of headers.
         $tempheaders = (array) explode("\n", $headers);
         $headers = array();
         // If it's actually got contents
         if (!empty($tempheaders)) {
             // Iterate through the raw headers
             foreach ((array) $tempheaders as $header) {
                 if (strpos($header, ':') === false) {
                     continue;
                 }
                 // Explode them out
                 list($name, $content) = explode(':', trim($header), 2);
                 // Cleanup crew
                 $name = trim($name);
                 $content = trim($content);
                 // Add it to our grand headers array
                 $headers[trim($name)] = trim($content);
             }
             //end foreach
         }
         //end if
     }
     //end function mail
     // Now that $headers is for-sure full, pull out things that belong elsewhere
     $tempheaders = array();
     foreach ($headers as $name => $content) {
         if ('from' == strtolower($name)) {
             if (strpos($content, '<') !== false) {
                 // So... making my life hard again?
                 $from_name = substr($content, 0, strpos($content, '<') - 1);
                 $from_name = str_replace('"', '', $from_name);
                 $from_name = trim($from_name);
                 $from_email = substr($content, strpos($content, '<') + 1);
                 $from_email = str_replace('>', '', $from_email);
                 $from_email = trim($from_email);
             } else {
                 $from_name = trim($content);
             }
             //end else
         } elseif ('content-type' == strtolower($name)) {
             if (strpos($content, ';') !== false) {
                 list($type, $charset) = explode(';', $content);
                 $content_type = trim($type);
                 $charset = trim(str_replace(array('charset=', '"'), '', $charset));
             } else {
                 $content_type = trim($content);
             }
             //end else
         } elseif ('cc' == strtolower($name)) {
             $cc = explode(",", $content);
         } elseif ('bcc' == strtolower($name)) {
             $bcc = explode(",", $content);
         } else {
             $tempheaders[$name] = $content;
         }
         //end else
     }
     //end foreach
     // Headers are everything that's left after the last foreach
     $headers = $tempheaders;
     // Empty out the values that may be set
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     // From email and name
     // If we don't have a name from the input headers
     if (!isset($from_name)) {
         $from_name = 'Plymouth State University';
     }
     // If we don't have an email from the input headers
     if (!isset($from_email)) {
         $from_email = '*****@*****.**';
     }
     // Set the from name and email
     $phpmailer->From = $from_email;
     $phpmailer->FromName = $from_name;
     // Set destination address
     if (!is_array($to)) {
         $to = explode(',', str_replace(';', ',', $to));
     }
     foreach ((array) $to as $recipient) {
         $phpmailer->AddAddress(trim($recipient));
     }
     //end foreach
     // Set mail's subject and body
     $phpmailer->Subject = $subject;
     if (!is_array($message)) {
         $phpmailer->Body = $message;
     } else {
         $phpmailer->AltBody = $message[0];
         $phpmailer->Body = $message[1];
         $phpmailer->IsHTML(TRUE);
     }
     //end else
     // Add any CC and BCC recipients
     if (!empty($cc)) {
         foreach ((array) $cc as $recipient) {
             $phpmailer->AddCc(trim($recipient));
         }
         //end foreach
     }
     //end if
     if (!empty($bcc)) {
         foreach ((array) $bcc as $recipient) {
             $phpmailer->AddBcc(trim($recipient));
         }
         //end foreach
     }
     //end if
     // Set to use SMTP via Owl
     $phpmailer->IsSMTP();
     $phpmailer->Host = 'owl.plymouth.edu';
     /*
     		these vars may be useful if we decide to use authenticated smtp
     		$phpmailer->SMTPAuth = true;
     		$phpmailer->Username = "******";
     		$phpmailer->Password = "******";
     	and these for encrypted
     		$phpmailer->SMTPSecure 	= 'ssl'; //or 'tls' or ''
     		$phpmailer->Port 		= 25;
     */
     // Set Content-Type and charset
     // If we don't have a content-type from the input headers
     if (!isset($content_type)) {
         $content_type = 'text/plain';
     }
     //end if
     // Set whether it's plaintext or not, depending on $content_type
     if ($content_type == 'text/html') {
         $phpmailer->IsHTML(true);
     } else {
         $phpmailer->IsHTML(false);
     }
     //end else
     // If we don't have a charset from the input headers
     if (!isset($charset)) {
         $charset = 'UTF-8';
     }
     //end if
     // Set the content-type and charset
     $phpmailer->CharSet = $charset;
     // Set custom headers
     if (!empty($headers)) {
         foreach ((array) $headers as $name => $content) {
             $phpmailer->AddCustomHeader(sprintf('%1$s: %2$s', $name, $content));
         }
         //end foreach
     }
     //end if
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (is_array($attachment)) {
                 call_user_func_array(array($phpmailer, 'AddAttachment'), $attachment);
             } else {
                 $phpmailer->AddAttachment($attachment);
             }
         }
         //end foreach
     }
     //end if
     // Send!
     $result = @$phpmailer->Send();
     return $result;
 }
<?php

class PeopleFu
{
    public static function get()
    {
        return new self();
    }
}
// add api instance shortcut
PSU::get()->add_shortcut('peoplefu', array('PeopleFu', 'get'));
// add database shortcut
PSU::get()->add_database('peopledb', 'oracle/peopledb/fixcase');
 /**
  * Set the portal user.
  */
 public function setUser($identifier)
 {
     $this->wp_id = $identifier;
     $this->person = new PSUPerson($_SESSION['username']);
     if ($ad_info = PSU::get('ad')->user_info($this->person->username, array('pwdlastset'))) {
         $ad_stamp = round(($ad_info[0]['pwdlastset'][0] - 116444736000000000) / 10000000);
         $this->password_info = array('changed' => date('F j, Y', $ad_stamp), 'days' => round((time() - $ad_stamp) / 60 / 60 / 24));
         if ($this->password_info['days'] > 160) {
             $this->password_info['class'] = 'password-alarm';
         } elseif ($this->password_info['days'] > 120) {
             $this->password_info['class'] = 'password-warning';
         }
         //end elseif
     }
     //end if
 }
<?php

PSU::get()->banner = PSU::db('test');
PSU::db('banner')->debug = true;
$args = array('pidm' => $_REQUEST['pidm'], 'term_code' => $_REQUEST['term_code'], 'comment_text' => $_REQUEST['note']);
$query = "INSERT INTO sgrscmt(\n\t\t\t\t\tsgrscmt_pidm,\n\t\t\t\t\tsgrscmt_seq_no,\n\t\t\t\t\tsgrscmt_term_code,\n\t\t\t\t\tsgrscmt_comment_text,\n\t\t\t\t\tsgrscmt_activity_date\n\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:pidm,\n\t\t\t\t\t(SELECT MAX(NVL(sgrscmt_seq_no,0))+1 FROM sgrscmt WHERE sgrscmt_pidm=:pidm),\n\t\t\t\t\t:term_code,\n\t\t\t\t\t:comment_text,\n\t\t\t\t\tSYSDATE\n\t\t\t\t)";
$action = PSU::db('banner')->Execute($query, $args);
PSUHTML::redirect($GLOBALS['BASE_URL'] . '/student/' . $person->pidm);
 /**
  * Return the age, in days, of a user's password.
  * @param $ident an identifier to pass to PSUPerson::get()
  * @return int the password age
  */
 function passwordAge($ident)
 {
     $person = PSUPerson::get($ident);
     $ad_info = PSU::get('ad')->user_info($person->login_name, array('pwdlastset'));
     // 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days huh.
     $ad_stamp = round(($ad_info[0]['pwdlastset'][0] - 116444736000000000) / 10000000);
     $change_date = date('F j, Y', $ad_stamp);
     $seconds = time() - $ad_stamp;
     $days = round($seconds / 60 / 60 / 24);
     return $days;
 }
示例#15
0
<?php

$response = array();
$response['messages'] = array();
$response['errors'] = array();
$is_ajax = isset($_REQUEST['ajax']) ? true : false;
$pidm = (int) $_GET['pidm'];
// check for invalid pidm
if (!$GLOBALS['BannerGeneral']->isValidPidm($pidm)) {
    $response['errors'] = sprintf('PIDM "%d" is invalid.', $pidm);
}
// where should redirects go?
$redirect_url = $GLOBALS['BASE_URL'] . '/user/' . $pidm;
if ($_GET['synchronize_ldi'] == 1) {
    // TODO: replace LDI sync code with REST API call to POST user/sync/ldi/[:id]/[:source] Where ":source" is the username of the synchronizer
    $person = new PSUPerson($pidm);
    if ($person->sync_ldi($_SESSION['username'] ?: 'ape')) {
        $response['messages'][] = 'Synchronization has been queued.';
    } else {
        $response['errors'][] = 'LDISync() failed, contact MIS.';
    }
    action_cleanup($redirect_url, $response, $is_ajax);
} elseif ($_GET['synchronize_ad']) {
    $GLOBALS['LOG']->write('Active Directory Sync', PSU::get('idmobject')->getIdentifier($pidm, 'pid', 'username'));
    require_once 'PSUadLDAP.class.php';
    $GLOBALS['AD'] = new PSUadLDAP();
    $GLOBALS['AD']->syncGroups($pidm);
    $response['messages'][] = 'Synchronization has been queued.';
    action_cleanup($redirect_url, $response, $is_ajax);
}
//end elseif
 /**
  * returns the contributors to the given checklist or checklist section
  *
  * @param $subject PSUPerson person the checklist is for
  * @param $attribute string checklist permission
  * @param $type_id int type of attribute
  */
 public static function contributors($subject, $checklist_id, $attribute = null, $type_id = null, $list = null)
 {
     if ($type_id != 1 || $list == 'Department') {
         // get all the supervisors
         $attributes = array('attribute' => array("pa.type_id" => 2, "pa.attribute" => 'supervisor'));
         $users = PSU::get('idmobject')->getUsersByAttribute($attributes);
         foreach ((array) $users as $user) {
             $person = new PSUPerson($user['username']);
             // only email supervisors whose departments match the person leaving
             if ($person->department == $subject->department) {
                 $people[$user['username']] = $person;
             }
             //end if
         }
         //end foreach
         $categories = HRChecklist::categories('employee-exit', 'slug');
         // get emails of non-completed checklist categories
         $attributes = array();
         foreach ($categories as $category) {
             if (!HRChecklist::is_complete('employee-exit', $checklist_id)) {
                 $attributes[] = array("pa.type_id" => 1, "pa.attribute" => 'ape_checklist_employee_exit_' . $category);
             }
             //end if
         }
         //end foreach
     } else {
         // get all people that match the given checklist
         $attributes = array('attribute' => array("pa.type_id" => $type_id, "pa.attribute" => $attribute));
     }
     //end else
     $users = PSU::get('idmobject')->getUsersByAttribute($attributes);
     foreach ((array) $users as $user) {
         $people[$user['username']] = new PSUPerson($user['username']);
     }
     //end foreach
     return $people;
 }
 /**
  * synchronize banner roles with luminis
  *
  * @param $person mixed person identifier or person object
  * @param $portal_roles array person's existing portal roles
  */
 public function syncLuminisRoles($person, $portal_roles = null)
 {
     /**
      * We DONT HAVE AN LDAP
      */
     return;
     // if $person isn't a PSUPerson, instantiate
     if (!$person instanceof PSUPerson) {
         $person = new PSUPerson($person);
     }
     //end if
     // if the person doesn't have a pidm, they won't exist in luminis
     if (!$person->pidm) {
         return;
     }
     // force a banner role calc
     PSU::get('idmobject')->maintainBannerRoles($person->pidm);
     // get the user's banner roles
     $banner_roles = PSU::get('idmobject')->getAllBannerRoles($person->pidm);
     $managed_roles = array('alumni', 'developmentofficer', 'employee', 'faculty', 'finance', 'friends', 'student', 'sysadmin', 'syssupport', 'creator', 'accountadmin', 'user', 'prospectivestudent', 'guest', 'administrator', 'observer', 'prospect', 'applicant', 'institutionaccept', 'applicantaccept', 'bannerinb', 'loadtester', 'newstudent', 'activestudent', 'student_active', 'student_grad', 'student_undergrad', 'student_exiting', 'student_pending', 'student_expected', 'psu_friend', 'student_ug_grad_candidate', 'student_enrolled', 'student_ug_first_year', 'student_ug_junior', 'student_ug_senior', 'student_ug_sophomore', 'student_ug_transfer', 'ug_app', 'ug_app_accept', 'ug_app_denied', 'ug_app_withdrawn', 'student_account_active', 'employee_os', 'employee_pat', 'employee_pa', 'alumni_campus', 'alumni_emeritus', 'staff', 'personal_email_collected', 'student_former', 'ug_app_accept_fall', 'faculty_services', 'student_worker', 'finaid', 'pds_authenticate', 'zimbra');
     $intended_roles = array();
     // figure out which roles the user should have
     if (is_array($banner_roles)) {
         $managed_banner_roles = array_intersect($banner_roles, $managed_roles);
     }
     if ($intended_roles) {
         // determine roles to delete
         $roles_to_delete = array_diff($portal_roles, $intended_roles);
         // determine roles to add
         $roles_to_add = array_diff($intended_roles, $portal_roles);
         // if there are roles to delete or add, update the role
         if ($roles_to_delete || $roles_to_add) {
             $array = array();
             $array['pdsrole'] = $intended_roles;
             PSU::get('luminisportal')->changeAttribute($person->login_name, $array);
         }
         //end if
     }
     //end if
     $person->destroy();
 }
示例#18
0
 public function pending_deletion_count()
 {
     $users = PSU::get('ad')->group_info('pending_deletion');
     return $users[0]['member']['count'];
 }
示例#19
0
<?php

include_once '../common.php';
//setlocale(LC_MONETARY, 'en_US');
$GLOBALS['BASE_URL'] .= '/report';
/*******************[End Site Constants]*****************/
require_once 'includes/report.lib.php';
/*******************[Authentication Stuff]*****************/
IDMObject::authN();
if (!IDMObject::authZ('permission', 'ecommerce_report') && !IDMObject::authZ('permission', 'mis')) {
    echo 'You do not have access to use this application';
    exit;
}
//end if
/*******************[End Authentication Stuff]*****************/
$GLOBALS['ECommerceTransaction'] = new PSUECommerceTransaction(PSU::get('banner'));
 /**
  * loads data from Banner Third Party Access
  *
  * @access		protected
  */
 protected function _load_third_party_access()
 {
     $third_party = array();
     $sql = "BEGIN :c_cursor := gb_third_party_access.f_query_one(:pidm); END;";
     if ($results = PSU::get('banner')->ExecuteCursor($sql, 'c_cursor', array('pidm' => $this->person->pidm))) {
         foreach ($results as $data) {
             $third_party = $data;
         }
         //end foreach
     }
     //end if
     $this->person->username = $third_party['gobtpac_external_user'];
     $this->person->login_name = $third_party['gobtpac_ldap_user'];
     $this->person->pin_exists = $third_party['gobtpac_pin'] != '' ? true : false;
     if ($this->person->pin_exists) {
         $this->person->pin_disabled = $third_party['gobtpac_pin_disabled_ind'] == 'Y' ? true : false;
         $this->person->pin_expires = strtotime($third_party['gobtpac_pin_exp_date']);
     }
     //end if
     $this->person->security_question = $third_party['gobtpac_question'];
 }
 /**
  * __construct
  *
  * Initial object setup.
  *
  * @param	string|boolean $uid_or_auto indicates how cache and template directories should be set. uid specifies a unique id to build names, true generates paths automatically. leave blank or false to specify these paths yourself.
  */
 function __construct($uid_or_auto = true)
 {
     self::$GLOBAL_TEMPLATES = PSU_LEGACY_DIR . '/templates';
     self::$STYLE_TEMPLATES = PSU_BASE_DIR . '/app/core/templates';
     parent::__construct();
     static::$js_registry = array('jquery' => 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.js', 'jquery-ui' => 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js', 'ddm' => '/includes/js/jquery-plugins/jquery.multi-ddm.min.js', 'my-combined' => '/webapp/my/js/combined.js', 'my-behavior' => '/webapp/my/js/behavior.js', 'myjs' => '/webapp/portal/myjs/index.php', 'style-behavior' => '/webapp/style-bootstrap/js/behavior.js', 'bootstrap' => '/webapp/style-bootstrap/js/bootstrap.min.js');
     $this->psu_server = ($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://';
     if (PSU::isdev()) {
         $this->psu_server .= self::psu_dev_server;
     } else {
         $this->psu_server .= self::psu_prod_server;
     }
     // does user want us to set up smarty dirs?
     if ($uid_or_auto) {
         // what's our temp directory?
         $tmp = null;
         if (isset($GLOBALS['TEMPORARY_FILES'])) {
             $tmp = $GLOBALS['TEMPORARY_FILES'];
         } else {
             foreach (self::$DEFAULT_TMP as $this_tmp) {
                 if (is_dir($this_tmp) && is_writable($this_tmp)) {
                     $tmp = $this_tmp;
                     break;
                 }
             }
         }
         if ($uid_or_auto === true) {
             // true means full automatic. use BASE_URL as the unique seed
             if (!isset($GLOBALS['BASE_URL'])) {
                 // can't be full auto without a base url.
                 throw new PSUSmartyException(PSUSmartyException::NO_BASE_URL);
             }
             $md5 = md5($GLOBALS['BASE_URL']);
             $this->compile_dir = $tmp . '/smarty_tc_' . $md5;
         } else {
             // uid was set, and it wasn't true, so use the string
             $this->compile_dir = $tmp . '/smarty_tc_' . $uid_or_auto;
         }
     } elseif (isset($GLOBALS['SMARTY_COMPILE'])) {
         // user did not want an auto dir, but specified a dir elsewhere
         $this->compile_dir = $GLOBALS['SMARTY_COMPILE'];
     }
     // create compile directory if it's not there yet
     if (!is_dir($this->compile_dir)) {
         $old_umask = umask(07);
         mkdir($this->compile_dir);
         umask($old_umask);
     }
     $this->plugins_dir[] = PSU_EXTERNAL_DIR . '/smarty/psu_plugins';
     $this->head = array('js' => array(), 'google_lazy_js' => array(), 'css' => array());
     // register any custom functions
     $this->register_function('PSU_JS', array($this, 'psu_js'));
     $this->register_function('psu_js', array($this, 'psu_js'));
     $this->register_function('PSU_GOOGLE_LAZY_JS', array($this, 'psu_google_lazy_js'));
     $this->register_function('PSU_CSS', array($this, 'psu_css'));
     $this->register_function('psu_dbug', array($this, 'psu_dbug'));
     $this->register_function('icon', array($this, 'icon'));
     $this->register_function('iconbox', array($this, 'iconbox'));
     $this->register_function('psu_puke', array($this, 'psu_puke'));
     $this->register_function('psu_progress', array($this, 'psu_progress'));
     $this->register_function('psu_authz_js', array($this, 'psu_authz_js'));
     $this->register_outputfilter(array($this, 'psu_head_includes'));
     $this->register_modifier('cdn', array($this, 'cdn'));
     $this->register_modifier('cssslug', array($this, 'cssslug'));
     $this->register_function('paging_querystring', array($this, 'paging_querystring'));
     $this->register_modifier('paging_order', array($this, 'paging_order'));
     $this->register_function('psu_messages', array($this, 'psu_messages'));
     $this->register_function('psu_errors', array($this, 'psu_errors'));
     $this->register_function('psu_successes', array($this, 'psu_successes'));
     $this->register_function('psu_warnings', array($this, 'psu_warnings'));
     $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
     // add in the registry
     $this->assign('psureg', PSU::get());
 }
示例#22
0
/**
 * Utility script to dump email addresses for every portal user who
 * has done some customization. Currently, this includes adding a
 * relationship and modifying the layout.
 *
 * Append ?simple=1 to URL to hide names.
 */
require __DIR__ . '/init.php';
require_once 'autoload.php';
IDMObject::authN();
if (!IDMObject::authZ('role', 'myplymouth')) {
    die('no access');
}
echo '<pre>';
PSU::get()->portal = PSU::db('portal_dev');
$sql = "SELECT DISTINCT wpid1 FROM relsearch WHERE substr(wpid1, 1, 1) <> 't'";
$wpids = PSU::db('portal')->GetCol($sql);
$sql = "SELECT DISTINCT wp_id FROM usertabs WHERE wp_id != 0 AND substr(wp_id, 1, 1) <> 't'";
$wpids2 = PSU::db('portal')->GetCol($sql);
$wpids = array_merge($wpids, $wpids2);
$wpids = array_unique($wpids);
sort($wpids);
if (!$_GET['simple']) {
    echo "// append ?simple=1 to url to hide names\n\n";
}
foreach ($wpids as $wpid) {
    $p = new PSUPerson($wpid);
    if ($_GET['simple'] == 1) {
        if ($p->wp_email) {
            echo $p->wp_email . ", ";
 /**
  * get roles for a user
  *
  * @deprecated Portal roles are deprecated, use IDMObject::getAllBannerRoles()
  *
  * @param string $search
  * @param string $type
  * @return array
  */
 function getRoles($search, $type = 'pdsLoginId')
 {
     trigger_error('portal::getRoles() is deprecated, use IDMObject', E_USER_DEPRECATED);
     $person = PSUPerson::get($search);
     // if possible, return current user's banner roles
     if (isset($_SESSION['wp_id']) && $person->wp_id == $_SESSION['wp_id'] && isset($_SESSION['AUTHZ']) && isset($_SESSION['AUTHZ']['banner'])) {
         return array_values($_SESSION['AUTHZ']['banner']);
     }
     return PSU::get('idmobject')->getAllBannerRoles($search);
 }
示例#24
0
 /**
  * Checks if the person is eligible to register
  *
  * @access		public
  * @return		boolean
  */
 public function _load_eligible_to_register()
 {
     $this->eligible_to_register = false;
     $data = \PSU::get('banner')->GetCol("SELECT sobterm_term_code term_code FROM sobterm WHERE sobterm_profile_send_ind = 'Y'");
     $global_term_string = implode("','", $data);
     $sql = "SELECT 'Y'\n\t\t\t\t\t\t FROM sgbstdn a,\n\t\t\t\t\t\t\t\t\tstvstst\n\t\t\t\t\t\tWHERE a.sgbstdn_pidm = :pidm\n\t\t\t\t\t\t\t\t\tAND a.sgbstdn_stst_code = stvstst_code\n\t\t\t\t\t\t\t\t\tAND stvstst_reg_ind = 'Y'\n\t\t\t\t\t\t\t\t\tAND a.sgbstdn_term_code_eff IN\n\t\t\t\t\t\t\t\t\t (SELECT MAX (b.sgbstdn_term_code_eff)\n\t\t\t\t\t\t\t\t\t\t\tFROM sgbstdn b, stvterm c\n\t\t\t\t\t\t\t\t\t\t WHERE     b.sgbstdn_pidm = a.sgbstdn_pidm\n\t\t\t\t\t\t\t\t\t\t\t\t\t AND b.sgbstdn_term_code_eff <= c.stvterm_code\n\t\t\t\t\t\t\t\t\t\t\t\t\t AND c.stvterm_code IN ('" . $global_term_string . "')\n\t\t\t\t\t\t\t\t\t\t GROUP BY c.stvterm_code)";
     $this->eligible_to_register = \PSU::get('banner')->GetOne($sql, array('pidm' => $this->pidm)) == 'Y' ? true : false;
 }
 public function log($message)
 {
     $log = \PSU::get('log/igrad/x_ecommerce');
     $log->write(sprintf("[%s] %s", $this->psp_user_id(), $message));
 }
示例#26
0
 /**
  * __construct
  *
  * Initial object setup.
  *
  * @param	string|boolean $uid_or_auto indicates how cache and template directories should be set. uid specifies a unique id to build names, true generates paths automatically. leave blank or false to specify these paths yourself.
  */
 function __construct($params = null, $fluid = false, $uid_or_auto = true)
 {
     static::$GLOBAL_STYLE = PSU_BASE_DIR . '/app/core/templates';
     parent::__construct($uid_or_auto);
     if ($_SESSION['impersonate']) {
         \PSU::get('log/impersonate')->write('Impersonation' . (\PSU::isDev() ? ' on dev server' : '') . ': accessing ' . $_SERVER['REQUEST_URI'] . ($_SERVER['HTTP_REFERER'] ? ' via ' . $_SERVER['HTTP_REFERER'] : ''), $_SESSION['username'], serialize($_REQUEST));
     }
     //end if
     if ($GLOBALS['TEMPLATES']) {
         $this->template_dir = $GLOBALS['TEMPLATES'];
     }
     if (!isset($GLOBALS['USE_APPLICATION_STYLE'])) {
         $GLOBALS['USE_APPLICATION_STYLE'] = true;
     }
     if ($params) {
         parse_str($params, $params);
         $key = key($params);
         if (!$params[$key]) {
             $params['page_title'] = str_replace('_', ' ', $key);
         }
         //end if
     }
     //end if
     $this->page_title = $params['page_title'];
     $this->app_title = $params['app_title'] ? $params['app_title'] : ($GLOBALS['TITLE'] ? $GLOBALS['TITLE'] : 'PSU Webapp');
     $this->fluid = $params['fluid'] ? $params['fluid'] : $fluid;
     // register any custom functions
     $this->register_block('box', array($this, 'psu_box'));
     $this->register_block('col', array($this, 'psu_col'));
     $this->register_block('message', array($this, 'psu_message'));
     $this->register_modifier('yesno', array($this, 'yesno'));
     $this->register_modifier('pluralize', array($this, 'pluralize'));
     $this->register_modifier('query_string', 'http_build_query');
     $this->register_function('myrel_access', array($this, 'myrel_access'));
     $this->register_function('myrel_list', array($this, 'myrel_list'));
     $this->register_function('randomid', array($this, 'randomid'));
     $this->register_function('nav', array($this, 'nav'));
     $this->register_function('navselect', array($this, 'navselect'));
     $this->register_modifier('bool2str', array($this, 'bool2str'));
     $this->content_classes = array(\PSU::isDev() ? 'webapp-dev' : 'webapp-prod');
     $this->body_style_classes = array();
     $this->body_style_classes[] = strtolower('month-' . date('F'));
     $this->body_style_classes[] = strtolower('weekday-' . date('l'));
     $this->body_style_classes[] = 'week-' . date('W');
     $this->body_style_classes[] = 'day-of-year-' . date('z');
     $this->body_style_classes[] = 'day-of-month-' . date('j');
     $this->body_style_classes[] = 'hour-' . date('H');
     $this->body_style_classes[] = 'minute-' . date('i');
     if ($_SESSION['username']) {
         $this->body_style_classes[] = 'user-' . $_SESSION['username'];
     }
     //end if
     if ($_SESSION['wp_id']) {
         $this->body_style_classes[] = 'user-' . $_SESSION['wp_id'];
     }
     //end if
     if ($GLOBALS['FANCY_TPL']) {
         $this->body_style_classes[] = 'extra-tag-styles';
     }
     $this->assign('facebook_api', \PSU::fbAPI());
     $this->assign('facebook_enable', $GLOBALS['FACEBOOK_ENABLE'] == true);
     $go = new \go($_SESSION['wp_id'] ? $_SESSION['wp_id'] : $_SESSION['username']);
     $hot_links = $go->cacheGetSites($_SESSION['wp_id'] || $_SESSION['username'] ? 'popular-me' : 'popular-everyone');
     if (sizeof($hot_links) < 5 && $_SESSION['username']) {
         $everyone_links = $go->cacheGetSites('popular-everyone');
         $hot_links = array_merge($hot_links, $everyone_links);
         $hot_links = array_unique($hot_links);
     }
     //end if
     $this->assign('webapp_hot_links', $hot_links);
     // cdn base url; omit trailing slash
     $this->assign('cdn', substr(\PSU::cdn(), 0, -1));
     if (\PSU::mobile() && $_COOKIE['psumobile'] != 'disable' || $_COOKIE['psumobile'] == 'force') {
         $this->mobile = true;
     }
     //end if
 }
示例#27
0
 /**
  * getCallerData
  *
  * returns caller data.  wewt.
  *
  * @param string $caller Caller username or pidm or wp_id
  * @param array $person Person record
  * @return array
  */
 function getCallerData($caller, $person = false)
 {
     $found_via = null;
     if ($person) {
         $found_via = 'function-args';
     }
     if (!$caller) {
         return array();
     }
     $config = \PSU\Config\Factory::get_config();
     $overrides = $config->get_json('psuperson', 'overrides');
     if (isset($overrides->{$caller})) {
         $caller = $overrides->{$caller};
     }
     //has the caller data already been queried?
     if (is_scalar($caller) && $this->people[$caller]) {
         //aye!  return it
         return $this->people[$caller];
     }
     //end if
     // are we trying to query getCallerData based on an already-populated $caller?
     if (is_array($caller) && isset($caller['wp_id']) && isset($this->people[$caller['wp_id']])) {
         return $this->people[$caller['wp_id']];
     } elseif (is_array($caller) && isset($caller['pidm']) && isset($this->people[$caller['pidm']])) {
         return $this->people[$caller['pidm']];
     }
     //end elseif
     //
     // populate generic data
     //
     $caller_data = array('pidm' => 0, 'wp_id' => null, 'identifier' => 'generic', 'email' => $GLOBALS['HELPDESK_EMAIL'], 'name_first' => 'Generic Caller', 'name_last' => 'Help Desk');
     switch ($caller) {
         case 'generic':
             $found_via = 'fake-user';
             break;
         case 'kiosk':
             $caller_data['identifier'] = 'kiosk';
             $caller_data['name_first'] = 'Kiosk';
             $found_via = 'fake-user';
             break;
         case 'clusteradm':
             $caller_data['identifier'] = 'clusteradm';
             $caller_data['name_first'] = 'Cluster Call';
             $found_via = 'fake-user';
             break;
     }
     //end switch
     $caller_data['name_full'] = $caller_data['name_first'] . ' - ' . $caller_data['name_last'];
     //
     // done with generic user setup; try to populate real user
     //
     if (!$person && !$this->isFakeUser($caller)) {
         // looks like a real user. try and find him.
         $caller_person = new PSUPerson($caller);
         if ($caller_person->is_valid()) {
             $person = array();
             $person['name_full'] = $caller_person->formatName('f l');
             $person['wp_id'] = $caller_person->wp_id;
             $person['email'] = $caller_person->wp_email;
             $person['pidm'] = $caller_person->pidm ? $caller_person->pidm : null;
             $person['identifier'] = $caller_person->wp_email ? $caller_person->wp_id : $caller_person->pidm;
             $person['username'] = $caller_person->username ?: $caller_person->wp_id;
             $found_via = 'psuperson';
         }
     }
     //end if
     //was a person record found?
     if (!empty($person)) {
         //Do some data cleansing
         $person['phone_number'] = $person['phone_of'] ? $person['phone_of'] : $person['phone_vm'];
         if ($person['pidm']) {
             $person['role'] = @implode(', ', PSU::get('idmobject')->getAllBannerRoles($person['identifier']));
         } else {
             $person['role'] = 'No Roles: Family Portal Only';
         }
         //end else
         if ($person['class'] == 'Alumni') {
             $person['class'] = strtolower($person['class']) . '.';
         }
         //end if
         if ($person['pidm']) {
             //get address for location
             if ($addresses = current($GLOBALS['BannerGeneral']->getAddress($person['pidm'], 'RH'))) {
                 $person['location'] = $addresses['r_street_line1'] . ' / ' . $person['msc'];
             } elseif ($addresses = current($GLOBALS['BannerGeneral']->getAddress($person['pidm'], 'OF'))) {
                 $person['location'] = $addresses['r_street_line2'] . ' / ' . $person['msc'];
             }
             //end elseif
             $psu_person = new PSUPerson($person['pidm']);
             $person['phone_number'] = $this->getCallerPhone($psu_person);
         }
         //end if
         //set the caller data to the person record
         $caller_data = $person;
     } elseif (!$this->isFakeUser($caller)) {
         $person = new PSUPerson($caller);
         $caller_data = array('pidm' => $person->pidm, 'wp_id' => $person->wp_id, 'psu_id' => $person->id, 'username' => $person->username, 'identifier' => $person->username ? $person->username : $person->wp_id, 'email' => $person->wp_email ? $person->wp_email : ($person->email ? $person->email['CA'][0] : ''), 'name_last' => $person->last_name, 'name_first' => $person->first_name, 'name_full' => "{$person->first_name} {$person->last_name}", 'phone_number' => $this->getCallerPhone($person));
         if (isset($caller_data['email']['CA']) && strpos($caller_data['email']['CA'], '@') !== false) {
             $caller_data['email'] = $caller_data['email']['CA'][0];
         } elseif (count($caller_data['email'])) {
             if (is_array($caller_data['email'])) {
                 $caller_data['email'] = array_shift(array_shift($caller_data['email']));
             } else {
                 $caller_data['email'] = $caller_data['email'];
             }
         } else {
             $caller_data['email'] = null;
         }
     }
     $caller_data['username'] = $caller_data['username'] ?: $caller_data['identifier'];
     if ($found_via == null) {
         return false;
     }
     //store the caller data so it isn't requeried a crap ton of times
     $this->people[$caller] = $caller_data;
     return $caller_data;
 }
 /**
  * syncGroups
  * 
  * Synchronizes the given user's ad roles with banner
  *
  * @param       mixed $pidm the user identifier
  */
 public function syncGroups($pidm, $banner_roles = false, $output = false, $username = null)
 {
     $lists = array('pat', 'os', 'faculty', 'lecturer', 'hourly', 'pa', 'usnh_employees');
     //these are the banner roles we care about for AD
     $ad_banner_roles = array('student_account_active', 'student_active', 'student_worker', 'student_exiting', 'employee', 'faculty', 'psu_friend', 'alumni', 'alumni_campus', 'alumni_emeritus');
     try {
         if (!$username) {
             $username = PSU::get('idmobject')->getIdentifier($pidm, 'pidm', 'username');
         }
         //end if
         if (!$username) {
             throw new UnexpectedValueException('Pidm ' . $pidm . ' does not have a username');
         }
         //end if
         $person_attributes = PSU::get('idmobject')->getPersonAttributes($pidm);
         $groups = $this->user_groups($username, true);
         //all of the user's current AD groups
         if (!is_array($groups)) {
             $groups = array();
         }
         $add_groups = array();
         $remove_groups = array();
         if (!$banner_roles) {
             $banner_roles = PSU::get('idmobject')->getAllBannerRoles($pidm);
         }
         $banner_roles = array_intersect($banner_roles, $ad_banner_roles);
         $banner_roles = (array) $banner_roles;
         //********* CHECK FOR STUDENT ROLE *******
         if (in_array('student_account_active', $banner_roles) || in_array('student_active', $banner_roles) || in_array('student_worker', $banner_roles)) {
             //they're a student
             if (!in_array('students', $groups)) {
                 $add_groups[] = 'students';
             }
         } else {
             if (in_array('students', $groups)) {
                 $remove_groups[] = 'students';
             }
         }
         //********** END STUDENT ROLE CODE ********
         //********** CHECK EMPLOYEE ROLES *********
         if (in_array('employee', $banner_roles) || $person_attributes['role']['usnh']) {
             //they're an employee break it down
             foreach ($lists as $list) {
                 if ('usnh_employees' == $list) {
                     $role = 'usnh';
                 } else {
                     $role = $list;
                 }
                 //end else
                 if ($person_attributes['role'][$role]) {
                     if (!in_array($list, $groups)) {
                         $add_groups[] = $list;
                     }
                 } else {
                     if (in_array($list, $groups)) {
                         $remove_groups[] = $list;
                     }
                 }
                 //end else
             }
             //end foreach
         } else {
             // they aren't an employee
             foreach ($lists as $list) {
                 if (in_array($list, $groups)) {
                     $remove_groups[] = $list;
                 }
             }
             //end foreach
         }
         //end else
         //************ END EMPLOYEE ROLE CODE ***************
         //********* CHECK FOR PSU FRIEND *******
         if (in_array('psu_friend', $banner_roles)) {
             //they're a friend
             if (!in_array('friends', $groups)) {
                 $add_groups[] = 'friends';
             }
         } else {
             if (in_array('friends', $groups)) {
                 $remove_groups[] = 'friends';
             }
         }
         //********** END PSU FRIEND ROLE CODE ********
         //********* CHECK FOR RETIREE *******
         if ($person_attributes['role']['retiree'] || in_array('alumni_emeritus', $banner_roles)) {
             //they're a Retiree
             if (!in_array('retirees', $groups)) {
                 $add_groups[] = 'retirees';
             }
         } else {
             if (in_array('retirees', $groups)) {
                 $remove_groups[] = 'retirees';
             }
         }
         //********** END RETIREE ROLE CODE ********
         //********* CHECK FOR ALUMNI ROLE *******
         if (in_array('alumni', $banner_roles)) {
             //they're alumni
             if (!in_array('alumni', $groups)) {
                 $add_groups[] = 'alumni';
             }
         } else {
             if (in_array('alumni', $groups)) {
                 $remove_groups[] = 'alumni';
             }
         }
         //********** END ALUMNI ROLE CODE ********
         //********* CHECK FOR ALUMNI CAMPUS ROLE *******
         if (in_array('alumni_campus', $banner_roles)) {
             //they're alumni
             if (!in_array('alumni_campus', $groups)) {
                 $add_groups[] = 'alumni_campus';
             }
         } else {
             if (in_array('alumni_campus', $groups)) {
                 $remove_groups[] = 'alumni_campus';
             }
         }
         //********** END ALUMNI ROLE CODE ********
         //********* CHECK FOR ALUMNI ONLY *******
         if (in_array('alumni', $banner_roles) && count($banner_roles) == 1) {
             //they're alumni and have no other roles
             if (!in_array('alumni_only', $groups)) {
                 $add_groups[] = 'alumni_only';
             }
         } else {
             if (in_array('alumni_only', $groups)) {
                 $remove_groups[] = 'alumni_only';
             }
         }
         //********** END ALUMNI ONLY ROLE CODE ********
         //********* CHECK FOR PENDING DELETION *******
         if (empty($banner_roles)) {
             //they have no valid banner roles that would cause account creation
             if (!in_array('pending_deletion', $groups)) {
                 $add_groups[] = 'pending_deletion';
             }
         } else {
             if (in_array('pending_deletion', $groups)) {
                 $remove_groups[] = 'pending_deletion';
             }
         }
         //********** END PENDING DELETION ********
         $this->addUserToGroup($username, $add_groups);
         $this->removeUserFromGroup($username, $remove_groups);
     } catch (Exception $e) {
         return false;
     }
     //end catch
 }
示例#29
0
function adodb_firephp($msg, $newline)
{
    PSU::get('firephp')->log(html_entity_decode(strip_tags($msg)));
}