Exemplo n.º 1
0
 public function admin()
 {
     /**
      * Folder permissions needed
      */
     switch ($_REQUEST['fop']) {
         case 'open_file_manager':
             if (!Current_User::verifySaltedUrl()) {
                 javascript('close_refresh');
                 Layout::nakedDisplay();
             }
             return $this->openFileManager();
             break;
         case 'fm_folders':
             return $this->folderView();
             break;
         case 'fm_fld_contents':
             return $this->folderContentView();
             break;
         case 'pick_file':
             $this->pickFile();
             break;
         case 'resize_pick':
             $this->resizePick();
             break;
     }
 }
Exemplo n.º 2
0
 public function admin()
 {
     switch ($_REQUEST['iop']) {
         case 'delete_image':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadImage(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->image->delete();
             PHPWS_Core::goBack();
             break;
         case 'post_image_upload':
             if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             if (!$this->postImageUpload()) {
                 \Cabinet::setMessage('Failed to upload image. Check directory permissions.');
             }
             Layout::nakedDisplay();
             //\PHPWS_Core::goBack();
             break;
         case 'upload_image_form':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadImage(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->edit();
             echo Layout::wrap($this->content, 'Image Upload', true);
             exit;
     }
 }
Exemplo n.º 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);
        }
    }
}
Exemplo n.º 4
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do no have permission to run reports.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Reports.php');
     $reportName = $context->get('report');
     if (is_null($reportName)) {
         throw new InvalidArgumentException('Missing report name.');
     }
     //$context->setContent(HMS_Reports::runReport($reportName));
     Layout::nakedDisplay(HMS_Reports::runReport($reportName), true);
 }
Exemplo n.º 5
0
 /**
  *
  *
  *
  *
  */
 function action()
 {
     switch ($_REQUEST['PHAT_REPORT_OP']) {
         case 'list':
             if (Current_User::allow('phatform', 'report_view')) {
                 $content = $this->report();
             } else {
                 $this->accessDenied();
             }
             break;
         case 'edit':
             if (Current_User::allow('phatform', 'report_edit')) {
                 $content = $_SESSION['PHAT_FormManager']->menu() . $this->edit();
             } else {
                 $this->accessDenied();
             }
             break;
         case 'view':
             if (Current_User::allow('phatform', 'report_view')) {
                 $content = $_SESSION['PHAT_FormManager']->menu() . $this->view();
             } else {
                 $this->accessDenied();
             }
             break;
         case 'confirmDelete':
             if (Current_User::allow('phatform', 'report_delete')) {
                 $content = $this->confirmDelete();
             } else {
                 $this->accessDenied();
             }
             break;
         case 'delete':
             if (Current_User::allow('phatform', 'report_delete')) {
                 $content = $this->delete();
             } else {
                 $this->accessDenied();
             }
             break;
         case 'export':
             if (Current_User::allow('phatform', 'report_export')) {
                 include PHPWS_SOURCE_DIR . 'mod/phatform/inc/Export.php';
                 $error = export($this->_formId);
                 if (PHPWS_Error::isError($error)) {
                     javascript('alert', array('content' => PHPWS_Error::printError($error)));
                     $content = $this->report();
                 }
             } else {
                 $this->accessDenied();
             }
             break;
     }
     if ($content) {
         if (isset($_REQUEST['lay_quiet'])) {
             Layout::nakedDisplay($content);
         } else {
             $GLOBALS['CNT_phatform']['content'] = $content;
         }
     }
 }
 /**
  * @Override FC_Document_Manager::postDocumentUpload().
  *
  * This is a copy and past of the overriden function except
  * that we now create a new InternDocument object
  * and save it to databse.
  */
 public function postDocumentUpload()
 {
     // importPost in File_Common
     $result = $this->document->importPost('file_name');
     if (\PHPWS_Error::isError($result) || !$result) {
         \PHPWS_Error::log($result);
         $vars['timeout'] = '3';
         $vars['refresh'] = 0;
         javascript('close_refresh', $vars);
         return dgettext('filecabinet', 'An error occurred when trying to save your document.');
     } elseif ($result) {
         $result = $this->document->save();
         if (\PHPWS_Error::logIfError($result)) {
             $content = dgettext('filecabinet', '<p>Could not upload file to folder. Please check your directory permissions.</p>');
             $content .= sprintf('<a href="#" onclick="window.close(); return false">%s</a>', dgettext('filecabinet', 'Close this window'));
             Layout::nakedDisplay($content);
             exit;
         }
         //\PHPWS_Core::initModClass('filecabinet', 'File_Assoc.php');
         //\FC_File_Assoc::updateTag(\FC_DOCUMENT, $this->document->id, $this->document->getTag());
         $this->document->moveToFolder();
         // If the document's id is set in the request
         // then we are updating a file. Not need to insert
         // it into database.
         if (!isset($_REQUEST['document_id'])) {
             // Save InternDocument in database.
             $doc = new InternDocument();
             $doc->internship_id = $_REQUEST['internship'];
             $doc->document_fc_id = $this->document->id;
             $result = $doc->save();
         }
         // Choose the proper notification text...
         if (isset($_REQUEST['document_id']) && $_REQUEST['document_id'] && $result) {
             \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "File saved.");
         } else {
             if ($result) {
                 \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "File added.");
             } else {
                 if (\PHPWS_Error::logIfError($result)) {
                     \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $result->toString());
                 }
             }
         }
         \NQ::close();
         if (!isset($_POST['im'])) {
             javascript('close_refresh');
         } else {
             javascript('/filecabinet/refresh_manager', array('document_id' => $this->document->id));
         }
     } else {
         return $this->edit();
     }
 }
