public function replaceNew() { $my = JXFactory::getUser(); $file_id = JRequest::getInt('file_id'); $file = JTable::getInstance('File', 'StreamTable'); $result = new stdClass(); $result->error = true; if (intval($file_id) > 0) { $file->load($file_id); $previousFilename = $file->filename; if ($file->user_id != $my->id) { continue; } require JPATH_ROOT . DS . 'components' . DS . 'com_stream' . DS . 'controllers' . DS . 'system.php'; $systemController = new StreamControllerSystem(); $result = $systemController->handleUpload(); if (isset($result['success']) && $result['success']) { // Get mime type if (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension $file->mimetype = finfo_file($finfo, JPATH_ROOT . DS . $result['path']); finfo_close($finfo); } else { $file->mimetype = @mime_content_type(JPATH_ROOT . DS . $result['path']); } $newFileExt = array_pop(explode('.', $result['filename'])); $oldFileExt = array_pop(explode('.', $file->filename)); $file->filename = preg_replace('/\\.\\w+$/', '.' . $newFileExt, $file->filename); // Delete the old one before saving the new one to the file db entry if ($file->getParam('has_preview')) { JFile::delete(JPATH_ROOT . DS . $file->path); $pathinfo = pathinfo($file->path); $thumbPath = JPATH_ROOT . DS . $pathinfo['dirname'] . DS . $pathinfo['filename'] . '_thumb.jpg'; JFile::delete($thumbPath); $thumbPath = JPATH_ROOT . DS . $pathinfo['dirname'] . DS . $pathinfo['filename'] . '_preview.jpg'; JFile::delete($thumbPath); } // set the file entry to the new uploaded file $file->path = $result['path']; $file->filesize = filesize(JPATH_ROOT . DS . $file->path); $file->store(); // Trigger Mentioned Name Notification $notificationType = 'file_replace_new'; StreamNotification::trigger($notificationType, $file, $previousFilename); $result['filename'] = $file->filename; $result['newext'] = $newFileExt; $result['oldext'] = $oldFileExt; $result['filesize'] = '(' . StreamMessage::formatBytes($file->filesize) . ')'; if ($file->getParam('has_preview')) { $pathinfo = pathinfo($result['path']); $result['preview'] = JURI::root() . str_replace(DS, '/', $file->getParam('thumb_path')); } else { $result['preview'] = JURI::root(); } } } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); exit; }
/** * Check user access * * @action string should be in a form of 'objectName.actionName' * @asset mixed typical an object which is needed to resolve permission */ public static function check($userid, $action, $asset) { $permission = true; switch ($action) { case 'profiles.list': // Disallow profile listing access for invited user with lmited access $user = JXFactory::getUser($userid); if ($user->getParam('groups_member_limited')) { return false; } break; case 'profile.read': // $asset contains user object to be accessed. $user = JXFactory::getUser($userid); if ($user->getParam('groups_member_limited')) { return false; } //@todo : check for the given break; case 'profile.edit': break; default: # code... break; } return $permission; }
function display($tpl = null) { jimport('joomla.html.pagination'); $configHelper = new JXConfig(); $usersInvite = AccountFactory::getModel('usersInvite'); $my = JXFactory::getUser(); $total = $usersInvite->getTotal(array('from_email' => $my->email)); $result = $usersInvite->getList(array('from_email' => $my->email, 'order_by' => 'status, last_invite_date'), $configHelper->get('list_limit'), JRequest::getVar('limitstart', 0)); $inviteEmail = ''; if ($_POST) { $postVar = JRequest::getVar('params'); $inviteEmail = $postVar['invitation']; } // Extranet/Limited groups $groupModel = StreamFactory::getModel('groups'); $myJoinedGroups = $groupModel->getGroups(array('id' => $my->getParam('groups_member')), 100); // Pagination $pagination = new JPagination($total, JRequest::getVar('limitstart', 0), $configHelper->get('list_limit')); $pendingStat = AccountTableUsersInvite::PENDING; $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_ACCOUNT_LABEL_INVITE_USERS")); $this->assignRef('inviteEmail', $inviteEmail); $this->assignRef('pagination', $pagination); $this->assignRef('pendingStat', $pendingStat); $this->assign('allowInvite', $configHelper->allowUsersRegister()); $this->assignRef('results', $result); $this->assignRef('myJoinedGroups', $myJoinedGroups); parent::display($tpl); }
public function display($cachable = false, $urlparams = false) { // Only admin can use this function to invite guests $mainframe = JFactory::getApplication(); $my = JXFactory::getUser(); if ($_POST) { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $jxConfig = new JXConfig(); $name = JRequest::getVar('name', ''); $email = JRequest::getVar('email', ''); $username = JRequest::getVar('username', ''); $password1 = JRequest::getString('password', ''); $password2 = JRequest::getString('confirm_password', ''); $data = array('name' => $name, 'username' => $username, 'password' => $password1, 'conf_pass' => $password2, 'email' => $email); $model = RegisterFactory::getModel('registration'); if ($model->registerUser($data)) { $mainframe->redirect(JURI::base(), JText::_('COM_REGISTER_MSG_REGISTRATION_SUCCESSFUL')); } else { $mainframe->enqueueMessage($model->getError(), 'error'); } } JRequest::setVar('view', 'register'); parent::display(); }
function display($tpl = null) { $jconfig = new JConfig(); jimport('joomla.html.pagination'); include_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'string.php'; $this->addPathway(JText::_('NAVIGATOR_LABEL_FILE'), JRoute::_('index.php?option=com_stream&view=groups')); $title = JText::_("COM_STREAM_LABEL_LINK_LISTING"); $this->_attachScripts(); // Reset the stream view count every time we visit this page $user = JXFactory::getUser(); $filter = array(); // Filter by user_id (cannot be used along with 'by' filter) if ($user_id = JRequest::getVar('user_id', '')) { $filter['user_id'] = $user_id; $user = JXFactory::getUser($user_id); $title = JText::sprintf("%1s's links", $user->name); } $usrLinks = $user->getParam('links', ''); $linkModel = StreamFactory::getModel('links'); $links = $linkModel->getLinks(array('id' => $usrLinks, '!link' => ''), $jconfig->list_limit, JRequest::getVar('limitstart', 0)); $total = $linkModel->getTotal(array('id' => $usrLinks, '!link' => '')); $doc = JFactory::getDocument(); $doc->setTitle($title); // Pagination $pagination = new JPagination($total, JRequest::getVar('limitstart', 0), $jconfig->list_limit); $html = ''; $tmpl = new StreamTemplate(); $tmpl->set('links', $links)->set('pagination', $pagination); $html .= $tmpl->fetch('links.list'); return $html; }
public function display() { // Only admin can use this function to invite guests $jxConfig = new JXConfig(); $my = JXFactory::getUser(); $mainframe = JFactory::getApplication(); $accessHelper = new AccountAccessHelper(); if (!$my->authorise('stream.setting.edit', $accessHelper)) { $mainframe->redirect(JURI::base(), JText::_('COM_ACCOUNT_ERRMSG_INVITATION_DENIED'), 'error'); } if ($_POST) { jimport('joomla.utilities.xintegration'); // Check if there is ad_integration posted and if the value is activedirectory // by comparing with xintegration library for supported integrations $adIntegration = JRequest::getString('ad_integration', ''); if (!empty($adIntegration) && JXIntegration::isActiveDirectory($adIntegration)) { $integrationTbl = JTable::getInstance('integration', 'AccountTable'); $integrationTbl->load(array('name' => $adIntegration)); $integrationTbl->setParam('dc', JRequest::getString('ad_dc', '')); $integrationTbl->setParam('dm', JRequest::getString('ad_dm', '')); if (JRequest::getString('ad_pw', '') != '') { $integrationTbl->setParam('pw', JRequest::getString('ad_pw', '')); } $integrationTbl->setParam('un', JRequest::getString('ad_un', '')); $integrationTbl->setParam('hi', JRequest::getString('ad_hi', '')); if (!$integrationTbl->store()) { $mainframe->redirect(JRoute::_('index.php?option=com_account&view=integration'), $integrationTbl->getError(), 'error'); } $mainframe->redirect(JRoute::_('index.php?option=com_account&view=integration'), JText::_('COM_ACCOUNT_ACTION_SAVE_INTEGRATION_SUCCESS!')); } } parent::display(); }
function display($tpl = null) { $doc = JFactory::getDocument(); $title = JText::_("NAVIGATOR_LABEL_BLOG"); $this->addPathway(JText::_('NAVIGATOR_LABEL_BLOG'), JRoute::_('index.php?option=com_stream&view=blog')); $html = ''; // Build the proper blog title if ($month = JRequest::getVar('month', '')) { $monthList = array(1 => 'JANUARY', 2 => 'FEBRUARY', 3 => 'MARCH', 4 => 'APRIL', 5 => 'MAY', 6 => 'JUNE', 7 => 'JULY', 8 => 'AUGUST', 9 => 'SEPTEMBER', 10 => 'OCTOBER', 11 => 'NOVEMBER', 12 => 'DECEMBER'); $title .= ' - ' . JText::_($monthList[$month]) . ' '; } if ($year = JRequest::getVar('year', '')) { $title .= $year; } $doc->setTitle($title); $tmpl = new StreamTemplate(); $html .= $tmpl->fetch('blog.header'); $my = JXFactory::getUser(); if (!$my->getParam(ALERT_BLOG_INTRO)) { $html .= ' <div class="alert alert-success" data-alert_id="' . ALERT_BLOG_INTRO . '"> <a data-dismiss="alert" class="close">×</a> ' . JText::_('COM_STREAM_HELPER_BLOG') . '</div>'; } $html .= $this->getStreamDataHTML(); echo $html; }
public function search($username, $filter = null) { if (empty($username)) { return array(); } $where = array(); $db = JFactory::getDbo(); if (isset($filter['!id']) && !empty($filter['!id'])) { // Id can be a single number or list of ids, such as 1,2,3,4,5 $filter['!id'] = trim((string) $filter['!id'], ','); $where[] = $db->nameQuote('t.id') . " NOT IN (" . $filter['!id'] . ") "; } if (empty($where)) { $where[] = ' 1 '; } // Select those with username start with the given name // and later search those with the given username in the middle $query = " SELECT * FROM (SELECT id FROM #__users WHERE `username` LIKE " . $db->Quote($username . '%') . " UNION" . " SELECT id FROM #__users WHERE `username` LIKE " . $db->Quote('%' . $username . '%') . " ) as t" . " WHERE " . implode(' AND ', $where); $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $users = array(); foreach ($result as $row) { $users[] = JXFactory::getUser($row->id); } return $users; }
/** * Open, parse, and return the template file. * * @param $file string the template file name */ public function fetch($file = null) { $tmpFile = $file; if (empty($file)) { $file = $this->file; } $file = JPATH_ROOT . DS . 'components' . DS . 'com_messaging' . DS . 'templates' . DS . 'default' . DS . $file . '.php'; // Template variable: $my; $my = JXFactory::getUser(); $this->setRef('my', $my); // Template variable: the rest. if ($this->vars) { extract($this->vars, EXTR_REFS); } if (!JFile::exists($file)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('COM_STREAM_TEMPLATE_FILE_NOT_FOUND', $tmpFile . '.php'), 'error'); return; } ob_start(); // Start output buffering require $file; // Include the file $contents = ob_get_contents(); // Get the contents of the buffer ob_end_clean(); // End buffering and discard // Replace all _QQQ_ to " // Language file now uses new _QQQ_ to maintain Joomla 1.6 compatibility $contents = MessagingTemplate::quote($contents); return $contents; // Return the contents }
/** * Allow user */ public static function allowPublicStream($userid) { $user = JXFactory::getUser($userid); if ($user->getParam('groups_member_limited')) { return false; } return true; }
function display($tpl = null) { $document = JFactory::getDocument(); $document->addScript(JURI::root() . "/media/jquery/jquery-1.7.min.js"); $document->addScript(JURI::root() . 'components/com_profile/assets/javascript/script.js'); $user = JXFactory::getUser(); $this->assignRef('user', $user); parent::display($tpl); }
public function ajaxGenerateAnalytics() { $username = JRequest::getVar('user', ''); $user = JXFactory::getUser($username); $view = ProfileFactory::getView('display'); $html = $view->generateAnalytics($user); echo $html; exit; }
public function __construct($user = null) { if (is_null($user) || !$user instanceof JUser) { $this->_user = JXFactory::getUser(); } else { $this->_user = $user; } $this->_initializeDefault(); $this->_prepareDefault($this->_user->getParameters()); }
/** * Basic message read permission */ public function allowRead($userid) { // If private, only the group member can access if ($this->data->access) { $my = JXFactory::getUser(); $userGroups = $my->getParam('groups_member'); // added condition to allow also siteadmin and superuser to read the private group content return JXUtility::csvExist($userGroups, $this->data->group_id) || $my->isAdmin(); } return true; }
public function unlike() { $my = JXFactory::getUser(); $likesInArray = explode(',', trim($this->likes, ',')); if (in_array($my->id, $likesInArray)) { // Remove user like from array $key = array_search($my->id, $likesInArray); unset($likesInArray[$key]); $this->likes = ltrim(implode(',', $likesInArray), ','); } }
public function __construct($user = null) { if (is_null($user) || !$user instanceof JUser) { $this->_user = JXFactory::getUser(); } else { $this->_user = $user; } // Include tables JTable::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_oauth' . DS . 'tables'); $this->_table = JTable::getInstance('token', 'OauthTable'); }
/** * Implements OAuth2::setAccessToken(). */ public function setAccessToken($oauthToken, $clientId, $expires, $scope = NULL) { $my = JXFactory::getUser(); $id = $this->_table->getParam('id', array('user_id' => $my->id, 'client_id' => $clientId)); $this->_table->load($id); $this->_table->oauth_token = $oauthToken; $this->_table->client_id = $clientId; $this->_table->expires = $expires; $this->_table->scope = $scope; return $this->_table->store(); }
public function delete() { $my = JXFactory::getUser(); $customlist_id = JRequest::getVar('customlist_id'); $customList = JTable::getInstance('Customlist', 'StreamTable'); $customList->load($customlist_id); $customList->delete(); $data = array(); $data['redirect'] = JRoute::_('index.php?option=com_stream&view=company', FALSE); echo json_encode($data); exit; }
/** * Show the message reading page */ public function read($data) { $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $doc = JFactory::getDocument(); // Add file attachment library $doc->addScript(JURI::root() . 'media/uploader/fileuploader.js'); $doc->addStyleSheet(JURI::root() . 'media/uploader/fileuploader.css'); $this->addPathway(JText::_('COM_COMMUNITY_INBOX'), JRoute::_('index.php?option=com_messaging&view=inbox')); //JXModule::addBuffer('right', '<br /><h4>Side bar stuff goes here</h4>'); $inboxModel = MessagingFactory::getModel('inbox'); $msgid = JRequest::getVar('msgid', 0, 'REQUEST'); $parentData = ''; $html = $htmlContent = ''; $messageHeading = ''; $recipient = array(); $parentData = $inboxModel->getMessage($msgid); if (!empty($data->messages)) { $document = JFactory::getDocument(); $document->setTitle($this->escape($parentData->subject)); $this->addPathway($this->escape($parentData->subject)); foreach ($data->messages as $row) { // onMessageDisplay Event trigger $args = array(); $args[] =& $row; $user = JXFactory::getUser($row->from); //construct the delete link $deleteLink = JRoute::_('index.php?option=com_community&task=remove&msgid=' . $row->id); $authorLink = JRoute::_('index.php?option=com_profile&view=display&user='******'user', $user)->set('msg', $row)->set('isMine', 0)->set('removeLink', $deleteLink)->set('authorLink', $authorLink)->set('attachments', $attachments)->set('readBy', $readBy)->fetch('inbox.message'); } $myLink = JRoute::_('index.php?option=com_profile&view=display'); $recipient = array(); // Put the sender in the participant list $from = new stdClass(); $from->to = $parentData->from; $recipient[] = $from; $recipient = array_merge($recipient, $inboxModel->getRecepientMessage($msgid)); $recepientCount = count($recipient) - 1; // exclude the sender $textOther = $recepientCount > 1 ? 'COM_COMMUNITY_MSG_OTHER' : 'COM_COMMUNITY_MSG_OTHER_SINGULAR'; $messageHeading = JText::sprintf('COM_COMMUNITY_MSG_BETWEEN_YOU_AND_USER', $myLink, '#', JText::sprintf($textOther, $recepientCount)); } else { $html = '<div class="text">' . JText::_('COM_COMMUNITY_INBOX_MESSAGE_EMPTY') . '</div>'; } $tmplMain = new MessagingTemplate(); $html .= $tmplMain->set('messageHeading', $messageHeading)->set('msgid', $msgid)->set('recipient', $recipient)->set('messages', $data->messages)->set('parentData', $parentData)->set('htmlContent', $htmlContent)->set('my', $my)->fetch('inbox.read'); return $html; }
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'); $userInviteTable->load(array('invite_email' => $email, 'status' => AccountTableUsersInvite::PENDING, 'token' => $token)); if ($userInviteTable->id) { if ($_POST) { $name = JRequest::getVar('name', ''); $username = JRequest::getVar('username', ''); $password1 = JRequest::getString('password', ''); $password2 = JRequest::getString('confirm_password', ''); $data = array('name' => $name, 'username' => $username, 'password' => $password1, 'conf_pass' => $password2, 'email' => $email, 'group_limited' => $userInviteTable->group_limited); $model = RegisterFactory::getModel('registration'); if ($userid = $model->registerUser($data)) { $userInviteTable->status = AccountTableUsersInvite::REGISTERED; $userInviteTable->store(); // If user is invited to a certain group only, add the user into the group if ($userInviteTable->group_limited) { // Include tables JTable::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_stream' . DS . 'tables'); $groups = explode(',', $userInviteTable->group_limited); $user = JXFactory::getUser($userid); foreach ($groups as $group_id) { $group = $group = JTable::getInstance('Group', 'StreamTable'); $group->load($group_id); // If you join, you'd also follow it $group->members = JXUtility::csvInsert($group->members, $user->id); $group->followers = JXUtility::csvInsert($group->followers, $user->id); $group->store(); // Store user cache $groupList = $user->getParam('groups_member'); $groupList = JXUtility::csvInsert($groupList, $group->id); $user->setParam('groups_member', $groupList); $user->save(); } } $mainframe->redirect(JURI::base(), JText::_('COM_REGISTER_MSG_REGISTRATION_SUCCESSFUL')); } else { $mainframe->enqueueMessage($model->getError(), 'error'); } } parent::display(); } else { $mainframe->redirect(JURI::base(), JText::_('COM_REGISTER_ERRMSG_NO_VALID_INVITATION'), 'error'); } }
public static function sortLastActive($groupA, $groupB) { $my = JXFactory::getUser(); $diffA = $groupA->getParam('last_message') - $my->getParam('group_' . $groupA->id . '_last'); $diffB = $groupB->getParam('last_message') - $my->getParam('group_' . $groupB->id . '_last'); if ($diffA < $diffB) { return 1; } if ($diffA > $diffB) { return -1; } return 0; }
/** * */ public function display($cachable = false, $urlparams = false) { JRequest::setVar('view', 'members'); $my = JXFactory::getUser(); $username = JRequest::getVar('user', ''); $user = JXFactory::getUser($username); // People need to be able to read the group if (!$my->authorise('profile.read', $user)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'error'); return; } parent::display(true); }
function display($tpl = null) { $user = JXFactory::getUser(); $this->assignRef('user', $user); JForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields'); $form = JForm::getInstance('form', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'details.xml'); $detailModel = ProfileFactory::getModel('detail'); $form->bind(array('params' => $detailModel->getDetails($user->id))); $this->assignRef('form', $form); $document = JFactory::getDocument(); $document->addScript(JURI::root() . 'media/jquery/jquery-1.7.min.js'); $document->setTitle(JText::_('COM_PROFILE_LABEL_EDIT_DETAILS')); parent::display($tpl); }
public function edit() { $mainframe = JFactory::getApplication(); $view = StreamFactory::getView('blog', '', 'html'); $message_id = JRequest::getVar('message_id'); // @todo: make sure message id and message type is valid $stream = JTable::getInstance('Stream', 'StreamTable'); $stream->load($message_id); $my = JXFactory::getUser(); if (!$my->authorise('stream.message.edit', $stream)) { $mainframe->redirect($stream->getUri(), JText::_('You do not have permission to edit this message'), 'error'); return; } // Save blog post // @todo: validation if (JRequest::getVar('action') == 'save') { // Update attachement there might be addition and removals $oldFiles = $stream->getFiles(); //@todo: validate content $errors = array(); $stream->bind(JRequest::get('POST', JREQUEST_ALLOWRAW)); $stream->raw = json_encode(JRequest::get('POST', JREQUEST_ALLOWRAW)); if (empty($_POST['title'])) { $errors[] = JText::_('COM_STREAM_BLOG_POST_NO_TITLE'); } if (empty($_POST['message'])) { $errors[] = JText::_('COM_STREAM_BLOG_POST_EMPTY'); } if (empty($errors)) { $stream->store(); $mainframe->enqueueMessage(JText::_('COM_STREAM_BLOG_POST_UPDATED')); // Delete file attachment that are no longer used foreach ($oldFiles as $file) { if (!in_array($file->id, JRequest::getVar('attachment', array()))) { $file->delete(); } } // For all new attachment, we need to set their owner $fileModel = StreamFactory::getModel('files'); $fileModel->updateOwner($stream); } else { foreach ($errors as $err) { $mainframe->enqueueMessage($err, 'error'); } } } echo $view->edit($stream); }
function display($tpl = null) { $name = JRequest::getString('user'); $userId = JUserHelper::getUserId($name); $user = JXFactory::getUser($userId); $lastStatus = $user->getStatus(); $vals['name'] = $user->get('name'); $vals['username'] = $user->get('username'); $vals['designation'] = $user->get('designation'); $vals['about_me'] = $user->getParam('about_me'); $vals['skills'] = $user->get('skills'); $vals['avatar'] = $user->getAvatarURL(); // wrapper $results['profile'] = $vals; echo json_encode($results); exit; }
function display($tpl = null) { // Reset the Analytics view count every time we visit this page $doc = JFactory::getDocument(); $my = JXFactory::getUser(); $doc->setTitle(JText::_('COM_ANALYTICS_LABEL_COMMUNITY_ANALYTICS')); // this section is to get the group_type to set the twitter button's toggle $validGroupType = JAnalytics::getGroupType(); $analyticsGroupBy = JRequest::getVar('group_type', 'day'); $analyticIndex = array_search($analyticsGroupBy, $validGroupType); $analyticIndex = $analyticIndex === false ? 1 : $analyticIndex; $this->assign('analyticHtml', $this->generateAnalytics()); $this->assign('analyticType', $validGroupType); $this->assign('analyticIndex', $analyticIndex); $this->assign('activeUserList', $this->getActiveUser()); $this->assign('activeGroupList', $this->getActiveGroup()); 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); }
function display($tpl = null) { $user = JXFactory::getUser(); $this->assignRef('user', $user); // use JForm to create standardize $form = JForm::getInstance('profileForm', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'edit.xml'); $this->assignRef('profileForm', $form); $this->assign('userEmail', $user->get('email')); $this->assign('userTimezone', $user->getParam('timezone')); $this->assign('userLanguage', $user->getParam('language')); $this->assign('userAboutMe', $user->getParam('about_me')); $this->assign('isIntegration', JXIntegration::isActiveDirectory($user->getParam('integration'))); /* $this->assignRef('timezoneList', $this->getTimezoneList()); */ /* /\* defaulted to +8 *\/ */ /* $jLang = JFactory::getLanguage(); */ /* $this->assignRef('languageList', $jLang->getKnownLanguages()); */ $document = JFactory::getDocument(); $document->addScript(JURI::root() . 'media/jquery/jquery-1.7.min.js'); $document->setTitle(JText::_('COM_PROFILE_LABEL_EDIT_PROFILE')); parent::display($tpl); }
public function showMessages() { jimport('joomla.html.pagination'); $app = JFactory::getApplication(); $my = JXFactory::getUser(); $jconfig = new JConfig(); $html = ''; if ($ids = JRequest::getVar('ids', '')) { $filter['id'] = $ids; } $model = StreamFactory::getModel('stream'); $data = $model->getStream($filter, $jconfig->list_limit, JRequest::getVar('limitstart', 0)); // for some reason, data retrieved has not permissable view message foreach ($data as $streamMsg) { if (!$my->authorise('stream.message.read', $streamMsg)) { $app = JFactory::getApplication(); $app->redirect(JURI::base(), JText::_('COM_STREAM_ERROR_NO_ACCESS'), 'error'); exit; } } $total = $model->countStream($filter); // Pagination $pagination = new JPagination($total, JRequest::getVar('limitstart', 0), $jconfig->list_limit); // If URI is defined, we need to set the pagination link properly if ($uri = JRequest::getVar('uri', '')) { $uri = new JURI($uri); $router = $app->getRouter(); $result = $router->parse($uri); foreach ($result as $key => $val) { $pagination->setAdditionalUrlParam($key, $val); } } $tmpl = new StreamTemplate(); $tmpl->set('rows', $data); $tmpl->set('total', $total); $tmpl->set('pagination', $pagination); $html .= $tmpl->fetch('stream.data'); return $html; }
function display($tpl = null) { $this->addPathway(JText::_('NAVIGATOR_LABEL_INBOX'), JRoute::_('index.php?option=com_stream&view=direct')); $this->_attachScripts(); $my = JXFactory::getUser(); $html = ''; $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_STREAM_MY_PRIVATE_MESSAGES")); // Add attachment script $doc->addScript(JURI::root() . 'media/uploader/fileuploader.js'); $doc->addStyleSheet(JURI::root() . 'media/uploader/fileuploader.css'); jimport('joomla.html.pagination'); $jconfig = new JConfig(); $filter = array(); if ($mention = JRequest::getVar('mention', '')) { $filter['mention'] = '@' . $mention; } if ($search = JRequest::getVar('search', '')) { $filter['search'] = $search; } $status = JRequest::getVar('status', ''); if ($status != '') { $filter['status'] = $status; } $filter['type'] = 'direct'; $model = StreamFactory::getModel('stream'); $data = $model->getStream($filter); $total = $model->countStream($filter); $pagination = new JPagination($total, JRequest::getVar('limitstart', 0), $jconfig->list_limit); $html = ''; $tmpl = new StreamTemplate(); $tmpl->set('rows', $data); $tmpl->set('total', $total); $tmpl->set('pagination', $pagination); $html .= $tmpl->fetch('direct.list'); echo $html; }