예제 #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listingTypeID = SJB_Request::getVar('listing_type_id', null);
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSID);
     $productSID = SJB_Request::getVar('product_sid', false);
     $editUser = SJB_Request::getVar('edit_user', false);
     $action = SJB_Request::getVar('action', false);
     $username = SJB_Request::getVar('username', false);
     $errors = array();
     if ($username && ($userSID = SJB_UserManager::getUserSIDbyUsername($username))) {
         $userInfo = SJB_UserManager::getUserInfoBySID($userSID);
         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']);
         if (!$productSID) {
             $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($userGroupInfo['sid']);
             foreach ($products as $key => $product) {
                 if (empty($product['listing_type_sid']) || $product['listing_type_sid'] != $listingTypeSID) {
                     unset($products[$key]);
                 }
             }
             if ($action == 'productVerify') {
                 $errors['PRODUCT_NOT_SELECTED'] = 1;
             }
             $tp->assign('errors', $errors);
             $tp->assign('username', $username);
             $tp->assign('products', $products);
             $tp->assign('edit_user', $editUser);
             $tp->assign('userSID', $userSID);
             $tp->assign('userGroupInfo', $userGroupInfo);
             $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
             $tp->display('select_product.tpl');
         } else {
             $form_submitted = SJB_Request::getVar('action', '') == 'add';
             $tmp_listing_id_from_request = SJB_Request::getVar('listing_id', false, 'default', 'int');
             if (!empty($tmp_listing_id_from_request)) {
                 $tmp_listing_sid = $tmp_listing_id_from_request;
             } elseif (!$tmp_listing_id_from_request) {
                 $tmp_listing_sid = time();
             }
             $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
             $extraInfo = is_null($productInfo['serialized_extra_info']) ? null : unserialize($productInfo['serialized_extra_info']);
             if (!empty($extraInfo)) {
                 $extraInfo['product_sid'] = $productSID;
             }
             $_REQUEST['featured'] = !empty($_REQUEST['featured']) ? $_REQUEST['featured'] : $productInfo['featured'];
             $_REQUEST['priority'] = !empty($_REQUEST['priority']) ? $_REQUEST['priority'] : $productInfo['priority'];
             $listing = new SJB_Listing($_REQUEST, $listingTypeSID);
             $properties = $listing->getPropertyList();
             foreach ($properties as $property) {
                 $propertyInfo = $listing->getPropertyInfo($property);
                 $propertyInfo['user_sid'] = $userSID;
                 if ($propertyInfo['type'] == 'location') {
                     $child = $listing->getChild($property);
                     $childProperties = $child->getPropertyList();
                     foreach ($childProperties as $childProperty) {
                         $childPropertyInfo = $child->getPropertyInfo($childProperty);
                         $childPropertyInfo['user_sid'] = $userSID;
                         $child->setPropertyInfo($childProperty, $childPropertyInfo);
                     }
                 }
                 $listing->setPropertyInfo($property, $propertyInfo);
             }
             $listing->deleteProperty('status');
             $listing->deleteProperty('reject_reason');
             $access_type = $listing->getProperty('access_type');
             if ($form_submitted) {
                 if (!empty($access_type)) {
                     $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true));
                 }
             }
             $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($userSID);
             if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                 $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
                 if ($issetQuestionnairyField) {
                     $value = SJB_Request::getVar("screening_questionnaire");
                     $listing_info = $_REQUEST;
                     $value = $value ? $value : isset($listing_info['screening_questionnaire']) ? $listing_info['screening_questionnaire'] : '';
                     $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($userSID), 'is_system' => true));
                 }
             } else {
                 $listing->deleteProperty('screening_questionnaire');
             }
             if ($listing->getProperty('captcha')) {
                 $listing->deleteProperty('captcha');
             }
             $add_listing_form = new SJB_Form($listing);
             $add_listing_form->registerTags($tp);
             $field_errors = array();
             if ($form_submitted && $add_listing_form->isDataValid($field_errors)) {
                 $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 $listing->setUserSID($userSID);
                 $listing->setProductInfo($extraInfo);
                 if (empty($access_type->value)) {
                     $listing->setPropertyValue('access_type', 'everyone');
                 }
                 SJB_ListingManager::saveListing($listing);
                 SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $_REQUEST['featured'], $_REQUEST['priority'], $userSID);
                 if (isset($_SESSION['tmp_file_storage'])) {
                     foreach ($_SESSION['tmp_file_storage'] as $v) {
                         SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s", $listing->getSID(), $v['picture_saved_name']);
                         SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s", $listing->getSID(), $v['thumb_saved_name']);
                     }
                     SJB_Session::unsetValue('tmp_file_storage');
                 }
                 $formToken = SJB_Request::getVar('form_token');
                 $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
                 if (!empty($uploadedFields)) {
                     foreach ($uploadedFields as $fieldId => $fieldValue) {
                         // get field of listing
                         $isComplex = false;
                         if (strpos($fieldId, ':') !== false) {
                             $isComplex = true;
                         }
                         $tmpUploadedFileId = $fieldValue['file_id'];
                         // rename it to real listing field value
                         $newFileId = $fieldId . "_" . $listing->getSID();
                         SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                         if ($isComplex) {
                             list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                             $parentProp = $listing->getProperty($parentField);
                             $parentValue = $parentProp->getValue();
                             // look for complex property with current $fieldID and set it to new value of property
                             if (!empty($parentValue)) {
                                 foreach ($parentValue as $id => $value) {
                                     if ($id == $subField) {
                                         $parentValue[$id][$complexStep] = $newFileId;
                                     }
                                 }
                                 $listing->setPropertyValue($parentField, $parentValue);
                             }
                         } else {
                             $listing->setPropertyValue($fieldId, $newFileId);
                         }
                         // unset value from session temporary storage
                         $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                     }
                     //and remove token key from temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                     SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                     SJB_ListingManager::saveListing($listing);
                 }
                 SJB_ListingManager::activateListingBySID($listing->getSID());
                 SJB_ProductsManager::incrementPostingsNumber($productSID);
                 $listingSid = $listing->getSID();
                 SJB_Event::dispatch('listingSaved', $listingSid);
                 if ($editUser) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-user/?user_sid=" . $userSID);
                 } else {
                     if ($listingTypeID == 'resume' || $listingTypeID == 'job') {
                         $link = "manage-" . strtolower($listingTypeID) . "s";
                     } else {
                         $link = "manage-" . strtolower($listingTypeID) . "-listings";
                     }
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/{$link}/?action=search&listing_type_sid=" . $listingTypeSID);
                 }
             } else {
                 $listing->deleteProperty('access_list');
                 $listing->deleteProperty('contract_id');
                 $add_listing_form = new SJB_Form($listing);
                 if ($form_submitted) {
                     $add_listing_form->isDataValid($field_errors);
                 }
                 $add_listing_form->registerTags($tp);
                 $form_fields = $add_listing_form->getFormFieldsInfo();
                 $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
                 $formFieldsSorted = array();
                 $formFieldsSorted['featured'] = $form_fields['featured'];
                 $formFieldsSorted['priority'] = $form_fields['priority'];
                 foreach ($pages as $page) {
                     $listing_fields = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']);
                     foreach (array_keys($listing_fields) as $field) {
                         if ($listing->propertyIsSet($field)) {
                             $formFieldsSorted[$field] = $form_fields[$field];
                         }
                     }
                 }
                 $form_fields = $formFieldsSorted;
                 //SJB_HelperFunctions::d($form_fields);
                 $employers_list = SJB_Request::getVar('list_emp_ids', false);
                 $employers = array();
                 if (is_array($employers_list)) {
                     foreach ($employers_list as $emp) {
                         $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                         $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                     }
                     sort($employers);
                 }
                 $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                 $tp->assign("pic_limit", $numberOfPictures);
                 $tp->assign("listing_id", $tmp_listing_sid);
                 $tp->assign("listing_access_list", $employers);
                 $tp->assign("errors", $field_errors);
                 $tp->assign("form_fields", $form_fields);
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             }
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             $tp->assign('edit_user', $editUser);
             $tp->assign('productInfo', $productInfo);
             $tp->assign('username', $username);
             $tp->assign('product_sid', $productSID);
             $tp->assign('userSID', $userSID);
             $tp->assign('userGroupInfo', $userGroupInfo);
             $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
             $tp->display('input_form.tpl');
         }
     } else {
         if ($username && !$userSID) {
             $errors['USER_NOT_FOUND'] = 1;
         } elseif ($action == 'userVerify') {
             $errors['USER_NOT_SELECTED'] = 1;
         }
         $tp->assign('errors', $errors);
         $tp->assign('username', $username);
         $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
         $tp->display('select_user.tpl');
     }
 }
예제 #2
0
 protected function getWorkFieldsInfo($position)
 {
     return array('employer' => SJB_Array::getPath($position, 'employer/name'), 'position' => SJB_Array::getPath($position, 'position/name'), 'location' => SJB_Array::getPath($position, 'location/name'), 'start_date' => SJB_Array::get($position, 'start_date'), 'end_date' => SJB_Array::get($position, 'end_date'), 'description' => SJB_Array::get($position, 'description'));
 }