Exemplo n.º 7
0
 public function show()
 {
     $tpl = new PHPWS_Template('hms');
     if (!$tpl->setFile('admin/reports/hall_overview.tpl')) {
         return 'Template error.';
     }
     $rlcs = HMS_Learning_Community::getRlcList();
     $rlcs_abbr = HMS_Learning_Community::getRLCListAbbr();
     $tpl->setData(array('HALL' => $this->hall->hall_name, 'TERM' => Term::getPrintableSelectedTerm()));
     if ($this->nakedDisplay) {
         $menuCmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
         $tpl->setData(array('MAINTENANCE' => $menuCmd->getLink('Main Menu')));
     }
     $class = 'toggle1';
     $this->hall->loadFloors();
     foreach ($this->hall->_floors as $floor) {
         $floor->loadRooms();
         if (!isset($floor->_rooms)) {
             continue;
         }
         if ($floor->rlc_id != NULL) {
             $floor_rlc = $rlcs[$floor->rlc_id];
         } else {
             $floor_rlc = '';
         }
         foreach ($floor->_rooms as $room) {
             $extra_attribs = '';
             if ($room->isOffline()) {
                 $extra_attribs .= 'Offline ';
             }
             if ($room->isReserved()) {
                 $extra_attribs .= 'Reserved ';
             }
             if ($room->isRa()) {
                 $extra_attribs .= 'RA ';
             }
             if ($room->isPrivate()) {
                 $extra_attribs .= 'Private ';
             }
             if ($room->isOverflow()) {
                 $extra_attribs .= 'Overflow ';
             }
             if ($room->isParlor()) {
                 $extra_attribs .= 'Parlor ';
             }
             if ($room->isADA()) {
                 $extra_attribs .= 'ADA';
             }
             if ($room->isHearingImpaired()) {
                 $extra_attribs .= 'Hearing Impaired';
             }
             if ($room->bathEnSuite()) {
                 $extra_attribs .= 'Bath en Suite';
             }
             $room->loadBeds();
             if (empty($room->_beds)) {
                 $tpl->setCurrentBlock('room_repeat');
                 $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room')));
                 $tpl->parseCurrentBlock();
                 continue;
             }
             foreach ($room->_beds as $bed) {
                 $bed->loadAssignment();
                 $tpl->setCurrentBlock('bed_repeat');
                 $bed_link = $bed->getLink();
                 if (isset($bed->_curr_assignment)) {
                     $username = $bed->_curr_assignment->asu_username;
                     try {
                         $student = StudentFactory::getStudentByUsername($username, $this->hall->term);
                     } catch (StudentNotFoundException $e) {
                         $student = null;
                         NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for: {$username}");
                     }
                     $assign_rlc = HMS_RLC_Assignment::checkForAssignment($username, $this->hall->term);
                     //false or index
                     if ($assign_rlc != FALSE) {
                         $rlc_abbr = $rlcs_abbr[$assign_rlc['rlc_id']];
                         //get the abbr for the rlc
                     } else {
                         $rlc_abbr = '';
                     }
                     // Alternating background colors
                     if ($class == 'toggle1') {
                         $class = 'toggle2';
                     } else {
                         $class = 'toggle1';
                     }
                     if (is_null($student)) {
                         $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => 'UNKNOWN', 'USERNAME' => $username, 'BANNER_ID' => '', 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr));
                     } else {
                         $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $student->getProfileLink(), 'USERNAME' => $student->getUsername(), 'BANNER_ID' => $student->getBannerId(), 'TOGGLE' => $class, 'RLC_ABBR' => $rlc_abbr));
                     }
                 } else {
                     $tpl->setData(array('BED_LABEL' => $bed->bedroom_label, 'BED' => $bed_link, 'NAME' => $bed->get_assigned_to_link(), 'VACANT' => ''));
                 }
                 $tpl->parseCurrentBlock();
             }
             $tpl->setCurrentBlock('room_repeat');
             $tpl->setData(array('EXTRA_ATTRIBS' => $extra_attribs, 'ROOM_NUMBER' => $room->getLink('Room')));
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock('floor_repeat');
         $tpl->setData(array('FLOOR_NUMBER' => $floor->getLink('Floor'), 'FLOOR_RLC' => $floor_rlc));
         $tpl->parseCurrentBlock();
     }
     if ($this->nakedDisplay) {
         Layout::nakedDisplay($tpl->get(), 'Building overview for ' . $this->hall->hall_name, TRUE);
     }
     Layout::addPageTitle("Hall Overview");
     return $tpl->get();
 }
Exemplo n.º 8
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'));
         }
     }
 }
