Пример #1
0
function showFP()
{
    $db = new PHPWS_DB('ps_page');
    $db->addWhere('front_page', 1);
    if ($db->isTableColumn('deleted')) {
        $db->addWhere('deleted', 0);
    }
    Key::restrictView($db, 'pagesmith');
    $db->loadClass('pagesmith', 'PS_Page.php');
    $result = $db->getObjects('PS_Page');
    if (!PHPWS_Error::logIfError($result) && !empty($result)) {
        PHPWS_Core::initModClass('pagesmith', 'PageSmith.php');
        foreach ($result as $page) {
            $content = $page->view();
            if ($content && !PHPWS_Error::logIfError($content)) {
                if (Current_User::allow('pagesmith', 'edit_page', $page->id)) {
                    $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink());
                }
                Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE);
            }
        }
    } else {
        return null;
    }
}
Пример #2
0
 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     $term = $this->term;
     $db = new PHPWS_DB('hms_checkin');
     // Join hall structure
     $db->addJoin('', 'hms_checkin', 'hms_hall_structure', 'bed_id', 'bedid');
     $db->addColumn('hms_checkin.banner_id');
     $db->addColumn('hms_checkin.checkin_date');
     $db->addColumn('hms_hall_structure.hall_name');
     $db->addColumn('hms_hall_structure.room_number');
     $db->addWhere('hms_checkin.term', $term);
     $db->addWhere('hms_checkin.checkout_date', null, 'IS NULL');
     // Sort by hall, then room number
     $db->addOrder(array('hms_hall_structure.hall_name ASC', 'hms_hall_structure.room_number ASC'));
     $results = $db->select();
     if (PHPWS_Error::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     // Post-processing, cleanup, making it pretty
     foreach ($results as $row) {
         // Updates counts
         $this->total++;
         $row['checkin_date'] = HMS_Util::get_short_date_time($row['checkin_date']);
         // Copy the cleaned up row to the member var for data
         $this->data[] = $row;
     }
 }
Пример #3
0
 public function execute(CommandContext $context)
 {
     // Check for report ID
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentException('Missing report id.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     // Load the report to get its class
     try {
         $report = ReportFactory::getReportById($reportId);
     } catch (InvalidArgumentException $e) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
         $context->goBack();
     }
     $db = new PHPWS_DB('hms_report');
     $db->addWhere('id', $reportId);
     $result = $db->delete();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
     $cmd = CommandFactory::getCommand('ShowReportDetail');
     $cmd->setReportClass($report->getClass());
     $cmd->redirect();
 }
Пример #4
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'edit_role_members')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit role members.');
     }
     $username = $context->get('username');
     $rolename = $context->get('role');
     $class = $context->get('className');
     $instance = $context->get('instance');
     if (is_null($username) || is_null($rolename)) {
         echo json_encode(false);
         exit;
     }
     $db = new PHPWS_DB('hms_role');
     $db->addWhere('name', $rolename);
     $result = $db->select('row');
     if (PHPWS_Error::logIfError($result) || is_null($result['id'])) {
         echo json_encode(false);
         exit;
     }
     $role_id = $result['id'];
     $role = new HMS_Role();
     $role->id = $role_id;
     if ($role->load()) {
         echo json_encode($role->removeUser($username, $class, $instance));
         exit;
     }
     echo json_encode(false);
     exit;
 }
 public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $messageAll = Current_User::allow('hms', 'email_all');
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addWhere('term', $term);
     $results = $db->getObjects('HMS_Residence_Hall');
     if (PHPWS_Error::logIfError($results) || is_null($results)) {
         $errorMsg = array();
         if (is_null($results)) {
             $errorMsg['error'] = 'You do not have permission to message any halls, sorry.';
         } else {
             $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page.  If the problem persists contact ESS.';
         }
         echo json_encode($errorMsg);
         exit;
     }
     $permission = new HMS_Permission();
     $data = array();
     foreach ($results as $hall) {
         $somethingEnabled = false;
         $floors = $hall->get_floors();
         unset($obj);
         $obj = new stdClass();
         $obj->name = $hall->getHallName();
         $obj->id = $hall->getId();
         $obj->floors = array();
         //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false');
         if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) {
             $obj->enabled = true;
             $somethingEnabled = true;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = true;
                 $obj->floors[] = $floor_obj;
             }
         } else {
             $obj->enabled = false;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email');
                 $obj->floors[] = $floor_obj;
                 if ($floor_obj->enabled) {
                     $somethingEnabled = true;
                 }
             }
         }
         if ($somethingEnabled) {
             $data[] = $obj;
         }
     }
     echo json_encode($data);
     exit;
 }
