Ejemplo n.º 1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $listingTypeID = SJB_Request::getVar('listing_type_id', '');
     if (SJB_UserManager::isUserLoggedIn()) {
         if (!SJB_Acl::getInstance()->isAllowed('save_' . trim($listingTypeID))) {
             $errors[] = 'DENIED_VIEW_SAVED_LISTING';
         }
         if (!$errors) {
             $userSid = SJB_UserManager::getCurrentUserSID();
             if (SJB_Request::getVar('action', '') == 'delete') {
                 $listing_id = SJB_Request::getVar('listing_id', null);
                 if (!is_null($listing_id)) {
                     foreach ($listing_id as $key => $value) {
                         SJB_SavedListings::deleteListingFromDBBySID($key, $userSid);
                     }
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . SJB_Navigator::getURI());
                 }
             }
             $saved_listings_id = SJB_SavedListings::getSavedListingsFromDB($userSid);
             $listings_structure = array();
             $listing_structure_meta_data = array();
             foreach ($saved_listings_id as $saved_listing) {
                 $saved_listing_id = $saved_listing['listing_sid'];
                 $listing = SJB_ListingManager::getObjectBySID($saved_listing_id);
                 if (is_null($listing)) {
                     continue;
                 }
                 $listing->addPicturesProperty();
                 $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
                 $listings_structure[$listing->getID()] = $listing_structure;
                 $listings_structure[$listing->getID()]['saved_listing'] = $saved_listing;
                 if (isset($listing_structure['METADATA'])) {
                     $listing_structure_meta_data = array_merge($listing_structure_meta_data, $listing_structure['METADATA']);
                 }
             }
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure_meta_data)));
             $tp->assign("listings", $listings_structure);
             $tp->assign("listing_type_id", $listingTypeID);
             $tp->display("saved_listings.tpl");
         } else {
             $tp->assign("errors", $errors);
             $tp->display("save_search_failed.tpl");
         }
     } else {
         $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/system/classifieds" . SJB_System::getURI());
         switch ($listingTypeID) {
             case 'job':
                 $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/saved-jobs/");
                 break;
             case 'resume':
                 $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/saved-resumes/");
                 break;
         }
         $tp->assign("return_url", $url);
         $tp->display("../users/login.tpl");
     }
 }
Ejemplo n.º 2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listing_types = SJB_ListingTypeManager::getAllListingTypesInfo();
     $countListings = array();
     foreach ($listing_types as $type) {
         $requested_data = array();
         $requested_data['action'] = 'search';
         $requested_data['active']['equal'] = '1';
         $requested_data['listing_type']['equal'] = $type['id'];
         $requireApprove = SJB_ListingTypeManager::getWaitApproveSettingByListingType($type['sid']);
         if ($requireApprove) {
             $requested_data['status']['equal'] = 'approved';
         }
         $listing = new SJB_Listing(array(), $type['sid']);
         $id_alias_info = $listing->addIDProperty();
         $listing->addActivationDateProperty();
         $username_alias_info = $listing->addUsernameProperty();
         $listing_type_id_info = $listing->addListingTypeIDProperty();
         $listing->addCompanyNameProperty();
         if ($type['id'] == 'Resume') {
             $requested_data['access_type'] = array('accessible' => SJB_UserManager::getCurrentUserSID());
         }
         $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($requested_data, $listing);
         $aliases = new SJB_PropertyAliases();
         $aliases->addAlias($id_alias_info);
         $aliases->addAlias($username_alias_info);
         $aliases->addAlias($listing_type_id_info);
         $searcher = new SJB_ListingSearcher();
         $countListings[$type['id']] = $searcher->countRowsByCriteria($criteria, $aliases);
     }
     $tp->assign('listings_types', $countListings);
     $tp->display('count_listings.tpl');
 }
Ejemplo n.º 3
0
 public function execute()
 {
     $count_listing = SJB_Request::getVar('count_listing', 10);
     $listings_structure = array();
     $listing_structure_meta_data = array();
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_sid = SJB_UserManager::getCurrentUserSID();
         $viewed_listings = SJB_UserManager::getRecentlyViewedListingsByUserSid($user_sid, $count_listing);
         if (count($viewed_listings)) {
             foreach ($viewed_listings as $viewed_listing) {
                 $listing = SJB_ListingManager::getObjectBySID($viewed_listing['listing_sid']);
                 if (empty($listing)) {
                     continue;
                 }
                 $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
                 $listings_structure[] = $listing_structure;
                 if (isset($listing_structure['METADATA'])) {
                     $listing_structure_meta_data = array_merge($listing_structure_meta_data, $listing_structure['METADATA']);
                 }
             }
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure_meta_data)));
             $tp->assign("listings", $listings_structure);
         }
         $tp->display('recently_viewed_listings.tpl');
     }
 }
Ejemplo n.º 4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         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));
         $messagesPerPage = SJB_Request::getInt('messagesPerPage', 10);
         $total = SJB_PrivateMessage::getTotalOutbox($user_id);
         $totalPages = ceil($total / $messagesPerPage);
         if ($totalPages == 0) {
             $totalPages = 1;
         }
         if (empty($page) || $page <= 0) {
             $page = 1;
         }
         if ($totalPages < $page) {
             SJB_HelperFunctions::redirect("?page={$totalPages}");
         }
         $list = SJB_PrivateMessage::getListOutbox($user_id, $page, $messagesPerPage);
         $tp->assign('message_list', $list);
         $tp->assign('messagesPerPage', $messagesPerPage);
         $tp->assign('page', $page);
         $tp->assign('totalPages', $totalPages);
         $tp->assign('include', 'list_outbox.tpl');
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
     }
     $tp->display('main.tpl');
 }
Ejemplo n.º 5
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $errors = array();
         $id = SJB_Request::getInt('id', 0, 'GET');
         $action = SJB_Request::getVar('action', '', 'GET');
         if ($id > 0) {
             // read message
             if (SJB_PrivateMessage::isMyMessage($id)) {
                 if ($action == 'delete') {
                     SJB_PrivateMessage::delete(array($id));
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                 }
                 $message = SJB_PrivateMessage::readMessage($id);
                 SJB_Authorization::updateCurrentUserSession();
                 $current_user_info = SJB_UserManager::createTemplateStructureForCurrentUser();
                 $current_user_info['logged_in'] = true;
                 $current_user_info['new_messages'] = SJB_PrivateMessage::getCountUnreadMessages($current_user_info['id']);
                 SJB_System::setCurrentUserInfo($current_user_info);
                 $tp->assign('message', $message);
                 $tp->assign('include', 'message_detail.tpl');
             } else {
                 $errors['NOT_EXISTS_MESSAGE'] = 1;
             }
         }
         $tp->assign('errors', $errors);
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
         $tp->display('main.tpl');
     } else {
         $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis()));
         $tp->display('../users/login.tpl');
     }
 }