Exemplo n.º 9
0
 public static function route($action)
 {
     $title = $content = NULL;
     $message = Block_Admin::getMessage();
     if (isset($_REQUEST['block_id'])) {
         $block = new Block_Item($_REQUEST['block_id']);
     } else {
         $block = new Block_Item();
     }
     switch ($action) {
         case 'new':
             $title = dgettext('block', 'New Block');
             $content = Block_Admin::edit($block);
             break;
         case 'delete':
             if (!Current_User::authorized('block', 'delete_block', $_REQUEST['block_id'])) {
                 Current_User::disallow();
             }
             $block->kill();
             Block_Admin::sendMessage(dgettext('block', 'Block deleted.'));
             PHPWS_Core::goBack();
             break;
         case 'edit':
             if (!Current_User::authorized('block', 'edit_block', $_REQUEST['block_id'])) {
                 Current_User::disallow();
             }
             $title = 'Edit Block';
             $content = Block_Admin::edit($block);
             break;
         case 'pin_all':
             if (!Current_User::authorized('block', 'delete_block', $_REQUEST['block_id'])) {
                 Current_User::disallow();
             }
             Block_Admin::pinBlockAll($block);
             Block_Admin::sendMessage(dgettext('block', 'Block pinned'), 'list');
             break;
         case 'remove':
             if (!Current_User::authorized('block', 'edit_block', $_REQUEST['block_id'])) {
                 Current_User::disallow();
             }
             Block_Admin::removeBlock();
             PHPWS_Core::goBack();
             break;
         case 'postBlock':
             if (Block_Admin::postBlock($block)) {
                 $result = $block->save();
                 Block_Admin::sendMessage(dgettext('block', 'Block saved'), 'list');
             } else {
                 $message = dgettext('block', 'Block must have a title, some content, or a file attachment.');
                 $title = 'Edit Block';
                 $content = Block_Admin::edit($block);
             }
             break;
         case 'settings':
             $title = dgettext('block', 'Settings');
             $content = Block_Admin::settings();
             break;
         case 'post_settings':
             $result = Block_Admin::postSettings();
             if (is_array($result)) {
                 $message = implode('<br />', $result);
                 $title = dgettext('block', 'Settings');
                 $content = Block_Admin::settings();
             } else {
                 Block_Admin::sendMessage(dgettext('block', 'Settings saved'), 'settings');
             }
             break;
         case 'postJSBlock':
             if (Block_Admin::postBlock($block)) {
                 $result = $block->save();
                 if (PHPWS_Error::isError($result)) {
                     PHPWS_Error::log($result);
                 } elseif (isset($_REQUEST['key_id'])) {
                     Block_Admin::lockBlock($block->id, $_REQUEST['key_id']);
                 }
                 PHPWS_Core::goBack();
             } else {
                 $template['TITLE'] = dgettext('block', 'New Block');
                 $template['CONTENT'] = Block_Admin::edit($block, TRUE);
                 $template['MESSAGE'] = dgettext('block', 'Block must have a title, some content, or a file attachment.');
                 $content = PHPWS_Template::process($template, 'block', 'admin.tpl');
                 Layout::nakedDisplay($content);
             }
             break;
         case 'lock':
             $result = Block_Admin::lockBlock($_GET['block_id'], $_GET['key_id']);
             if (PHPWS_Error::isError($result)) {
                 PHPWS_Error::log($result);
             }
             PHPWS_Core::goBack();
             break;
         case 'list':
             $title = dgettext('block', 'Block list');
             $content = Block_Admin::blockList();
             break;
         case 'js_block_edit':
             $template['CONTENT'] = Block_Admin::edit($block, TRUE);
             echo PHPWS_Template::process($template, 'block', 'admin.tpl');
             exit;
             break;
     }
     $template['TITLE'] =& $title;
     if (isset($message)) {
         $template['MESSAGE'] =& $message;
     }
     $template['CONTENT'] =& $content;
     return PHPWS_Template::process($template, 'block', 'admin.tpl');
 }
Exemplo n.º 10
0
 public static function moveBoxMenu()
 {
     $box = new Layout_Box($_GET['box']);
     $vars['action'] = 'admin';
     $vars['command'] = 'moveBox';
     $vars['box_source'] = $box->id;
     $vars['box_dest'] = 'move_box_top';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move to top'), 'layout', $vars);
     $vars['box_dest'] = 'move_box_up';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move up'), 'layout', $vars);
     $vars['box_dest'] = 'move_box_down';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move down'), 'layout', $vars);
     $vars['box_dest'] = 'move_box_bottom';
     $step_links[] = PHPWS_Text::secureLink(dgettext('layout', 'Move to bottom'), 'layout', $vars);
     if (Current_User::isDeity() && !$_SESSION['Layout_Settings']->deity_reload) {
         $_SESSION['Layout_Settings']->loadSettings();
     }
     $themeVars = $_SESSION['Layout_Settings']->getAllowedVariables();
     foreach ($themeVars as $var) {
         if ($box->theme_var == $var) {
             continue;
         }
         $vars['box_dest'] = $var;
         $theme_links[] = PHPWS_Text::secureLink(sprintf(dgettext('layout', 'Send to %s'), $var), 'layout', $vars);
     }
     $vars['box_dest'] = 'restore';
     $template['RESTORE'] = PHPWS_Text::secureLink(dgettext('layout', 'Restore to default'), 'layout', $vars);
     $template['STEP_LINKS'] = implode('<br>', $step_links);
     $template['THEME_LINKS'] = implode('<br>', $theme_links);
     $template['CANCEL'] = sprintf('<a href="." onclick="window.close()">%s</a>', dgettext('layout', 'Cancel'));
     $template['TITLE'] = sprintf(dgettext('layout', 'Move box: %s'), $box->content_var);
     $content = PHPWS_Template::process($template, 'layout', 'move_box_select.tpl');
     Layout::nakedDisplay($content);
 }
Exemplo n.º 11
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 '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 '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);
             exit;
             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 'boxMoveForm':
             self::boxMoveForm();
             exit;
     }
     $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()));
 }