예제 #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = SJB_Request::getVar('template', 'manage_invoices.tpl');
     $searchTemplate = SJB_Request::getVar('search_template', 'invoice_search_form.tpl');
     $action = SJB_Request::getVar('action_name');
     if (!empty($action)) {
         $invoicesSIDs = SJB_Request::getVar('invoices', array());
         $_REQUEST['restore'] = 1;
         switch ($action) {
             case 'paid':
                 foreach (array_keys($invoicesSIDs) as $invoiceSID) {
                     $invoice = SJB_InvoiceManager::getObjectBySID($invoiceSID);
                     $userSID = $invoice->getPropertyValue('user_sid');
                     if (SJB_UserManager::isUserExistsByUserSid($userSID)) {
                         $items = $invoice->getPropertyValue('items');
                         $productSIDs = $items['products'];
                         foreach ($productSIDs as $key => $productSID) {
                             if ($productSID != -1) {
                                 if (SJB_ProductsManager::isProductExists($productSID)) {
                                     $productInfo = $invoice->getItemValue($key);
                                     $listingNumber = $productInfo['qty'];
                                     $contract = new SJB_Contract(array('product_sid' => $productSID, 'numberOfListings' => $listingNumber, 'is_recurring' => $invoice->isRecurring()));
                                     $contract->setUserSID($userSID);
                                     $contract->setPrice($items['amount'][$key]);
                                     if ($contract->saveInDB()) {
                                         SJB_ListingManager::activateListingsAfterPaid($userSID, $productSID, $contract->getID(), $listingNumber);
                                         SJB_ShoppingCart::deleteItemFromCartBySID($productInfo['shoppingCartRecord'], $userSID);
                                         $bannerInfo = $productInfo['banner_info'];
                                         if ($productInfo['product_type'] == 'banners' && !empty($bannerInfo)) {
                                             $bannersObj = new SJB_Banners();
                                             $bannersObj->addBanner($bannerInfo['title'], $bannerInfo['link'], $bannerInfo['bannerFilePath'], $bannerInfo['sx'], $bannerInfo['sy'], $bannerInfo['type'], 0, $bannerInfo['banner_group_sid'], $bannerInfo, $userSID, $contract->getID());
                                             $bannerGroup = $bannersObj->getBannerGroupBySID($bannerInfo['banner_group_sid']);
                                             SJB_AdminNotifications::sendAdminBannerAddedLetter($userSID, $bannerGroup);
                                         }
                                         if ($contract->isFeaturedProfile()) {
                                             SJB_UserManager::makeFeaturedBySID($userSID);
                                         }
                                         if (SJB_UserNotificationsManager::isUserNotifiedOnSubscriptionActivation($userSID)) {
                                             SJB_Notifications::sendSubscriptionActivationLetter($userSID, $productInfo);
                                         }
                                     }
                                 }
                             } else {
                                 $type = SJB_Array::getPath($items, 'custom_info/' . $key . '/type');
                                 switch ($type) {
                                     case 'featuredListing':
                                         $listingId = SJB_Array::getPath($items, 'custom_info/' . $key . '/listing_id');
                                         SJB_ListingManager::makeFeaturedBySID($listingId);
                                         break;
                                     case 'priorityListing':
                                         $listingId = SJB_Array::getPath($items, 'custom_info/' . $key . '/listing_id');
                                         SJB_ListingManager::makePriorityBySID($listingId);
                                         break;
                                     case 'activateListing':
                                         $listingsIds = explode(",", SJB_Array::getPath($items, 'custom_info/' . $key . '/listings_ids'));
                                         foreach ($listingsIds as $listingId) {
                                             SJB_ListingManager::activateListingBySID($listingId);
                                         }
                                         break;
                                 }
                             }
                         }
                         SJB_Statistics::addStatisticsFromInvoice($invoice);
                     }
                     $total = $invoice->getPropertyValue('total');
                     if ($total > 0) {
                         $gatewayID = $invoice->getPropertyValue('payment_method');
                         $gatewayID = isset($gatewayID) ? $gatewayID : 'cash_payment';
                         $transactionId = md5($invoiceSID . $gatewayID);
                         $transactionInfo = array('transaction_id' => $transactionId, 'invoice_sid' => $invoiceSID, 'amount' => $total, 'payment_method' => $gatewayID, 'user_sid' => $invoice->getPropertyValue('user_sid'));
                         $transaction = new SJB_Transaction($transactionInfo);
                         SJB_TransactionManager::saveTransaction($transaction);
                     }
                     SJB_InvoiceManager::markPaidInvoiceBySID($invoiceSID);
                     SJB_PromotionsManager::markPromotionAsPaidByInvoiceSID($invoiceSID);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-invoices/");
                 break;
             case 'unpaid':
                 foreach (array_keys($invoicesSIDs) as $invoiceSID) {
                     SJB_InvoiceManager::markUnPaidInvoiceBySID($invoiceSID);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-invoices/');
                 break;
             case 'delete':
                 foreach (array_keys($invoicesSIDs) as $invoiceSID) {
                     SJB_InvoiceManager::deleteInvoiceBySID($invoiceSID);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-invoices/');
                 break;
             default:
                 unset($_REQUEST['restore']);
                 break;
         }
     }
     /***************************************************************/
     $_REQUEST['action'] = 'search';
     $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 *********************/
     $paginator = new SJB_InvoicePagination();
     $innerJoin = false;
     if ($paginator->sortingField == 'username') {
         $innerJoin = array('users' => array('sort_field' => array(36 => array('FirstName', 'LastName'), 41 => 'CompanyName'), 'join_field' => 'sid', 'join_field2' => 'user_sid', 'main_table' => 'invoices', 'join' => 'LEFT JOIN'));
     }
     $searcher = new SJB_InvoiceSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder, $innerJoin);
     $foundInvoices = array();
     $foundInvoicesInfo = array();
     if (SJB_Request::getVar('action', '') == 'search') {
         $foundInvoices = $searcher->getObjectsByCriteria($criteria, $aliases);
         if (empty($foundInvoices) && $paginator->currentPage != 1) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-invoices/?page=1');
         }
         $criteriaSaver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
     } elseif (isset($_REQUEST['restore'])) {
         $foundInvoices = $criteriaSaver->getObjectsFromSession();
     }
     foreach ($foundInvoices as $id => $invoice) {
         $subUserSID = $invoice->getPropertyValue('subuser_sid');
         if ($subUserSID) {
             $subUserInfo = SJB_UserManager::getUserInfoBySID($subUserSID);
             $parentInfo = SJB_UserManager::getUserInfoBySID($subUserInfo['parent_sid']);
             $username = $parentInfo['CompanyName'];
         } else {
             $userSID = $invoice->getPropertyValue('user_sid');
             $userInfo = SJB_UserManager::getUserInfoBySID($userSID);
             if (SJB_UserGroupManager::getUserGroupIDBySID($userInfo['user_group_sid']) == 'Employer') {
                 $username = $userInfo['CompanyName'];
             } else {
                 if (SJB_UserGroupManager::getUserGroupIDBySID($userInfo['user_group_sid']) == 'JobSeeker') {
                     $username = $userInfo['FirstName'] . ' ' . $userInfo['LastName'];
                 } else {
                     $username = $userInfo['username'];
                 }
             }
         }
         $invoice->addProperty(array('id' => 'sid', 'type' => 'string', 'value' => $invoice->getSID()));
         $invoice->addProperty(array('id' => 'username', 'type' => 'string', 'value' => $username));
         $foundInvoices[$id] = $invoice;
         $foundInvoicesInfo[$invoice->getSID()] = SJB_InvoiceManager::getInvoiceInfoBySID($invoice->getSID());
         $foundInvoicesInfo[$invoice->getSID()]['userExists'] = !empty($username) ? 1 : 0;
     }
     /****************************************************************/
     $paginator->setItemsCount($searcher->getAffectedRows());
     $form_collection = new SJB_FormCollection($foundInvoices);
     $form_collection->registerTags($tp);
     $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     $tp->assign("found_invoices", $foundInvoicesInfo);
     $tp->display($template);
 }
예제 #4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $display_form = new SJB_Form();
     $display_form->registerTags($tp);
     $errors = array();
     $criteria_saver = new SJB_ListingCriteriaSaver('MyListings');
     $listingSID = SJB_Request::getVar("listing_id");
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listingSID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     $template = SJB_Request::getVar('display_template', 'display_listing.tpl');
     if (is_null($listingSID)) {
         $errors['UNDEFINED_LISTING_ID'] = true;
     } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listingSID))) {
         $errors['WRONG_LISTING_ID_SPECIFIED'] = true;
     } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
         $errors['LISTING_IS_NOT_ACTIVE'] = true;
     } else {
         $listing->addPicturesProperty();
         if ($listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
             $errors['NOT_OWNER'] = true;
         }
         $display_form = new SJB_Form($listing);
         $display_form->registerTags($tp);
         $form_fields = $display_form->getFormFieldsInfo();
         $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid);
         // listing preview @author still
         $listingTypeSID = $listing->getListingTypeSID();
         $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSID);
         if (SJB_Request::getInstance()->page_config->uri == '/' . strtolower($listingTypeID) . '-preview/') {
             if (!empty($_SERVER['HTTP_REFERER']) && (stristr($_SERVER['HTTP_REFERER'], 'edit-' . $listingTypeID) || stristr($_SERVER['HTTP_REFERER'], 'clone-job'))) {
                 $tp->assign('referer', $_SERVER['HTTP_REFERER']);
             } else {
                 $lastPage = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
                 $lastPage = array_pop($lastPage);
                 $tp->assign('referer', SJB_System::getSystemSettings('SITE_URL') . '/add-listing/' . $listingTypeID . '/' . $lastPage['page_id'] . '/' . $listing->getSID());
             }
             $tp->assign('checkouted', SJB_ListingManager::isListingCheckOuted($listing->getSID()));
             $tp->assign('contract_id', $listing->contractID);
         }
         $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings'));
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             SJB_UploadFileManager::openFile($filename, $listingSID);
             $errors['NO_SUCH_FILE'] = true;
         }
         $prev_and_next_listing_id = $criteria_saver->getPreviousAndNextObjectID($listingSID);
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listingStructure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $comments = '';
         $comments_total = '';
         if (SJB_Settings::getSettingByName('show_comments') == '1') {
             $comments = SJB_CommentManager::getEnabledCommentsToListing($listingSID);
             $comments_total = count($comments);
         }
         $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates'));
         $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments'));
         $tp->assign('comments', $comments);
         $tp->assign('comments_total', $comments_total);
         $tp->assign('listing_id', $listingSID);
         $tp->assign('form_fields', $form_fields);
         $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields));
         $tp->filterThenAssign("listing", $listingStructure);
         $tp->assign('prev_next_ids', $prev_and_next_listing_id);
         $tp->assign('preview_listing_sid', SJB_Request::getVar('preview_listing_sid'));
         $tp->assign('listingOwner', $listingOwner);
         if (SJB_Request::getVar('action', false) == 'download_pdf_version') {
             $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, SJB_Array::getPath($listingStructure, 'type/id'));
             $formBuilder->setChargedTemplateProcessor($tp);
             $tpl = 'resume_to_pdf.tpl';
             $filename = $listingStructure['user']['FirstName'] . ' ' . $listingStructure['user']['LastName'] . '_' . $listingStructure['Title'] . '.pdf';
             try {
                 $tp->assign('myListing', 1);
                 $html = $tp->fetch($tpl);
                 $html = preg_replace('/<div[^>]*>/', '', $html);
                 $html = str_replace('</div>', '', $html);
                 SJB_HelperFunctions::html2pdf($html, $filename, str_replace('http://', '', SJB_HelperFunctions::getSiteUrl()));
                 exit;
             } catch (Exception $e) {
                 SJB_Error::writeToLog($e->getMessage());
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/my-resume-details/' . $listingSID . '/?error=TCPDF_ERROR');
             }
         } else {
             $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, SJB_Array::getPath($listingStructure, 'type/id'));
             $formBuilder->setChargedTemplateProcessor($tp);
         }
     }
     $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria();
     $tp->filterThenAssign('search_criteria', $search_criteria_structure);
     $tp->assign('errors', $errors);
     $tp->assign('myListing', true);
     $tp->display($template);
 }
예제 #5
0
 /**
  * @param $listingSID
  * @param $contractID
  * @param $productSID
  */
 public function addListing($listingSID, $contractID = false, $productSID = false)
 {
     if ($productSID != false) {
         $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
         $extraInfo['product_sid'] = (string) $extraInfo['product_sid'];
     } else {
         $contract = new SJB_Contract(array('contract_id' => $contractID));
         $extraInfo = $contract->extra_info;
     }
     $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
     $this->tp->assign("pic_limit", $numberOfPictures);
     $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
     if (!$this->listingTypeID && count($listingTypesInfo) == 1) {
         $listingTypeInfo = array_pop($listingTypesInfo);
         $this->listingTypeID = $listingTypeInfo['id'];
     }
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
     $pageSID = $this->getPageSID($pages, $listingTypeSID);
     $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listingTypeSID);
     $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
     if (($contractID || !empty($this->buttonPressedPostToProceed)) && $this->listingTypeID) {
         $formSubmitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested;
         /*
          * social plugin
          * complete listing of data from an array of social data
          * if is allowed
          */
         $aAutoFillData = array('formSubmitted' => &$formSubmitted, 'listingTypeID' => &$this->listingTypeID);
         SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
         /*
          * end of "social plugin"
          */
         $listing = new SJB_Listing($_REQUEST, $listingTypeSID, $pageSID);
         $listing->deleteProperty('featured');
         $listing->deleteProperty('priority');
         $listing->deleteProperty('status');
         $listing->deleteProperty('reject_reason');
         $listing->deleteProperty('ListingLogo');
         $access_type = $listing->getProperty('access_type');
         if ($formSubmitted) {
             if (!empty($access_type)) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true));
             }
             $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true));
         }
         $currentUser = SJB_UserManager::getCurrentUser();
         $screeningQuestionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID());
         if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screeningQuestionnaires) {
             $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
             if ($issetQuestionnairyField) {
                 $value = SJB_Request::getVar("screening_questionnaire");
                 $listingInfo = $_REQUEST;
                 $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                 $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true));
             }
         } else {
             $listing->deleteProperty('screening_questionnaire');
         }
         /*
          * social plugin
          * "synchronization"
          * if user is not registered using linkedin , delete linkedin sync property
          * also if sync is turned off in admin part
          */
         $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $this->listingTypeID, 'listing_info' => $_REQUEST);
         SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
         /*
          * end of social plugin "sync"
          */
         $listingFormAdd = new SJB_Form($listing);
         $listingFormAdd->registerTags($this->tp);
         $fieldErrors = array();
         if ($formSubmitted && ($this->formSubmittedFromPreview || $listingFormAdd->isDataValid($fieldErrors))) {
             if ($isPageLast) {
                 $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
             }
             $listing->setUserSID($currentUser->getSID());
             $listing->setProductInfo($extraInfo);
             if (empty($access_type->value)) {
                 $listing->setPropertyValue('access_type', 'everyone');
             }
             if ($currentUser->isSubuser()) {
                 $subuserInfo = $currentUser->getSubuserInfo();
                 $listing->addSubuserProperty($subuserInfo['sid']);
             }
             /**
              * >>>>> listing preview @author still
              */
             if (!empty($listingSID)) {
                 $listing->setSID($listingSID);
             }
             /*
              * <<<<< listing preview
              */
             SJB_ListingManager::saveListing($listing);
             if (!empty($this->buttonPressedPostToProceed)) {
                 SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID());
             }
             SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']);
             if ($contractID) {
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
                 $contract->incrementPostingsNumber();
                 SJB_ProductsManager::incrementPostingsNumber($contract->product_sid);
             }
             if (SJB_Session::getValue('tmp_file_storage')) {
                 foreach ($_SESSION['tmp_file_storage'] as $v) {
                     SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s", $listing->getSID(), $v['picture_saved_name']);
                     SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s", $listing->getSID(), $v['thumb_saved_name']);
                 }
                 SJB_Session::unsetValue('tmp_file_storage');
             }
             // >>> SJB-1197
             // check temporary uploaded storage for listing uploads and assign it to saved listing
             $formToken = SJB_Request::getVar('form_token');
             $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
             $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
             if (!empty($uploadedFields)) {
                 foreach ($uploadedFields as $fieldId => $fieldValue) {
                     // get field of listing
                     $isComplex = false;
                     if (strpos($fieldId, ':') !== false) {
                         $isComplex = true;
                     }
                     $tmpUploadedFileId = $fieldValue['file_id'];
                     // rename it to real listing field value
                     $newFileId = $fieldId . "_" . $listing->getSID();
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                     if ($isComplex) {
                         list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                         $parentProp = $listing->getProperty($parentField);
                         $parentValue = $parentProp->getValue();
                         // look for complex property with current $fieldID and set it to new value of property
                         if (!empty($parentValue)) {
                             foreach ($parentValue as $id => $value) {
                                 if ($id == $subField) {
                                     $parentValue[$id][$complexStep] = $newFileId;
                                 }
                             }
                             $listing->setPropertyValue($parentField, $parentValue);
                         }
                     } else {
                         $listing->setPropertyValue($fieldId, $newFileId);
                     }
                     // unset value from session temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                 }
                 //and remove token key from temporary storage
                 $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                 SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                 SJB_ListingManager::saveListing($listing);
                 $keywords = $listing->getKeywords();
                 SJB_ListingManager::updateKeywords($keywords, $listing->getSID());
             }
             // <<< SJB-1197
             if ($isPageLast && !$isPreviewListingRequested) {
                 /* delete temp preview listing sid */
                 SJB_Session::unsetValue('preview_listing_sid_for_add');
                 // Start Event
                 $listingSid = $listing->getSID();
                 SJB_Event::dispatch('listingSaved', $listingSid);
                 if ($extraInfo['featured']) {
                     SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                 }
                 if ($extraInfo['priority']) {
                     SJB_ListingManager::makePriorityBySID($listing->getSID());
                 }
                 if (!empty($this->buttonPressedPostToProceed)) {
                     $this->proceedToCheckout($currentUser->getSID(), $productSID);
                 } else {
                     if (SJB_ListingManager::activateListingBySID($listing->getSID())) {
                         SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
                     }
                     // notify administrator
                     SJB_AdminNotifications::sendAdminListingAddedLetter($listing);
                     if (isset($_REQUEST['action_add_pictures'])) {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID());
                     } else {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($this->listingTypeID) . '/?listing_id=' . $listing->getSID());
                     }
                 }
             } elseif ($isPageLast && $isPreviewListingRequested) {
                 // for listing preview
                 SJB_Session::setValue('preview_listing_sid_for_add', $listing->getSID());
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($this->listingTypeID) . '-preview/' . $listing->getSID() . '/');
             } else {
                 // listing steps (pages)
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$this->listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . "/" . $listing->getSID());
             }
         } else {
             $listing->deleteProperty('access_list');
             $listing->deleteProperty('contract_id');
             $listingFormAdd = new SJB_Form($listing);
             if ($formSubmitted) {
                 $listingFormAdd->isDataValid($fieldErrors);
             }
             $listingFormAdd->registerTags($this->tp);
             $template = isset($_REQUEST['input_template']) ? $_REQUEST['input_template'] : "input_form.tpl";
             $formFields = $listingFormAdd->getFormFieldsInfo();
             $employersList = SJB_Request::getVar('list_emp_ids', false);
             $employers = array();
             if (is_array($employersList)) {
                 foreach ($employersList as $emp) {
                     $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                     $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                 }
                 sort($employers);
             }
             $this->tp->assign('form_token', SJB_Request::getVar('form_token'));
             $this->tp->assign("account_activated", SJB_Request::getVar('account_activated', ''));
             $this->tp->assign("contract_id", $contractID);
             $this->tp->assign("listing_access_list", $employers);
             $this->tp->assign("listingTypeID", $this->listingTypeID);
             $this->tp->assign('listingTypeStructure', SJB_ListingTypeManager::createTemplateStructure(SJB_ListingTypeManager::getListingTypeInfoBySID($listing->listing_type_sid)));
             $this->tp->assign("field_errors", $fieldErrors);
             $this->tp->assign("form_fields", $formFields);
             $this->tp->assign("pages", $pages);
             $this->tp->assign("pageSID", $pageSID);
             $this->tp->assign("extraInfo", $extraInfo);
             $this->tp->assign("currentPage", SJB_PostingPagesManager::getPageInfoBySID($pageSID));
             $this->tp->assign("isPageLast", $isPageLast);
             $this->tp->assign("nextPage", SJB_PostingPagesManager::getNextPage($pageSID));
             $this->tp->assign("prevPage", SJB_PostingPagesManager::getPrevPage($pageSID));
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $this->tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($formFields)));
             /*
              * social plugin
              * only for Resume listing types
              */
             $aAutoFillData = array('tp' => &$this->tp, 'listingTypeID' => &$this->listingTypeID, 'userSID' => $currentUser->getSID());
             SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
             /*
              * social plugin
              */
             $this->tp->display($template);
         }
     }
 }
