示例#1
0
 function getSelectReportCategory()
 {
     $config = JblanceHelper::getConfig();
     $categories = $config->reportCategory;
     $values = explode(";", $categories);
     $put[] = JHtml::_('select.option', '', '- ' . JText::_('COM_JBLANCE_PLEASE_SELECT') . ' -');
     foreach ($values as $value) {
         if ($value) {
             $put[] = JHtml::_('select.option', $value, JText::_($value), 'value', 'text');
         }
     }
     $lists = JHtml::_('select.genericlist', $put, 'category', "class='form-control required' size='1'", 'value', 'text', '');
     return $lists;
 }
示例#2
0
 public function load($cid)
 {
     static $instances = array();
     $config = JblanceHelper::getConfig();
     if (!isset($instances[$cid])) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jblance/tables');
         $project = JTable::getInstance('Project', 'Table');
         $state = $project->load($cid);
         if (!$state) {
             return $this->onLoadArticleError($cid);
         }
         $instances[$cid] = $project;
     }
     $this->_item = $instances[$cid];
     return $this;
 }
示例#3
0
 function display($tpl = null)
 {
     // parameters
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $document = JFactory::getDocument();
     $params = $app->getParams();
     $feedEmail = @$app->get('feed_email') ? $app->get('feed_email') : 'author';
     $siteEmail = $app->get('mailfrom');
     $document->link = JRoute::_('index.php?option=com_jblance&view=project&layout=listproject');
     $now = JFactory::getDate();
     $config = JblanceHelper::getConfig();
     $limit = (int) $config->rssLimit;
     // Get some data from the model
     $app->input->set('limit', $app->get('feed_limit'));
     $rows = $this->get('Items');
     $query = "SELECT p.*,(TO_DAYS(p.start_date) - TO_DAYS(NOW())) AS daydiff FROM #__jblance_project p " . "WHERE p.status=" . $db->quote('COM_JBLANCE_OPEN') . " AND p.approved=1 AND p.start_date < " . $db->quote($now) . " " . "ORDER BY p.is_featured DESC, p.id DESC " . "LIMIT " . $limit;
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     foreach ($rows as $row) {
         // strip html from feed item title
         $title = $this->escape($row->project_title);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         // url link to article
         $link = JRoute::_('index.php?option=com_jblance&view=project&layout=detailproject&id=' . $row->id);
         // strip html from feed item description text
         $description = strip_tags($row->description);
         //get the publisher info
         $publisherInfo = JFactory::getUser($row->publisher_userid);
         $author = $publisherInfo->username;
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->description = $description;
         $item->date = $row->start_date;
         $item->category = JblanceHelper::getCategoryNames($row->id_category);
         $item->author = $author;
         if ($feedEmail == 'site') {
             $item->authorEmail = $siteEmail;
         } else {
             $item->authorEmail = $row->author_email;
         }
         // loads item info into rss array
         $document->addItem($item);
     }
 }
示例#4
0
 * @created by	:	JoomBri Team
 * @contact		:	www.joombri.in, support@joombri.in
 * @created on	:	05 November 2014
 * @file name	:	views/service/tmpl/viewservice.php
 * @copyright   :	Copyright (C) 2012 - 2015 BriTech Solutions. All rights reserved.
 * @license     :	GNU General Public License version 2 or later
 * @author      :	Faisel
 * @description	: 	List of services provided by users (jblance)
 */
defined('_JEXEC') or die('Restricted access');
JHtml::_('jquery.framework');
JHtml::_('bootstrap.framework');
JHtml::_('bootstrap.carousel');
$user = JFactory::getUser();
$model = $this->getModel();
$config = JblanceHelper::getConfig();
$currencysym = $config->currencySymbol;
$showUsername = $config->showUsername;
$enableAddThis = $config->enableAddThis;
$addThisPubid = $config->addThisPubid;
$row = $this->row;
$nameOrUsername = $showUsername ? 'username' : 'name';
$isMine = $row->user_id == $user->id;
$sellerInfo = JFactory::getUser($row->user_id);
$userType = JblanceHelper::getUserType($user->id);
$link_edit = JRoute::_('index.php?option=com_jblance&view=service&layout=editservice&id=' . $row->id);
?>