Exemplo n.º 12
0
    case 'update_core':
        $content[] = $backToBoost . '<br />';
        $content[] = Boost_Action::updateModule('core');
        break;
    case 'update':
        $js = javascriptEnabled();
        if (!$js) {
            $content[] = $backToBoost . '<br />';
        } else {
            $content[] = sprintf('<p style="text-align : center"><input type="button" onclick="closeWindow(); return false" value="%s" /></p>', dgettext('boost', 'Close window'));
        }
        $content[] = Boost_Action::updateModule($_REQUEST['opmod']);
        break;
    case 'show_dependency':
        $js = javascriptEnabled();
        $content[] = Boost_Action::showDependency($_REQUEST['opmod']);
        break;
    case 'show_depended_upon':
        $content[] = Boost_Action::showDependedUpon($_REQUEST['opmod']);
        break;
}
// End area switch
if ($js) {
    javascript('close_refresh', array('use_link' => true));
    $content[] = sprintf('<p style="text-align : center"><input type="button" onclick="closeWindow(); return false" value="%s" /></p>', dgettext('boost', 'Close window'));
    Layout::nakedDisplay(implode('', $content));
} else {
    $boostPanel->setContent(implode('', $content));
    $finalContent = $boostPanel->display();
    Layout::add(PHPWS_ControlPanel::display($finalContent));
}
Exemplo n.º 13
0
 public function postDocumentUpload()
 {
     // importPost in File_Common
     $result = $this->document->importPost('file_name');
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         $vars['timeout'] = '3';
         $vars['refresh'] = 0;
         javascript('close_refresh', $vars);
         return dgettext('filecabinet', 'An error occurred when trying to save your document.');
     } elseif ($result) {
         $result = $this->document->save();
         if (PHPWS_Error::logIfError($result)) {
             $content = dgettext('filecabinet', '<p>Could not upload file to folder. Please check your directory permissions.</p>');
             $content .= sprintf('<a href="#" onclick="window.close(); return false">%s</a>', dgettext('filecabinet', 'Close this window'));
             Layout::nakedDisplay($content);
             exit;
         }
         PHPWS_Core::initModClass('filecabinet', 'File_Assoc.php');
         // This function doesn't do anything
         //FC_File_Assoc::updateTag(FC_DOCUMENT, $this->document->id, $this->document->getTag());
         $this->document->moveToFolder();
         if (!isset($_POST['im'])) {
             javascript('close_refresh');
         } else {
             javascriptMod('filecabinet', 'refresh_manager', array('document_id' => $this->document->id));
         }
     } else {
         foreach ($this->document->_errors as $err) {
             $message[] = $err->getMessage();
         }
         Cabinet::setMessage($this->document->printErrors());
     }
 }