Ejemplo n.º 6
0
 public static function addStatistics($event, $type = '', $objectSID = 0, $unique = false, $featured = 0, $priority = 0, $userSID = false, $price = 0, $plugin = '', $reactivate = 0)
 {
     if (!$userSID) {
         $userSID = SJB_UserManager::getCurrentUserSID();
         $userSID = $userSID ? $userSID : 0;
     }
     $IP = $_SERVER['REMOTE_ADDR'];
     $params = array('ip' => $IP, 'type' => $type, 'event' => $event, 'date' => 'YEAR(CURDATE()) = YEAR(`date`) AND DAYOFYEAR(CURDATE()) = DAYOFYEAR(`date`)', 'object_sid' => $objectSID, 'limit' => 1, 'price' => $price);
     if (!in_array($event, array('siteView', 'viewMobileVersion'))) {
         $params['user_sid'] = $userSID;
     }
     $browsingEvents = array('viewListing', 'siteView', 'partneringSites', 'showInSearchResults');
     if (SJB_Request::isBot() && in_array($event, $browsingEvents)) {
         return false;
     } else {
         if ($statistics = self::getStatistics($params)) {
             $statistics = array_pop($statistics);
             if (!$unique) {
                 SJB_DB::query("UPDATE `statistics` SET `count` = ?n WHERE `sid` = ?n", ++$statistics['count'], $statistics['sid']);
             } elseif ($userSID && $statistics['user_sid'] == 0) {
                 SJB_DB::query("UPDATE `statistics` SET `user_sid` = ?n WHERE `sid` = ?n", $userSID, $statistics['sid']);
             }
         } else {
             SJB_DB::query("INSERT INTO `statistics` (`user_sid`, `ip`, `event`, `object_sid`, `type`, `date`, `featured`, `priority`, `reactivate`, `price`, `plugin`) VALUES (?n, ?s, ?s, ?n, ?s, NOW(), ?n, ?n, ?n, ?f, ?s)", $userSID, $IP, $event, $objectSID, $type, $featured, $priority, $reactivate, $price, $plugin);
         }
         return true;
     }
 }
Ejemplo n.º 7
0
 function getPropertyVariablesToAssign()
 {
     $profile_field_as_dv = '';
     if (isset($this->property_info['profile_field_as_dv']) && $this->property_info['profile_field_as_dv'] != '') {
         $profile_field_as_dv = SJB_UserManager::getSystemPropertyValueByObjectSID('users', SJB_UserManager::getCurrentUserSID(), $this->property_info['profile_field_as_dv']);
     }
     return array('id' => $this->property_info['id'], 'useAutocomplete' => $this->property_info['use_autocomplete'], 'type' => $this->property_info['type'], 'isClassifieds' => $this->property_info['is_classifieds'], 'value' => $this->property_info['value'], 'default_value' => $this->property_info['default_value'], 'profile_field_as_dv' => $profile_field_as_dv);
 }
Ejemplo n.º 8
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $unread = SJB_PrivateMessage::getCountUnreadMessages($user_id);
         $tp->assign('unread', $unread);
         $tp->assign('include', '');
     }
     $tp->display('main.tpl');
 }
Ejemplo n.º 9
0
 private function jsRate()
 {
     if (!SJB_UserManager::isUserLoggedIn()) {
         exit;
     }
     $listing_sid = SJB_Request::getInt('listing', 0, SJB_Request::METHOD_POST);
     $rate = SJB_Request::getInt('rate', 0, SJB_Request::METHOD_POST);
     $new_rating = SJB_Rating::setRaiting($rate, $listing_sid, SJB_UserManager::getCurrentUserSID());
     if (isset($new_rating['rating'])) {
         echo $new_rating['rating'];
     }
 }
Ejemplo n.º 10
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int');
     $listingType = SJB_Request::getVar('listing_type', null);
     if (!$listingType) {
         if ($listingId) {
             $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
             $listingType = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
         } else {
             $listingType = 'job';
         }
     }
     $displayForm = SJB_Request::getVar('displayForm', false);
     $error = null;
     if (!SJB_Acl::getInstance()->isAllowed('save_' . trim($listingType))) {
         $error = 'DENIED_SAVE_LISTING';
     }
     if (SJB_UserManager::isUserLoggedIn()) {
         if (!$error) {
             if (!is_null($listingId)) {
                 if (SJB_UserManager::isUserLoggedIn()) {
                     SJB_SavedListings::saveListingOnDB($listingId, SJB_UserManager::getCurrentUserSID());
                     SJB_Statistics::addStatistics('saveListing', SJB_ListingTypeManager::getListingTypeSIDByID($listingType), $listingId);
                 } else {
                     SJB_SavedListings::saveListingInCookie($listingId);
                 }
                 $template_processor->assign('saved_listing', SJB_SavedListings::getSavedListingsByUserAndListingSid(SJB_UserManager::getCurrentUserSID(), $listingId));
             } else {
                 $error = 'LISTING_ID_NOT_SPECIFIED';
             }
         }
         $params = SJB_Request::getVar('params', false);
         $searchId = SJB_Request::getVar('searchId', false);
         $page = SJB_Request::getVar('page', false);
         $template_processor->assign("params", $params);
         $template_processor->assign("searchId", $searchId);
         $template_processor->assign("page", $page);
         $template_processor->assign("listing_type", $listingType);
         $template_processor->assign("listing_sid", $listingId);
         $template_processor->assign("from_login", SJB_Request::getVar("from_login", false));
         $template_processor->assign("error", $error);
         $template_processor->assign("displayForm", $displayForm);
         $template_processor->assign("view", SJB_Request::getVar('view'));
         $template_processor->display("save_listing.tpl");
     } else {
         $template_processor->assign("return_url", base64_encode(SJB_Navigator::getURIThis() . "&from_login=1"));
         $template_processor->assign("ajaxRelocate", true);
         $template_processor->display("../users/login.tpl");
     }
 }
