private function checkValue($name, $value) { static $initCharacters; $db =& JFactory::getDBO(); if ($name == 'personId') { $tmp = explode('!', $value); if (strlen($tmp[1]) > (int) JoaktreeHelper::getIdlength()) { die('wrong request'); } $tmp[0] = (int) $tmp[0]; $tmp[1] = $db->escape($tmp[1]); $retValue = $tmp; } else { $retValue = $db->escape($value); $retValue = (int) $retValue; } return $retValue; }
public function save() { $canDo = JoaktreeHelper::getActions(); if ($canDo->get('core.edit')) { $input = JFactory::getApplication()->input; $cids = $input->get('cid', null, 'array'); foreach ($cids as $cid) { $id = explode('!', $cid); $id[0] = (int) $id[0]; // This is app_id $id[1] = substr($id[1], 0, (int) JoaktreeHelper::getIdlength()); // This is person_id $robot = $input->get('robot' . $cid, null, 'int'); $map = $input->get('map' . $cid, null, 'int'); $query = $this->_db->getQuery(true); $query->update(' #__joaktree_admin_persons '); $query->set(' robots = ' . ($robot - 1) . ' '); $query->set(' map = ' . ($map - 1) . ' '); $query->where(' app_id = ' . $id[0] . ' '); $query->where(' id = ' . $this->_db->quote($id[1]) . ' '); $this->_db->setQuery($query); $this->_db->query(); } $return = JText::sprintf('JTADMIN_PERSONS_UPDATED', count($cids)); } else { $return = JText::_('JT_NOTAUTHORISED'); } return $return; }
public function getArticle($id, $app_id, $person_id, $type) { $articleId = (int) $id; $app_id = (int) $app_id; $person_id = $this->_db->escape(substr($person_id, 0, (int) JoaktreeHelper::getIdlength())); $query = $this->_db->getQuery(true); if ($type == 'article') { // select from content $query->select(' a.id AS id '); $query->select(' a.title AS title '); $query->select(' a.introtext AS introtext '); $query->select(' a.fulltext AS \'fulltext\' '); $query->select(' DATE_FORMAT( a.modified, "%e %b %Y" ) AS modified '); $query->select(' a.attribs AS attribs '); $query->from(' #__content AS a '); $query->where(' a.state = 1 '); $query->where(' a.access IN ' . $this->_levels . ' '); $query->where(' a.id = ' . $articleId . ' '); // Filter by language if ($this->languageFilter) { $query->where('a.language in (' . $this->_db->Quote(JFactory::getLanguage()->getTag()) . ',' . $this->_db->Quote('*') . ') '); } // select from categories $query->select(' cc.id AS cat_id '); $query->leftJoin(' #__categories AS cc ' . ' ON ( cc.id = a.catid ' . ' AND cc.published = 1 ' . ' AND cc.access IN ' . $this->_levels . ' ' . ' ) '); } else { if ($type == 'note') { $params = JoaktreeHelper::getJTParams(); $titleLength = (int) $params->get('notetitlelength', 0); // prepare title // 1. Trim the title to "titlelength" after first space and remove , (if present) $tmp = ' TRIM( TRAILING ' . $this->_db->Quote(',') . ' FROM ' . ' RTRIM( SUBSTRING( IFNULL( jne.value, jpn.value ) ' . ' , 1 ' . ' , LOCATE( ' . $this->_db->Quote(' ') . ' ' . ' , IFNULL( jne.value, jpn.value ) ' . ' , ' . $titleLength . ' ' . ' ) ' . ' ) ' . ' ) ' . ' ) '; // 2. Concatenat the trimmed text with .... $attribs = array(); $attribs[] = $tmp; $attribs[] = $this->_db->Quote(' ...'); $concat = $query->concatenate($attribs); // end prepare title $query->select(' jpn.orderNumber AS id '); $query->select(' IF( ' . $titleLength . ' = 0 ' . ' , ' . $this->_db->Quote(JText::_('JT_NOTE')) . ' ' . ' , ' . $concat . ' ' . ' ) AS title '); $query->select(' IFNULL( jne.value, jpn.value ) AS introtext '); $query->select(' NULL AS \'fulltext\' '); $query->select(' jpn.person_id AS cat_id '); $query->select(' NULL AS modified '); $query->from(' #__joaktree_person_notes AS jpn '); $query->leftJoin(' #__joaktree_notes AS jne ' . ' ON ( jne.app_id = jpn.app_id ' . ' AND jne.id = jpn.note_id ' . ' ) '); $query->where(' jpn.app_id = ' . $app_id . ' '); $query->where(' jpn.person_id = ' . $this->_db->Quote($person_id) . ' '); $query->where(' jpn.orderNumber = ' . $articleId . ' '); } } $this->_db->setQuery($query); $article = $this->_db->loadObject(); // Convert parameter fields to objects for article. if (isset($article->attribs)) { $registry = new JRegistry(); $registry->loadString($article->attribs); $indIntrotext = $registry->get('show_intro', '1'); } else { $indIntrotext = '0'; } // Are we showing introtext with the article if ($indIntrotext == '1') { $article->text = $article->introtext . chr(13) . chr(13) . $article->fulltext; } elseif (!empty($article->fulltext)) { $article->text = $article->fulltext; } else { $article->text = $article->introtext; } // formating last update date if (!empty($article->modified)) { $article->modified = JoaktreeHelper::lastUpdateDateTimePerson($article->modified); } if ($type == 'article') { // check content using the content plugin - if it is available $plug = JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'joaktree' . DS . 'joaktree.php'; // check if plugin file exists - only then we will use it if (JFile::exists($plug)) { // load the plugin JLoader::register('plgContentJoaktree', $plug); $params = array(); plgContentJoaktree::onContentPrepare('com_content', $article, $params); } } return $article; }