<script type="text/javascript">
<!--
示例#5
0
 function saveService()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialize variables
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $row = JTable::getInstance('service', 'Table');
     $post = $app->input->post->getArray();
     $id = $app->input->get('id', 0, 'int');
     $now = JFactory::getDate();
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $config = JblanceHelper::getConfig();
     $reviewServices = $config->reviewServices;
     $isNew = $id > 0 ? false : true;
     if (!$isNew) {
         $row->load($id);
     }
     // if the service is new, set the create date else set modify date. If the service is new and it does not require approval by admin, set the publish up date.
     if ($isNew) {
         $post['create_date'] = $now->toSql();
         if (!$reviewServices) {
             $post['publish_up'] = $now->toSql();
         }
     } else {
         $post['modify_date'] = $now->toSql();
     }
     //check if the service is to be reviewed by admin. If so, set the approved=0
     if ($reviewServices) {
         $post['approved'] = 0;
     }
     $post['user_id'] = $user->id;
     //process category ids
     $id_category = $app->input->get('id_category', '', 'array');
     JArrayHelper::toInteger($id_category);
     if (count($id_category) > 0 && !(count($id_category) == 1 && empty($id_category[0]))) {
         $categ = implode(',', $id_category);
     } elseif ($id_category[0] == 0) {
         $categ = 0;
     }
     $post['id_category'] = $categ;
     //process extra add-ons
     $extras = $app->input->get('extras', null, 'array');
     $registry = new JRegistry();
     $registry->loadArray($extras);
     $post['extras'] = $registry->toString();
     //process service files
     $serviceFiles = $app->input->get('serviceFiles', null, 'array');
     $registry = new JRegistry();
     $registry->loadArray($serviceFiles);
     $post['attachment'] = $registry->toString();
     if ($isNew) {
         //deduct charge per service from seller'a account
         $plan = JblanceHelper::whichPlan($user->id);
         $chargePerService = $plan->flChargePerService;
         if ($chargePerService > 0) {
             $transDtl = JText::_('COM_JBLANCE_CHARGE_PER_SERVICE') . ' - ' . $post['service_title'];
             JblanceHelper::updateTransaction($user->id, $transDtl, $chargePerService, -1);
             $msg_debit = JText::sprintf('COM_JBLANCE_YOUR_ACCOUNT_DEBITED_WITH_CURRENCY_FOR_POSTING_SERVICE', JblanceHelper::formatCurrency($chargePerService));
             $app->enqueueMessage($msg_debit);
         }
     }
     if (!$row->save($post)) {
         JError::raiseError(500, $row->getError());
     }
     //send email to admin if the service needs review (everytime the service is saved)
     if ($reviewServices || !$row->approved) {
         $jbmail->sendAdminServicePendingApproval($row->id);
     }
     $msg = JText::_('COM_JBLANCE_SERVICE_SAVED_SUCCESSFULLY') . ' : ' . $row->service_title;
     $return = JRoute::_('index.php?option=com_jblance&view=service&layout=myservice', false);
     $this->setRedirect($return, $msg);
 }
示例#6
0
 function saveWithdrawFund()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $params = $app->input->get('params', null, 'array');
     $post = $app->input->post->getArray();
     $now = JFactory::getDate();
     $row = JTable::getInstance('withdraw', 'Table');
     $config = JblanceHelper::getConfig();
     $invoiceFormatWithdraw = $config->invoiceFormatWithdraw;
     //check if the user has enough fund to withdraw
     $totalFund = JblanceHelper::getTotalFund($user->id);
     if ($totalFund < $post['amount']) {
         $msg = JText::_('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_MAKE_PAYMENT');
         $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=withdrawfund&step=2&gateway=' . $post['gateway'], false);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     $row->user_id = $user->id;
     $row->date_withdraw = $now->toSql();
     $row->finalAmount = $post['amount'] - $post['withdrawFee'];
     $registry = new JRegistry();
     $registry->loadArray($params);
     $row->params = $registry->toString();
     unset($post['params']);
     if (!$row->save($post)) {
         JError::raiseError(500, $row->getError());
     }
     $year = date("Y");
     $time = time();
     //replace the tags
     $tags = array("[ID]", "[USERID]", "[YYYY]", "[TIME]");
     $tagsValues = array("{$row->id}", "{$user->id}", "{$year}", "{$time}");
     $invoiceNo = str_replace($tags, $tagsValues, $invoiceFormatWithdraw);
     $row->invoiceNo = $invoiceNo;
     // save the changes after updating the invoice no
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     $row->checkin();
     //send withdraw request to admin
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $jbmail->sendWithdrawFundRequest($row->id);
     $msg = JText::_('COM_JBLANCE_WITHDRAWAL_REQUEST_SENT_SUCCESSFULLY');
     $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=managepay', false);
     $this->setRedirect($link, $msg);
     return false;
 }
