Exemplo n.º 1
0
 public function main()
 {
     $auth = Current_User::getAuthorization();
     if (!Current_User::isLogged() || !$auth->local_user) {
         PHPWS_Core::errorPage('403');
     }
     $result = $this->init();
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'The is a problem with My Page.')));
         return;
     } elseif (!$result) {
         Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'No modules are registered to My Page.')));
         return;
     }
     $panel = My_Page::cpanel();
     $module = $panel->getCurrentTab();
     if (!$this->moduleIsRegistered($module)) {
         Layout::add(dgettext('users', 'This module is not registered with My Page'));
         return;
     }
     $content = My_Page::userOption($module);
     if (PHPWS_Error::isError($content)) {
         $content = $content->getMessage();
     }
     Layout::add(PHPWS_ControlPanel::display($content));
 }
Exemplo n.º 2
0
 public function runTime(\Request $request)
 {
     if (\Current_User::isLogged()) {
         \election\Controller\User::loadNavBar();
     }
     if (\PHPWS_Core::atHome()) {
         \election\Controller\User::welcomeScreen($this);
     }
 }
Exemplo n.º 3
0
 public static function getActive()
 {
     $db = self::initDb();
     $db->addWhere('active', 1);
     // Exclude certain trackers if the user is logged in
     if (Current_User::isLogged()) {
         $db->addWhere('disable_if_logged', 0);
     }
     return self::runQuery($db);
 }
Exemplo n.º 4
0
 public function runTime(\Request $request)
 {
     if (\Current_User::allow('sysinventory')) {
         \systemsinventory\Controller\System::loadAdminBar();
     }
     if (\PHPWS_Core::atHome() && \Current_User::isLogged()) {
         $path = $_SERVER['SCRIPT_NAME'] . '?module=systemsinventory';
         header('HTTP/1.1 303 See Other');
         header("Location: {$path}");
         exit;
     }
 }
Exemplo n.º 5
0
 public function checkinForm()
 {
     $form = new PHPWS_Form('checkin');
     $form->turnOffAutoComplete();
     $form->setProtected(false);
     $form->addHidden('module', 'checkin');
     $form->addHidden('uop', 'post_checkin');
     $form->addText('first_name', isset($_POST['first_name']) ? trim($_POST['first_name']) : null);
     $form->setLabel('first_name', dgettext('checkin', 'First name'));
     $form->setRequired('first_name');
     $form->addText('last_name', isset($_POST['last_name']) ? trim($_POST['last_name']) : null);
     $form->setLabel('last_name', dgettext('checkin', 'Last name'));
     $form->setRequired('last_name');
     if (PHPWS_Settings::get('checkin', 'email')) {
         $form->addText('email', isset($_POST['email']) ? trim($_POST['email']) : null);
         $form->setLabel('email', dgettext('checkin', 'Email address'));
         $form->setRequired('email');
     }
     // If gender is requested
     if (PHPWS_Settings::get('checkin', 'gender')) {
         $sex = array('male' => 'Male', 'female' => 'Female');
         $form->addRadioAssoc('gender', $sex);
         $form->addTplTag('GENDER_LABEL', dgettext('checkin', 'Gender'));
     }
     // If birthdate is requested
     if (PHPWS_Settings::get('checkin', 'birthdate')) {
         /*
          * Minimum representable date is 12-13-1901, and instead of doing 
          * lots of math to ensure that all selected dates in 1901 are after
          * 12-13-1901, just make the minimum year always be 1902
          */
         $yearsPrior = date('Y', time()) - 1902;
         // current year - minimum full year (1902)
         $form->dateSelect('birthdate', 0, '%B', $yearsPrior, 0);
         $form->addTplTag('BIRTHDATE_LABEL', dgettext('checkin', 'Date of birth'));
     }
     $reasons = $this->getReasons();
     if (!empty($reasons)) {
         $reasons = array_reverse($reasons, true);
         $reasons[0] = dgettext('checkin', '-- Please choose a reason from the list below --');
         $reasons = array_reverse($reasons, true);
         $form->addSelect('reason_id', $reasons);
         $form->setLabel('reason_id', dgettext('checkin', 'Reason for visit'));
     }
     $form->addSubmit(dgettext('checkin', 'Check in'));
     $tpl = $form->getTemplate();
     $this->title = dgettext('checkin', 'Please check in using the form below');
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'signin.tpl');
     if (!Current_User::isLogged() && PHPWS_Settings::get('checkin', 'collapse_signin')) {
         Layout::collapse();
     }
 }
Exemplo n.º 6
0
 public function process()
 {
     // This hack is the most awful hack ever.  Fix phpWebSite so that
     // user logins are logged separately.
     if (Current_User::isLogged() && !isset($_SESSION['HMS_LOGGED_THE_LOGIN'])) {
         $username = strtolower(Current_User::getUsername());
         HMS_Activity_Log::log_activity($username, ACTIVITY_LOGIN, $username, NULL);
         $_SESSION['HMS_LOGGED_THE_LOGIN'] = $username;
     }
     if (!Current_User::isLogged() && $this->context->get('action') != 'ShowFrontPage') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must be logged in to do that.');
         $action = 'ShowFrontPage';
     } else {
         $action = $this->context->get('action');
     }
     $cmd = CommandFactory::getCommand($action);
     if (HMS_DEBUG) {
         $cmd->execute($this->context);
     } else {
         try {
             $cmd->execute($this->context);
         } catch (PermissionException $p) {
             NQ::Simple('hms', hms\NotificationView::ERROR, 'You do not have permission to perform that action. If you believe this is an error, please contact University Housing.');
             $nv = new hms\NotificationView();
             $nv->popNotifications();
             Layout::add($nv->show());
         } catch (Exception $e) {
             try {
                 $message = $this->formatException($e);
                 NQ::Simple('hms', hms\NotificationView::ERROR, 'An internal error has occurred, and the authorities have been notified.  We apologize for the inconvenience.');
                 $this->emailError($message);
                 $nv = new hms\NotificationView();
                 $nv->popNotifications();
                 Layout::add($nv->show());
             } catch (Exception $e) {
                 $message2 = $this->formatException($e);
                 echo "HMS 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(FROM_ADDRESS, 'A Major HMS Error Has Occurred', $message);
                 exit;
             }
         }
     }
 }
