Exemplo n.º 1
0
 public static function confirmThemeChange()
 {
     $form = new PHPWS_Form('confirmThemeChange');
     $form->addHidden('module', 'layout');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'confirmThemeChange');
     $form->addSubmit('confirm', dgettext('layout', 'Complete the theme change'));
     $form->addSubmit('decline', dgettext('layout', 'Restore the default theme'));
     $address = 'index.php?module=layout&action=admin&command=demo_fail';
     Layout::metaRoute($address, 10);
     $tpl = $form->getTemplate();
     return $tpl['START_FORM'] . $tpl['CONFIRM'] . $tpl['DECLINE'] . $tpl['END_FORM'];
 }
Exemplo n.º 2
0
 /**
  * Directs the administrative choices
  * Content is displayed in main
  */
 public function direct()
 {
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $this->panel->getCurrentTab();
     }
     switch ($command) {
         case 'new':
             $this->resetAdmin();
             $this->edit_db();
             break;
         case 'edit':
             // editing existing branch
             if (empty($this->branch->id)) {
                 $this->content = dgettext('branch', 'Incorrect or missing branch id.');
             }
             break;
         case 'list':
             // list all branches in the system
             $this->listBranches();
             break;
         case 'post_db':
             // post a new or updated branch to the system
             if (isset($_POST['plug'])) {
                 // user is going to use the hub dsn information
                 $this->plugHubValues();
                 $this->edit_db();
             } else {
                 if (!$this->post_db()) {
                     $this->edit_db();
                 } else {
                     $this->testDB(!empty($_POST['force']));
                 }
             }
             break;
         case 'edit_branch':
             $this->edit_basic();
             break;
         case 'post_basic':
             if (!$this->branch->id) {
                 $new_branch = true;
             } else {
                 $new_branch = false;
             }
             if (!$this->post_basic()) {
                 $this->edit_basic();
             } else {
                 $result = $this->branch->save();
                 if (PHPWS_Error::isError($result)) {
                     PHPWS_Error::log($result);
                     $this->title = dgettext('branch', 'An error occurred while saving your branch.');
                     $this->content = $result->getMessage();
                     return;
                 }
                 if ($new_branch) {
                     if ($this->branch->createDirectories()) {
                         $this->setCreateStep(3);
                         $this->title = dgettext('branch', 'Create branch directories');
                         $this->message[] = dgettext('branch', 'Branch created successfully.');
                         $this->install_branch_core();
                     } else {
                         $this->title = dgettext('branch', 'Unable to create branch directories.');
                         $this->content = dgettext('branch', 'Sorry, but Branch failed to make the proper directories.');
                     }
                 } else {
                     $this->listBranches();
                 }
             }
             break;
         case 'install_branch_core':
             $this->install_branch_core();
             break;
         case 'core_module_installation':
             $result = $this->core_module_installation();
             if ($result) {
                 $this->content[] = dgettext('branch', 'All done!');
                 $this->resetAdmin();
             } elseif ($_SESSION['Boost']->currentDone()) {
                 $meta = sprintf('index.php?module=branch&command=core_module_installation&branch_id=%s&authkey=%s', $this->branch->id, Current_User::getAuthKey());
                 Layout::metaRoute($meta);
             }
             break;
         case 'remove_branch':
             if (isset($_REQUEST['branch_id']) && isset($_REQUEST['branch_name']) && $this->branch->branch_name === $_REQUEST['branch_name']) {
                 $this->branch->delete();
             }
             $this->listBranches();
             break;
         case 'force_install':
             $this->setCreateStep(2);
             $this->saveDSN();
             $this->message[] = dgettext('branch', 'Connection successful. Database available.');
             $this->edit_basic();
             break;
     }
     // end of the command switch
 }