示例#7
0
文件: user.php 项目: Ovi1/LSPB-jombri
 function pendingActions($userid)
 {
     $db = JFactory::getDbo();
     $config = JblanceHelper::getConfig();
     $enableEscrowPayment = $config->enableEscrowPayment;
     $result = array();
     $userType = JblanceHelper::getUserType($userid);
     $link_my_bid = JRoute::_('index.php?option=com_jblance&view=project&layout=showmybid');
     $link_my_project = JRoute::_('index.php?option=com_jblance&view=project&layout=showmyproject');
     $link_project_list = JRoute::_('index.php?option=com_jblance&view=project&layout=listproject');
     $link_my_service = JRoute::_('index.php?option=com_jblance&view=service&layout=myservice');
     $link_svc_bought = JRoute::_('index.php?option=com_jblance&view=service&layout=servicebought');
     $link_svc_sold = JRoute::_('index.php?option=com_jblance&view=service&layout=servicesold');
     $link_managepay = JRoute::_('index.php?option=com_jblance&view=membership&layout=managepay');
     //get no of bid offers
     $query = "SELECT COUNT(*) FROM #__jblance_project p " . "LEFT JOIN #__jblance_bid b ON p.id=b.project_id " . "WHERE b.user_id=" . $db->quote($userid) . " AND p.assigned_userid=" . $db->quote($userid) . " AND b.status=" . $db->quote('');
     $db->setQuery($query);
     $bid_offers = $db->loadResult();
     if ($bid_offers > 0) {
         $link = JHtml::_('link', $link_my_bid, '<i class="material-icons">pageview</i>', array());
         $result['bid_offers'] = JText::sprintf('COM_JBLANCE_PENDING_X_BID_OFFERS_REQUIRING_ACTION', '<b>' . $bid_offers . '</b>') . ' ' . $link;
     }
     //get no of bids and projects
     $query = "SELECT p.id, COUNT(b.id) bidcount FROM #__jblance_project p " . "INNER JOIN #__jblance_bid b ON p.id=b.project_id " . "WHERE p.publisher_userid=" . $db->quote($userid) . " AND p.status=" . $db->quote('COM_JBLANCE_OPEN') . " " . "GROUP BY p.id";
     //echo $query;
     $db->setQuery($query);
     $projects = $db->loadObjectList();
     $tot_proj = count($projects);
     $tot_bids = 0;
     foreach ($projects as $project) {
         $tot_bids += $project->bidcount;
     }
     if ($tot_proj > 0) {
         $link = JHtml::_('link', $link_my_project, '<i class="material-icons">pageview</i>', array());
         $result['project_bids'] = JText::sprintf('COM_JBLANCE_PENDING_X_BIDS_FROM_Y_PROJECTS_REQUIRING_ACTION', '<b>' . $tot_bids . '</b>', '<b>' . $tot_proj . '</b>') . ' ' . $link;
     }
     // get no of invited projects
     $query = "SELECT COUNT(*) FROM #__jblance_project p " . "LEFT JOIN #__jblance_bid b ON p.id=b.project_id " . "WHERE p.status='COM_JBLANCE_OPEN' AND FIND_IN_SET(" . $db->quote($userid) . ", p.invite_user_id) AND b.id IS NULL";
     $db->setQuery($query);
     $invites = $db->loadResult();
     if ($invites > 0) {
         $link = JHtml::_('link', $link_project_list, '<i class="material-icons">pageview</i>', array());
         $result['invites'] = JText::sprintf('COM_JBLANCE_PENDING_X_PROJECT_INVITATION_REQUIRING_ACTION', '<b>' . $invites . '</b>') . ' ' . $link;
     }
     //get services yet to be started
     $query = "SELECT COUNT(*) FROM #__jblance_service_order so " . "LEFT JOIN #__jblance_service s ON so.service_id=s.id " . "WHERE s.user_id=" . $db->quote($userid) . " AND so.p_status = ''";
     $db->setQuery($query);
     $service_not_started = $db->loadResult();
     if ($service_not_started > 0) {
         $link = JHtml::_('link', $link_my_service, '<i class="material-icons">pageview</i>', array());
         $result['service_not_started'] = JText::sprintf('COM_JBLANCE_PENDING_X_SERVICES_YET_TO_START', '<b>' . $service_not_started . '</b>') . ' ' . $link;
     }
     //get services in progress
     $query = "SELECT COUNT(*) FROM #__jblance_service_order so " . "LEFT JOIN #__jblance_service s ON so.service_id=s.id " . "WHERE s.user_id=" . $db->quote($userid) . " AND (so.p_status = 'COM_JBLANCE_INITIATED' OR so.p_status = 'COM_JBLANCE_IN_PROGRESS')";
     $db->setQuery($query);
     $service_in_progress = $db->loadResult();
     if ($service_in_progress > 0) {
         $link = JHtml::_('link', $link_my_service, '<i class="material-icons">pageview</i>', array());
         $result['service_in_progress'] = JText::sprintf('COM_JBLANCE_PENDING_X_SERVICES_IN_PROGRESS', '<b>' . $service_in_progress . '</b>') . ' ' . $link;
     }
     //get pending rating for project and service
     if ($userType->freelancer) {
         // for project
         $query = "SELECT COUNT(*) FROM #__jblance_project p " . "LEFT JOIN #__jblance_bid b ON b.project_id=p.id " . "WHERE p.assigned_userid=" . $db->quote($userid) . " AND b.p_status='COM_JBLANCE_COMPLETED' AND " . "p.id NOT IN (SELECT project_id FROM #__jblance_rating r where r.actor=" . $db->quote($userid) . " and r.type='COM_JBLANCE_PROJECT')";
         $db->setQuery($query);
         $seller_rating = $db->loadResult();
         if ($seller_rating > 0) {
             $link = JHtml::_('link', $link_my_bid, '<i class="material-icons">pageview</i>', array());
             $result['rating-project'] = JText::sprintf('COM_JBLANCE_PENDING_X_USERS_RATE_BID_REQUIRING_ACTION', '<b>' . $seller_rating . '</b>') . ' ' . $link;
         }
         // for service
         $query = "SELECT COUNT(*) FROM #__jblance_service s " . "LEFT JOIN #__jblance_service_order so ON s.id=so.service_id " . "WHERE s.user_id=" . $db->quote($userid) . " AND p_status='COM_JBLANCE_COMPLETED' AND " . "so.id NOT IN (SELECT project_id FROM #__jblance_rating r WHERE r.actor=" . $db->quote($userid) . " AND r.type='COM_JBLANCE_SERVICE')";
         $db->setQuery($query);
         $seller_rating = $db->loadResult();
         if ($seller_rating > 0) {
             $link = JHtml::_('link', $link_svc_sold, '<i class="material-icons">pageview</i>', array());
             $result['rating-service'] = JText::sprintf('COM_JBLANCE_PENDING_X_USERS_RATE_SERVICE_SOLD_REQUIRING_ACTION', '<b>' . $seller_rating . '</b>') . ' ' . $link;
         }
     } elseif ($userType->buyer) {
         // for project
         $query = "SELECT COUNT(*) FROM #__jblance_project p " . "LEFT JOIN #__jblance_bid b ON b.project_id=p.id " . "WHERE p.publisher_userid=" . $db->quote($userid) . " AND b.p_status='COM_JBLANCE_COMPLETED' AND " . "p.id NOT IN (SELECT project_id FROM #__jblance_rating r where r.actor=" . $db->quote($userid) . " and r.type='COM_JBLANCE_PROJECT')";
         $db->setQuery($query);
         $buyer_rating = $db->loadResult();
         if ($buyer_rating > 0) {
             $link = JHtml::_('link', $link_my_project, '<i class="material-icons">pageview</i>', array());
             $result['rating-project'] = JText::sprintf('COM_JBLANCE_PENDING_X_USERS_RATE_PROJECT_REQUIRING_ACTION', '<b>' . $buyer_rating . '</b>') . ' ' . $link;
         }
         // for service
         $query = "SELECT COUNT(*) FROM #__jblance_service_order so " . "WHERE so.user_id=" . $db->quote($userid) . " AND p_status='COM_JBLANCE_COMPLETED' AND " . "so.id NOT IN (SELECT project_id FROM #__jblance_rating r WHERE r.actor=" . $db->quote($userid) . " and r.type='COM_JBLANCE_SERVICE')";
         $db->setQuery($query);
         $buyer_rating = $db->loadResult();
         if ($buyer_rating > 0) {
             $link = JHtml::_('link', $link_svc_bought, '<i class="material-icons">pageview</i>', array());
             $result['rating-service'] = JText::sprintf('COM_JBLANCE_PENDING_X_USERS_RATE_SERVICE_BOUGHT_REQUIRING_ACTION', '<b>' . $buyer_rating . '</b>') . ' ' . $link;
         }
     }
     //check if escrow payment is enabled?
     if ($enableEscrowPayment) {
         //get pending payments
         $query = "SELECT COUNT(*) FROM #__jblance_project p " . "WHERE p.publisher_userid=" . $db->quote($userid) . " AND p.status=" . $db->quote('COM_JBLANCE_CLOSED') . " AND p.paid_status <> " . $db->quote('COM_JBLANCE_PYMT_COMPLETE');
         $db->setQuery($query);
         $payment = $db->loadResult();
         if ($payment > 0) {
             $link = JHtml::_('link', $link_my_project, '<i class="material-icons">pageview</i>', array());
             $result['payment'] = JText::sprintf('COM_JBLANCE_PENDING_X_PAYMENTS_REQUIRING_ACTION', '<b>' . $payment . '</b>') . ' ' . $link;
         }
         //pending incoming escrows
         $query = "SELECT COUNT(*) FROM #__jblance_escrow e " . "WHERE e.to_id= " . $db->quote($userid) . " AND e.status=" . $db->quote('COM_JBLANCE_RELEASED');
         $db->setQuery($query);
         $in_escrow = $db->loadResult();
         if ($in_escrow > 0) {
             $link = JHtml::_('link', $link_managepay, '<i class="material-icons">pageview</i>', array());
             $result['in_escrow'] = JText::sprintf('COM_JBLANCE_PENDING_X_INCOMING_ESCROW_PAYMENTS_REQUIRING_ACTION', '<b>' . $in_escrow . '</b>') . ' ' . $link;
         }
         //pending outgoing escrows
         $query = "SELECT COUNT(*) FROM #__jblance_escrow e " . "WHERE e.from_id= " . $db->quote($userid) . " AND e.status=" . $db->quote('');
         $db->setQuery($query);
         $out_escrow = $db->loadResult();
         if ($out_escrow > 0) {
             $link = JHtml::_('link', $link_managepay, '<i class="material-icons">pageview</i>', array());
             $result['out_escrow'] = JText::sprintf('COM_JBLANCE_PENDING_X_OUTGOING_ESCROW_PAYMENTS_REQUIRING_ACTION', '<b>' . $out_escrow . '</b>') . ' ' . $link;
         }
     }
     return $result;
 }