예제 #6
0
 public function execute()
 {
     $listing_id = SJB_Request::getVar('listing_id', null);
     $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id);
     $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_info['listing_type_sid']);
     if (!is_null($listing_info)) {
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             $file = SJB_UploadFileManager::openFile($filename, $listing_id);
             $errors['NO_SUCH_FILE'] = true;
         }
         if (isset($_REQUEST['Occupations']) && isset($_REQUEST['Occupations']['tree']) && !$_REQUEST['Occupations']['tree']) {
             unset($_REQUEST['Occupations']['tree']);
         }
         $listing_info = array_merge($listing_info, $_REQUEST);
         if (isset($_REQUEST['Occupations']) && isset($_REQUEST['Occupations']['tree']) && $_REQUEST['Occupations']['tree']) {
             $listing_info['Occupations'] = $_REQUEST['Occupations']['tree'];
         }
         $listing = new SJB_Listing($listing_info, $listing_info['listing_type_sid']);
         $listing->setSID($listing_id);
         $listing_edit_form = new SJB_Form($listing);
         $form_is_submitted = SJB_Request::getVar('action');
         $errors = array();
         if ($form_is_submitted) {
             $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true));
         }
         if ($form_is_submitted && $listing_edit_form->isDataValid($errors)) {
             $listingSid = $listing->getID();
             SJB_BrowseDBManager::deleteListings($listingSid);
             SJB_ListingManager::saveListing($listing);
             SJB_BrowseDBManager::addListings($listingSid);
             $formToken = SJB_Request::getVar('form_token');
             $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
             $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
             if (!empty($uploadedFields)) {
                 foreach ($uploadedFields as $fieldId => $fieldValue) {
                     // get field of listing
                     $isComplex = false;
                     if (strpos($fieldId, ':') !== false) {
                         $isComplex = true;
                     }
                     $tmpUploadedFileId = $fieldValue['file_id'];
                     // rename it to real listing field value
                     $newFileId = $fieldId . "_" . $listing->getSID();
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                     if ($isComplex) {
                         list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                         $parentProp = $listing->getProperty($parentField);
                         $parentValue = $parentProp->getValue();
                         // look for complex property with current $fieldID and set it to new value of property
                         if (!empty($parentValue)) {
                             foreach ($parentValue as $id => $value) {
                                 if ($id == $subField) {
                                     $parentValue[$id][$complexStep] = $newFileId;
                                 }
                             }
                             $listing->setPropertyValue($parentField, $parentValue);
                         }
                     } else {
                         $listing->setPropertyValue($fieldId, $newFileId);
                     }
                     // unset value from session temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                 }
                 //and remove token key from temporary storage
                 $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                 SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                 SJB_ListingManager::saveListing($listing);
             }
             SJB_Event::dispatch('listingEdited', $listingSid);
             if (SJB_Request::isAjax()) {
                 echo '<p class="green">Listing Saved</p>';
                 exit;
             }
             if ($form_is_submitted == 'save_info') {
                 $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listing_info['listing_type_sid']);
                 $listingType = $listingTypeId != 'Job' && $listingTypeId != 'Resume' ? $listingTypeId . '-listings' : $listingTypeId . 's';
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/manage-" . strtolower($listingType) . "/?restore=1");
             }
         }
         $listing->deleteProperty('access_list');
         $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id);
         $comments_total = count($comments);
         $rate = SJB_Rating::getRatingNumToListing($listing_id);
         $form_fields = $listing_edit_form->getFormFieldsInfo();
         $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing->getListingTypeSID());
         $realFormFields = array();
         foreach ($pages as $page) {
             $listingFields = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']);
             foreach ($listingFields as $fieldID => $listingField) {
                 if (isset($form_fields[$fieldID])) {
                     $realFormFields[$fieldID] = $form_fields[$fieldID];
                 }
             }
         }
         $adminFields = array();
         foreach ($form_fields as $fieldName => $field) {
             if (!isset($realFormFields[$fieldName])) {
                 $adminFields[$fieldName] = $field;
             }
         }
         $realFormFields = array_merge($adminFields, $realFormFields);
         $tp = SJB_System::getTemplateProcessor();
         $listing_edit_form->registerTags($tp);
         $extraInfo = $listing_info['product_info'];
         if ($extraInfo) {
             $extraInfo = unserialize($extraInfo);
             $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
             $tp->assign("listing_duration", $extraInfo['listing_duration']);
             $tp->assign("pic_limit", $numberOfPictures);
         }
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
         if (!isset($listing_structure['access_type'])) {
             $listing_structure['access_type'] = 'everyone';
         }
         $listing_access_list = SJB_ListingManager::getListingAccessList($listing_id, $listing->getPropertyValue('access_type'));
         $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
         $tp->assign('form_fields', $realFormFields);
         $tp->assign('listing', $listing_structure);
         $tp->assign('errors', $errors);
         $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
         $tp->assign('listing_access_list', $listing_access_list);
         $tp->assign('comments_total', $comments_total);
         $tp->assign('rate', $rate);
         $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID()));
         SJB_System::setGlobalTemplateVariable('wikiExtraParam', $listingTypeInfo['id']);
         $tp->display('edit_listing.tpl');
     }
 }
예제 #7
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;
     }
 }
