本文整理汇总了PHP中SJB_UserManager::getUserNameByUserSID方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_UserManager::getUserNameByUserSID方法的具体用法?PHP SJB_UserManager::getUserNameByUserSID怎么用?PHP SJB_UserManager::getUserNameByUserSID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SJB_UserManager
的用法示例。
在下文中一共展示了SJB_UserManager::getUserNameByUserSID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$userInfo = SJB_Authorization::getCurrentUserInfo();
if (empty($userInfo)) {
$tp->assign("ERROR", "NOT_LOGIN");
$tp->display("../miscellaneous/error.tpl");
return;
}
$template = SJB_Request::getVar('template', 'my_invoices.tpl');
$searchTemplate = SJB_Request::getVar('search_template', 'invoice_search_form.tpl');
/***************************************************************/
$_REQUEST['action'] = 'search';
$_REQUEST['user_sid']['equal'] = $userInfo['sid'];
if (!isset($_REQUEST['date'])) {
$i18n = SJB_ObjectMother::createI18N();
$_REQUEST['date']['not_less'] = $i18n->getDate(date('Y-m-d', time() - 30 * 24 * 60 * 60));
$_REQUEST['date']['not_more'] = $i18n->getDate(date('Y-m-d'));
}
$invoice = new SJB_Invoice(array());
$invoice->addProperty(array('id' => 'username', 'type' => 'string', 'value' => '', 'is_system' => true));
$aliases = new SJB_PropertyAliases();
$aliases->addAlias(array('id' => 'username', 'real_id' => 'user_sid', 'transform_function' => 'SJB_UserDBManager::getUserSIDsLikeSearchString'));
$searchFormBuilder = new SJB_SearchFormBuilder($invoice);
$criteriaSaver = new SJB_InvoiceCriteriaSaver();
if (isset($_REQUEST['restore'])) {
$_REQUEST = array_merge($_REQUEST, $criteriaSaver->getCriteria());
}
$criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $invoice);
$searchFormBuilder->setCriteria($criteria);
$searchFormBuilder->registerTags($tp);
$tp->display($searchTemplate);
/********************** S O R T I N G *********************/
$criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $invoice);
$searcher = new SJB_InvoiceSearcher();
$foundInvoices = array();
$foundInvoicesInfo = array();
if (SJB_Request::getVar('action', '') == 'search') {
$foundInvoices = $searcher->getObjectsByCriteria($criteria, $aliases);
$criteriaSaver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
} elseif (isset($_REQUEST['restore'])) {
$foundInvoices = $criteriaSaver->getObjectsFromSession();
}
foreach ($foundInvoices as $id => $invoice) {
$invoice->addProperty(array('id' => 'sid', 'type' => 'string', 'value' => $invoice->getSID()));
$subUserSid = $invoice->getPropertyValue('subuser_sid');
if ($subUserSid) {
$payer = SJB_UserManager::getUserNameByUserSID($subUserSid);
} else {
$userSid = $invoice->getPropertyValue('user_sid');
$payer = SJB_UserManager::getUserNameByUserSID($userSid);
}
$invoice->addProperty(array('id' => 'payer', 'type' => 'string', 'value' => $payer));
$foundInvoices[$id] = $invoice;
$foundInvoicesInfo[$invoice->getSID()] = SJB_InvoiceManager::getInvoiceInfoBySID($invoice->getSID());
}
$sortingField = SJB_Request::getVar('sorting_field', 'sid');
$sortingOrder = SJB_Request::getVar('sorting_order', 'DESC');
if ($invoice->propertyIsSet($sortingField)) {
$sortArray = array();
$sortedFoundInvoicesInfo = array();
foreach ($foundInvoices as $id => $invoice) {
$sortArray[$id] = $invoice->getPropertyValue($sortingField);
}
if ($sortingOrder == 'ASC') {
asort($sortArray);
} elseif ($sortingOrder == 'DESC') {
arsort($sortArray);
}
foreach ($sortArray as $id => $value) {
$sortedFoundInvoicesInfo[$id] = $foundInvoicesInfo[$id];
}
} else {
$sortedFoundInvoicesInfo = $foundInvoicesInfo;
}
$formCollection = new SJB_FormCollection($foundInvoices);
$formCollection->registerTags($tp);
$subUsers = SJB_UserManager::getSubUsers($userInfo['sid']);
$isSubUserExists = !empty($subUsers) ? true : false;
$tp->assign('isSubUserExists', $isSubUserExists);
$tp->assign('sorting_field', $sortingField);
$tp->assign('sorting_order', $sortingOrder);
$tp->assign('found_invoices', $sortedFoundInvoicesInfo);
$tp->display($template);
}
示例2: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$template = SJB_Request::getVar('template', 'users.tpl');
$searchTemplate = SJB_Request::getVar('search_template', 'user_search_form.tpl');
$passedParametersViaUri = SJB_UrlParamProvider::getParams();
$userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false;
$userGroupSID = $userGroupID ? SJB_UserGroupManager::getUserGroupSIDByID($userGroupID) : null;
$errors = array();
/********** A C T I O N S W I T H U S E R S **********/
$action = SJB_Request::getVar('action_name');
if (!empty($action)) {
$users_sids = SJB_Request::getVar('users', array());
$_REQUEST['restore'] = 1;
switch ($action) {
case 'approve':
foreach ($users_sids as $user_sid => $value) {
$username = SJB_UserManager::getUserNameByUserSID($user_sid);
SJB_UserManager::setApprovalStatusByUserName($username, 'Approved');
SJB_UserManager::activateUserByUserName($username);
SJB_UserDBManager::deleteActivationKeyByUsername($username);
if (!SJB_SocialPlugin::getProfileSocialID($user_sid)) {
SJB_Notifications::sendUserWelcomeLetter($user_sid);
} else {
SJB_Notifications::sendUserApprovedLetter($user_sid);
}
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
case 'reject':
$rejection_reason = SJB_Request::getVar('rejection_reason', '');
foreach ($users_sids as $user_sid => $value) {
$username = SJB_UserManager::getUserNameByUserSID($user_sid);
SJB_UserManager::setApprovalStatusByUserName($username, 'Rejected', $rejection_reason);
SJB_UserManager::deactivateUserByUserName($username);
SJB_Notifications::sendUserRejectedLetter($user_sid);
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
case 'activate':
foreach ($users_sids as $user_sid => $value) {
$username = SJB_UserManager::getUserNameByUserSID($user_sid);
$userinfo = SJB_UserManager::getUserInfoByUserName($username);
SJB_UserManager::activateUserByUserName($username);
if ($userinfo['approval'] == 'Approved') {
SJB_UserDBManager::deleteActivationKeyByUsername($username);
SJB_Notifications::sendUserApprovedLetter($user_sid);
}
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
case 'deactivate':
foreach ($users_sids as $user_sid => $value) {
$username = SJB_UserManager::getUserNameByUserSID($user_sid);
SJB_UserManager::deactivateUserByUserName($username);
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
case 'delete':
foreach (array_keys($users_sids) as $user_sid) {
try {
SJB_UserManager::deleteUserById($user_sid);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
case 'send_activation_letter':
foreach ($users_sids as $user_sid => $value) {
SJB_Notifications::sendUserActivationLetter($user_sid);
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
case 'change_product':
$productToChange = SJB_Request::getVar('product_to_change');
if (empty($productToChange)) {
$productToChange = 0;
}
foreach ($users_sids as $user_sid => $value) {
$user = SJB_UserManager::getObjectBySID($user_sid);
// UNSUBSCRIBE selected
if ($productToChange == 0) {
SJB_ContractManager::deleteAllContractsByUserSID($user_sid);
} else {
$productInfo = SJB_ProductsManager::getProductInfoBySID($productToChange);
$listingNumber = SJB_Request::getVar('number_of_listings', null);
if (is_null($listingNumber) && !empty($productInfo['number_of_listings'])) {
$listingNumber = $productInfo['number_of_listings'];
}
$contract = new SJB_Contract(array('product_sid' => $productToChange, 'numberOfListings' => $listingNumber, 'is_recurring' => 0));
$contract->setUserSID($user_sid);
$contract->saveInDB();
if ($contract->isFeaturedProfile()) {
SJB_UserManager::makeFeaturedBySID($user_sid);
}
}
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
break;
//.........这里部分代码省略.........
示例3: execute
public function execute()
{
$this->redirectToListingByKeywords();
// SEO friendly URL for company profile
$m = array();
$isCompanyProfilePage = false;
if (preg_match('#/company/([0-9]+)/.*#', SJB_Navigator::getURI(), $m)) {
$isCompanyProfilePage = true;
$params = SJB_FixedUrlParamProvider::getParams($_REQUEST);
if (!empty($params)) {
$aliasUsername = SJB_UserManager::getUserNameByUserSID($m[1]);
if (!empty($aliasUsername)) {
$_REQUEST['username']['equal'] = $aliasUsername;
$_REQUEST['anonymous']['equal'] = 0;
}
}
}
if (!empty($_REQUEST['username']['equal']) && is_int($_REQUEST['username']['equal'])) {
$aliasUsername = SJB_UserManager::getUserNameByUserSID(intval($_REQUEST['username']['equal']));
if (!empty($aliasUsername)) {
$_REQUEST['username']['equal'] = $aliasUsername;
}
}
$listingTypeId = SJB_Request::getVar('listing_type_id', 0);
if (!$listingTypeId) {
$listingTypeId = isset($_REQUEST['listing_type']['equal']) ? $_REQUEST['listing_type']['equal'] : SJB_Session::getValue('listing_type_id');
}
if ($listingTypeId) {
$_REQUEST['listing_type']['equal'] = $listingTypeId;
}
$action = SJB_Request::getVar('action', 'search');
//XSS defense
$searchId = SJB_Request::getVar('searchId', false);
if ($searchId && !is_numeric($searchId)) {
$_REQUEST['searchId'] = false;
}
$request = $_REQUEST;
if (SJB_System::getSettingByName('turn_on_refine_search_' . $listingTypeId)) {
switch ($action) {
case 'refine':
$searchID = SJB_Request::getVar('searchId', false);
unset($request['searchId']);
$criteria_saver = new SJB_ListingCriteriaSaver($searchID);
$request = SJB_RefineSearch::mergeCriteria($criteria_saver->getCriteria(), $request);
break;
case 'undo':
$param = SJB_Request::getVar('param', false);
$field_type = SJB_Request::getVar('type', false);
$value = SJB_Request::getVar('value', false);
if ($param && $field_type && $value) {
$searchID = SJB_Request::getVar('searchId', false);
unset($request['searchId']);
$criteria_saver = new SJB_ListingCriteriaSaver($searchID);
$criteria = $criteria_saver->criteria;
if (isset($criteria[$param][$field_type])) {
switch ($field_type) {
case 'geo':
if ($criteria[$param][$field_type]['location'] == $value) {
unset($criteria[$param]);
}
break;
case 'monetary':
if ($criteria[$param][$field_type]['not_less'] == $value) {
$criteria[$param][$field_type]['not_less'] = "";
}
if ($criteria[$param][$field_type]['not_more'] == $value) {
$criteria[$param][$field_type]['not_more'] = "";
}
break;
case 'tree':
// search params incoming as string, where params separated by ','
// we need to undo one of them
$params = explode(',', $criteria[$param][$field_type]);
$params = array_flip($params);
unset($params[$value]);
$params = array_flip($params);
$criteria[$param][$field_type] = implode(',', $params);
break;
default:
if (is_array($criteria[$param][$field_type])) {
foreach ($criteria[$param][$field_type] as $key => $val) {
if ($val == $value) {
unset($criteria[$param][$field_type][$key]);
}
}
} else {
unset($criteria[$param]);
}
break;
}
}
$criteria['default_sorting_field'] = $request['default_sorting_field'];
$criteria['default_sorting_order'] = $request['default_sorting_order'];
$criteria['default_listings_per_page'] = $request['default_listings_per_page'];
$criteria['results_template'] = $request['results_template'];
$request = array_merge($criteria, $request);
}
break;
}
}
//.........这里部分代码省略.........
示例4: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$parent_name = null;
$user_sid = SJB_Request::getVar('user_sid', false);
if (!is_null($user_sid)) {
$user_info = SJB_UserManager::getUserInfoBySID($user_sid);
$user_info = array_merge($user_info, $_REQUEST);
$form_submitted = SJB_Request::getVar('action_name');
$user = new SJB_User($user_info, $user_info['user_group_sid']);
if (!empty($user_info['parent_sid'])) {
$props = $user->getProperties();
$allowedProperties = array('username', 'email', 'password');
foreach ($props as $prop) {
if (!in_array($prop->getID(), $allowedProperties)) {
$user->deleteProperty($prop->getID());
}
}
$parent_name = SJB_UserManager::getUserNameByUserSID($user_info['parent_sid']);
}
$user->setSID($user_info['sid']);
$user->getProperty('email')->type->disableEmailConfirmation();
$user->deleteProperty("active");
$user->makePropertyNotRequired("password");
if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) {
if ($form_submitted) {
$email = $user->getPropertyValue('email');
if (is_array($email)) {
$email = $email['original'];
}
$user->setPropertyValue('username', $email);
}
}
$user->addExtUserIDProperty($user_info['extUserID']);
$edit_user_form = new SJB_Form($user);
$errors = array();
if ($form_submitted && $edit_user_form->isDataValid($errors)) {
$password_value = $user->getPropertyValue('password');
$properties = null;
if (empty($password_value['original'])) {
$properties = $user->getProperties();
$user->deleteProperty('password');
}
SJB_UserManager::saveUser($user);
// >>> SJB-1197
// needs to check session for ajax-uploaded files, and set it to user profile
$tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
$formToken = SJB_Request::getVar('form_token');
if (!empty($formToken)) {
$tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken);
if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) {
// prepare user profile fields array
$userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo();
$userProfileFields = array();
foreach ($userProfileFieldsInfo as $field) {
$userProfileFields[$field['id']] = $field;
}
// look for temporary values
foreach ($tmpUploadedFields as $fieldId => $fieldInfo) {
// check field ID for valid ID in user profile fields
if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) {
continue;
}
$fieldType = $userProfileFields[$fieldId]['type'];
$profilePropertyId = $fieldId . '_' . $user->getSID();
switch (strtolower($fieldType)) {
case 'video':
case 'file':
// change temporary file ID
SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
// set value of user property to new uploaded file
$user->setPropertyValue($fieldId, $profilePropertyId);
break;
case 'logo':
// change temporary file ID and thumb ID
SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb');
// set value of user property to new uploaded file
$user->setPropertyValue($fieldId, $profilePropertyId);
break;
default:
break;
}
$tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}");
}
// and save user with new fields data
SJB_UserManager::saveUser($user);
SJB_Authorization::updateCurrentUserSession();
// clean temporary storage
$tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
// CLEAR TEMPORARY SESSION STORAGE
SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
}
}
// <<< SJB-1197
if (SJB_Request::isAjax()) {
echo "<p class=\"green\">User Saved</p>";
exit;
}
if ($form_submitted == 'save_info') {
//.........这里部分代码省略.........
示例5: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$errors = array();
/********** A C T I O N S W I T H T R A N S A C T I O N S **********/
$action = SJB_Request::getVar('action_name', SJB_Request::getVar('action', false));
$transactions_sids = SJB_Request::getVar('transactions', false);
if ($action && $transactions_sids) {
$_REQUEST['restore'] = 1;
if ($action == 'delete') {
// DELETE
foreach ($transactions_sids as $transaction_sid => $value) {
SJB_TransactionManager::deleteTransactionBySID($transaction_sid);
}
} else {
unset($_REQUEST['restore']);
}
}
/********** D E F A U L T V A L U E S F O R S E A R C H **********/
$_REQUEST['action'] = 'filter';
$i18n = SJB_ObjectMother::createI18N();
if (!isset($_REQUEST['date'])) {
$_REQUEST['date']['not_less'] = $i18n->getDate(date('Y-m-d', time() - 30 * 24 * 60 * 60));
$_REQUEST['date']['not_more'] = $i18n->getDate(date('Y-m-d', time() + 24 * 60 * 60));
} else {
if (!$i18n->isValidDate($_REQUEST['date']['not_less']) && !empty($_REQUEST['date']['not_less'])) {
$errors[] = 'INVALID_PERIOD_FROM';
}
if (!$i18n->isValidDate($_REQUEST['date']['not_more']) && !empty($_REQUEST['date']['not_more'])) {
$errors[] = 'INVALID_PERIOD_TO';
}
}
/************************ S E A R C H F O R M ***************************/
$transaction = new SJB_Transaction();
$transaction->addProperty(array('id' => 'username', 'type' => 'string', 'value' => '', 'is_system' => true));
$aliases = new SJB_PropertyAliases();
$aliases->addAlias(array('id' => 'username', 'real_id' => 'user_sid', 'transform_function' => 'SJB_UserManager::getUserSIDsLikeUsername'));
$search_form_builder = new SJB_SearchFormBuilder($transaction);
$criteria_saver = new SJB_TransactionCriteriaSaver();
if (isset($_REQUEST['restore'])) {
$_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
}
$criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $transaction);
$search_form_builder->setCriteria($criteria);
$search_form_builder->registerTags($tp);
$tp->display('payment_form.tpl');
/******************** S E A R C H ************************/
$paginator = new SJB_TransactionHistoryPagination();
$searcher = new SJB_TransactionSearcher($paginator);
if (SJB_Request::getVar('action', '') == 'filter') {
$transactions = $searcher->getObjectsByCriteria($criteria, $aliases);
if (empty($transactions) && $paginator->currentPage != 1) {
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/payments/?page=1');
}
$criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
} elseif (isset($_REQUEST['restore'])) {
$transactions = $criteria_saver->getObjectsFromSession();
}
$paginator->setItemsCount($searcher->getAffectedRows());
$found_trans = array();
$found_trans_sids = array();
foreach ($transactions as $transaction) {
$user_sid = $transaction->getPropertyValue('user_sid');
$username = SJB_UserManager::getUserNameByUserSID($user_sid);
$transaction->addProperty(array('id' => 'username', 'type' => 'string', 'value' => $username));
$found_trans[$transaction->getSID()] = $transaction;
$found_trans_sids[$transaction->getSID()] = $transaction->getSID();
}
$sorted_found_trans_sids = $found_trans_sids;
$form_collection = new SJB_FormCollection($found_trans);
$form_collection->registerTags($tp);
$tp->assign('paginationInfo', $paginator->getPaginationInfo());
$tp->assign('errors', $errors);
$tp->assign('found_transactions_sids', $sorted_found_trans_sids);
$tp->display('payments.tpl');
}