示例#8
0
 function getDetailProject()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $id = $app->input->get('id', 0, 'int');
     $config = JblanceHelper::getConfig();
     $sealProjectBids = $config->sealProjectBids;
     $row = JTable::getInstance('project', 'Table');
     $row->load($id);
     //get the location info
     $location = JTable::getInstance('location', 'Table');
     if ($row->id_location > 0) {
         $location->load($row->id_location);
         $this->setState('projectLocation', $location->params);
     }
     //redirect the project to login page if the project is a `private` project and user is not logged in
     if ($row->is_private && $user->guest) {
         $url = JFactory::getURI()->toString();
         $msg = JText::_('COM_JBLANCE_PRIVATE_PROJECT_LOGGED_IN_TO_SEE_DESCRIPTION');
         $link_login = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($url), false);
         $app->enqueueMessage($msg, 'error');
         $app->redirect($link_login);
     }
     //redirect the user to dashboard if the project is not approved.
     if (!$row->approved) {
         $msg = JText::_('COM_JBLANCE_PROJECT_PENDING_APPROVAL_FROM_ADMIN');
         $link_dash = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
         $app->enqueueMessage($msg, 'error');
         $app->redirect($link_dash);
     }
     //redirect to dashboard if this is private invite project
     if ($row->is_private_invite) {
         $isMine = $row->publisher_userid == $user->id;
         $invite_ids = explode(',', $row->invite_user_id);
         if (!in_array($user->id, $invite_ids) && !$isMine) {
             $msg = JText::_('COM_JBLANCE_THIS_IS_A_PRIVATE_INVITE_PROJECT_VISIBLE_TO_OWNER_INVITEES');
             $link_dash = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
             $app->enqueueMessage($msg, 'error');
             $app->redirect($link_dash);
         }
     }
     //get project files
     $query = 'SELECT * FROM #__jblance_project_file WHERE project_id=' . $db->quote($id);
     $db->setQuery($query);
     $projfiles = $db->loadObjectList();
     //if the project is sealed, get the particular bid row for the bidder.
     $projHelper = JblanceHelper::get('helper.project');
     // create an instance of the class ProjectHelper
     $hasBid = $projHelper->hasBid($row->id, $user->id);
     $bidderQuery = 'TRUE';
     if (($sealProjectBids || $row->is_sealed) && $hasBid) {
         $bidderQuery = " b.user_id=" . $db->quote($user->id);
     }
     //for nda projects, bid count should inlcude only signed bids
     $ndaQuery = 'TRUE';
     if ($row->is_nda) {
         $ndaQuery = " b.is_nda_signed=1";
     }
     //get bid info
     $query = "SELECT b.*, u.username, u.name FROM #__jblance_bid b " . "INNER JOIN #__users u ON b.user_id=u.id " . "WHERE b.project_id =" . $db->quote($id) . " AND " . $bidderQuery . " AND " . $ndaQuery;
     //echo $query;
     $db->setQuery($query);
     $bids = $db->loadObjectList();
     $query = "SELECT * FROM #__jblance_custom_field " . "WHERE published=1 AND field_for=" . $db->quote('project') . " " . "ORDER BY ordering";
     $db->setQuery($query);
     $fields = $db->loadObjectList();
     //get the forum list
     $query = "SELECT * FROM #__jblance_forum " . "WHERE project_id=" . $db->quote($row->id) . " " . "ORDER BY date_post ASC";
     $db->setQuery($query);
     //echo $query;
     $forums = $db->loadObjectList();
     $return[0] = $row;
     $return[1] = $projfiles;
     $return[2] = $bids;
     $return[3] = $fields;
     $return[4] = $forums;
     return $return;
 }