Пример #6
0
 public function setTabs($tabs)
 {
     if (!is_array($tabs)) {
         return PHPWS_Error::get(CP_BAD_TABS, 'controlpanel', 'setTabs');
     }
     $this->tabs =& $tabs;
 }
 public static function saveObject(DbStorable $o)
 {
     $vars = $o->extractVars();
     $tableName = $o::getTableName();
     // Check if the key already exists
     $query = "SELECT * FROM {$tableName} WHERE id = {$vars['id']}";
     $result = \PHPWS_DB::getAll($query);
     if (count($result) > 0) {
         $exists = true;
     } else {
         $exists = false;
     }
     $db = new \PHPWS_DB($o->getTableName());
     foreach ($vars as $key => $value) {
         $db->addValue($key, $value);
     }
     if ($exists) {
         $db->addWhere('id', $vars['id']);
         $result = $db->update();
     } else {
         $result = $db->insert(false);
     }
     if (\PHPWS_Error::logIfError($result)) {
         throw new \Exception($result->toString());
     }
 }
Пример #8
0
 public function execute()
 {
     $this->checkinCounts = PHPWS_DB::getAssoc("select hall_name, count(*) from hms_checkin JOIN hms_hall_structure ON hms_checkin.bed_id = hms_hall_structure.bedid WHERE term = {$this->term} and checkout_date IS NULL GROUP BY hall_name ORDER BY hall_name");
     if (PHPWS_Error::isError($this->checkinCounts)) {
         throw new DatabaseException($this->checkinCounts->toString());
     }
 }