Exemplo n.º 14
0
 public function auto_assign($test = 0)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Room.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     // TODO update this to use HousignAssignment
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'BannerQueue.php');
     $term = Term::get_selected_term();
     // In both cases: Random, and include Banner info
     $f_rooms = HMS_Room::get_all_free_rooms($term, FEMALE, TRUE);
     $m_rooms = HMS_Room::get_all_free_rooms($term, MALE, TRUE);
     $roommates = HMS_Roommate::get_all_confirmed_roommates($term, TRUE);
     $applicants = HousingApplication::getAllFreshmenApplications($term, 'gender', 'hms_fall_application.lifestyle_option', 'hms_fall_application.preferred_bedtime', 'hms_fall_application.room_condition', 'random');
     $problems = array();
     $rlcs = array();
     $assigns = array();
     $notices = array();
     $successes = array();
     $assigned = array();
     reset($f_rooms);
     reset($m_rooms);
     $i_f_count = count($f_rooms);
     $i_m_count = count($m_rooms);
     // Assign Roommates
     reset($roommates);
     foreach ($roommates as $pair) {
         $a = HousingApplication::getApplicationByUser($pair['requestor'], $term);
         if (in_array($a->username, $assigned)) {
             $notices[] = "<strong>{$a->username}</strong> already scheduled for assignment.";
             continue;
         }
         $rlc = HMS_RLC_Assignment::checkForAssignment($a->username, $term);
         if ($rlc !== FALSE) {
             $rlcs[] = "Skipping <strong>{$a->username}</strong>; assigned to an RLC.";
             continue;
         }
         $b = HousingApplication::getApplicationByUser($pair['requestee'], $term);
         if (in_array($b->username, $assigned)) {
             $notices[] = "<strong>{$b->username}</strong> already scheduled for assignment.";
             continue;
         }
         $rlc = HMS_RLC_Assignment::checkForAssignment($b->username, $term);
         if ($rlc !== FALSE) {
             $rlcs[] = "Skipping <strong>{$b->username}</strong>; assigned to an RLC.";
             continue;
         }
         if (is_null($a->id)) {
             $problems[] = "Could not assign <strong>{$a->username}</strong> with roommate <strong>{$b->username}</strong>; {$a->username} does not have an application.";
             continue;
         }
         if (is_null($b->id)) {
             $problems[] = "Could not assign <strong>{$a->username}</strong> with roommate <strong>{$b->username}</strong>; {$b->username} does not have an application.";
             continue;
         }
         if ($a->gender != $b->gender) {
             $problems[] = "Epic FAIL... <strong>{$a->username}</strong> and <strong>{$b->username}</strong> are not the same gender.";
             continue;
         }
         $ass = HMS_Assignment::get_assignment($a->username, $term);
         if (is_a($ass, 'HMS_Assignment')) {
             $bbc = $ass->get_banner_building_code();
             $bed = $ass->get_banner_bed_id();
             $assigns[] = "Could not assign <strong>{$a->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>";
             continue;
         }
         $ass = HMS_Assignment::get_assignment($b->username, $term);
         if (is_a($ass, 'HMS_Assignment')) {
             $bbc = $ass->get_banner_building_code();
             $bed = $ass->get_banner_bed_id();
             $assigns[] = "Could not assign <strong>{$b->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>";
             continue;
         }
         $room = $a->gender == FEMALE ? array_shift($f_rooms) : ($a->gender == MALE ? array_shift($m_rooms) : 'badgender');
         if (is_null($room)) {
             $problems[] = "Could not assign <strong>{$a->username}</strong>; out of empty " . ($a->gender ? 'male' : 'female') . ' rooms.';
             $problems[] = "Could not assign <strong>{$b->username}</strong>; out of empty " . ($b->gender ? 'male' : 'female') . ' rooms.';
             continue;
         } else {
             if ($room === 'badgender') {
                 $problems[] = "Could not assign <strong>{$a->username}</strong>; {$a->gender} is not a valid gender.";
                 continue;
             }
         }
         // Prepare for assignment
         $room =& new HMS_Room($room);
         $room->loadBeds();
         $bed_a_text = $room->_beds[0]->get_banner_building_code() . ' ' . $room->_beds[0]->banner_id;
         $bed_b_text = $room->_beds[1]->get_banner_building_code() . ' ' . $room->_beds[1]->banner_id;
         if ($test) {
             $successes[] = HMS_Autoassigner::record_success('TEST Requested', $a, $b, $bed_a_text);
             $successes[] = HMS_Autoassigner::record_success('TEST Requested', $b, $a, $bed_b_text);
         } else {
             $result = HMS_Autoassigner::assign($a, $room->_beds[0], $term);
             if ($result === TRUE) {
                 $successes[] = HMS_Autoassigner::record_success('Requested', $a, $b, $bed_a_text);
                 $assigned[] = $a->username;
             } else {
                 $problems[] = $result;
             }
             if (!is_null($b->id)) {
                 $result = HMS_Autoassigner::assign($b, $room->_beds[1], $term);
                 if ($result === TRUE) {
                     $successes[] = HMS_Autoassigner::record_success('Requested', $b, $a, $bed_b_text);
                     $assigned[] = $b->username;
                 } else {
                     $problems[] = $result;
                 }
             }
         }
     }
     reset($applicants);
     while (count($applicants) > 0) {
         $a = array_shift($applicants);
         if ($a === FALSE) {
             continue;
         }
         if (!isset($a)) {
             continue;
         }
         if (in_array($a->username, $assigned)) {
             $notices[] = "<strong>{$a->username}</strong> already scheduled for assignment.";
             continue;
         }
         $rlc = HMS_RLC_Assignment::checkForAssignment($a->username, $term);
         if ($rlc !== FALSE) {
             $rlcs[] = "Skipping <strong>{$a->username}</strong>; assigned to an RLC.";
             continue;
         }
         $b = array_shift($applicants);
         if (in_array($b->username, $assigned)) {
             $notices[] = "<strong>{$b->username}</strong> already scheduled for assignment.";
             array_unshift($applicants, $a);
             continue;
         }
         $rlc = HMS_RLC_Assignment::checkForAssignment($b->username, $term);
         if ($rlc !== FALSE) {
             $rlcs[] = "Skipping <strong>{$b->username}</strong>; assigned to an RLC.";
             array_unshift($applicants, $a);
             continue;
         }
         if ($a->gender != $b->gender) {
             array_unshift($applicants, $b);
             $b = NULL;
             continue;
         }
         $ass = HMS_Assignment::get_assignment($a->username, $term);
         if (is_a($ass, 'HMS_Assignment')) {
             $bbc = $ass->get_banner_building_code();
             $bed = $ass->get_banner_bed_id();
             $assigns[] = "Could not assign <strong>{$a->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>";
             array_unshift($applicants, $b);
             continue;
         }
         $ass = HMS_Assignment::get_assignment($b->username, $term);
         if (is_a($ass, 'HMS_Assignment')) {
             $bbc = $ass->get_banner_building_code();
             $bed = $ass->get_banner_bed_id();
             $assigns[] = "Could not assign <strong>{$b->username}</strong>; already assigned to <strong>{$bbc} {$bed}</strong>";
             array_unshift($applicants, $a);
             continue;
         }
         // Determine Room Gender
         $room = $a->gender == FEMALE ? array_shift($f_rooms) : ($a->gender == MALE ? array_shift($m_rooms) : 'badgender');
         // We could be out of rooms or have database corruption
         if (is_null($room)) {
             $problems[] = "Could not assign <strong>{$a->username}</strong>; out of " . ($a->gender ? 'male' : 'female') . ' rooms.';
             $problems[] = "Could not assign <strong>{$b->username}</strong>; out of " . ($b->gender ? 'male' : 'female') . ' rooms.';
             continue;
         } else {
             if ($room === 'badgender') {
                 $problems[] = "Could not assign <strong>{$a->username}</strong>; {$a->gender} is not a valid gender.";
                 continue;
             }
         }
         // Prepare for assignment
         $room =& new HMS_Room($room);
         $room->loadBeds();
         $bed_a_text = $room->_beds[0]->get_banner_building_code() . ' ' . $room->_beds[0]->banner_id;
         $bed_b_text = $room->_beds[1]->get_banner_building_code() . ' ' . $room->_beds[1]->banner_id;
         if ($test) {
             $successes[] = HMS_Autoassigner::record_success('TEST Auto', $a, $b, $bed_a_text);
             $successes[] = HMS_Autoassigner::record_success('TEST Auto', $b, $a, $bed_b_text);
         } else {
             $result = HMS_Autoassigner::assign($a, $room->_beds[0], $term);
             if ($result === TRUE) {
                 $successes[] = HMS_Autoassigner::record_success('Auto', $a, $b, $bed_a_text);
                 $assigned[] = $a->username;
             } else {
                 $problems[] = $result;
             }
             if (!is_null($b->id)) {
                 $result = HMS_Autoassigner::assign($b, $room->_beds[1], $term);
                 if ($result === TRUE) {
                     $successes[] = HMS_Autoassigner::record_success('Auto', $b, $a, $bed_b_text);
                     $assigned[] = $b->username;
                 } else {
                     $problems[] = $result;
                 }
             }
         }
     }
     $f_f_count = count($f_rooms);
     $f_m_count = count($m_rooms);
     usort($successes, array('HMS_Autoassigner', 'sort_successes'));
     $content = '<h1>Autoassigner Results - ' . date('Y-m-d') . '</h1>';
     $content .= '<h2>Total Assignments: ' . count($assigned) . '</h2>';
     $content .= "<p>Began with {$i_f_count} female rooms and {$i_m_count} male rooms</p>";
     $content .= "<p>Ended with {$f_f_count} female rooms and {$f_m_count} male rooms</p>";
     $content .= '<h2>Assignment Report (' . count($successes) . ')</h2>';
     $content .= '<table><tr>';
     $content .= '<th>Type</th><th>Bed A</th><th>Code A</th><th>Bed B</th><th>Code B</th><th>Room</th>';
     $content .= '</tr>';
     foreach ($successes as $success) {
         $content .= '<tr>';
         $content .= '<td>' . $success['type'] . '</td>';
         $content .= '<td>' . $success['a'] . '</td>';
         $content .= '<td>' . $success['a_code'] . '</td>';
         $content .= '<td>' . $success['room'] . '</td>';
         $content .= '<td>' . $success['b'] . '</td>';
         $content .= '<td>' . $success['b_code'] . '</td>';
         $content .= "</tr>\n";
     }
     $content .= '</tr></table>';
     sort($problems);
     $content .= '<h2>Problems (' . count($problems) . ')</h2>';
     $content .= implode("<br />\n", $problems);
     sort($rlcs);
     $content .= '<h2>Skipped for RLC (' . count($rlcs) . ')</h2>';
     $content .= implode("<br />\n", $rlcs);
     sort($assigns);
     $content .= '<h2>Skipped, already assigned (' . count($assigns) . ')</h2>';
     $content .= implode("<br />\n", $assigns);
     sort($notices);
     $content .= '<h2>Notices (' . count($notices) . ')</h2>';
     $content .= implode("<br />\n", $notices);
     Layout::nakedDisplay($content, NULL, TRUE);
 }