示例#9
0
 function getAutocompleteUsername()
 {
     // Check for request forgeries
     JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $config = JblanceHelper::getConfig();
     $showUsername = $config->showUsername;
     $nameOrUsername = $showUsername ? 'username' : 'name';
     $search = $app->input->get('recipient', '', 'string');
     $result = array();
     // Some simple validation
     if (is_string($search) && strlen($search) > 2 && strlen($search) < 64) {
         $query = "SELECT u.username,u.name FROM #__users u " . "WHERE u.block=0 AND u.username LIKE " . $db->quote('%' . $search . '%') . " OR u.name LIKE " . $db->quote('%' . $search . '%');
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         for ($i = 0; $i < count($rows); $i++) {
             $row = $rows[$i];
             $result[$row->username] = $row->{$nameOrUsername};
         }
     }
     echo json_encode($result);
     exit;
 }
示例#10
0
 function submitForum()
 {
     // Check for request forgeries
     JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $now = JFactory::getDate();
     $row = JTable::getInstance('forum', 'Table');
     $message = $app->input->get('message', '', 'string');
     $userid = $app->input->get('user_id', 0, 'int');
     $projectid = $app->input->get('project_id', 0, 'int');
     $post = array();
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $projHelper = JblanceHelper::get('helper.project');
     // create an instance of the class ProjectHelper
     //show whether name/username
     $config = JblanceHelper::getConfig();
     $showUsername = $config->showUsername;
     $nameOrUsername = $showUsername ? 'username' : 'name';
     //get user details
     $user = JFactory::getUser($userid);
     //get project details
     $jbproject = $projHelper->getProjectDetails($projectid);
     $post['date_post'] = $now->toSql();
     $post['message'] = $message;
     $post['user_id'] = $userid;
     $post['project_id'] = $projectid;
     $post['project_title'] = $jbproject->project_title;
     $post['publisher_userid'] = $jbproject->publisher_userid;
     if ($message) {
         $result = $row->save($post);
         if ($result) {
             $username = '******' . $user->{$nameOrUsername} . '<span class="pull-right">' . JText::_('COM_JBLANCE_RECENTLY') . '</span></span>';
             $message = '<p>' . strip_tags($post['message']) . '</p>';
             echo "<li>{$username}" . "{$message}</li>";
             //send notification to the users who are in the forum
             $jbmail->sendForumMessageNotification($post);
         } else {
             JError::raiseError(500, $row->getError());
         }
     }
     exit;
 }