Ejemplo n.º 11
0
 public function execute()
 {
     $listing_id = SJB_Request::getVar('listing_id', null);
     $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id);
     $field_id = SJB_Request::getVar('field_id', null);
     $current_user_sid = SJB_UserManager::getCurrentUserSID();
     $owner_sid = SJB_ListingManager::getUserSIDByListingSID($listing_id);
     $errors = array();
     $complexEmun = SJB_Request::getVar('complexEnum', null, 'GET');
     $complexFieldID = SJB_Request::getVar('complexParent', null, 'GET');
     if (!is_null($complexEmun) && !is_null($complexFieldID)) {
         $fieldArr = array();
         array_push($fieldArr, $complexFieldID);
         array_push($fieldArr, $field_id);
         array_push($fieldArr, $complexEmun);
         $field_id = $complexFieldID . ':' . $field_id . $complexEmun . '_' . $listing_id;
     } else {
         $fieldArr = explode(':', $field_id);
         $complexEmun = isset($fieldArr[2]) ? explode('_', $fieldArr[2]) : false;
         $complexEmun = $complexEmun ? $complexEmun[0] : false;
     }
     if (is_null($listing_id) || is_null($field_id)) {
         $errors['PARAMETERS_MISSED'] = 1;
     } else {
         if (is_null($listing_info) || $complexEmun === false || !isset($listing_info[$fieldArr[0]][$fieldArr[1]][$complexEmun])) {
             $errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
         } else {
             if ($owner_sid != $current_user_sid) {
                 $errors['NOT_OWNER'] = 1;
             } else {
                 $uploaded_file_id = $listing_info[$fieldArr[0]][$fieldArr[1]][$complexEmun];
                 SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id);
                 $listing_info[$field_id] = '';
                 $listing = new SJB_Listing($listing_info, $listing_info['listing_type_sid']);
                 $props = $listing->getProperties();
                 foreach ($props as $prop) {
                     if ($prop->getID() !== $field_id) {
                         $listing->deleteProperty($prop->getID());
                     }
                 }
                 $listing->setSID($listing_id);
                 SJB_ListingManager::saveListing($listing);
             }
         }
     }
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('errors', $errors);
     $tp->assign('listing_id', $listing_id);
     $tp->display('delete_uploaded_file.tpl');
 }
Ejemplo n.º 12
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $userSID = SJB_UserManager::getCurrentUserSID();
         $action = SJB_Request::getVar('pm_action', null);
         if ($action) {
             $checked = SJB_Request::getVar('pm_check', array(), 'POST');
             switch ($action) {
                 case 'delete':
                     SJB_PrivateMessage::deleteContact($userSID, $checked);
                     break;
                 case 'save_contact':
                     $error = '';
                     $contactSID = SJB_Request::getInt('user_id', 0);
                     SJB_PrivateMessage::saveContact($userSID, $contactSID, $error);
                     $tp->assign('error', $error);
                     $tp->display('contact_save.tpl');
                     return true;
                     break;
                 default:
                     break;
             }
         }
         $page = SJB_Request::getInt('page', 1, 'GET');
         $contactsPerPage = SJB_Request::getInt('contactsPerPage', 10);
         SJB_PrivateMessage::deleteNonexistentContacts($userSID);
         $total = SJB_PrivateMessage::getTotalContacts($userSID);
         $totalPages = ceil($total / $contactsPerPage);
         if ($totalPages == 0) {
             $totalPages = 1;
         }
         if (empty($page) || $page <= 0) {
             $page = 1;
         }
         if ($totalPages < $page) {
             SJB_HelperFunctions::redirect("?page={$totalPages}");
         }
         $tp->assign('message_list', SJB_PrivateMessage::getContacts($userSID, $page, $contactsPerPage));
         $tp->assign('contactsPerPage', $contactsPerPage);
         $tp->assign('page', $page);
         $tp->assign('totalPages', $totalPages);
         $tp->assign('include', 'contacts.tpl');
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($userSID));
     }
     $tp->display('main.tpl');
 }
 /**
  * @param $invoice
  * @return bool
  */
 private function invoiceValidation($invoice)
 {
     if ($invoice instanceof SJB_Invoice) {
         if (SJB_UserManager::getCurrentUserSID() != $invoice->getUserSID()) {
             SJB_FlashMessages::getInstance()->addError('NOT_OWNER');
             return false;
         } else {
             if ($invoice->getStatus() == SJB_Invoice::INVOICE_STATUS_PAID) {
                 SJB_FlashMessages::getInstance()->addError('INVOICE_ALREADY_PAID');
                 return false;
             }
         }
     } else {
         SJB_FlashMessages::getInstance()->addError('NOT_VALID_PAYMENT_ID');
         return false;
     }
     return true;
 }
Ejemplo n.º 14
0
 protected function _get_Captions_with_Counts_Grouped_by_Captions($request_data, array $listingSids = array())
 {
     $items = array();
     if (!empty($request_data[$this->field['field']]['tree'])) {
         $this->parent = $items = explode(',', $request_data[$this->field['field']]['tree']);
         $treeValues = $this->tree_values;
         $this->tree_values = array();
     }
     if (SJB_Settings::getValue('enableBrowseByCounter')) {
         $request_data['access_type'] = array('accessible' => SJB_UserManager::getCurrentUserSID());
         $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($request_data);
         $sqlTranslator = new SJB_SearchSqlTranslator('listings');
         $whereStatement = $sqlTranslator->_getWhereStatement($criteria);
         $sql = "`{$this->field['field']}` != ''";
         if (count($items) > 1) {
             $sql = " AND (";
             foreach ($items as $key => $item) {
                 if ($key == 0) {
                     $sql .= " FIND_IN_SET('{$item}',`{$this->field['field']}`) ";
                 } else {
                     $sql .= " OR FIND_IN_SET('{$item}',`{$this->field['field']}`) ";
                 }
                 if (isset($treeValues[$item])) {
                     $this->tree_values[$item] = $treeValues[$item];
                 }
             }
             $sql .= ")";
         }
         if (!empty($listingSids)) {
             $sql .= ' AND `listings`.`sid` IN (' . implode(',', $listingSids) . ')';
         }
         $sql = "SELECT `?w` AS caption, `sid` AS object_sid FROM `listings` {$whereStatement} AND {$sql}";
         $result = SJB_DB::query($sql, $this->field['field']);
         $result = self::_getCountsByItems($result);
     } else {
         if (count($items) > 1) {
             foreach ($items as $item) {
                 $this->tree_values[$item] = $treeValues[$item];
             }
         }
         $result = self::getTreeItems($this->tree_values, SJB_ListingFieldTreeManager::getTreeDepthBySID($this->field['sid']));
     }
     return $result;
 }
