本文整理汇总了PHP中PHPWS_Error::logIfError方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_Error::logIfError方法的具体用法?PHP PHPWS_Error::logIfError怎么用?PHP PHPWS_Error::logIfError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_Error
的用法示例。
在下文中一共展示了PHPWS_Error::logIfError方法的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: 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);
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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());
}
}
示例6: 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();
}
示例7: init
public function init()
{
$DB = new PHPWS_DB('controlpanel_tab');
$result = $DB->loadObject($this);
if (PHPWS_Error::logIfError($result) || !$result) {
$this->id = null;
}
}
示例8: save
public function save()
{
$db = new PHPWS_DB('analytics_tracker');
$result = $db->saveObject($this);
if (PHPWS_Error::logIfError($result)) {
return $result;
}
}
示例9: 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();
}
示例10: filecabinet_unregister
/**
* @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;
}
示例11: save
public function save()
{
$db = new PHPWS_DB('hms_eligibility_waiver');
$result = $db->saveObject($this);
if (!$result || PHPWS_Error::logIfError($result)) {
return false;
}
return true;
}
示例12: delete
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;
}
示例13: delete
/**
* 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;
}
示例14: __construct
public function __construct($term)
{
parent::__construct($term);
$db = new PHPWS_DB('hms_special_assignment');
$db->addWhere('term', $this->term);
$result = $db->getObjects('SpecialAssignment');
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->getMessage());
}
$this->specials = $result;
}
示例15: getChangesForInternship
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;
}