Exemplo n.º 15
0
 public static function permission()
 {
     if (!isset($_REQUEST['key_id'])) {
         return;
     }
     $key = new Key((int) $_REQUEST['key_id']);
     if (!Key::checkKey($key, false)) {
         return;
     }
     if (Current_User::isRestricted($key->module) || !$key->allowEdit()) {
         Current_User::disallow();
     }
     // View permissions must be first to allow error checking
     // Edit will add its list to the view
     Users_Permission::postViewPermissions($key);
     Users_Permission::postEditPermissions($key);
     $result = $key->savePermissions();
     if (isset($_POST['popbox'])) {
         Layout::nakedDisplay(javascript('close_refresh', array('refresh' => 0)));
     } else {
         if (PHPWS_Error::logIfError($result)) {
             $_SESSION['Permission_Message'] = dgettext('users', 'An error occurred.');
         } else {
             $_SESSION['Permission_Message'] = dgettext('users', 'Permissions updated.');
         }
         PHPWS_Core::goBack();
     }
 }
Exemplo n.º 16
0
 public function postSchedule()
 {
     $default_public = PHPWS_Settings::get('calendar', 'public_schedule');
     if ($this->calendar->schedule->post()) {
         if (!$this->allowSchedulePost()) {
             Current_User::disallow();
             return;
         }
         $result = $this->calendar->schedule->save();
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
             if (PHPWS_Calendar::isJS()) {
                 $this->sendMessage(dgettext('calendar', 'An error occurred when saving your schedule.'), null, false);
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             } else {
                 $this->sendMessage(dgettext('calendar', 'An error occurred when saving your schedule.'), 'aop=schedules');
             }
         } else {
             if ($this->calendar->schedule->public && $default_public < 1) {
                 PHPWS_Settings::set('calendar', 'public_schedule', $this->calendar->schedule->id);
                 PHPWS_Settings::save('calendar');
             }
             if (!$this->calendar->schedule->public && $this->calendar->schedule->id == $default_public) {
                 PHPWS_Settings::set('calendar', 'public_schedule', 0);
                 PHPWS_Settings::save('calendar');
             }
             if (PHPWS_Calendar::isJS()) {
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             } else {
                 $this->sendMessage(dgettext('calendar', 'Schedule saved.'), 'aop=schedules');
             }
         }
     } else {
         $this->message = $this->calendar->schedule->_error;
         $this->editSchedule();
     }
 }
Exemplo n.º 17
0
 public function checkPermission()
 {
     if (!isset($this->contact) || !$this->contact->id || $this->contact->id != $_SESSION['Contact_User']->id || !$this->contact->checkKey()) {
         unset($_SESSION['Contact_User']);
         \Layout::nakedDisplay('Command not allowed. <a href=".">Return to home page.</a>');
         exit;
     }
 }