예제 #8
0
 public function execute()
 {
     $listingTypeSid = SJB_Request::getVar('listing_type_sid', false);
     $template_processor = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['restore']) && isset($listingSearcher['criteria_values']['listing_type_sid'])) {
         $listingSearcher = SJB_Session::getValue('ListingSearcher', null);
         $listingTypeSid = $listingSearcher['criteria_values']['listing_type_sid']['equal'];
     }
     $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSid);
     $template_processor->assign('showApprovalStatusField', $listingTypeInfo['waitApprove']);
     $template_processor->assign('listingsType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
     $show_search_form = true;
     if (empty($_REQUEST['action']) && empty($_REQUEST['restore'])) {
         $show_search_form = false;
     }
     $template_processor->assign('show_search_form', $show_search_form);
     /**************** S E A R C H   F O R M ****************/
     $listing = SJB_ObjectMother::createListing(array(), $listingTypeSid);
     $id_alias_info = $listing->addIDProperty();
     $username_alias_info = $listing->addUsernameProperty();
     $productAliasInfo = $listing->addProductProperty($listingTypeSid);
     $listing->addCompanyNameProperty();
     $listing->addActivationDateProperty();
     $listing->addExpirationDateProperty();
     $listing->addActiveProperty();
     $listing->addKeywordsProperty();
     $listing->addDataSourceProperty();
     $listing->addPriorityProperty();
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias($username_alias_info);
     $aliases->addAlias($id_alias_info);
     $aliases->addAlias($productAliasInfo);
     $search_form_builder = new SJB_SearchFormBuilder($listing);
     $criteria_saver = SJB_ObjectMother::createListingCriteriaSaver();
     $keywords = NULL;
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
         $criteria = $criteria_saver->getCriteria();
         $listingSid = SJB_Array::getPath($criteria, 'sid') ? $criteria['sid']['equal'] : '';
         $keywords = SJB_Array::getPath($criteria, 'keywords') ? $criteria['keywords']['like'] : $listingSid;
     }
     if ($listingTypeSid) {
         $_REQUEST['listing_type_sid'] = array('equal' => $listingTypeSid);
     }
     $template_processor->assign('companyName', isset($_REQUEST['company_name']['like']) ? $_REQUEST['company_name']['like'] : '');
     $template_processor->assign('idKeyword', isset($_REQUEST['idKeyword']) ? $_REQUEST['idKeyword'] : $keywords);
     $this->prepareRequestedCriteria();
     $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST, $listing);
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($template_processor);
     $template_processor->display("manage_listings.tpl");
     /************* S E A R C H   F O R M   R E S U L T S *************/
     $paginator = new SJB_ListingPagination($listingTypeInfo);
     $searcher = SJB_ObjectMother::createListingSearcher();
     $inner_join = array();
     if (SJB_Request::getVar('action', '') == 'search' || isset($_REQUEST['restore'])) {
         if (!isset($_REQUEST['restore'])) {
             $criteria_saver->resetSearchResultsDisplay();
         }
         if (isset($_REQUEST['company_name']['like']) && $_REQUEST['company_name']['like'] != '') {
             $inner_join = array('users' => array('join_field' => 'sid', 'join_field2' => 'user_sid', 'main_table' => 'listings', 'join' => 'INNER JOIN'));
         }
         $foundListingsSIDs = $searcher->getObjectsSIDsByCriteria($criteria, $aliases, array(), $inner_join);
         //get found listing sids
         if (empty($foundListingsSIDs) && $paginator->currentPage != 1) {
             if ($listingTypeInfo['id'] == 'Job' || $listingTypeInfo['id'] == 'Resume') {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeInfo['id']) . 's/?page=1&restore=1');
             } else {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeInfo['id']) . '-listings/?page=1&restore=1');
             }
         }
         $criteria_saver->setSessionForListingsPerPage($paginator->itemsPerPage);
         $criteria_saver->setSessionForCurrentPage($paginator->currentPage);
         $criteria_saver->setSessionForCriteria($_REQUEST);
         $orderInfo = array('sorting_field' => $paginator->sortingField, 'sorting_order' => $paginator->sortingOrder);
         $criteria_saver->setSessionForOrderInfo($orderInfo);
     } else {
         $criteria_saver->resetSearchResultsDisplay();
         return;
     }
     $criteria_saver->setSessionForObjectSIDs($foundListingsSIDs);
     $listing_search_structure = $criteria_saver->createTemplateStructureForSearch();
     /**************** S O R T I N G *****************/
     $empty_listing = SJB_ObjectMother::createListing(array(), $listingTypeSid);
     $empty_listing->addPicturesProperty();
     $empty_listing->addIDProperty();
     $empty_listing->addListingTypeIDProperty();
     $empty_listing->addActivationDateProperty();
     $empty_listing->addExpirationDateProperty();
     $empty_listing->addUsernameProperty();
     $empty_listing->addPicturesProperty();
     $empty_listing->addNumberOfViewsProperty();
     $empty_listing->addActiveProperty();
     $empty_listing->addKeywordsProperty();
     $empty_listing->addDataSourceProperty();
     $listing->addRejectReasonProperty();
     if ($empty_listing->propertyIsSet($listing_search_structure['sorting_field']) && !empty($foundListingsSIDs)) {
         $sorting_field = $listing_search_structure['sorting_field'];
         $sorting_order = $listing_search_structure['sorting_order'];
         switch ($sorting_field) {
             case 'username':
                 $ids = join(", ", $foundListingsSIDs);
                 $sql = "\tSELECT\t\tlistings.*\n\t\t\t\t\t\tFROM \t\tlistings\n\t\t\t\t\t\tLEFT JOIN\tusers on listings.user_sid = users.sid\n\t\t\t\t\t\tWHERE \t\tlistings.sid IN ({$ids})\n\t\t\t\t\t\tORDER BY users.username {$sorting_order}";
                 $listings_info = SJB_DB::query($sql);
                 break;
             case 'listing_type':
                 $ids = join(", ", $foundListingsSIDs);
                 $sql = "\tSELECT\t\tlistings.*\n\t\t\t\t\t\tFROM \t\tlistings\n\t\t\t\t\t\tLEFT JOIN\tlisting_types on listings.listing_type_sid = listing_types.sid\n\t\t\t\t\t\tWHERE \t\tlistings.sid IN ({$ids})\n\t\t\t\t\t\tORDER BY listing_types.id {$sorting_order}";
                 $listings_info = SJB_DB::query($sql);
                 break;
             case 'id':
                 $ids = join(", ", $foundListingsSIDs);
                 $sql = "\tSELECT\t\tlistings.*\n\t\t\t\t\t\tFROM \t\tlistings\n\t\t\t\t\t\tWHERE\t\tlistings.sid IN ({$ids})\n\t\t\t\t\t\tORDER BY sid {$sorting_order}";
                 $listings_info = SJB_DB::query($sql);
                 break;
             default:
                 $property = $empty_listing->getProperty($sorting_field);
                 $listing_request_creator = new SJB_ListingRequestCreator($foundListingsSIDs, array('property' => $property, 'sorting_order' => $sorting_order));
                 $listings_info = SJB_DB::query($listing_request_creator->getRequest());
                 break;
         }
         $listings_sids = array();
         foreach ($listings_info as $listing_info) {
             $listings_sids[$listing_info['sid']] = $listing_info['sid'];
         }
         $sortedFoundListingsSIDs = array_keys($listings_sids);
         $criteria_saver->setSessionForObjectSIDs($sortedFoundListingsSIDs);
     } else {
         $sortedFoundListingsSIDs = $foundListingsSIDs;
         $criteria_saver->setSessionForObjectSIDs($foundListingsSIDs);
     }
     /**************** P A G I N G *****************/
     $sortedFoundListingsSIDsByPages = array_chunk($sortedFoundListingsSIDs, $paginator->itemsPerPage, true);
     $paginator->setItemsCount(count($sortedFoundListingsSIDs));
     /************* S T R U C T U R E **************/
     $listings_structure = array();
     if (isset($sortedFoundListingsSIDsByPages[$paginator->currentPage - 1])) {
         foreach ($sortedFoundListingsSIDsByPages[$paginator->currentPage - 1] as $sid) {
             $listing = SJB_ListingManager::getObjectBySID($sid);
             $listing->addPicturesProperty();
             $listings_structure[$listing->getID()] = SJB_ListingManager::createTemplateStructureForListing($listing);
         }
     }
     /*************** D I S P L A Y ****************/
     $template_processor->assign("search_criteria", $criteria_saver->createTemplateStructureForCriteria());
     $template_processor->assign('paginationInfo', $paginator->getPaginationInfo());
     $template_processor->assign('listings', $listings_structure);
     $template_processor->display('display_results.tpl');
 }
예제 #9
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $registration_form_template = 'registration_form.tpl';
     if (SJB_Authorization::isUserLoggedIn()) {
         $tp->display('already_logged_in.tpl');
         return;
     }
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         if (empty($user_group_sid)) {
             $errors['NO_SUCH_USER_GROUP_IN_THE_SYSTEM'] = 1;
         }
     }
     $this->setSessionValueForRedirectAfterRegister();
     if (!is_null($user_group_id) && empty($errors)) {
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         if (SJB_Request::isAjax() || 'true' == SJB_Request::getVar('isajaxrequest')) {
             $field = SJB_Request::getVar('type');
             if ('email' == $field) {
                 $user->getProperty($field)->type->disableEmailConfirmation();
             }
             echo $user->getProperty($field)->isValid();
             exit;
         }
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $form_submitted = SJB_Request::getVar('action', false) == 'register';
         if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) {
             $user->prepareRegistrationFields();
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) {
             $email = $user->getPropertyValue('email');
             if (is_array($email)) {
                 $email = $email['original'];
             }
             $user->setPropertyValue('username', $email);
         }
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             $user->deleteProperty('captcha');
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID());
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             // >>> SJB-1197
             // needs to check session for ajax-uploaded files, and set it to user profile
             $formToken = SJB_Request::getVar('form_token');
             $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
             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}");
                     }
                     // save user with new values
                     SJB_UserManager::saveUser($user);
                     // clean temporary storage
                     $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
                     // CLEAR TEMPORARY SESSION STORAGE
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
             }
             // <<< SJB-1197
             // notifying administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $fromAnonymousShoppingCart = SJB_Session::getValue('fromAnonymousShoppingCart');
                 SJB_Session::unsetValue('fromAnonymousShoppingCart');
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID(), $fromAnonymousShoppingCart ? true : false);
                 if ($isSent) {
                     $registration_form_template = 'registration_confirm.tpl';
                 } else {
                     SJB_FlashMessages::getInstance()->addWarning('ERROR_SEND_ACTIVATION_EMAIL');
                     $registration_form_template = 'registration_failed_to_send_activation_email.tpl';
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $registration_form_template = 'registration_pending.tpl';
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     if (!SJB_SocialPlugin::getProfileSocialID($user->getSID())) {
                         SJB_Notifications::sendUserWelcomeLetter($user->getSID());
                     }
                     SJB_Authorization::login($user->getUserName(), $_REQUEST['password']['original'], false, $errors);
                     $proceedToPosting = SJB_Session::getValue('proceed_to_posting');
                     if ($proceedToPosting) {
                         $redirectUrl = SJB_HelperFunctions::getSiteUrl() . '/add-listing/?listing_type_id=' . SJB_Session::getValue('listing_type_id') . '&proceed_to_posting=' . $proceedToPosting . '&productSID=' . SJB_Session::getValue('productSID');
                     } else {
                         $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                         $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     }
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             $registration_form->registerTags($tp);
             $registration_form_template = 'registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             // define default template with ajax checking
             $registration_form->setDefaultTemplateByFieldName('email', 'email_ajaxchecking.tpl');
             $registration_form->setDefaultTemplateByFieldName('username', 'unique_string.tpl');
             // use specific template for user profile video
             $registration_form->setDefaultTemplateByFieldName('video', 'video_profile.tpl');
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         }
     } else {
         $registration_form_template = 'registration_choose_user_group.tpl';
         $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo();
         $tp->assign('user_groups_info', $user_groups_info);
     }
     $tp->assign('userTree', true);
     $tp->assign('errors', $errors);
     $tp->display($registration_form_template);
 }
