public function ajaxUploadNewPicture($userId) { $filter = JFilterInput::getInstance(); $userId = $filter->clean($userId, 'int'); $objResponse = new JAXResponse(); $my = CFactory::getUser(); //CFactory::load( 'helpers', 'owner' ); $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES, COMMUNITY_CACHE_TAG_FRONTPAGE)); if (!isCommunityAdmin()) { return $this->ajaxBlockUnregister(); } $title = JText::_('COM_COMMUNITY_CHANGE_AVATAR'); $formAction = CRoute::_('index.php?option=com_community&view=profile&task=uploadAvatar', false); $config = CFactory::getConfig(); $uploadLimit = (double) $config->get('maxuploadsize'); $uploadLimit .= 'MB'; $content = '<form name="jsform-profile-ajaxuploadnewpicture" action="' . $formAction . '" id="uploadForm" method="post" enctype="multipart/form-data" class="reset-gap">'; $content .= '<input class="btn" type="file" id="file-upload" name="Filedata" />'; $content .= '<input type="hidden" name="action" value="doUpload" />'; $content .= '<input type="hidden" name="userid" value="' . $userId . '" />'; $content .= '</form>'; $actions = '<input type="button" class="btn" onclick="cWindowHide();return false;" value="' . JText::_('COM_COMMUNITY_CANCEL_BUTTON') . '" />'; $actions .= '<input type="button" value="' . JText::_('COM_COMMUNITY_BUTTON_UPLOAD_PICTURE') . '" class="btn btn-primary pull-right" onclick="joms.jQuery(\'#uploadForm\').submit();" />'; if ($uploadLimit != 0) { $content .= '<p class="info">' . JText::sprintf('COM_COMMUNITY_MAX_FILE_SIZE_FOR_UPLOAD', $uploadLimit) . '</p>'; } $objResponse->addAssign('cwin_logo', 'innerHTML', $title); $objResponse->addScriptCall('cWindowAddContent', $content, $actions); return $objResponse->sendResponse(); }
function onProfileDisplay() { $mainframe =& JFactory::getApplication(); JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); $document =& JFactory::getDocument(); $my = CFactory::getUser(); $config = CFactory::getConfig(); // Load libraries CFactory::load('libraries', 'wall'); CFactory::load('helpers', 'friends'); $user = CFactory::getRequestUser(); $friendModel = CFactory::getModel('friends'); $avatarModel = CFactory::getModel('avatar'); $isMe = $my->id == $user->id && $my->id != 0; $isGuest = $my->id == 0 ? true : false; $isConnected = CFriendsHelper::isConnected($my->id, $user->id); CFactory::load('helpers', 'owner'); $isSuperAdmin = isCommunityAdmin(); // @rule: Limit should follow Joomla's list limit $jConfig =& JFactory::getConfig(); $limit = JRequest::getVar('limit', $jConfig->getValue('list_limit'), 'REQUEST'); $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST'); if (JRequest::getVar('task', '', 'REQUEST') == 'app') { $cache =& JFactory::getCache('plgCommunityWalls_fullview'); } else { $cache =& JFactory::getCache('plgCommunityWalls'); } $caching = $this->params->get('cache', 1); if ($caching) { $caching = $mainframe->getCfg('caching'); } $cache->setCaching($caching); $callback = array('plgCommunityWalls', '_getWallHTML'); $allowPosting = ($isMe || !$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && $isConnected || $isSuperAdmin) && !$isGuest; $allowRemoval = $isMe || $isSuperAdmin; $maxchar = $this->params->get('charlimit', 0); if (!empty($maxchar)) { $this->characterLimitScript($maxchar); } //$cache_id = JCacheCallback::_makeId(array('plgCommunityWalls', '_getWallHTML'), array($user->id, $limit, $limitstart , $allowPosting , $allowRemoval)); //get cache id $callback_args = array($user->id, $limit, $limitstart, $allowPosting, $allowRemoval); $cache_id = md5(serialize(array($callback, $callback_args))); $javascript = <<<SHOWJS \t\t\t\t\t\t\tfunction getCacheId() \t\t\t\t\t\t \t{ \t\t\t\t\t\t\t\tvar cache_id = "'.{$cache_id}.'"; \t\t\t\t\t\t\t\treturn cache_id; \t\t\t\t\t\t\t} SHOWJS; $document->addScriptDeclaration($javascript); $content = $cache->call($callback, $user->id, $limit, $limitstart, $allowPosting, $allowRemoval); return $content; }
public function ajaxUploadNewPicture($userId) { $objResponse = new JAXResponse(); $my = CFactory::getUser(); CFactory::load('helpers', 'owner'); if (!isCommunityAdmin()) { return $this->ajaxBlockUnregister(); } $title = JText::_('CC EDIT AVATAR'); $objResponse->addAssign('cwin_logo', 'innerHTML', $title); $formAction = CRoute::_('index.php?option=com_community&view=profile&task=uploadAvatar', false); $config = CFactory::getConfig(); $uploadLimit = (double) $config->get('maxuploadsize'); $uploadLimit .= 'MB'; $content = '<form name="jsform-profile-ajaxuploadnewpicture" action="' . $formAction . '" id="uploadForm" method="post" enctype="multipart/form-data">'; $content .= '<input class="inputbox button" type="file" id="file-upload" name="Filedata" />'; $content .= '<input class="button" size="30" type="submit" id="file-upload-submit" value="' . JText::_('CC BUTTON UPLOAD PICTURE') . '">'; $content .= '<input type="hidden" name="action" value="doUpload" />'; $content .= '<input type="hidden" name="userid" value="' . $userId . '" />'; $content .= '</form>'; if ($uploadLimit != 0) { $content .= '<p class="info">' . JText::sprintf('CC MAX FILE SIZE FOR UPLOAD', $uploadLimit) . '</p>'; } $objResponse->addAssign('cWindowContent', 'innerHTML', $content); return $objResponse->sendResponse(); }