예제 #1
0
 public function forceLogin()
 {
     if (!$this->force_login) {
         return;
     }
     PHPWS_Core::reroute($this->login_link);
 }
예제 #2
0
/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
function my_page()
{
    $title = $content = $message = NULL;
    if (isset($_SESSION['Layout_User_Message'])) {
        $message = $_SESSION['Layout_User_Message'];
        unset($_SESSION['Layout_User_Message']);
    }
    if (isset($_SESSION['Reset_Layout'])) {
        unset($_SESSION['Reset_Layout']);
        Layout::reset();
    }
    if (isset($_REQUEST['lo_command'])) {
        $lo_command = $_REQUEST['lo_command'];
    } else {
        $lo_command = 'user_form';
    }
    switch ($lo_command) {
        case 'user_form':
            $title = dgettext('layout', 'Display settings');
            $content = Layout_User_Settings::user_form();
            break;
        case 'save_settings':
            Layout_User_Settings::save_settings();
            $_SESSION['Reset_Layout'] = 1;
            $_SESSION['Layout_User_Message'] = dgettext('layout', 'Settings saved');
            PHPWS_Core::reroute('index.php?module=users&action=user&tab=layout');
            break;
    }
    $tpl['TITLE'] = $title;
    $tpl['CONTENT'] = $content;
    $tpl['MESSAGE'] = $message;
    return PHPWS_Template::process($tpl, 'layout', 'main.tpl');
}
예제 #3
0
function check_cookie()
{
    $cookie = PHPWS_Cookie::read('cookie_enabled');
    if (!$cookie) {
        if (!isset($_GET['cc'])) {
            PHPWS_Cookie::write('cookie_enabled', 'y');
            PHPWS_Core::reroute('index.php?cc=1');
        } else {
            $tpl['MESSAGE'] = dgettext('layout', 'This site requires you to enable cookies on your browser.');
            $message = PHPWS_Template::process($tpl, 'layout', 'no_cookie.tpl');
            Layout::nakedDisplay($message);
        }
    }
}
예제 #4
0
 function adminMenu()
 {
     if (!Current_User::allow('whatsnew')) {
         Current_User::disallow();
     }
     $this->loadPanel();
     $javascript = false;
     $this->loadMessage();
     switch ($_REQUEST['aop']) {
         case 'menu':
             if (!isset($_GET['tab'])) {
                 $this->loadForm('settings');
             } else {
                 $this->loadForm($_GET['tab']);
             }
             break;
         case 'post_settings':
             if (!Current_User::authorized('whatsnew')) {
                 Current_User::disallow();
             }
             if ($this->postSettings()) {
                 $this->forwardMessage(dgettext('whatsnew', 'Whatsnew settings saved.'));
                 PHPWS_Core::reroute('index.php?module=whatsnew&aop=menu');
             } else {
                 $this->loadForm('settings');
             }
             break;
         case 'flush_cache':
             if (!Current_User::authorized('whatsnew')) {
                 Current_User::disallow();
             }
             if ($this->flushCache()) {
                 $this->forwardMessage(dgettext('whatsnew', 'Cache flushed.'));
                 PHPWS_Core::reroute('index.php?module=whatsnew&aop=menu');
             } else {
                 $this->loadForm('settings');
             }
             break;
     }
     $tpl['TITLE'] = $this->title;
     $tpl['CONTENT'] = $this->content;
     $tpl['MESSAGE'] = $this->message;
     if ($javascript) {
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'whatsnew', 'main_admin.tpl'));
     } else {
         $this->panel->setContent(PHPWS_Template::process($tpl, 'whatsnew', 'main_admin.tpl'));
         Layout::add(PHPWS_ControlPanel::display($this->panel->display()));
     }
 }
예제 #5
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'save':
             $factory->postSettings();
             break;
     }
     \PHPWS_Core::reroute('tailgate/Admin/');
 }
예제 #6
0
 public function post(\Request $request)
 {
     $factory = new Factory();
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     switch ($request->getVar('command')) {
         case 'createNewAccount':
             $factory->postNewStudent(\Current_User::getId());
             \PHPWS_Core::reroute('tailgate/');
             break;
     }
     return $response;
 }
 public function execute()
 {
     // Make sure an 'internship_id' key is set on the request
     if (!isset($_REQUEST['internship_id'])) {
         \NQ::simple('intern', NotifyUI::ERROR, 'No internship ID was given.');
         \NQ::close();
         \PHPWS_Core::reroute('index.php');
     }
     // Load the Internship
     try {
         $intern = InternshipFactory::getInternshipById($_REQUEST['internship_id']);
     } catch (\Intern\Exception\InternshipNotFoundException $e) {
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.');
         return;
     }
     if ($intern === false) {
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.');
         //TODO redirect to the search interface
         return;
     }
     // Load a fresh copy of the student data from the web service
     try {
         $student = StudentProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm());
     } catch (\Intern\Exception\StudentNotFoundException $e) {
         $studentId = $intern->getBannerId();
         $student = null;
         \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student.");
     }
     // Load the WorkflowState
     $wfState = $intern->getWorkflowState();
     // Load the agency
     $agency = AgencyFactory::getAgencyById($intern->getAgencyId());
     // Load the documents
     $docs = $intern->getDocuments();
     if ($docs === null) {
         $docs = array();
         // if no docs, setup an empty array
     }
     $view = new InternshipView($intern, $student, $wfState, $agency, $docs);
     return $view->display();
 }
예제 #8
0
function my_page()
{
    if (isset($_REQUEST['subcommand'])) {
        $subcommand = $_REQUEST['subcommand'];
    } else {
        $subcommand = 'updateSettings';
    }
    $user = $_SESSION['User'];
    $template['TITLE'] = dgettext('users', 'Change my Settings');
    switch ($subcommand) {
        case 'updateSettings':
            if (isset($_GET['save'])) {
                $template['MESSAGE'] = dgettext('users', 'User settings updated.');
            }
            $content = User_Settings::userForm($user);
            break;
        case 'postUser':
            User_Settings::setTZ();
            User_Settings::rememberMe();
            User_Settings::setCP();
            $result = User_Action::postUser($user, FALSE);
            if (is_array($result)) {
                $content = User_Settings::userForm($user, $result);
            } else {
                if (PHPWS_Error::logIfError($user->save())) {
                    $content = dgettext('users', 'An error occurred while updating your user account.');
                } else {
                    $_SESSION['User'] = $user;
                    PHPWS_Core::reroute('index.php?module=users&action=user&tab=users&save=1');
                }
            }
            break;
    }
    $template['CONTENT'] = $content;
    return PHPWS_Template::process($template, 'users', 'my_page/main.tpl');
}
예제 #9
0
 public static function show($start_date = null, $end_date = null)
 {
     if (!Blog_User::allowView()) {
         return null;
     }
     $db = new PHPWS_DB('blog_entries');
     if ($start_date) {
         $db->addWhere('publish_date', $start_date, '>=', 'and', 2);
     }
     if ($end_date) {
         $db->addWhere('publish_date', $end_date, '<=', 'and', 2);
     }
     $db->addWhere('approved', 1);
     $db->addWhere('publish_date', time(), '<');
     $db->addWhere('expire_date', time(), '>', 'and', 1);
     $db->addWhere('expire_date', 0, '=', 'or', 1);
     $db->setGroupConj(1, 'and');
     Key::restrictView($db, 'blog');
     $total_entries = Blog_User::totalEntries($db);
     $limit = PHPWS_Settings::get('blog', 'blog_limit');
     if (isset($_GET['page'])) {
         $page = $_GET['page'];
     } else {
         $page = 0;
     }
     if (!is_numeric($page) || $page < 2) {
         $offset = $page = 0;
     } else {
         $offset = ($page - 1) * $limit;
     }
     Layout::addStyle('blog');
     $result = Blog_User::getEntries($db, $limit, $offset);
     if ($page > 0 && empty($result)) {
         PHPWS_Core::reroute('blog/action/view/page/1');
     }
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         return NULL;
     }
     if (empty($result)) {
         if (Current_User::allow('blog')) {
             MiniAdmin::add('blog', PHPWS_Text::secureLink(dgettext('blog', 'Create first blog entry!'), 'blog', array('action' => 'admin', 'command' => 'new')));
         }
         return NULL;
     }
     if ($page < 2) {
         $past_entries = PHPWS_Settings::get('blog', 'past_entries');
         if ($past_entries) {
             $db->setLimit($past_entries, $limit);
             $past = $db->getObjects('Blog');
             if (PHPWS_Error::isError($past)) {
                 PHPWS_Error::log($past);
             } elseif ($past) {
                 Blog_User::showPast($past);
             }
         }
     }
     $rss = false;
     foreach ($result as $blog) {
         if (!$rss) {
             if (PHPWS_Core::moduleExists('rss')) {
                 PHPWS_Core::initModClass('rss', 'RSS.php');
                 $key = new Key($blog->key_id);
                 RSS::showIcon($key);
                 $rss = true;
             }
         }
         $view = $blog->view();
         if (!empty($view)) {
             $list[] = $view;
         }
     }
     $page_vars['action'] = 'view';
     if ($page > 1) {
         $page_vars['page'] = $page - 1;
         $tpl['PREV_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Previous page'), 'blog', $page_vars);
         if ($limit + $offset < $total_entries) {
             $page_vars['page'] = $page + 1;
             $tpl['NEXT_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Next page'), 'blog', $page_vars);
         }
     } elseif ($limit + $offset < $total_entries) {
         $page_vars['page'] = 2;
         $tpl['NEXT_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Next page'), 'blog', $page_vars);
     }
     $tpl['ENTRIES'] = implode('', $list);
     $content = PHPWS_Template::process($tpl, 'blog', 'list_view.tpl');
     if (Current_User::allow('blog', 'edit_blog')) {
         Blog_User::miniAdminList();
         $vars['action'] = 'admin';
         $vars['command'] = 'new';
         $link[] = PHPWS_Text::secureLink(dgettext('blog', 'Add new blog'), 'blog', $vars);
         MiniAdmin::add('blog', $link);
     }
     return $content;
 }