Ejemplo n.º 15
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'list');
     $sid = SJB_Request::getVar('sid', null, null, 'int');
     if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires')) {
         switch ($action) {
             case 'delete':
                 if (SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $sid)) {
                     SJB_ScreeningQuestionnaires::deleteQuestionnaireBySID($sid);
                 }
                 $action = 'list';
                 break;
         }
         $tp->assign('questionnaires', SJB_ScreeningQuestionnaires::getList(SJB_UserManager::getCurrentUserSID()));
         $tp->assign('action', $action);
         $tp->display('screening_questionnaires.tpl');
     }
 }
Ejemplo n.º 16
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $action = SJB_Request::getVar('pm_action', SJB_Request::METHOD_POST, false);
         if ($action) {
             $checked = SJB_Request::getVar('pm_check', SJB_Request::METHOD_POST, array());
             switch ($action) {
                 case 'mark':
                     SJB_PrivateMessage::markAsRead($checked);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                     break;
                 case 'delete':
                     SJB_PrivateMessage::delete($checked);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                     break;
                 default:
                     break;
             }
         }
         $page = SJB_Request::getInt('page', 1, 'GET');
         $messagesPerPage = SJB_Request::getInt('messagesPerPage', 10);
         $total = SJB_PrivateMessage::getTotalInbox($user_id);
         $totalPages = ceil($total / $messagesPerPage);
         if ($totalPages == 0) {
             $totalPages = 1;
         }
         if (empty($page) || $page <= 0) {
             $page = 1;
         }
         if ($totalPages < $page) {
             SJB_HelperFunctions::redirect("?page={$totalPages}");
         }
         $tp->assign('message_list', SJB_PrivateMessage::getListInbox($user_id, $page, $messagesPerPage));
         $tp->assign('include', 'list_inbox.tpl');
         $tp->assign('messagesPerPage', $messagesPerPage);
         $tp->assign('page', $page);
         $tp->assign('totalPages', $totalPages);
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
     }
     $tp->display('main.tpl');
 }
Ejemplo n.º 17
0
 function getPropertyVariablesToAssign()
 {
     $profileFieldAsDv = '';
     if (isset($this->property_info['profile_field_as_dv']) && $this->property_info['profile_field_as_dv'] != '') {
         if (!empty($this->property_info['user_sid'])) {
             $userSID = $this->property_info['user_sid'];
         } else {
             $userSID = SJB_UserManager::getCurrentUserSID();
         }
         if ($this->property_info['parentID']) {
             if (SJB_UserManager::issetFieldByName($this->property_info['parentID'] . '_' . $this->property_info['profile_field_as_dv'])) {
                 $profileFieldAsDv = SJB_UserManager::getSystemPropertyValueByObjectSID('users', $userSID, $this->property_info['parentID'] . '_' . $this->property_info['profile_field_as_dv']);
             }
         } else {
             $profileFieldAsDv = SJB_UserManager::getSystemPropertyValueByObjectSID('users', $userSID, $this->property_info['profile_field_as_dv']);
         }
     }
     return array('id' => $this->property_info['id'], 'useAutocomplete' => $this->property_info['use_autocomplete'], 'type' => $this->property_info['type'], 'isClassifieds' => $this->property_info['is_classifieds'], 'value' => SJB_HelperFunctions::getClearVariablesToAssign($this->property_info['value']), 'default_value' => $this->property_info['default_value'], 'profile_field_as_dv' => $profileFieldAsDv, 'hidden' => $this->property_info['hidden']);
 }
Ejemplo n.º 18
0
 function getPropertyVariablesToAssign()
 {
     $profile_field_as_dv = '';
     if (isset($this->property_info['profile_field_as_dv']) && $this->property_info['profile_field_as_dv'] != '') {
         if (!empty($this->property_info['user_sid'])) {
             $userSID = $this->property_info['user_sid'];
         } else {
             $userSID = SJB_UserManager::getCurrentUserSID();
         }
         if ($this->property_info['parentID']) {
             if (SJB_UserManager::issetFieldByName($this->property_info['parentID'] . "_" . $this->property_info['profile_field_as_dv'])) {
                 $profile_field_as_dv = SJB_UserManager::getSystemPropertyValueByObjectSID('users', $userSID, $this->property_info['parentID'] . "_" . $this->property_info['profile_field_as_dv']);
             }
         } else {
             $profile_field_as_dv = SJB_UserManager::getSystemPropertyValueByObjectSID('users', $userSID, $this->property_info['profile_field_as_dv']);
         }
     }
     return array('id' => $this->property_info['id'], 'value' => $this->property_info['value'] !== null ? SJB_HelperFunctions::getClearVariablesToAssign($this->property_info['value']) : null, 'default_value' => $this->property_info['default_value'], 'profile_field_as_dv' => $profile_field_as_dv, 'hidden' => $this->property_info['hidden']);
 }
Ejemplo n.º 19
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = null;
     if (SJB_UserManager::isUserLoggedIn()) {
         $userSID = SJB_UserManager::getCurrentUserSID();
         $contactSID = 0;
         $errors = array();
         if (isset($_REQUEST['passed_parameters_via_uri'])) {
             $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
             $contactSID = SJB_Array::get($passed_parameters_via_uri, 0);
         }
         if (!$contactSID) {
             $errors['UNDEFINED_CONTACT_ID'] = 1;
         } else {
             $contactInfo = SJB_PrivateMessage::getContactInfo($userSID, $contactSID);
             if (!$contactInfo) {
                 $errors['WRONG_CONTACT_ID_SPECIFIED'] = 1;
             } else {
                 $action = SJB_Request::getVar('action');
                 switch ($action) {
                     case 'save':
                         $note = SJB_Request::getVar('note');
                         $result = SJB_PrivateMessage::saveContactNote($userSID, $contactSID, $note);
                         if ($result) {
                             $tp->assign('noteSaved', true);
                         }
                         break;
                     default:
                         break;
                 }
             }
             $tp->assign('contactInfo', $contactInfo);
         }
         $tp->assign('errors', $errors);
     }
     if ($action) {
         $tp->assign('action', $action);
         $tp->display('notes.tpl');
     } else {
         $tp->display('contact.tpl');
     }
 }