Exemplo n.º 18
0
 function userMenu($action = null)
 {
     $javascript = false;
     if (empty($action)) {
         if (!isset($_REQUEST['uop'])) {
             PHPWS_Core::errorPage('404');
         }
         $action = $_REQUEST['uop'];
     }
     $this->loadMessage();
     switch ($action) {
         case 'view':
             $this->title = PHPWS_Settings::get('whatsnew', 'title');
             $this->content = $this->whatsnewBlock();
             break;
     }
     $tpl['TITLE'] = $this->title;
     $tpl['CONTENT'] = $this->content;
     $tpl['MESSAGE'] = $this->message;
     if ($javascript) {
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'whatsnew', 'main_user.tpl'));
     } else {
         Layout::add(PHPWS_Template::process($tpl, 'whatsnew', 'main_user.tpl'));
     }
 }
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 action()
 {
     switch ($_REQUEST['page_op']) {
         case 'edit':
             $template['TITLE'] = dgettext('wiki', 'Edit') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->edit();
             break;
         case 'save':
             $template['TITLE'] = dgettext('wiki', 'Edit') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->post();
             break;
         case 'delete':
             $template['TITLE'] = dgettext('wiki', 'Delete') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->kill();
             break;
         case 'raw':
             Header('Content-type: text/plain');
             echo $this->getPagetext(FALSE);
             exit;
             break;
         case 'print':
             Layout::nakedDisplay($this->view());
             break;
         case 'history':
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $this->history();
             break;
         case 'viewold':
             PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
             $oldpage = new OldWikiPage($_REQUEST['id']);
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $oldpage->view();
             break;
         case 'restore':
             PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
             $oldpage = new OldWikiPage($_REQUEST['id']);
             $oldpage->restore($this->hits);
             /* Does not return */
             break;
         case 'removeold':
             PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
             $oldpage = new OldWikiPage($_REQUEST['id']);
             $oldpage->remove();
             /* Does not return */
             break;
         case 'compare':
             PHPWS_Core::initModClass('wiki', 'WikiDiff.php');
             $wikiDiff = new WikiDiff(PHPWS_Settings::get('wiki', 'diff_type'));
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $wikiDiff->diff($_REQUEST['oVer'], $_REQUEST['nVer']);
             break;
         case 'whatlinkshere':
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $this->whatLinksHere();
             break;
         case 'move':
             $template['TITLE'] = dgettext('wiki', 'Move') . ' ' . $this->getTitle();
             $template['CONTENT'] = $this->move();
             break;
         case 'do_move':
             /* Function never returns: user will be redirected to new page. */
             $this->doMove();
             break;
         case 'discussion':
             $template['TITLE'] = $this->getTitle() . ' ' . dgettext('wiki', 'Discussion');
             $template['CONTENT'] = $this->discussion();
             break;
         case 'togglelock':
             $this->toggleLock();
             PHPWS_Core::goBack();
             break;
         default:
             $this->incHits();
             $template['TITLE'] = $this->getTitle();
             $template['CONTENT'] = $this->view();
             $template['CATEGORIES'] = $this->getCategories();
     }
     Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
 }
Exemplo n.º 21
0
 /**
  * Pathing for which view to display
  */
 public function view()
 {
     require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Event.php';
     $key = new Key($this->calendar->schedule->key_id);
     if (!$key->allowView()) {
         $this->calendar->loadDefaultSchedule();
     }
     $schedule_key = $this->calendar->schedule->getKey();
     if (!$this->calendar->schedule->public && !$schedule_key->allowView()) {
         PHPWS_Core::errorPage('403');
     }
     \Layout::disableRobots();
     $current_date = $this->calendar->current_date * 1000;
     switch ($this->current_view) {
         case 'day':
             $this->content = $this->day();
             break;
         case 'grid':
             if (ALLOW_CACHE_LITE && Current_User::allow('calendar')) {
                 if (strftime('%Y%m', $this->calendar->today) == strftime('%Y%m', $this->calendar->current_date)) {
                     $current_date = $this->calendar->today * 1000;
                 }
                 $this->resetCacheLink('grid', $this->calendar->int_month, $this->calendar->int_year, $this->calendar->schedule->id);
             }
             $this->content = $this->month_grid();
             break;
         case 'list':
             if (ALLOW_CACHE_LITE && Current_User::allow('calendar')) {
                 $this->resetCacheLink('list', $this->calendar->int_month, $this->calendar->int_year, $this->calendar->schedule->id);
             }
             $this->content = $this->month_list();
             break;
         case 'week':
             $this->content = $this->week();
             break;
         case 'event':
             if (isset($_REQUEST['page'])) {
                 $event_id = (int) $_REQUEST['page'];
             } elseif (isset($_REQUEST['event_id'])) {
                 $event_id = $_REQUEST['event_id'];
             } else {
                 $this->content = $this->day();
             }
             if (!$this->loadEvent($event_id) || !$this->event->id) {
                 $this->content = $this->day();
                 break;
             }
             if (isset($_REQUEST['js'])) {
                 $this->content = $this->event(true);
                 Layout::nakedDisplay($this->content);
                 return;
             } else {
                 $this->content = $this->event();
             }
             break;
         default:
             $this->content = dgettext('calendar', 'Incorrect option');
             break;
     }
     if ($this->calendar->schedule->checkPermissions()) {
         if ($this->calendar->schedule->id) {
             require_once PHPWS_SOURCE_DIR . 'mod/calendar/class/Admin.php';
             $event = new Calendar_Event(0, $this->calendar->schedule);
             Layout::add(\Calendar_Admin::eventModal($event));
             \Calendar_Admin::includeEventJS();
             $link = '<a style="cursor:pointer" class="add-event" data-schedule-id="' . $this->calendar->schedule->id . '" data-date="' . $current_date * 1000 . '">Add event</a>';
             MiniAdmin::add('calendar', $link);
             MiniAdmin::add('calendar', $this->calendar->schedule->uploadEventsLink());
         }
     }
     if ($this->current_view == 'event') {
         $this->event->flagKey();
     } else {
         $schedule_key->flag();
     }
 }