예제 #10
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $current_user = SJB_UserManager::getCurrentUser();
     $currentUserInfo = SJB_UserManager::getCurrentUserInfo();
     $tp->assign('current_user', $currentUserInfo);
     $errors = array();
     $error = '';
     $listing_id = SJB_Request::getVar('listing_id', null, 'default', 'int');
     if (SJB_UserGroupManager::getUserGroupIDBySID($current_user->user_group_sid) == 'Employer') {
         $template = SJB_Request::getVar('input_template', 'copy_listing.tpl');
     } else {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-listings/Job/');
     }
     //getting $tmp_listing_id from request
     $tmp_listing_id_from_request = SJB_Request::getVar('tmp_listing_id', false, 'default', 'int');
     $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id);
     $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing_info['listing_type_sid']);
     if ($productsInfo = $this->canCurrentUserAddListing($error, $listing_type_id)) {
         $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_info['listing_type_sid']);
         if (!empty($tmp_listing_id_from_request)) {
             $tmp_listing_sid = $tmp_listing_id_from_request;
         } elseif (!$tmp_listing_id_from_request) {
             $tmp_listing_sid = time();
         }
         $gallery = new SJB_ListingGallery();
         $gallery->setListingSID($listing_info['sid']);
         $pictures_info = $gallery->getPicturesInfo();
         $gallery->setListingSID($tmp_listing_sid);
         $pictures_info_new = $gallery->getPicturesInfo();
         //reuploading pictures
         if (!$pictures_info_new) {
             foreach ($pictures_info as $v) {
                 if (!$gallery->uploadImage($v['picture_url'], $v['caption'])) {
                     $field_errors['Picture'] = $gallery->getError();
                 }
             }
         }
         $contractID = SJB_Request::getVar('contract_id', false, 'default', 'int');
         if ($contractID) {
             $contract = new SJB_Contract(array('contract_id' => $contractID));
         } elseif (count($productsInfo) == 1) {
             $productInfo = array_pop($productsInfo);
             $contractID = $productInfo['contract_id'];
             $contract = new SJB_Contract(array('contract_id' => $contractID));
         } else {
             $tp->assign('listing_id', $listing_id);
             $tp->assign("products_info", $productsInfo);
             $tp->assign("listing_type_id", $listing_type_id);
             $tp->display("listing_product_choice.tpl");
         }
         if ($contractID) {
             $tp->assign('tmp_listing_id', $tmp_listing_sid);
             $extraInfo = $contract->extra_info;
             $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
             $tp->assign("pic_limit", $numberOfPictures);
             $tp->assign('contractID', $contractID);
             if ($listing_info['user_sid'] != SJB_UserManager::getCurrentUserSID()) {
                 $errors['NOT_OWNER_OF_LISTING'] = $listing_id;
             } elseif (!is_null($listing_info)) {
                 $listing_info = array_merge($listing_info, $_REQUEST);
                 $listing = new SJB_Listing($listing_info, $listing_info['listing_type_sid']);
                 $listing->deleteProperty('featured');
                 $listing->deleteProperty('priority');
                 $listing->deleteProperty('status');
                 $listing->deleteProperty('reject_reason');
                 $listing->setSID($listing_id);
                 $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->getSID());
                 if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                     $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
                     if ($issetQuestionnairyField) {
                         $value = SJB_Request::getVar('screening_questionnaire');
                         $value = $value ? $value : isset($listing_info['screening_questionnaire']) ? $listing_info['screening_questionnaire'] : '';
                         $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($current_user->getSID()), 'is_system' => true));
                     }
                 } else {
                     $listing->deleteProperty('screening_questionnaire');
                 }
                 $listing_edit_form = new SJB_Form($listing);
                 $listing_edit_form->registerTags($tp);
                 $extraInfo = $listing_info['product_info'];
                 if ($extraInfo) {
                     $extraInfo = unserialize($extraInfo);
                     $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                     $tp->assign("pic_limit", $numberOfPictures);
                 }
                 $form_is_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'save_info' || isset($_REQUEST['action']) && $_REQUEST['action'] == 'add';
                 $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true));
                 $delete = SJB_Request::getVar('action', '') == 'delete';
                 $field_errors = null;
                 if ($delete && isset($_REQUEST['field_id'])) {
                     $field_id = $_REQUEST['field_id'];
                     $listing->details->properties[$field_id]->type->property_info['value'] = null;
                 } elseif ($form_is_submitted && $listing_edit_form->isDataValid($field_errors)) {
                     $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                     $listing->setUserSID($current_user->getSID());
                     $extraInfo = $contract->extra_info;
                     $listing->setProductInfo($extraInfo);
                     $listing->sid = null;
                     if (!empty($listing_info['subuser_sid'])) {
                         $listing->addSubuserProperty($listing_info['subuser_sid']);
                     }
                     $listingSidsForCopy = array('filesFrom' => $listing_id, 'picturesFrom' => $tmp_listing_sid);
                     SJB_ListingManager::saveListing($listing, $listingSidsForCopy);
                     // >>> SJB-1197
                     // SET VALUES FROM TEMPORARY SESSION STORAGE
                     $formToken = SJB_Request::getVar('form_token');
                     $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $tempFieldsData = SJB_Array::getPath($sessionFileStorage, $formToken);
                     if (is_array($tempFieldsData)) {
                         foreach ($tempFieldsData as $fieldId => $fieldData) {
                             $isComplex = false;
                             if (strpos($fieldId, ':') !== false) {
                                 $isComplex = true;
                             }
                             $tmpUploadedFileId = $fieldData['file_id'];
                             // rename it to real listing field value
                             $newFileId = $fieldId . "_" . $listing->getSID();
                             SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                             if ($isComplex) {
                                 list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                                 $parentProp = $listing->getProperty($parentField);
                                 $parentValue = $parentProp->getValue();
                                 // look for complex property with current $fieldID and set it to new value of property
                                 if (!empty($parentValue)) {
                                     foreach ($parentValue as $id => $value) {
                                         if ($id == $subField) {
                                             $parentValue[$id][$complexStep] = $newFileId;
                                         }
                                     }
                                     $listing->setPropertyValue($parentField, $parentValue);
                                 }
                             } else {
                                 $listing->setPropertyValue($fieldId, $newFileId);
                             }
                             // clean temporary field storage
                             $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                         }
                         //and remove token key from temporary storage
                         $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}");
                         // clear temporary data in session storage
                         SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                         $listingSidsForCopy = array('filesFrom' => $listing_id, 'picturesFrom' => $listing_id);
                         SJB_ListingManager::saveListing($listing, $listingSidsForCopy);
                     }
                     // <<< SJB-1197
                     SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']);
                     $contract->incrementPostingsNumber();
                     SJB_ProductsManager::incrementPostingsNumber($contract->product_sid);
                     // is listing featured by default
                     if ($extraInfo['featured']) {
                         SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                     }
                     if ($extraInfo['priority']) {
                         SJB_ListingManager::makePriorityBySID($listing->getSID());
                     }
                     SJB_ListingManager::activateListingBySID($listing->getSID());
                     SJB_AdminNotifications::sendAdminListingAddedLetter($listing);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listing_type_id) . '/?listing_id=' . $listing->getSID());
                 } elseif ($form_is_submitted) {
                     $field_id = 'video';
                     if (!isset($_REQUEST['video_hidden']) && $listing->getPropertyValue($field_id)) {
                         $listing->details->properties[$field_id]->type->property_info['value'] = null;
                     }
                 }
                 $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
                 $form_fields = $listing_edit_form->getFormFieldsInfo();
                 $listing_fields_by_page = array();
                 $countPages = count($pages);
                 $i = 1;
                 foreach ($pages as $page) {
                     $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']);
                     if ($i == $countPages && isset($form_fields['screening_questionnaire'])) {
                         $listing_fields_by_page[$page['page_name']]['screening_questionnaire'] = $form_fields['screening_questionnaire'];
                     }
                     foreach (array_keys($listing_fields_by_page[$page['page_name']]) as $field) {
                         if (!$listing->propertyIsSet($field)) {
                             unset($listing_fields_by_page[$page['page_name']][$field]);
                         }
                     }
                     $i++;
                 }
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
                 $contract_id = $listing_info['contract_id'];
                 $contract = new SJB_Contract(array('contract_id' => $contract_id));
                 $tp->assign('contract_id', $contract_id);
                 $tp->assign('contract', $contract->extra_info);
                 $tp->assign('countPages', count($listing_fields_by_page));
                 $tp->assign('copy_listing', 1);
                 $tp->assign('tmp_listing_id', $tmp_listing_sid);
                 $tp->assign('listing_id', $listing_id);
                 $tp->assign('contractID', $contractID);
                 $tp->assign('listing', $listing_structure);
                 $tp->assign('pages', $listing_fields_by_page);
                 $tp->assign('field_errors', $field_errors);
             }
             $tp->assign('errors', $errors);
             $tp->display($template);
         }
     } else {
         $listing_type_id = isset($listing_info['listing_type_sid']) ? $listing_info['listing_type_sid'] : false;
         if ($error == 'NO_CONTRACT') {
             if ($_GET) {
                 $getParam = '?';
                 foreach ($_GET as $key => $val) {
                     $getParam .= $key . '=' . $val . '&';
                 }
                 $getParam = substr($getParam, 0, -1);
             }
             $page = base64_encode(SJB_System::getURI() . $getParam);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?page=' . $page);
         }
         $tp->assign('clone_job', 1);
         $tp->assign('listing_type_id', $listing_type_id);
         $tp->assign('error', $error);
         $tp->display('add_listing_error.tpl');
     }
 }
예제 #11
0
 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') {
                 $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8'));
             }
             if (!empty($properties)) {
                 $user->details->properties = $properties;
             }
         }
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) {
             $user->deleteProperty("username");
         }
         $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
         $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($user_info['user_group_sid']);
         $allowedListingTypes = array();
         foreach ($products as $product) {
             if (!empty($product['listing_type_sid']) && empty($allowedListingTypes[$product['listing_type_sid']])) {
                 foreach ($listingTypes as $listingType) {
                     if ($product['listing_type_sid'] == $listingType['sid']) {
                         $allowedListingTypes[$product['listing_type_sid']] = $listingType;
                     }
                 }
             }
         }
         $edit_user_form = SJB_ObjectMother::createForm($user);
         $edit_user_form->registerTags($tp);
         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
         if (SJB_UserManager::checkBan($errors, $user_info['ip'])) {
             $user_info['ip_is_banned'] = 1;
         }
         $tp->assign("form_fields", $edit_user_form->getFormFieldsInfo());
         $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
         $tp->assign("errors", $errors);
         $tp->assign("listingTypes", $allowedListingTypes);
         $tp->assign("user_info", $user_info);
         $tp->assign("user_group_info", $userGroupInfo);
         $tp->assign('userTree', true);
         $tp->assign("parent_name", $parent_name);
         $tp->assign("restore", preg_match('/manage-(jobseekers)|(employers)|([a-z0-9\\_]-users)/', SJB_Request::getVar('HTTP_REFERER', '', 'SERVER')));
         SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']);
         $tp->display("edit_user.tpl");
     }
 }