Пример #9
0
/**
 * unregisters deleted keys from menu
 *
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function menu_unregister_key(Key $key)
{
    PHPWS_Core::initModClass('menu', 'Menu_Link.php');
    if (empty($key) || empty($key->id)) {
        return FALSE;
    }
    $db = new PHPWS_DB('menu_links');
    $db->addWhere('key_id', $key->id);
    $result = $db->delete();
    if (PHPWS_Error::isError($result)) {
        PHPWS_Error::log($result);
    }
    $db2 = new PHPWS_DB('menu_assoc');
    $db2->addWhere('key_id', $key->id);
    $result = $db2->delete();
    if (PHPWS_Error::isError($result)) {
        PHPWS_Error::log($result);
    }
    $db3 = new PHPWS_DB('menus');
    $db3->addWhere('assoc_key', $key->id);
    $db3->addValue('assoc_key', 0);
    $db3->addValue('assoc_url', null);
    $db3->update();
    return true;
}
Пример #10
0
/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function users_register($module, &$content)
{
    PHPWS_Core::initModClass('users', 'Permission.php');
    PHPWS_Core::initModClass('users', 'My_Page.php');
    $no_permissions = $no_my_page = FALSE;
    $result = Users_Permission::createPermissions($module);
    if (is_null($result)) {
        PHPWS_Boost::addLog('users', dgettext('users', 'Permissions file not implemented.'));
        $content[] = dgettext('users', 'Permissions file not implemented.');
        $no_permissions = TRUE;
    } elseif (PHPWS_Error::isError($result)) {
        $content[] = dgettext('users', 'Permissions table not created successfully.');
        PHPWS_Error::log($result);
        return FALSE;
    } else {
        $content[] = dgettext('users', 'Permissions table created successfully.');
    }
    $result = My_Page::registerMyPage($module);
    if (PHPWS_Error::isError($result)) {
        PHPWS_Boost::addLog('users', dgettext('users', 'A problem occurred when trying to register this module to My Page.'));
        $content[] = dgettext('users', 'A problem occurred when trying to register this module to My Page.');
        return FALSE;
    } elseif ($result != FALSE) {
        $content[] = dgettext('users', 'My Page registered to Users module.');
    } else {
        $no_my_page = TRUE;
    }
    // If the module doesn't have permissions or a My Page
    // then don't register the module
    if ($no_permissions && $no_my_page) {
        return FALSE;
    } else {
        return TRUE;
    }
}
Пример #11
0
 /**
  * Main searching function. Does the database lookup and then checks each student though the various functions.
  */
 public function doSearch()
 {
     // Clear all the caches
     StudentDataProvider::clearAllCache();
     $term = $this->term;
     $query = "select DISTINCT * FROM (select hms_new_application.username from hms_new_application WHERE term={$term} AND cancelled != 1 UNION select hms_assignment.asu_username from hms_assignment WHERE term={$term}) as foo";
     $result = PHPWS_DB::getCol($query);
     if (PHPWS_Error::logIfError($result)) {
         throw new Exception($result->toString());
     }
     foreach ($result as $username) {
         $student = null;
         try {
             $student = StudentFactory::getStudentByUsername($username, $term);
         } catch (Exception $e) {
             $this->actions[$username][] = 'WARNING!! Unknown student!';
             // Commenting out the NQ line, since this doesn't work when the search is run from cron/Pulse
             //NQ::simple('hms', hms\NotificationView::WARNING, 'Unknown student: ' . $username);
             continue;
         }
         if ($student->getType() != TYPE_WITHDRAWN && $student->getAdmissionDecisionCode() != ADMISSION_WITHDRAWN_PAID && $student->getAdmissionDecisionCode() != ADMISSION_RESCIND) {
             continue;
         }
         $this->actions[$username][] = $student->getBannerId() . ' (' . $student->getUsername() . ')';
         $this->withdrawnCount++;
         $this->handleApplication($student);
         $this->handleAssignment($student);
         $this->handleRoommate($student);
         $this->handleRlcAssignment($student);
         $this->handleRlcApplication($student);
     }
 }
Пример #12
0
 /**
  * Shows the requested report's HTML output.
  * 
  * @param CommandContext $context
  * @throws InvalidArgumentExection
  */
 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.');
     }
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentExection('Missing report id.');
     }
     // Instantiate the report controller with the requested report id
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $report = ReportFactory::getReportById($reportId);
     Layout::addPageTitle($report->getFriendlyName());
     $detailCmd = CommandFactory::getCommand('ShowReportDetail');
     $detailCmd->setReportClass($report->getClass());
     $content = '<div> ' . $detailCmd->getLink('&laquo; back') . ' </div>';
     $content .= file_get_contents($report->getHtmlOutputFilename());
     if ($content === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
         PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
         $reportCmd = CommandFactory::getCommand('ShowReportDetail');
         $reportCmd->setReportClass($report->getClass());
         $reportCmd->redirect();
     }
     $context->setContent($content);
 }
Пример #13
0
 /**
  * Exec
  *
  * @param CommandContext $context
  * @throws InvalidArgumentExection
  */
 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.');
     }
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentExection('Missing report id.');
     }
     // Instantiate the report controller with the requested report id
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $report = ReportFactory::getReportById($reportId);
     // Check to make sure the file exists
     if (!file_exists($report->getCsvOutputFilename())) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
         PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
         $reportCmd = CommandFactory::getCommand('ShowReportDetail');
         $reportCmd->setReportClass($report->getClass());
         $reportCmd->redirect();
     }
     $pdf = file_get_contents($report->getCsvOutputFilename());
     // Hoepfully force the browser to open a 'save as' dialogue
     header('Content-Type: text/csv');
     header('Cache-Control: public, must-revalidate, max-age=0');
     // HTTP/1.1
     header('Pragma: public');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Length: ' . strlen($pdf));
     header('Content-Disposition: attachment; filename="' . basename($report->getCsvOutputFilename()) . '";');
     echo $pdf;
     exit;
 }