Exemplo n.º 7
0
 private function landing()
 {
     $factory = new Factory();
     if (\Current_User::isLogged()) {
         if (!\Current_User::allow('tailgate') && !$factory->isStudent(\Current_User::getUsername())) {
             return $this->notStudentMessage();
         }
         $student = $factory->getCurrentStudent();
         if ($student) {
             // student is logged in and has account
             return $this->showStatus($student->getId());
         } else {
             // student is logged in but doesn't have an account
             return $this->createAccount();
         }
     } else {
         // student is not logged in
         return $this->newAccountInformation();
     }
 }
Exemplo n.º 8
0
 public static function logBox($logged = TRUE)
 {
     $auth = Current_User::getAuthorization();
     if (PHPWS_Settings::get('users', 'user_menu') == 'none') {
         return null;
     }
     if (Current_User::isLogged()) {
         $username = Current_User::getUsername();
         return User_Form::loggedIn();
     } else {
         if (PHPWS_Settings::get('users', 'show_login')) {
             if ($auth->showLoginForm()) {
                 return User_Form::loggedOut();
             } else {
                 return $auth->getLoginLink();
             }
         } else {
             return NULL;
         }
     }
 }
Exemplo n.º 9
0
 public static function get()
 {
     if (!\Current_User::isLogged()) {
         return;
     }
     $modlist = PHPWS_Core::getModuleNames();
     $tpl['MINIADMIN_TITLE'] = dgettext('miniadmin', 'MiniAdmin');
     $tpl['MINIADMIN_TITLE_ALT'] = dgettext('miniadmin', 'Administrate');
     if (isset($GLOBALS['MiniAdmin'])) {
         foreach ($GLOBALS['MiniAdmin'] as $module => $links) {
             $mod_title = $modlist[$module];
             if (isset($links['title_link'])) {
                 $mod_title = sprintf('<a href="%s">%s</a>', $links['title_link'], $mod_title);
             }
             $module_links[$mod_title] = $links;
         }
         $tpl['module_links'] = $module_links;
     }
     $template = new \Template($tpl);
     $template->setModuleTemplate('miniadmin', MINIADMIN_TEMPLATE);
     $content = $template->get();
     Layout::set($content, 'miniadmin', 'mini_admin');
 }
Exemplo n.º 10
0
 public function userSignup()
 {
     if (!$this->signup->sheet->id) {
         PHPWS_Core::errorPage('404');
     }
     $sheet = $this->signup->sheet;
     $peep = $this->signup->peep;
     if (Current_User::isLogged() && empty($peep->email)) {
         $peep->email = Current_User::getEmail();
     }
     if ($sheet->end_time < time()) {
         $this->signup->title = dgettext('signup', 'Sorry');
         $this->signup->content = dgettext('signup', 'We are no longer accepting applications.');
         return;
     }
     $slots = $sheet->getAllSlots();
     $slots_filled = $sheet->totalSlotsFilled();
     if (empty($slots)) {
         $this->signup->title = dgettext('signup', 'Sorry');
         $this->signup->content = dgettext('signup', 'There is a problem with this signup sheet. Please check back later.');
         return;
     }
     $this->signup->title =& $sheet->title;
     foreach ($slots as $slot) {
         // if the slots are filled, don't offer it
         if ($slots_filled && isset($slots_filled[$slot->id])) {
             $filled =& $slots_filled[$slot->id];
             if ($filled >= $slot->openings) {
                 continue;
             } else {
                 $openings_left = $slot->openings - $filled;
             }
         } else {
             $openings_left =& $slot->openings;
         }
         $options[$slot->id] = sprintf(dngettext('signup', '%s (%s opening)', '%s (%s openings)', $openings_left), $slot->title, $openings_left);
     }
     if (!isset($options)) {
         $this->signup->content = dgettext('signup', 'Sorry, but all available slots are full. Please check back later for possible cancellations.');
         return;
     } else {
         $form = new PHPWS_Form('slots');
         $form->useFieldset();
         $form->setLegend(dgettext('signup', 'Signup form'));
         $form->addHidden('module', 'signup');
         $form->addHidden('uop', 'slot_signup');
         $form->addHidden('sheet_id', $this->signup->sheet->id);
         $form->addSelect('slot_id', $options);
         $form->setLabel('slot_id', dgettext('signup', 'Available slots'));
         $form->setMatch('slot_id', $peep->slot_id);
         $form->addText('first_name', $peep->first_name);
         $form->setLabel('first_name', dgettext('signup', 'First name'));
         $form->addText('last_name', $peep->last_name);
         $form->setLabel('last_name', dgettext('signup', 'Last name'));
         $form->addText('email', $peep->email);
         $form->setSize('email', 30);
         $form->setLabel('email', dgettext('signup', 'Email address'));
         $form->addText('phone', $peep->getPhone());
         $form->setSize('phone', 15);
         $form->setLabel('phone', dgettext('signup', 'Phone number'));
         if (!empty($this->signup->sheet->extra1)) {
             $form->addText('extra1', $peep->extra1);
             $form->setLabel('extra1', $this->signup->sheet->extra1);
         }
         if (!empty($this->signup->sheet->extra2)) {
             $form->addText('extra2', $peep->extra2);
             $form->setLabel('extra2', $this->signup->sheet->extra2);
         }
         if (!empty($this->signup->sheet->extra3)) {
             $form->addText('extra3', $peep->extra3);
             $form->setLabel('extra3', $this->signup->sheet->extra3);
         }
         $form->addSubmit(dgettext('signup', 'Submit'));
         $tpl = $form->getTemplate();
     }
     $tpl['DESCRIPTION'] = $sheet->getDescription();
     $this->signup->content = PHPWS_Template::process($tpl, 'signup', 'signup_form.tpl');
     $this->signup->sheet->flag();
 }
