function email_user_approved($reservation_idx)
 {
     //emails the user when thier loan has been approved
     $reserve = ReserveDatabaseAPI::by_id($reservation_idx);
     $reservation = $reserve[$reservation_idx];
     $index = $reserve[$reservation_idx]['building_idx'];
     $categories = ReserveDatabaseAPI::categories();
     $locations = ReserveDatabaseAPI::locations();
     $email = new \PSUSmarty();
     $email->assign('categories', $categories);
     $email->assign('locations', $locations);
     $email->assign('reserve', $reservation);
     $contents = $email->fetch($GLOBALS['TEMPLATES'] . '/email.user.approve.tpl');
     return PSU::mail($reserve[$reservation_idx]['email'], 'Media Request Approved!', $contents, self::headers());
 }
 /**
  * build the email channel
  *
  * @since		version 1.0
  */
 public function emailChannel()
 {
     require_once 'PSUSmarty.class.php';
     $tpl = new PSUSmarty();
     $total_messages = 0;
     $unread_messages = 0;
     $clean_messages = array();
     $messages = $this->getMessages('in:inbox');
     if ($messages === false) {
         return sprintf('Sorry, your mailbox could not be fetched (%s).', $this->error_code);
     }
     if (is_array($messages)) {
         $more = $messages['more'];
         foreach ($messages['m'] as $message) {
             $clean_message = array();
             $clean_message['subject'] = isset($message['su'][0]) && $message['su'][0] != '' ? htmlentities($message['su'][0]) : '[None]';
             $clean_message['subject'] = strlen($clean_message['subject']) > 20 ? substr($clean_message['subject'], 0, 17) . '...' : $clean_message['subject'];
             $clean_message['body_fragment'] = $message['fr'][0];
             $clean_message['from_email'] = $message['e_attribute_a'][0];
             $clean_message['from'] = $message['e_attribute_p'][0] ? htmlspecialchars($message['e_attribute_p'][0]) : $clean_message['from_email'];
             $clean_message['size'] = $this->makeBytesPretty($message['s'], 40 * 1024 * 1024);
             $clean_message['date'] = date('n/j/y', $message['d'] / 1000);
             $clean_message['id'] = $message['id'];
             $clean_message['url'] = 'http://go.plymouth.edu/mymail/msg/' . $clean_message['id'];
             $clean_message['attachment'] = false;
             $clean_message['status'] = 'read';
             $clean_message['deleted'] = false;
             $clean_message['flagged'] = false;
             if (isset($message['f'])) {
                 $clean_message['attachment'] = strpos($message['f'], 'a') !== false ? true : false;
                 $clean_message['status'] = strpos($message['f'], 'u') !== false ? 'unread' : 'read';
                 $clean_message['deleted'] = strpos($message['f'], '2') !== false ? true : false;
                 $clean_message['flagged'] = strpos($message['f'], 'f') !== false ? true : false;
             }
             $clean_messages[] = $clean_message;
         }
         $tpl->assign('messages', $clean_messages);
         $inbox = $this->getFolder(array('l' => 2));
         $total_messages = (int) $inbox['n'];
         $unread_messages = (int) $inbox['u'];
     }
     $tpl->assign('total_messages', $total_messages);
     $tpl->assign('unread_messages', $unread_messages);
     $info = $this->getInfo(array('sections' => 'mbox'));
     if (is_array($info['attrs'][0]['attr_attribute_name'])) {
         $quota = $info['attrs'][0]['attr'][array_search('zimbraMailQuota', $info['attrs'][0]['attr_attribute_name'])];
         $size_text = $this->makeBytesPretty($info['used'][0], $quota * 0.75) . ' out of ' . $this->makeBytesPretty($quota);
         $tpl->assign('size', $size_text);
     }
     /*include_once 'portal_functions.php';
     		$roles = getRoles($this->_username);
     
     		if(in_array('faculty', $roles) || in_array('employee', $roles))
     		{
     			$tpl->parse('main.away_message');
     		}*/
     return $tpl->fetch('/web/pscpages/webapp/portal/channel/email/templates/index.tpl');
 }