예제 #12
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $display_form = new SJB_Form();
     $display_form->registerTags($tp);
     $current_user = SJB_UserManager::getCurrentUser();
     $errors = array();
     $template = SJB_Request::getVar('display_template', 'display_listing.tpl');
     $tcpdfError = SJB_Request::getVar('error', false);
     $action = substr($template, 0, -4);
     $listing_id = SJB_Request::getVar("listing_id");
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listing_id = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     if (is_null($listing_id) && SJB_FormBuilderManager::getIfBuilderModeIsSet()) {
         $listing_type_id = SJB_Request::getVar('listing_type_id');
         $listing_id = SJB_ListingManager::getListingIDByListingTypeID($listing_type_id);
     }
     if (is_null($listing_id)) {
         $errors['UNDEFINED_LISTING_ID'] = true;
     } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listing_id)) || !SJB_ListingManager::isListingAccessableByUser($listing_id, SJB_UserManager::getCurrentUserSID())) {
         $errors['WRONG_LISTING_ID_SPECIFIED'] = true;
     } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
         $errors['LISTING_IS_NOT_ACTIVE'] = true;
     } elseif (($listingStatus = SJB_ListingManager::getListingApprovalStatusBySID($listing_id)) != 'approved' && SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing->listing_type_sid) == 1 && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) {
         $errors['LISTING_IS_NOT_APPROVED'] = true;
     } elseif (SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Resume' && ($template == 'display_job.tpl' or SJB_System::getURI() == '/print-job/') || SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Job' && ($template == 'display_resume.tpl' or SJB_System::getURI() == '/print-resume/')) {
         $errors['WRONG_DISPLAY_TEMPLATE'] = true;
     } else {
         $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid);
         if (SJB_System::getURI() == '/print-listing/') {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/print-' . strtolower($listing_type_id) . '/?listing_id=' . $listing_id);
             exit;
         }
         $listing->addPicturesProperty();
         $display_form = new SJB_Form($listing);
         $display_form->registerTags($tp);
         $form_fields = $display_form->getFormFieldsInfo();
         $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid);
         if ($action !== 'print_listing') {
             SJB_ListingManager::incrementViewsCounterForListing($listing_id, $listing);
         }
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings'));
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             $file = SJB_UploadFileManager::openFile($filename, $listing_id);
             $errors['NO_SUCH_FILE'] = true;
         }
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure['METADATA']), "form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $comments = array();
         $comments_total = '';
         if (SJB_Settings::getSettingByName('show_comments') == '1') {
             $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id);
             $comments_total = count($comments);
         }
         $searchId = SJB_Request::getVar("searchId", "");
         $page = SJB_Request::getVar("page", "");
         $criteria_saver = new SJB_ListingCriteriaSaver($searchId);
         $searchCriteria = $criteria_saver->getCriteria();
         $keywordsHighlight = '';
         if (isset($searchCriteria['keywords']) && SJB_System::getSettingByName('use_highlight_for_keywords')) {
             foreach ($searchCriteria['keywords'] as $type => $keywords) {
                 switch ($type) {
                     case 'like':
                     case 'exact_phrase':
                         $keywordsHighlight = json_encode($keywords);
                         break;
                     case 'all_words':
                     case 'any_words':
                         $keywordsHighlight = json_encode(explode(' ', $keywords));
                         break;
                     case 'boolean':
                         $keywordsHighlight = json_encode(SJB_BooleanEvaluator::parse($keywords, true));
                         break;
                 }
             }
         }
         $prevNextIds = $criteria_saver->getPreviousAndNextObjectID($listing_id);
         $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria();
         //permissions contact info
         $acl = SJB_Acl::getInstance();
         $permission = 'view_' . $listing_type_id . '_contact_info';
         $allowViewContactInfo = false;
         if (SJB_UserManager::isUserLoggedIn()) {
             if (SJB_ContractManager::isPageViewed($current_user->getSID(), $permission, $listing_id) || $acl->isAllowed($permission) && in_array($acl->getPermissionParams($permission), array('', '0'))) {
                 $allowViewContactInfo = true;
             } elseif ($acl->isAllowed($permission)) {
                 $viewContactInfo['count_views'] = 0;
                 $contractIDs = $current_user->getContractID();
                 $numberOfContactViewed = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), $contractIDs, $permission);
                 foreach ($contractIDs as $contractID) {
                     if ($acl->getPermissionParams($permission, $contractID, 'contract')) {
                         $params = $acl->getPermissionParams($permission, $contractID, 'contract');
                         $viewsLeft = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), array($contractID), $permission);
                         if (isset($viewContactInfo['count_views']) && is_numeric($params)) {
                             $viewContactInfo['count_views'] += $params;
                             if ($params > $viewsLeft) {
                                 $viewContactInfo['contract_id'] = $contractID;
                             }
                         }
                     }
                 }
                 if ($viewContactInfo && $viewContactInfo['count_views'] > $numberOfContactViewed) {
                     $allowViewContactInfo = true;
                     SJB_ContractManager::addViewPage($current_user->getSID(), $permission, $listing_id, $viewContactInfo['contract_id'], $listing->getListingTypeSID());
                 }
             }
             $user_group_id = SJB_UserGroupManager::getUserGroupIDBySID($current_user->getUserGroupSID());
             if ($allowViewContactInfo && $user_group_id == 'JobSeeker' && $listing_type_id == 'Job') {
                 SJB_UserManager::saveRecentlyViewedListings($current_user->getSID(), $listing_id);
             }
         } elseif ($acl->isAllowed($permission)) {
             $allowViewContactInfo = true;
         }
         $tp->assign("keywordsHighlight", $keywordsHighlight);
         $tp->assign('allowViewContactInfo', $allowViewContactInfo);
         $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates'));
         $tp->assign("isApplied", SJB_Applications::isApplied($listing_id, SJB_UserManager::getCurrentUserSID()));
         $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates'));
         $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments'));
         $tp->assign('comments', $comments);
         $tp->assign('comments_total', $comments_total);
         $tp->assign('listing_id', $listing_id);
         $tp->assign("form_fields", $form_fields);
         $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields));
         $tp->assign('uri', base64_encode(SJB_Navigator::getURIThis()));
         $tp->assign('listingOwner', $listingOwner);
         $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $criteria_saver->criteria);
         // SJB-1197: ajax autoupload.
         // Fix to view video from temporary uploaded storage.
         $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
         // NEED TO CHECK FOR COMPLEX PARENT AND COMPLEX STEP PARAMETERS!
         $complexParent = SJB_Request::getVar('complexParent');
         $complexStep = SJB_Request::getVar('complexEnum');
         $fieldId = SJB_Request::getVar('field_id');
         $isComplex = false;
         if ($complexParent && $complexStep) {
             $fieldId = $complexParent . ":" . $fieldId . ":" . $complexStep;
             $isComplex = true;
         }
         $tempFileValue = SJB_Array::getPath($sessionFilesStorage, "listings/{$listing_id}/{$fieldId}");
         if ($isComplex) {
             $uploadFileManager = new SJB_UploadFileManager();
             $fileLink = $uploadFileManager->getUploadedFileLink($tempFileValue['file_id']);
             $tp->assign('videoFileLink', $fileLink);
         } else {
             if (!empty($tempFileValue)) {
                 $fileUniqueId = isset($tempFileValue['file_id']) ? $tempFileValue['file_id'] : '';
                 if (!empty($fileUniqueId)) {
                     $upload_manager = new SJB_UploadFileManager();
                     // file structure for videoplayer
                     $fileInfo = array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId);
                     $listing_structure[$fieldId] = $fileInfo;
                 }
             }
         }
         // SJB-1197
         // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION
         $zipCode = '';
         if (!empty($listing_structure['Location']['ZipCode'])) {
             $zipCode = $listing_structure['Location']['ZipCode'];
         }
         // get 'latitude' and 'longitude' from zipCode field, if it not set
         $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : '';
         $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : '';
         if (!empty($zipCode) && empty($latitude) && empty($longitude)) {
             $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode);
             if ($result) {
                 $listing_structure['latitude'] = $result[0]['latitude'];
                 $listing_structure['longitude'] = $result[0]['longitude'];
             }
         } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) {
             $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country'];
             $address = urlencode($address);
             $cache = SJB_Cache::getInstance();
             $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']);
             $hash = md5('google_map' . serialize($parameters));
             $data = $cache->load($hash);
             $geoCod = '';
             if (!$data) {
                 try {
                     $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false");
                     $geoCod = json_decode($geoCod);
                     if ($geoCod->status == 'OK') {
                         $cache->save($geoCod, $hash);
                     }
                 } catch (Exception $e) {
                     $backtrace = SJB_Logger::getBackTrace();
                     SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                 }
             } else {
                 $geoCod = $data;
             }
             try {
                 if (!is_object($geoCod)) {
                     throw new Exception("Map object nave not been Created");
                 }
                 if ($geoCod->status !== 'OK') {
                     throw new Exception("Status is not OK");
                 }
                 $location = $geoCod->results[0]->geometry->location;
                 $listing_structure['latitude'] = $location->lat;
                 $listing_structure['longitude'] = $location->lng;
             } catch (Exception $e) {
                 $backtrace = SJB_Logger::getBackTrace();
                 SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
             }
         }
         if (SJB_Request::getVar('view')) {
             $tp->assign('listings', array($listing_structure));
         }
         $tp->filterThenAssign("listing", $listing_structure);
         $tp->assign("prev_next_ids", $prevNextIds);
         $tp->assign("searchId", $searchId);
         $tp->assign("page", $page);
         $tp->filterThenAssign("search_criteria", $search_criteria_structure);
         $tp->filterThenAssign("search_uri", $criteria_saver->getUri());
         if ($field_id = SJB_Request::getVar('field_id')) {
             // SJB-825
             $complexEnum = SJB_Request::getVar('complexEnum', null, 'GET');
             $complexFieldID = SJB_Request::getVar('complexParent', null, 'GET');
             if (!is_null($complexEnum) && !is_null($complexFieldID)) {
                 $videoFileID = $complexFieldID . ':' . $field_id . ':' . $complexEnum . '_' . $listing_id;
                 $videoFileLink = SJB_UploadFileManager::getUploadedFileLink($videoFileID);
                 if ($videoFileLink) {
                     $tp->assign('videoFileLink', $videoFileLink);
                 }
             }
             // SJB-825
             $tp->assign('field_id', $field_id);
         } else {
             if (SJB_Request::getVar('action', false) == 'download_pdf_version') {
                 $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, $listing_type_id);
                 $formBuilder->setChargedTemplateProcessor($tp);
                 $tpl = 'resume_to_pdf.tpl';
                 if ($listing_structure['anonymous'] == '1') {
                     $filename = 'Anonymous User_' . $listing_structure['Title'] . '.pdf';
                 } else {
                     $filename = $listing_structure['user']['FirstName'] . ' ' . $listing_structure['user']['LastName'] . '_' . $listing_structure['Title'] . '.pdf';
                 }
                 try {
                     $html = $tp->fetch($tpl);
                     $html = preg_replace('/<div[^>]*>/', '', $html);
                     $html = str_replace('</div>', '', $html);
                     SJB_HelperFunctions::html2pdf($html, $filename, str_replace('http://', '', SJB_HelperFunctions::getSiteUrl()));
                     exit;
                 } catch (Exception $e) {
                     SJB_Error::writeToLog($e->getMessage());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/display-resume/' . $listing_id . '/?error=TCPDF_ERROR');
                 }
             } else {
                 $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, $listing_type_id);
                 $formBuilder->setChargedTemplateProcessor($tp);
             }
         }
     }
     if ($errors) {
         foreach ($errors as $k => $v) {
             switch ($k) {
                 case 'TCPDF_ERROR':
                 case 'UNDEFINED_LISTING_ID':
                 case 'WRONG_LISTING_ID_SPECIFIED':
                 case 'LISTING_IS_NOT_ACTIVE':
                 case 'LISTING_IS_NOT_APPROVED':
                     $header = $_SERVER['SERVER_PROTOCOL'] . ' 404  Not Found';
                     $header_status = "Status: 404  Not Found";
                     header($header_status);
                     header($header);
                     SJB_System::setGlobalTemplateVariable('page_not_found', true);
                     break;
             }
         }
     }
     $tp->assign('errors', $errors);
     $tp->assign('tcpdfError', $tcpdfError);
     $tp->display($template);
 }