Exemplo n.º 3
0
 public function successfulSignup($user)
 {
     switch (PHPWS_User::getUserSetting('new_user_method')) {
         case AUTO_SIGNUP:
             $result = User_Action::saveNewUser($user, true);
             if ($result) {
                 User_Action::assignDefaultGroup($user);
                 $content[] = dgettext('users', 'Account created successfully!');
                 $content[] = dgettext('users', 'You will return to the home page in five seconds.');
                 $content[] = PHPWS_Text::moduleLink(dgettext('users', 'Click here if you are not redirected.'));
                 Layout::metaRoute();
             } else {
                 $content[] = dgettext('users', 'An error occurred when trying to create your account. Please try again later.');
             }
             break;
         case CONFIRM_SIGNUP:
             if (User_Action::saveNewUser($user, false)) {
                 if (User_Action::confirmEmail($user)) {
                     $content[] = dgettext('users', 'User created successfully. Check your email for your login information.');
                 } else {
                     $result = $user->kill();
                     PHPWS_Error::logIfError($result);
                     $content[] = dgettext('users', 'There was problem creating your acccount. Check back later.');
                 }
             } else {
                 $content[] = dgettext('users', 'There was problem creating your acccount. Check back later.');
             }
     }
     return implode('<br />', $content);
 }
Exemplo n.º 4
0
 public function waiting($small_view = false)
 {
     Layout::addStyle('checkin');
     javascriptMod('checkin', 'send_note');
     $this->title = dgettext('checkin', 'Waiting list');
     if (!$this->current_staff) {
         $this->content = dgettext('checkin', 'You are not a staff member.');
         return;
     }
     // Load all visitors for this staff member
     $this->loadVisitorList($this->current_staff->id);
     // No visitors found, load all the visitors that are unassigned.
     if (empty($this->visitor_list)) {
         $tpl['MESSAGE'] = dgettext('checkin', 'You currently do not have any visitors.');
         if (PHPWS_Settings::get('checkin', 'unassigned_seen')) {
             $this->loadVisitorList(0);
             if (!empty($this->visitor_list)) {
                 $this->unassigned_only = true;
                 $tpl['MESSAGE'] .= '<br />' . sprintf(dgettext('checkin', 'There are %s unassigned visitors.'), count($this->visitor_list));
             }
         }
     } else {
         foreach ($this->visitor_list as $vis) {
             if ($vis->id == $this->current_staff->visitor_id) {
                 $current_vis = $vis;
                 continue;
             }
             if (!isset($first_visitor)) {
                 $first_visitor = $vis->id;
             }
             $row = $links = array();
             $row = $vis->row(null, $this->current_staff);
             $tpl['list'][] = $row;
         }
     }
     $this->current_visitor = $this->visitor_list[0];
     $this->statusButtons($tpl);
     if ($small_view) {
         $tpl['REDUCE'] = 'small-view';
         $tpl['CLOSE'] = sprintf('<input type="button" onclick="window.close()" value="%s" />', dgettext('checkin', 'Close'));
         Layout::metaRoute('index.php?module=checkin&aop=small_wait', PHPWS_Settings::get('checkin', 'waiting_refresh'));
     } else {
         $tpl['HIDE_PANEL'] = $this->hidePanelLink();
         $tpl['HIDE_SIDEBAR'] = $this->hideSidebarLink();
         $tpl['SMALL_VIEW'] = $this->smallViewLink();
         $tpl['REFRESH'] = sprintf('<a href="index.php?module=checkin&tab=waiting">%s</a>', dgettext('checkin', 'Refresh'));
         Layout::metaRoute('index.php?module=checkin&aop=waiting', PHPWS_Settings::get('checkin', 'waiting_refresh'));
     }
     $tpl['NAME_LABEL'] = dgettext('checkin', 'Name / Notes');
     $tpl['WAITING_LABEL'] = dgettext('checkin', 'Time waiting');
     $tpl['SENDBANK'] = 'what what';
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'waiting.tpl');
 }
