예제 #1
0
 public static function getCurrentUserInfo()
 {
     if (SJB_Authorization::isUserLoggedIn()) {
         return SJB_Authorization::getCurrentUserInfo();
     }
     return null;
 }
예제 #2
0
 public static function getCurrentUserInfo()
 {
     if (SJB_Admin::admin_authed()) {
         return SJB_Authorization::getCurrentUserInfo();
     }
     return null;
 }
예제 #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user_menu_template = 'user_menu.tpl';
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_info = SJB_Authorization::getCurrentUserInfo();
         if (!empty($user_info)) {
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
             if (!empty($user_group_info['user_menu_template']) && $tp->templateExists($user_group_info['user_menu_template'])) {
                 $user_menu_template = $user_group_info['user_menu_template'];
             }
             $tp->assign("user_group_info", $user_group_info);
             $tp->assign('listingTypesInfo', SJB_ListingTypeManager::getAllListingTypesInfo());
         }
     }
     $tp->assign("account_activated", SJB_Request::getVar('account_activated', ''));
     $tp->display($user_menu_template);
 }
예제 #4
0
 public function execute()
 {
     $page_id = SJB_Request::getVar('pageid', null);
     if ($page_id) {
         $tp = SJB_System::getTemplateProcessor();
         $i18n = SJB_I18N::getInstance();
         $lang = SJB_Request::getVar('lang', $i18n->getCurrentLanguage());
         $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $lang);
         if (empty($staticContent)) {
             $def_lang = SJB_System::getSettingByName('i18n_default_language');
             $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $def_lang);
         }
         if (!empty($staticContent)) {
             if ($page_id == '404') {
                 $isLoggedIn = SJB_Authorization::isUserLoggedIn();
                 if ($isLoggedIn) {
                     $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
                     $currentUserInfo = SJB_Authorization::getCurrentUserInfo();
                     $userGroupinfo = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']);
                     $acl = SJB_Acl::getInstance();
                     $tp->assign('acl', $acl);
                     $tp->assign('listingTypesInfo', $listingTypesInfo);
                     $tp->assign('userGroupInfo', $userGroupinfo);
                 }
                 $staticContent['content'] = htmlspecialchars_decode($staticContent['content']);
                 $tp->assign('isLoggedIn', $isLoggedIn);
             }
             if (empty($staticContent['content'])) {
                 // Null создаёт ошибку в smarty
                 $staticContent['content'] = '';
             }
             $tp->assign('staticContent', $staticContent['content']);
             $tp->display('static_content.tpl');
         }
     }
 }
예제 #5
0
 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);
 }
예제 #6
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user_info = SJB_Authorization::getCurrentUserInfo();
     if (!empty($user_info['subuser'])) {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/sub-accounts/edit/?user_id=' . $user_info['subuser']['sid']);
     }
     if (!empty($user_info)) {
         $user_info = array_merge($user_info, $_REQUEST);
         $username = $user_info['username'];
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
         $delete_profile = SJB_Request::getVar('command', '', 'post') == 'unregister-user';
         $errors = array();
         if ($delete_profile && SJB_Acl::getInstance()->isAllowed('delete_user_profile')) {
             try {
                 $user = SJB_UserManager::getObjectBySID($user_info['sid']);
                 SJB_UserManager::deleteUserById($user_info['sid']);
                 SJB_AdminNotifications::sendAdminDeletingUserProfile($user, SJB_Request::getVar('reason', '', 'post'));
                 SJB_Authorization::logout();
                 $user_info = array();
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-profile/?profile_deleted=true');
             } catch (Exception $e) {
                 $errors[] = $e->getMessage();
             }
         }
         $user = new SJB_User($user_info, $user_info['user_group_sid']);
         $user->setSID($user_info['sid']);
         $user->deleteProperty("active");
         $user->deleteProperty("featured");
         $user->makePropertyNotRequired("password");
         $user->getProperty('email')->type->disableEmailConfirmation();
         $edit_profile_form = new SJB_Form($user);
         $edit_profile_form->registerTags($tp);
         $edit_profile_form->makeDisabled("username");
         $form_submitted = SJB_Request::getVar('action', false) == 'save_info';
         if ($form_submitted && $edit_profile_form->isDataValid($errors)) {
             $password_value = $user->getPropertyValue('password');
             if (empty($password_value['original'])) {
                 $user->deleteProperty('password');
             }
             SJB_UserManager::saveUser($user);
             SJB_Authorization::updateCurrentUserSession();
             // >>> 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
             $tp->assign("form_is_submitted", true);
         } else {
             $tp->assign("errors", $errors);
         }
         $form_fields = $edit_profile_form->getFormFieldsInfo();
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $tp->assign("show_mailing_flag", $user_group_info['show_mailing_flag']);
         $tp->assign("form_fields", $form_fields);
         $tp->assign('userTree', true);
         $tp->display('edit_profile.tpl');
     } elseif (empty($user_info) && SJB_Request::getVar('profile_deleted', '') == true) {
         $user = new SJB_User(array());
         $edit_profile_form = new SJB_Form($user);
         $edit_profile_form->registerTags($tp);
         $edit_profile_form->makeDisabled("username");
         $form_fields = $edit_profile_form->getFormFieldsInfo();
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $tp->assign("form_fields", $form_fields);
         $tp->assign('action', 'delete_profile');
         $tp->assign('tree_link_users', 'users');
         $tp->assign('userTree', true);
         $tp->display('edit_profile.tpl');
     } else {
         $tp->assign("ERROR", "NOT_LOGIN");
         $tp->display("../miscellaneous/error.tpl");
         return;
     }
 }