public static function award_points($rule_name, $user_id = 0, $points = 0, $reference = null, $description = null, $conditional_rules = array()) { $db = JFactory::getDbo(); $user = JFactory::getUser(); $points = intval($points); if (CjBlogApi::$_enable_logging) { JLog::add('CjBlogApi.award_points - Rule: ' . $rule_name . '| UserID: ' . $user_id, JLog::DEBUG, CJBLOG); } if (strlen($rule_name) < 3) { return false; } if (!$user_id && $user->guest) { return false; } $user_id = $user_id > 0 ? $user_id : $user->id; $query = ' select id, name, asset_name, description, points, published, auto_approve, access, conditional_rules from ' . T_CJBLOG_POINT_RULES . ' where name=' . $db->quote($rule_name); if ($db->getErrorNum()) { JLog::add('CjBlogApi.award_points - DB Error: ' . $db->getErrorMsg(), JLog::ERROR, CJBLOG); } $db->setQuery($query); $rule = $db->loadObject(); if (empty($rule)) { return false; } $rule->conditional_rules = json_decode($rule->conditional_rules); if (!$rule || !$rule->id || $rule->published != '1' || $points == 0 && $rule->points == 0 && empty($rule->conditional_rules)) { return false; } if (!in_array($rule->access, JAccess::getAuthorisedViewLevels($user_id))) { return false; } if (!empty($rule->conditional_rules) && is_array($rule->conditional_rules)) { $match_found = false; $gtFoundValue = $geFoundValue = $ltFoundValue = $leFoundValue = $foundValue = 0; foreach ($rule->conditional_rules as $condition) { if (isset($condition->criteria) && isset($conditional_rules[$condition->criteria])) { $paramValue = (int) $conditional_rules[$condition->criteria]; $conditionValue = (int) $condition->value; switch ($condition->comparator) { case 'eq': if ($paramValue == $conditionValue) { $points = (int) $condition->points; $foundValue = $conditionValue; $match_found = true; } break; case 'gt': if ($paramValue > $conditionValue && $conditionValue > $gtFoundValue) { $points = (int) $condition->points; $gtFoundValue = $foundValue = $conditionValue; $match_found = true; } break; case 'ge': if ($paramValue >= $conditionValue && $conditionValue >= $geFoundValue) { $points = (int) $condition->points; $geFoundValue = $foundValue = $conditionValue; $match_found = true; } break; case 'lt': if ($paramValue < $conditionValue && $conditionValue < $ltFoundValue) { $points = (int) $condition->points; $ltFoundValue = $foundValue = $conditionValue; $match_found = true; } break; case 'le': if ($paramValue <= $conditionValue && $conditionValue <= $leFoundValue) { $points = (int) $condition->points; $leFoundValue = $foundValue = $conditionValue; $match_found = true; } break; } } } if ($match_found) { $reference = $reference . '.' . $foundValue; } else { return false; } } else { if (!$points || $points == 0) { $points = $rule->points; } } if ($reference) { $query = ' select count(*) from ' . T_CJBLOG_POINTS . ' where user_id = ' . $user_id . ' and rule_id=' . $rule->id . ' and ref_id=' . $db->quote($reference); $db->setQuery($query); $count = (int) $db->loadResult(); if ($db->getErrorNum()) { JLog::add('CjBlogApi.award_points - DB Error: ' . $db->getErrorMsg(), JLog::ERROR, CJBLOG); } if ($count > 0) { return false; } } $reference = !$reference ? 'null' : $db->quote($reference); $description = !$description ? 'null' : $db->quote(CJFunctions::clean_value($description, true)); $createdate = JFactory::getDate()->toSql(); $published = $rule->auto_approve == 1 ? 1 : 2; $query = ' insert into ' . T_CJBLOG_POINTS . '(user_id, rule_id, points, ref_id, published, description, created_by, created) values (' . $user_id . ',' . $rule->id . ',' . $points . ',' . $reference . ',' . $published . ',' . $description . ',' . $user->id . ',' . $db->quote($createdate) . ')'; $db->setQuery($query); if (!$db->query()) { CjBlogApi::$_errors[] = 'Error: ' . $db->getErrorMsg(); if ($db->getErrorNum()) { JLog::add('CjBlogApi.award_points - DB Error: ' . $db->getErrorMsg(), JLog::ERROR, CJBLOG); } return false; } if ($published == 1) { $query = 'update ' . T_CJBLOG_USERS . ' set points = points ' . ($points > 0 ? '+' . $points : '-' . abs($points)) . ' where id = ' . $user_id; $db->setQuery($query); if (!$db->query()) { CjBlogApi::$_errors[] = 'Error: ' . $db->getErrorMsg(); } } $params = JComponentHelper::getParams(CJBLOG); if ($user_id && $user_id == $user->id && $params->get('display_messages', 0) == 1) { $message = $published == 1 ? 'COM_CJBLOG_POINTS_ASSIGNED_FOR' : 'COM_CJBLOG_POINTS_ASSIGNED_FOR_PENDING'; JFactory::getApplication()->enqueueMessage(JText::sprintf($message, $points, $description)); } return true; }
</thead> <tbody> <?php foreach ($this->points as $i => $point) { ?> <tr> <td><?php echo $this->pagination->get('limitstart') + $i + 1; ?> </td> <td><?php echo $this->escape($point->rule_description); ?> </td> <td><?php echo CJFunctions::clean_value($point->description, true); ?> </td> <td style="text-align: center"><?php echo $this->escape($point->points); ?> </td> <td nowrap="nowrap"><?php echo CJFunctions::get_localized_date($point->created); ?> </td> </tr> <?php } ?> </tbody>
echo JText::sprintf('TXT_LAST_VISITED_DATE', CJFunctions::get_localized_date($this->profile['lastvisitDate'], $dateFormat)); ?> </div> <div class="muted"><?php echo JText::sprintf('TXT_PROFILE_VIEWS', $this->profile['profile_views']); ?> </div> <?php // support for external plugins on group CjBlog for event onAfterDisplayProfile $plugin_output = $dispatcher->trigger('onAfterCjBlogProfileDisplay', array($this->profile)); if (!empty($plugin_output) && is_array($plugin_output)) { foreach ($plugin_output as $output) { if (!empty($output) && !empty($output['header']) && !empty($output['content'])) { echo '<h2 class="page-header margin-bottom-10">' . $this->escape($output['header']) . '</h2>'; echo CJFunctions::clean_value($output['content']); } } } ?> </div> </div> </div> <div class="modal" id="modal-error-message" tabindex="-1" role="dialog" aria-labelledby="model-label" aria-hidden="true" style="display: none;"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h3 id="model-label"><?php echo JText::_('LBL_ERROR'); ?> </h3>
/** * Gets the clean content from the request variable named <code>var</code>. If the second parameter passed as false, html tags will be stripped out. * * @param string $var * @param boolean $html * @return Ambigous <string, mixed> */ public static function get_clean_var($var, $html = true, $default = '') { $value = $html ? JRequest::getVar($var, $default, 'post', 'string', JREQUEST_ALLOWRAW) : JRequest::getVar($var, $default, 'post', 'string'); $value = empty($_POST[$var]) ? $default : $_POST[$var]; return CJFunctions::clean_value($value); }
echo JHtml::_('grid.id', $i, $item->id); ?> <?php } ?> </td> <td class="left"><?php echo $this->escape($item->rule_title); ?> </td> <td class="left"><?php echo $this->escape($item->rule_description); ?> </td> <td class="left"><?php echo CJFunctions::clean_value($item->description, true); ?> </td> <td><?php echo $this->escape($item->name); ?> </td> <td><?php echo $this->escape($item->username); ?> </td> <td><?php echo $this->escape($item->points); ?> </td> <td><?php