Exemplo n.º 11
0
 function _formAction()
 {
     if (PHATFORM_CAPTCHA) {
         PHPWS_Core::initCoreClass('Captcha.php');
     }
     if (isset($_REQUEST['PHAT_Next'])) {
         if ($this->isSaved()) {
             $error = $this->_saveFormData();
             if (PHPWS_Error::isError($error)) {
                 javascript('alert', array('content' => PHPWS_Error::printError($error)));
             }
         } else {
             $this->_position += $this->_pageLimit;
         }
         if (Current_User::allow('phatform')) {
             $content = $_SESSION['PHAT_FormManager']->menu() . $this->view();
         } else {
             $content = $this->view();
         }
         return $content;
     } elseif (isset($_REQUEST['PHAT_Back'])) {
         $this->_position = $this->_position - $this->_pageLimit;
         if (Current_User::allow('phatform')) {
             $content = $_SESSION['PHAT_FormManager']->menu() . $this->view();
         } else {
             $content = $this->view();
         }
         return $content;
     } elseif ($_REQUEST['PHAT_Submit']) {
         if (PHATFORM_CAPTCHA && $this->_anonymous && !Current_User::isLogged() && !Captcha::verify()) {
             javascript('alert', array('content' => dgettext('phatform', 'CAPTCHA word was not correct.')));
             return $this->view(false);
         }
         if ($this->isSaved()) {
             $error = $this->_saveFormData();
             if (PHPWS_Error::isError($error)) {
                 javascript('alert', array('content' => PHPWS_Error::printError($error)));
                 if (Current_User::allow('phatform')) {
                     $content = $_SESSION['PHAT_FormManager']->menu() . $this->view(false, $error);
                 } else {
                     $content = $this->view(false, $error);
                 }
                 return $content;
             } else {
                 if (Current_User::allow('phatform')) {
                     $content = $_SESSION['PHAT_FormManager']->menu() . $this->_thanks();
                 } else {
                     $content = $this->_thanks();
                 }
                 $this->_emailData();
                 return $content;
             }
         } else {
             $_SESSION['PHAT_FormManager']->_list();
             return NULL;
         }
     }
 }
Exemplo n.º 12
0
 /**
  * added limitations to a select query to only pull rows that
  * the user is allowed to see. This function does does not work alone.
  * it requires a database object to already be started.
  *
  * The user module MUST be active for this function to work.
  * This Key function cannot be called without it.
  *
  * If the user is a deity or an unrestricted user, no change will be made
  * to your db object.
  *
  */
 public static function restrictView($db, $module = null, $check_dates = true, $source_table = null)
 {
     $now = time();
     if (empty($source_table)) {
         $source_table = $db->tables[0];
     }
     if ($source_table == 'phpws_key') {
         if (!isset($db->tables[1])) {
             return PHPWS_Error::get(KEY_RESTRICT_NO_TABLE, 'core', 'Key::restrictView');
         }
         $source_table = $db->tables[1];
         $key_table = true;
     } else {
         $key_table = false;
     }
     if (!$key_table) {
         $db->addJoin('left', $source_table, 'phpws_key', 'key_id', 'id');
     } else {
         $db->addJoin('left', 'phpws_key', $source_table, 'id', 'key_id');
     }
     $db->addWhere("{$source_table}.key_id", '0', null, null, 'base');
     $db->addWhere('phpws_key.active', 1, null, null, 'active');
     $db->groupIn('active', 'base');
     $db->setGroupConj('active', 'or');
     if (Current_User::isDeity() || isset($module) && Current_User::isUnrestricted($module)) {
         return;
     }
     if ($check_dates) {
         $db->addWhere('phpws_key.show_after', $now, '<', null, 'active');
         $db->addWhere('phpws_key.hide_after', $now, '>', null, 'active');
     }
     if (!Current_User::isLogged()) {
         $db->addWhere('phpws_key.restricted', 0, null, 'and', 'active');
         return;
     } else {
         $groups = Current_User::getGroups();
         if (empty($groups)) {
             return;
         }
         $db->addJoin('left', 'phpws_key', 'phpws_key_view', 'id', 'key_id');
         // if key only has a level 1 restriction, a logged user can view it
         $db->addWhere('phpws_key.restricted', KEY_LOGGED_RESTRICTED, '<=', null, 'restrict_1');
         $db->setGroupConj('restrict_1', 'and');
         // at level 2, the user must be in a group given view permissions
         $db->addWhere('phpws_key.restricted', KEY_GROUP_RESTRICTED, '=', null, 'restrict_2');
         $db->addWhere('phpws_key_view.group_id', $groups, 'in', null, 'restrict_2');
         $db->setGroupConj('restrict_2', 'or');
         if (empty($module)) {
             $levels = Current_User::getUnrestrictedLevels();
             if (!empty($levels)) {
                 $db->addWhere('phpws_key.module', $levels, null, null, 'permission');
                 $db->groupIn('permission', 'restrict_2');
             }
         }
         $db->groupIn('restrict_1', 'base');
         $db->groupIn('restrict_2', 'restrict_1');
     }
 }
Exemplo n.º 13
0
    * 
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    * 
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    *
    * @author Jeremy Booker <jbooker at tux dot appstate dot edu>
