public function execute() { $tp = SJB_System::getTemplateProcessor(); $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid', 0, SJB_Request::METHOD_GET)); $user_id = $user['sid']; if (SJB_Request::getVar('pm_action', '', SJB_Request::METHOD_POST) == 'delete') { $checked = SJB_Request::getVar('pm_check', array(), SJB_Request::METHOD_POST); SJB_PrivateMessage::delete($checked); } $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET)); $per_page = 10; $total = SJB_PrivateMessage::getTotalOutbox($user_id); $max_pages = ceil($total / $per_page); if ($max_pages == 0) { $max_pages = 1; } if ($max_pages < $page) { SJB_HelperFunctions::redirect("?user_sid={$user_id}&page={$max_pages}"); } $navigate = SJB_PrivateMessage::getNavigate($page, $total, $per_page); $list = SJB_PrivateMessage::getListOutbox($user_id, $page, $per_page); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('username', $user['username']); $tp->assign('user_sid', $user_id); $tp->assign('message', $list); $tp->assign('navigate', $navigate); $tp->assign('page', $page); $tp->display('pm_outbox.tpl'); }
public static function saveInvoice($invoice) { $serializedItemsDetails['items'] = $invoice->getPropertyValue('items'); $products = isset($serializedItemsDetails['items']['products']) ? $serializedItemsDetails['items']['products'] : array(); $products = implode(',', $products); $invoice->addProperty(array('id' => 'serialized_items_info', 'type' => 'text', 'value' => serialize($serializedItemsDetails), 'is_system' => true)); $invoice->addProperty(array('id' => 'product_sid', 'type' => 'string', 'value' => $products, 'is_system' => true)); $invoice->deleteProperty('items'); $serializedTaxDetails['tax_info'] = $invoice->getPropertyValue('tax_info'); $invoice->addProperty(array('id' => 'serialized_tax_info', 'type' => 'text', 'value' => serialize($serializedTaxDetails), 'is_system' => true)); $invoice->deleteProperty('tax_info'); $user_sid = $invoice->getPropertyValue('user_sid'); $user_info = SJB_UserManager::getUserInfoBySID($user_sid); if (!empty($user_info['parent_sid'])) { $invoice->setPropertyValue('subuser_sid', $user_sid); $invoice->setPropertyValue('user_sid', $user_info['parent_sid']); } $dateProperty = $invoice->getProperty('date'); $value = $dateProperty->getValue(); if (!$dateProperty->type->getConvertToDBDate() && $value != null) { $invoice->setPropertyValue('date', SJB_I18N::getInstance()->getDate($value)); } $invoice->setPropertyValue('sub_total', SJB_I18N::getInstance()->getFloat($invoice->getPropertyValue('sub_total'))); $invoice->setPropertyValue('total', SJB_I18N::getInstance()->getFloat($invoice->getPropertyValue('total'))); parent::saveObject('invoices', $invoice); if ($value == null) { SJB_DB::query('UPDATE `invoices` SET `date`= NOW() WHERE `sid`=?n', $invoice->getSID()); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid')); $user_id = $user['sid']; $total_in = SJB_PrivateMessage::getTotalInbox($user_id); $total_out = SJB_PrivateMessage::getTotalOutbox($user_id); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign('username', $user['username']); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('user_sid', $user_id); $tp->assign('total_in', $total_in); $tp->assign('total_out', $total_out); $tp->display('main.tpl'); }
function saveInDB() { $result = SJB_ContractSQL::insert($this->_getHashedFields()); if ($result) { if (!$this->id) { $this->id = $result; } SJB_ContractSQL::updateContractExtraInfoByProductSID($this); if ($this->status == 'active') { SJB_Acl::copyPermissions($this->product_sid, $this->id, $this->number_of_listings); } else { SJB_Acl::clearPermissions('contract', $this->id); } $userInfo = SJB_UserManager::getUserInfoBySID($this->user_sid); $user = new SJB_User($userInfo, $userInfo['user_group_sid']); $user->updateSubscribeOnceUsersProperties($this->product_sid, $this->user_sid); } return (bool) $result; }
public function execute() { $access_type = SJB_Request::getVar('access_type'); $listing_id = SJB_Request::getVar('listing_id'); $user_group_id = SJB_Request::getVar('user_group_id'); $employersGroupSID = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id); $employersSIDs = SJB_UserManager::getUserSIDsByUserGroupSID($employersGroupSID); $employers = array(); foreach ($employersSIDs as $emp) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); if (isset($currEmp['CompanyName']) && $currEmp['CompanyName'] != '') { $employers[] = array('name' => $currEmp['CompanyName'], 'sid' => $emp); } } sort($employers); $tp = SJB_System::getTemplateProcessor(); $listing_access_list = SJB_ListingManager::getListingAccessList($listing_id, $access_type); $tp->assign('listing_access_list', $listing_access_list); $tp->assign('employers', $employers); $tp->display('employers_list.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', '', SJB_Request::METHOD_GET); $mess_id = intval(SJB_Request::getVar('mess', 0, SJB_Request::METHOD_GET)); $return_to = SJB_Request::getVar('from', 'in', SJB_Request::METHOD_GET); $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET)); $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid')); $user_id = $user['sid']; if ($action == 'delete') { SJB_DB::query("DELETE FROM `private_message` WHERE `id` = '{$mess_id}'"); $per_page = 10; if ($return_to == 'in') { $total = SJB_PrivateMessage::getTotalInbox($user_id); } else { $total = SJB_PrivateMessage::getTotalOutbox($user_id); } $max_pages = ceil($total / $per_page); if ($max_pages == 0) { $max_pages = 1; } if ($max_pages < $page) { $page = $max_pages; } $site_url = SJB_System::getSystemSettings('SITE_URL'); SJB_HelperFunctions::redirect($site_url . '/private-messages/pm-' . ($return_to == 'in' ? 'inbox' : 'outbox') . "/?user_sid={$user_id}&page={$page}"); } $message = SJB_PrivateMessage::ReadMessage($mess_id, true); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('returt_to', $return_to); $tp->assign('username', $user['username']); $tp->assign('user_sid', $user_id); $tp->assign('message', $message); $tp->assign('page', $page); $tp->display('pm_read.tpl'); }
/** * @param $listing SJB_Listing * @return array|bool */ public static function saveListing($listing, $listingSidsForCopy = array()) { $listing_type_sid = $listing->getListingTypeSID(); if (!is_null($listing_type_sid)) { $keywords = SJB_ListingDBManager::getListingKeywordsArray($listing); // Строчку в низ не переносить, так как после сохранения объекта вытащить кейворды сложнее parent::saveObject('listings', $listing, false, $listingSidsForCopy); $user_info = SJB_UserManager::getUserInfoBySID($listing->getUserSID()); $user_keywords = SJB_ListingDBManager::getUserKeywords($user_info); if ($user_keywords) { $keywords[] = $user_keywords; } SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS)); foreach ($keywords as $keyword) { SJB_ListingDBManager::saveListingKeyword($keyword, $listing->getSID(), $listing->isActive()); } if (!SJB_ListingManager::hasListingProduct($listing->getSID())) { SJB_ListingManager::insertProduct($listing->getSID(), $listing->getProductInfo()); } return SJB_DB::query('UPDATE `?w` SET `listing_type_sid` = ?n, `user_sid` = ?n, `keywords` = ?s, ' . '`activation_date` = ' . ($listing->getActivationDate() == null ? 'NOW()' : "'{$listing->getActivationDate()}'") . ' WHERE `sid` = ?n', 'listings', $listing_type_sid, $listing->getUserSID(), $listing->getKeywords(), $listing->getSID()); } return false; }
public static function generateExportData($parameters) { $exportProperties = $aliases = $sid = null; extract($parameters); $exportData = array(); $userInfo = SJB_UserManager::getUserInfoBySID($sid); $userInfo['id'] = $userInfo['sid']; $userInfo = $aliases->changePropertiesInfo($userInfo); if (!empty($userInfo['product'])) { $contracts = $userInfo['product']; $userInfo['product'] = array(); foreach ($contracts as $contract) { $productInfo = SJB_ProductsManager::getProductInfoBySID($contract['product_sid']); if ($productInfo) { $extraInfo = !empty($contract['serialized_extra_info']) ? unserialize($contract['serialized_extra_info']) : null; $userInfo['product'][] = serialize(array('name' => $productInfo['name'], 'creation_date' => $contract['creation_date'], 'expired_date' => $contract['expired_date'], 'price' => $contract['price'], 'number_of_postings' => $contract['number_of_postings'], 'number_of_listings' => $extraInfo ? $extraInfo['number_of_listings'] : 0, 'status' => $contract['status'])); } } $userInfo['product'] = implode(',', $userInfo['product']); } else { $userInfo['product'] = ''; } // this data is necessary for additional properties : like tree $exportData[$sid][self::USER_OPTIONS_INDEX]['user_group_id'] = SJB_Array::get($userInfo, 'user_group'); foreach ($exportProperties as $propertyId => $value) { $exportData[$sid][$propertyId] = isset($userInfo[$propertyId]) ? $userInfo[$propertyId] : null; } self::changeTreeProperties($exportData); self::changeListProperties($exportData); self::cleanOptions($exportData); self::changeMonetaryProperties($exportProperties, $exportData); self::changeFileProperties($exportProperties, $exportData, 'file'); self::changeFileProperties($exportProperties, $exportData, 'video'); self::changeFileProperties($exportProperties, $exportData, 'Logo'); self::changeLocationProperties($exportProperties, $exportData); return $exportData[$sid]; }
public function execute() { $user_sid = isset($_REQUEST['user_sid']) ? $_REQUEST['user_sid'] : null; $field_id = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : null; $user_info = SJB_UserManager::getUserInfoBySID($user_sid); if (is_null($field_id) || is_null($user_sid)) { $errors['PARAMETERS_MISSED'] = 1; } elseif (!isset($user_info[$field_id])) { $errors['WRONG_PARAMETERS_SPECIFIED'] = 1; } else { $uploaded_file_id = $user_info[$field_id]; SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id); $user_info[$field_id] = ""; $user = new SJB_User($user_info, $user_info['user_group_sid']); $user->deleteProperty("active"); $user->deleteProperty('password'); $user->setSID($user_info['sid']); SJB_UserManager::saveUser($user); } $template_processor = SJB_System::getTemplateProcessor(); $template_processor->assign("errors", isset($errors) ? $errors : null); $template_processor->assign("user_sid", $user_sid); $template_processor->display("delete_uploaded_picture.tpl"); }
public static function getListingAccessList($listing_id, $access_type) { $result = SJB_DB::query("SELECT `access_list` FROM `listings` WHERE `access_type` = ?s AND `sid` =?n ", $access_type, $listing_id); if ($result) { $result = array_pop($result); $result = explode(',', array_pop($result)); } else { $result = false; } $employers = array(); if (is_array($result)) { foreach ($result as $emp) { if (!empty($emp)) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']); } } sort($employers); } return $employers; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $userSID = SJB_Request::getVar('user_sid', false); $includeTax = SJB_Request::getVar('include_tax', SJB_Settings::getSettingByName('enable_taxes')); $errors = array(); $invoiceErrors = array(); $template = 'add_invoice.tpl'; $userInfo = SJB_UserManager::getUserInfoBySID($userSID); if ($userInfo) { if (!empty($userInfo['parent_sid'])) { $parent_sid = $userInfo['parent_sid']; $username = $userInfo['username'] . '/' . $userInfo['email']; } else { $parent_sid = $userSID; $username = $userInfo['FirstName'] . ' ' . $userInfo['LastName'] . ' ' . $userInfo['ContactName'] . ' ' . $userInfo['CompanyName'] . '/' . $userInfo['email']; } $formSubmitted = SJB_Request::getVar('action', '') == 'save'; $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']); $products = array(); foreach ($productsSIDs as $key => $productSID) { $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { $volumeBasedPricing = $productInfo['volume_based_pricing']; $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[$i]['number_of_listings'] = $i; for ($j = 1; $j <= count($volumeBasedPricing['listings_range_from']); $j++) { if ($i >= $volumeBasedPricing['listings_range_from'][$j] && $i <= $volumeBasedPricing['listings_range_to'][$j]) { $countListings[$i]['price'] = $volumeBasedPricing['price_per_unit'][$j]; } } } $productInfo['count_listings'] = $countListings; } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { unset($productInfo['volume_based_pricing']); } $products[$key] = $productInfo; } $total = SJB_I18N::getInstance()->getInput('float', SJB_Request::getVar('total', 0)); $taxInfo = SJB_TaxesManager::getTaxInfoByUserSidAndPrice($parent_sid, $total); $invoice = new SJB_Invoice($_REQUEST); $addForm = new SJB_Form($invoice); $addForm->registerTags($tp); if ($formSubmitted) { $invoiceErrors = $invoice->isValid(); if (empty($invoiceErrors) && $addForm->isDataValid($errors)) { $invoice->setFloatNumbersIntoValidFormat(); $invoice->setPropertyValue('success_page_url', SJB_System::getSystemSettings('USER_SITE_URL') . '/create-contract/'); SJB_InvoiceManager::saveInvoice($invoice); if (SJB_Request::getVar('send_invoice', false)) { SJB_Notifications::sendInvoiceToCustomer($invoice->getSID(), $userSID); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/manage-invoices/'); } else { $invoiceDate = SJB_I18N::getInstance()->getInput('date', $invoice->getPropertyValue('date')); $invoice->setPropertyValue('date', $invoiceDate); } } else { $invoice->setPropertyValue('date', date('Y-m-d')); $invoice->setPropertyValue('status', SJB_Invoice::INVOICE_STATUS_UNPAID); } $invoice->setFloatNumbersIntoValidFormat(); $tp->assign('username', $username); $tp->assign('user_sid', $userSID); $tp->assign('products', $products); $tp->assign('tax', $taxInfo); $tp->assign('include_tax', $includeTax); } else { $errors[] = 'CUSTOMER_NOT_SELECTED'; $tp->assign('action', 'add'); $template = 'errors.tpl'; } $tp->assign("errors", array_merge($errors, $invoiceErrors)); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $template = 'sub_accounts.tpl'; $currentUserInfo = SJB_UserManager::getCurrentUserInfo(); $listSubusers = false; if (!empty($currentUserInfo['subuser']) && SJB_Request::getVar('action_name') != 'edit' && SJB_Request::getVar('user_id', 0) != $currentUserInfo['subuser']['sid']) { $errors['ACCESS_DENIED'] = 'ACCESS_DENIED'; } switch (SJB_Request::getVar('action_name')) { case 'new': $form_submitted = SJB_Request::getMethod() === SJB_Request::METHOD_POST; $user_group_sid = $currentUserInfo['user_group_sid']; $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); $_REQUEST['user_group_id'] = $user_group_info['id']; $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid); $props = $user->getProperties(); $allowedProperties = array('username', 'email', 'password'); foreach ($props as $prop) { if (!in_array($prop->getID(), $allowedProperties)) { $user->deleteProperty($prop->getID()); } } $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); } $registration_form = SJB_ObjectMother::createForm($user); if ($form_submitted && $registration_form->isDataValid($errors)) { $user->addParentProperty($currentUserInfo['sid']); $subuserPermissions = array('subuser_add_listings' => array('title' => 'Add new listings', 'value' => 'deny'), 'subuser_manage_listings' => array('title' => 'Manage listings and applications of other sub users', 'value' => 'deny'), 'subuser_manage_subscription' => array('title' => 'View and update subscription', 'value' => 'deny'), 'subuser_use_screening_questionnaires' => array('title' => 'Manage Questionnaries', 'value' => 'deny')); SJB_UserManager::saveUser($user); SJB_Statistics::addStatistics('addSubAccount', $user->getUserGroupSID(), $user->getSID()); SJB_Acl::clearPermissions('user', $user->getSID()); foreach ($subuserPermissions as $permissionID => $permission) { $allowDeny = SJB_Request::getVar($permissionID, 'deny'); $subuserPermissions[$permissionID]['value'] = $allowDeny; SJB_Acl::allow($permissionID, 'user', $user->getSID(), $allowDeny); } SJB_UserManager::activateUserByUserName($user->getUserName()); SJB_Notifications::sendSubuserRegistrationLetter($user, SJB_Request::get(), $subuserPermissions); $tp->assign('isSubuserRegistered', true); $listSubusers = true; } else { if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) { $user->deleteProperty("username"); } $registration_form = SJB_ObjectMother::createForm($user); if ($form_submitted) { $registration_form->isDataValid($errors); } $registration_form->registerTags($tp); $form_fields = $registration_form->getFormFieldsInfo(); $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))); $tp->display('subuser_registration_form.tpl'); } break; case 'edit': $userInfo = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_id', 0)); if (!empty($userInfo) && $userInfo['parent_sid'] === $currentUserInfo['sid']) { $userInfo = array_merge($userInfo, $_REQUEST); $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']); $user = new SJB_User($userInfo, $userInfo['user_group_sid']); $user->setSID($userInfo['sid']); $user->addParentProperty($currentUserInfo['sid']); $props = $user->getProperties(); $allowedProperties = array('username', 'email', 'password'); foreach ($props as $prop) { if (!in_array($prop->getID(), $allowedProperties)) { $user->deleteProperty($prop->getID()); } } $user->makePropertyNotRequired("password"); $edit_profile_form = SJB_ObjectMother::createForm($user); $edit_profile_form->registerTags($tp); $edit_profile_form->makeDisabled("username"); $form_submitted = SJB_Request::getMethod() == SJB_Request::METHOD_POST; if (empty($errors) && $form_submitted && $edit_profile_form->isDataValid($errors)) { $password_value = $user->getPropertyValue('password'); if (empty($password_value['original'])) { $user->deleteProperty('password'); } $currentUser = SJB_UserManager::getCurrentUser(); if (!$currentUser->isSubuser()) { $subuserPermissions = array('subuser_add_listings', 'subuser_manage_listings', 'subuser_manage_subscription', 'subuser_use_screening_questionnaires'); SJB_Acl::clearPermissions('user', $user->getSID()); foreach ($subuserPermissions as $permission) { SJB_Acl::allow($permission, 'user', $user->getSID(), SJB_Request::getVar($permission, 'deny')); } } SJB_UserManager::saveUser($user); $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("form_fields", $form_fields); $tp->assign('user_info', $userInfo); $tp->display('edit_subuser_profile.tpl'); } break; case 'delete': $users = SJB_Request::getVar('user_id', array()); foreach ($users as $user) { SJB_UserManager::deleteUserById($user); } $listSubusers = true; break; default: $listSubusers = true; break; } if ($listSubusers) { $tp->assign('errors', $errors); $tp->assign('subusers', SJB_UserManager::getSubusers($currentUserInfo['sid'])); $tp->assign('isEmailAsUsername', SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($currentUserInfo['user_group_sid'])); $tp->display($template); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $displayForm = new SJB_Form(); $displayForm->registerTags($tp); $invoiceSid = SJB_Request::getVar('sid', false); if (SJB_Request::getVar('error', false)) { SJB_FlashMessages::getInstance()->addWarning('TCPDF_ERROR'); } $action = SJB_Request::getVar('action', false); $paymentGateway = SJB_Request::getVar('payment_gateway', false); $template = 'print_invoice.tpl'; $currentUserSID = SJB_UserManager::getCurrentUserSID(); $invoiceInfo = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSid); if ($invoiceInfo) { if ($currentUserSID == $invoiceInfo['user_sid']) { $taxInfo = SJB_TaxesManager::getTaxInfoBySID($invoiceInfo['tax_info']['sid']); $invoiceInfo = array_merge($invoiceInfo, $_REQUEST); if (is_array($taxInfo)) { $taxInfo = array_merge($invoiceInfo['tax_info'], $taxInfo); } else { $taxInfo = $invoiceInfo['tax_info']; } $invoice = new SJB_Invoice($invoiceInfo); $invoice->setSID($invoiceSid); $userInfo = SJB_UserManager::getUserInfoBySID($currentUserSID); $username = $userInfo['CompanyName'] . ' ' . $userInfo['FirstName'] . ' ' . $userInfo['LastName']; $user = SJB_UserManager::getObjectBySID($currentUserSID); $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']); $products = array(); foreach ($productsSIDs as $key => $productSID) { $product = SJB_ProductsManager::getProductInfoBySID($productSID); $products[$key] = $product; } $displayForm = new SJB_Form($invoice); $displayForm->registerTags($tp); $show = true; if ($action == 'download_pdf_version' || $action == 'print') { $show = false; } $tp->assign('show', $show); $tp->assign('products', $products); $tp->assign('invoice_sid', $invoiceSid); $tp->assign('invoice_status', $invoiceInfo['status']); $tp->assign('username', trim($username)); $tp->assign('user_sid', $currentUserSID); $tp->assign('tax', $taxInfo); $userStructure = SJB_UserManager::createTemplateStructureForUser($user); $tp->assign('user', $userStructure); $tp->assign('include_tax', $invoiceInfo['include_tax']); if ($action == 'download_pdf_version') { $template = 'invoice_to_pdf.tpl'; $filename = 'invoice_' . $invoiceSid . '.pdf'; try { SJB_HelperFunctions::html2pdf($tp->fetch($template), $filename); exit; } catch (Exception $e) { SJB_Error::writeToLog($e->getMessage()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/print-invoice/?sid=' . $invoiceSid . '&action=print&error=TCPDF_ERROR'); } } } else { SJB_FlashMessages::getInstance()->addError('NOT_OWNER'); } } else { SJB_FlashMessages::getInstance()->addError('WRONG_INVOICE_ID_SPECIFIED'); } if ($paymentGateway) { $gatewaySID = SJB_PaymentGatewayManager::getSIDByID($paymentGateway); $gatewayInfo = SJB_PaymentGatewayManager::getInfoBySID($gatewaySID); $tp->assign('gatewayInfo', $gatewayInfo); } $tp->assign('paymentError', SJB_Request::getVar('payment_error', false)); $tp->display($template); }
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'); } }
private function runTaskScheduler() { // Deactivate Expired Listings & Send Notifications $listingsExpiredID = SJB_ListingManager::getExpiredListingsSID(); foreach ($listingsExpiredID as $listingExpiredID) { SJB_ListingManager::deactivateListingBySID($listingExpiredID, true); $listing = SJB_ListingManager::getObjectBySID($listingExpiredID); $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing); if (SJB_UserNotificationsManager::isUserNotifiedOnListingExpiration($listing->getUserSID())) { SJB_Notifications::sendUserListingExpiredLetter($listingInfo); } // notify admin SJB_AdminNotifications::sendAdminListingExpiredLetter($listingInfo); } $listingsDeactivatedID = array(); if (SJB_Settings::getSettingByName('automatically_delete_expired_listings')) { $listingsDeactivatedID = SJB_ListingManager::getDeactivatedListingsSID(); foreach ($listingsDeactivatedID as $listingID) { SJB_ListingManager::deleteListingBySID($listingID); } } SJB_ListingManager::unFeaturedListings(); SJB_ListingManager::unPriorityListings(); SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS)); /////////////////////////// Send remind notifications about expiration of LISTINGS // 1. get user sids and days count of 'remind listing notification' setting = 1 from user_notifications table // 2. foreach user: // - get listings with that expiration remind date // - check every listing sid in DB table of sended. If sended - remove from send list // - send notification with listings to user // - write listings sid in DB table of sended notifications $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnListingExpirationRemind(); foreach ($notificationData as $elem) { $userSID = $elem['user_sid']; $days = $elem['days']; $listingSIDs = SJB_ListingManager::getListingsIDByDaysLeftToExpired($userSID, $days); if (empty($listingSIDs)) { continue; } $listingsInfo = array(); // check listings remind sended foreach ($listingSIDs as $key => $sid) { if (SJB_ListingManager::isListingNotificationSended($sid)) { unset($listingSIDs[$key]); continue; } $info = SJB_ListingManager::getListingInfoBySID($sid); $listingsInfo[$sid] = $info; } if (!empty($listingsInfo)) { // now only unsended listings we have in array // send listing notification foreach ($listingSIDs as $sid) { SJB_Notifications::sendRemindListingExpirationLetter($userSID, $sid, $days); } // write listing id in DB table of sended notifications SJB_ListingManager::saveListingIDAsSendedNotificationsTable($listingSIDs); } } // Send Notifications for Expired Contracts $contractsExpiredID = SJB_ContractManager::getExpiredContractsID(); foreach ($contractsExpiredID as $contractExpiredID) { $contractInfo = SJB_ContractManager::getInfo($contractExpiredID); $productInfo = SJB_ProductsManager::getProductInfoBySID($contractInfo['product_sid']); $userInfo = SJB_UserManager::getUserInfoBySID($contractInfo['user_sid']); $serializedExtraInfo = unserialize($contractInfo['serialized_extra_info']); if (!empty($serializedExtraInfo['featured_profile']) && !empty($userInfo['featured'])) { $contracts = SJB_ContractManager::getAllContractsInfoByUserSID($userInfo['sid']); $isFeatured = 0; foreach ($contracts as $contract) { if ($contract['id'] != $contractExpiredID) { $serializedExtraInfo = unserialize($contract['serialized_extra_info']); if (!empty($serializedExtraInfo['featured'])) { $isFeatured = 1; } } } if (!$isFeatured) { SJB_UserManager::removeFromFeaturedBySID($userInfo['sid']); } } if (SJB_UserNotificationsManager::isUserNotifiedOnContractExpiration($contractInfo['user_sid'])) { SJB_Notifications::sendUserContractExpiredLetter($userInfo, $contractInfo, $productInfo); } // notify admin SJB_AdminNotifications::sendAdminUserContractExpiredLetter($userInfo['sid'], $contractInfo, $productInfo); SJB_ContractManager::deleteContract($contractExpiredID, $contractInfo['user_sid']); } //////////////////////// Send remind notifications about expiration of contracts // 1. get user sids and days count of 'remind subscription notification' setting = 1 from user_notifications table // 2. foreach user: // - get contracts with that expiration remind date // - check every contract sid in DB table of sended. If sended - remove from send list // - send notification with contracts to user // - write contract sid in DB table of sended contract notifications $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnSubscriptionExpirationRemind(); foreach ($notificationData as $elem) { $userSID = $elem['user_sid']; $days = $elem['days']; $contractSIDs = SJB_ContractManager::getContractsIDByDaysLeftToExpired($userSID, $days); if (empty($contractSIDs)) { continue; } $contractsInfo = array(); // check contracts sended foreach ($contractSIDs as $key => $sid) { if (SJB_ContractManager::isContractNotificationSended($sid)) { unset($contractSIDs[$key]); continue; } $info = SJB_ContractManager::getInfo($sid); $info['extra_info'] = !empty($info['serialized_extra_info']) ? unserialize($info['serialized_extra_info']) : ''; $contractsInfo[$sid] = $info; } if (!empty($contractsInfo)) { // now only unsended contracts we have in array // send contract notification foreach ($contractSIDs as $sid) { SJB_Notifications::sendRemindSubscriptionExpirationLetter($userSID, $contractsInfo[$sid], $days); } // write contract id in DB table of sended contract notifications SJB_ContractManager::saveContractIDAsSendedNotificationsTable($contractSIDs); } } // delete applications with no employer and job seeker $emptyApplications = SJB_DB::query('SELECT `id` FROM `applications` WHERE `show_js` = 0 AND `show_emp` = 0'); foreach ($emptyApplications as $application) { SJB_Applications::remove($application['id']); } // NEWS $expiredNews = SJB_NewsManager::getExpiredNews(); foreach ($expiredNews as $article) { SJB_NewsManager::deactivateItemBySID($article['sid']); } // LISTING XML IMPORT SJB_XmlImport::runImport(); // UPDATE PAGES WITH FUNCTION EQUAL BROWSE(e.g. /browse-by-city/) SJB_BrowseDBManager::rebuildBrowses(); //-------------------sitemap generator--------------------// SJB_System::executeFunction('miscellaneous', 'sitemap_generator'); // CLEAR `error_log` TABLE $errorLogLifetime = SJB_System::getSettingByName('error_log_lifetime'); $lifeTime = strtotime("-{$errorLogLifetime} days"); if ($lifeTime > 0) { SJB_DB::query('DELETE FROM `error_log` WHERE `date` < ?t', $lifeTime); } SJB_Settings::updateSetting('task_scheduler_last_executed_date', $this->currentDate); $this->tp->assign('expired_listings_id', $listingsExpiredID); $this->tp->assign('deactivated_listings_id', $listingsDeactivatedID); $this->tp->assign('expired_contracts_id', $contractsExpiredID); $this->tp->assign('notified_saved_searches_id', $this->notifiedSavedSearchesSID); $schedulerLog = $this->tp->fetch('task_scheduler_log.tpl'); SJB_HelperFunctions::writeCronLogFile('task_scheduler.log', $schedulerLog); SJB_DB::query('INSERT INTO `task_scheduler_log` (`last_executed_date`, `notifieds_sent`, `expired_listings`, `expired_contracts`, `log_text`) VALUES ( NOW(), ?n, ?n, ?n, ?s)', count($this->notifiedSavedSearchesSID), count($listingsExpiredID), count($contractsExpiredID), $schedulerLog); SJB_System::getModuleManager()->executeFunction('social', 'linkedin'); SJB_System::getModuleManager()->executeFunction('social', 'facebook'); SJB_System::getModuleManager()->executeFunction('classifieds', 'linkedin'); SJB_System::getModuleManager()->executeFunction('classifieds', 'facebook'); SJB_System::getModuleManager()->executeFunction('classifieds', 'twitter'); SJB_Event::dispatch('task_scheduler_run'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $info = ''; if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $to = SJB_Request::getVar('to'); // POST and check for errors form_to form_subject form_message if (isset($_POST['form_to'])) { $to_user_name = SJB_Request::getVar('form_to', null, 'POST'); $to_user_info = null; // trying to get user info by user id if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } /* * в функции compose private message функцию отправки * сообщения по имени пользователя оставить рабочей */ if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } // trying to get user info by user id if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } /* * в функции compose private message функцию отправки * сообщения по имени пользователя оставить рабочей */ if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? true : false; if ($to_user == 0) { $errors['form_to'] = 'You specified wrong username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($message)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, false, $anonym); $info = 'The message was sent successfully'; $to = ''; // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } } else { $tp->assign("form_to", htmlentities($to_user_name, ENT_QUOTES, "UTF-8")); $tp->assign("form_subject", htmlentities($subject, ENT_QUOTES, "UTF-8")); $tp->assign("form_message", $message); $tp->assign("form_save", $save); $tp->assign("errors", $errors); } } $display_to = ''; // get display name for "Message to" field SJB_UserManager::getComposeDisplayName($to, $display_to); $tp->assign('info', $info); $tp->assign('to', $to); $tp->assign('anonym', SJB_Request::getVar('anonym')); $tp->assign('display_to', $display_to); $tp->assign('include', 'new_message.tpl'); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('main.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->assign('ajaxRelocate', true); $tp->display('../users/login.tpl'); } }
/** * Create structure for templates * * @param SJB_NewsArticle $article * @return array: */ public static function createTemplateStructureForNewsArticle($article) { $articleInfo = parent::getObjectInfo($article); if (is_null(self::$uploadFileManager)) { self::$uploadFileManager = new SJB_UploadFileManager(); } foreach ($article->getProperties() as $property) { if ($property->isComplex()) { $isPropertyEmpty = true; $properties = $property->type->complex->getProperties(); $properties = is_array($properties) ? $properties : array(); foreach ($properties as $subProperty) { if (!empty($articleInfo['user_defined'][$property->getID()][$subProperty->getID()]) && is_array($articleInfo['user_defined'][$property->getID()][$subProperty->getID()])) { foreach ($articleInfo['user_defined'][$property->getID()][$subProperty->getID()] as $subValue) { if (!empty($subValue)) { $isPropertyEmpty = false; } } } } if ($isPropertyEmpty) { $articleInfo['user_defined'][$property->getID()] = ''; } } } $structure = array('sid' => $articleInfo['system']['id'], 'id' => $articleInfo['system']['id'], 'date' => $articleInfo['system']['date'], 'expiration_date' => $articleInfo['system']['expiration_date'], 'active' => $articleInfo['system']['active'], 'image_link' => self::$uploadFileManager->getUploadedFileLink($articleInfo['system']['image'])); if (!empty($articleInfo['system']['subuser_sid'])) { $structure['subuser'] = SJB_UserManager::getUserInfoBySID($articleInfo['system']['subuser_sid']); } $structure['METADATA'] = array('date' => array('type' => 'date'), 'expiration_date' => array('type' => 'date')); $structure = array_merge($structure, $articleInfo['user_defined']); $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($article)); return array_merge($structure, $articleInfo['user_defined']); }
public static function deleteNonexistentContacts($userSID) { $contacts = SJB_DB::query("SELECT `contact_sid` FROM `private_message_contacts` WHERE `user_sid` = ?n", $userSID); foreach ($contacts as $contactInfo) { $userInfo = SJB_UserManager::getUserInfoBySID($contactInfo['contact_sid']); if (empty($userInfo)) { SJB_PrivateMessage::deleteContact($userSID, $contactInfo['contact_sid']); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $errors = array(); $info = ''; $to = SJB_Request::getVar('to', '', 'GET'); // POST and check for errors form_to form_subject form_message if (isset($_POST['act'])) { $to_user_name = SJB_Request::getVar('form_to', '', 'POST'); $to_user_info = null; if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } // в функции compose private message функцию отправки // сообщения по имени пользователя оставить рабочей if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } $cc = SJB_Request::getVar('cc', false); if ($cc !== false) { if (intval($cc)) { $cc_info = SJB_UserManager::getUserInfoBySID($cc); } // в функции compose private message функцию отправки // сообщения по имени пользователя оставить рабочей if (is_null($cc_info)) { $cc_info = SJB_UserManager::getUserInfoByUserName($cc); } if (!empty($cc_info)) { $cc = $cc_info['sid']; } } $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? $_POST['form_save'] == 1 ? true : false : false; if ($to_user == 0) { $errors['form_to'] = 'Please enter correct username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($message)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, $cc, $anonym); // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } echo '<p class="message">' . SJB_I18N::getInstance()->gettext(null, 'The message was sent successfully') . '</p>'; exit; } } $display_to = ''; // get display name for 'Message to' field SJB_UserManager::getComposeDisplayName($to, $display_to); $tp->assign('errors', $errors); $tp->assign('info', $info); $tp->assign('to', $to); $tp->assign('display_to', $display_to); $tp->assign('anonym', SJB_Request::getVar('anonym')); $tp->assign('cc', SJB_Request::getVar('cc', '')); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('new_message_ajax.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->assign('ajaxRelocate', true); $tp->display('../users/login.tpl'); } }
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); }
public static function getCurrentUserInfo() { $currentUser = SJB_Session::getValue('current_user'); if (!empty($currentUser)) { return $currentUser; } if (isset($_COOKIE['session_key'])) { $user_sid = SJB_UserManager::getUserSIDBySessionKey($_COOKIE['session_key']); if (!empty($user_sid)) { $userInfo = SJB_UserManager::getUserInfoBySID($user_sid); if (!empty($userInfo['parent_sid'])) { $subuserInfo = $userInfo; $userInfo = SJB_UserManager::getUserInfoBySID($userInfo['parent_sid']); $userInfo['subuser'] = $subuserInfo; } SJB_Session::setValue('current_user', $userInfo); SJB_Authorization::setKeepCookieForUser($_COOKIE['session_key']); return $userInfo; } } return null; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $template = SJB_Request::getVar('template', 'users.tpl'); $searchTemplate = SJB_Request::getVar('search_template', 'user_search_form.tpl'); $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false; $userGroupSID = $userGroupID ? SJB_UserGroupManager::getUserGroupSIDByID($userGroupID) : null; $errors = array(); /********** A C T I O N S W I T H U S E R S **********/ $action = SJB_Request::getVar('action_name'); if (!empty($action)) { $users_sids = SJB_Request::getVar('users', array()); $_REQUEST['restore'] = 1; switch ($action) { case 'approve': foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); SJB_UserManager::setApprovalStatusByUserName($username, 'Approved'); SJB_UserManager::activateUserByUserName($username); SJB_UserDBManager::deleteActivationKeyByUsername($username); if (!SJB_SocialPlugin::getProfileSocialID($user_sid)) { SJB_Notifications::sendUserWelcomeLetter($user_sid); } else { SJB_Notifications::sendUserApprovedLetter($user_sid); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'reject': $rejection_reason = SJB_Request::getVar('rejection_reason', ''); foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); SJB_UserManager::setApprovalStatusByUserName($username, 'Rejected', $rejection_reason); SJB_UserManager::deactivateUserByUserName($username); SJB_Notifications::sendUserRejectedLetter($user_sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'activate': foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); $userinfo = SJB_UserManager::getUserInfoByUserName($username); SJB_UserManager::activateUserByUserName($username); if ($userinfo['approval'] == 'Approved') { SJB_UserDBManager::deleteActivationKeyByUsername($username); SJB_Notifications::sendUserApprovedLetter($user_sid); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'deactivate': foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); SJB_UserManager::deactivateUserByUserName($username); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'delete': foreach (array_keys($users_sids) as $user_sid) { try { SJB_UserManager::deleteUserById($user_sid); } catch (Exception $e) { $errors[] = $e->getMessage(); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'send_activation_letter': foreach ($users_sids as $user_sid => $value) { SJB_Notifications::sendUserActivationLetter($user_sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'change_product': $productToChange = SJB_Request::getVar('product_to_change'); if (empty($productToChange)) { $productToChange = 0; } foreach ($users_sids as $user_sid => $value) { $user = SJB_UserManager::getObjectBySID($user_sid); // UNSUBSCRIBE selected if ($productToChange == 0) { SJB_ContractManager::deleteAllContractsByUserSID($user_sid); } else { $productInfo = SJB_ProductsManager::getProductInfoBySID($productToChange); $listingNumber = SJB_Request::getVar('number_of_listings', null); if (is_null($listingNumber) && !empty($productInfo['number_of_listings'])) { $listingNumber = $productInfo['number_of_listings']; } $contract = new SJB_Contract(array('product_sid' => $productToChange, 'numberOfListings' => $listingNumber, 'is_recurring' => 0)); $contract->setUserSID($user_sid); $contract->saveInDB(); if ($contract->isFeaturedProfile()) { SJB_UserManager::makeFeaturedBySID($user_sid); } } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'ban_ip': $cantBanUsers = array(); foreach ($users_sids as $user_sid => $value) { $user = SJB_UserManager::getUserInfoBySID($user_sid); if ($user['ip'] && !SJB_IPManager::getBannedIPByValue($user['ip'])) { SJB_IPManager::makeIPBanned($user['ip']); } else { $cantBanUsers[] = $user['username']; } } if ($cantBanUsers) { $tp->assign('cantBanUsers', $cantBanUsers); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); } break; case 'unban_ip': $cantUnbanIPs = array(); foreach ($users_sids as $user_sid => $value) { $user = SJB_UserManager::getUserInfoBySID($user_sid); if ($user['ip'] !== '') { if (SJB_IPManager::getBannedIPByValue($user['ip'])) { SJB_IPManager::makeIPEnabledByValue($user['ip']); } elseif (SJB_UserManager::checkBan($errors, $user['ip'])) { $cantUnbanIPs[] = $user['ip']; } } } if ($cantUnbanIPs) { $tp->assign('rangeIPs', $cantUnbanIPs); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); } break; default: unset($_REQUEST['restore']); break; } if (empty($errors)) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); } } /***************************************************************/ $_REQUEST['action'] = 'search'; $user = new SJB_User(array(), $userGroupSID); $user->addProperty(array('id' => 'user_group', 'type' => 'list', 'value' => '', 'is_system' => true, 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions())); $user->addProperty(array('id' => 'registration_date', 'type' => 'date', 'value' => '', 'is_system' => true)); $user->addProperty(array('id' => 'approval', 'caption' => 'Approval', 'type' => 'list', 'list_values' => array(array('id' => 'Pending', 'caption' => 'Pending'), array('id' => 'Approved', 'caption' => 'Approved'), array('id' => 'Rejected', 'caption' => 'Rejected')), 'length' => '10', 'is_required' => false, 'is_system' => true)); // get array of accessible products $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID); $products = array(); foreach ($productsSIDs as $key => $productSID) { $product = SJB_ProductsManager::getProductInfoBySID($productSID); $products[$key] = $product; if (!empty($product['pricing_type']) && $product['pricing_type'] == 'volume_based' && !empty($product['volume_based_pricing'])) { $volumeBasedPricing = $product['volume_based_pricing']; $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[] = $i; } $products[$key]['count_listings'] = $countListings; } } $user->addProperty(array('id' => 'product', 'type' => 'list', 'value' => '', 'list_values' => $products, 'is_system' => true)); $aliases = new SJB_PropertyAliases(); $aliases->addAlias(array('id' => 'user_group', 'real_id' => 'user_group_sid', 'transform_function' => 'SJB_UserGroupManager::getUserGroupSIDByID')); $aliases->addAlias(array('id' => 'product', 'real_id' => 'product_sid')); $_REQUEST['user_group']['equal'] = $userGroupSID; $search_form_builder = new SJB_SearchFormBuilder($user); $criteria_saver = new SJB_UserCriteriaSaver(); if (isset($_REQUEST['restore'])) { $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria()); } $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user); $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($tp); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID); if (SJB_Request::getVar('online', '') == '1') { $tp->assign("online", true); } $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('products', $products); $tp->assign('selectedProduct', isset($_REQUEST['product']['simple_equal']) ? $_REQUEST['product']['simple_equal'] : ''); $tp->display($searchTemplate); /********************** S O R T I N G *********************/ $paginator = new SJB_UsersPagination($userGroupInfo, SJB_Request::getVar('online', ''), $template); $firstLastName = ''; if (!empty($_REQUEST['FirstName']['equal'])) { $name['FirstName']['any_words'] = $name['LastName']['any_words'] = $_REQUEST['FirstName']['equal']; $firstLastName = $_REQUEST['FirstName']; unset($_REQUEST['FirstName']); $_REQUEST['FirstName']['fields_or'] = $name; } $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user); $inner_join = false; // if search by product field if (isset($_REQUEST['product']['simple_equal']) && $_REQUEST['product']['simple_equal'] != '') { $inner_join = array('contracts' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'INNER JOIN')); } if (SJB_Request::getVar('online', '') == '1') { $maxLifeTime = ini_get("session.gc_maxlifetime"); $currentTime = time(); $innerJoinOnline = array('user_session_data_storage' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'select_field' => 'session_id', 'join' => 'INNER JOIN', 'where' => "AND unix_timestamp(`user_session_data_storage`.`last_activity`) + {$maxLifeTime} > {$currentTime}")); if ($inner_join) { $inner_join = array_merge($inner_join, $innerJoinOnline); } else { $inner_join = $innerJoinOnline; } } $searcher = new SJB_UserSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder, $inner_join); $found_users = array(); $found_users_sids = array(); if (SJB_Request::getVar('action', '') == 'search') { $found_users = $searcher->getObjectsSIDsByCriteria($criteria, $aliases); $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs()); } elseif (isset($_REQUEST['restore'])) { $found_users = $criteria_saver->getObjectsFromSession(); } foreach ($found_users as $id => $userID) { $user_info = SJB_UserManager::getUserInfoBySID($userID); $contractInfo = SJB_ContractManager::getAllContractsInfoByUserSID($user_info['sid']); $user_info['products'] = count($contractInfo); $found_users[$id] = $user_info; } $paginator->setItemsCount($searcher->getAffectedRows()); $sorted_found_users_sids = $found_users_sids; /****************************************************************/ $tp->assign("userGroupInfo", $userGroupInfo); $tp->assign("found_users", $found_users); $searchFields = ''; foreach ($_REQUEST as $key => $val) { if (is_array($val)) { foreach ($val as $fieldName => $fieldValue) { if (is_array($fieldValue)) { foreach ($fieldValue as $fieldSubName => $fieldSubValue) { $searchFields .= "&{$key}[{$fieldSubName}]=" . array_pop($fieldSubValue); } } else { $searchFields .= "&{$key}[{$fieldName}]={$fieldValue}"; } } } } $tp->assign('paginationInfo', $paginator->getPaginationInfo()); $tp->assign("searchFields", $searchFields); $tp->assign("found_users_sids", $sorted_found_users_sids); $tp->assign('errors', $errors); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listingTypeID = SJB_Request::getVar('listing_type_id'); $listingTypeSID = SJB_Request::getVar('listing_type'); if ($listingTypeID !== null) { $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID); } // SET PAGINATION AND SORTING VALUES $restore = SJB_Request::getVar('restore', false); $paginator = new SJB_FlaggedListingsPagination(); // FILTERS $filters = array(); $filters['title'] = SJB_Request::getVar('filter_title'); $filters['username'] = SJB_Request::getVar('filter_user'); $filters['flag'] = SJB_Request::getVar('filter_flag'); // check session for pagination settings $sessionFlaggedSettings = !is_null(SJB_Session::getValue('flagged_settings')) ? SJB_Session::getValue('flagged_settings') : false; if ($sessionFlaggedSettings !== false) { if (!$restore) { SJB_Session::setValue('flagged_settings', array('filters' => $filters)); } else { if (!$listingTypeSID && !empty($sessionFlaggedSettings['listing_type_sid'])) { $listingTypeSID = $sessionFlaggedSettings['listing_type_sid']; } $filters = $sessionFlaggedSettings['filters']; } } else { SJB_Session::setValue('flagged_settings', array('filters' => $filters)); } // DEFAULT SORTING // resolve flag to it text value for search $filterFlag = $filters['flag']; if (!empty($filterFlag) && is_numeric($filterFlag)) { $result = SJB_DB::query('SELECT * FROM `flag_listing_settings` WHERE `sid` = ?n LIMIT 1', $filterFlag); if (!empty($result)) { $filters['flag_reason'] = $result[0]['value']; } } ////////////////////// ACTIONS $action = SJB_Request::getVar('action_name'); $flagSIDs = SJB_Request::getVar('flagged'); if (!empty($flagSIDs)) { switch ($action) { case 'remove': foreach ($flagSIDs as $sid => $val) { SJB_ListingManager::removeFlagBySID($sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); break; case 'deactivate': foreach ($flagSIDs as $sid => $val) { SJB_ListingManager::deactivateListingByFlagSID($sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); break; case 'delete': foreach ($flagSIDs as $sid => $val) { SJB_ListingManager::deleteListingByFlagSID($sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); break; } } //////////////////////// OUTPUT $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); $allFlags = SJB_ListingManager::getAllFlags(); $countFlaggedListings = SJB_ListingManager::getFlagsNumberByListingTypeSID($listingTypeSID, $filters); $paginator->setItemsCount($countFlaggedListings); $flaggedListings = SJB_ListingManager::getFlaggedListings($listingTypeSID, $paginator->currentPage, $paginator->itemsPerPage, $paginator->sortingField, $paginator->sortingOrder, $filters); if (empty($flaggedListings) && $paginator->currentPage != 1) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); } foreach ($flaggedListings as $key => $val) { $listingInfo = SJB_ListingManager::getListingInfoBySID($val['listing_sid']); $listingUser = SJB_UserManager::getUserInfoBySID($listingInfo['user_sid']); $flaggedUser = SJB_UserManager::getUserInfoBySID($val['user_sid']); $flaggedListings[$key]['listing_info'] = $listingInfo; $flaggedListings[$key]['user_info'] = $listingUser; $flaggedListings[$key]['flagged_user'] = $flaggedUser; } $tp->assign('paginationInfo', $paginator->getPaginationInfo()); $tp->assign('listing_types', $allListingTypes); $tp->assign('listings', $flaggedListings); $tp->assign('listing_type_sid', $listingTypeSID); $tp->assign('all_flags', $allFlags); $tp->assign('filters', $filters); $tp->display('flagged_listings.tpl'); }
/** * @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); } } }
/** * Можно ли? * @param $resource * @param $roleId */ public function isAllowed($resource, $roleId = null, $type = 'user', $returnParams = false, $returnMessage = false) { $resource = strtolower($resource); $userInfo = array(); if (null === $roleId) { // если не задан пользователь, то попробуем использовать текущего $userInfo = SJB_UserManager::getCurrentUserInfo(); if (!empty($userInfo)) { $roleId = $userInfo['sid']; } if (null === $roleId) { if (SJB_Admin::admin_authed() && SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == 'admin') { if ($returnParams) { return ''; } if ($returnMessage) { return ''; } return true; } $roleId = 'guest'; } } else { $cacheId = 'SJB_Acl::SJB_UserManager::getUserInfoBySID' . $roleId; if (SJB_MemoryCache::has($cacheId)) { $userInfo = SJB_MemoryCache::get($cacheId); } else { $userInfo = SJB_UserManager::getUserInfoBySID($roleId); SJB_MemoryCache::set($cacheId, $userInfo); } } $role = $type . '_' . $roleId; if ($resource == 'use_screening_questionnaires' && intval($userInfo['parent_sid']) > 0) { if ($this->isAllowed($resource, $userInfo['parent_sid'])) { return $this->isAllowed('subuser_use_screening_questionnaires', $userInfo['sid']); } return false; } if (!isset($this->permissions[$role])) { switch ($type) { case 'user': case 'guest': if ($roleId == 'guest' || $type == 'guest') { $role = 'user_guest'; if (empty($this->permissions[$role])) { $this->permissions[$role] = $this->getPermissions('guest', 'guest'); } } else { $permissions = $this->getPermissions('user', $roleId); $groupPermissions = $this->getPermissions('group', $userInfo['user_group_sid']); $this->permissions['group_' . $userInfo['user_group_sid']] = $groupPermissions; $contracts = SJB_ContractManager::getAllContractsSIDsByUserSID($roleId); if (!empty($contracts)) { foreach ($contracts as $contract) { $contractPermissions = $this->mergePermissionsWithGroup($this->getPermissions('contract', $contract), $groupPermissions); $this->permissions['contract_' . $contract] = $contractPermissions; $permissions = $this->mergePermissions($contractPermissions, $permissions); } } else { $permissions = $this->mergePermissionsWithGroup($permissions, $groupPermissions); } $this->permissions[$role] = $permissions; } break; case 'group': $this->permissions[$role] = $this->getPermissions($type, $roleId); break; case 'product': $productInfo = SJB_ProductsManager::getProductInfoBySID($roleId); if (!empty($productInfo['user_group_sid'])) { $groupRole = 'group_' . $productInfo['user_group_sid']; if (empty($this->permissions[$groupRole])) { $this->permissions[$groupRole] = $this->getPermissions('group', $productInfo['user_group_sid']); } $this->permissions[$role] = $this->mergePermissionsWithGroup($this->getPermissions('product', $roleId), $this->permissions[$groupRole]); } else { $this->permissions[$role] = $this->getPermissions('product', $roleId); } break; case 'contract': $this->permissions[$role] = $this->getPermissions('contract', $roleId); break; } } if (!isset($userInfo)) { $userInfo = SJB_UserManager::getCurrentUserInfo(); } $is_display_resume = !preg_match_all("/.*\\/(?:display_resume|display_job)\\/(\\d*)/i", $_SERVER['REQUEST_URI'], $match) ? isset($_SERVER['REDIRECT_URL']) ? preg_match_all("/.*\\/(?:display_resume|display_job)\\/(\\d*)/i", $_SERVER['REDIRECT_URL'], $match) : false : true; // Allow access to Resume/Job Details page if an employer has an application linked to the resume if (isset($userInfo) && $is_display_resume) { $apps = SJB_DB::query("SELECT `a`.resume FROM `applications` `a`\n\t\t\t\t\t\t INNER JOIN `listings` l ON\n\t\t\t\t\t\t `l`.`sid` = `a`.`listing_id`\n\t\t\t\t\t\t WHERE `l`.`user_sid` = ?n AND `a`.`show_emp` = 1 ORDER BY a.`date` DESC", $userInfo['sid']); if (isset($match[1]) && in_array(array("resume" => array_pop($match[1])), $apps)) { $this->permissions[$role][$resource]['value'] = 'allow'; $this->permissions[$role][$resource]['params'] = ''; } } if ($returnParams) { return empty($this->permissions[$role][$resource]['params']) ? '' : $this->permissions[$role][$resource]['params']; } elseif ($returnMessage) { $message = empty($this->permissions[$role][$resource]['message']) ? '' : $this->permissions[$role][$resource]['message']; if (!$message) { if (!empty($userInfo)) { $groupRole = 'group_' . $userInfo['user_group_sid']; $message = empty($this->permissions[$groupRole][$resource]['message']) ? '' : $this->permissions[$groupRole][$resource]['message']; } } return $message; } return isset($this->permissions[$role][$resource]['value']) && $this->permissions[$role][$resource]['value'] == 'allow'; }
public function execute() { $acl = SJB_Acl::getInstance(); $type = SJB_Request::getVar('type', ''); $role = SJB_Request::getVar('role', ''); $tp = SJB_System::getTemplateProcessor(); $resources = $acl->getResources(); $form_submitted = SJB_Request::getVar('action'); if ($form_submitted) { SJB_Acl::clearPermissions($type, $role); foreach ($resources as $name => $resource) { $params = SJB_Request::getVar($name . '_params'); $message = ''; if (SJB_Request::getVar($name) == 'deny') { $params = SJB_Request::getVar($name . '_params1'); if ($params == 'message') { $message = SJB_Request::getVar($name . '_message'); } } SJB_Acl::allow($name, $type, $role, SJB_Request::getVar($name, ''), $params, SJB_Request::getVar($name . '_message')); } if ($type == 'plan' && SJB_Request::getVar('update_users', 0) == 1) { $contracts = SJB_ContractManager::getAllContractsByMemebershipPlanSID($role); foreach ($contracts as $contract_id) { SJB_Acl::clearPermissions('contract', $contract_id['id']); SJB_DB::query("insert into `permissions` (`type`, `role`, `name`, `value`, `params`, `message`)" . " select 'contract', ?s, `name`, `value`, `params`, `message` from `permissions` " . " where `type` = 'plan' and `role` = ?s", $contract_id['id'], $role); } } if ($form_submitted == 'save') { switch ($type) { case 'group': $parameter = "/edit-user-group/?sid=" . $role; break; case 'guest': $parameter = "/user-groups/"; break; } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . $parameter); } } $acl = SJB_Acl::getInstance(true); $resources = $acl->getResources($type); $perms = SJB_DB::query('select * from `permissions` where `type` = ?s and `role` = ?s', $type, $role); foreach ($resources as $key => $resource) { $resources[$key]['value'] = 'inherit'; $resources[$key]['name'] = $key; foreach ($perms as $perm) { if ($key == $perm['name']) { $resources[$key]['value'] = $perm['value']; $resources[$key]['params'] = $perm['params']; $resources[$key]['message'] = $perm['message']; break; } } } $tp->assign('resources', $resources); $tp->assign('type', $type); $tp->assign('listingTypes', SJB_ListingTypeManager::getAllListingTypesInfo()); $tp->assign('role', $role); switch ($type) { case 'group': $tp->assign('userGroupInfo', SJB_UserGroupManager::getUserGroupInfoBySID($role)); break; case 'user': $userInfo = SJB_UserManager::getUserInfoBySID($role); $tp->assign('userGroupInfo', SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid'])); break; } $tp->display('acl.tpl'); }
public static function sendNewPrivateMessageLetter($user_id, $sender_id, $message, $cc = false) { $user = SJB_UserManager::getObjectBySID($user_id); $userGroupSID = $user->getUserGroupSID(); $emailTplSID = SJB_UserGroupManager::getEmailTemplateSIDByUserGroupAndField($userGroupSID, 'notify_on_private_message'); $userInfo = SJB_UserManager::createTemplateStructureForUser($user); $sender = SJB_UserManager::getObjectBySID($sender_id); $sender = SJB_UserManager::createTemplateStructureForUser($sender); $data = array('recipient' => $userInfo, 'sender' => $sender, 'message' => $message); $email = SJB_EmailTemplateEditor::getEmail($userInfo['email'], $emailTplSID, $data); if (!empty($cc)) { $cc = SJB_UserManager::getUserInfoBySID($cc); if (!empty($cc)) { $email->addCC($cc['email']); } } return $email->send('Send private message'); }
/** * define displayName ("Message to" field ) for Private Messages * @param string|integer $to * @param string $displayName * @return string or null */ public static function getComposeDisplayName($to, &$displayName) { if (empty($to)) { return null; } // by user's id $oReceiverInfo = SJB_UserManager::getUserInfoBySID((int) $to); // by username if (is_null($oReceiverInfo)) { $oReceiverInfo = SJB_UserManager::getUserInfoByUserName($to); } // Message to: отображать там если есть то CompanyName // если нет, то FirstName LastName // если нет и того ни другого, то можно написать username if (!empty($oReceiverInfo['CompanyName'])) { $displayName = $oReceiverInfo['CompanyName']; } elseif (!empty($oReceiverInfo['FirstName'])) { $displayName = $oReceiverInfo['FirstName'] . (!empty($oReceiverInfo['LastName']) ? ' ' . $oReceiverInfo['LastName'] : ''); } elseif (!empty($oReceiverInfo['username'])) { $displayName = $oReceiverInfo['username']; } }
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'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $template = 'edit_invoice.tpl'; $errors = array(); $invoiceErrors = array(); $invoiceSID = SJB_Request::getVar('sid', false); $action = SJB_Request::getVar('action', false); $tcpdfError = SJB_Request::getVar('error', false); if ($tcpdfError) { $invoiceErrors[] = $tcpdfError; } $invoiceInfo = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSID); $user_structure = null; if ($invoiceInfo) { $product_info = array(); if (array_key_exists('custom_info', $invoiceInfo['items'])) { $product_info = $invoiceInfo['items']['custom_info']; } $invoiceInfo = array_merge($invoiceInfo, $_REQUEST); $invoiceInfo['items']['custom_info'] = $product_info; $includeTax = $invoiceInfo['include_tax']; $invoice = new SJB_Invoice($invoiceInfo); $invoice->setSID($invoiceSID); $userSID = $invoice->getPropertyValue('user_sid'); $userExists = SJB_UserManager::isUserExistsByUserSid($userSID); $subUserSID = $invoice->getPropertyValue('subuser_sid'); if (!empty($subUserSID)) { $userInfo = SJB_UserManager::getUserInfoBySID($subUserSID); $username = $userInfo['username'] . '/' . $userInfo['email']; } else { $userInfo = SJB_UserManager::getUserInfoBySID($userSID); $username = $userInfo['FirstName'] . ' ' . $userInfo['LastName'] . ' ' . $userInfo['ContactName'] . ' ' . $userInfo['CompanyName'] . '/' . $userInfo['email']; } $taxInfo = $invoice->getPropertyValue('tax_info'); $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']); $products = array(); foreach ($productsSIDs as $key => $productSID) { $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { $volumeBasedPricing = $productInfo['volume_based_pricing']; $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[$i]['number_of_listings'] = $i; for ($j = 1; $j <= count($volumeBasedPricing['listings_range_from']); $j++) { if ($i >= $volumeBasedPricing['listings_range_from'][$j] && $i <= $volumeBasedPricing['listings_range_to'][$j]) { $countListings[$i]['price'] = $volumeBasedPricing['price_per_unit'][$j]; } } } $productInfo['count_listings'] = $countListings; } $products[$key] = $productInfo; } $addForm = new SJB_Form($invoice); $addForm->registerTags($tp); $tp->assign('userExists', $userExists); $tp->assign('products', $products); $tp->assign('invoice_sid', $invoiceSID); $tp->assign('include_tax', $includeTax); $tp->assign('username', trim($username)); if ($action) { switch ($action) { case 'save': case 'apply': $invoiceErrors = $invoice->isValid(); if (empty($invoiceErrors) && $addForm->isDataValid($errors)) { $invoice->setFloatNumbersIntoValidFormat(); SJB_InvoiceManager::saveInvoice($invoice); if ($action == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/manage-invoices/'); } } else { $invoiceDate = SJB_I18N::getInstance()->getInput('date', $invoice->getPropertyValue('date')); $invoice->setPropertyValue('date', $invoiceDate); } $invoice->setFloatNumbersIntoValidFormat(); $taxInfo['tax_amount'] = SJB_I18N::getInstance()->getInput('float', $taxInfo['tax_amount']); break; case 'print': case 'download_pdf_version': $user = SJB_UserManager::getObjectBySID($userSID); $user_structure = SJB_UserManager::createTemplateStructureForUser($user); $template = 'print_invoice.tpl'; $username = SJB_Array::get($user_structure, 'CompanyName') . ' ' . SJB_Array::get($user_structure, 'FirstName') . ' ' . SJB_Array::get($user_structure, 'LastName'); $tp->assign('username', trim($username)); $tp->assign('user', $user_structure); $tp->assign('tax', $taxInfo); if ($action == 'download_pdf_version') { $template = 'invoice_to_pdf.tpl'; $filename = 'invoice_' . $invoiceSID . '.pdf'; try { SJB_HelperFunctions::html2pdf($tp->fetch($template), $filename); exit; } catch (Exception $e) { SJB_Error::writeToLog($e->getMessage()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/edit-invoice/?sid=' . $invoiceSID . '&error=TCPDF_ERROR'); } } break; case 'send_invoice': $result = SJB_Notifications::sendInvoiceToCustomer($invoiceSID, $userSID); if ($result) { echo SJB_I18N::getInstance()->gettext("Backend", "Invoice successfully sent"); } else { echo SJB_I18N::getInstance()->gettext("Backend", "Invoice not sent"); } exit; break; } } $transactions = SJB_TransactionManager::getTransactionsByInvoice($invoiceSID); $tp->assign('tax', $taxInfo); $tp->assign('transactions', $transactions); } else { $tp->assign('action', 'edit'); $errors[] = 'WRONG_INVOICE_ID_SPECIFIED'; $template = 'errors.tpl'; } $tp->assign("errors", array_merge($errors, $invoiceErrors)); $tp->display($template); }