Пример #14
0
 public function save()
 {
     $db = new PHPWS_DB('analytics_tracker');
     $result = $db->saveObject($this);
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     }
 }
 /**
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'hall_attributes')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit halls.');
     }
     // Make sure a hall ID was set
     $hallId = $context->get('hallId');
     if (is_null($hallId)) {
         throw new InvalidArgumentException('Missing hall ID.');
     }
     $viewCmd = CommandFactory::getCommand('EditResidenceHallView');
     $viewCmd->setHallId($hallId);
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     // Create the hall object given the hall id
     $hall = new HMS_Residence_Hall($hallId);
     if (!$hall) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid hall.');
         $viewCmd->redirect();
     }
     if ($context->get('tab') == 'settings') {
         // Compare the hall's gender and the gender the user selected
         // If they're not equal, call 'can_change_gender' public function
         if ($hall->gender_type != $_REQUEST['gender_type']) {
             if (!$hall->can_change_gender($_REQUEST['gender_type'])) {
                 NQ::simple('hms', hms\NotificationView::ERROR, 'Incompatible gender detected. No changes were made.');
                 $viewCmd->redirect();
             }
         }
         // Grab all the input from the form and save the hall
         $hall->hall_name = $context->get('hall_name');
         $hall->gender_type = $context->get('gender_type');
         // Set the defaults for the check boxes
         $context->setDefault('air_conditioned', 0);
         $context->setDefault('is_online', 0);
         $context->setDefault('meal_plan_required', 0);
         $context->setDefault('assignment_notifications', 0);
         $hall->air_conditioned = $context->get('air_conditioned');
         $hall->is_online = $context->get('is_online');
         $hall->meal_plan_required = $context->get('meal_plan_required');
         $hall->assignment_notifications = $context->get('assignment_notifications');
         $hall->setPackageDeskId($context->get('package_desk'));
     } else {
         if ($context->get('tab') == 'images') {
             $hall->exterior_image_id = $context->get('exterior_image_id');
             $hall->other_image_id = $context->get('other_image_id');
             $hall->map_image_id = $context->get('map_image_id');
             $hall->room_plan_image_id = $context->get('room_plan_image_id');
         }
     }
     $result = $hall->save();
     if (!$result || PHPWS_Error::logIfError($result)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was a problem saving the Residence Hall. No changes were made.');
         $viewCmd->redirect();
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'The Residence hall was updated successfully.');
     $viewCmd->redirect();
 }
Пример #16
0
 public function dropSequence($table)
 {
     $table = PHPWS_DB::addPrefix($table);
     $result = $GLOBALS['PHPWS_DB']['connection']->query("DROP TABLE {$table}");
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     return TRUE;
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php');
     $requestId = $context->get('requestId');
     $mealPlan = $context->get('mealPlan');
     $errorCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest');
     $errorCmd->setRequestId($requestId);
     $errorCmd->setMealPlan($mealPlan);
     // Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     // Check for a meal plan
     if (!isset($mealPlan) || $mealPlan == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a meal plan.');
         $errorCmd->redirect();
     }
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Update the meal plan field on the application
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $app->setMealPlan($mealPlan);
     try {
         $app->save();
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     // Try to actually make the assignment
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     try {
         HMS_Lottery::confirm_roommate_request(UserStatus::getUsername(), $requestId, $mealPlan);
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log the fact that the roommate was accepted and successfully assigned
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_CONFIRMED_ROOMMATE, UserStatus::getUsername(), "Captcha: \"{$captcha}\"");
     // Check for an RLC membership and update status if necessary
     // If this student was an RLC self-select, update the RLC memberhsip state
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
         $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment));
     }
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId);
     $successCmd = CommandFactory::getCommand('LotteryShowConfirmedRoommateThanks');
     $successCmd->setRequestId($requestId);
     $successCmd->redirect();
 }
Пример #18
0
/**
 * @version $Id$
 * @author Adam Morton
 * @author Steven Levin
 */