Exemplo n.º 22
0
 public function postHeader()
 {
     PHPWS_Core::initModClass('pagesmith', 'PS_Text.php');
     $header = strip_tags($_POST['header'], PS_ALLOWED_HEADER_TAGS);
     $section = new PS_Text();
     $section->pid = $_POST['pid'];
     $section->secname = $_POST['section_name'];
     $section->content = PHPWS_Text::parseInput($header);
     $section->setSaved();
     $vars['cnt_section_name'] = $_POST['tpl'] . '-' . $_POST['section_name'];
     //$vars['hdn_section_name'] = sprintf('pagesmith_%s', $_POST['section_name']);
     $vars['content'] = addslashes(PHPWS_Text::parseOutput($section->content));
     $vars['hidden_value'] = $section->content;
     Layout::nakedDisplay(javascriptMod('pagesmith', 'update', $vars));
 }
Exemplo n.º 23
0
 public static function main()
 {
     $tpl['MESSAGE'] = NULL;
     $message = RSS_Admin::getMessage();
     PHPWS_Core::initModClass('rss', 'Feed.php');
     PHPWS_Core::initModClass('rss', 'Channel.php');
     if (!Current_User::allow('rss')) {
         Current_User::disallow();
     }
     $panel = RSS_Admin::adminPanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } elseif (isset($_REQUEST['tab'])) {
         $command = $_REQUEST['tab'];
     } else {
         $command = $panel->getCurrentTab();
     }
     if (isset($_REQUEST['channel_id'])) {
         $channel = new RSS_Channel($_REQUEST['channel_id']);
     } else {
         $channel = new RSS_Channel();
     }
     if (isset($_REQUEST['feed_id'])) {
         $feed = new RSS_Feed($_REQUEST['feed_id']);
     } else {
         $feed = new RSS_Feed();
     }
     switch ($command) {
         case 'channels':
             $tpl = RSS_Admin::channels();
             break;
         case 'settings':
             $tpl = RSS_Admin::settings();
             break;
         case 'save_settings':
             $result = RSS_Admin::save_settings();
             if (!$result) {
                 PHPWS_Settings::save('rss');
                 $result = dgettext('rss', 'Settings saved successfully.');
             }
             $tpl = RSS_Admin::settings();
             $tpl['MESSAGE'] =& $result;
             break;
         case 'feedInfo':
             $feed = new RSS_Feed(filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT));
             echo json_encode($feed);
             exit;
             break;
         case 'save_feed':
             $result = $feed->post();
             if (is_array($result)) {
                 $tpl['CONTENT'] = RSS_Admin::editFeed($feed, true);
                 $tpl['MESSAGE'] = implode('<br />', $result);
             } else {
                 $result = $feed->save();
                 PHPWS_Core::reroute('index.php?module=rss&tab=import');
             }
             break;
         case 'edit_channel':
             $tpl = RSS_Admin::editChannel($channel);
             break;
         case 'post_channel':
             $result = $channel->post();
             if (is_array($result)) {
                 $message = implode('<br />', $result);
                 $tpl = RSS_Admin::editChannel($channel);
             } else {
                 $result = $channel->save();
                 if (PHPWS_Error::isError($result)) {
                     RSS_Admin::sendMessage(dgettext('rss', 'An error occurred when saving your channel.'), 'channels');
                 } else {
                     RSS_Admin::sendMessage(dgettext('rss', 'Channel saved.'), 'channels');
                 }
             }
             break;
         case 'reset_feed':
             $feed->reset();
         case 'import':
             $tpl = RSS_Admin::import();
             break;
         case 'turn_on_display':
             $feed->display = 1;
             $feed->save();
             $tpl = RSS_Admin::import();
             break;
         case 'turn_off_display':
             $feed->display = 0;
             $feed->save();
             $tpl = RSS_Admin::import();
             break;
         case 'add_feed':
             $tpl = RSS_Admin::editFeed($feed);
             Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl'));
             exit;
             break;
         case 'edit_feed':
             $tpl = RSS_Admin::editFeed($feed);
             Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl'));
             exit;
             break;
         case 'delete_feed':
             $feed->delete();
             $tpl = RSS_Admin::import();
             break;
         default:
             PHPWS_Core::errorPage('404');
             break;
     }
     if (!empty($message)) {
         $tpl['MESSAGE'] = $message;
     }
     $content = PHPWS_Template::process($tpl, 'rss', 'main.tpl');
     $panel->setContent($content);
     $content = $panel->display();
     Layout::add(PHPWS_ControlPanel::display($content));
 }
Exemplo n.º 24
0
 public function userMenu($action = null)
 {
     $javascript = false;
     if (empty($action)) {
         if (!isset($_REQUEST['uop'])) {
             PHPWS_Core::errorPage('404');
         }
         $action = $_REQUEST['uop'];
     }
     switch ($action) {
         case 'message':
             $this->loadMessage();
             if (empty($this->message)) {
                 PHPWS_Core::home();
             }
             $this->title = dgettext('signup', 'Signup');
             break;
         case 'signup_sheet':
             $this->loadPeep();
             $this->loadForm('user_signup');
             break;
         case 'slot_signup':
             if ($this->postPeep()) {
                 if ($this->saveUnregistered()) {
                     $this->forwardMessage(dgettext('signup', 'You should receive an email allowing you to verify your application.<br />You have one hour to confirm your application.'), dgettext('signup', 'Thank you'));
                     $this->sendMessage();
                 } else {
                     $this->loadForm('user_signup');
                 }
             } else {
                 $this->loadForm('user_signup');
             }
             break;
         case 'confirm':
             $this->confirmPeep();
             $this->purgeOverdue();
             break;
     }
     $tpl['TITLE'] = $this->title;
     $tpl['MESSAGE'] = $this->message;
     $tpl['CONTENT'] = $this->content;
     if ($javascript) {
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'signup', 'usermain.tpl'));
     } else {
         Layout::add(PHPWS_Template::process($tpl, 'signup', 'usermain.tpl'));
     }
 }