예제 #10
0
 public function post()
 {
     $this->loadContact();
     switch ($_POST['cop']) {
         case 'login':
             if ($this->login()) {
                 \PHPWS_Core::home();
                 // login successful, contact page
             } else {
                 $this->contactLogin();
             }
             break;
         case 'save_property':
             $this->checkPermission();
             $this->loadProperty($this->contact->id);
             if ($this->property->post()) {
                 try {
                     $this->property->save();
                     $this->setCarryMessage('Property saved successfully.');
                     \PHPWS_Core::reroute($this->property->viewLink());
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                     \PHPWS_Core::reroute('index.php?module=properties&cop=view_properties&k=' . $_SESSION['Contact_User']->getKey());
                 }
             } else {
                 $this->editProperty($this->contact->id);
             }
             break;
         case 'save_contact':
             $this->checkPermission();
             if ($this->contact->post()) {
                 try {
                     $this->contact->save();
                     $this->contact->errors = null;
                     \PHPWS_Core::home();
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                     $this->editContact();
                 }
             } else {
                 $this->editContact();
             }
             break;
         case 'post_photo':
             try {
                 $photo = new Photo();
                 $photo->post();
                 $this->setCarryMessage('Photo uploaded');
                 if (isset($_POST['v'])) {
                     $property = new Property($photo->pid);
                     $url = './properties/id/' . $photo->pid . '/photo/1';
                 } else {
                     $url = 'index.php?module=properties&cop=view_properties&k=' . $_SESSION['Contact_User']->getKey() . '&pid=' . $photo->pid;
                 }
                 \PHPWS_Core::reroute($url);
             } catch (\Exception $e) {
                 $this->setCarryMessage($e->getMessage());
                 \PHPWS_Core::goBack();
             }
             break;
     }
     $this->display();
 }