Ejemplo n.º 20
0
 public function execute()
 {
     $listing_id = SJB_Request::getVar('listing_id', null);
     $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id);
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeIDBySID($listing_info['listing_type_sid']);
     $field_id = SJB_Request::getVar('field_id', null);
     $current_user_sid = SJB_UserManager::getCurrentUserSID();
     $owner_sid = SJB_ListingManager::getUserSIDByListingSID($listing_id);
     $errors = array();
     if (is_null($listing_id) || is_null($field_id)) {
         $errors['PARAMETERS_MISSED'] = 1;
     } else {
         if (is_null($listing_info) || !isset($listing_info[$field_id])) {
             $errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
         } else {
             if ($owner_sid != $current_user_sid) {
                 $errors['NOT_OWNER'] = 1;
             } else {
                 $uploaded_file_id = $listing_info[$field_id];
                 SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id);
                 $listing_info[$field_id] = '';
                 $listing = new SJB_Listing($listing_info, $listing_info['listing_type_sid']);
                 $props = $listing->getProperties();
                 foreach ($props as $prop) {
                     if ($prop->getID() !== $field_id) {
                         $listing->deleteProperty($prop->getID());
                     }
                 }
                 $listing->setSID($listing_id);
                 SJB_ListingManager::saveListing($listing);
             }
         }
     }
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('errors', $errors);
     $tp->assign('listing_id', $listing_id);
     $tp->assign('listingTypeSID', $listingTypeSID);
     $tp->display('delete_uploaded_file.tpl');
 }
Ejemplo n.º 21
0
 public function execute()
 {
     $user_info = SJB_UserManager::getCurrentUserInfo();
     $field_id = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : null;
     if (is_null($field_id)) {
         $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_info['email'] = array('original' => $user_info['email']);
         $user = new SJB_User($user_info, $user_info['user_group_sid']);
         $user->deleteProperty("active");
         $user->deleteProperty('password');
         $user->setSID(SJB_UserManager::getCurrentUserSID());
         SJB_UserManager::saveUser($user);
     }
     $template_processor = SJB_System::getTemplateProcessor();
     $template_processor->assign("errors", isset($errors) ? $errors : null);
     $template_processor->display("delete_uploaded_file.tpl");
 }
Ejemplo n.º 22
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn() === false) {
         $tp->assign('ERROR', 'NOT_LOGIN');
         $tp->display('../miscellaneous/error.tpl');
         return;
     }
     $appsSID = 0;
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $appsSID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     if (SJB_Applications::isUserOwnerApps(SJB_UserManager::getCurrentUserSID(), $appsSID)) {
         $apps_info = SJB_Applications::getBySID($appsSID);
         if (!empty($apps_info['questionnaire'])) {
             $questions = unserialize($apps_info['questionnaire']);
             $tp->assign('questions', $questions);
         }
         $tp->assign('apps_info', $apps_info);
         $tp->display('view_questionaire.tpl');
     }
 }
