本文整理汇总了PHP中PHPWS_Error类的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_Error类的具体用法?PHP PHPWS_Error怎么用?PHP PHPWS_Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPWS_Error类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showFP
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: execute
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: execute
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: execute
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;
}
示例5: execute
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: setTabs
public function setTabs($tabs)
{
if (!is_array($tabs)) {
return PHPWS_Error::get(CP_BAD_TABS, 'controlpanel', 'setTabs');
}
$this->tabs =& $tabs;
}
示例7: saveObject
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: execute
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: menu_unregister_key
/**
* 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: users_register
/**
* @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: doSearch
/**
* 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: execute
/**
* 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('« 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: execute
/**
* 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: save
public function save()
{
$db = new PHPWS_DB('analytics_tracker');
$result = $db->saveObject($this);
if (PHPWS_Error::logIfError($result)) {
return $result;
}
}
示例15: execute
/**
* @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();
}