Пример #1
0
 /**
  * Looks for an entry with the 'magic_winner' flag set and returns it, otherwise it returns null
  */
 public static function check_magic_winner($term)
 {
     $now = time();
     $query = "SELECT * FROM hms_new_application JOIN hms_lottery_application ON hms_new_application.id = hms_lottery_application.id\n                    LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$term}) as foo ON hms_new_application.username = foo.asu_username\n                    WHERE foo.asu_username IS NULL AND (hms_lottery_application.invite_expires_on < {$now} OR hms_lottery_application.invite_expires_on IS NULL)\n                    AND hms_new_application.term = {$term}\n                    AND hms_lottery_application.magic_winner = 1";
     $result = PHPWS_DB::getRow($query);
     if (PEAR::isError($result)) {
         PHPWS_Error::log($result);
         return null;
     }
     if (!isset($result) || empty($result)) {
         return null;
     } else {
         return $result;
     }
 }
 /**
  * Returns a Department object based on the given department ID.
  * @param unknown $id
  * @return Department
  */
 public static function getDepartmentById($id)
 {
     // Sanity checking
     if (!isset($id) || $id === '') {
         throw new \InvalidArgumentException('Missing department ID.');
     }
     // Query
     $query = "SELECT * FROM intern_department WHERE id = {$id}";
     $result = \PHPWS_DB::getRow($query);
     if (\PHPWS_Error::isError($result)) {
         throw new DatabaseException($result->toString());
     }
     if (sizeof($result) == 0) {
         return null;
     }
     // Create the object and set member variables
     $department = new DepartmentDB();
     $department->setId($result['id']);
     $department->setName($result['name']);
     $department->setHidden($result['hidden']);
     $department->setCorequisite($result['corequisite']);
     return $department;
 }
 public static function getFacultyObjectById($id)
 {
     if (!isset($id)) {
         throw new \InvalidArgumentException('Missing faculty id.');
     }
     $sql = "SELECT intern_faculty.* FROM intern_faculty WHERE intern_faculty.id = {$id}";
     $row = \PHPWS_DB::getRow($sql);
     if (\PHPWS_Error::logIfError($row)) {
         throw new Exception($row);
     }
     $faculty = new FacultyDB();
     $faculty->setId($row['id']);
     $faculty->setUsername($row['username']);
     $faculty->setFirstName($row['first_name']);
     $faculty->setLastName($row['last_name']);
     $faculty->setPhone($row['phone']);
     $faculty->setFax($row['fax']);
     $faculty->setStreetAddress1($row['street_address1']);
     $faculty->setStreetAddress2($row['street_address2']);
     $faculty->setCity($row['city']);
     $faculty->setState($row['state']);
     $faculty->setZip($row['zip']);
     return $faculty;
 }
Пример #4
0
 /**
  *
  *
  *
  *
  */
 function view($showLinks = TRUE)
 {
     /* Find the key into the entries array for the selected entry */
     foreach ($this->_entries as $entryKey => $entryValue) {
         if ($entryValue['id'] == $_REQUEST['PHAT_ENTRY_ID']) {
             break;
         }
     }
     /* Get the data for the selected entry from the database */
     $sql = 'SELECT * FROM ' . $this->getFormTable() . " WHERE id='" . $_REQUEST['PHAT_ENTRY_ID'] . "'";
     $entry = PHPWS_DB::getRow($sql);
     $rowClass = NULL;
     $entryTags = array();
     $entryTags['ENTRY_DATA'] = NULL;
     /* Step through the entries values and feed them through the entryRow template */
     $toggle = 1;
     foreach ($entry as $key => $value) {
         $rowTags = array();
         if ($key == 'position') {
             continue;
         } elseif ($key == 'updated') {
             $value = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $value);
         }
         $attribute = ' class="bgcolor1" ';
         /* Toggle the row colors for better visability */
         if ($toggle % 2) {
             $rowClass = $attribute;
         } else {
             $rowClass = null;
         }
         $toggle++;
         if (isset($rowClass)) {
             $rowTags['ROW_CLASS'] = $rowClass;
         }
         $rowTags['ENTRY_LABEL'] = $key;
         if (preg_match('/a:\\d+:{/', $value)) {
             $rowTags['ENTRY_VALUE'] = implode(', ', unserialize($value));
         } else {
             $rowTags['ENTRY_VALUE'] = PHPWS_Text::parseOutput($value, ENCODE_PARSED_TEXT, false, true);
         }
         $entryTags['ENTRY_DATA'] .= PHPWS_Template::processTemplate($rowTags, 'phatform', 'report/entryRow.tpl');
     }
     if (isset($this->archive)) {
         $entryTags['BACK_LINK'] = $_SESSION['PHAT_advViews']->getArchiveViewLink();
     }
     if ($showLinks && !isset($_REQUEST['lay_quiet'])) {
         $entryTags['PRINT'] = '<a href="index.php?module=phatform&amp;PHAT_REPORT_OP=view&amp;PHAT_ENTRY_ID=' . $_REQUEST['PHAT_ENTRY_ID'] . '&amp;lay_quiet=1" target="_blank">' . dgettext('phatform', 'Print View') . '</a>';
         /* Show the next and/or previous links to step through entries */
         if ($entryKey < sizeof($this->_entries) - 1) {
             $entryTags['NEXT'] = '<a href="index.php?module=phatform&amp;PHAT_REPORT_OP=view&amp;PHAT_ENTRY_ID=' . $this->_entries[$entryKey + 1]['id'] . '">' . dgettext('phatform', 'Next Entry') . '</a>';
         }
         if ($entryKey > 0) {
             $entryTags['PREVIOUS'] = '<a href="index.php?module=phatform&amp;PHAT_REPORT_OP=view&amp;PHAT_ENTRY_ID=' . $this->_entries[$entryKey - 1]['id'] . '">' . dgettext('phatform', 'Previous Entry') . '</a>';
         }
     }
     $GLOBALS['CNT_phatform']['title'] = $_SESSION['PHAT_FormManager']->form->getLabel();
     /* Return the entire processed entry */
     if (isset($_REQUEST['lay_quiet'])) {
         echo PHPWS_Template::processTemplate($entryTags, 'phatform', 'report/entry.tpl');
     } else {
         return PHPWS_Template::processTemplate($entryTags, 'phatform', 'report/entry.tpl');
     }
 }