Exemplo n.º 5
0
 /**
  * Sends everyone (limited by search) in a specific sheet an email
  */
 public function sendEmail()
 {
     PHPWS_Core::initCoreClass('Mail.php');
     if (!isset($_SESSION['Email_Applicants'])) {
         $_SESSION['Email_Applicants']['email'] =& $this->email;
         $_SESSION['Email_Applicants']['sheet_id'] = $this->sheet->id;
         $_SESSION['Email_Applicants']['search'] = @$_REQUEST['search'];
         $vars['aop'] = 'send_email';
         Layout::metaRoute(PHPWS_Text::linkAddress('signup', $vars, true), 1);
         $this->title = dgettext('signup', 'Sending emails');
         $this->content = dgettext('signup', 'Please wait');
         return;
     }
     $email_session =& $_SESSION['Email_Applicants'];
     $mail = new PHPWS_Mail();
     $mail->setSubject($email_session['email']['subject']);
     $mail->setFrom($email_session['email']['from']);
     $mail->setReplyTo($email_session['email']['from']);
     $mail->setMessageBody($email_session['email']['message']);
     $mail->sendIndividually(true);
     $this->loadSheet($email_session['sheet_id']);
     if (!$this->sheet->id) {
         $this->title = dgettext('signup', 'Sorry');
         $this->content = dgettext('signup', 'Unable to send emails. Signup sheet does not exist.');
         PHPWS_Core::killSession('Email_Applicants');
         return;
     }
     $db = new PHPWS_DB('signup_peeps');
     $db->addColumn('email');
     $db->addWhere('sheet_id', $this->sheet->id);
     if (isset($email_session['search'])) {
         $search = explode('+', $email_session['search']);
         foreach ($search as $s) {
             $db->addWhere('first_name', "%{$s}%", 'like', 'or', 1);
             $db->addWhere('last_name', "%{$s}%", 'like', 'or', 1);
         }
     }
     $result = $db->select('col');
     if (empty($result)) {
         $this->title = dgettext('signup', 'Emails not sent');
         $this->content = dgettext('signup', 'Signup sheet did not contain any applicants.');
         return;
     } elseif (PHPWS_Error::logIfError($result)) {
         $this->title = dgettext('signup', 'Emails not sent');
         $this->content = dgettext('signup', 'An error occurred when pulling applicants.');
         return;
     }
     foreach ($result as $address) {
         $mail->addSendTo($address);
     }
     $mail->send();
     $vars['aop'] = 'report';
     $vars['sheet_id'] = $this->sheet->id;
     $link = PHPWS_Text::linkAddress('signup', $vars, true);
     $this->title = dgettext('signup', 'Emails sent');
     $this->content = dgettext('signup', 'Returning to applicant listing.');
     Layout::metaRoute($link, 5);
     PHPWS_Core::killSession('Email_Applicants');
 }
Exemplo n.º 6
0
 public function process($command = null)
 {
     if (empty($command)) {
         @($command = $_REQUEST['uop']);
     }
     switch ($command) {
         case 'checkin_form':
             $this->checkinForm();
             break;
         case 'error':
             $this->title = dgettext('checkin', 'Sorry');
             $this->content = dgettext('checkin', 'An error is preventing your account to save. Please alert the office.');
             Layout::metaRoute('index.php', 5);
             break;
         case 'thank':
             $this->title = dgettext('checkin', 'Thank you');
             $this->loadReason();
             $this->content = $this->reason->message;
             Layout::metaRoute('index.php', 5);
             break;
         case 'post_checkin':
             if ($this->postCheckin()) {
                 if (PHPWS_Error::logIfError($this->visitor->save())) {
                     PHPWS_Core::reroute('index.php?module=checkin&uop=error');
                 } else {
                     PHPWS_Core::reroute('index.php?module=checkin&uop=thank&reason_id=' . $_POST['reason_id']);
                 }
             } else {
                 $this->checkinForm();
             }
             break;
         default:
             PHPWS_Core::errorPage('404');
     }
     Layout::add($this->main());
 }