Esempio n. 1
0
 public static function rememberMe()
 {
     // User must authorize locally
     if (PHPWS_Settings::get('users', 'allow_remember') && $_SESSION['User']->authorize == 1) {
         if (isset($_POST['remember_me'])) {
             $db = new PHPWS_DB('user_authorization');
             $db->addColumn('password');
             $db->addWhere('username', $_SESSION['User']->username);
             $password = $db->select('one');
             if (empty($password)) {
                 return false;
             } elseif (PHPWS_Error::isError($password)) {
                 PHPWS_Error::log($password);
                 return false;
             }
             $remember['username'] = $_SESSION['User']->username;
             $remember['password'] = $password;
             $time_to_live = time() + 86400 * REMEMBER_ME_LIFE;
             PHPWS_Cookie::write('remember_me', serialize($remember), $time_to_live);
         } else {
             PHPWS_Cookie::delete('remember_me');
         }
     }
 }
Esempio n. 2
0
 public static function getUserType()
 {
     if ($user_type = PHPWS_Cookie::read('phpws_editor')) {
         if ($user_type == 'none') {
             return null;
         }
         // prevent shenanigans
         if (preg_match('/\\W/', $user_type)) {
             return DEFAULT_EDITOR_TOOL;
         }
         if (Editor::isType($user_type)) {
             return $user_type;
         } else {
             PHPWS_Cookie::delete('phpws_editor');
         }
     }
     return DEFAULT_EDITOR_TOOL;
 }
Esempio n. 3
0
 public function clearSearch()
 {
     unset($_SESSION['roommate_search']);
     \PHPWS_Cookie::delete('roommate_search');
     $this->loadSearchParameters();
 }