예제 #13
0
    public static function getMimeTypeByFilename($filename, $id)
    {
        $mime_type = false;
        $listing = SJB_ListingManager::getObjectBySID($id);
        $complexPropertyName = SJB_Request::getVar('complex_field', '');
        // check for new listing (add-listing action during we do not have real listing ID)
        if (strlen($id) == strlen(time())) {
            // look for listing ID in temporary storage
            if (empty($complexPropertyName)) {
                // simple field file
                $fieldName = SJB_Request::getVar('field_id', '');
                if (empty($fieldName)) {
                    return false;
                }
            } else {
                // complex field file
                $fieldName = $complexPropertyName;
            }
            $tmpFileStorage = SJB_Session::getValue('tmp_uploads_storage');
            $tmpFileId = SJB_Array::getPath($tmpFileStorage, "listings/{$id}/{$fieldName}/file_id");
            if (!empty($tmpFileId)) {
                $mime_type = SJB_DB::query("SELECT `up`.`mime_type`, `up`.`sid`, `up`.`id` FROM `uploaded_files` `up`\n\t\t\t\t\tWHERE `up`.`id` IN (?s) AND `up`.`saved_file_name` = ?s", $tmpFileId, $filename);
            }
        } else {
            // ORDINARY WORK WITH REAL LISTINGS
            foreach ($listing->getProperties() as $property) {
                if ($property->isComplex()) {
                    foreach ($property->type->complex->getProperties() as $complexProperty) {
                        if ($complexProperty->getType() == 'file' || $complexProperty->getType() == 'complexfile') {
                            $fileIds = $complexProperty->type->property_info['value'];
                            if (is_array($fileIds)) {
                                foreach ($fileIds as $key => $fileID) {
                                    if ($fileID != $complexPropertyName) {
                                        unset($fileIds[$key]);
                                    }
                                }
                                if (!empty($fileIds)) {
                                    return SJB_DB::query('SELECT `up`.`mime_type`, `up`.`sid`, `up`.`id` FROM `uploaded_files` `up`
										WHERE `up`.`id` IN (?l) AND `up`.`saved_file_name` = ?s', $fileIds, $filename);
                                } else {
                                    // check temporary session storage by filename
                                    $tmpFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                                    $complexPropertyName = SJB_Request::getVar('complex_field', '');
                                    $tmpFileId = SJB_Array::getPath($tmpFileStorage, "listings/{$id}/{$complexPropertyName}/file_id");
                                    if (!empty($tmpFileId)) {
                                        $mime_type = SJB_DB::query("SELECT `up`.`mime_type`, `up`.`sid`, `up`.`id` FROM `uploaded_files` `up`\n\t\t\t\t\t\t\t\t\t\t\tWHERE `up`.`id` IN (?s) AND `up`.`saved_file_name` = ?s", $tmpFileId, $filename);
                                    }
                                }
                            }
                        }
                    }
                } elseif ($property->getType() == 'file') {
                    $fileIds = $property->getValue();
                    if (is_array($fileIds) && !empty($fileIds['saved_file_name'])) {
                        if (!empty($fileIds['file_id'])) {
                            $query = 'SELECT `up`.`mime_type`, `up`.`sid`, `up`.`id` FROM `uploaded_files` `up`
										WHERE `up`.`id` IN (?l) AND `up`.`saved_file_name` = ?s';
                            $mime_type = SJB_DB::query($query, $fileIds['file_id'], $filename);
                            if ($mime_type) {
                                break;
                            }
                        } else {
                            // check temporary session storage by filename
                            $tmpFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                            $tmpFileId = SJB_Array::getPath($tmpFileStorage, "listings/{$id}/{$property->id}/file_id");
                            if (!empty($tmpFileId)) {
                                $mime_type = SJB_DB::query("SELECT `up`.`mime_type`, `up`.`sid`, `up`.`id` FROM `uploaded_files` `up`\n\t\t\t\t\t\t\t\t\tWHERE `up`.`id` IN (?s) AND `up`.`saved_file_name` = ?s", $tmpFileId, $filename);
                            }
                        }
                    }
                }
            }
        }
        return $mime_type ? array_pop($mime_type) : false;
    }
예제 #14
0
 private function validationManager($fieldInfo, $tp, $uploadedFieldId, $complex = null)
 {
     // will use tmp_uploads_storage in $_SESSION to storage file info
     $uniqueStorageId = SJB_Session::getSessionId();
     $this->fileUniqueId = $uniqueStorageId . "_" . $uploadedFieldId . "_tmp";
     // delete uniquie value
     SJB_UploadFileManager::deleteUploadedFileByID($this->fileUniqueId);
     $this->property = new SJB_ObjectProperty($fieldInfo);
     $this->property->setValue('');
     if ($complex) {
         $this->property->setComplexParent($complex['parentField']);
         $this->property->setComplexEnum($complex['complexStep']);
         $fileNamePath = "{$complex['parentField']}/name/{$complex['subFieldId']}/{$complex['complexStep']}";
         $fileSizePath = "{$complex['parentField']}/size/{$complex['subFieldId']}/{$complex['complexStep']}";
     } else {
         $fileNamePath = $uploadedFieldId . '/name';
         $fileSizePath = $uploadedFieldId . '/size';
     }
     $fileName = SJB_Array::getPath($_FILES, $fileNamePath);
     if (!$fileName) {
         $validation = 'UPLOAD_ERR_INI_SIZE';
     } else {
         $uploadedFilesize = SJB_Array::getPath($_FILES, $fileSizePath);
         $filesizeInfo = SJB_HelperFunctions::getFileSizeAndSizeToken($uploadedFilesize);
         $tp->assign(array('filesize' => $filesizeInfo['filesize'], 'size_token' => $filesizeInfo['size_token']));
         $validation = $this->property->isValid();
     }
     $this->propertyValue = $this->property->getValue();
     if ($validation !== true) {
         $this->errors[$validation] = 1;
         if (!$complex) {
             $tp->assign(array('id' => $uploadedFieldId, 'value' => array('file_url' => SJB_Array::get($this->propertyValue, 'file_url'), 'file_name' => SJB_Array::get($this->propertyValue, 'file_name'), 'saved_file_name' => SJB_Array::get($this->propertyValue, 'saved_file_name'), 'file_id' => $this->fileUniqueId)));
         }
     }
     $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
     return $validation === true;
 }
예제 #15
0
 public function execute()
 {
     $formToken = SJB_Request::getVar('form_token');
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('form_token', $formToken);
     $post_max_size_orig = ini_get('post_max_size');
     $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null;
     // get post_max_size in bytes
     $val = trim($post_max_size_orig);
     $tmp = substr($val, strlen($val) - 1);
     $tmp = strtolower($tmp);
     switch ($tmp) {
         case 'g':
             $val *= 1024;
             break;
         case 'm':
             $val *= 1024;
             break;
         case 'k':
             $val *= 1024;
             break;
     }
     $post_max_size = $val;
     $errors = array();
     if (SJB_Request::getVar('from-preview', false, 'POST') && !SJB_Request::getVar('action_add', false, 'POST')) {
         $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int');
         $previewListingId = SJB_Session::getValue('preview_listing_sid');
         if ($previewListingId && SJB_ListingManager::isListingExists($previewListingId)) {
             $listingId = $previewListingId;
         }
     } else {
         $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int');
     }
     $template = SJB_Request::getVar('edit_template', 'edit_listing.tpl');
     $filename = SJB_Request::getVar('filename', false);
     if ($filename) {
         SJB_UploadFileManager::openFile($filename, $listingId);
         // if file not found - set error here
         $errors['NO_SUCH_FILE'] = true;
     }
     if (empty($_POST) && $server_content_length > $post_max_size) {
         $errors['MAX_FILE_SIZE_EXCEEDED'] = 1;
         $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int');
         $tp->assign('post_max_size', $post_max_size_orig);
     }
     $current_user = SJB_UserManager::getCurrentUser();
     $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
     // for listing preview
     $formSubmittedFromPreview = false;
     if (empty($listingInfo)) {
         $listingId = SJB_Session::getValue('preview_listing_sid');
         $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
         if (!empty($listingInfo)) {
             // if on preview page 'POST' button was pressed
             $formSubmittedFromPreview = SJB_Request::getVar('action_add', false, 'POST') && SJB_Request::getVar('from-preview', false, 'POST');
             if ($formSubmittedFromPreview) {
                 $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']);
                 $properties = $listing->getProperties();
                 foreach ($properties as $fieldID => $property) {
                     switch ($property->getType()) {
                         case 'date':
                             if (!empty($listingInfo[$fieldID])) {
                                 $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]);
                             }
                             break;
                         case 'complex':
                             $complex = $property->type->complex;
                             $complexProperties = $complex->getProperties();
                             foreach ($complexProperties as $complexfieldID => $complexProperty) {
                                 if ($complexProperty->getType() == 'date') {
                                     $values = $complexProperty->getValue();
                                     foreach ($values as $index => $value) {
                                         if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) {
                                             $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]);
                                         }
                                     }
                                 }
                             }
                             break;
                     }
                 }
             }
         } else {
             $listingId = null;
             SJB_Session::unsetValue('preview_listing_sid');
         }
     }
     // if preview button was pressed
     $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
     if (SJB_UserManager::isUserLoggedIn()) {
         if ($listingInfo['user_sid'] != $current_user->getID()) {
             $errors['NOT_OWNER_OF_LISTING'] = $listingId;
         } elseif (!is_null($listingInfo)) {
             $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingInfo['listing_type_sid']);
             $form_is_submitted = SJB_Request::getVar('action', '') == 'save_info' || SJB_Request::getVar('action', '') == 'add' || $isPreviewListingRequested || $formSubmittedFromPreview;
             if (!$form_is_submitted && !SJB_Request::getVar('from-preview', false, 'POST')) {
                 SJB_Session::unsetValue('previewListingId');
                 SJB_Session::unsetValue('preview_listing_sid_or');
             }
             // fill listing from an array of social data if allowed
             $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']);
             $listingTypeID = $listing_type_info['id'];
             $aAutoFillData = array('formSubmitted' => $form_is_submitted, 'listingTypeID' => $listingTypeID);
             SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
             $listingInfo = array_merge($listingInfo, $_REQUEST);
             $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']);
             $listing->deleteProperty('ListingLogo');
             $listing->deleteProperty('featured');
             $listing->deleteProperty('priority');
             $listing->deleteProperty('reject_reason');
             $listing->deleteProperty('status');
             $list_emp_ids = SJB_Request::getVar('list_emp_ids');
             $listing->setSID($listingId);
             $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->getSID());
             if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                 $value = SJB_Request::getVar('screening_questionnaire');
                 $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                 $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($current_user->getSID()), 'is_system' => true));
             } else {
                 $listing->deleteProperty('screening_questionnaire');
             }
             //--->CLT-2637
             $properties = $listing->getProperties();
             $listing_fields_by_page = array();
             foreach ($pages as $page) {
                 $listing_fields_by_page = array_merge(SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']), $listing_fields_by_page);
             }
             foreach ($properties as $property) {
                 if (!in_array($property->getID(), array_keys($listing_fields_by_page))) {
                     $listing->deleteProperty($property->getID());
                 }
             }
             //--->CLT-2637
             // if user is not registered using linkedin , delete linkedin sync property, also if sync is turned off in admin part
             $aAutoFillData = array('oListing' => &$listing, 'userSID' => $current_user->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo);
             SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
             $listing_edit_form = new SJB_Form($listing);
             $listing_edit_form->registerTags($tp);
             $extraInfo = $listingInfo['product_info'];
             if ($extraInfo) {
                 $extraInfo = unserialize($extraInfo);
                 $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                 $listingSidForPictures = SJB_Session::getValue('preview_listing_sid_or') ? SJB_Session::getValue('preview_listing_sid_or') : $listingId;
                 $tp->assign('pic_limit', $numberOfPictures);
                 $tp->assign('listingSidForPictures', $listingSidForPictures);
             }
             if ($form_is_submitted) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true));
             }
             $field_errors = array();
             if ($form_is_submitted && ($formSubmittedFromPreview || $listing_edit_form->isDataValid($field_errors))) {
                 $or_listing_id = SJB_Session::getValue('preview_listing_sid_or');
                 /* preview listing */
                 if ($isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') != $listing->getSID()) {
                     SJB_Session::setValue('preview_listing_sid_or', $listing->getSID());
                     $listing->setSID(null);
                 } elseif (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listing->getSID() && $or_listing_id && $or_listing_id != $listingId) {
                     $listing->setSID($or_listing_id);
                 }
                 if ($isPreviewListingRequested) {
                     $listing->addProperty(array('id' => 'preview', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 } else {
                     $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 }
                 if ($isPreviewListingRequested) {
                     $listing->product_info = $extraInfo;
                     if (SJB_Session::getValue('previewListingId')) {
                         $listing->setSID(SJB_Session::getValue('previewListingId'));
                     }
                 } else {
                     SJB_BrowseDBManager::deleteListings($listing->getID());
                 }
                 $listingSidsForCopy = array('filesFrom' => $listingId, 'picturesFrom' => $isPreviewListingRequested && (!$or_listing_id || $or_listing_id === $listingId) ? $listingId : null);
                 SJB_ListingManager::saveListing($listing, $listingSidsForCopy);
                 if (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listingId && $or_listing_id && $or_listing_id != $listingId) {
                     SJB_Session::unsetValue('preview_listing_sid');
                     SJB_ListingManager::deleteListingBySID($listingId);
                 }
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listing->getSID());
                 if ($listingInfo['active']) {
                     SJB_ListingManager::activateListingKeywordsBySID($listing->getSID());
                     SJB_BrowseDBManager::addListings($listing->getID());
                 }
                 // >>> SJB-1197
                 // SET VALUES FROM TEMPORARY SESSION STORAGE
                 $formToken = SJB_Request::getVar('form_token');
                 $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $tempFieldsData = SJB_Array::getPath($sessionFileStorage, $formToken);
                 if (is_array($tempFieldsData)) {
                     foreach ($tempFieldsData as $fieldId => $fieldData) {
                         $isComplex = false;
                         if (strpos($fieldId, ':') !== false) {
                             $isComplex = true;
                         }
                         $tmpUploadedFileId = $fieldData['file_id'];
                         // rename it to real listing field value
                         $newFileId = $fieldId . "_" . $listing->getSID();
                         SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                         if ($isComplex) {
                             list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                             $parentProp = $listing->getProperty($parentField);
                             $parentValue = $parentProp->getValue();
                             // look for complex property with current $fieldID and set it to new value of property
                             if (!empty($parentValue)) {
                                 foreach ($parentValue as $id => $value) {
                                     if ($id == $subField) {
                                         $parentValue[$id][$complexStep] = $newFileId;
                                     }
                                 }
                                 $listing->setPropertyValue($parentField, $parentValue);
                             }
                         } else {
                             $listing->setPropertyValue($fieldId, $newFileId);
                         }
                     }
                     SJB_ListingManager::saveListing($listing);
                     // recreate form object for saved listing
                     // it fix display of complex file fields
                     $listing = SJB_ListingManager::getObjectBySID($listing->getSID());
                     $listing->deleteProperty('featured');
                     $listing->deleteProperty('priority');
                     $listing->deleteProperty('reject_reason');
                     $listing->deleteProperty('status');
                     $listing_edit_form = new SJB_Form($listing);
                     $listing_edit_form->registerTags($tp);
                 }
                 // <<< SJB-1197
                 if ($isPreviewListingRequested) {
                     SJB_Session::setValue('previewListingId', $listing->getSID());
                 }
                 /* preview listing */
                 if ($isPreviewListingRequested) {
                     $listing->setUserSID($current_user->getSID());
                     SJB_Session::setValue('preview_listing_sid', $listing->getSID());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/');
                 } else {
                     /* normal */
                     $listingSid = $listing->getSID();
                     SJB_Event::dispatch('listingEdited', $listingSid);
                     $tp->assign('display_preview', 1);
                     SJB_Session::unsetValue('preview_listing_sid');
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-' . strtolower($listingTypeID) . '-details/' . $listing->getSID() . '/');
                 }
             }
             $listing->deleteProperty('access_list');
             $tp->assign('form_is_submitted', $form_is_submitted);
             $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
             $form_fields = $listing_edit_form->getFormFieldsInfo();
             $listing_fields_by_page = array();
             foreach ($pages as $page) {
                 $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']);
                 foreach (array_keys($listing_fields_by_page[$page['page_name']]) as $field) {
                     if (!$listing->propertyIsSet($field)) {
                         unset($listing_fields_by_page[$page['page_name']][$field]);
                     }
                 }
             }
             // delete sync fields from posting pages that are not in array $form_fields
             $aAutoFillData = array('listing_fields_by_page' => &$listing_fields_by_page, 'pages' => &$pages, 'form_fields' => $form_fields);
             SJB_Event::dispatch('SocialSynchronizationFieldsOnPostingPages', $aAutoFillData);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             if (!isset($listing_structure['access_type'])) {
                 $listing_structure['access_type'] = 'everyone';
             }
             $listing_access_list = SJB_ListingManager::getListingAccessList($listingId, $listing->getPropertyValue('access_type'));
             $tp->assign('contract_id', $listingInfo['contract_id']);
             $tp->assign('extraInfo', $extraInfo);
             $tp->assign('listing', $listing_structure);
             $tp->assign('pages', $listing_fields_by_page);
             $tp->assign('countPages', count($listing_fields_by_page));
             $tp->assign('field_errors', $field_errors);
             $tp->assign('listing_access_list', $listing_access_list);
             $tp->assign('listingTypeID', $listingTypeID);
             $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID()));
             // only for Resume listing types
             $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $current_user->getSID());
             SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
         }
     } else {
         $errors['NOT_LOGGED_IN'] = 1;
     }
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
예제 #16
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = SJB_Request::getVar('input_template', 'input_form.tpl');
     $error = null;
     $listingTypeID = SJB_Request::getVar('listing_type_id', false);
     $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false);
     $pageID = false;
     if ($passed_parameters_via_uri) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listingTypeID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : $listingTypeID;
         $pageID = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : false;
         $listing_id = isset($passed_parameters_via_uri[2]) ? $passed_parameters_via_uri[2] : false;
     }
     if (SJB_UserManager::isUserLoggedIn()) {
         $post_max_size_orig = ini_get('post_max_size');
         $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null;
         $fromPreview = SJB_Request::getVar('from-preview', false);
         // get post_max_size in bytes
         $val = trim($post_max_size_orig);
         $tmp = substr($val, strlen($val) - 1);
         $tmp = strtolower($tmp);
         /* if ini value is K - then multiply to 1024
          * if ini value is M - then multiply twice: in case 'm', and case 'k'
          * if ini value is G - then multiply tree times: in 'g', 'm', 'k'
          * out value - in bytes!
          */
         switch ($tmp) {
             case 'g':
                 $val *= 1024;
             case 'm':
                 $val *= 1024;
             case 'k':
                 $val *= 1024;
         }
         $post_max_size = $val;
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             $file = SJB_UploadFileManager::openFile($filename, $listing_id);
             $errors['NO_SUCH_FILE'] = true;
         }
         if (empty($_POST) && $server_content_length > $post_max_size) {
             $errors['MAX_FILE_SIZE_EXCEEDED'] = 1;
             $tp->assign('post_max_size', $post_max_size_orig);
         }
         $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id);
         $currentUser = SJB_UserManager::getCurrentUser();
         $contractID = $listingInfo['contract_id'];
         if ($contractID == 0) {
             $extraInfo = unserialize($listingInfo['product_info']);
             $productSID = $extraInfo['product_sid'];
         } else {
             $contract = new SJB_Contract(array('contract_id' => $contractID));
             $extraInfo = $contract->extra_info;
         }
         if ($listingInfo['user_sid'] != SJB_UserManager::getCurrentUserSID()) {
             $errors['NOT_OWNER_OF_LISTING'] = $listing_id;
         } else {
             $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
             $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid);
             if (!$pageID) {
                 $pageID = $pages[0]['page_id'];
             }
             $pageSID = SJB_PostingPagesManager::getPostingPageSIDByID($pageID, $listing_type_sid);
             $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listing_type_sid);
             // preview listing
             $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
             $form_submitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested;
             // fill listing from an array of social data if allowed
             $aAutoFillData = array('formSubmitted' => &$form_submitted, 'listingTypeID' => &$listingTypeID);
             SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
             $listingInfo = array_merge($listingInfo, $_REQUEST);
             $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID);
             if ($fromPreview) {
                 if ($form_submitted) {
                     $properties = $listing->getProperties();
                     foreach ($properties as $fieldID => $property) {
                         switch ($property->getType()) {
                             case 'date':
                                 if (!empty($listing_info[$fieldID])) {
                                     $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]);
                                 }
                                 break;
                             case 'complex':
                                 $complex = $property->type->complex;
                                 $complexProperties = $complex->getProperties();
                                 foreach ($complexProperties as $complexfieldID => $complexProperty) {
                                     if ($complexProperty->getType() == 'date') {
                                         $values = $complexProperty->getValue();
                                         foreach ($values as $index => $value) {
                                             if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) {
                                                 $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]);
                                             }
                                         }
                                     }
                                 }
                                 break;
                         }
                     }
                     $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID);
                 }
             }
             $previousComplexFields = $this->processComplexFields($listing, $listingInfo);
             $listing->deleteProperty('featured');
             $listing->deleteProperty('priority');
             $listing->deleteProperty('status');
             $listing->deleteProperty('reject_reason');
             $listing->deleteProperty('ListingLogo');
             $listing->setSID($listing_id);
             $access_type = $listing->getProperty('access_type');
             if ($form_submitted && !empty($access_type)) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true));
             }
             $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID());
             if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                 $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
                 if ($issetQuestionnairyField) {
                     $value = SJB_Request::getVar('screening_questionnaire');
                     $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                     $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true));
                 }
             } else {
                 $listing->deleteProperty('screening_questionnaire');
             }
             /* social plugin
              * "synchronization"
              * if user is not registered using linkedin , delete linkedin sync property
              * also deletes it if sync is turned off in admin part
              */
             if ($pages[0]['page_id'] == $pageID) {
                 $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo);
                 SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
             }
             $add_listing_form = new SJB_Form($listing);
             $add_listing_form->registerTags($tp);
             $field_errors = array();
             if ($form_submitted && (SJB_Session::getValue(self::PREVIEW_LISTING_SID) == $listing_id || $add_listing_form->isDataValid($field_errors))) {
                 /* delete temp preview listing sid */
                 SJB_Session::unsetValue(self::PREVIEW_LISTING_SID);
                 if ($isPageLast) {
                     $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 }
                 $listing->setUserSID($currentUser->getSID());
                 if (empty($access_type->value)) {
                     $listing->setPropertyValue('access_type', 'everyone');
                 }
                 if (isset($_SESSION['tmp_file_storage'])) {
                     foreach ($_SESSION['tmp_file_storage'] as $k => $v) {
                         SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s', $listing->getSID(), $v['picture_saved_name']);
                         SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s', $listing->getSID(), $v['thumb_saved_name']);
                     }
                     SJB_Session::unsetValue('tmp_file_storage');
                 }
                 // >>> SJB-1197
                 // check temporary uploaded storage for listing uploads and assign it to saved listing
                 $formToken = SJB_Request::getVar('form_token');
                 $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
                 if (!empty($uploadedFields)) {
                     foreach ($uploadedFields as $fieldId => $fieldValue) {
                         // get field of listing
                         $isComplex = false;
                         if (strpos($fieldId, ':') !== false) {
                             $isComplex = true;
                         }
                         $tmpUploadedFileId = $fieldValue['file_id'];
                         // rename it to real listing field value
                         $newFileId = $fieldId . "_" . $listing->getSID();
                         SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                         if ($isComplex) {
                             list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                             $parentProp = $listing->getProperty($parentField);
                             $parentValue = $parentProp->getValue();
                             // look for complex property with current $fieldID and set it to new value of property
                             if (!empty($parentValue)) {
                                 foreach ($parentValue as $id => $value) {
                                     if ($id == $subField) {
                                         $parentValue[$id][$complexStep] = $newFileId;
                                     }
                                 }
                                 $listing->setPropertyValue($parentField, $parentValue);
                             }
                         } else {
                             $listing->setPropertyValue($fieldId, $newFileId);
                         }
                         // unset value from session temporary storage
                         $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                     }
                     //and remove token key from temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                     SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                 }
                 // <<< SJB-1197
                 SJB_ListingManager::saveListing($listing);
                 foreach ($previousComplexFields as $propertyId) {
                     $listing->deleteProperty($propertyId);
                 }
                 if ($isPageLast && !$isPreviewListingRequested) {
                     $listingSID = $listing->getSID();
                     $listing = SJB_ListingManager::getObjectBySID($listingSID);
                     $listing->setSID($listingSID);
                     $keywords = $listing->getKeywords();
                     SJB_ListingManager::updateKeywords($keywords, $listing->getSID());
                     // Start Event
                     $listingSid = $listing->getSID();
                     SJB_Event::dispatch('listingSaved', $listingSid);
                     // is listing featured by default
                     if ($extraInfo['featured']) {
                         SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                     }
                     if ($extraInfo['priority']) {
                         SJB_ListingManager::makePriorityBySID($listing->getSID());
                     }
                     if ($contractID) {
                         if (SJB_ListingManager::activateListingBySID($listing->getSID())) {
                             SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
                         }
                         // notify administrator
                         SJB_AdminNotifications::sendAdminListingAddedLetter($listing);
                         if (isset($_REQUEST['action_add_pictures'])) {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID());
                         } else {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeID) . '/?listing_id=' . $listing->getSID());
                         }
                     } else {
                         SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID());
                         $this->proceedToCheckout($currentUser->getSID(), $productSID);
                     }
                 } elseif ($isPageLast && $isPreviewListingRequested) {
                     // for listing preview
                     SJB_Session::setValue(self::PREVIEW_LISTING_SID, $listing->getSID());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/');
                 } else {
                     // listing steps (pages)
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . '/' . $listing->getSID());
                 }
             } else {
                 foreach ($previousComplexFields as $propertyId) {
                     $listing->deleteProperty($propertyId);
                 }
                 $listing->deleteProperty('access_list');
                 $listing->deleteProperty('contract_id');
                 $add_listing_form = new SJB_Form($listing);
                 if (SJB_Request::get('action_add') == 'Next') {
                     $add_listing_form->setUseDefaultValues();
                 }
                 if ($form_submitted) {
                     $add_listing_form->isDataValid($field_errors);
                 }
                 $add_listing_form->registerTags($tp);
                 $form_fields = $add_listing_form->getFormFieldsInfo();
                 $employers_list = SJB_Request::getVar('list_emp_ids', false);
                 $employers = array();
                 if (is_array($employers_list)) {
                     foreach ($employers_list as $emp) {
                         $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                         $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                     }
                     sort($employers);
                 } else {
                     $access_type = $listing->getPropertyValue('access_type');
                     $employers = SJB_ListingManager::getListingAccessList($listing_id, $access_type);
                 }
                 $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                 $tp->assign('pic_limit', $numberOfPictures);
                 $tp->assign('listing_sid', $listing_id);
                 $tp->assign('listing_id', $listing_id);
                 $tp->assign('listingSID', $listing->getSID());
                 $tp->assign('listing_access_list', $employers);
                 $tp->assign('listingTypeID', $listingTypeID);
                 $tp->assign('contract_id', $contractID);
                 $tp->assign('field_errors', $field_errors);
                 $tp->assign('form_fields', $form_fields);
                 $tp->assign("extraInfo", $extraInfo);
                 $tp->assign('pages', $pages);
                 $tp->assign('pageSID', $pageSID);
                 $tp->assign('currentPage', SJB_PostingPagesManager::getPageInfoBySID($pageSID));
                 $tp->assign('isPageLast', $isPageLast);
                 $tp->assign('nextPage', SJB_PostingPagesManager::getNextPage($pageSID));
                 $tp->assign('prevPage', SJB_PostingPagesManager::getPrevPage($pageSID));
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
                 // social plugin  only for Resume listing types
                 $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $currentUser->getSID());
                 SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
                 SJB_Session::unsetValue(self::PREVIEW_LISTING_SID);
                 $tp->display($template);
             }
         }
     } else {
         $tp->assign('listingTypeID', $listingTypeID);
         $tp->assign('error', 'NOT_LOGGED_IN');
         $tp->display('add_listing_error.tpl');
     }
 }