function archive($formId = NULL)
{
    if (!isset($formId)) {
        $message = dgettext('phatform', 'No form ID was passed');
        return new PHPWS_Error('phatform', 'archive()', $message, 'continue', PHAT_DEBUG_MODE);
    }
    $archiveDir = PHPWS_HOME_DIR . 'files/phatform/archive/';
    $path = $archiveDir;
    clearstatcache();
    if (!is_dir($path)) {
        if (is_writeable($archiveDir)) {
            PHPWS_File::makeDir($path);
        } else {
            return PHPWS_Error::get(PHATFORM_ARCHIVE_PATH, 'phatform', 'Archive.php::archive', $path);
        }
    } else {
        if (!is_writeable($path)) {
            return PHPWS_Error::get(PHATFORM_ARCHIVE_PATH, 'phatform', 'Archive.php::archive()');
        }
    }
    $table = array();
    $time = time();
    $table[] = 'mod_phatform_forms';
    $table[] = 'mod_phatform_forms_seq';
    $table[] = 'mod_phatform_form_' . $formId;
    $table[] = 'mod_phatform_form_' . $formId . '_seq';
    $table[] = 'mod_phatform_multiselect';
    $table[] = 'mod_phatform_multiselect_seq';
    $table[] = 'mod_phatform_checkbox';
    $table[] = 'mod_phatform_checkbox_seq';
    $table[] = 'mod_phatform_dropbox';
    $table[] = 'mod_phatform_dropbox_seq';
    $table[] = 'mod_phatform_options';
    $table[] = 'mod_phatform_options_seq';
    $table[] = 'mod_phatform_radiobutton';
    $table[] = 'mod_phatform_radiobutton_seq';
    $table[] = 'mod_phatform_textarea';
    $table[] = 'mod_phatform_textarea_seq';
    $table[] = 'mod_phatform_textfield';
    $table[] = 'mod_phatform_textfield_seq';
    $step1 = explode('//', PHPWS_DSN);
    $step2 = explode('@', $step1[1]);
    $step3 = explode(':', $step2[0]);
    $step4 = explode('/', $step2[1]);
    $dbuser = $step3[0];
    $dbpass = $step3[1];
    $dbhost = $step4[0];
    $dbname = $step4[1];
    for ($i = 0; $i < sizeof($table); $i++) {
        $pipe = ' >> ';
        if ($i == 0) {
            $pipe = ' > ';
        }
        $goCode = 'mysqldump -h' . $dbhost . ' -u' . $dbuser . ' -p' . $dbpass . ' ' . $dbname . ' ' . $table[$i] . $pipe . $path . $formId . '.' . $time . '.phat';
        system($goCode);
    }
}
Пример #19
0
 public function save()
 {
     $db = new PHPWS_DB('hms_eligibility_waiver');
     $result = $db->saveObject($this);
     if (!$result || PHPWS_Error::logIfError($result)) {
         return false;
     }
     return true;
 }