Ejemplo n.º 23
0
 public function execute()
 {
     $errors = array();
     $field_errors = array();
     $tp = SJB_System::getTemplateProcessor();
     $loggedIn = SJB_UserManager::isUserLoggedIn();
     $current_user_sid = SJB_UserManager::getCurrentUserSID();
     $controller = new SJB_SendListingInfoController($_REQUEST);
     $isDataSubmitted = false;
     $jobInfo = SJB_ListingManager::getListingInfoBySID($controller->getListingID());
     if ($controller->isListingSpecified()) {
         if ($controller->isDataSubmitted()) {
             if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors)) {
                 // получим уникальный id для файла в uploaded_files
                 $file_id_current = 'application_' . md5(microtime());
                 $upload_manager = new SJB_UploadFileManager();
                 $upload_manager->setFileGroup('files');
                 $upload_manager->setUploadedFileID($file_id_current);
                 $file_name = $upload_manager->uploadFile('file_tmp');
                 $id_file = $upload_manager->fileId;
                 $post = $controller->getData();
                 $listingId = 0;
                 $post['submitted_data']['questionnaire'] = '';
                 if (isset($post['submitted_data']['id_resume'])) {
                     $listingId = $post['submitted_data']['id_resume'];
                 }
                 $mimeType = isset($_FILES['file_tmp']['type']) ? $_FILES['file_tmp']['type'] : '';
                 if (isset($_FILES['file_tmp']['size']) && $file_name != '' && $_FILES['file_tmp']['size'] == 0) {
                     $errors['FILE_IS_EMPTY'] = 'The uploaded file should not be blank';
                 }
                 if (!empty($_FILES['file_tmp']['name'])) {
                     $fileFormats = explode(',', SJB_System::getSettingByName('file_valid_types'));
                     $fileInfo = pathinfo($_FILES['file_tmp']['name']);
                     if (!isset($fileInfo['extension']) || !in_array(strtolower($fileInfo['extension']), $fileFormats)) {
                         $errors['NOT_SUPPORTED_FILE_FORMAT'] = strtolower($fileInfo['extension']) . ' ' . SJB_I18N::getInstance()->gettext(null, 'is not in an acceptable file format');
                     }
                 }
                 if ($file_name == '' && $listingId == 0) {
                     $canAppplyWithoutResume = false;
                     SJB_Event::dispatch('CanApplyWithoutResume', $canAppplyWithoutResume);
                     if (!$canAppplyWithoutResume) {
                         $errors['APPLY_INPUT_ERROR'] = 'Please select file or resume';
                     }
                 } else {
                     if (SJB_Applications::isApplied($post['submitted_data']['listing_id'], $current_user_sid) && !is_null($current_user_sid)) {
                         $errors['APPLY_APPLIED_ERROR'] = 'You already applied';
                     }
                 }
                 $res = false;
                 $listing_info = '';
                 $notRegisterUserData = $_POST;
                 $score = 0;
                 // для зарегестрированного пользователя получим поля email и name
                 // для незарегестрированных - поля name и email приходят с формы
                 if ($loggedIn === true) {
                     $userData = SJB_UserManager::getCurrentUserInfo();
                     $post['submitted_data']['username'] = isset($userData['username']) ? $userData['username'] : '';
                     $post['submitted_data']['LastName'] = isset($userData['LastName']) ? $userData['LastName'] : '';
                     $post['submitted_data']['FirstName'] = isset($userData['FirstName']) ? $userData['FirstName'] : '';
                     $post['submitted_data']['name'] = $post['submitted_data']['FirstName'] . ' ' . $post['submitted_data']['LastName'];
                     $post['submitted_data']['email'] = $userData['email'];
                 }
                 if (!empty($jobInfo['screening_questionnaire'])) {
                     $questions = new SJB_Questions($_REQUEST, $jobInfo['screening_questionnaire']);
                     $add_form = new SJB_Form($questions);
                     $add_form->registerTags($tp);
                     $add_form->isDataValid($field_errors);
                     $tp->assign('field_errors', $field_errors);
                     if (!$field_errors) {
                         $result = array();
                         $properties = $questions->getProperties();
                         $countAnswers = 0;
                         foreach ($properties as $key => $val) {
                             if ($val->type->property_info['type'] == 'boolean') {
                                 switch ($val->value) {
                                     case 0:
                                         $val->value = 'No';
                                         break;
                                     case 1:
                                         $val->value = 'Yes';
                                         break;
                                 }
                             }
                             $result[$val->caption] = $val->value;
                             if (isset($val->type->property_info['list_values'])) {
                                 foreach ($val->type->property_info['list_values'] as $list_values) {
                                     if (is_array($val->value)) {
                                         foreach ($val->value as $value) {
                                             if ($value == $list_values['id'] && $list_values['score'] != 'no') {
                                                 $score += $list_values['score'];
                                                 $countAnswers++;
                                             }
                                         }
                                     } else {
                                         if ($val->value == $list_values['id'] && $list_values['score'] != 'no') {
                                             $score += $list_values['score'];
                                             $countAnswers++;
                                         }
                                     }
                                 }
                             }
                         }
                         if ($countAnswers === 0) {
                             $score = 0.0;
                         } else {
                             $score = round($score / $countAnswers, 2);
                         }
                         $post['submitted_data']['questionnaire'] = serialize($result);
                     }
                 }
                 if (count($errors) == 0 && count($field_errors) == 0) {
                     $res = SJB_Applications::create($post['submitted_data']['listing_id'], $current_user_sid, isset($post['submitted_data']['id_resume']) ? $post['submitted_data']['id_resume'] : '', $post['submitted_data']['comments'], $file_name, $mimeType, $id_file, isset($post['submitted_data']['anonymous']) ? $post['submitted_data']['anonymous'] : '0', $notRegisterUserData, $post['submitted_data']['questionnaire'], $score);
                     if ($res) {
                         SJB_Statistics::addStatistics('apply', $post['submitted_data']['listing_id'], $res);
                     }
                     if (isset($post['submitted_data']['id_resume']) && $post['submitted_data']['id_resume'] != 0) {
                         $listing_info = SJB_ListingManager::getListingInfoBySID($post['submitted_data']['id_resume']);
                         $emp_sid = SJB_ListingManager::getUserSIDByListingSID($post['submitted_data']['listing_id']);
                         $accessible = SJB_ListingManager::isListingAccessableByUser($post['submitted_data']['id_resume'], $emp_sid);
                         if (!$accessible) {
                             SJB_ListingManager::setListingAccessibleToUser($post['submitted_data']['id_resume'], $emp_sid);
                         }
                     }
                     if (!empty($file_name)) {
                         $file_name = 'files/files/' . $file_name;
                     }
                     SJB_Notifications::sendApplyNow($post, $file_name, $listing_info, $current_user_sid, $notRegisterUserData, $score);
                     if (!empty($jobInfo['screening_questionnaire'])) {
                         $questionnaire = SJB_ScreeningQuestionnaires::getInfoBySID($jobInfo['screening_questionnaire']);
                         if ($questionnaire) {
                             $passing_score = 0;
                             switch ($questionnaire['passing_score']) {
                                 case 'acceptable':
                                     $passing_score = 1;
                                     break;
                                 case 'good':
                                     $passing_score = 2;
                                     break;
                                 case 'very_good':
                                     $passing_score = 3;
                                     break;
                                 case 'excellent':
                                     $passing_score = 4;
                                     break;
                             }
                         }
                         if ($score >= $passing_score && $questionnaire['send_auto_reply_more'] == 1) {
                             if (!empty($questionnaire['email_text_more'])) {
                                 SJB_Notifications::userAutoReply($jobInfo, $current_user_sid, $questionnaire['email_text_more'], $notRegisterUserData);
                             }
                         } elseif ($score < $passing_score && $questionnaire['send_auto_reply_less'] == 1) {
                             if (!empty($questionnaire['email_text_less'])) {
                                 SJB_Notifications::userAutoReply($jobInfo, $current_user_sid, $questionnaire['email_text_less'], $notRegisterUserData);
                             }
                         }
                     }
                 }
                 if ($res === false) {
                     $errors['APPLY_ERROR'] = 'Cannot apply';
                 }
                 $isDataSubmitted = true;
             }
         }
         if (!empty($jobInfo['screening_questionnaire'])) {
             $questions = new SJB_Questions($_REQUEST, $jobInfo['screening_questionnaire']);
             $add_form = new SJB_Form($questions);
             $add_form->registerTags($tp);
             $form_fields = $add_form->getFormFieldsInfo();
             $tp->assign('form_fields', $form_fields);
             $tp->assign('questionsObject', $questions);
         }
         if ($loggedIn) {
             $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID('Resume');
             $wait_approve = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid);
             $approve_status = '';
             if ($wait_approve) {
                 $approve_status = "AND `l`.`status` = 'approved'";
             }
             $result = SJB_DB::query("SELECT `l`.`sid` , `l`.`Title` FROM `listings` as `l`\n\t\t\t\tLEFT JOIN `listing_types` as `lt` ON (`lt`.`sid` = `l`.`listing_type_sid`)\n\t\t\t\tWHERE `lt`.`id` = 'Resume' {$approve_status} AND `l`.`user_sid` = {$current_user_sid} AND `l`.`active`");
             $resume = array();
             foreach ($result as $val) {
                 $resume[$val['sid']] = $val['Title'];
             }
             $tp->assign('resume', $resume);
         }
         $tp->assign('listing', $jobInfo);
     } else {
         $errors['UNDEFINED_LISTING_ID'] = true;
     }
     $tp->assign('request', $_REQUEST);
     $tp->assign('errors', $errors);
     $tp->assign('listing_id', $controller->getListingID());
     $tp->assign('is_data_submitted', $isDataSubmitted);
     $tp->display('apply_now.tpl');
 }