*/
if (!defined('PHPWS_SOURCE_DIR')) {
    include '../../config/core/404.html';
    exit;
}
# Include configuration and defines
PHPWS_Core::requireInc('faxmaster', 'defines.php');
PHPWS_Core::requireInc('faxmaster', 'errordefines.php');
PHPWS_Core::requireConfig('faxmaster');
Layout::addStyle('faxmaster');
/* The user must be logged in to use this module. So, if
 * there's no user session, or the user is not logged
 * in, then return here
 */
if ((!isset($_SESSION['User']) || !Current_User::isLogged()) && (!isset($_REQUEST['op']) || $_REQUEST['op'] != 'new_fax')) {
    return;
}
# Create the Faxmaster
PHPWS_Core::initModClass('faxmaster', 'Faxmaster.php');
$fm = new Faxmaster();
Exemplo n.º 14
0
 public static function whatsnewBlock()
 {
     if (PHPWS_Settings::get('whatsnew', 'cache_timeout') > 0) {
         $cache_key = 'whatsnew_cache_key';
         $content = PHPWS_Cache::get($cache_key, PHPWS_Settings::get('whatsnew', 'cache_timeout'));
         if (!empty($content)) {
             return $content;
         }
     }
     $link = null;
     $summary = null;
     $date = null;
     $module_name = null;
     $exclude = unserialize(PHPWS_Settings::get('whatsnew', 'exclude'));
     $db = new PHPWS_DB('phpws_key');
     $db->addJoin('left', 'phpws_key', 'modules', 'module', 'title');
     $db->addWhere('active', 1);
     $db->addWhere('restricted', 0);
     if ($exclude) {
         foreach ($exclude as $module) {
             $db->addWhere('module', $module, '!=');
         }
     }
     $db->addOrder('update_date desc');
     $db->setLimit(PHPWS_Settings::get('whatsnew', 'qty_items'));
     $db->setIndexBy('id');
     $db->addColumn('phpws_key.url');
     $db->addColumn('phpws_key.title');
     $db->addColumn('phpws_key.summary');
     $db->addColumn('phpws_key.update_date');
     $db->addColumn('modules.title', null, 'module_title');
     $db->addColumn('modules.proper_name');
     //        $db->setTestMode();
     $result = $db->select();
     $tpl['TITLE'] = PHPWS_Text::parseOutput(PHPWS_Settings::get('whatsnew', 'title'));
     $tpl['TEXT'] = PHPWS_Text::parseOutput(PHPWS_Settings::get('whatsnew', 'text'));
     if (!PHPWS_Error::logIfError($result) && !empty($result)) {
         foreach ($result as $item) {
             $link = '<a href="' . $item['url'] . '">' . $item['title'] . '</a>';
             if (PHPWS_Settings::get('whatsnew', 'show_summaries')) {
                 $summary = PHPWS_Text::parseOutput($item['summary']);
             }
             if (PHPWS_Settings::get('whatsnew', 'show_dates')) {
                 $date = strftime(WHATSNEW_DATE_FORMAT, $item['update_date']);
             }
             if (PHPWS_Settings::get('whatsnew', 'show_source_modules')) {
                 $module_name = dgettext($item['module_title'], PHPWS_Text::parseOutput($item['proper_name']));
             }
             $tpl['new-items'][] = array('LINK' => $link, 'SUMMARY' => $summary, 'DATE' => $date, 'MODULE_NAME' => $module_name);
         }
     } else {
         $tpl['new-items'][] = array('LINK' => dgettext('whatsnew', 'Sorry, no results'));
     }
     $content = PHPWS_Template::process($tpl, 'whatsnew', 'block.tpl');
     if (PHPWS_Settings::get('whatsnew', 'cache_timeout') > 0 && !Current_User::isLogged() && !Current_User::allow('whatsnew')) {
         PHPWS_Cache::save($cache_key, $content);
     }
     return $content;
 }
Exemplo n.º 15
0
 public static function getStudentStatus()
 {
     if (\Current_User::isLogged()) {
         $content = '<a class="btn btn-primary btn-sm" href="./tailgate">Check lottery status</a>';
     } else {
         $content = '<a class="btn btn-primary btn-sm" href="./admin">Login</a>';
     }
     return $content;
 }