예제 #11
0
 public function execute()
 {
     PHPWS_Core::initModClass('intern', 'Internship.php');
     PHPWS_Core::initModClass('intern', 'Agency.php');
     PHPWS_Core::initModClass('intern', 'Department.php');
     PHPWS_Core::initModClass('intern', 'Faculty.php');
     /**************
      * Sanity Checks
      */
     // Required fields check
     $missing = self::checkRequest();
     if (!is_null($missing) && !empty($missing)) {
         // checkRequest returned some missing fields.
         $url = 'index.php?module=intern&action=edit_internship';
         $url .= '&missing=' . implode('+', $missing);
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, 'Please fill in the highlighted fields.');
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check the Banner ID
     if (!preg_match('/^\\d{9}$/', $_REQUEST['banner'])) {
         $url = 'index.php?module=intern&action=edit_internship&missing=banner';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The Banner ID you entered is not valid. No changes were saved. The student's Banner ID should be nine digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check student email
     if (isset($_REQUEST['student_email']) && preg_match("/@/", $_REQUEST['student_email'])) {
         $url = 'index.php?module=intern&action=edit_internship&missing=student_email';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The student's email address is invalid. No changes were saved. Enter only the username portion of the student's email address. The '@appstate.edu' portion is not necessary.");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check student zip
     if (isset($_REQUEST['student_zip']) && $_REQUEST['student_zip'] != "" && (strlen($_REQUEST['student_zip']) != 5 || !is_numeric($_REQUEST['student_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=student_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The student's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Course start date must be before end date
     if (!empty($_REQUEST['start_date']) && !empty($_REQUEST['end_date'])) {
         $start = strtotime($_REQUEST['start_date']);
         $end = strtotime($_REQUEST['end_date']);
         if ($start > $end) {
             $url = 'index.php?module=intern&action=edit_internship&missing=start_date+end_date';
             // Restore the values in the fields the user already entered
             unset($_POST['start_date']);
             unset($_POST['end_date']);
             foreach ($_POST as $key => $val) {
                 $url .= "&{$key}={$val}";
             }
             NQ::simple('intern', INTERN_WARNING, 'The internship start date must be before the end date.');
             NQ::close();
             return PHPWS_Core::reroute($url);
         }
     }
     // Sanity check internship location zip
     if (isset($_REQUEST['loc_zip']) && $_REQUEST['loc_zip'] != "" && (strlen($_REQUEST['loc_zip']) != 5 || !is_numeric($_REQUEST['loc_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=loc_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The internship location's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check agency zip
     if (isset($_REQUEST['agency_zip']) && $_REQUEST['agency_zip'] != "" && (strlen($_REQUEST['agency_zip']) != 5 || !is_numeric($_REQUEST['agency_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check supervisor's zip
     if (isset($_REQUEST['agency_sup_zip']) && $_REQUEST['agency_sup_zip'] != "" && (strlen($_REQUEST['agency_sup_zip']) != 5 || !is_numeric($_REQUEST['agency_sup_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_sup_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency supervisor's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check course number
     if (isset($_REQUEST['course_no']) && $_REQUEST['course_no'] != '' && (strlen($_REQUEST['course_no']) > 20 || !is_numeric($_REQUEST['course_no']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=course_no';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The course number provided is invalid. No changes were saved. Course numbers should be less than 20 digits (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     PHPWS_DB::begin();
     // Create/Save agency
     $agency = new Agency();
     if (isset($_REQUEST['agency_id'])) {
         // User is editing internship
         try {
             $agency = new Agency($_REQUEST['agency_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     }
     $agency->name = $_REQUEST['agency_name'];
     $agency->address = $_REQUEST['agency_address'];
     $agency->city = $_REQUEST['agency_city'];
     $agency->zip = $_REQUEST['agency_zip'];
     $agency->phone = $_REQUEST['agency_phone'];
     if ($_REQUEST['location'] == 'internat') {
         /* Location is INTERNATIONAL. Country is required. Province was typed in. */
         $agency->state = $_REQUEST['agency_state'];
         $agency->province = $_REQUEST['agency_province'];
         $agency->country = $_REQUEST['agency_country'];
         $agency->supervisor_state = $_REQUEST['agency_sup_state'];
         $agency->supervisor_province = $_REQUEST['agency_sup_province'];
         $agency->supervisor_country = $_REQUEST['agency_sup_country'];
     } else {
         /* Location is DOMESTIC. Country is U.S. State was chosen from drop down */
         $agency->state = $_REQUEST['agency_state'] == -1 ? null : $_REQUEST['agency_state'];
         $agency->country = 'United States';
         $agency->supervisor_state = $_REQUEST['agency_sup_state'] == -1 ? null : $_REQUEST['agency_sup_state'];
         $agency->supervisor_country = 'United States';
     }
     $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name'];
     $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name'];
     $agency->supervisor_title = $_REQUEST['agency_sup_title'];
     $agency->supervisor_phone = $_REQUEST['agency_sup_phone'];
     $agency->supervisor_email = $_REQUEST['agency_sup_email'];
     $agency->supervisor_fax = $_REQUEST['agency_sup_fax'];
     $agency->supervisor_address = $_REQUEST['agency_sup_address'];
     $agency->supervisor_city = $_REQUEST['agency_sup_city'];
     $agency->supervisor_zip = $_REQUEST['agency_sup_zip'];
     $agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f';
     try {
         $agencyId = $agency->save();
     } catch (Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         PHPWS_DB::rollback();
         throw $e;
     }
     /**********************************
      * Create and/or save the Internship
      */
     if (isset($_REQUEST['internship_id']) && $_REQUEST['internship_id'] != '') {
         // User is editing internship
         try {
             PHPWS_Core::initModClass('intern', 'InternshipFactory.php');
             $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     } else {
         $i = new Internship();
     }
     $i->term = $_REQUEST['term'];
     $i->agency_id = $agencyId;
     $i->faculty_id = $_REQUEST['faculty_id'] > 0 ? $_REQUEST['faculty_id'] : null;
     $i->department_id = $_REQUEST['department'];
     $i->start_date = !empty($_REQUEST['start_date']) ? strtotime($_REQUEST['start_date']) : 0;
     $i->end_date = !empty($_REQUEST['end_date']) ? strtotime($_REQUEST['end_date']) : 0;
     // Credit hours must be an integer (because of database column type),
     // so round the credit hours to nearest int
     if (isset($_REQUEST['credits'])) {
         $i->credits = round($_REQUEST['credits']);
     }
     $avg_hours_week = (int) $_REQUEST['avg_hours_week'];
     $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null;
     $i->paid = $_REQUEST['payment'] == 'paid';
     $i->stipend = isset($_REQUEST['stipend']) && $i->paid;
     $i->unpaid = $_REQUEST['payment'] == 'unpaid';
     $i->pay_rate = $_REQUEST['pay_rate'];
     // Internship experience type
     if (isset($_REQUEST['experience_type'])) {
         $i->setExperienceType($_REQUEST['experience_type']);
     }
     // Set fields depending on domestic/international
     if ($_REQUEST['location'] == 'domestic') {
         // Set Flags
         $i->domestic = 1;
         $i->international = 0;
         // Set state
         if ($_POST['loc_state'] != '-1') {
             $i->loc_state = strip_tags($_POST['loc_state']);
         } else {
             $i->loc_state = null;
         }
         // Clear province, country
         $i->loc_province = '';
         $i->loc_country = '';
     } else {
         if ($_REQUEST['location'] == 'internat') {
             // Set flags
             $i->domestic = 0;
             $i->international = 1;
             // Set province, country
             $i->loc_province = $_POST['loc_province'];
             $i->loc_country = strip_tags($_POST['loc_country']);
             // Clear state
             $i->loc_state = null;
         }
     }
     // Address, city, zip are always set (no matter domestic or international)
     $i->loc_address = strip_tags($_POST['loc_address']);
     $i->loc_city = strip_tags($_POST['loc_city']);
     $i->loc_zip = strip_tags($_POST['loc_zip']);
     if (isset($_POST['course_subj']) && $_POST['course_subj'] != '-1') {
         $i->course_subj = strip_tags($_POST['course_subj']);
     } else {
         $i->course_subj = null;
     }
     // Course info
     $i->course_no = strip_tags($_POST['course_no']);
     $i->course_sect = strip_tags($_POST['course_sect']);
     $i->course_title = strip_tags($_POST['course_title']);
     // Multipart course
     if (isset($_POST['multipart'])) {
         $i->multi_part = 1;
     } else {
         $i->multi_part = 0;
     }
     if (isset($_POST['multipart']) && isset($_POST['secondary_part'])) {
         $i->secondary_part = 1;
     } else {
         $i->secondary_part = 0;
     }
     // Corequisite Course Info
     if (isset($_POST['corequisite_course_num'])) {
         $i->corequisite_number = $_POST['corequisite_course_num'];
     }
     if (isset($_POST['corequisite_course_sect'])) {
         $i->corequisite_section = $_POST['corequisite_course_sect'];
     }
     // Student Information
     $i->first_name = $_REQUEST['student_first_name'];
     $i->middle_name = $_REQUEST['student_middle_name'];
     $i->last_name = $_REQUEST['student_last_name'];
     $i->setFirstNameMetaphone($_REQUEST['student_first_name']);
     $i->setLastNameMetaphone($_REQUEST['student_last_name']);
     $i->banner = $_REQUEST['banner'];
     $i->phone = $_REQUEST['student_phone'];
     $i->email = $_REQUEST['student_email'];
     $i->level = $_REQUEST['student_level'];
     // Check the level and record the major/program for this level.
     // Be sure to set/clear the other leve's major/program to null
     // in case the user is switching levels.
     if ($i->getLevel() == 'ugrad') {
         $i->ugrad_major = $_REQUEST['ugrad_major'];
         $i->grad_prog = null;
     } else {
         if ($i->getLevel() == 'grad') {
             $i->grad_prog = $_REQUEST['grad_prog'];
             $i->ugrad_major = null;
         }
     }
     $i->gpa = $_REQUEST['student_gpa'];
     $i->campus = $_REQUEST['campus'];
     $i->student_address = $_REQUEST['student_address'];
     $i->student_city = $_REQUEST['student_city'];
     if ($_REQUEST['student_state'] != '-1') {
         $i->student_state = $_REQUEST['student_state'];
     } else {
         $i->student_state = "";
     }
     $i->student_zip = $_REQUEST['student_zip'];
     /*
     $i->emergency_contact_name = $_REQUEST['emergency_contact_name'];
     $i->emergency_contact_relation = $_REQUEST['emergency_contact_relation'];
     $i->emergency_contact_phone = $_REQUEST['emergency_contact_phone'];
     */
     /************
      * OIED Certification
      */
     // If OIED certification has changed, then double check permissions
     $cert = $i->oied_certified == 1 ? true : false;
     $certSubmitted = $_POST['oied_certified_hidden'] == 'true' ? true : false;
     $certChanged = $cert != $certSubmitted;
     if ($certChanged && !Current_User::allow('intern', 'oied_certify')) {
         $url = "index.php?module=intern&action=edit_internship&internship_id={$i->getId()}";
         NQ::simple('intern', INTERN_ERROR, "You do not have permission to change the OIED certification checkbox. No changes were saved.");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Check if this has changed from non-certified->certified so we can log it later
     if ($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true') {
         // note the change for later
         $oiedCertified = true;
     } else {
         $oiedCertified = false;
     }
     if ($_POST['oied_certified_hidden'] == 'true') {
         $i->oied_certified = 1;
     } else {
         if ($_POST['oied_certified_hidden'] == 'false') {
             $i->oied_certified = 0;
         } else {
             $i->oied_certified = 0;
         }
     }
     // If we don't have a state and this is a new internship,
     // the set an initial state
     if ($i->id == 0 && is_null($i->state)) {
         PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
         $state = WorkflowStateFactory::getState('CreationState');
         $i->setState($state);
         // Set this initial value
     }
     try {
         $i->save();
     } catch (Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         PHPWS_DB::rollback();
         throw $e;
     }
     PHPWS_DB::commit();
     /***************************
      * State/Workflow Handling *
      ***************************/
     PHPWS_Core::initModClass('intern', 'WorkflowController.php');
     PHPWS_Core::initModClass('intern', 'WorkflowTransitionFactory.php');
     $t = WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']);
     $workflow = new WorkflowController($i, $t);
     try {
         $workflow->doTransition(isset($_POST['notes']) ? $_POST['notes'] : null);
     } catch (MissingDataException $e) {
         NQ::simple('intern', INTERN_ERROR, $e->getMessage());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     }
     // Create a ChangeHisotry for the OIED certification.
     if ($oiedCertified) {
         $currState = WorkflowStateFactory::getState($i->getStateName());
         $ch = new ChangeHistory($i, Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED');
         $ch->save();
     }
     $workflow->doNotification(isset($_POST['notes']) ? $_POST['notes'] : null);
     if (isset($_REQUEST['internship_id'])) {
         // Show message if user edited internship
         NQ::simple('intern', INTERN_SUCCESS, 'Saved internship for ' . $i->getFullName());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     } else {
         NQ::simple('intern', INTERN_SUCCESS, 'Added internship for ' . $i->getFullName());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     }
 }
예제 #12
0
 public function admin()
 {
     if (!Current_User::allow('pagesmith')) {
         Current_User::disallow();
     }
     $this->loadPanel();
     $javascript = false;
     switch ($_REQUEST['aop']) {
         case 'block_info':
             $this->getTextBlockData($_GET['bid'], $_GET['pid'], $_GET['section_id']);
             exit;
         case 'save_block':
             $this->saveBlockData($_POST['pid'], $_POST['bid'], $_POST['section_id'], $_POST['content']);
             PHPWS_Cache::clearCache();
             exit;
         case 'get_undo':
             $this->getLastUndo($_GET['pid'], $_GET['bid'], $_GET['section_id']);
             exit;
         case 'menu':
             $this->loadForms();
             if (!isset($_GET['tab'])) {
                 $tab = $this->panel->getCurrentTab();
             } else {
                 $tab =& $_GET['tab'];
             }
             switch ($tab) {
                 case 'new':
                     $this->resetUndoSession(0);
                     $this->clearPageSession();
                     $this->loadPage();
                     $this->forms->editPage();
                     break;
                 case 'list':
                     $this->forms->pageList();
                     break;
                 case 'settings':
                     if (!Current_User::allow('pagesmith', null, null, null, true)) {
                         Current_User::disallow();
                     }
                     $this->forms->settings();
                     break;
             }
             break;
         case 'edit_page':
             $this->resetUndoSession(0);
             $this->loadPage();
             if (!$this->page->id) {
                 $this->title = dgettext('pagesmith', 'Sorry');
                 $this->content = dgettext('pagesmith', 'Page not found');
                 break;
             }
             $this->loadForms();
             if (!Current_User::allow('pagesmith', 'edit_page', $this->page->id)) {
                 Current_User::disallow();
             }
             $this->page->loadSections(true);
             $this->forms->pageLayout();
             break;
         case 'pick_template':
             $this->resetUndoSession(0);
             $this->loadForms();
             $this->loadPage();
             $this->page->loadTemplate();
             $this->page->loadSections(true);
             $this->killSaved($this->page->id);
             $this->forms->editPage();
             break;
         case 'delete_page':
             if (!Current_User::authorized('pagesmith', 'delete_page')) {
                 Current_User::disallow();
             }
             $this->loadPage();
             $this->page->delete();
             PHPWS_Cache::clearCache();
             $this->loadForms();
             $this->forms->pageList();
             break;
         case 'edit_page_header':
             $this->loadPage();
             $this->loadForms();
             $this->forms->editPageHeader();
             $javascript = true;
             break;
         case 'delete_section':
             $this->deleteSection($_GET['sec_id']);
             exit;
             break;
         case 'post_header':
             $this->postHeader();
             break;
         case 'post_text':
             $this->postText();
             break;
         case 'post_page':
             $result = $this->postPage();
             switch ($result) {
                 case -1:
                     $this->loadForms();
                     $this->page->loadSections(true);
                     $this->forms->editPage();
                     break;
                 case 0:
                     $this->message = dgettext('pagesmith', 'Not enough content to create a page.');
                     $this->loadForms();
                     $this->page->loadSections(true);
                     $this->forms->editPage();
                     break;
                 case 1:
                     $this->killSaved($this->page->id);
                     PHPWS_Cache::clearCache();
                     PHPWS_Core::reroute($this->page->url());
                     break;
             }
             break;
         case 'front_page_toggle':
             $db = \Database::newDB();
             $db->addTable('ps_page')->addValue('front_page', 0);
             $db->update();
             $this->loadPage();
             $this->page->front_page = (bool) $_GET['fp'];
             $this->page->save();
             PHPWS_Cache::clearCache();
             $this->removeFromMenu();
             $this->loadForms();
             $this->forms->pageList();
             break;
         case 'shorten_links':
             if (!Current_User::authorized('pagesmith', 'settings', null, null, true)) {
                 Current_User::disallow();
             }
             $this->shortenLinks();
             PHPWS_Core::goBack();
             break;
         case 'lengthen_links':
             if (!Current_User::authorized('pagesmith', 'settings', null, null, true)) {
                 Current_User::disallow();
             }
             $this->lengthenLinks();
             PHPWS_Core::goBack();
             break;
         case 'post_settings':
             if (!Current_User::authorized('pagesmith', 'settings', null, null, true)) {
                 Current_User::disallow();
             }
             $this->postSettings();
             $this->message = dgettext('pagesmith', 'Settings saved');
             $this->loadForms();
             $this->forms->settings();
             break;
         default:
             PHPWS_Core::errorPage('404');
             break;
     }
     if ($javascript) {
         $tpl['TITLE'] = $this->title;
         $tpl['CONTENT'] = $this->content;
         $tpl['MESSAGE'] = $this->message;
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'pagesmith', 'admin_main.tpl'));
     } else {
         Layout::add(PHPWS_ControlPanel::display($this->panel->display($this->content, $this->title, $this->message)));
     }
 }
예제 #13
0
 public static function loadHeaderTags(&$template)
 {
     $page_metatags = null;
     $theme = Layout::getCurrentTheme();
     $key = Key::getCurrent();
     if (Key::checkKey($key, false)) {
         $page_metatags = Layout::getMetaPage($key->id);
         if (PHPWS_Error::isError($page_metatags)) {
             PHPWS_Error::log($page_metatags);
             $page_metatags = null;
         }
     }
     if (!isset($_SESSION['javascript_enabled'])) {
         $jsHead[] = '<noscript><meta http-equiv="refresh" content="0;url=index.php?nojs=1&ret=' . urlencode(PHPWS_Core::getCurrentUrl()) . '"/></noscript>';
     }
     if (isset($_GET['nojs'])) {
         $_SESSION['javascript_enabled'] = false;
         PHPWS_Core::reroute(urldecode($_GET['ret']));
     } elseif (!isset($_SESSION['javascript_enabled'])) {
         $_SESSION['javascript_enabled'] = true;
     }
     if (isset($GLOBALS['Layout_JS'])) {
         foreach ($GLOBALS['Layout_JS'] as $script => $javascript) {
             $jsHead[] = $javascript['head'];
         }
     }
     if (!empty($jsHead)) {
         $template['JAVASCRIPT'] = implode("\n", $jsHead);
     }
     Layout::importStyleSheets();
     Layout::submitHeaders($theme, $template);
     if (!empty($GLOBALS['Layout_Links'])) {
         $template['STYLE'] .= "\n" . implode("\n", $GLOBALS['Layout_Links']);
     }
     $template['METATAGS'] = Layout::getMetaTags($page_metatags);
     if ($page_metatags) {
         $template['PAGE_TITLE'] = $page_metatags['page_title'] . PAGE_TITLE_DIVIDER . $_SESSION['Layout_Settings']->getPageTitle(true);
     } else {
         $template['PAGE_TITLE'] = $_SESSION['Layout_Settings']->getPageTitle();
     }
     $template['ONLY_TITLE'] = $_SESSION['Layout_Settings']->getPageTitle(TRUE);
     // Depricated
     // The Site's Name, as set in Layout 'Meta Tags' interface.
     $template['SITE_NAME'] = $_SESSION['Layout_Settings']->getPageTitle(TRUE);
     $template['BASE'] = Layout::getBase();
     $template['HTTP'] = PHPWS_Core::getHttp();
     // 'http' or 'https'
     // Complete URL of the site's home page
     $template['HOME_URL'] = PHPWS_Core::getHomeHttp(true, true, true);
 }
예제 #14
0
 /**
  * Gets random page from the database
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function random()
 {
     $db = new PHPWS_DB('wiki_pages');
     $db->addOrder('random');
     $db->setLimit(1);
     $db->addColumn('title');
     $result = $db->select('col');
     if (!PHPWS_Error::logIfError($result) && $result != NULL) {
         PHPWS_Core::reroute(PHPWS_Text::linkAddress('wiki', array('page' => $result[0])));
     }
     PHPWS_Core::reroute(PHPWS_Text::linkAddress('wiki'));
 }
예제 #15
0
 /**
  * Handles admin functions outside of file manager.
  * Expects an 'aop' command.
  */
 public function admin()
 {
     $javascript = false;
     // if true, sends to nakedDisplay
     $this->loadPanel();
     if (isset($_REQUEST['aop'])) {
         $aop = $_REQUEST['aop'];
     } else {
         $aop = $this->panel->getCurrentTab();
     }
     if (!Current_User::isLogged()) {
         Current_User::disallow();
         return;
     }
     if ($aop != 'edit_image' && $aop != 'get_images' && !Current_User::allow('filecabinet')) {
         Current_User::disallow();
         return;
     }
     // Requires an unrestricted user
     switch ($aop) {
         case 'delete_folder':
         case 'unpin':
             if (Current_User::isRestricted('filecabinet')) {
                 Current_User::disallow();
             }
     }
     switch ($aop) {
         case 'image':
             $this->panel->setCurrentTab('image');
             $this->title = dgettext('filecabinet', 'Image folders');
             $this->loadForms();
             $this->forms->getFolders(IMAGE_FOLDER);
             break;
         case 'multimedia':
             $this->panel->setCurrentTab('multimedia');
             $this->title = dgettext('filecabinet', 'Multimedia folders');
             $this->loadForms();
             $this->forms->getFolders(MULTIMEDIA_FOLDER);
             break;
         case 'add_folder':
             if (!Current_User::allow('filecabinet', 'edit_folders', null, null, true)) {
                 Current_User::disallow();
             }
             $javascript = true;
             $this->loadFolder();
             $this->addFolder();
             break;
         case 'classify':
             if (!Current_User::isDeity()) {
                 Current_User::errorPage();
             }
             $this->loadForms();
             $this->forms->classifyFileList();
             break;
         case 'classify_action':
             if (!Current_User::isDeity() || !Current_User::verifyAuthKey()) {
                 Current_User::errorPage();
             }
             $this->classifyAction();
             break;
         case 'classify_file':
             if (!Current_User::isDeity() || !Current_User::verifyAuthKey()) {
                 Current_User::disallow();
             }
             $this->loadForms();
             if (!empty($_POST['file_list'])) {
                 $this->forms->classifyFile($_POST['file_list']);
             } elseif (isset($_GET['file'])) {
                 $this->forms->classifyFile($_GET['file']);
             } else {
                 $this->forms->classifyFileList();
             }
             break;
         case 'post_classifications':
             if (!Current_User::isDeity()) {
                 Current_User::errorPage();
             }
             $result = $this->classifyFiles();
             if (is_array($result)) {
                 $this->message = implode('<br />', $result);
             }
             $this->loadForms();
             $this->forms->classifyFileList();
             break;
         case 'unpin':
             if (!Current_User::authorized('filecabinet')) {
                 Current_User::disallow();
             }
             Cabinet::unpinFolder();
             PHPWS_Core::goBack();
             break;
         case 'pin_form':
             $javascript = true;
             @($key_id = (int) $_GET['key_id']);
             if (!$key_id) {
                 javascript('close_refresh', array('refresh' => 0));
                 break;
             }
             $this->loadForms();
             $this->forms->pinFolder($key_id);
             break;
         case 'delete_folder':
             if (!Current_User::authorized('filecabinet', 'delete_folders', null, null, true)) {
                 Current_User::disallow();
             }
             $this->loadFolder();
             $this->folder->delete();
             PHPWS_Core::goBack();
             break;
         case 'delete_incoming':
             if (!Current_User::isDeity()) {
                 Current_User::errorPage();
             }
             $this->deleteIncoming();
             $this->loadForms();
             $this->forms->classifyFileList();
             break;
         case 'document':
             $this->panel->setCurrentTab('document');
             $this->title = dgettext('filecabinet', 'Document folders');
             $this->loadForms();
             $this->forms->getFolders(DOCUMENT_FOLDER);
             break;
         case 'edit_folder_modal':
             $javascript = true;
             $this->loadFolder();
             // permission check in function below
             $this->editFolder(false);
             break;
         case 'edit_folder':
             $javascript = true;
             $this->loadFolder();
             // permission check in function below
             $this->editFolder(true);
             break;
         case 'change_tn':
             $javascript = true;
             $this->changeTN();
             break;
         case 'post_thumbnail':
             $javascript = true;
             if ($this->postTN()) {
                 javascript('close_refresh');
             } else {
                 $this->message = dgettext('filecabinet', 'Could not save thumbnail image.');
                 $this->changeTN();
             }
             break;
         case 'post_folder':
             if (!Current_User::authorized('filecabinet', 'edit_folders')) {
                 Current_User::disallow();
             }
             $this->loadFolder();
             if ($this->folder->post()) {
                 if (!$this->folder->save()) {
                     self::setMessage(dgettext('filecabinet', 'Failed to create folder. Please check your logs.'));
                 }
             } else {
                 self::setMessage(dgettext('filecabinet', 'Failed to create folder. Please check your logs.'));
             }
             if (filter_input(INPUT_POST, 'js') == 1) {
                 javascript('close_refresh');
             } else {
                 PHPWS_Core::goBack();
             }
             break;
         case 'post_allowed_files':
             if (!Current_User::isDeity()) {
                 Current_User::disallow();
             }
             $this->loadForms();
             $this->forms->postAllowedFiles();
             $this->message = dgettext('filecabinet', 'File types saved.');
             $this->title = dgettext('filecabinet', 'Allowed file types');
             $this->content = $this->forms->fileTypes();
             break;
         case 'save_settings':
             if (!Current_User::isDeity()) {
                 Current_User::disallow();
             }
             $this->loadForms();
             $result = $this->forms->saveSettings();
             if (is_array($result)) {
                 $this->message = implode('<br />', $result);
             } else {
                 $this->message = dgettext('filecabinet', 'Settings saved.');
             }
         case 'settings':
             if (!Current_User::isDeity()) {
                 Current_User::disallow();
             }
             $this->loadForms();
             $this->title = dgettext('filecabinet', 'Settings');
             $this->content = $this->forms->settings();
             break;
         case 'view_folder':
             $this->viewFolder();
             break;
         case 'file_types':
             if (!Current_User::isDeity()) {
                 Current_User::disallow();
             }
             $this->loadForms();
             $this->title = dgettext('filecabinet', 'Allowed file types');
             $this->content = $this->forms->fileTypes();
             break;
         case 'fix_document_dir':
             if (!Current_User::isDeity() || !Current_User::verifyAuthKey()) {
                 Current_User::disallow();
             }
             if (strtolower($_GET['confirm']) == 'yes') {
                 $this->fixDocumentDirectories();
             }
             PHPWS_Core::reroute('index.php?module=filecabinet&tab=settings');
     }
     $template['TITLE'] =& $this->title;
     $template['MESSAGE'] =& $this->message;
     $template['CONTENT'] =& $this->content;
     if ($javascript) {
         $main = PHPWS_Template::process($template, 'filecabinet', 'javascript.tpl');
         Layout::nakedDisplay($main);
     } else {
         $main = PHPWS_Template::process($template, 'filecabinet', 'main.tpl');
         $this->panel->setContent($main);
         $finalPanel = $this->panel->display();
         Layout::add(PHPWS_ControlPanel::display($finalPanel));
     }
 }
예제 #16
0
        } catch (Exception $e) {
            $message2 = formatException($e);
            echo "The Intern Inventory has experienced a major internal error.  Attempting to email an admin and then exit.";
            $message = "Something terrible has happened, and the exception catch-all threw an exception.\n\nThe first exception was:\n\n{$message}\n\nThe second exception was:\n\n{$message2}";
            mail('*****@*****.**', 'A Major Intern Inventory Error Has Occurred', $message);
            exit;
        }
    }
}
/**
 * Plug content into TopUI. Show notifications. Add Style.
 */
if (isset($content)) {
    if ($content === false) {
        \NQ::close();
        \PHPWS_Core::reroute('index.php?module=intern');
    }
}
// Add top menu bar to theme
\PHPWS_Core::initModClass('intern', 'UI/TopUI.php');
UI\TopUI::plug();
// Get Notifications, add to layout
$nv = new UI\NotifyUI();
$notifications = $nv->display();
\Layout::add($notifications);
// Add content to Layout
\Layout::addStyle('intern', 'style.css');
\Layout::addStyle('intern', 'tango-icons.css');
\Layout::add($content);
function formatException(Exception $e)
{
예제 #17
0
 public static function sendMessage($message, $command)
 {
     $_SESSION['Search_Message'] = $message;
     PHPWS_Core::reroute('index.php?module=search&command=' . $command);
 }
예제 #18
0
 public static function popUrlHistory()
 {
     if (!isset($_SESSION['PHPWS_UrlHistory']) || count($_SESSION['PHPWS_UrlHistory']) == 0) {
         PHPWS_Core::home();
     }
     PHPWS_Core::reroute(array_pop($_SESSION['PHPWS_UrlHistory']));
 }
예제 #19
0
        } catch (Exception $e) {
            $message2 = formatException($e);
            echo "The AppSync Admin Panel has experienced a major internal error.  Attempting to email an admin and then exit.";
            $message = "Something terrible has happened, and the exception catch-all threw an exception.\n\nThe first exception was:\n\n{$message}\n\nThe second exception was:\n\n{$message2}";
            mail('*****@*****.**', 'A Major AppSync Error Has Occurred', $message);
            exit;
        }
    }
}
/**
 * Plug content into TopUI. Show notifications. Add Style.
 */
if (isset($content)) {
    if ($content === false) {
        \NQ::close();
        \PHPWS_Core::reroute('index.php?module=appsync');
    }
}
// Add top menu bar to theme
// \PHPWS_Core::initModClass('appsync', 'UI/TopUI.php');
// UI\TopUI::plug();
// Get Notifications, add to layout
$nv = new \AppSync\UI\NotifyUI();
$notifications = $nv->display();
\Layout::add($notifications);
// Add content to Layout
\Layout::addStyle('appsync', 'style.css');
\Layout::addStyle('appsync', 'tango-icons.css');
\Layout::add($content);
function formatException(Exception $e)
{
예제 #20
0
 public static function display($content = null, $current_tab = null)
 {
     self::deleteLinksAdmin();
     Layout::addStyle('controlpanel');
     $panel = new PHPWS_Panel('controlpanel');
     $panel->disableSecure();
     $current_mod = PHPWS_Core::getCurrentModule();
     $checkTabs = PHPWS_ControlPanel::loadTabs();
     $panel->setTabs($checkTabs);
     $allLinks = PHPWS_ControlPanel::getAllLinks();
     if (empty($checkTabs)) {
         PHPWS_Error::log(CP_NO_TABS, 'controlpanel', 'display');
         PHPWS_ControlPanel::makeDefaultTabs();
         PHPWS_ControlPanel::reset();
         PHPWS_Core::errorPage();
         exit;
     }
     $defaultTabs = PHPWS_ControlPanel::getDefaultTabs();
     foreach ($defaultTabs as $tempTab) {
         $tabList[] = $tempTab['id'];
     }
     if (!empty($allLinks)) {
         $links = array_keys($allLinks);
         if ($current_mod != 'controlpanel' && !$current_tab) {
             foreach ($allLinks as $key => $tablinks) {
                 foreach ($tablinks as $link) {
                     if ($link->itemname == $current_mod) {
                         $current_tab = $key;
                         break 2;
                     }
                 }
             }
         }
     }
     foreach ($checkTabs as $tab) {
         if ($tab->getItemname() == 'controlpanel' && in_array($tab->id, $tabList) && (!isset($links) || !in_array($tab->id, $links))) {
             $panel->dropTab($tab->id);
         }
     }
     if (empty($panel->tabs)) {
         return dgettext('controlpanel', 'No tabs available in the Control Panel.');
     }
     if (!isset($content) && $current_mod == 'controlpanel') {
         if (isset($allLinks[$panel->getCurrentTab()])) {
             foreach ($allLinks[$panel->getCurrentTab()] as $id => $link) {
                 $link_content[] = $link->view();
             }
             $link_content = PHPWS_Template::process(array('LINKS' => implode('', $link_content)), 'controlpanel', 'links.tpl');
             $panel->setContent($link_content);
         }
     } else {
         $panel->setContent($content);
     }
     if (isset($current_tab)) {
         $panel->setCurrentTab($current_tab);
     }
     if (!isset($panel->tabs[$panel->getCurrentTab()])) {
         return dgettext('controlpanel', 'An error occurred while accessing the Control Panel.');
     }
     $tab = $panel->tabs[$panel->getCurrentTab()];
     $link = str_replace('&amp;', '&', $tab->getLink(false)) . '&tab=' . $tab->id;
     $current_link = str_replace($_SERVER['PHP_SELF'] . '\\?', '', $_SERVER['REQUEST_URI']);
     // Headers to the tab's link if it is not a control panel
     // link tab.
     if (isset($_REQUEST['command']) && $_REQUEST['command'] == 'panel_view' && !preg_match('/controlpanel/', $link) && $link != $current_link) {
         PHPWS_Core::reroute($link);
     }
     return $panel->display();
 }
예제 #21
0
 public function post()
 {
     switch ($_POST['rop']) {
         case 'post_roommate':
             $this->loadUserRoommate();
             if ($this->roommate->post()) {
                 try {
                     $this->roommate->save();
                     $this->setCarryMessage('Roommate saved successfully.');
                     \PHPWS_Core::reroute($this->roommate->viewLink());
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                     \PHPWS_Core::reroute('index.php?module=properties&rop=view');
                 }
             } else {
                 $this->editRoommate();
                 $this->display();
             }
             break;
         case 'send_message':
             if (!$this->sendMessage()) {
                 $this->content = 'Sorry, but we couldn\'t save your message.';
                 return;
             }
             if (!$this->roommate->id) {
                 $this->content = 'Sorry, could not find this roommate. <a href="index.php?module=properties&rop=view">Go back to the list?</a>';
             } else {
                 $this->setCarryMessage('Message sent');
                 \PHPWS_Core::goBack();
             }
             break;
         case 'report_post':
             $this->reportPost();
             \PHPWS_Core::reroute('index.php?module=properties&rop=read_messages');
             break;
     }
 }
예제 #22
0
    /**
     * Controller of user requests. Based on the command request variable
     * defaults to my_page
     */
    public static function userAction()
    {
        $auth = Current_User::getAuthorization();
        $content = $title = null;
        if (isset($_REQUEST['command'])) {
            $command = $_REQUEST['command'];
        } else {
            $command = 'my_page';
        }
        switch ($command) {
            case 'login':
                if (!Current_User::isLogged() && isset($_POST['phpws_username']) && isset($_POST['phpws_password'])) {
                    $result = Current_User::loginUser($_POST['phpws_username'], $_POST['phpws_password']);
                    // here
                    if (!$result) {
                        $title = dgettext('users', 'Login page');
                        $message = dgettext('users', 'Username and password combination not found.');
                        $content = User_Form::loginPage();
                    } elseif (PHPWS_Error::isError($result)) {
                        if (preg_match('/L\\d/', $result->code)) {
                            $title = dgettext('users', 'Sorry');
                            $content = $result->getMessage();
                            $content .= ' ' . sprintf('<a href="mailto:%s">%s</a>', PHPWS_User::getUserSetting('site_contact'), dgettext('users', 'Contact the site administrator'));
                        } else {
                            PHPWS_Error::log($result);
                            $message = dgettext('users', 'A problem occurred when accessing user information. Please try again later.');
                        }
                    } else {
                        Current_User::getLogin();
                        PHPWS_Core::returnToBookmark();
                    }
                } else {
                    PHPWS_Core::errorPage('403');
                }
                break;
                // This is used by auth scripts if they need to return the user to
                // where they left off after redirection to another site for SSO
            // This is used by auth scripts if they need to return the user to
            // where they left off after redirection to another site for SSO
            case 'return_bookmark':
                PHPWS_Core::popUrlHistory();
                break;
                // reset user password
            // reset user password
            case 'rp':
                $user_id = User_Action::checkResetPassword();
                if ($user_id) {
                    $title = dgettext('users', 'Reset my password');
                    $content = User_Form::resetPassword($user_id, $_GET['auth']);
                } else {
                    $title = dgettext('users', 'Sorry');
                    $content = dgettext('users', 'Your password request was not found or timed out. Please apply again.');
                }
                break;
            case 'my_page':
                if ($auth->local_user) {
                    PHPWS_Core::initModClass('users', 'My_Page.php');
                    $my_page = new My_Page();
                    $my_page->main();
                } else {
                    Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'My Page unavailable to remote users.'), 'my_page'));
                }
                break;
            case 'signup_user':
                $title = dgettext('users', 'New Account Sign-up');
                if (Current_User::isLogged()) {
                    $content = dgettext('users', 'You already have an account.');
                    break;
                }
                $user = new PHPWS_User();
                if (PHPWS_User::getUserSetting('new_user_method') == 0) {
                    $content = dgettext('users', 'Sorry, we are not accepting new users at this time.');
                    break;
                }
                $content = User_Form::signup_form($user);
                break;
            case 'submit_new_user':
                $title = dgettext('users', 'New Account Sign-up');
                $user_method = PHPWS_User::getUserSetting('new_user_method');
                if ($user_method == 0) {
                    Current_User::disallow(dgettext('users', 'New user signup not allowed.'));
                    return;
                }
                $user = new PHPWS_User();
                $result = User_Action::postNewUser($user);
                if (is_array($result)) {
                    $content = User_Form::signup_form($user, $result);
                } else {
                    $content = User_Action::successfulSignup($user);
                }
                break;
            case 'logout':
                $auth = Current_User::getAuthorization();
                $auth->logout();
                PHPWS_Core::killAllSessions();
                PHPWS_Core::reroute('index.php?module=users&action=reset');
                break;
            case 'login_page':
                if (Current_User::isLogged()) {
                    PHPWS_Core::home();
                }
                $title = dgettext('users', 'Login Page');
                $content = User_Form::loginPage();
                break;
            case 'confirm_user':
                if (Current_User::isLogged()) {
                    PHPWS_Core::home();
                }
                if (User_Action::confirmUser()) {
                    $title = dgettext('users', 'Welcome!');
                    $content = dgettext('users', 'Your account has been successfully activated. Please log in.');
                } else {
                    $title = dgettext('users', 'Sorry');
                    $content = dgettext('users', 'This authentication does not exist.<br />
 If you did not log in within the time frame specified in your email, please apply for another account.');
                }
                User_Action::cleanUpConfirm();
                break;
            case 'forgot_password':
                if (Current_User::isLogged()) {
                    PHPWS_Core::home();
                }
                $title = dgettext('users', 'Forgot Password');
                $content = User_Form::forgotForm();
                break;
            case 'post_forgot':
                $title = dgettext('users', 'Forgot Password');
                if (ALLOW_CAPTCHA) {
                    PHPWS_Core::initCoreClass('Captcha.php');
                    if (!Captcha::verify()) {
                        $content = dgettext('users', 'Captcha information was incorrect.');
                        $content .= User_Form::forgotForm();
                    } else {
                        if (!User_Action::postForgot($content)) {
                            $content .= User_Form::forgotForm();
                        }
                    }
                } elseif (!User_Action::postForgot($content)) {
                    $content .= User_Form::forgotForm();
                }
                break;
            case 'reset_pw':
                $pw_result = User_Action::finishResetPW();
                switch ($pw_result) {
                    case PHPWS_Error::isError($pw_result):
                        $title = dgettext('users', 'Reset my password');
                        $content = dgettext('users', 'Passwords were not acceptable for the following reason:');
                        $content .= '<br />' . $pw_result->getmessage() . '<br />';
                        $content .= User_Form::resetPassword($_POST['user_id'], $_POST['authhash']);
                        break;
                    case 0:
                        $title = dgettext('users', 'Sorry');
                        $content = dgettext('users', 'A problem occurred when trying to update your password. Please try again later.');
                        break;
                    case 1:
                        PHPWS_Core::home();
                        break;
                }
                break;
            default:
                PHPWS_Core::errorPage('404');
                break;
        }
        if (isset($message)) {
            $tag['MESSAGE'] = $message;
        }
        if (isset($title)) {
            $tag['TITLE'] = $title;
        }
        if (isset($content)) {
            $tag['CONTENT'] = $content;
        }
        if (isset($tag)) {
            $final = PHPWS_Template::process($tag, 'users', 'user_main.tpl');
            Layout::add($final);
        }
    }
예제 #23
0
 public static function admin()
 {
     if (!Current_User::allow('layout')) {
         Current_User::disallow();
     }
     PHPWS_Core::initModClass('controlpanel', 'Panel.php');
     $title = $content = null;
     $panel = Layout_Admin::adminPanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $panel->getCurrentTab();
     }
     switch ($command) {
         case 'arrange':
             $title = dgettext('layout', 'Arrange Layout');
             $content[] = Layout_Admin::arrangeForm();
             break;
         case 'turn_off_box_move':
             Layout::moveBoxes(false);
             PHPWS_Core::goBack();
             break;
         case 'post_style_change':
             $result = Layout_Admin::postStyleChange();
             if (PHPWS_Error::isError($result)) {
                 PHPWS_Error::log($result);
             }
             javascript('close_refresh');
             break;
         case 'reset_boxes':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::resetDefaultBoxes();
             unset($_SESSION['Layout_Settings']);
             PHPWS_Core::reroute('index.php?module=layout&action=admin&authkey=' . Current_User::getAuthKey());
             break;
         case 'move_boxes_on':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::moveBoxes(true);
             PHPWS_Core::goBack();
             break;
         case 'move_boxes_off':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::moveBoxes(false);
             PHPWS_Core::goBack();
             break;
         case 'confirmThemeChange':
             $title = dgettext('layout', 'Themes');
             if (isset($_POST['confirm'])) {
                 Layout_Admin::changeTheme();
                 PHPWS_Core::reroute('index.php?module=layout&action=admin&tab=theme');
                 exit;
             } else {
                 Layout::reset();
             }
             $content[] = Layout_Admin::adminThemes();
             break;
         case 'meta':
             $title = dgettext('layout', 'Edit Meta Tags');
             $content[] = Layout_Admin::metaForm();
             break;
         case 'clear_templates':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             $files = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'templates/cache', false, true);
             if (!empty($files) && is_array($files)) {
                 foreach ($files as $fn) {
                     $delete_cache_path = "templates/cache/{$fn}";
                     if (is_file($delete_cache_path)) {
                         unlink('templates/cache/' . $fn);
                     }
                 }
             }
             PHPWS_Core::goBack();
             break;
         case 'clear_cache':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             PHPWS_Cache::clearCache();
             PHPWS_Core::goBack();
             break;
         case 'moveBox':
             $result = Layout_Admin::moveBox();
             PHPWS_Error::logIfError($result);
             javascript('close_refresh');
             Layout::nakedDisplay();
             break;
         case 'postMeta':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout_Admin::postMeta();
             if (isset($_POST['key_id'])) {
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             }
             Layout::reset();
             $title = dgettext('layout', 'Edit Meta Tags');
             $template['MESSAGE'] = dgettext('layout', 'Meta Tags updated.');
             $content[] = Layout_Admin::metaForm();
             break;
         case 'demo_fail':
             unset($_SESSION['Layout_Settings']);
             Layout::checkSettings();
             PHPWS_Core::reroute('index.php?module=layout&amp;action=admin&amp;command=confirmThemeChange');
             break;
         case 'demo_theme':
             $title = dgettext('layout', 'Confirm Theme Change');
             $content[] = dgettext('layout', 'If you are happy with the change, click the appropiate button.');
             $content[] = dgettext('layout', 'Failure to respond in ten seconds, reverts phpWebSite to the default theme.');
             $content[] = Layout_Admin::confirmThemeChange();
             break;
         case 'postTheme':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             if ($_POST['default_theme'] != $_SESSION['Layout_Settings']->current_theme) {
                 Layout::reset($_POST['default_theme']);
                 PHPWS_Core::reroute('index.php?module=layout&action=admin&command=demo_theme&authkey=' . Current_User::getAuthKey());
             } else {
                 PHPWS_Settings::set('layout', 'include_css_order', (int) $_POST['include_css_order']);
                 PHPWS_Settings::save('layout');
                 $title = dgettext('layout', 'Themes');
                 $content[] = Layout_Admin::adminThemes();
             }
             break;
         case 'theme':
             $title = dgettext('layout', 'Themes');
             $content[] = Layout_Admin::adminThemes();
             break;
         case 'js_style_change':
             $content = Layout_Admin::jsStyleChange();
             if (empty($content)) {
                 javascript('close_refresh');
             }
             Layout::nakedDisplay($content, dgettext('layout', 'Change CSS'));
             break;
         case 'page_meta_tags':
             $content = Layout_Admin::pageMetaTags((int) $_REQUEST['key_id']);
             if (empty($content)) {
                 javascript('close_refresh');
             }
             Layout::nakedDisplay($content, dgettext('layout', 'Set meta tags'));
             break;
         case 'move_popup':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout_Admin::moveBoxMenu();
             break;
     }
     $template['TITLE'] = $title;
     if (isset($content)) {
         $template['CONTENT'] = implode('<br />', $content);
     }
     if (isset($message)) {
         $template['MESSAGE'] = $message;
     }
     $final = PHPWS_Template::process($template, 'layout', 'main.tpl');
     $panel->setContent($final);
     Layout::add(PHPWS_ControlPanel::display($panel->display()));
 }
예제 #24
0
 public function post()
 {
     switch ($_POST['aop']) {
         case 'save_property':
             if (!\Current_User::authorized('properties')) {
                 Current_User::disallow('Action not allowed');
             }
             $this->loadProperty();
             if ($this->property->post()) {
                 try {
                     $this->property->save();
                     $this->setCarryMessage('Property saved successfully.');
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                 }
                 \PHPWS_Core::reroute('index.php?module=properties&aop=properties');
             } else {
                 $this->editProperty();
             }
             break;
         case 'save_contact':
             if (!\Current_User::authorized('properties')) {
                 Current_User::disallow();
             }
             $this->loadContact();
             if ($this->contact->post()) {
                 try {
                     $this->contact->save();
                     if (isset($_POST['contact_contact'])) {
                         $this->emailContact($this->contact->username, $_POST['password'], $_POST['email_address']);
                     }
                     $this->setCarryMessage('Contact saved successfully.');
                     \PHPWS_Core::reroute('index.php?module=properties&aop=contacts');
                 } catch (\Exception $e) {
                     $this->setCarryMessage($e->getMessage());
                     $this->editContact();
                 }
             } else {
                 $this->editContact();
             }
             break;
         case 'post_photo':
             try {
                 $photo = new Photo();
                 $photo->post();
                 $this->setCarryMessage('Photo uploaded');
                 if (isset($_POST['v'])) {
                     $property = new Property($photo->pid);
                     $url = './properties/id/' . $photo->pid . '/photo/1';
                 } else {
                     $url = 'index.php?module=properties&aop=properties&pid=' . $photo->pid;
                 }
                 \PHPWS_Core::reroute($url);
             } catch (\Exception $e) {
                 $this->setCarryMessage($e->getMessage());
                 \PHPWS_Core::goBack();
             }
             break;
         case 'post_settings':
             if ($this->postSettings()) {
                 $this->setCarryMessage('Settings updated');
                 \PHPWS_Core::reroute('index.php?module=properties&aop=settings');
             } else {
                 $this->settingsForm();
             }
             break;
         case 'block_post':
             $this->blockPost();
             $this->viewReported();
             break;
     }
     $this->display();
 }
예제 #25
0
 public static function sendMessage($message, $command = null)
 {
     $_SESSION['block_message'] = $message;
     if (isset($command)) {
         PHPWS_Core::reroute(PHPWS_Text::linkAddress('block', array('action' => $command), TRUE));
     }
 }
예제 #26
0
 public static function autoForward()
 {
     $current_url = PHPWS_Core::getCurrentUrl();
     if (preg_match('@pagesmith/\\d+@', $current_url)) {
         $page_name = str_replace('/', ':', $current_url);
         $db = new PHPWS_DB('access_shortcuts');
         $db->addColumn('keyword');
         $db->addWhere('url', $page_name);
         $db->setLimit(1);
         $keyword = $db->select('one');
         if (!empty($keyword)) {
             PHPWS_Core::reroute($keyword);
             exit;
         }
     }
 }
 public function execute()
 {
     /**************
      * Sanity Checks
      */
     // Required fields check
     $missing = self::checkRequest();
     if (!is_null($missing) && !empty($missing)) {
         // checkRequest returned some missing fields.
         $url = 'index.php?module=intern&action=ShowInternship';
         $url .= '&missing=' . implode('+', $missing);
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Please fill in the highlighted fields.');
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check student email
     if (isset($_REQUEST['student_email']) && preg_match("/@/", $_REQUEST['student_email'])) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=student_email';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The student's email address is invalid. No changes were saved. Enter only the username portion of the student's email address. The '@appstate.edu' portion is not necessary.");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check student zip
     if (isset($_REQUEST['student_zip']) && $_REQUEST['student_zip'] != "" && !preg_match('/^[\\d]{5}$|^[\\d]{5}-[\\d]{4}$/', $_REQUEST['student_zip'])) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=student_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The student's zip code is invalid. No changes were saved. The zip code should be 5 digits (no letters, spaces, or punctuation), OR use the extended nine digit form (e.g. 28608-1234).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Course start date must be before end date
     if (!empty($_REQUEST['start_date']) && !empty($_REQUEST['end_date'])) {
         $start = strtotime($_REQUEST['start_date']);
         $end = strtotime($_REQUEST['end_date']);
         if ($start > $end) {
             $url = 'index.php?module=intern&action=ShowInternship&missing=start_date+end_date';
             // Restore the values in the fields the user already entered
             unset($_POST['start_date']);
             unset($_POST['end_date']);
             foreach ($_POST as $key => $val) {
                 $url .= "&{$key}={$val}";
             }
             \NQ::simple('intern', Intern\NotifyUI::WARNING, 'The internship start date must be before the end date.');
             \NQ::close();
             return \PHPWS_Core::reroute($url);
         }
     }
     // Sanity check internship location zip
     if (isset($_REQUEST['loc_zip']) && $_REQUEST['loc_zip'] != "" && !is_numeric($_REQUEST['loc_zip'])) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=loc_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The internship location's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check agency zip
     if (isset($_REQUEST['agency_zip']) && $_REQUEST['agency_zip'] != "" && !is_numeric($_REQUEST['agency_zip'])) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=agency_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The agency's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check supervisor's zip
     if (isset($_REQUEST['agency_sup_zip']) && $_REQUEST['agency_sup_zip'] != "" && !is_numeric($_REQUEST['agency_sup_zip'])) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=agency_sup_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The agency supervisor's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check course number
     if (isset($_REQUEST['course_no']) && $_REQUEST['course_no'] != '' && (strlen($_REQUEST['course_no']) > 20 || !is_numeric($_REQUEST['course_no']))) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=course_no';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The course number provided is invalid. No changes were saved. Course numbers should be less than 20 digits (no letters, spaces, or punctuation).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     \PHPWS_DB::begin();
     /********************************
      * Load the existing internship *
      */
     try {
         $i = \Intern\InternshipFactory::getInternshipById($_REQUEST['internship_id']);
     } catch (\Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         \PHPWS_DB::rollback();
         throw $e;
     }
     // Load the student object
     try {
         $student = StudentProviderFactory::getProvider()->getStudent($i->getBannerId(), $i->getTerm());
     } catch (StudentNotFoundException $e) {
         $student = null;
         \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a matching student in Banner. Your changes were saved, but this student probably needs to contact the Registrar's Office to re-enroll.");
         \NQ::close();
     }
     $i->faculty_id = $_REQUEST['faculty_id'] > 0 ? $_REQUEST['faculty_id'] : null;
     $i->department_id = $_REQUEST['department'];
     $i->start_date = !empty($_REQUEST['start_date']) ? strtotime($_REQUEST['start_date']) : 0;
     $i->end_date = !empty($_REQUEST['end_date']) ? strtotime($_REQUEST['end_date']) : 0;
     $i->credits = $_REQUEST['credits'] != '' ? (int) $_REQUEST['credits'] : null;
     $avg_hours_week = (int) $_REQUEST['avg_hours_week'];
     $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null;
     $i->paid = $_REQUEST['payment'] == 'paid';
     $i->stipend = isset($_REQUEST['stipend']) && $i->paid;
     $i->pay_rate = $_REQUEST['pay_rate'];
     // Internship experience type
     if (isset($_REQUEST['experience_type'])) {
         $i->setExperienceType($_REQUEST['experience_type']);
     }
     if ($i->isInternational()) {
         // Set province
         $i->loc_province = $_POST['loc_province'];
     }
     // Address, city, zip are always set (no matter domestic or international)
     $i->loc_address = strip_tags($_POST['loc_address']);
     $i->loc_city = strip_tags($_POST['loc_city']);
     $i->loc_zip = strip_tags($_POST['loc_zip']);
     if (isset($_POST['course_subj']) && $_POST['course_subj'] != '-1') {
         $i->course_subj = strip_tags($_POST['course_subj']);
     } else {
         $i->course_subj = null;
     }
     // Course info
     $i->course_no = strip_tags($_POST['course_no']);
     $i->course_sect = strip_tags($_POST['course_sect']);
     $i->course_title = strip_tags($_POST['course_title']);
     // Multipart course
     if (isset($_POST['multipart'])) {
         $i->multi_part = 1;
     } else {
         $i->multi_part = 0;
     }
     if (isset($_POST['multipart']) && isset($_POST['secondary_part'])) {
         $i->secondary_part = 1;
     } else {
         $i->secondary_part = 0;
     }
     // Corequisite Course Info
     if (isset($_POST['corequisite_course_num'])) {
         $i->corequisite_number = $_POST['corequisite_course_num'];
     }
     if (isset($_POST['corequisite_course_sect'])) {
         $i->corequisite_section = $_POST['corequisite_course_sect'];
     }
     // Student Information
     $i->first_name = $_REQUEST['student_first_name'];
     $i->middle_name = $_REQUEST['student_middle_name'];
     $i->last_name = $_REQUEST['student_last_name'];
     $i->setFirstNameMetaphone($_REQUEST['student_first_name']);
     $i->setMiddleNameMetaphone($_REQUEST['student_middle_name']);
     $i->setLastNameMetaphone($_REQUEST['student_last_name']);
     $i->phone = $_REQUEST['student_phone'];
     $i->email = $_REQUEST['student_email'];
     $i->student_address = $_REQUEST['student_address'];
     $i->student_city = $_REQUEST['student_city'];
     if ($_REQUEST['student_state'] != '-1') {
         $i->student_state = $_REQUEST['student_state'];
     } else {
         $i->student_state = "";
     }
     $i->student_zip = $_REQUEST['student_zip'];
     // Student major handling, if more than one major
     // Make sure we have a student object, since it could be null if the Banner lookup failed
     if (isset($student) && $student != null) {
         $majors = $student->getMajors();
     } else {
         $majors = array();
     }
     if (sizeof($majors) > 1) {
         if (!isset($_POST['major_code'])) {
             // Student has multiple majors, but user didn't choose one, so just take the first one
             $i->major_code = $majors[0]->getCode();
             $i->major_description = $majors[0]->getDescription();
         } else {
             // User choose a major, so loop over the set of majors until we find the matching major code
             $code = $_POST['major_code'];
             foreach ($majors as $m) {
                 if ($m->getCode() == $code) {
                     $major = $m;
                     break;
                 }
             }
             $i->major_code = $major->getCode();
             $i->major_description = $major->getDescription();
         }
     } else {
         if (sizeof($majors) == 1) {
             // Student has exactly one major
             $i->major_code = $majors[0]->getCode();
             $i->major_description = $majors[0]->getDescription();
         }
     }
     /************
      * OIED Certification
      */
     // Check if this has changed from non-certified->certified so we can log it later
     if ($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true') {
         // note the change for later
         $oiedCertified = true;
     } else {
         $oiedCertified = false;
     }
     if ($_POST['oied_certified_hidden'] == 'true') {
         $i->oied_certified = 1;
     } else {
         if ($_POST['oied_certified_hidden'] == 'false') {
             $i->oied_certified = 0;
         } else {
             $i->oied_certified = 0;
         }
     }
     // If we don't have a state and this is a new internship,
     // the set an initial state
     if ($i->id == 0 && is_null($i->state)) {
         $state = WorkflowStateFactory::getState('CreationState');
         $i->setState($state);
         // Set this initial value
     }
     try {
         $i->save();
     } catch (\Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         \PHPWS_DB::rollback();
         throw $e;
     }
     // Update agency
     try {
         $agency = AgencyFactory::getAgencyById($_REQUEST['agency_id']);
     } catch (\Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         \PHPWS_DB::rollback();
         throw $e;
     }
     // Agency Info
     $agency->name = $_REQUEST['agency_name'];
     $agency->address = $_REQUEST['agency_address'];
     $agency->city = $_REQUEST['agency_city'];
     $agency->zip = $_REQUEST['agency_zip'];
     $agency->phone = $_REQUEST['agency_phone'];
     if ($i->isDomestic()) {
         $agency->state = $_REQUEST['agency_state'] == '-1' ? null : $_REQUEST['agency_state'];
     } else {
         $agency->province = $_REQUEST['agency_province'];
         $agency->country = $_REQUEST['agency_country'] == '-1' ? null : $_REQUEST['agency_country'];
     }
     // Agency Supervisor Info
     $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name'];
     $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name'];
     $agency->supervisor_title = $_REQUEST['agency_sup_title'];
     $agency->supervisor_phone = $_REQUEST['agency_sup_phone'];
     $agency->supervisor_email = $_REQUEST['agency_sup_email'];
     $agency->supervisor_fax = $_REQUEST['agency_sup_fax'];
     $agency->supervisor_address = $_REQUEST['agency_sup_address'];
     $agency->supervisor_city = $_REQUEST['agency_sup_city'];
     $agency->supervisor_zip = $_REQUEST['agency_sup_zip'];
     if ($i->isDomestic()) {
         $agency->supervisor_state = $_REQUEST['agency_sup_state'];
     } else {
         $agency->supervisor_province = $_REQUEST['agency_sup_province'];
         $agency->supervisor_country = $_REQUEST['agency_sup_country'] == '-1' ? null : $_REQUEST['agency_sup_country'];
     }
     $agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f';
     try {
         DatabaseStorage::save($agency);
     } catch (\Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         \PHPWS_DB::rollback();
         throw $e;
     }
     /***************************
      * State/Workflow Handling *
      ***************************/
     $t = \Intern\WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']);
     $workflow = new \Intern\WorkflowController($i, $t);
     try {
         $workflow->doTransition(isset($_POST['notes']) ? $_POST['notes'] : null);
     } catch (\Intern\Exception\MissingDataException $e) {
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $e->getMessage());
         \NQ::close();
         return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id);
     }
     // Create a ChangeHisotry for the OIED certification.
     if ($oiedCertified) {
         $currState = WorkflowStateFactory::getState($i->getStateName());
         $ch = new ChangeHistory($i, \Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED');
         $ch->save();
     }
     \PHPWS_DB::commit();
     $workflow->doNotification(isset($_POST['notes']) ? $_POST['notes'] : null);
     //var_dump($_POST['generateContract']);exit;
     // If the user clicked the 'Generate Contract' button, then redirect to the PDF view
     if (isset($_POST['generateContract']) && $_POST['generateContract'] == 'true') {
         //return \PHPWS_Core::reroute('index.php?module=intern&action=pdf&internship_id=' . $i->id);
         echo json_encode($i);
         exit;
     } else {
         // Otherwise, redirect to the internship edit view
         // Show message if user edited internship
         \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Saved internship for ' . $i->getFullName());
         \NQ::close();
         return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id);
     }
 }
예제 #28
0
 public function sendMessage($message, $location = null)
 {
     $_SESSION['Calendar_Admin_Message'] = $message;
     if (empty($location)) {
         PHPWS_Core::goBack();
     } else {
         PHPWS_Core::reroute('index.php?module=calendar&' . $location);
         exit;
     }
 }
예제 #29
0
 public static function sendMessage($message, $command)
 {
     $_SESSION['RSS_Message'] = $message;
     PHPWS_Core::reroute(sprintf('index.php?module=rss&command=%s&authkey=%s', $command, Current_User::getAuthKey()));
 }
예제 #30
0
 public function display()
 {
     javascript('jquery');
     \Layout::addPageTitle('Search Results');
     // Initalize variables
     $dept = null;
     $term = null;
     $name = null;
     $ugradMajor = null;
     $gradProg = null;
     $level = null;
     $campus = null;
     $type = null;
     $loc = null;
     $state = null;
     $country = null;
     $workflowState = null;
     $courseSubject = null;
     $courseNum = null;
     $courseSect = null;
     /**
      * Check if any search fields are set.
      * This is a pretty nasty block of code...
      */
     if (isset($_REQUEST['dept'])) {
         $dept = $_REQUEST['dept'];
     }
     if (isset($_REQUEST['term_select'])) {
         $term = $_REQUEST['term_select'];
     }
     if (isset($_REQUEST['name'])) {
         $name = $_REQUEST['name'];
     }
     if (isset($_REQUEST['undergrad_major'])) {
         $ugradMajor = $_REQUEST['undergrad_major'];
     }
     if (isset($_REQUEST['graduate_major'])) {
         $gradProg = $_REQUEST['graduate_major'];
     }
     if (isset($_REQUEST['student_level']) && $_REQUEST['student_level'] != '-1') {
         $level = $_REQUEST['student_level'];
     }
     if (isset($_REQUEST['type'])) {
         $type = $_REQUEST['type'];
     }
     if (isset($_REQUEST['campus'])) {
         $campus = $_REQUEST['campus'];
     }
     if (isset($_REQUEST['location'])) {
         $loc = $_REQUEST['location'];
     }
     if (isset($_REQUEST['state'])) {
         $state = $_REQUEST['state'];
     }
     if (isset($_REQUEST['country'])) {
         $country = $_REQUEST['country'];
     }
     if (isset($_REQUEST['workflow_state'])) {
         $workflowState = $_REQUEST['workflow_state'];
     }
     if (isset($_REQUEST['course_subj'])) {
         $courseSubject = $_REQUEST['course_subj'];
     }
     if (isset($_REQUEST['course_no'])) {
         $courseNum = $_REQUEST['course_no'];
     }
     if (isset($_REQUEST['course_sect'])) {
         $courseSect = $_REQUEST['course_sect'];
     }
     /* Get Pager */
     $pager = self::getPager($name, $dept, $term, $ugradMajor, $gradProg, $level, $type, $campus, $loc, $state, $country, $workflowState, $courseSubject, $courseNum, $courseSect);
     $pagerContent = $pager->get();
     // If there were no results, send the user back to the search interface
     if ($pager->total_rows == 0) {
         \NQ::simple('intern', NotifyUI::WARNING, "There were no internships that matched your search criteria. If you're looking for a specific student double check the student's name, id number, or email address. Otherwise, try selecting less search criteria and then search again.");
         \NQ::close();
         // Rebuild the URL
         $url = 'index.php?module=intern&action=search&';
         unset($_REQUEST['action']);
         unset($_REQUEST['module']);
         $url .= http_build_query($_REQUEST);
         return \PHPWS_Core::reroute($url);
     }
     return $pagerContent;
 }