Ejemplo n.º 24
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $sid = SJB_Request::getVar('sid', null, null, 'int');
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     $request['field_sid'] = $sid;
     $display_list_controller = new SJB_ScreeningQuestionnairesDisplayListController($request);
     $questionInfo = SJB_ScreeningQuestionnairesFieldManager::getFieldInfoBySID($sid);
     if (!empty($questionInfo['questionnaire_sid']) && SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $questionInfo['questionnaire_sid'])) {
         $questionInfo = array_merge($questionInfo, $_REQUEST);
         $questionnaire_field = new SJB_ScreeningQuestionnairesField($questionInfo);
         $questionnaire_field->deleteProperty('maxlength');
         $questionnaire_field->deleteProperty('template');
         $add_questionnaire_field_form = new SJB_Form($questionnaire_field);
         $add_questionnaire_field_form->registerTags($tp);
         $form_is_submitted = SJB_Request::getVar('action', '') == 'add';
         $errors = null;
         $type = SJB_Request::getVar('type', false);
         $savedType = $display_list_controller->field->getProperty('type')->value;
         $type = $type ? $type : $savedType;
         $answers = SJB_Request::getVar('answer', false);
         $score = SJB_Request::getVar('score', false);
         $answer_boolean = SJB_Request::getVar('answer_boolean', false);
         $score_boolean = SJB_Request::getVar('score_boolean', false);
         if ($type != 'string') {
             $answers = $answers ? $answers : $display_list_controller->list_items['answer'];
             $score = $score ? $score : $display_list_controller->list_items['score'];
             $answer_boolean = $answer_boolean ? $answer_boolean : $display_list_controller->list_items['answer'];
             $score_boolean = $score_boolean ? $score_boolean : $display_list_controller->list_items['score'];
         }
         if ($answer_boolean && $score_boolean) {
             foreach ($answer_boolean as $key => $val) {
                 $score_boolean[strtolower($val)] = $score_boolean[$key];
             }
         }
         if ($form_is_submitted && $add_questionnaire_field_form->isDataValid($errors)) {
             $questionnaire_field->addProperty(array('id' => 'questionnaire_sid', 'type' => 'id', 'value' => $questionInfo['questionnaire_sid'], 'is_system' => true));
             $id = $questionnaire_field->getProperty('caption');
             $questionnaire_field->addProperty(array('id' => 'id', 'type' => 'string', 'value' => md5($id->value), 'is_system' => true));
             $questionnaire_field->setSID($sid);
             $questionnairesListItemManager = new SJB_ScreeningQuestionnairesListItemManager();
             $questionnairesListItemManager->deleteItemsByFieldSID($sid);
             SJB_ScreeningQuestionnairesFieldManager::saveQuestion($questionnaire_field);
             if ($type == 'boolean') {
                 $request['list_multiItem_value'] = $answer_boolean;
                 $request['field_sid'] = $questionnaire_field->sid;
                 $request['score'] = $score_boolean;
                 $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request);
                 if ($edit_list_controller->isvalidFieldSID()) {
                     $edit_list_controller->saveItem(true);
                 }
             } elseif ($type != 'string') {
                 $request['list_multiItem_value'] = $answers;
                 $request['field_sid'] = $questionnaire_field->sid;
                 $request['score'] = $score;
                 $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request);
                 if ($edit_list_controller->isvalidFieldSID()) {
                     $edit_list_controller->saveItem(true);
                 }
             }
             $questionnaire_sid = $questionnaire_field->getSID();
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$questionInfo['questionnaire_sid']}/?edit=1");
         } else {
             switch ($type) {
                 case 'boolean':
                     $tp->assign('answer_boolean', $answer_boolean);
                     $tp->assign('score_boolean', $score_boolean);
                     break;
                 case 'multilist':
                 case 'list':
                     $tp->assign('answers', $answers);
                     $tp->assign('score', $score);
                     break;
             }
             $tp->assign('errors', $errors);
             $tp->assign('action', 'edit');
             $tp->assign('questionnaire_sid', $questionInfo['questionnaire_sid']);
             $add_questionnaire_field_form->registerTags($tp);
             $tp->assign('form_fields', $add_questionnaire_field_form->getFormFieldsInfo());
             $tp->display('add_questions.tpl');
         }
     }
 }
Ejemplo n.º 25
0
 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');
     }
 }
Ejemplo n.º 26
0
 public function execute()
 {
     $invoiceSID = SJB_Request::getVar('invoice_sid', null, 'default', 'int');
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', false);
     $checkPaymentErrors = array();
     $currentUser = SJB_UserManager::getCurrentUser();
     if ($action == 'pay_for_products') {
         $subscribe = SJB_Request::getVar('subscribe', false);
         $subTotalPrice = SJB_Request::getVar('sub_total_price', 0);
         $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
         $codeInfo = array();
         $index = 1;
         $items = array();
         foreach ($products as $product) {
             $product_info = unserialize($product['product_info']);
             $items['products'][$index] = $product_info['sid'];
             $qty = !empty($product_info['number_of_listings']) ? $product_info['number_of_listings'] : null;
             if ($qty > 0) {
                 $items['price'][$index] = round($product_info['price'] / $qty, 2);
             } else {
                 $items['price'][$index] = round($product_info['price'], 2);
             }
             $items['amount'][$index] = $product_info['price'];
             $items['custom_item'][$index] = "";
             $items['qty'][$index] = $qty;
             $items['custom_info'][$index]['shoppingCartRecord'] = $product['sid'];
             if ($product_info['product_type'] == 'banners' && !empty($product_info['banner_info'])) {
                 $items['custom_info'][$index]['banner_info'] = $product_info['banner_info'];
             }
             $index++;
             SJB_PromotionsManager::preparePromoCodeInfoByProductPromoCodeInfo($product_info, $codeInfo);
         }
         $userSID = $currentUser->getSID();
         $invoiceSID = SJB_InvoiceManager::generateInvoice($items, $userSID, $subTotalPrice, SJB_System::getSystemSettings('SITE_URL') . "/create-contract/", (bool) $subscribe);
         SJB_PromotionsManager::addCodeToHistory($codeInfo, $invoiceSID, $userSID);
     }
     $gatewayId = SJB_Request::getVar('gw', false);
     if (SJB_Request::$method == SJB_Request::METHOD_POST && !$action && $gatewayId == 'authnet_sim') {
         if (isset($_REQUEST['submit'])) {
             $gateway = SJB_PaymentGatewayManager::getObjectByID($gatewayId, true);
             $subscriptionResult = $gateway->createSubscription($_REQUEST);
             if ($subscriptionResult !== true) {
                 $tp->assign('form_submit_url', $_SERVER['REQUEST_URI']);
                 $tp->assign('form_data_source', $_REQUEST);
                 $tp->assign('errors', $subscriptionResult);
                 $tp->display('recurring_payment_page.tpl');
             } else {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?subscriptionComplete=true');
             }
         } else {
             $tp->assign('form_submit_url', $_SERVER['REQUEST_URI']);
             $tp->assign('form_data_source', $_REQUEST);
             $tp->display('recurring_payment_page.tpl');
         }
     } else {
         if (!is_null($invoiceSID)) {
             $invoice_info = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSID);
             $invoice = new SJB_Invoice($invoice_info);
             if (SJB_PromotionsManager::isPromoCodeExpired($invoiceSID)) {
                 $checkPaymentErrors['PROMOTION_TOO_MANY_USES'] = true;
             } else {
                 $invoice->setSID($invoiceSID);
                 if (count($invoice->isValid($invoiceSID)) == 0) {
                     $invoiceUserSID = $invoice->getPropertyValue('user_sid');
                     $currentUserSID = SJB_UserManager::getCurrentUserSID();
                     if ($invoiceUserSID === $currentUserSID) {
                         $payment_gateway_forms = SJB_InvoiceManager::getPaymentForms($invoice);
                         $tp->assign('productsNames', $invoice->getProductNames());
                         $tp->assign('gateways', $payment_gateway_forms);
                         $tp->assign('invoice_info', $invoice_info);
                     } else {
                         $checkPaymentErrors['NOT_OWNER'] = true;
                     }
                 } else {
                     $checkPaymentErrors['WRONG_INVOICE_PARAMETERS'] = true;
                 }
             }
             $tp->assign('checkPaymentErrors', $checkPaymentErrors);
             $tp->display('invoice_payment_page.tpl');
         } else {
             $tp->display('recurring_payment_page.tpl');
         }
     }
 }