Esempio n. 4
0
 public function process()
 {
     if (!Current_User::allow('checkin')) {
         Current_User::disallow();
     }
     if (isset($_REQUEST['aop'])) {
         if ($_REQUEST['aop'] == 'switch') {
             if (Current_User::allow('checkin', 'settings')) {
                 $cmd = 'settings';
             } elseif (Current_User::allow('checkin', 'assign_visitors')) {
                 $cmd = 'assign';
             } else {
                 $cmd = 'waiting';
             }
         } else {
             $cmd = $_REQUEST['aop'];
         }
     } elseif ($_REQUEST['tab']) {
         $cmd = $_REQUEST['tab'];
     } else {
         PHPWS_Core::errorPage('404');
     }
     $js = false;
     $js = isset($_GET['print']);
     switch ($cmd) {
         case 'finish_meeting':
             $this->finishMeeting();
             PHPWS_Core::goBack();
             break;
         case 'start_meeting':
             $this->startMeeting();
             PHPWS_Core::goBack();
             break;
         case 'sendback':
             $this->sendBack();
             PHPWS_Core::goBack();
             break;
         case 'unavailable':
             $this->unavailable();
             PHPWS_Core::goBack();
             break;
         case 'available':
             $this->available();
             PHPWS_Core::goBack();
             break;
         case 'report':
             if (!PHPWS_Settings::get('checkin', 'staff_see_reports') && !Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             if (isset($_GET['daily_report'])) {
                 $this->dailyReport(isset($_GET['print']));
             } elseif (isset($_GET['summary_report'])) {
                 $this->summaryReport();
             } else {
                 $this->report();
             }
             //$this->report2();
             break;
         case 'daily_report':
             if (!PHPWS_Settings::get('checkin', 'staff_see_reports') && !Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             break;
         case 'month_report':
             if (!Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             $this->monthReport(isset($_GET['print']));
             break;
         case 'visitor_report':
             if (!Current_User::allow('checkin', 'assign_visitors')) {
                 Current_User::disallow();
             }
             $this->visitorReport(isset($_GET['print']));
             break;
         case 'reassign':
             // Called via ajax
             if (Current_User::authorized('checkin', 'assign_visitors')) {
                 if (isset($_GET['staff_id']) && $_GET['staff_id'] >= 0 && isset($_GET['visitor_id'])) {
                     $this->loadVisitor($_GET['visitor_id']);
                     $staff_id = $this->visitor->assigned;
                     $db = new PHPWS_DB('checkin_visitor');
                     $db->addValue('assigned', (int) $_GET['staff_id']);
                     $db->addWhere('id', (int) $_GET['visitor_id']);
                     PHPWS_Error::logIfError($db->update());
                     printf('staff_id %s, visitor_id %s', $_GET['staff_id'], $_GET['visitor_id']);
                     $this->loadStaff($staff_id);
                     /*
                      if ($this->staff->status == 3) {
                      $this->staff->status = 0;
                      $this->staff->save();
                      }
                     */
                 }
             }
             exit;
             break;
         case 'move_up':
             if (Current_User::allow('checkin', 'assign_visitors')) {
                 $db = new PHPWS_DB('checkin_staff');
                 $db->moveRow('view_order', 'id', $_GET['staff_id'], 'up');
             }
             PHPWS_Core::goBack();
             break;
         case 'move_down':
             if (Current_User::allow('checkin', 'assign_visitors')) {
                 $db = new PHPWS_DB('checkin_staff');
                 $db->moveRow('view_order', 'id', $_GET['staff_id'], 'down');
             }
             PHPWS_Core::goBack();
             break;
         case 'assign':
             if (Current_User::allow('checkin', 'assign_visitors')) {
                 $this->panel->setCurrentTab('assign');
                 $this->assign();
             }
             break;
         case 'post_note':
             $this->loadVisitor();
             $this->saveNote();
             PHPWS_Core::goBack();
             break;
         case 'hide_panel':
             PHPWS_Cookie::write('checkin_hide_panel', 1);
             PHPWS_Core::goBack();
             break;
         case 'show_panel':
             PHPWS_Cookie::delete('checkin_hide_panel');
             PHPWS_Core::goBack();
             $this->panel->setCurrentTab('assign');
             $this->assign();
             break;
         case 'hide_sidebar':
             PHPWS_Cookie::write('checkin_hide_sidebar', 1);
             PHPWS_Core::goBack();
             $this->panel->setCurrentTab('assign');
             $this->use_sidebar = false;
             $this->assign();
             break;
         case 'show_sidebar':
             PHPWS_Cookie::delete('checkin_hide_sidebar');
             PHPWS_Core::goBack();
             $this->panel->setCurrentTab('assign');
             $this->assign();
             break;
         case 'waiting':
             $this->panel->setCurrentTab('waiting');
             $this->loadCurrentStaff();
             $this->waiting();
             break;
         case 'repeats':
             $this->repeats();
             break;
         case 'small_wait':
             $this->loadCurrentStaff();
             $this->waiting(true);
             $js = true;
             break;
         case 'remove_visitor':
             if (Current_User::allow('checkin', 'remove_visitors')) {
                 $this->removeVisitor();
             }
             PHPWS_Core::goBack();
             break;
         case 'settings':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->panel->setCurrentTab('settings');
                 $this->settings();
             }
             break;
         case 'reasons':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->panel->setCurrentTab('reasons');
                 $this->reasons();
             }
             break;
         case 'post_reason':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->loadReason();
                 if ($this->postReason()) {
                     $this->reason->save();
                     PHPWS_Core::reroute('index.php?module=checkin&tab=reasons');
                 } else {
                     $this->editReason();
                 }
             }
             break;
         case 'staff':
             $this->panel->setCurrentTab('staff');
             $this->staff();
             break;
         case 'edit_staff':
             if (Current_User::allow('checkin', 'settings')) {
                 $this->loadStaff(null, true);
                 $this->editStaff();
             }
             break;
         case 'search_users':
             $this->searchUsers();
             break;
         case 'update_reason':
             if (Current_User::allow('checkin', 'settings')) {
                 if (Current_User::authorized('checkin', 'settings')) {
                     $this->updateReason();
                 }
                 $this->panel->setCurrentTab('settings');
                 $this->settings();
             }
             break;
         case 'post_staff':
             if (!Current_User::authorized('checkin', 'settings')) {
                 Current_User::disallow();
             }
             if ($this->postStaff()) {
                 // save post
                 $this->staff->save();
                 $this->staff->saveReasons();
                 PHPWS_Core::reroute('index.php?module=checkin&tab=staff');
             } else {
                 // post failed
                 $this->loadStaff();
                 $this->editStaff();
             }
             break;
         case 'post_settings':
             // from Checkin_Admin::settings
             if (Current_User::authorized('checkin', 'settings')) {
                 $this->postSettings();
             }
             PHPWS_Core::reroute('index.php?module=checkin&tab=settings');
             break;
         case 'edit_reason':
             $this->loadReason();
             $this->editReason();
             break;
         case 'delete_reason':
             $this->loadReason();
             $this->reason->delete();
             PHPWS_Core::goBack();
             break;
         case 'deactivate_staff':
             PHPWS_Core::initModClass('checkin', 'Staff.php');
             $staff = new Checkin_Staff($_GET['id']);
             $staff->active = 0;
             $staff->save();
             PHPWS_Core::goBack();
             break;
         case 'activate_staff':
             PHPWS_Core::initModClass('checkin', 'Staff.php');
             $staff = new Checkin_Staff($_GET['id']);
             $staff->active = 1;
             $staff->save();
             PHPWS_Core::goBack();
             break;
             // This is for testing purposes and never happens in actual use
         // This is for testing purposes and never happens in actual use
         case 'unassignAll':
             $this->unassignAll();
             break;
             // This is for testing purposes and never happens in actual use
         // This is for testing purposes and never happens in actual use
         case 'auto_assign':
             $this->autoAssign();
             break;
     }
     if (empty($this->content)) {
         $this->content = dgettext('checkin', 'Command not recognized.');
     }
     if ($js) {
         $tpl['TITLE'] =& $this->title;
         $tpl['CONTENT'] =& $this->content;
         $tpl['MESSAGE'] =& $this->message;
         $content = PHPWS_Template::process($tpl, 'checkin', 'main.tpl');
         Layout::nakedDisplay($content, $this->title);
     } else {
         if (is_array($this->message)) {
             $this->message = implode('<br />', $this->message);
         }
         if (!$this->use_sidebar) {
             Layout::collapse();
         }
         if ($this->use_panel) {
             Layout::add(PHPWS_ControlPanel::display($this->panel->display($this->content, $this->title, $this->message)));
         } else {
             $tpl['TITLE'] =& $this->title;
             $tpl['CONTENT'] =& $this->content;
             $tpl['MESSAGE'] =& $this->message;
             Layout::add(PHPWS_Template::process($tpl, 'checkin', 'main.tpl'));
         }
     }
 }