Exemplo n.º 16
0
 public function month_list()
 {
     if (PHPWS_Settings::get('calendar', 'use_calendar_style')) {
         Layout::addStyle('calendar');
     }
     $month =& $this->calendar->int_month;
     $year =& $this->calendar->int_year;
     $day = 1;
     if ($this->calendar->schedule->public && !Current_User::isLogged() && PHPWS_Settings::get('calendar', 'cache_month_views')) {
         $cache_key = sprintf('list_%s_%s_%s', $month, $year, $this->calendar->schedule->id);
     }
     if (isset($cache_key)) {
         // Check cache
         $content = PHPWS_Cache::get($cache_key);
         if (!empty($content)) {
             return $content;
         }
     }
     // cache empty, make calendar
     $startdate = mktime(0, 0, 0, $month, 1, $year);
     $enddate = mktime(23, 59, 59, $month + 1, 0, $year);
     $date_pick = $this->getDatePick();
     $this->calendar->loadEventList($startdate, $enddate);
     $tpl = new PHPWS_Template('calendar');
     $tpl->setFile('view/month/list.tpl');
     $events_found = false;
     $lvars = array('view' => 'day', 'schedule_id' => $this->calendar->schedule->id);
     $slink = new PHPWS_Link(null, 'calendar');
     $slink->setNoFollow(PHPWS_Settings::get('calendar', 'no_follow'));
     for ($i = $startdate; $i <= $enddate; $i += 86400) {
         $day_result = $this->getDaysEvents($i, $tpl);
         $lvars['date'] = $i;
         $slink->clearValues();
         $slink->addValues($lvars);
         if ($day_result) {
             $events_found = true;
             $slink->setLabel(strftime('%A', $i));
             $day_tpl['FULL_WEEKDAY'] = $slink->get();
             $slink->setLabel(strftime('%a', $i));
             $day_tpl['ABBR_WEEKDAY'] = $slink->get();
             $slink->setLabel(strftime('%e', $i));
             $day_tpl['DAY_NUMBER'] = $slink->get();
             $tpl->setCurrentBlock('days');
             $tpl->setData($day_tpl);
             $tpl->parseCurrentBlock();
         }
     }
     if (!$events_found) {
         $tpl->setVariable('MESSAGE', dgettext('calendar', 'No events this month.'));
     }
     $main_tpl = $this->viewLinks('list');
     $main_tpl['FULL_MONTH_NAME'] = strftime('%B', mktime(0, 0, 0, $month, $day, $year));
     $main_tpl['ABRV_MONTH_NAME'] = strftime('%b', mktime(0, 0, 0, $month, $day, $year));
     $main_tpl['SCHEDULE_TITLE'] = $this->calendar->schedule->title;
     $main_tpl['FULL_YEAR'] = strftime('%Y', mktime(0, 0, 0, $month, $day, $year));
     $main_tpl['ABRV_YEAR'] = strftime('%y', mktime(0, 0, 0, $month, $day, $year));
     $main_tpl['SCHEDULE_PICK'] = $this->schedulePick();
     $main_tpl['PICK'] = $date_pick;
     $main_tpl['DOWNLOAD'] = $this->downloadLink($startdate, $enddate);
     $main_tpl['SUGGEST'] = $this->suggestLink();
     if ($this->calendar->schedule->checkPermissions()) {
         $main_tpl['ADD_EVENT'] = '<button class="add-event btn btn-success" data-schedule-id="' . $this->calendar->schedule->id . '" data-date="' . $this->calendar->current_date * 1000 . '"><i class="fa fa-plus"></i> Add event</button>';
     }
     $tpl->setData($main_tpl);
     $content = $tpl->get();
     if (isset($cache_key)) {
         PHPWS_Cache::save($cache_key, $content);
     }
     return $content;
 }
Exemplo n.º 17
0
<?php

/**
    *
    * See docs/AUTHORS and docs/COPYRIGHT for relevant info.
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    * 
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    * 
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    *
    * @author Jeremy Booker <jbooker at tux dot appstate dot edu>
*/
//PHPWS_Core::initModClass('skeleton', 'Skeleton_Runtime.php');
//Skeleton_Runtime::showBlock();
if (!isset($_REQUEST['module'])) {
    PHPWS_Core::initModClass('faxmaster', '../index.php');
}
if (!Current_User::isLogged()) {
    Layout::add('<div class="text-center"><a href="secure" class="btn btn-lg btn-primary">Sign In</a></div>');
}
Exemplo n.º 18
0
<?php

/***
 * Commenting this out for now.. Need to test more extensively when we can get r6test updated to latest phpws
if(!Current_User::isLogged() && isset($_SERVER['HTTP_SHIB_EP_PRINCIPALNAME'])) {
    NQ::simple('intern', INTERN_ERROR, "You have successfully signed in, but we have not setup your Internship Inventory account. Please contact the Career Development Center at 828-262-2180.");
    NQ::close();
}
*/
if (PHPWS_Core::atHome() && Current_User::isLogged()) {
    $path = $_SERVER['SCRIPT_NAME'] . '?module=appsync';
    header('HTTP/1.1 303 See Other');
    header("Location: {$path}");
    exit;
}
Exemplo n.º 19
0
 public function authenticate($admin_only = true)
 {
     if (!Current_User::isLogged()) {
         javascript('close_refresh');
         Layout::nakedDisplay(dgettext('filecabinet', 'Cannot access this page.'));
         exit;
     }
     if ($admin_only) {
         return Current_User::allow('filecabinet');
     } else {
         return true;
     }
 }
Exemplo n.º 20
0
 function getHistoryTpl()
 {
     $vars['page'] = $this->getTitle(FALSE);
     $vars['page_op'] = 'viewold';
     $vars['id'] = $this->getId();
     $links[] = PHPWS_Text::moduleLink(dgettext('wiki', 'View'), 'wiki', $vars);
     if ((Current_User::allow('wiki', 'edit_page') || PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) && $this->getAllowEdit() && !$this->getVrCurrent()) {
         $vars['page_op'] = 'restore';
         $links[] = PHPWS_Text::secureLink(dgettext('wiki', 'Restore'), 'wiki', $vars);
     }
     if (Current_User::allow('wiki', 'delete_page') && $this->getAllowEdit() && !$this->getVrCurrent()) {
         $vars['page_op'] = 'removeold';
         $js_var['ADDRESS'] = PHPWS_Text::linkAddress('wiki', $vars, TRUE);
         $js_var['QUESTION'] = dgettext('wiki', 'Are you sure you want to remove this page revision?');
         $js_var['LINK'] = dgettext('wiki', 'Remove');
         $links[] = Layout::getJavascript('confirm', $js_var);
     }
     $template['ACTIONS'] = implode(' | ', $links);
     $template['VERSION'] = $this->getVrNumber();
     $template['UPDATED'] = $this->getUpdated();
     $template['EDITOR'] = $this->getEditor();
     $template['COMMENT'] = $this->getComment() . '';
     $template['DIFF'] = $this->getDiffOptions();
     return $template;
 }