Ejemplo n.º 27
0
 /**
  * Check message owner by message id
  *
  * @param integer $id
  * @return boolean
  */
 public static function isMyMessage($id)
 {
     if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == 'admin') {
         return true;
     }
     $user_id = SJB_UserManager::getCurrentUserSID();
     $mes = SJB_PrivateMessage::readMessage($id, true);
     if ($mes) {
         return $mes['from_id'] == $user_id || $mes['to_id'] == $user_id;
     }
     return false;
 }
Ejemplo n.º 28
0
 /**
  * Flag listing by listing SID
  * Set flag marker to listing with some reason and comment.
  * @param integer $listingSID
  * @param integer $reason
  * @param string $comment
  * @return integer|boolean
  */
 public static function flagListingBySID($listingSID, $reason, $comment)
 {
     $result = SJB_DB::query("SELECT * FROM `flag_listing_settings` WHERE `sid` = ?n", $reason);
     $reasonText = '';
     if (!empty($result)) {
         $reasonText = $result[0]['value'];
     }
     $userSID = SJB_UserManager::getCurrentUserSID();
     $listingInfo = self::getListingInfoBySID($listingSID);
     return SJB_DB::query("INSERT INTO `flagged_listings` SET `listing_sid` = ?n, `user_sid` = ?n, `comment` = ?s, `flag_reason` = ?s, `date` = NOW(), `listing_type_sid` = ?n", $listingSID, $userSID, $comment, $reasonText, $listingInfo['listing_type_sid']);
 }
Ejemplo n.º 29
0
 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);
 }
Ejemplo n.º 30
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $actionPage = SJB_Request::getVar('action');
     $page = SJB_Request::getVar('page', false);
     $action = SJB_Request::getVar('actionNew');
     $close = SJB_Request::getVar('close', false);
     $closeWindow = SJB_Request::getVar('closeWindow', false);
     $action = $action ? $action : $actionPage;
     $action = isset($close) && $close != '' ? 'close' : $action;
     if (!$page) {
         $sid = SJB_Request::getVar('listing_sid');
         $tp->assign("listing_sid", $sid);
     } elseif ($page == 'apps') {
         $sid = SJB_Request::getVar('apps_id');
         $action = $action != 'add' ? $action . '_apps' : $action;
         $tp->assign("page", $page);
         $tp->assign("apps_id", $sid);
         $tp->assign("listing_sid", $sid);
     }
     if ($sid) {
         switch ($action) {
             case 'add':
                 $action = 'edit';
                 $tp->assign("saved_listing", false);
                 break;
             case 'save':
                 $noteSaved = false;
                 $note = SJB_Request::getVar('note');
                 if (SJB_SavedListings::saveNoteOnDB(SJB_UserManager::getCurrentUserSID(), $sid, $note)) {
                     $noteSaved = true;
                 }
                 $tp->assign("noteText", $note);
                 $tp->assign("noteSaved", $noteSaved);
                 break;
             case 'edit':
                 $saved_listing = SJB_SavedListings::getSavedListingsByUserAndListingSid(SJB_UserManager::getCurrentUserSID(), $sid);
                 $tp->assign("saved_listing", $saved_listing);
                 break;
             case 'save_apps':
                 $noteSaved = false;
                 $note = SJB_Request::getVar('note');
                 if (SJB_Applications::saveNoteOnDB($note, $sid)) {
                     $noteSaved = true;
                 }
                 $action = 'save';
                 $tp->assign("noteSaved", $noteSaved);
                 break;
             case 'edit_apps':
                 $apps = SJB_Applications::getById($sid);
                 $action = 'edit';
                 $tp->assign("saved_listing", $apps);
                 break;
             case 'close_apps':
                 $apps = SJB_Applications::getById($sid);
                 $action = 'close';
                 $tp->assign("saved_listing", $apps);
                 break;
             case 'close':
                 $saved_listing = SJB_SavedListings::getSavedListingsByUserAndListingSid(SJB_UserManager::getCurrentUserSID(), $sid);
                 $tp->assign("saved_listing", $saved_listing);
                 break;
         }
     } else {
         if (!$page) {
             $errors['UNDEFINED_LISTING_ID'] = true;
         } else {
             $errors['UNDEFINED_APPS_ID'] = true;
         }
     }
     $tp->assign('view', SJB_Request::getVar('view'));
     $tp->assign("closeWindow", $closeWindow);
     $tp->assign("action", $action);
     $tp->assign("errors", $errors);
     $tp->display('notes.tpl');
 }