예제 #17
0
 public static function sendApplyNow($info, $file = '', $data_resume = array(), $current_user_sid = false, $notRegisterUserData = false, $score = false)
 {
     if ($current_user_sid) {
         $user_info = SJB_UserManager::getUserInfoBySID($current_user_sid);
         $sender_email_address = $user_info['email'];
     } else {
         $sender_email_address = $notRegisterUserData['email'];
     }
     $application_email = SJB_Applications::getApplicationEmailbyListingId($info['listing']['id']);
     $email_address = !empty($application_email) ? $application_email : $info['listing']['user']['email'];
     $questionnaire = !empty($info['submitted_data']['questionnaire']) ? unserialize($info['submitted_data']['questionnaire']) : '';
     $questionnaireInfo = array();
     if ($questionnaire) {
         $listingInfo = SJB_ListingManager::getListingInfoBySID($info['listing']['id']);
         $questSID = isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : 0;
         $questionnaireInfo = SJB_ScreeningQuestionnaires::getInfoBySID($questSID);
         $passing_score = 0;
         switch ($questionnaireInfo['passing_score']) {
             case 'acceptable':
                 $passing_score = 1;
                 break;
             case 'good':
                 $passing_score = 2;
                 break;
             case 'very_good':
                 $passing_score = 3;
                 break;
             case 'excellent':
                 $passing_score = 4;
                 break;
         }
         if ($score >= $passing_score) {
             $questionnaireInfo['passing_score'] = 'Passed';
         } else {
             $questionnaireInfo['passing_score'] = 'Not passed';
         }
     }
     if (!empty($info['listing']['subuser']['sid'])) {
         $subUserInfo = SJB_UserManager::getUserInfoBySID($info['listing']['subuser']['sid']);
         if (!empty($subUserInfo)) {
             $email_address = $subUserInfo['email'];
         }
     }
     $data = array('user' => SJB_Array::getPath($info, 'listing/user'), 'listing' => $info['listing'], 'applicant_request' => $info['submitted_data'], 'data_resume' => $data_resume, 'questionnaire' => $questionnaire, 'score' => $score, 'questionnaire_info' => $questionnaireInfo);
     $email = SJB_EmailTemplateEditor::getEmail($email_address, self::SEND_APPLY_NOW_SID, $data);
     $email->setReplyTo($sender_email_address);
     if ($file != '') {
         $email->setFile($file);
     }
     return $email->send('Apply Now');
 }
예제 #18
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $extUserID = SJB_Request::getVar('extUserID', null);
     $passedParametersViaUri = SJB_UrlParamProvider::getParams();
     $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false;
     if (!$userGroupID) {
         $userGroupsInfo = SJB_UserGroupManager::getAllUserGroupsInfo();
         $tp->assign('user_groups_info', $userGroupsInfo);
         $tp->display('add_user_choose_user_group.tpl');
     } else {
         $userGroupSID = SJB_UserGroupManager::getUserGroupSIDByID($userGroupID);
         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID);
         $user = SJB_ObjectMother::createUser($_REQUEST, $userGroupSID);
         $user->deleteProperty('active');
         $user->addExtUserIDProperty($extUserID);
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         $form_submitted = SJB_Request::getVar('action', '') == 'add';
         $errors = array();
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($userGroupSID) && $form_submitted) {
             $email = $user->getPropertyValue('email');
             if (is_array($email)) {
                 $email = $email['original'];
             }
             $user->setPropertyValue('username', $email);
         }
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             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);
                     // clean temporary storage
                     $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
                     // CLEAR TEMPORARY SESSION STORAGE
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
             }
             // <<< SJB-1197
             SJB_UserManager::activateUserByUserName($user->getUserName());
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($userGroupSID);
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8'));
         } else {
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($userGroupSID)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             $registration_form->registerTags($tp);
             $tp->assign("errors", $errors);
             $tp->assign("user_group", $userGroupInfo);
             $tp->assign('userTree', true);
             $tp->assign("form_fields", $registration_form->getFormFieldsInfo());
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             $tp->display("add_user.tpl");
         }
     }
 }