Пример #5
0
 private function getMagicWinner()
 {
     $query = "SELECT * FROM hms_new_application JOIN hms_lottery_application ON hms_new_application.id = hms_lottery_application.id\n                            LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term = {$this->term}) as foo ON hms_new_application.username = foo.asu_username\n                            WHERE foo.asu_username IS NULL AND (hms_lottery_application.invited_on IS NULL)\n                            AND hms_new_application.term = {$this->term}\n                            AND hms_lottery_application.magic_winner = 1";
     $result = PHPWS_DB::getRow($query);
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return $result;
 }
Пример #6
0
 function _editOptions()
 {
     if (Current_User::allow('phatform', 'edit_options')) {
         if (isset($_REQUEST['PHAT_OptionSetId']) && !is_numeric($_REQUEST['PHAT_OptionSetId']) || isset($_REQUEST['PHAT_OptionBack'])) {
             $_REQUEST['PHAT_MAN_OP'] = 'Options';
             $this->action();
             return;
         } else {
             $optionSetId = $_REQUEST['PHAT_OptionSetId'];
         }
         if (isset($_REQUEST['PHAT_SaveOptionSet'])) {
             if (is_array($_REQUEST['PHAT_ElementOptions']) && is_array($_REQUEST['PHAT_ElementValues'])) {
                 for ($i = 0; $i < sizeof($_REQUEST['PHAT_ElementOptions']); $i++) {
                     $_REQUEST['PHAT_ElementOptions'][$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementOptions'][$i]);
                     $_REQUEST['PHAT_ElementValues'][$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementValues'][$i]);
                 }
                 $options = addslashes(serialize($_REQUEST['PHAT_ElementOptions']));
                 $values = addslashes(serialize($_REQUEST['PHAT_ElementValues']));
                 $saveArray = array('optionSet' => $options, 'valueSet' => $values);
                 $db = new PHPWS_DB('mod_phatform_options');
                 $db->addWhere('id', $optionSetId);
                 $db->addValue($saveArray);
                 $db->update();
             }
         } else {
             if (isset($_REQUEST['PHAT_delete'])) {
                 $db = new PHPWS_DB('mod_phatform_options');
                 $db->addWhere('id', $optionSetId);
                 $db->delete();
                 $_REQUEST['PHAT_MAN_OP'] = 'Options';
                 $this->action();
                 return;
             }
         }
         $GLOBALS['CNT_phatform']['title'] = PHAT_TITLE;
         $sql = "SELECT * FROM mod_phatform_options WHERE id='{$optionSetId}'";
         $result = PHPWS_DB::getRow($sql);
         if ($result) {
             $elements = array();
             $elements[] = PHPWS_Form::formHidden('module', $this->_module);
             $elements[] = PHPWS_Form::formHidden('PHAT_MAN_OP', 'editOptions');
             $elements[] = PHPWS_Form::formHidden('PHAT_OptionSetId', $optionSetId);
             $options = unserialize(stripslashes($result['optionSet']));
             $values = unserialize(stripslashes($result['valueSet']));
             $editTags = array();
             $editTags['TITLE'] = dgettext('phatform', 'Edit option set') . "&#160;{$result['label']}";
             $editTags['NUMBER_LABEL'] = dgettext('phatform', 'Option');
             $editTags['INPUT_LABEL'] = dgettext('phatform', 'Text');
             $editTags['VALUE_LABEL'] = dgettext('phatform', 'Value');
             $editTags['OPTIONS'] = '';
             $rowClass = NULL;
             for ($i = 0; $i < sizeof($options); $i++) {
                 $optionRow['OPTION_NUMBER'] = $i + 1;
                 $optionRow['OPTION_INPUT'] = PHPWS_Form::formTextField("PHAT_ElementOptions[{$i}]", $options[$i], PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
                 $optionRow['VALUE_INPUT'] = PHPWS_Form::formTextField("PHAT_ElementValues[{$i}]", $values[$i], PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
                 $optionRow['ROW_CLASS'] = $rowClass;
                 if ($i % 2) {
                     $rowClass = ' class="bgcolor1"';
                 } else {
                     $rowClass = null;
                 }
                 $editTags['OPTIONS'] .= PHPWS_Template::processTemplate($optionRow, 'phatform', 'options/option.tpl');
             }
         }
         $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_OptionBack');
         $editTags['SAVE_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Save'), 'PHAT_SaveOptionSet');
         $elements[] = PHPWS_Template::processTemplate($editTags, 'phatform', 'options/optionList.tpl');
         return PHPWS_Form::makeForm('PHAT_Options_edit', 'index.php', $elements);
     } else {
         $this->_list();
     }
 }