本文整理汇总了PHP中ca_users::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_users::get方法的具体用法?PHP ca_users::get怎么用?PHP ca_users::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_users
的用法示例。
在下文中一共展示了ca_users::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderWidget
public function renderWidget($ps_widget_id, &$pa_settings)
{
parent::renderWidget($ps_widget_id, $pa_settings);
$vn_threshold = time() - $pa_settings['logins_since'] * 60 * 60;
$o_db = new Db();
$qr_res = $o_db->query("\n\t\t\t\tSELECT e.code, e.message, e.date_time\n\t\t\t\tFROM ca_eventlog e\n\t\t\t\tWHERE\n\t\t\t\t\t(e.date_time >= ?) AND (e.code = 'LOGN')\n\t\t\t\tORDER BY\n\t\t\t\t\te.date_time DESC\n\t\t\t", $vn_threshold);
$va_login_list = array();
$t_user = new ca_users();
$va_user_cache = array();
while ($qr_res->nextRow()) {
$va_log = $qr_res->getRow();
$vs_message = $va_log['message'];
$va_tmp = explode(';', $vs_message);
$vs_username = '?';
if (preg_match('!\'([^\']+)\'!', $va_tmp[0], $va_matches)) {
$vs_username = $va_matches[1];
}
$va_log['username'] = $vs_username;
if (!isset($va_user_cache[$vs_username])) {
if ($t_user->load(array('user_name' => $vs_username))) {
$va_user_cache[$vs_username] = array('fname' => $t_user->get('fname'), 'lname' => $t_user->get('lname'), 'email' => $t_user->get('email'));
} else {
$va_user_cache[$vs_username] = array('fname' => '?', 'lname' => '?', 'email' => '?');
}
}
$va_log = array_merge($va_log, $va_user_cache[$vs_username]);
$va_log['ip'] = str_replace('IP=', '', $va_tmp[1]);
$va_login_list[] = $va_log;
}
$this->opo_view->setVar('request', $this->getRequest());
$this->opo_view->setVar('login_list', $va_login_list);
return $this->opo_view->render('main_html.php');
}
示例2: authenticate
public static function authenticate($ps_username, $ps_password = '', $pa_options = null)
{
$t_user = new ca_users();
$t_user->load($ps_username);
if ($t_user->getPrimaryKey() > 0) {
$vs_hash = $t_user->get('password');
if (preg_match('/^[a-f0-9]{32}$/', $vs_hash)) {
// old-style md5 passwords
//throw new CaUsersException(_t('The stored password for this user seems to be in legacy format. Please update the user account by resetting the password.'));
if (md5($ps_password) == $vs_hash) {
// if the md5 hash matches, authenticate successfully and move the user over to pbkdf2 key
$t_user->setMode(ACCESS_WRITE);
// ca_users::update takes care of the hashing by calling AuthenticationManager::updatePassword()
$t_user->set('password', $ps_password);
$t_user->update();
return true;
} else {
return false;
}
}
return validate_password($ps_password, $vs_hash);
} else {
return false;
}
}
示例3: send
/**
*
*/
public static function send($pn_user_id, $ps_message)
{
global $AUTH_CURRENT_USER_ID, $g_request;
if (!function_exists("curl_init")) {
return false;
}
if ($pn_user_id == $AUTH_CURRENT_USER_ID) {
$t_user = $g_request->user;
// use request user object
} else {
$t_user = new ca_users($pn_user_id);
}
if (!$t_user->getPrimaryKey()) {
return null;
}
if (!$t_user->get('sms_number')) {
return null;
}
if (!($vn_sendhub_contact_id = $t_user->getVar('sms_sendhub_contact_id')) || $t_user->getVar('sms_sendhub_phone_number') != $t_user->get('sms_number')) {
if (!($vn_sendhub_contact_id = WLPlugSMSSendHub::addContact($t_user))) {
// TODO: check and log errors here
return null;
}
}
$vs_user = $t_user->getAppConfig()->get('sms_user');
$vs_api_key = $t_user->getAppConfig()->get('sms_api_key');
$vs_url = "https://api.sendhub.com/v1/messages/?username={$vs_user}&api_key={$vs_api_key}";
$o_ch = curl_init();
$ps_message = stripslashes(rawurldecode($ps_message));
$ps_message = trim(preg_replace("!\n+!", "\\" . "n", $ps_message));
curl_setopt($o_ch, CURLOPT_URL, $vs_url);
curl_setopt($o_ch, CURLOPT_HEADER, false);
curl_setopt($o_ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($o_ch, CURLOPT_POSTFIELDS, '{"contacts":[' . $vn_sendhub_contact_id . '],"text":"' . $ps_message . '"}');
curl_setopt($o_ch, CURLOPT_RETURNTRANSFER, 1);
$vs_return = curl_exec($o_ch);
$va_return = json_decode($vs_return);
// TODO: check and log errors here
curl_close($o_ch);
return true;
}
示例4: hookPeriodicTask
/**
* Perform client services-related periodic tasks
*/
public function hookPeriodicTask(&$pa_params)
{
$t_log = new Eventlog();
$o_db = new Db();
if (!(bool) $this->opo_config->get('enable_library_services')) {
return true;
}
if ((bool) $this->opo_config->get('enable_object_checkout')) {
$t_user = new ca_users();
$t_checkout = new ca_object_checkouts();
$vs_app_name = $this->opo_config->get('app_display_name');
$vs_sender_name = $this->opo_library_services_config->get('notification_sender_name');
$vs_sender_email = $this->opo_library_services_config->get('notification_sender_email');
if (!is_array($va_administrative_email_addresses = $this->opo_library_services_config->getList('administrative_email_addresses'))) {
$va_administrative_email_addresses = array();
}
// Periodic "coming due" notices
if ($this->opo_library_services_config->get('send_coming_due_notices') && ($vs_interval = $this->opo_library_services_config->get('coming_due_interval'))) {
try {
$va_items_by_user = ca_object_checkouts::getItemsDueWithin($vs_interval, array('groupBy' => 'user_id', 'template' => $this->opo_library_services_config->get('coming_due_item_display_template'), 'notificationInterval' => $this->opo_library_services_config->get('coming_due_notification_interval')));
foreach ($va_items_by_user as $vn_user_id => $va_items_for_user) {
if ($t_user->load($vn_user_id)) {
if ($vs_user_email = $t_user->get('email')) {
$vs_subject = _t('Notice of items coming due for return');
if (caSendMessageUsingView(null, $vs_user_email, $vs_sender_email, "[{$vs_app_name}] {$vs_subject}", "library_coming_due.tpl", array('subject' => $vs_subject, 'from_user_id' => $vn_user_id, 'sender_name' => $vs_sender_name, 'sender_email' => $vs_sender_email, 'sent_on' => time(), 'items' => $va_items_for_user), null, $va_administrative_email_addresses)) {
// mark record
foreach ($va_items_for_user as $va_item) {
if ($t_checkout->load($va_item['checkout_id'])) {
$t_checkout->setMode(ACCESS_WRITE);
$t_checkout->set('last_sent_coming_due_email', _t('now'));
$t_checkout->update();
if ($t_checkout->numErrors()) {
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not mark checkout coming due message sent time because update failed: %1', join("; ", $t_checkout->getErrors())), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
} else {
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not mark checkout coming due message sent time because checkout id %1 was not found', $va_item['checkout_id']), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
}
}
} else {
// no email
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('No email address set for user %1 (%2)', $t_user->get('user_name'), trim($t_user->get('fname') . ' ' . $t_user->get('lname'))), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
} else {
// invalid user
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('User id %1 does not exist', $vn_user_id), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
}
} catch (Exception $e) {
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Invalid interval (%1) specified for coming due notices', $vs_interval), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
}
// Periodic overdue notices
if ($this->opo_library_services_config->get('send_overdue_notices')) {
try {
$va_items_by_user = ca_object_checkouts::getOverdueItems(array('groupBy' => 'user_id', 'template' => $this->opo_library_services_config->get('overdue_item_display_template'), 'notificationInterval' => $this->opo_library_services_config->get('overdue_notification_interval')));
foreach ($va_items_by_user as $vn_user_id => $va_items_for_user) {
if ($t_user->load($vn_user_id)) {
if ($vs_user_email = $t_user->get('email')) {
$vs_subject = _t('Notice of overdue items');
if (caSendMessageUsingView(null, $vs_user_email, $vs_sender_email, "[{$vs_app_name}] {$vs_subject}", "library_overdue.tpl", array('subject' => $vs_subject, 'from_user_id' => $vn_user_id, 'sender_name' => $vs_sender_name, 'sender_email' => $vs_sender_email, 'sent_on' => time(), 'items' => $va_items_for_user), null, $va_administrative_email_addresses)) {
// mark record
foreach ($va_items_for_user as $va_item) {
if ($t_checkout->load($va_item['checkout_id'])) {
$t_checkout->setMode(ACCESS_WRITE);
$t_checkout->set('last_sent_overdue_email', _t('now'));
$t_checkout->update();
if ($t_checkout->numErrors()) {
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not mark checkout overdue message sent time because update failed: %1', join("; ", $t_checkout->getErrors())), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
} else {
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not mark checkout overdue message sent time because checkout id %1 was not found', $va_item['checkout_id']), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
}
}
} else {
// no email
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('No email address set for user %1 (%2)', $t_user->get('user_name'), trim($t_user->get('fname') . ' ' . $t_user->get('lname'))), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
} else {
// invalid user
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('User id %1 does not exist', $vn_user_id), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
}
} catch (Exception $e) {
$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Failed to get overdue list'), 'SOURCE' => 'libraryServicesPlugin->hookPeriodicTask'));
}
}
// Notice when reservation becomes available
if ($this->opo_library_services_config->get('send_reservation_available_notices')) {
try {
$va_items_by_user = ca_object_checkouts::getReservedAvailableItems(array('groupBy' => 'user_id', 'template' => $this->opo_library_services_config->get('overdue_item_display_template'), 'notificationInterval' => $this->opo_library_services_config->get('reservation_available_notification_interval')));
foreach ($va_items_by_user as $vn_user_id => $va_items_for_user) {
if ($t_user->load($vn_user_id)) {
if ($vs_user_email = $t_user->get('email')) {
$vs_subject = _t('Notice of reserved available items');
if (caSendMessageUsingView(null, $vs_user_email, $vs_sender_email, "[{$vs_app_name}] {$vs_subject}", "library_reservation_available.tpl", array('subject' => $vs_subject, 'from_user_id' => $vn_user_id, 'sender_name' => $vs_sender_name, 'sender_email' => $vs_sender_email, 'sent_on' => time(), 'items' => $va_items_for_user), null, $va_administrative_email_addresses)) {
//.........这里部分代码省略.........
示例5: getCriterionLabel
/**
* Returns a display label for a given criterion and facet.
*
* @param string $ps_facet_name Name of facet
* @param mixed $pm_criterion
* @return string
*/
public function getCriterionLabel($ps_facet_name, $pn_row_id)
{
if (!($va_facet_info = $this->getInfoForFacet($ps_facet_name))) {
return null;
}
switch ($va_facet_info['type']) {
# -----------------------------------------------------
case 'has':
$vs_yes_text = isset($va_facet_info['label_yes']) && $va_facet_info['label_yes'] ? $va_facet_info['label_yes'] : _t('Yes');
$vs_no_text = isset($va_facet_info['label_no']) && $va_facet_info['label_no'] ? $va_facet_info['label_no'] : _t('No');
return (bool) $pn_row_id ? $vs_yes_text : $vs_no_text;
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'label':
if (!($t_table = $this->opo_datamodel->getInstanceByTableName(isset($va_facet_info['relative_to']) && $va_facet_info['relative_to'] ? $va_facet_info['relative_to'] : $this->ops_browse_table_name, true))) {
break;
}
if (!$t_table->load($pn_row_id)) {
return '???';
}
return $t_table->getLabelForDisplay();
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'authority':
if (!($t_table = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table'], true))) {
break;
}
if (!$t_table->load($pn_row_id)) {
return '???';
}
return $t_table->getLabelForDisplay();
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'attribute':
$t_element = new ca_metadata_elements();
if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
return urldecode($pn_row_id);
}
$vn_element_id = $t_element->getPrimaryKey();
switch ($vn_element_type = $t_element->get('datatype')) {
case __CA_ATTRIBUTE_VALUE_LIST__:
$t_list = new ca_lists();
return $t_list->getItemFromListForDisplayByItemID($t_element->get('list_id'), $pn_row_id, true);
break;
case __CA_ATTRIBUTE_VALUE_OBJECTS__:
case __CA_ATTRIBUTE_VALUE_ENTITIES__:
case __CA_ATTRIBUTE_VALUE_PLACES__:
case __CA_ATTRIBUTE_VALUE_OCCURRENCES__:
case __CA_ATTRIBUTE_VALUE_COLLECTIONS__:
case __CA_ATTRIBUTE_VALUE_LOANS__:
case __CA_ATTRIBUTE_VALUE_MOVEMENTS__:
case __CA_ATTRIBUTE_VALUE_STORAGELOCATIONS__:
case __CA_ATTRIBUTE_VALUE_OBJECTLOTS__:
if ($t_rel_item = AuthorityAttributeValue::elementTypeToInstance($vn_element_type)) {
return $t_rel_item->load($pn_row_id) ? $t_rel_item->getLabelForDisplay() : "???";
}
break;
default:
return urldecode($pn_row_id);
break;
}
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'field':
if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
break;
}
if ($vb_is_bit = $t_item->getFieldInfo($va_facet_info['field'], 'FIELD_TYPE') == FT_BIT) {
return (bool) $pn_row_id ? caGetOption('label_yes', $va_facet_info, _t('Yes')) : caGetOption('label_no', $va_facet_info, _t('No'));
}
return urldecode($pn_row_id);
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'violations':
if (!($t_rule = $this->opo_datamodel->getInstanceByTableName('ca_metadata_dictionary_rules', true))) {
break;
}
if ($t_rule->load(array('rule_code' => $pn_row_id))) {
return $t_rule->getSetting('label');
}
return urldecode($pn_row_id);
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'checkouts':
$vs_status_text = null;
$vs_status_code = isset($va_facet_info['status']) && $va_facet_info['status'] ? $va_facet_info['status'] : $pn_row_id;
switch ($vs_status_code) {
//.........这里部分代码省略.........
示例6: sizeof
print sizeof($va_comments) . " " . (sizeof($va_comments) == 1 ? _t("comment") : _t("comments"));
?>
<i class="fa fa-arrows-v"></i></a><HR/></div>
<?php
if (sizeof($va_comments)) {
$t_author = new ca_users();
print "<div class='lbComments' style='display:none;'>";
foreach ($va_comments as $va_comment) {
print "<small>";
# --- display link to remove comment?
if ($vb_write_access || $va_comment["user_id"] == $this->request->user->get("user_id")) {
print "<div class='pull-right'>" . caNavLink($this->request, "<i class='fa fa-times' title='" . _t("remove comment") . "'></i>", "", "", "Sets", "deleteComment", array("comment_id" => $va_comment["comment_id"], "set_id" => $t_set->get("set_id"), "reload" => "detail")) . "</div>";
}
$t_author->load($va_comment["user_id"]);
print $va_comment["comment"] . "<br/>";
print "<small>" . trim($t_author->get("fname") . " " . $t_author->get("lname")) . " " . date("n/j/y g:i A", $va_comment["created_on"]) . "</small>";
print "</small><HR/>";
}
print "</div>";
}
}
print $this->render("Browse/browse_refine_subview_html.php");
?>
</div><!-- end col -->
</div><!-- end row -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#lbSetResultLoadContainer').jscroll({
autoTrigger: true,
loadingHtml: "<?php
print caBusyIndicatorIcon($this->request) . ' ' . addslashes(_t('Loading...'));
示例7: SaveTransaction
/**
*
*/
public function SaveTransaction()
{
$ps_item_list = $this->request->getParameter('item_list', pString);
$pa_item_list = json_decode($ps_item_list, true);
$t_checkout = new ca_object_checkouts();
$va_ret = array('status' => 'OK', 'errors' => array(), 'checkins' => array());
foreach ($pa_item_list as $vn_i => $va_item) {
if ($t_checkout->load($va_item['checkout_id'])) {
$vn_object_id = $t_checkout->get('object_id');
$t_object = new ca_objects($vn_object_id);
if ($t_checkout->isOut()) {
try {
$t_checkout->checkin($vn_object_id, $va_item['note'], array('request' => $this->request));
$t_user = new ca_users($t_checkout->get('user_id'));
$vs_user_name = $t_user->get('ca_users.fname') . ' ' . $t_user->get('ca_users.lname');
$vs_borrow_date = $t_checkout->get('ca_object_checkouts.checkout_date', array('timeOmit' => true));
if ($t_checkout->numErrors() == 0) {
$va_ret['checkins'][] = _t('Returned <em>%1</em> (%2) borrowed by %3 on %4', $t_object->get('ca_objects.preferred_labels.name'), $t_object->get('ca_objects.idno'), $vs_user_name, $vs_borrow_date);
} else {
$va_ret['errors'][] = _t('Could not check in <em>%1</em> (%2): %3', $t_object->get('ca_objects.preferred_labels.name'), $t_object->get('ca_objects.idno'), join("; ", $t_checkout->getErrors()));
}
} catch (Exception $e) {
$va_ret['errors'][] = _t('<em>%1</em> (%2) is not out', $t_object->get('ca_objects.preferred_labels.name'), $t_object->get('ca_objects.idno'));
}
} else {
$va_ret['errors'][] = _t('<em>%1</em> (%2) is not out', $t_object->get('ca_objects.preferred_labels.name'), $t_object->get('ca_objects.idno'));
}
}
}
$this->view->setVar('data', $va_ret);
$this->render('checkin/ajax_data_json.php');
}
示例8: CreateNewOrderFromCommunication
/**
*
*/
public function CreateNewOrderFromCommunication()
{
if ($pn_communication_id = $this->request->getParameter('communication_id', pInteger)) {
$t_comm = new ca_commerce_communications($pn_communication_id);
if (!$t_comm->getPrimaryKey()) {
$this->notification->addNotification(_t('Invalid message'), __NOTIFICATION_TYPE_ERROR__);
$this->CustomerInfo();
return;
}
$t_trans = new ca_commerce_transactions($t_comm->get('transaction_id'));
if (!$t_trans->getPrimaryKey()) {
$this->notification->addNotification(_t('Message is not associated with a transaction'), __NOTIFICATION_TYPE_ERROR__);
$this->CustomerInfo();
return;
}
$t_user = new ca_users($t_trans->get('user_id'));
$this->opt_order->setMode(ACCESS_WRITE);
$this->opt_order->set('transaction_id', $t_trans->getPrimaryKey());
if ($t_user->getPrimaryKey()) {
$this->opt_order->set('billing_fname', $t_user->get('fname'));
$this->opt_order->set('billing_lname', $t_user->get('lname'));
$this->opt_order->set('billing_email', $t_user->get('email'));
$this->opt_order->set('shipping_fname', $t_user->get('fname'));
$this->opt_order->set('shipping_lname', $t_user->get('lname'));
$this->opt_order->set('shipping_email', $t_user->get('email'));
// Pre-populate order with user's profile address
$va_mapping = array('billing_organization' => 'user_profile_organization', 'billing_address1' => 'user_profile_address1', 'billing_address2' => 'user_profile_address2', 'billing_city' => 'user_profile_city', 'billing_zone' => 'user_profile_state', 'billing_postal_code' => 'user_profile_postalcode', 'billing_country' => 'user_profile_country', 'billing_phone' => 'user_profile_phone', 'billing_fax' => 'user_profile_fax', 'shipping_organization' => 'user_profile_organization', 'shipping_address1' => 'user_profile_address1', 'shipping_address2' => 'user_profile_address2', 'shipping_city' => 'user_profile_city', 'shipping_zone' => 'user_profile_state', 'shipping_postal_code' => 'user_profile_postalcode', 'shipping_country' => 'user_profile_country', 'shipping_phone' => 'user_profile_phone', 'shipping_fax' => 'user_profile_fax');
foreach ($va_mapping as $vs_field => $vs_pref) {
$this->opt_order->set($vs_field, $t_user->getPreference($vs_pref));
}
}
$this->opt_order->set('order_type', 'L');
// L=loan
$this->opt_order->insert();
$this->request->setParameter('order_id', $this->opt_order->getPrimaryKey());
if (!$this->opt_order->numErrors()) {
$this->notification->addNotification(_t('Saved changes'), __NOTIFICATION_TYPE_INFO__);
// Add items
$t_set = new ca_sets($t_trans->get('set_id'));
if ($t_set->getPrimaryKey()) {
$va_items = $t_set->getItems();
foreach ($va_items as $va_item_list) {
foreach ($va_item_list as $vn_i => $va_item) {
if (!is_array($va_item['selected_services'])) {
//$va_item['selected_services'] = array('DIGITAL_COPY'); // TODO: make default configurable
}
foreach ($va_item['selected_services'] as $vs_service) {
if ($t_item = $this->opt_order->addItem($va_item['row_id'], array('service' => $vs_service), array('representations_ids' => is_array($va_item['selected_representations']) && sizeof($va_item['selected_representations']) ? $va_item['selected_representations'] : null))) {
$t_item->updateFee();
}
}
}
}
// Delete originating set if configured to do so
if ($this->opo_client_services_config->get('set_disposal_policy') == 'DELETE_WHEN_ORDER_CREATED') {
$t_set->setMode(ACCESS_WRITE);
$t_set->delete(true);
}
}
} else {
$va_errors['general'] = $this->opt_order->errors();
$this->notification->addNotification(_t('Errors occurred: %1', join('; ', $this->opt_order->getErrors())), __NOTIFICATION_TYPE_ERROR__);
}
$this->view->setVar('errors', $va_errors);
}
$this->OrderOverview();
}
示例9: resetSave
function resetSave()
{
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Reset Password"));
$ps_action = $this->request->getParameter('action', pString);
if (!$ps_action) {
$ps_action = "reset";
}
$ps_key = $this->request->getParameter('key', pString);
$ps_key = preg_replace("/[^A-Za-z0-9]+/", "", $ps_key);
$this->view->setVar("key", $ps_key);
$this->view->setVar("email", $this->request->config->get("ca_admin_email"));
$o_check_key = new Db();
$qr_check_key = $o_check_key->query("\n\t\t\t\tSELECT user_id \n\t\t\t\tFROM ca_users \n\t\t\t\tWHERE\n\t\t\t\t\tmd5(concat(concat(user_id, '/'), password)) = ?\n\t\t\t", $ps_key);
#
# Check reset key
#
if (!$qr_check_key->nextRow() || !($vs_user_id = $qr_check_key->get("user_id"))) {
$this->view->setVar("action", "reset_failure");
$this->view->setVar("message", _t("Your password could not be reset"));
$this->render('LoginReg/form_reset_html.php');
} else {
$ps_password = $this->request->getParameter('password', pString);
$ps_password_confirm = $this->request->getParameter('password_confirm', pString);
switch ($ps_action) {
case 'reset_save':
if (!$ps_password || !$ps_password_confirm) {
$this->view->setVar("message", _t("Please enter and re-type your password."));
$ps_action = "reset";
break;
}
if ($ps_password != $ps_password_confirm) {
$this->view->setVar("message", _t("Passwords do not match. Please try again."));
$ps_action = "reset";
break;
}
$t_user = new ca_users();
$t_user->purify(true);
$t_user->load($vs_user_id);
# verify user exists with this e-mail address
if ($t_user->getPrimaryKey()) {
# user with e-mail already exists...
$t_user->setMode(ACCESS_WRITE);
$t_user->set("password", $ps_password);
$t_user->update();
if ($t_user->numErrors()) {
$this->notification->addNotification(join("; ", $t_user->getErrors()), __NOTIFICATION_TYPE_INFO__);
$ps_action = "reset_failure";
} else {
$ps_action = "reset_success";
$o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
# -- generate email subject
$vs_subject_line = $o_view->render("mailTemplates/notification_subject.tpl");
# -- generate mail text from template - get both the html and text versions
$vs_mail_message_text = $o_view->render("mailTemplates/notification.tpl");
$vs_mail_message_html = $o_view->render("mailTemplates/notification_html.tpl");
caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), $vs_subject_line, $vs_mail_message_text, $vs_mail_message_html);
}
break;
} else {
$this->notification->addNotification(_t("Invalid user"), __NOTIFICATION_TYPE_INFO__);
$ps_action = "reset_failure";
}
}
$this->view->setVar("action", $ps_action);
$this->render('LoginReg/form_reset_html.php');
}
}
示例10: resetSave
function resetSave()
{
$ps_action = $this->request->getParameter('action', pString);
$ps_key = $this->request->getParameter('key', pString);
$ps_key = preg_replace("/[^A-Za-z0-9]+/", "", $ps_key);
$this->view->setVar("key", $ps_key);
$o_check_key = new Db();
$qr_check_key = $o_check_key->query("\n\t\t\t\tSELECT user_id \n\t\t\t\tFROM ca_users \n\t\t\t\tWHERE\n\t\t\t\t\tmd5(concat(concat(user_id, '/'), password)) = ?\n\t\t\t", $ps_key);
#
# Check reset key
#
if (!$qr_check_key->nextRow() || !($vs_user_id = $qr_check_key->get("user_id"))) {
$this->view->setVar("action", "reset_failure");
$this->render('LoginReg/resetpw_html.php');
} else {
$ps_password = $this->request->getParameter('password', pString);
$ps_password_confirm = $this->request->getParameter('password_confirm', pString);
switch ($ps_action) {
case 'reset_save':
if (!$ps_password || !$ps_password_confirm) {
$this->view->setVar("password_error", _t("Please enter and re-type your password."));
$ps_action = "reset";
break;
}
if ($ps_password != $ps_password_confirm) {
$this->view->setVar("password_error", _t("Passwords do not match. Please try again."));
$ps_action = "reset";
break;
}
$t_user = new ca_users();
$t_user->load($vs_user_id);
# verify user exists with this e-mail address
if ($t_user->getPrimaryKey()) {
# user with e-mail already exists...
$t_user->setMode(ACCESS_WRITE);
$t_user->set("password", $ps_password);
$t_user->update();
if ($t_user->numErrors()) {
$this->notification->addNotification(join("; ", $t_user->getErrors()), __NOTIFICATION_TYPE_INFO__);
$ps_action = "reset_failure";
} else {
$ps_action = "reset_success";
# -- generate mail text from template
ob_start();
require $this->request->getViewsDirectoryPath() . "/mailTemplates/notification.tpl";
$vs_mail_message = ob_get_contents();
ob_end_clean();
caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), "[" . $this->request->config->get("app_display_name") . "] " . _t("Your password has been reset"), $vs_mail_message);
}
break;
} else {
$this->notification->addNotification(_t("Invalid user"), __NOTIFICATION_TYPE_INFO__);
$ps_action = "reset_failure";
}
}
$this->view->setVar("action", $ps_action);
$this->render('LoginReg/resetpw_html.php');
}
}
示例11: saveShareSet
function saveShareSet()
{
if (!$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'loginForm'));
return;
}
$t_set = $this->_getSet(__CA_SET_EDIT_ACCESS__);
$o_purifier = new HTMLPurifier();
$ps_user = $o_purifier->purify($this->request->getParameter('user', pString));
# --- ps_user can be list of emails separated by comma
$va_users = explode(", ", $ps_user);
$pn_group_id = $this->request->getParameter('group_id', pInteger);
if (!$pn_group_id && !$ps_user) {
$va_errors["general"] = _t("Please select a user or group");
}
$pn_access = $this->request->getParameter('access', pInteger);
if (!$pn_access) {
$va_errors["access"] = _t("Please select an access level");
}
if (sizeof($va_errors) == 0) {
if ($pn_group_id) {
$t_sets_x_user_groups = new ca_sets_x_user_groups();
if ($t_sets_x_user_groups->load(array("set_id" => $t_set->get("set_id"), "group_id" => $pn_group_id))) {
$this->view->setVar("message", _t('Group already has access to the lightbox'));
$this->render("Form/reload_html.php");
} else {
$t_sets_x_user_groups->setMode(ACCESS_WRITE);
$t_sets_x_user_groups->set('access', $pn_access);
$t_sets_x_user_groups->set('group_id', $pn_group_id);
$t_sets_x_user_groups->set('set_id', $t_set->get("set_id"));
$t_sets_x_user_groups->insert();
if ($t_sets_x_user_groups->numErrors()) {
$va_errors["general"] = join("; ", $t_sets_x_user_groups->getErrors());
$this->view->setVar('errors', $va_errors);
$this->shareSetForm();
} else {
$t_group = new ca_user_groups($pn_group_id);
$va_group_users = $t_group->getGroupUsers();
if (sizeof($va_group_users)) {
# --- send email to each group user
# --- send email confirmation
$o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
$o_view->setVar("set", $t_set->getLabelForDisplay());
$o_view->setVar("from_name", trim($this->request->user->get("fname") . " " . $this->request->user->get("lname")));
# -- generate email subject line from template
$vs_subject_line = $o_view->render("mailTemplates/share_set_notification_subject.tpl");
# -- generate mail text from template - get both the text and the html versions
$vs_mail_message_text = $o_view->render("mailTemplates/share_set_notification.tpl");
$vs_mail_message_html = $o_view->render("mailTemplates/share_set_notification_html.tpl");
foreach ($va_group_users as $va_user_info) {
# --- don't send notification to self
if ($this->request->user->get("user_id") != $va_user_info["user_id"]) {
caSendmail($va_user_info["email"], array($this->request->user->get("email") => trim($this->request->user->get("fname") . " " . $this->request->user->get("lname"))), $vs_subject_line, $vs_mail_message_text, $vs_mail_message_html);
}
}
}
$this->view->setVar("message", _t('Shared lightbox with group'));
$this->render("Form/reload_html.php");
}
}
} else {
$va_error_emails = array();
$va_success_emails = array();
$va_error_emails_has_access = array();
$t_user = new ca_users();
foreach ($va_users as $vs_user) {
# --- lookup the user/users
$t_user->load(array("email" => $vs_user));
if ($vn_user_id = $t_user->get("user_id")) {
$t_sets_x_users = new ca_sets_x_users();
if ($vn_user_id == $t_set->get("user_id") || $t_sets_x_users->load(array("set_id" => $t_set->get("set_id"), "user_id" => $vn_user_id))) {
$va_error_emails_has_access[] = $vs_user;
} else {
$t_sets_x_users->setMode(ACCESS_WRITE);
$t_sets_x_users->set('access', $pn_access);
$t_sets_x_users->set('user_id', $vn_user_id);
$t_sets_x_users->set('set_id', $t_set->get("set_id"));
$t_sets_x_users->insert();
if ($t_sets_x_users->numErrors()) {
$va_errors["general"] = _t("There were errors while sharing this lightbox with %1", $vs_user) . join("; ", $t_sets_x_users->getErrors());
$this->view->setVar('errors', $va_errors);
$this->shareSetForm();
} else {
$va_success_emails[] = $vs_user;
$va_success_emails_info[] = array("email" => $vs_user, "name" => trim($t_user->get("fname") . " " . $t_user->get("lname")));
}
}
} else {
$va_error_emails[] = $vs_user;
}
}
if (sizeof($va_error_emails) || sizeof($va_error_emails_has_access)) {
$va_user_errors = array();
if (sizeof($va_error_emails)) {
$va_user_errors[] = _t("The following email(s) you entered do not belong to a registered user: " . implode(", ", $va_error_emails));
}
if (sizeof($va_error_emails_has_access)) {
$va_user_errors[] = _t("The following email(s) you entered already have access to this lightbox: " . implode(", ", $va_error_emails_has_access));
}
if (sizeof($va_success_emails)) {
//.........这里部分代码省略.........
示例12: Save
public function Save()
{
// Field to user profile preference mapping
$va_mapping = array('billing_organization' => 'user_profile_organization', 'billing_address1' => 'user_profile_address1', 'billing_address2' => 'user_profile_address2', 'billing_city' => 'user_profile_city', 'billing_zone' => 'user_profile_state', 'billing_postal_code' => 'user_profile_postalcode', 'billing_country' => 'user_profile_country', 'billing_phone' => 'user_profile_phone', 'billing_fax' => 'user_profile_fax', 'shipping_organization' => 'user_profile_organization', 'shipping_address1' => 'user_profile_address1', 'shipping_address2' => 'user_profile_address2', 'shipping_city' => 'user_profile_city', 'shipping_zone' => 'user_profile_state', 'shipping_postal_code' => 'user_profile_postalcode', 'shipping_country' => 'user_profile_country', 'shipping_phone' => 'user_profile_phone', 'shipping_fax' => 'user_profile_fax');
$va_errors = array();
$va_failed_insert_list = array();
$va_fields = $this->opt_order->getFormFields();
foreach ($va_fields as $vs_f => $va_field_info) {
switch ($vs_f) {
case 'transaction_id':
// noop
break;
default:
if (isset($_REQUEST[$vs_f])) {
if (!$this->opt_order->set($vs_f, $this->request->getParameter($vs_f, pString))) {
$va_errors[$vs_f] = $this->opt_order->errors();
}
}
break;
}
}
// Set additional fees for order
$va_fees = $this->opo_client_services_config->getAssoc('additional_order_fees');
if (is_array($va_fees)) {
if (!is_array($va_fee_values = $this->opt_order->get('additional_fees'))) {
$va_fee_values = array();
}
foreach ($va_fees as $vs_code => $va_info) {
$va_fee_values[$vs_code] = (double) $this->request->getParameter("additional_fee_{$vs_code}", pString);
}
$this->opt_order->set('additional_fees', $va_fee_values);
}
$this->opt_order->setMode(ACCESS_WRITE);
if ($this->opt_order->getPrimaryKey()) {
$this->opt_order->update();
$vn_transaction_id = $this->opt_order->get('transaction_id');
} else {
// Set transaction
if (!($vn_transaction_id = $this->request->getParameter('transaction_id', pInteger))) {
if (!($vn_user_id = $this->request->getParameter('transaction_user_id', pInteger))) {
if ($vs_user_name = $this->request->getParameter('billing_email', pString)) {
// Try to create user in-line
$t_user = new ca_users();
if ($t_user->load(array('user_name' => $vs_user_name))) {
if ($t_user->get('active') == 1) {
// user is active - if not active don't use
if ($t_user->get('userclass') == 255) {
// user is deleted
$t_user->setMode(ACCESS_WRITE);
$t_user->set('userclass', 1);
// 1=public user (no back-end login)
$t_user->update();
if ($t_user->numErrors()) {
$this->notification->addNotification(_t('Errors occurred when undeleting user: %1', join('; ', $t_user->getErrors())), __NOTIFICATION_TYPE_ERROR__);
} else {
$vn_user_id = $t_user->getPrimaryKey();
}
} else {
$vn_user_id = $t_user->getPrimaryKey();
}
} else {
$t_user->setMode(ACCESS_WRITE);
$t_user->set('active', 1);
$t_user->set('userclass', 1);
// 1=public user (no back-end login)
$t_user->update();
if ($t_user->numErrors()) {
$this->notification->addNotification(_t('Errors occurred when reactivating user: %1', join('; ', $t_user->getErrors())), __NOTIFICATION_TYPE_ERROR__);
} else {
$vn_user_id = $t_user->getPrimaryKey();
}
}
} else {
$t_user->setMode(ACCESS_WRITE);
$t_user->set('user_name', $vs_user_name);
$t_user->set('password', $vs_password = substr(md5(uniqid(microtime())), 0, 6));
$t_user->set('userclass', 1);
// 1=public user (no back-end login)
$t_user->set('fname', $vs_fname = $this->request->getParameter('billing_fname', pString));
$t_user->set('lname', $vs_lname = $this->request->getParameter('billing_lname', pString));
$t_user->set('email', $vs_user_name);
$t_user->insert();
if ($t_user->numErrors()) {
$this->notification->addNotification(_t('Errors occurred when creating new user: %1', join('; ', $t_user->getErrors())), __NOTIFICATION_TYPE_ERROR__);
} else {
$vn_user_id = $t_user->getPrimaryKey();
$this->notification->addNotification(_t('Created new client login for <em>%1</em>. Login name is <em>%2</em> and password is <em>%3</em>', $vs_fname . ' ' . $vs_lname, $vs_user_name, $vs_password), __NOTIFICATION_TYPE_INFO__);
// Create related entity?
}
}
}
}
if ($vn_user_id) {
// try to create transaction
$t_trans = new ca_commerce_transactions();
$t_trans->setMode(ACCESS_WRITE);
$t_trans->set('user_id', $vn_user_id);
$t_trans->set('short_description', "Created on " . date("c"));
$t_trans->set('set_id', null);
$t_trans->insert();
//.........这里部分代码省略.........
示例13: getFulfillmentLog
/**
* Returns a list of fulfillment events for the currently loaded order
*
* @param array $pa_options An array of options (none supported yet)
* @return array A list of arrays, each containing information about a specific fulfillment event. The list is ordered by date/time starting with the oldest event.
*/
public function getFulfillmentLog($pa_options = null)
{
if (!($vn_order_id = $this->getPrimaryKey())) {
return null;
}
$o_db = $this->getDb();
$qr_res = $o_db->query("\n\t\t\tSELECT e.*, i.*, o.idno item_idno\n\t\t\tFROM ca_commerce_fulfillment_events e \n\t\t\tINNER JOIN ca_commerce_order_items AS i ON i.item_id = e.item_id\n\t\t\tINNER JOIN ca_objects AS o ON o.object_id = i.object_id\n\t\t\tWHERE \n\t\t\t\te.order_id = ?\n\t\t\tORDER BY e.occurred_on\n\t\t", (int) $vn_order_id);
$t_object = new ca_objects();
$va_labels = $t_object->getPreferredDisplayLabelsForIDs($qr_res->getAllFieldValues("object_id"));
$t_item = new ca_commerce_order_items();
$va_events = array();
$qr_res->seek(0);
$va_user_cache = array();
while ($qr_res->nextRow()) {
$va_row = $qr_res->getRow();
$va_row['fulfillment_details'] = caUnserializeForDatabase($va_row['fulfillment_details']);
$va_row['item_label'] = $va_labels[$va_row['object_id']];
$va_row['fulfillment_method_display'] = $t_item->getChoiceListValue('fullfillment_method', $va_row['fullfillment_method']);
$va_row['service_display'] = $t_item->getChoiceListValue('service', $va_row['service']);
if ($vn_user_id = (int) $va_row['fulfillment_details']['user_id']) {
if (!isset($va_user_cache[$vn_user_id])) {
$t_user = new ca_users($vn_user_id);
if ($t_user->getPrimaryKey()) {
$va_user_cache[$vn_user_id] = array('fname' => $t_user->get('fname'), 'lname' => $t_user->get('lname'), 'email' => $t_user->get('email'));
} else {
$va_user_cache[$vn_user_id] = null;
}
}
if (is_array($va_user_cache[$vn_user_id])) {
$va_row = array_merge($va_row, $va_user_cache[$vn_user_id]);
}
}
$va_events[] = $va_row;
}
return $va_events;
}
示例14: GetObjectInfo
/**
* Return info via ajax on selected object
*/
public function GetObjectInfo()
{
$pn_user_id = $this->request->getParameter('user_id', pInteger);
$pn_object_id = $this->request->getParameter('object_id', pInteger);
$t_object = new ca_objects($pn_object_id);
$vn_current_user_id = $vs_current_user = $vs_current_user_checkout_date = $vs_reservation_list = null;
// user_id of current holder of item
$vb_is_reserved_by_current_user = false;
switch ($vn_status = $t_object->getCheckoutStatus()) {
case __CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__:
$vs_status_display = _t('Available');
break;
case __CA_OBJECTS_CHECKOUT_STATUS_OUT__:
$t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
$vn_current_user_id = $t_checkout->get('user_id');
$vs_status_display = $vn_current_user_id == $pn_user_id ? _t('Out with this user') : _t('Out');
$vs_current_user_checkout_date = $t_checkout->get('checkout_date', array('timeOmit' => true));
break;
case __CA_OBJECTS_CHECKOUT_STATUS_OUT_WITH_RESERVATIONS__:
$t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
$vn_current_user_id = $t_checkout->get('user_id');
$va_reservations = $t_object->getCheckoutReservations();
$vn_num_reservations = sizeof($va_reservations);
$vs_current_user_checkout_date = $t_checkout->get('checkout_date', array('timeOmit' => true));
$vs_status_display = $vn_num_reservations == 1 ? _t('Out with %1 reservation', $vn_num_reservations) : _t('Out with %1 reservations', $vn_num_reservations);
break;
case __CA_OBJECTS_CHECKOUT_STATUS_RESERVED__:
// get reservations list
$va_reservations = $t_object->getCheckoutReservations();
$vn_num_reservations = sizeof($va_reservations);
$t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
$vs_current_user_checkout_date = $t_checkout->get('created_on', array('timeOmit' => true));
$vs_status_display = $vn_num_reservations == 1 ? _t('Reserved') : _t('Available with %1 reservations', $vn_num_reservations);
break;
}
$vb_is_held_by_current_user = $pn_user_id == $vn_current_user_id;
if (is_array($va_reservations)) {
$va_tmp = array();
foreach ($va_reservations as $va_reservation) {
$vb_is_reserved_by_current_user = $va_reservation['user_id'] == $pn_user_id;
$t_user = new ca_users($va_reservation['user_id']);
$va_tmp[] = $t_user->get('fname') . ' ' . $t_user->get('lname') . (($vs_email = $t_user->get('email')) ? " ({$vs_email})" : "");
}
$vs_reservation_list = join(", ", $va_tmp);
}
if ($vn_current_user_id) {
$t_user = new ca_users($vn_current_user_id);
$vs_current_user = $t_user->get('fname') . ' ' . $t_user->get('lname');
}
$va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
$vs_holder_display_label = '';
if ($vb_is_held_by_current_user) {
$vs_status_display = _t('The user currently has this item');
} elseif ($vb_is_reserved_by_current_user) {
$vs_status_display = _t('The user has reserved this item');
} else {
$vs_reserve_display_label = $vn_status == 3 ? _t('Currently reserved by %1', $vs_reservation_list) : _t('Will reserve');
if (in_array($vn_status, array(1, 2))) {
$vs_holder_display_label = _t('held by %1 since %2', $vs_current_user, $vs_current_user_checkout_date);
}
}
$va_info = array('object_id' => $t_object->getPrimaryKey(), 'idno' => $t_object->get('idno'), 'name' => $t_object->get('ca_objects.preferred_labels.name'), 'media' => $t_object->getWithTemplate('^ca_object_representations.media.icon'), 'status' => $vn_status, 'status_display' => $vs_status_display, 'numReservations' => sizeof($va_reservations), 'reservations' => $va_reservations, 'config' => $va_checkout_config, 'current_user_id' => $vn_current_user_id, 'current_user' => $vs_current_user, 'current_user_checkout_date' => $vs_current_user_checkout_date, 'isOutWithCurrentUser' => $pn_user_id == $vn_current_user_id, 'isReservedByCurrentUser' => $vb_is_reserved_by_current_user, 'reserve_display_label' => $vs_reserve_display_label, 'due_on_display_label' => _t('Due on'), 'notes_display_label' => _t('Notes'), 'holder_display_label' => $vs_holder_display_label);
$va_info['title'] = $va_info['name'] . " (" . $va_info['idno'] . ")";
$va_info['storage_location'] = $t_object->getWithTemplate($va_checkout_config['show_storage_location_template']);
$this->view->setVar('data', $va_info);
$this->render('checkout/ajax_data_json.php');
}
示例15: caClientServicesGetSenderName
/**
*
*
* @param array $pa_data
* @param array $pa_options
*
* @return string
*/
function caClientServicesGetSenderName($pa_data, $pa_options = null)
{
global $g_caClientServicesNameCache;
if (!isset($g_caClientServicesNameCache[$pa_data['from_user_id']])) {
$t_user = new ca_users($pa_data['from_user_id']);
return $g_caClientServicesNameCache[$pa_data['from_user_id']] = $t_user->get('fname') . ' ' . $t_user->get('lname');
} else {
return $g_caClientServicesNameCache[$pa_data['from_user_id']];
}
}