function smarty_function_psugraph_options($params, &$smarty)
{
    $tpl = new PSUSmarty();
    $tpl->assign('args', $params);
    return $tpl->fetch('/web/pscpages/webapp/analytics/templates/graph.options.tpl');
}
 /**
  * displays a ticket's public updates
  */
 public function ticket($ticket)
 {
     IDMObject::authN();
     $sql = "SELECT *,\n\t\t\t\t\t\t\t\t\t CONCAT(date_assigned, ' ', time_assigned) update_date\n\t\t\t        FROM call_history\n\t\t\t\t\t\t WHERE call_id = ?\n               AND (updated_by = ?\n\t\t\t\t\t\t        OR\n\t\t\t\t\t\t        tlc_assigned_to = ?\n\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\tupdated_by = ?\n\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\ttlc_assigned_to = ?\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t ORDER BY date_assigned, time_assigned";
     $args = array($ticket, $this->myuser->login_name, $this->myuser->login_name, $this->myuser->wp_id, $this->myuser->wp_id);
     $details = PSU::db('calllog')->GetAll($sql, $args);
     foreach ($details as &$detail) {
         $p = new PSUPerson($detail['updated_by']);
         $detail['updated_by_name'] = $p->wp_id == $_SESSION['wp_id'] ? 'You' : $p->formatName('f');
         $p->destroy();
         unset($p);
     }
     //end foreach
     $sql = "SELECT call_status\n\t\t\t        FROM call_history\n\t\t\t\t\t\t WHERE call_id = ? AND current = 1";
     $args = array($ticket);
     $this->tpl->assign('call_status', PSU::db('calllog')->GetOne($sql, $args));
     $this->tpl->assign('details', $details);
     $this->tpl->assign('ticket', $ticket);
     $tpl = new PSUSmarty();
     $tpl->assign('hide_checklist', true);
     $tpl->assign('details_title', 'Update Ticket');
     $form = $tpl->fetch(PSU_BASE_DIR . '/webapp/calllog/templates/ticket_form.tpl');
     $this->tpl->assign('form', $form);
     $this->tpl->display('ticket.tpl');
 }
 /**
  * This function is used to send off an email regaurding information on the employee exit checklist. 
  * This function is a bit smashed together to only work with employee exit checklist. If a future checklist was made this function
  * will have to be rethought.
  *
  * @param $attribute string containing pa.attribute and pa.type keys in order to populate usernames by attribute
  * @param $type_id int 1 = permission 2 = role 6 = admin. Must be one of these numebrs
  * @param $subject PSUPerson the person the email is about. 
  * @param $end_date string the date the person will be leaving the institution
  * @param $list string the checklist the email is using. 
  */
 public static function email($subject, $end_date, $attribute, $type_id, $list, $checklist_id, $response)
 {
     global $config;
     $emails = array();
     $people = self::contributors($subject, $checklist_id, $attribute, $type_id);
     $emails = self::contributor_email($people);
     $checklist = self::get($subject->pidm, 'employee-exit');
     if ($emails) {
         $url = $config->get('ape', 'base_url') . '/user/' . $subject->pidm . '/checklist/' . $list;
         $email = new PSUSmarty();
         $email->assign('no_outstanding_charges', $response->no_outstanding_charges);
         $email->assign('no_ape_attributes', $response->no_ape_attributes);
         $email->assign('no_academic_admin', $response->no_academic_admin);
         $email->assign('end_date', $end_date);
         $email->assign('employee_name', $subject->formatName('f m l'));
         $email->assign('employee_username', $subject->username);
         $email->assign('subject', $subject);
         $email->assign('position', $subject->employee_positions[$checklist['position_code']]);
         $email->assign('link', $url);
         $headers = 'Content-type: text/html; charset=UTF-8' . "\r\n";
         PSU::mail($emails, '[Action Required] ' . $subject->formatName('f m l') . ' - Leaving ' . date('M j, Y', $end_date), $email->fetch($GLOBALS['TEMPLATES'] . '/email.checklist.employee-exit.tpl'), $headers);
     }
     //end foreach
     return $emails;
 }