Пример #20
0
/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
function filecabinet_unregister($module, &$content)
{
    $db = new PHPWS_DB('folders');
    $db->addValue('module_created', null);
    $db->addWhere('module_created', $module);
    PHPWS_Error::logIfError($db->update());
    $content[] = dgettext('filecabinet', 'Unregistered from File Cabinet.');
    return true;
}
Пример #21
0
/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function calendar_uninstall(&$content)
{
    PHPWS_Core::initModClass('calendar', 'Schedule.php');
    // Need functions to remove old event tables
    $db = new PHPWS_DB('calendar_schedule');
    $schedules = $db->getObjects('Calendar_Schedule');
    if (PHPWS_Error::isError($schedules)) {
        return $schedules;
    } elseif (empty($schedules)) {
        $result = PHPWS_DB::dropTable('calendar_schedule');
        if (PHPWS_Error::isError($result)) {
            return $result;
        }
        $result = PHPWS_DB::dropTable('calendar_notice');
        if (PHPWS_Error::isError($result)) {
            return $result;
        }
        $result = PHPWS_DB::dropTable('calendar_suggestions');
        if (PHPWS_Error::isError($result)) {
            return $result;
        }
        return true;
    }
    $error = false;
    foreach ($schedules as $sch) {
        $result = $sch->delete();
        if (PHPWS_Error::isError($result)) {
            PHPWS_Error::log($result);
            $error = true;
        }
    }
    $result = PHPWS_DB::dropTable('calendar_schedule');
    if (PHPWS_Error::isError($result)) {
        return $result;
    }
    $result = PHPWS_DB::dropTable('calendar_notice');
    if (PHPWS_Error::isError($result)) {
        return $result;
    }
    $result = PHPWS_DB::dropTable('calendar_suggestions');
    if (PHPWS_Error::isError($result)) {
        return $result;
    }
    if (PHPWS_DB::isTable('converted')) {
        $db2 = new PHPWS_DB('converted');
        $db2->addWhere('convert_name', array('schedule', 'calendar'));
        $db2->delete();
        $content[] = dgettext('calendar', 'Removed convert flag.');
    }
    if (!$error) {
        $content[] = dgettext('calendar', 'Calendar tables removed.');
    } else {
        $content[] = dgettext('calendar', 'Some errors occurred when uninstalling Calendar.');
    }
    return true;
}
Пример #22
0
 public function init()
 {
     $db = new PHPWS_DB('signup_peeps');
     $result = $db->loadObject($this);
     if (PHPWS_Error::isError($result)) {
         $this->_error = $result;
     } elseif (!$result) {
         $this->id = 0;
     }
 }
Пример #23
0
 public function delete()
 {
     $db = new PHPWS_DB('hms_movein_time');
     $db->addWhere('id', $this->id);
     $result = $db->delete();
     if (!$result || PHPWS_Error::logIfError($result)) {
         return false;
     }
     return true;
 }
Пример #24
0
 /**
  * Deletes this item from the queue
  */
 public function delete()
 {
     $db = new PHPWS_DB('hms_banner_queue');
     $db->addWhere('id', $this->id);
     $result = $db->delete();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return TRUE;
 }
Пример #25
0
 public function init()
 {
     $db = new PHPWS_DB('search');
     $db->addWhere('key_id', $this->key_id);
     $result = $db->loadObject($this);
     if (PHPWS_Error::isError($result)) {
         $this->_error = $result;
     }
     $this->loadKeywords();
 }
Пример #26
0
 public static function write($name, $value, $time = 0)
 {
     if (empty($time)) {
         $time = time() + 31536000;
     }
     $time = (int) $time;
     $cookie_index = sprintf('%s[%s]', COOKIE_HASH, $name);
     if (!setcookie($cookie_index, $value, $time)) {
         return PHPWS_Error::get(COOKIE_SET_FAILED, 'core', 'PHPWS_Cookie::write');
     }
 }
 public static function getChangesForInternship(Internship $internship)
 {
     $db = new \PHPWS_DB('intern_change_history');
     $db->addWhere('internship_id', $internship->getId());
     $db->addOrder('timestamp ASC');
     $results = $db->getObjects('\\Intern\\ChangeHistory');
     if (\PHPWS_Error::logIfError($results)) {
         throw new \Exception($results->toString());
     }
     return $results;
 }
Пример #28
0
 public function save()
 {
     $db = $this->getDb();
     $result = $db->saveObject($this);
     if (PHPWS_Error::logIfError($result)) {
         PHPWS_Core::initModClass('faxmaster', 'exception/DatabaseException.php');
         throw new DatabaseException($result->toString());
     }
     // return new id
     return $result;
 }
Пример #29
0
 public static function getUserRolesForInstance($instance)
 {
     $db = new PHPWS_DB('hms_user_role');
     $db->addWhere('hms_user_role.class', strtolower(get_class($instance)));
     $db->addWhere('hms_user_role.instance', $instance->id);
     $result = $db->select();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return $result;
 }
Пример #30
0
 public function delete()
 {
     $db = $this->getDb();
     $db->addWhere('id', $this->id);
     //$db->setTestMode();
     $result = $db->delete();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     return TRUE;
 }