static function getTimeOptions($date = '0000-00-00 00:00:00') { // Get time (not including the final secons) $time = substr($date, 11, 5); $html = ''; $config = new JXConfig(); $tz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE'); $tz = new DateTimeZone($tz); /* create a date for every hour */ for ($i = 0; $i < 24; $i++) { $newDate = new JDate(mktime($i, 0, 0, 7, 1, 2000), $tz); $newDate->format(JText::_('H:i'), false); /* if the selected is in hours */ $selected = $time == $newDate->format(JText::_('H:i'), true) ? 'selected="selected"' : ''; /* add the options */ $html .= '<option ' . $selected . 'value="' . $newDate->format(JText::_('H:i'), true) . '" >' . $newDate->format(JText::_('JXLIB_TIME_SHORT_FORMAT'), true) . '</option>'; /* and modify for 30 mins between these hours */ $newDate->modify('+30 minute'); /* check again to see if its in 30 mins interval */ $selected = $time == $newDate->format(JText::_('H:i'), true) ? 'selected="selected"' : ''; /* add the options */ $html .= '<option ' . $selected . 'value="' . $newDate->format(JText::_('H:i'), true) . '" >' . $newDate->format(JText::_('JXLIB_TIME_SHORT_FORMAT'), true) . '</option>'; } return $html; }
function display($tpl = null) { $configHelper = new JXConfig(); $this->assign('logo', $configHelper->get(JXConfig::LOGO)); $this->assign('style', $configHelper->get(JXConfig::STYLE)); $this->assignRef('configHelper', $configHelper); $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_ACCOUNT_LABEL_MANAGE_THEME")); parent::display($tpl); }
public function getRowHtml() { $jxConfig = new JXConfig(); $rowData = $this; $allowInvite = $jxConfig->allowUsersRegister(); $pendingStat = self::PENDING; ob_start(); include JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'views' . DS . 'invite' . DS . 'tmpl' . DS . 'default.invitation.php'; $content = ob_get_contents(); ob_end_clean(); return $content; }
public function modMemberInvite() { $html = ''; $configHelper = new JXConfig(); if ($configHelper->allowInvite() && $configHelper->allowUsersRegister()) { ob_start(); require_once JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'templates' . DS . 'modInviteGuest.php'; $html = ob_get_contents(); ob_end_clean(); } return $html; }
public function image() { $url = JRequest::getVar('url', false); preg_match('/.*\\.([a-zA-Z]+)/', $url, $extension); if ($url) { /* use the existing path */ $imagePath = $url; if (false === file_get_contents($url, 0, null, 0, 1)) { /* default image is supplied the image path point to broken link */ $imagePath = JXConfig::getMissingImage(); } /* output the image but its possible to store this for caching purpose */ if (!empty($extension[1])) { switch ($extension[1]) { case 'jpg': $ext = 'jpeg'; break; default: $ext = $extension[1]; } header('Content-Type: image/' . $ext); header('Content-transfer-encoding: binary'); echo file_get_contents($imagePath); } } exit; }
/** * @return string JSON string */ public function grab($url, $opt = array()) { /* some request need to be ignored */ if (self::ignore($url)) { /* certain link should fetch the information */ return json_encode($this->ERROR_TAG_WITH_IGNORE); } jimport('joomla.http.http'); $jxConfig = new JXConfig(); /* pass token in url since cannot be set to request body */ //$uri = 'http://www.diffbot.com/api/article?token='.self::DEVELOPER_KEY.'&url='.$url; $uri = 'http://www.diffbot.com/api/article?token=' . $jxConfig->get(JXConfig::DIFFBOT) . '&url=' . $url; $u = JUri::getInstance($uri); $registry = new JRegistry(); $curl = new JHttpTransportXCurl($registry); $timeout = !empty($opt) && is_numeric($opt['timeout']) ? $opt['timeout'] : self::MAXIMUM_RESPONSE_TIME; /* expected object is JHttpResponse */ $result = new JHttpResponse(); try { /* passing token by data wont work, just use to pass timeout option */ $result = $curl->request('GET', $u, null, null, $timeout); /* response is set to return empty $result->body if exceeding timeout */ if (!$result->body) { throw new Exception('Timeout exceeded'); } } catch (Exception $e) { /* catch more error codes */ if (!empty($result->code) && $result->code != 200) { return false; } /* to check the content of retrieved value */ $body = json_decode($result->body); /* if its an errornous request fallback to error handler */ if (!empty($body->error)) { /* now $body contains $body->error and $body->errorCode */ $err = array('error' => $body->error, 'code' => $body->errorCode); $err = array_merge($err, $this->ERROR_TAG_WITH_IGNORE); $result->body = json_encode($err); } else { /* under some circumstances, the service will failed to load the excerpt from the url * if so, tagged with ignore as this will exhaust the request if we keep fetching them */ $result->body = json_encode($this->ERROR_TAG_WITH_IGNORE); } } /* preserve the json result and format using format() */ return $result->body; }
function display($tpl = null) { $jxConfig = new JXConfig(); $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_ACCOUNT_LABEL_BILLING")); $total = 0; /*$payments = JModel::getInstance('payments', 'AccountModel'); $total = $payments->getTotal(); $payments->getList(null, $jxConfig->get('list_limit'), JRequest::getVar('limitstart', 0)); */ $pagination = new JPagination($total, JRequest::getVar('limitstart', 0), $jxConfig->get('list_limit')); $this->assignRef('availablePlans', $jxConfig->getAvailablePlans()); $this->assignRef('plan', $jxConfig->getCurrentPlan()); $this->assignRef('jxConfig', $jxConfig); $this->assignRef('payments', $payments); $this->assignRef('pagination', $pagination); parent::display($tpl); }
/** * * $range array('month' => 2) */ public static function get($actions, $user_id, $group_id, $range, $group_by) { if ($group_by == 'hour') { // todo: db datetime is server utc, might need to calculate for offset $config = new JXConfig(); $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE'); $my = JXFactory::getUser($user_id); $myTimeZone = $my->getParam('timezone'); // Second load user personalize timezone (if any) to override system default timezone $timeZoneStr = empty($myTimeZone) ? $defaultTz : $myTimeZone; $tz = new DateTimeZone($timeZoneStr); $date2 = new JDate('now', $tz); $offset = $date2->getOffset() / 3600; } else { $offset = 0; } $result = self::getDbRecord($actions, $user_id, $group_id, $range, $group_by, $offset); return self::formulateData($result, $group_by, $offset); }
public function registerUser($data) { $jxConfig = new JXConfig(); $verifyEmail = $jxConfig->cleanEmailList(array($data['email'])); if (!is_array($verifyEmail)) { $this->setError($verifyEmail); return false; } elseif ($data['password'] == $data['conf_pass']) { $user = new JUser(); $temp = new stdClass(); $temp->name = $data['name']; $temp->username = $data['username']; $temp->password = $data['password']; $temp->block = 0; $temp->sendEmail = 0; $temp->email = $data['email']; // set the default new user group, Registered $temp->groups[] = 2; $bindData = (array) $temp; $user->bind($bindData); if (isset($data['group_limited'])) { $user->setParam('groups_member_limited', $data['group_limited']); } if ($user->save()) { $activity = JTable::getInstance('Activity', 'StreamTable'); $activity->addUser($user->id); return $user->id; } else { $this->setError($user->getError()); return false; } } else { $this->setError(JText::_('COM_REGISTER_ERRMSG_PASSWORD_MISMATCH')); return false; } return false; }
public function removeLogo() { // Remove previous logo $configHelper = new JXConfig(); $originalFilePath = $configHelper->getCompanyLogoPath(); if (JFile::exists($originalFilePath)) { JFile::delete($originalFilePath); } $param['logo'] = ''; $mainframe = JFactory::getApplication(); if (!$configHelper->saveConfig($param)) { /* Redirect to clear the previous post values */ $mainframe->redirect(JRoute::_('index.php?option=com_account&view=account&task=manageTheme', false), JText::_('COM_ACCOUNT_ACTION_REMOVE_LOGO_FAIL'), 'error'); } /* Redirect to clear the previous post values */ $mainframe->redirect(JRoute::_('index.php?option=com_account&view=account&task=manageTheme', false), JText::_('COM_ACCOUNT_ACTION_REMOVE_LOGO_SUCCESS')); }
/** * Prep crocodocs preview */ public function preparePreview() { $jxConfig = new JXConfig(); $my = JXFactory::getUser(); $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); // copy file to tmp path $tmpPath = $jxConfig->get('tmp_path') . DS . $this->filename; JFile::copy(JPATH_ROOT . DS . $this->path, $tmpPath); // if Crocodocs is enabled if ($jxConfig->isCrocodocsEnabled()) { curl_setopt($ch, CURLOPT_URL, 'https://crocodoc.com/api/v2/document/upload'); $post = array("token" => $jxConfig->get("crocodocs"), "file" => "@" . $tmpPath); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $response = curl_exec($ch); // @todo: validate json $responseObj = json_decode($response); if (!isset($responseObj->uuid)) { return false; } $uuid = $responseObj->uuid; $this->setParam('uuid', $uuid); $this->setParam('preview-ready', 0); } elseif ($jxConfig->isScribdEnabled()) { curl_setopt($ch, CURLOPT_URL, "http://api.scribd.com/api?api_key=" . $jxConfig->get(JXConfig::SCRIBD_API)); $post = array("method" => "docs.upload", "api_key" => $jxConfig->get(JXConfig::SCRIBD_API), "api_sig" => $jxConfig->get(JXConfig::SCRIBD_SECRET), "my_user_id" => $my->id, "paid_content" => 1, "file" => "@" . $tmpPath); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $response = curl_exec($ch); $result = simplexml_load_string($response); if (!isset($result->doc_id) && !isset($result->access_key)) { return false; } $this->setParam('doc_id', (string) $result->doc_id); $this->setParam('access_key', (string) $result->access_key); $this->setParam('preview-ready', 0); } JFile::delete($tmpPath); $this->store(); return true; }
$('#file_item_'+$('#file-replace-form #file_id').val()+' div.file-list-type').addClass(response.newext); $('#file_item_'+$('#file-replace-form #file_id').val()+' div.file-list-type img').attr('src', response.preview); $('#file_item_'+$('#file-replace-form #file_id').val()+' div.file-list-meta span.small').html(response.filesize); } }); } } // Hide n Show Container (stream) for grid view $(document).ready(function() { fileReplace.init(); }); </script> <ul id="file-listing" class="list clearfix"> <?php $jxConfig = new JXConfig(); $streamMessage = array(); foreach ($files as $row) { $user = JXFactory::getUser($row->user_id); $date = new JDate($row->created); $streamObj = getStreamMessage($streamTbl, $streamMessage, $row->stream_id); // formulate the filename for data binding in html5 $arrFilename = explode('.', $row->filename); $extension = strtolower(array_pop($arrFilename)); $fullFilename = implode('.', $arrFilename); ?> <li id="file_item_<?php echo $row->id; ?> "> <div class="file-list-avatar">
echo JText::_('MOD_LOGIN_FORGOT_YOUR_PASSWORD'); ?> </a> · <a href="<?php echo JRoute::_('index.php?option=com_users&view=remind'); ?> "> <?php echo JText::_('MOD_LOGIN_FORGOT_YOUR_USERNAME'); ?> </a> <?php jimport('joomla.utitlies.xconfig'); $jxConfig = new JXConfig(); $usersConfig = JComponentHelper::getParams('com_users'); if ($jxConfig->allowUsersRegister() && $usersConfig->get('allowUserRegistration')) { ?> · <a href="<?php echo JRoute::_('index.php?option=com_users&view=registration'); ?> "> <?php echo JText::_('MOD_LOGIN_REGISTER'); ?> </a> <?php } ?> </small>
function display($tpl = null) { $defaultAdmin = JXFactory::getUser(42); $configHelper = new JXConfig(); $crocodocs = $configHelper->get('crocodocs'); $crocodocsenable = $configHelper->get('crocodocsenable'); $scribd_api = $configHelper->get('scribd_api'); $scribd_secret = $configHelper->get('scribd_secret'); $scribdenable = $configHelper->get('scribdenable'); $diffbot = $configHelper->get('diffbot'); $mailer = $configHelper->get('mailer'); $mailfrom = $configHelper->get('mailfrom'); // admin email ? $fromname = $configHelper->get('fromname'); // admin name ? $sendmail = $configHelper->get('sendmail'); // /usr/sbin/sendmail $smtpauth = $configHelper->get('smtpauth'); $smtpuser = $configHelper->get('smtpuser'); $smtppass = $configHelper->get('smtppass'); $smtphost = $configHelper->get('smtphost'); $smtpsecure = $configHelper->get('smtpsecure'); $smtpport = $configHelper->get('smtpport'); // 25 //overwrite value with postParam when save error $error = array(); if ($_POST) { $postParam = JRequest::getVar('jform'); $crocodocs = $postParam['crocodocs']; $crocodocsenable = $postParam['crocodocsenable']; $scribd_api = $postParam['scribd_api']; $scribd_secret = $postParam['scribd_secret']; $scribdenable = $postParam['scribdenable']; $diffbot = $postParam['diffbot']; $mailer = $postParam['mailer']; $mailfrom = $postParam['mailfrom']; $fromname = $postParam['fromname']; $sendmail = $postParam['sendmail']; $smtpauth = $postParam['smtpauth']; $smtpuser = $postParam['smtpuser']; $smtppass = $postParam['smtppass']; $smtphost = $postParam['smtphost']; $smtpsecure = $postParam['smtpsecure']; $smtpport = $postParam['smtpport']; } $this->assignRef('crocodocs', $crocodocs); $this->assignRef('crocodocsenable', $crocodocsenable); $this->assignRef('scribd_api', $scribd_api); $this->assignRef('scribd_secret', $scribd_secret); $this->assignRef('scribdenable', $scribdenable); $this->assignRef('diffbot', $diffbot); $this->assignRef('mailer', $mailer); $this->assignRef('mailfrom', $mailfrom); $this->assignRef('fromname', $fromname); $this->assignRef('sendmail', $sendmail); $this->assignRef('smtpauth', $smtpauth); $this->assignRef('smtpuser', $smtpuser); $this->assignRef('smtppass', $smtppass); $this->assignRef('smtphost', $smtphost); $this->assignRef('smtpsecure', $smtpsecure); $this->assignRef('smtpport', $smtpport); $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_ACCOUNT_LABEL_ACCOUNT_ADVANCE_SETTING")); parent::display($tpl); }
/** * */ public function preview() { $my = JXFactory::getUser(); $fileid = JRequest::getVar('file_id'); $file = JTable::getInstance('File', 'StreamTable'); $jxConfig = new JXConfig(); $data = array(); $data['reload'] = false; if ($file->load($fileid) && $my->authorise('stream.file.download', $file) && ($jxConfig->isCrocodocsEnabled() || $jxConfig->isScribdEnabled())) { // Grab the uuid $uuid = $file->getParam('uuid'); $docid = $file->getParam('doc_id'); if ($jxConfig->isCrocodocsEnabled() && empty($uuid) || $jxConfig->isScribdEnabled() && empty($docid)) { // haven't been uploaded yet, upload and grab the uuid $store = $file->preparePreview(); // reload file for updated content $file->load($fileid); $uuid = $file->getParam('uuid'); $docid = $file->getParam('doc_id'); } // Check if file is ready $previewReady = $file->getParam('preview-ready'); $isViewable = false; if (empty($previewReady)) { if ($jxConfig->isCrocodocsEnabled()) { // Preview not ready, query status $options = new JRegistry(); $transport = new JHttpTransportCurl($options); $http = new JHttp($options, $transport); $response = $http->get('https://crocodoc.com/api/v2/document/status?token=' . $jxConfig->get(JXConfig::CROCODOCS) . '&uuids=' . $file->getParam('uuid')); $responseObj = json_decode($response->body); //print_r($responseObj); exit; if (!isset($responseObj->error)) { $isViewable = !empty($responseObj[0]->viewable); if ($isViewable) { $previewReady = true; $file->setParam('preview-ready', 1); $file->store(); } } } else { // Query Scribd Preview status $http = new JHttp(); $statusUrl = 'http://api.scribd.com/api?api_key=' . $jxConfig->get(JXConfig::SCRIBD_API) . '&doc_id=' . $file->getParam('doc_id') . '&method=docs.getConversionStatus&my_user_id=' . $file->user_id; $response = $http->get($statusUrl); $result = simplexml_load_string($response->body); if (isset($result->conversion_status) && $result->conversion_status == 'DONE') { $previewReady = true; $file->setParam('preview-ready', 1); $file->store(); } } } if ($previewReady && (!empty($uuid) || !empty($docid))) { if ($jxConfig->isCrocodocsEnabled()) { $session_id = $file->getParam('previewSession'); if (time() > $file->getParam('previewExpiry')) { // File uploaded, try to create session $options = new JRegistry(); $transport = new JHttpTransportCurl($options); $http = new JHttp($options, $transport); $response = $http->post('https://crocodoc.com/api/v2/session/create', array('token' => '$jxConfig->get(JXConfig::CROCODOCS)', 'uuid' => $file->getParam('uuid'))); //$response = $http->post( 'https://crocodoc.com/api/v2/session/create' , array('token' => 'Oe8fA1mQ59LSwtBlKy4Nkbvn', 'uuid' => $uuid ) ); $responseObj = json_decode($response->body); $session_id = $responseObj->session; // Store this session so that we don't have to fetch it again $file->setParam('previewSession', $session_id); $file->setParam('previewExpiry', time() + 60 * 50); // ste it 50 mins from now $file->store(); } $html = '<iframe style="border:0px;width:100%;height:100%" src="https://crocodoc.com/view/' . $session_id . '"></iframe>'; } else { $html = "<div id='embedded_doc' data-doc_id=\"" . $file->getParam("doc_id") . "\" data-access_key=\"" . $file->getParam("access_key") . "\"><a href='http://www.scribd.com'>Scribd</a></div>\t\t\t\t\t\t\n\t\t\t\t\t\t\t <script type=\"text/javascript\">\n\t\t\t\t\t\t\t\t// Instantiate iPaper\n\t\t\t\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\tscribd_doc = scribd.Document.getDoc(\$('#embedded_doc').data('doc_id'), \$('#embedded_doc').data('access_key'));\n\t\t\t\t\t\t\t\t\t// Parameters\n\t\t\t\t\t\t\t\t\tscribd_doc.addParam('height', 750);\n\t\t\t\t\t\t\t\t\tscribd_doc.addParam('width', 750);\n\t\t\t\t\t\t\t\t\tscribd_doc.addParam('auto_size', true);\n\t\t\t\t\t\t\t\t\tscribd_doc.addParam('mode', 'slideshow');\n\t\t\t\t\t\t\t\t\tscribd_doc.addParam('jsapi_version', 2);\n\n\t\t\t\t\t\t\t\t\t// Attach event listeners\n\t\t\t\t\t\t\t\t\tscribd_doc.addEventListener('docReady', onDocReady);\n\n\t\t\t\t\t\t\t\t\t// Write the instance\n\t\t\t\t\t\t\t\t\tscribd_doc.write('embedded_doc');\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\tvar onDocReady = function(e) {\n\t\t\t\t\t\t\t\t\tscribd_doc.api.setPage(1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t// Bookmark Helpers\n\t\t\t\t\t\t\t\tvar goToPage = function(page) {\n\t\t\t\t\t\t\t\t\tif (scribd_doc.api){\n\t\t\t\t\t\t\t\t\t\tscribd_doc.api.setPage(page);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\tvar goToMiddle = function() {\n\t\t\t\t\t\t\t\t\tif (scribd_doc.api){\n\t\t\t\t\t\t\t\t\t\tgoToPage( Math.floor(scribd_doc.api.getPageCount()/2) );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tvar goToEnd = function() {\n\t\t\t\t\t\t\t\t\tif (scribd_doc.api) {\n\t\t\t\t\t\t\t\t\t\tgoToPage(scribd_doc.api.getPageCount());\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t </script>"; } $data['html'] = $html; } else { $data['reload'] = 1; $data['file_id'] = $fileid; $data['html'] = '<p>Please wait while we prepare your document</p>'; } } else { $data['html'] = "<p>Not allowed to preview.</p>"; } echo json_encode($data); exit; }
<?php /** * @version 1.0.0 * @package com_account * @copyright Copyright (C) 2011 - 2013 Slashes & Dots Sdn Bhd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Offiria Team */ // no direct access defined('_JEXEC') or die; $jxConfig = new JXConfig(); ?> <div class="account-navbar"> <?php echo $this->showNavBar(); ?> </div> <div id="account-edit"> <form class="edit" action="<?php echo JRoute::_('index.php?option=com_account&view=account'); ?> " method="post"> <h3 class="section-title"><?php echo JText::_('COM_ACCOUNT_LABEL_BASIC_SETTING'); ?> </h3> <ul class="account-form"> <li> <label for="params_sitename" class="" id="params_sitename-lbl"><?php
<?php /** * @category Plugins * @package JomSocial * @copyright (C) 2008 by Slashes & Dots Sdn Bhd - All rights reserved! * @license GNU/GPL, see LICENSE.php */ // no direct access defined('_JEXEC') or die('Restricted access'); define('FINDER_PATH_INDEXER', JPATH_ROOT . '/components/com_finder/helpers/indexer'); JLoader::register('FinderIndexerHelper', FINDER_PATH_INDEXER . '/helper.php'); JLoader::register('FinderIndexerQuery', FINDER_PATH_INDEXER . '/query.php'); JLoader::register('FinderIndexerResult', FINDER_PATH_INDEXER . '/result.php'); jimport('joomla.plugin.plugin'); jimport('joomla.xfactory'); $lang = JFactory::getLanguage(); $my = JXFactory::getUser(); $config = new JXConfig(); // First load account setting language (if any) to override joomla! language $defLanguage = $config->getLanguage() != '' ? $config->getLanguage() : $lang->get('default'); // Second load user personal language (if any) to override default language $siteLanguage = intval($my->id) > 0 && $my->getParam('language') != '' ? $my->getParam('language') : $defLanguage; $lang->setLanguage($siteLanguage); $result = $lang->load('lib_xjoomla'); /** * Editor Jomsocial Photo Button * * @package Editors-xtd * @since 1.5 */
public function ajaxMemberInvite() { $configHelper = new JXConfig(); if ($configHelper->allowInvite()) { $postvar = JRequest::getVar('invitation'); $inviteType = JRequest::getVar('inviteType', ''); $arrEmails = explode(',', $postvar); $emailtoInvite = $configHelper->cleanEmailList($arrEmails); if (strtolower($inviteType) == 'welcome') { if (count($arrEmails) < 3 || (empty($arrEmails[0]) || empty($arrEmails[1]) || empty($arrEmails[2]))) { echo '{"error":"1", "msg":"' . JText::sprintf('COM_ACCOUNT_ERRMSG_PLEASE_INVITE_EMAILS', '3') . '"}'; exit; } elseif ($arrEmails[0] == $arrEmails[1] || $arrEmails[1] == $arrEmails[2] || $arrEmails[0] == $arrEmails[2]) { echo '{"error":"1", "msg":"' . JText::sprintf('COM_ACCOUNT_ERRMSG_PLEASE_INVITE_EMAILS', '3') . '"}'; exit; } } if (!is_array($emailtoInvite)) { echo '{"error":"1", "msg":"' . $emailtoInvite . '"}'; } else { $currentUserCount = $configHelper->getRegisteredAndInvitedCount(); $maxUserAllowed = $configHelper->getMaxAllowUsers(); $toHaveUserCount = $currentUserCount + count($emailtoInvite); if ($toHaveUserCount > $configHelper->getMaxAllowUsers()) { echo '{"error":"1", "msg":"' . JText::sprintf('COM_ACCOUNT_MSG_ALLOWED_NUMBERS_OF_INVITATION', $currentUserCount, $configHelper->getMaxAllowUsers() - $currentUserCount) . '"}'; } else { JTable::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'tables'); $my = JXFactory::getUser(); $alreadyUser = array(); $invitedEmail = array(); foreach ($emailtoInvite as $email) { $processResult = $this->processInvitation($my, $email); if ($processResult['flag'] == self::SENT_FLAG) { $invitedEmail[] = $email; } else { $alreadyUser[] = $email; } } $msg = ''; if (!empty($alreadyUser)) { $msg .= count($alreadyUser) == 1 ? JText::sprintf('COM_ACCOUNT_MSG_INVITATION_EMAIL_ALREADY_REGISTERED', implode(',', $alreadyUser)) . '\\n' : JText::sprintf('COM_ACCOUNT_MSG_INVITATION_EMAILS_ALREADY_REGISTERED', implode(',', $alreadyUser)) . '\\n'; } $msg .= empty($invitedEmail) ? '' : JText::sprintf('COM_ACCOUNT_MSG_INVITATION_SENT', implode(',', $invitedEmail)); echo '{"error":"0", "msg":"' . $msg . '"}'; } } } else { echo '{"error":"1", "msg":"' . JText::_('COM_ACCOUNT_ERRMSG_INVITATION_DENIED') . '"}'; } exit; }
/** * Return attachment view for the given stream */ public static function getAttachmentHTML($stream) { $my = JXFactory::getUser(); $data = json_decode($stream->raw); $html = ''; if (!function_exists('whoMakesAction')) { /** * Call this function to retrieve the item/message viewer * @param JTable $stream the current StreamTable * @param int $item_id the owner of the item (for example: id of the file or id of a message contains a link) * @param String $type type of the item (since tracking is done by id, being specific is safer. eg: file_220, link_220) */ function whoMakesAction($stream, $item_id = 0, $type = NULL) { // get list of avatar who viewed the stream $whoMakesAction = $stream->whoMakesAction($item_id, $type); $avatarListWhoMakeAction = ''; if ($whoMakesAction && count($whoMakesAction) > 0) { // Do rename the variable if its too long or easily mistyped $avatarListWhoMakeAction .= '<div class="user-horizontal-list message-reader-list">'; if ($type == 'video') { // change language from READ to SEEN if its a video $avatarListWhoMakeAction .= '<span class="small">' . JText::_('COM_STREAM_LABEL_SEEN_BY') . ' '; } else { $avatarListWhoMakeAction .= '<span class="small">' . JText::_('COM_STREAM_LABEL_READ_BY') . ' '; } /* $avatarListWhoMakeAction .= count($whoMakesAction) . ' reader'; */ $avatarListWhoMakeAction .= '<a href="#showReaders" data-content="<ul>'; foreach ($whoMakesAction as $user_id) { // there will be 0 as user which in return will load current user if ($user_id != 0 && $user_id != NULL) { $user = JXFactory::getUser($user_id); $avatarListWhoMakeAction .= StreamTemplate::escape('<li><a href="' . $user->getURL() . '">' . $user->name . '</a></li>'); } } $avatarListWhoMakeAction .= '</ul>">'; $label = count($whoMakesAction) > 1 ? JText::_('COM_STREAM_LABEL_USERS') : JText::_('COM_STREAM_LABEL_USER'); $avatarListWhoMakeAction .= count($whoMakesAction) . " {$label}</a>"; $avatarListWhoMakeAction .= '</span></div>'; } return $avatarListWhoMakeAction; } } // Attachment $jxConfig = new JXConfig(); $files = $stream->getFiles(); $hasPreview = false; $numPreview = 0; // Sort the files, photos at the bottom usort($files, array('StreamMessage', 'sortAttachment')); $imgHtml = '<div class="message-content-attachment">'; foreach ($files as $file) { // only show if the file does exist // @todo: templatize this ? $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); // Show file name only if preview doesn't exist // Otherwise, just show the preview. People can click on the preview and download it from tehre if (!$file->getParam('has_preview')) { // Show preview link, of if the filename is doc, docx, pdf, ppt, pptx $fext = strtolower(substr($file->filename, -4)); $html .= '<div data-filename="' . $file->filename . '" ' . 'data-message_id=' . $stream->id . ' class="message-content-file ">'; $html .= '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::abridge($file->filename, 20, 13)) . '</a>'; $html .= ' <span class="small hint">(' . StreamMessage::formatBytes($file->filesize, 1) . ')</span>'; // append to file container only once if ($jxConfig->isCrocodocsEnabled() || $jxConfig->isScribdEnabled()) { if (in_array($fext, array('.doc', 'docx', '.pdf', '.ppt', 'pptx'))) { $html .= ' <a href="#preview" class="meta-preview small" data-filename="' . StreamTemplate::escape($file->filename) . '" data-file_id="' . $file->id . '" onclick="return S.preview.show(this);">' . JText::_('COM_STREAM_LABEL_PREVIEW') . '</a>'; } } $html .= whoMakesAction($stream, $file->id, 'file'); $html .= '<div class="clear"></div>'; $html .= '</div>'; /* // File can only be remove in 'edit' view if( $my->authorise('stream.message.edit', $stream) ){ $html .= '<a class="meta-edit" href="#removeAttachment" file_id="'.$file->id.'">'. JText::_('COM_STREAM_LABEL_REMOVE').'</a>'; } */ } if ($file->getParam('has_preview')) { $randId = 'preview_' . rand(1000, 9999); $path = str_replace(DS, '/', $file->getParam('thumb_path')); $imgHtml .= '<div class="message-content-preview"><img rel="#' . $randId . '" src="' . JURI::root() . $path . '" /></div>'; // Attach overlay code $width = $file->getParam('width'); $height = $file->getParam('height'); if (!empty($width) && !empty($height)) { if ($width > 640) { $height = 640 / $width * $height; $width = 640; } if ($height > 640) { $width = 640 / $height * $width; $height = 640; } $viewLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id . '&display=1'); $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); // Replace all <show_next> tag, since the previous one is clearly not the last one $imgHtml = str_replace('<show_next>', '<div class="image_next btn btn-large" onclick="$(\'[rel=\\\'#' . $randId . '\\\']\').click();">→</div>', $imgHtml); $imgHtml .= ' <div id="' . $randId . '" class="apple_overlay" style="width:' . $width . 'px">'; // IF this is NOT the first preview, add the 'PREV' button if ($numPreview != 0) { $imgHtml .= '<div class="image_prev btn btn-large" onclick="$(\'[rel=\\\'#' . $prevRandId . '\\\']\').click();">←</div>'; } $imgSrc = $dlLink; if ($file->getParam('preview_path')) { $imgSrc = str_replace(DS, '/', $file->getParam('preview_path')); $imgSrc = JURI::root() . $imgSrc; } $imgHtml .= '<show_next> <a class="close"></a> <img width="' . $width . '" height="' . $height . '" src="' . $imgSrc . '" /> <div> <a href="' . $viewLink . '" target="_blank">View full-size image</a> • <a href="' . $dlLink . '">Download</a></div> </div>'; $prevRandId = $randId; $hasPreview = true; $numPreview++; } } } $imgHtml .= '</div>'; // If there is no attachement at all, remove the div $imgHtml = str_replace('<div class="message-content-attachment"></div>', '', $imgHtml); $html .= $imgHtml; // If we have added the preview, which is left floated, we need to add a clearing div // the sorting function above will make sure that preview'ed would be the last attachment if ($hasPreview) { // Get rid of all the <show_next> marker $html = str_replace('<show_next>', '', $html); $html .= '<div class="clear"></div>'; } // Videos if (!empty($data->video)) { foreach ($data->video as $videoid) { $video = JTable::getInstance('Video', 'StreamTable'); if ($video->load($videoid)) { $html .= '<div class="message-content-video" id="video-' . $videoid . '"> <img class="message-content-video-thumbnail interactive" src="' . $video->thumb . '" embed_id="' . $videoid . '" embed_type="videos"/> <span class="video-duration">' . StreamMessage::formatDuration($video->duration) . '</span> <div class="message-content-preview-desc"> <div class="preview-title">' . JHtmlString::truncate($video->title, 24) . '</div> <div class="preview-desc">' . JHtmlString::truncate($video->description, 180) . '</div> </div><div class="clear"></div>' . whoMakesAction($stream, $video->id, 'video') . ' <div class="clear"></div> </div>'; } } } // Slideshare if (!empty($data->slideshare)) { foreach ($data->slideshare as $slideshareid) { $slideshare = JTable::getInstance('Slideshare', 'StreamTable'); if ($slideshare->load($slideshareid)) { $ss = json_decode($slideshare->response); $html .= '<div class="message-content-video slideshare" id="video-' . $slideshareid . '"> <img src="' . $ss->thumbnail . '" embed_id="' . $slideshareid . '" embed_type="slideshare"/> <span class="video-duration"></span> <div class="message-content-preview-desc"> <div class="preview-title">' . JHtmlString::truncate($ss->title, 24) . '</div> <div class="preview-desc">' . JHtmlString::truncate($ss->author_name, 180) . '</div> </div><div class="clear"></div>' . whoMakesAction($stream, $slideshareid, 'slideshare') . ' <div class="clear"></div> </div>'; } } } /* Link service * Certain link will able to store excerpt from the linked page */ $params = json_decode($stream->params); /* refetch if the link is not grab yet */ $url = self::getLinks($stream->message); if (!empty($url[0])) { $linkTable = JTable::getInstance('Link', 'StreamTable'); if ($linkTable->load(array('link' => $url[0]))) { $linkParam = StreamLinks::format($linkTable->params); if (!empty($linkParam) && strlen($linkParam->text) > 0) { $html .= '<div class="stream-message-links-in-post">'; if ($linkParam->media_type && $linkParam->media_link) { if (strlen($linkParam->media_type == 'image' && $linkParam->media_link) > 0) { $html .= '<div class="stream-links-image-container"> <span> <img class="stream-message-links-image" src="' . StreamLinks::imageAssetThumbnailPath($linkParam->media_link) . '" /> </span> </div>'; } } $html .= '<div class="stream-links-container"> <div class="stream-message-links-title">' . $linkParam->title . '</div> <div class="stream-message-links-url">' . $linkParam->url . '</div> <div class="stream-message-links-content">' . $linkParam->text . '</div>' . '</div><div class="clear"></div>' . whoMakesAction($stream, $stream->id, 'link') . ' <div class="clear"></div> </div>'; } } } return $html; }
/** * */ public function getStorageStatsHTML() { $jxConfig = new JXConfig(); $current_plan = $jxConfig->getCurrentPlan(); $planPackage = $jxConfig->getAvailablePlans($current_plan); // Change from Gb to bytes $packSize = isset($planPackage[2]) && (int) $planPackage[2] > 0 ? $planPackage[2] : 0; $total = $packSize * 1000 * 1000 * 1000; $fileModel = StreamFactory::getModel('files'); $used = $fileModel->getTotalStorage(JRequest::getVar('user_id', null)); $tmpl = new StreamTemplate(); $tmpl->set('title', JText::_('COM_STREAM_LABEL_STORAGE_USAGE')); $tmpl->set('used', $used)->set('total', $total); $html = $tmpl->fetch('file.module.storagestats'); return $html; }
<?php /** * @package Offiria * @subpackage com_register * @copyright Copyright (C) 2011 - 2013 Slashes & Dots Sdn Bhd. All rights reserved. * @license GNU/GPL, see LICENSE.php * @author Offiria Team */ // No direct access. defined('_JEXEC') or die; require_once JPATH_ROOT . DS . 'components' . DS . 'com_register' . DS . 'factory.php'; JTable::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'tables'); jimport('joomla.utilities.xconfig'); $jxConfig = new JXConfig(); if (!$jxConfig->allowUsersRegister()) { $mainframe = JFactory::getApplication(); $mainframe->redirect(JURI::base(), JText::_('COM_REGISTER_USER_LIMIT_REACHED'), 'error'); } class RegisterControllerRegister extends JController { public function display($cachable = false, $urlparams = false) { // Only admin can use this function to invite guests $jxConfig = new JXConfig(); $mainframe = JFactory::getApplication(); $my = JXFactory::getUser(); $email = JRequest::getVar('email', ''); $token = JRequest::getString('token', ''); $code = JRequest::getString('code', ''); $userInviteTable = JTable::getInstance('usersInvite', 'AccountTable');
/** * Return standardized formatted date * NOTE: FOR TEMPLATE DISPLAY PURPOSE ONLY!!! DO NOT USE FOR DB QUERIES * Also use only for server generated time, NOT */ static function formatDate($date, $long = self::LONG_DATE_FORMAT, $user = null) { // return original input date that cannot be processed if (strtotime($date) === false) { return $date; } $config = new JXConfig(); // First load account setting (if any) timezone to override timezone in language file $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE'); $my = !$user instanceof JUser && !$user instanceof JXUser ? JXFactory::getUser() : $user; $timeZoneStr = $my->getParam('timezone'); // Second load user personalize timezone (if any) to override system default timezone $timeZoneStr = empty($timeZoneStr) ? $defaultTz : $timeZoneStr; $tz = new DateTimeZone($timeZoneStr); if ($date instanceof JDate) { $date = $date->format('Y-m-d h:i:s'); } $datenow = new JDate('now', $tz); $offset = $datenow->getOffset() / 3600; $date = new JDate($date); $date->setOffset($offset); $dateStr = $long == self::LONG_DATE_FORMAT ? $date->format(JText::_('JXLIB_DATE_FORMAT'), true) : $date->format(JText::_('JXLIB_DATE_SHORT_FORMAT'), true); if ($long == self::LONG_DATE_FORMAT) { // Test for today $dmy = $datenow->format(JText::_('JXLIB_DATE_DMY'), true); $dateStr = str_replace($dmy, JText::_('JXLIB_DATE_TODAY'), $dateStr); // Test for yesterday $datenow->modify('-1 day'); $dmy = $datenow->format(JText::_('JXLIB_DATE_DMY'), true); $dateStr = str_replace($dmy, JText::_('JXLIB_DATE_YESTERDAY'), $dateStr); } return $dateStr; }
static function loadLanguage($language = 'default') { // Load language file $lang = JFactory::getLanguage(); $config = new JXConfig(); // First load account setting language (if any) to override joomla! language $defLanguage = $config->getLanguage() != '' ? $config->getLanguage() : $lang->get('default'); /* // Second load user personal language (if any) to override default language $siteLanguage = (intval($user->id) > 0 && $user->getParam('language') != '') ? $user->getParam('language') : $defLanguage; */ $siteLanguage = empty($language) || $language == 'default' ? $defLanguage : $language; $lang->setLanguage($siteLanguage); $result = $lang->load('lib_xjoomla', JPATH_BASE, $siteLanguage, true); }
/** * This will return the user timezone * @param int $user_id id of the user * @param String $forDisplay get the display, if true then return value will be formatted to the proper display * @return String depends on the value of format */ public static function getUserTime($user_id = null, $forDisplay = false) { $config = new JXConfig(); $user = JFactory::getUser($user_id); // First load account setting (if any) timezone to override timezone in language file $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE'); $my = !$user instanceof JUser && !$user instanceof JXUser ? JXFactory::getUser() : $user; $timeZoneStr = $my->getParam('timezone'); // Second load user personalize timezone (if any) to override system default timezone $timeZoneStr = empty($timeZoneStr) ? $defaultTz : $timeZoneStr; $tz = new DateTimeZone($timeZoneStr); $date2 = new JDate('now', $tz); $offset = $date2->getOffset() / 3600; $date = new JDate(); $date->setOffset($offset); $xdate = new JXDate(); /* if the value want to be used as display purposes */ if ($forDisplay) { return $xdate->formatDate($date); } else { return $xdate->format($date); } }
function display($tpl = null) { $configHelper = new JXConfig(); $my = JFactory::getUser(); $defaultLang = JText::_('JXLIB_DEFAULT_LANGUAGE'); $defaultTz = JText::_('JXLIB_DEFAULT_TIMEZONE'); $defaultInvite = JXConfig::DISALLOW; $defaultAnon = JXConfig::ALLOW; // Additional Configuration which are not Joomla! native variables $siteName = $configHelper->get(JXConfig::SITENAME) == '' ? '' : $configHelper->get(JXConfig::SITENAME); $timeZone = $configHelper->getTimezone(); $language = $configHelper->getLanguage(); $allowAnon = $configHelper->get(JXConfig::ALLOW_ANON) == '' ? $defaultAnon : $configHelper->get(JXConfig::ALLOW_ANON); $allowInvite = $configHelper->get(JXConfig::ALLOW_INVITE) == '' ? $defaultInvite : $configHelper->get(JXConfig::ALLOW_INVITE); $limitEmailDomain = $configHelper->get(JXConfig::LIMIT_EMAIL_DOMAIN) == '' ? '' : $configHelper->get(JXConfig::LIMIT_EMAIL_DOMAIN); $domainName = $configHelper->getDomainName(true) == '' ? '' : $configHelper->getDomainName(true); //overwrite value with postParam when save error $error = array(); if ($_POST) { $postParam = JRequest::getVar('params'); $timeZone = isset($postParam['timezone']) ? $postParam['timezone'] : $timeZone; $language = isset($postParam['language']) ? $postParam['language'] : $language; $siteName = isset($postParam['sitename']) ? $postParam['sitename'] : $configHelper->get('sitename'); $allowInvite = isset($postParam['allow_invite']) ? $postParam['allow_invite'] : $allowInvite; $limitEmailDomain = isset($postParam['limit_email_domain']) ? $postParam['limit_email_domain'] : $limitEmailDomain; $domainName = isset($postParam['domain_name']) ? $postParam['domain_name'] : $domainName; } $form = JForm::getInstance('profileForm', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'edit.xml'); $this->assignRef('profileForm', $form); $this->assignRef('my', $my); $this->assignRef('sitename', $siteName); $this->assignRef('default_timezone', $timeZone); $this->assignRef('default_language', $language); $this->assignRef('domain_name', $domainName); $this->assignRef('limit_email_domain', $limitEmailDomain); $this->assignRef('allow_invite', $allowInvite); $this->assignRef('allow_anon', $allowAnon); $this->assign('domain_editable', $configHelper->allowChangeDomain()); $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_ACCOUNT_LABEL_ACCOUNT_SETTING")); parent::display($tpl); }