public function get_texts_of_author() { // Get the application object. $app = JFactory::getApplication(); $author_id = JRequest::getInt('author_id'); $user_id = JRequest::getInt('user_id'); $profile = JRequest::getInt('profile'); $pub = JRequest::getInt('published'); $type = JRequest::getString('type'); $authorsection = JRequest::getInt('authorsection'); $texts = ideary::getTextsOfUser($author_id, $pub, 0, 10); $countAllTexts = ideary::getCountTextsByUserId($author_id, $pub); $textHtmlArray = array(); if (!empty($texts)) { foreach ($texts as $index => $text) { $textHtmlArray[] = ideary::removeNewLinesFromString(ideary::generateTextContent($text, $author_id, $index, $profile, $authorsection, false, $type)); } } echo json_encode(array('texts' => $textHtmlArray, 'countAllTexts' => $countAllTexts)); $app->close(); }
public function generateMyStatsBox() { $user = JFactory::getUser(); $user_picture = ideary::getUserImage($user->id, "200", $user->get('name')); $html = '<div id="my-ideary-box">'; $html .= '<div id="my-ideary-title">' . $user_picture . '<span>' . JText::_('MY_IDEARY') . '</span></div>'; $html .= '<div id="my-ideary-container">'; $html .= '<ul>'; $html .= '<li class="my-ideary-impact" ><span class="key">Impacto</span> <span class="value">' . ideary::getUserImpact($user->id) . '</span></li>'; $html .= '<li class="my-ideary-applauses" ><span class="key">Aplausos</span> <span class="value">' . ideary::getUserApplausesCount($user->id) . '</span></li>'; $html .= '<li class="my-ideary-idearis" ><span class="key">Idearis</span> <span class="value">' . ideary::getCountTextsByUserId($user->id) . '</span></li>'; $html .= '</ul>'; $html .= '</div>'; $html .= '</div>'; return $html; }
} }); }); </script> <div id="write-text-form" style="overflow:inherit !important;" class="edit item-page<?php echo $this->pageclass_sfx; ?> "> <?php $userId = JFactory::getUser()->get('id'); $idearyCount = ideary::getCountTextsByUserId($userId); $hasFirst = ideary::getHasFirstByUserId($userId); if (!$hasFirst && $idearyCount < 1) { ?> <div id="first-ideari" >Hola! Veo que estás redactando tu primer Ideari. Quería contarte que Ideari es una comunidad, y nos gustaría conocerte. Por eso, nos encantaría que en esta ocasión nos cuentes un poco sobre vos.</div> <?php } ?> <div id="close-icon" class="cancel-button" title="<?php echo JText::_('JCANCEL'); ?> "></div> <form enctype= "multipart/form-data" action="<?php
/** * Method to display the view. * * @param string $tpl The template file to include * @since 1.6 */ public function display($tpl = null) { // Get the view data. $this->data = $this->get('Data'); $this->form = $this->get('Form'); $this->state = $this->get('State'); $this->params = $this->state->get('params'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } // Check if a user was found. if (!$this->data->id) { JError::raiseError(404, JText::_('JERROR_USERS_PROFILE_NOT_FOUND')); return false; } $app = JFactory::getApplication(); $this->user2 = JFactory::getUser(); $getUserId = $_GET['user_id'] ? $_GET['user_id'] : $this->user2->id; if ($getUserId != $this->user2->id) { $app->redirect(JRoute::_('index.php')); } // Check for layout override $active = JFactory::getApplication()->getMenu()->getActive(); if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } $this->user = ideary::getUserInfoById($this->user2->id); $this->userData = ideary::getUserById($this->user2->id); $resultEN = strpos($this->user->params, 'en-GB'); $resultES = strpos($this->user->params, 'es-ES'); $resultPT = strpos($this->user->params, 'pt-BR'); $userextra = Ideary::getExtraUserData($_GET["id"]); if ($resultEN != false && $resultEN != null) { $currentlang = 'en-GB'; } elseif ($resultES != false && $resultES != null) { $currentlang = 'es-ES'; } elseif ($resultPT != false && $resultPT != null) { $currentlang = 'pt-BR'; } $this->assignRef('userextra', $userextra); $this->assignRef('currentlang', $currentlang); $this->userDatafinal = Ideary::getuserData($this->user->id); $this->userDatafinal = $this->userDatafinal[0]; $this->userExtraData = Ideary::getExtraUserData($this->user->id); $this->cant_pub = Ideary::getUserCantTexts($this->user->id, 1); $this->cant_draft = Ideary::getUserCantTexts($this->user->id, 0); if ($_GET["layout"] == "edit") { $this->categories = Ideary::getCategories(); $this->user_interests = Ideary::getUserInterests($this->user->id); } if ($_GET["layout"] == "userconfiguration") { $this->UserNotifSettings = Ideary::getUserNotifSettings($this->user->id); if (count($this->UserNotifSettings) > 0) { $this->UserNotifSettings = $this->UserNotifSettings[0]; } } $pub = $_GET['draft'] == 1 ? 0 : 1; $text_type = $pub ? 'published' : 'draft'; $texts = ideary::getTextsOfUser($this->user->id, $pub, 0, 10); $countAlltexts = ideary::getCountTextsByUserId($this->user->id, $pub); $this->assignRef('texts', $texts); $this->assignRef('countAlltexts', $countAlltexts); $this->assignRef('text_type', $text_type); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->prepareDocument(); parent::display($tpl); }
public function generateMyStatsBox() { $user = JFactory::getUser(); $user_picture = ideary::getUserImage($user->id, "200", $user->get('name')); $publishedCount = ideary::getCountTextsByUserId($user->id); $userImpact = ideary::getUserImpact($user->id); $applauses = ideary::getUserApplausesCount($user->id); $readWord = $publishedCount > 1 ? 'fueron leídos' : 'fue leído'; $publishedWord = $publishedCount > 1 ? 'idearis, los cuales' : 'ideari, el cual'; $html = '<div id="my-ideary-box">'; $html .= '<div id="my-ideary-title">' . $user_picture . '<span>Impacto</span></div>'; $html .= '<div id="my-ideary-container">'; $html .= '<ul>'; $html .= '<li class="my-ideary-idearis" ><span class="key">Publicaste </span> <span class="value">' . $publishedCount . '</span><span> ' . $publishedWord . ' </span></li>'; $html .= '<li class="my-ideary-impact" ><span class="key">' . $readWord . '</span> <span class="value">' . $userImpact . '</span> veces </li>'; if ($applauses > 1) { $html .= '<li class="my-ideary-applauses" ><span class="key">y aplaudidos</span> <span class="value">' . $applauses . '</span> veces.</li>'; } $html .= '</ul>'; $html .= '</div>'; $html .= '</div>'; return $html; }
/** * Method to save a record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return Boolean True if successful, false otherwise. * @since 1.6 */ public function save($key = null, $urlVar = 'a_id') { // Load the backend helper for filtering. require_once JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php'; //var_dump($_POST['jform']);die; $app = JFactory::getApplication(); $error = false; $userId = JFactory::getUser()->get('id'); $isFirstIdeari = false; $jform['title'] = $_POST['jform']['title']; $jform['new'] = $_POST['jform']['new']; $jform['articletext'] = $_POST['jform']['articletext']; $jform['catid'] = 33; $app->setUserState('jformulario', $jform); if ($error) { session_start(); $_SESSION['flash']['msg'] = "Hubo un error al guardar tu Ideary ):"; $_SESSION['flash']['class'] = "error"; $idQueryString = $_POST['jform']['id'] != -1 ? '&a_id=' . $_POST['jform']['id'] : ''; $this->setRedirect(JRoute::_('index.php?option=com_content&view=form&layout=edit' . $idQueryString, false)); } else { $idearyCount = ideary::getCountTextsByUserId($userId); $hasFirst = ideary::getHasFirstByUserId($userId); $isFirstIdeari = !$hasFirst && $idearyCount < 1; $result = parent::save($key, $urlVar); $db =& JFactory::getDBO(); $model = $this->getModel(); if ($_POST['jform']['id'] == -1) { $textId = $model->getLastInsertedTextId(); } else { $textId = $_POST['jform']['id']; $isFirstIdeari = null; } $save_author_write_not = false; $actual_date = ''; if ($_POST['jform']['id'] == -1) { //...si el texto es nuevo. if ($_POST['jform']['state']) { //...si lo estamos publicando. $save_author_write_not = true; } $actual_date = 'created=NOW(), '; } else { $sql = 'SELECT COUNT(*) FROM text_notifications n ' . 'JOIN text_notification_types nt ON (nt.id=n.notification_type_id) ' . 'WHERE text_id=' . $textId . ' AND nt.type="followed_write"'; $db->setQuery($sql); $save_author_write_not = $db->loadResult() ? false : true; } // text was published, notify followers if ($save_author_write_not && $_POST['jform']['state']) { $sql = "SELECT DISTINCT follower_id FROM text_follows WHERE followed_id=" . $userId; $db->setQuery($sql); $authorFollowers = $db->loadObjectList(); foreach ($authorFollowers as $authorFollower) { $query = 'INSERT INTO text_notifications (user_id, notified_id, text_id, notification_type_id, created_at, saw) ' . 'VALUES ' . '(' . $userId . ', ' . $authorFollower->follower_id . ', ' . $textId . ', (SELECT id FROM text_notification_types WHERE TYPE="followed_write"), NOW(), FALSE)'; $db->setQuery($query); $db->query(); } } if (!$_POST['jform']['state']) { // text was unpublished, delete all notifications of it's publication $query = "\n \t \tDELETE FROM text_notifications \n \t \tWHERE text_id={$textId}\n\t\t\t\t\tAND notification_type_id in (\n\t\t\t\t\t\tselect id from text_notification_types\n\t\t\t\t\t\twhere type='followed_write'\n\t\t\t\t\t)"; $db->setQuery($query); $db->query(); } // Strip slashes added by magic quotes by dummy servers if (get_magic_quotes_gpc()) { $_POST['jform']['articletext'] = stripslashes($_POST['jform']['articletext']); } $query = 'UPDATE #__content SET ' . 'introtext="' . mysql_real_escape_string($_POST['jform']['articletext']) . '", ' . 'allow_comments=' . $_POST['jform']['comments'] . ', ' . 'state=' . $_POST['jform']['state'] . ', ' . 'catid=33, ' . 'modified_by=created_by, ' . 'checked_out=created_by, ' . $actual_date . 'editor_font_scale=' . $_POST['jform']['editor-font-scale'] . ', ' . 'editor_font_size="' . $_POST['jform']['editor-font-size'] . '" ' . ($isFirstIdeari === null ? '' : ', first=' . ($isFirstIdeari ? 1 : 0)) . ' ' . 'WHERE id=' . $textId; $db->setQuery($query); $db->query(); $app->setUserState('jformulario', null); ideary::clearCache(); switch ($_POST["accionpost"]) { case 'home': $this->setRedirect(JRoute::_('index.php?option=com_users&view=login')); break; case 'mytexts': $this->setRedirect(JRoute::_('index.php?option=com_users&mytexts=1&view=profile&user_id=' . $userId)); break; case 'draft': $this->setRedirect(JRoute::_('index.php?option=com_users&draft=1&view=profile&user_id=' . $userId)); break; case 'same': session_start(); $_SESSION['flash']['msg'] = "Tu Ideary fue guardado exitosamente!"; $_SESSION['flash']['class'] = "success"; $this->setRedirect(JRoute::_("index.php?option=com_content&Itemid=101&a_id=" . $textId . "&task=article.edit")); break; case 'view': session_start(); $this->setRedirect(JRoute::_("index.php?option=com_content&view=article&id=" . $textId)); break; } return $result; } }