Exemplo n.º 21
0
 /**
  * Delete
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function delete()
 {
     if (!Current_User::authorized('wiki', 'upload_images') && !(PHPWS_Settings::get('wiki', 'allow_image_upload') && Current_User::isLogged())) {
         Current_User::disallow(dgettext('wiki', 'User attempted access to image delete.'));
         return;
     }
     if (isset($_REQUEST['yes'])) {
         @unlink(PHPWS_HOME_DIR . 'images/wiki/' . $this->getFilename());
         $db = new PHPWS_DB('wiki_images');
         $db->addWhere('id', $this->getId());
         if (PHPWS_Error::logIfError($db->delete())) {
             return dgettext('wiki', 'Error deleting image.');
         }
         return dgettext('wiki', 'Image deleted!');
     } else {
         if (isset($_REQUEST['no'])) {
             return dgettext('wiki', 'Image was not deleted!');
         }
     }
     $tags = array();
     $tags['MESSAGE'] = dgettext('wiki', 'Are you sure you want to delete this image?');
     $tags['YES'] = PHPWS_Text::secureLink(dgettext('wiki', 'Yes'), 'wiki', array('op' => 'doimagedelete', 'yes' => 1, 'id' => $this->getId()));
     $tags['NO'] = PHPWS_Text::secureLink(dgettext('wiki', 'No'), 'wiki', array('op' => 'doimagedelete', 'no' => 1, 'id' => $this->getId()));
     $tags['WIKIPAGE'] = '<img src="images/wiki/' . $this->getFilename() . '" alt="" />';
     return PHPWS_Template::processTemplate($tags, 'wiki', 'confirm.tpl');
 }
Exemplo n.º 22
0
 public function allow()
 {
     if (!$this->public_folder && !Current_User::isLogged()) {
         return false;
     }
     if (!$this->key_id) {
         return true;
     }
     $key = new Key($this->key_id);
     return $key->allowView();
 }
Exemplo n.º 23
0
 public function listRoommates()
 {
     $this->setSearchParameters();
     $this->searchPanel();
     \Layout::addStyle('properties', 'forms.css');
     if (!\Current_User::isLogged()) {
         $login = \PHPWS_Settings::get('properties', 'login_link');
         if (empty($login)) {
             $login = '******';
         }
         $tpl['LOGIN'] = sprintf('Want to request or contact a roommate? <a href="%s">You will need to login</a>', $login);
     } else {
         $tpl['LOGIN'] = $this->options();
     }
     $pager = new \DBPager('prop_roommate', 'properties\\Roommate');
     $pager->addPageTags($tpl);
     $pager->setModule('properties');
     $pager->setTemplate('roommates.tpl');
     $pager->setDefaultOrder('updated', 'desc');
     $pager->addRowTags('rowtags');
     $pager->addSortHeader('name', 'Title');
     $pager->addSortHeader('monthly_rent', 'Monthly rent');
     $pager->addSortHeader('share_bedroom', 'bedroom?');
     $pager->addSortHeader('share_bathroom', 'bathroom?');
     $pager->addSortHeader('campus_distance', 'Campus distance');
     $pager->addSortHeader('move_in_date', 'Move in date');
     $pager->setSearch('name');
     if (!empty($_SESSION['roommate_search'])) {
         foreach ($_SESSION['roommate_search'] as $key => $value) {
             switch ($key) {
                 case 'sub':
                     $pager->db->addWhere('sublease', '1', '=', 'and', 'search');
                     break;
                 case 'nosub':
                     $pager->db->addWhere('sublease', '0', '=', 'and', 'search');
                     break;
                 case 'gen':
                     $pager->db->addWhere('gender', array(0, $value), 'in', 'and', 'search');
                     break;
                 case 'smoke':
                     $pager->db->addWhere('smoking', array(0, $value), 'in', 'and', 'search');
                     break;
                 case 'distance':
                     $pager->db->addWhere('campus_distance', $value, '=', 'and', 'search');
                     break;
                 case 'beds':
                     // notice the reverse
                     $value = $value ? 0 : 1;
                     $pager->db->addWhere('share_bedroom', $value, '=', 'and', 'search');
                     break;
                 case 'bath':
                     // notice the reverse
                     $value = $value ? 0 : 1;
                     $pager->db->addWhere('share_bathroom', $value, '=', 'and', 'search');
                     break;
                 case 'manager':
                     $value = preg_replace('/[^\\w\\s]|\\s{2,}/', ' ', $value);
                     $vlist = explode(' ', $value);
                     $db2 = new \PHPWS_DB('prop_contacts');
                     foreach ($vlist as $v) {
                         $db2->addWhere('company_name', "%{$value}%", 'like', 'or');
                     }
                     $db2->addColumn('id');
                     $managers = $db2->select('col');
                     if (!empty($managers)) {
                         $pager->db->addWhere('contact_id', $managers, 'in', 'and', 'properties');
                     } else {
                         $pager->db->addWhere('id', 0, '=', 'and', 'cancel');
                     }
                     break;
                 case 'price':
                     $pager->db->addWhere('monthly_rent', $value['min'] * 100, '>=', 'and', 'search');
                     $pager->db->addWhere('monthly_rent', $value['max'] * 100, '<=', 'and', 'search');
                     break;
                 case 'amenities':
                     foreach ($value as $amen_name => $foo) {
                         switch ($amen_name) {
                             case 'ac':
                                 $pager->db->addWhere('appalcart', 1, '=', 'and', 'search');
                                 break;
                             case 'ch':
                                 $pager->db->addWhere('clubhouse', 1, '=', 'and', 'search');
                                 break;
                             case 'dish':
                                 $pager->db->addWhere('dishwasher', 1, '=', 'and', 'search');
                                 break;
                             case 'furn':
                                 $pager->db->addWhere('furnished', 1, '=', 'and', 'search');
                                 break;
                             case 'pet':
                                 $pager->db->addWhere('pets_allowed', 1, '=', 'and', 'search');
                                 break;
                             case 'tr':
                                 $pager->db->addWhere('trash_type', 1, '=', 'and', 'search');
                                 break;
                             case 'wo':
                                 $pager->db->addWhere('workout_room', 1, '=', 'and', 'search');
                                 break;
                             case 'wash':
                                 $pager->db->addWhere('laundry_type', 1, '=', 'and', 'search');
                                 break;
                         }
                     }
                     break;
                 case 'property':
                     $value = preg_replace('/[^\\w\\s]|\\s{2,}/', ' ', $value);
                     $vlist = explode(' ', $value);
                     foreach ($vlist as $v) {
                         $pager->db->addWhere('name', "%{$v}%", 'like', 'or', 'property');
                     }
                     break;
             }
         }
     }
     // roommates that are a month past move in date, are not shown
     $cut_off_date = time() - 86400 * 30;
     $pager->addWhere('move_in_date', $cut_off_date, '>');
     $pager->setEmptyMessage('No one is currently looking for a roommate. Try again later.');
     $this->content = $pager->get();
 }
Exemplo n.º 24
0
 function doMove()
 {
     if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) || !$this->allow_edit) {
         Current_User::disallow(dgettext('wiki', 'User attempted to execute a wiki page move.'));
         return;
     }
     if (strlen($_POST['newpage']) == 0) {
         WikiManager::sendMessage(dgettext('wiki', 'Please supply a new page title'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $db = new PHPWS_DB('wiki_pages');
     $db->addWhere('title', $_POST['newpage']);
     $result = $db->select();
     if ($result != NULL) {
         WikiManager::sendMessage(dgettext('wiki', 'Page with that name already exists!'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $this->setTitle($_POST['newpage']);
     $db->reset();
     $db->saveObject($this);
     $db2 = new PHPWS_DB('wiki_pages_version');
     $db2->addWhere('title', $_POST['page']);
     $db2->addValue('title', $this->getTitle(FALSE));
     $db2->update();
     $db3 = new PHPWS_DB('phpws_key');
     $db3->addWhere('item_id', $this->getId());
     $db3->addWhere('module', 'wiki');
     $db3->addValue('title', $this->getTitle());
     $db3->addValue('url', (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $this->getTitle(FALSE));
     $db3->update();
     // Create redirect page
     $redirect = new WikiPage($_POST['page']);
     $redirect->setPagetext(sprintf(dgettext('wiki', 'This page has moved to %s.  Please modify links to point to the new location.'), $this->getTitle(FALSE)));
     $redirect->setOwnerId(Current_User::getId());
     $redirect->setEditorId(Current_User::getId());
     $redirect->setCreated(mktime());
     $redirect->setUpdated(mktime());
     $redirect->setComment(sprintf(dgettext('wiki', 'Moved page to %s.'), $this->getTitle(FALSE)));
     $redirect->save();
     PHPWS_Core::initModClass('version', 'Version.php');
     $version = new Version('wiki_pages');
     $version->setSource($redirect);
     $version->setApproved(1);
     $version->save();
     WikiManager::sendMessage(dgettext('wiki', 'Wiki Page Moved!'), array('page' => $this->getTitle(FALSE)), FALSE);
 }
Exemplo n.º 25
0
 public static function isGuest()
 {
     return !Current_User::isLogged();
 }
Exemplo n.º 26
0
 public function view()
 {
     \Layout::addStyle('properties', 'view.css');
     $tpl = $this->getBaseTpl();
     $tpl['BEDROOMS'] = $this->share_bedroom ? 'Yes' : 'No';
     $tpl['BATHROOMS'] = $this->share_bathroom ? 'Yes' : 'No';
     $tpl['SMOKING'] = $this->getSmoking();
     if ($this->pets_allowed) {
         $tpl['PETS_ALLOWED'] = 'Yes';
     } else {
         $tpl['PETS_ALLOWED'] = 'No';
     }
     $tpl['DESCRIPTION'] = $this->getDescription();
     $tpl['TV_TYPE'] = $this->getTvType();
     $tpl['GENDER'] = $this->getGender();
     javascriptMod('properties', 'contact');
     if (\Current_User::isLogged()) {
         if (\Current_User::getId() == $this->id) {
             $purge = $this->getTimeout();
             $tpl['EMAIL'] = '<a href="index.php?module=properties&rop=edit">Update my request</a> |
                 <a href="index.php?module=properties&rop=timeout">Update my cut-off date (' . $purge . ')</a>';
         } else {
             $tpl['EMAIL'] = sprintf('<a style="cursor : pointer" class="message" id="%s">Contact this renter</a>', $this->id);
         }
     } else {
         $tpl['EMAIL'] = sprintf('<a href="%s">Login to contact this renter</a>', Base::loginLink());
     }
     return \PHPWS_Template::process($tpl, 'properties', 'roommate_view.tpl');
 }
Exemplo n.º 27
0
 /**
  * Action
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function action()
 {
     Layout::addStyle('wiki');
     if (!PHPWS_Settings::get('wiki', 'allow_anon_view') && !Current_User::isLogged()) {
         Current_User::requireLogin();
         return;
     }
     if (isset($_REQUEST['page_id']) && is_numeric($_REQUEST['page_id'])) {
         PHPWS_Core::initModClass('wiki', 'WikiPage.php');
         $wikipage = new WikiPage($_REQUEST['page_id']);
     } else {
         if (isset($_REQUEST['page']) && is_string($_REQUEST['page'])) {
             PHPWS_Core::initModClass('wiki', 'WikiPage.php');
             $wikipage = new WikiPage($_REQUEST['page']);
         }
     }
     if (!isset($_REQUEST['op']) && !isset($_REQUEST['page_op'])) {
         // phpWebSite 1.5.0 and later mod_rewrite method
         if (isset($_GET['var1'])) {
             $_REQUEST['id'] = $_GET['id'] = $_GET['var1'];
         }
         if (isset($_REQUEST['id']) && is_string($_REQUEST['id'])) {
             PHPWS_Core::initModClass('wiki', 'WikiPage.php');
             $wikipage = new WikiPage($_REQUEST['id']);
         }
         $_REQUEST['page_op'] = 'view';
     }
     WikiManager::addToMiniAdmin();
     if (isset($_REQUEST['page_op']) && isset($wikipage)) {
         $wikipage->action();
         return;
     }
     switch (@$_REQUEST['op']) {
         case 'admin':
         case 'savesettings':
             PHPWS_Core::initModClass('wiki', 'WikiSettings.php');
             WikiSettings::admin();
             break;
         case 'doimagedelete':
         case 'doimageupload':
         case 'imageupload':
             WikiManager::imageUpload();
             break;
         case 'imagedelete':
             PHPWS_Core::initModClass('wiki', 'WikiImage.php');
             $delImage = new WikiImage($_REQUEST['id']);
             $template['TITLE'] = dgettext('wiki', 'Wiki Images');
             $template['CONTENT'] = $delImage->delete();
             Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
             break;
         case 'imagecopy':
             PHPWS_Core::initModClass('wiki', 'WikiImage.php');
             $image = new WikiImage($_REQUEST['id']);
             Clipboard::copy($image->getFilename(), $image->getTag());
             PHPWS_Core::goBack();
             break;
         case 'recentchanges':
             $template['TITLE'] = dgettext('wiki', 'Recent changes');
             $template['CONTENT'] = WikiManager::recentChanges();
             Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
             break;
         case 'random':
             WikiManager::random();
             break;
         case 'interwikisetup':
         case 'addinterwiki':
             PHPWS_Core::initModClass('wiki', 'InterWiki.php');
             $interwiki = new InterWiki();
             $interwiki->setup();
             break;
         case 'editinterwiki':
         case 'saveinterwiki':
         case 'deleteinterwiki':
         case 'dodeleteinterwiki':
             PHPWS_Core::initModClass('wiki', 'InterWiki.php');
             $interwiki = new InterWiki($_REQUEST['id']);
             $interwiki->setup();
             break;
         case 'copyinterwiki':
             PHPWS_Core::initModClass('wiki', 'InterWiki.php');
             $interwiki = new InterWiki($_REQUEST['id']);
             Clipboard::copy($interwiki->getLabel(), $interwiki->getLabel() . ':PageName');
             PHPWS_Core::goBack();
             break;
         default:
             $_REQUEST['page'] = PHPWS_Settings::get('wiki', 'default_page');
             WikiManager::action();
     }
 }
Exemplo n.º 28
0
 public static function welcomeScreen()
 {
     \Layout::addStyle('election', 'User/style.css');
     $template = new \Template();
     $template->setModuleTemplate('election', 'User/welcome.html');
     if (!\Current_User::isLogged()) {
         $template->add('color', 'primary');
         $template->add('label', '<i class="fa fa-check-square-o"></i> Sign in to Vote');
         $template->add('url', ELECTION_LOGIN_DIRECTORY);
     } else {
         $template->add('color', 'success');
         $template->add('label', '<i class="fa fa-check-square-o"></i> Get started voting!');
         $template->add('url', 'election/');
     }
     $template->add('image', PHPWS_SOURCE_HTTP . 'mod/election/img/background1.jpg');
     \Layout::add($template->get());
 }
Exemplo n.º 29
0
 /**
  * PHPWS_Email has a built-in simple logging function.  This replicates
  * the functionality of that function for SwiftMail.
  */
 public static function logSwiftmailMessage(Swift_Message $message)
 {
     $id = 'id:' . $message->getId();
     $from = 'from:' . $message->getSender();
     $to = 'to:' . implode(',', array_keys($message->getTo()));
     // Optional fields, If the message has them, implode the arrays to simple strings.
     $cc = $message->getCc() != null ? 'cc:' . implode(',', array_keys($message->getCc())) : '';
     $bcc = $message->getBcc() != null ? 'bcc:' . implode(',', array_keys($message->getBcc())) : '';
     $replyto = $message->getReplyTo() != null ? 'reply-to:' . implode(',', array_keys($message->getReplyTo())) : '';
     $subject = 'subject:' . $message->getSubject();
     $module = 'module:' . PHPWS_Core::getCurrentModule();
     $user = '******' . (Current_User::isLogged() ? Current_User::getUsername() : '');
     PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto}", 'phpws-mail.log', 'mail');
 }
Exemplo n.º 30
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id: runtime.php 7776 2010-06-11 13:52:58Z jtickle $
 */
if (!class_exists('PHPWS_User')) {
    include '../../core/conf/404.html';
    exit;
}
if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'users' && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'reset')) {
    $_SESSION['User'] = new PHPWS_User();
} elseif (!isset($_SESSION['User'])) {
    Current_User::init();
    if (Current_User::allowRememberMe()) {
        if (PHPWS_Settings::get('users', 'allow_remember')) {
            Current_User::rememberLogin();
        }
    }
}
Current_User::loadAuthorization($_SESSION['User']);
Current_User::getLogin();
if (Current_User::isLogged() && PHPWS_Settings::get('users', 'session_warning')) {
    $lifetime = ini_get('session.gc_maxlifetime');
    $path = PHPWS_SOURCE_HTTP . 'mod/users/javascript/session_check/script.min.js';
    $timeout = floor($lifetime / 60);
    $warning_minutes = $timeout - 5;
    javascript('jquery');
    \Layout::addJSHeader("<script type='text/javascript'>var sess_expirationMinutes = {$timeout};var sess_warningMinutes = {$warning_minutes};</script>" . "<script type='text/javascript' src='{$path}'></script>");
}