本文整理汇总了PHP中CError类的典型用法代码示例。如果您正苦于以下问题:PHP CError类的具体用法?PHP CError怎么用?PHP CError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the user status
*
* @param int user id
* @param string the message. Should be < 140 char (controller check)
*/
function update($id, $status)
{
$db =& $this->getDBO();
$my = CFactory::getUser();
// @todo: posted_on should be constructed to make sure we take into account
// of Joomla server offset
// Current user and update id should always be the same
CError::assert($my->id, $id, 'eq', __FILE__, __LINE__);
// Trigger onStatusUpdate
require_once COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'apps.php';
$appsLib =& CAppPlugins::getInstance();
$appsLib->loadApplications();
$args = array();
$args[] = $my->id;
// userid
$args[] = $my->getStatus();
// old status
$args[] = $status;
// new status
$appsLib->triggerEvent('onProfileStatusUpdate', $args);
$today =& JFactory::getDate();
$data = new stdClass();
$data->userid = $id;
$data->status = $status;
$data->posted_on = $today->toMySQL();
$db->updateObject('#__community_users', $data, 'userid');
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
}
示例2: setImage
public function setImage($path, $type = 'thumb')
{
CError::assert($path, '', '!empty', __FILE__, __LINE__);
$db = $this->getDBO();
// Fix the back quotes
$path = CString::str_ireplace('\\', '/', $path);
$type = JString::strtolower($type);
// Test if the record exists.
$oldFile = $this->{$type};
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
if ($oldFile) {
// File exists, try to remove old files first.
$oldFile = CString::str_ireplace('/', '/', $oldFile);
// If old file is default_thumb or default, we should not remove it.
//
// Need proper way to test it
if (!JString::stristr($oldFile, 'group.jpg') && !JString::stristr($oldFile, 'group_thumb.jpg') && !JString::stristr($oldFile, 'default.jpg') && !JString::stristr($oldFile, 'default_thumb.jpg')) {
jimport('joomla.filesystem.file');
JFile::delete($oldFile);
}
}
$this->{$type} = $path;
$this->store();
}
示例3: onDiscussionDisplay
public function onDiscussionDisplay($row)
{
CError::assert($row->message, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
if (!CStringHelper::isHTML($row->message)) {
$row->message = CStringHelper::nl2br($row->message);
}
}
示例4: onWallDisplay
public function onWallDisplay($row)
{
//CFactory::load( 'helpers' , 'string' );
CError::assert($row->comment, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
if (!CStringHelper::isHTML($row->comment)) {
$row->comment = CStringHelper::nl2br($row->comment);
}
}
示例5: onDiscussionDisplay
function onDiscussionDisplay(&$row)
{
CError::assert($row->message, '', '!empty', __FILE__, __LINE__);
$config = CFactory::getConfig();
// If editor is disabled, we only want to replace newlines with BR otherwise it doesn't make any sense to replace so many br
if ($config->get('editor') == '0') {
$row->message = $this->_filterText($row->message);
}
}
示例6: onMessageDisplay
public function onMessageDisplay($row)
{
CFactory::load('helpers', 'string');
CError::assert($row->body, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
if (!CStringHelper::isHTML($row->body)) {
$row->body = CStringHelper::nl2br($row->body);
}
}
示例7: onWallDisplay
public function onWallDisplay($row)
{
//CFactory::load( 'helpers' , 'string' );
CError::assert($row->comment, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
//@since 4.1 new rule added, to ignore newline replace
if (!CStringHelper::isHTML($row->comment) && !isset($row->newlineReplace)) {
$row->comment = CStringHelper::nl2br($row->comment);
}
}
示例8: load
/**
* 加载文件
*
* @param string $name
*/
public static function load($class_name)
{
if (self::checkClass($class_name)) {
return true;
}
// add to class map
self::addClass(str_replace('/', '_', $class_name));
$file = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $class_name) . '.php';
if (!is_file($file)) {
CError::show('COULD NOT FOUND THE FILE ' . $file);
}
require $file;
}
示例9: add
/**
* Add new activity,
* @access static
*
*/
function add($activity, $params = '', $points = 1)
{
CError::assert($activity, '', '!empty', __FILE__, __LINE__);
// If params is an object, instead of a string, we convert it to string
$cmd = !empty($activity->cmd) ? $activity->cmd : '';
if (!empty($cmd)) {
$userPointModel = CFactory::getModel('Userpoints');
// Test command, with userpoint command. If is unpublished do not proceed into adding to activity stream.
$point = $userPointModel->getPointData($cmd);
if ($point && !$point->published) {
return;
}
}
$actor = !empty($activity->actor) ? $activity->actor : '';
$target = !empty($activity->target) ? $activity->target : 0;
$title = !empty($activity->title) ? $activity->title : '';
$content = !empty($activity->content) ? $activity->content : '';
$appname = !empty($activity->app) ? $activity->app : '';
$cid = !empty($activity->cid) ? $activity->cid : 0;
$points = !empty($activity->points) ? $activity->points : $points;
$access = !empty($activity->access) ? $activity->access : 0;
// If the params in embedded within the activity object, use it
// if it is not explicitly overriden
if (empty($params) && !empty($activity->params)) {
$params = $activity->params;
}
include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'activities.php';
if (class_exists('CFactory')) {
$activities = CFactory::getModel('activities');
} else {
$activities = new CommunityModelActivities();
}
// Update access for activity based on the user's profile privacy
if (!empty($actor) && $actor != 0) {
$user = CFactory::getUser($actor);
$userParams = $user->getParams();
$profileAccess = $userParams->get('privacyProfileView');
// Only overwrite access if the user global profile privacy is higher
// BUT, if access is defined as PRIVACY_FORCE_PUBLIC, do not modify it
if ($access != PRIVACY_FORCE_PUBLIC && $profileAccess > $access) {
$access = $profileAccess;
}
}
$activities->add($actor, $target, $title, $content, $appname, $cid, $params, $points, $access);
}
示例10: build
public static function build($view, $task = '', $keys = null, $route = true)
{
// View cannot be empty. Assertion must be included here.
CError::assert($view, '', '!empty', __FILE__, __LINE__);
$url = 'index.php?option=com_community&view=' . $view;
// Task might be optional
$url .= !empty($task) ? '&task=' . $task : '';
if (!is_null($keys) && is_array($keys)) {
foreach ($keys as $key => $value) {
$url .= '&' . $key . '=' . $value;
}
}
// Test if it needs JRoute
if ($route) {
return CRoute::_($url);
}
return $url;
}
示例11: setImage
/**
* Set the avatar for specific application. Caller must have a database table
* that is named after the appType. E.g, users should have jos_community_users
*
* @param appType Application type. ( users , groups )
* @param path The relative path to the avatars.
* @param type The type of Image, thumb or avatar.
*
**/
function setImage($id, $path, $type = 'thumb')
{
CError::assert($id, '', '!empty', __FILE__, __LINE__);
CError::assert($path, '', '!empty', __FILE__, __LINE__);
$db =& $this->getDBO();
// Fix the back quotes
$path = JString::str_ireplace('\\', '/', $path);
$type = JString::strtolower($type);
// Test if the record exists.
$query = 'SELECT ' . $db->nameQuote($type) . ' FROM ' . $db->nameQuote('#__community_users') . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
$db->setQuery($query);
$oldFile = $db->loadResult();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
if (!$oldFile) {
$query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
$db->setQuery($query);
$db->query($query);
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
} else {
$query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
$db->setQuery($query);
$db->query($query);
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
// If old file is default_thumb or default, we should not remove it.
// Need proper way to test it
if (!Jstring::stristr($oldFile, 'components/com_community/assets/default.jpg') && !Jstring::stristr($oldFile, 'components/com_community/assets/default_thumb.jpg')) {
// File exists, try to remove old files first.
$oldFile = JString::str_ireplace('/', DS, $oldFile);
JFile::delete($oldFile);
}
}
}
示例12: getCategoryName
/**
* Returns the category name of the specific category
*
* @access public
* @param string Category Id
* @returns string Category name
* */
public function getCategoryName($categoryId)
{
CError::assert($categoryId, '', '!empty', __FILE__, __LINE__);
$db = $this->getDBO();
$query = 'SELECT ' . $db->quoteName('name') . ' ' . 'FROM ' . $db->quoteName('#__community_events_category') . ' ' . 'WHERE ' . $db->quoteName('id') . '=' . $db->Quote($categoryId);
$db->setQuery($query);
$result = $db->loadResult();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
CError::assert($result, '', '!empty', __FILE__, __LINE__);
return $result;
}
示例13: setImage
/**
* Set the avatar for specific application. Caller must have a database table
* that is named after the appType. E.g, users should have jos_community_users
*
* @param appType Application type. ( users , groups )
* @param path The relative path to the avatars.
* @param type The type of Image, thumb or avatar.
*
**/
function setImage($id, $path, $type = 'thumb', $removeOldImage = true)
{
CError::assert($id, '', '!empty', __FILE__, __LINE__);
CError::assert($path, '', '!empty', __FILE__, __LINE__);
$db =& $this->getDBO();
// Fix the back quotes
$path = JString::str_ireplace('\\', '/', $path);
$type = JString::strtolower($type);
// Test if the record exists.
$query = 'SELECT ' . $db->nameQuote($type) . ' FROM ' . $db->nameQuote('#__community_users') . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
$db->setQuery($query);
$oldFile = $db->loadResult();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
$appsLib =& CAppPlugins::getInstance();
$appsLib->loadApplications();
$args = array();
$args[] =& $id;
// userid
$args[] =& $oldFile;
// old path
$args[] =& $path;
// new path
$appsLib->triggerEvent('onProfileAvatarUpdate', $args);
if (!$oldFile) {
$query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
$db->setQuery($query);
$db->query($query);
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
} else {
$query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
$db->setQuery($query);
$db->Query();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
// If old file is default_thumb or default, we should not remove it.
// Need proper way to test it
if (!JString::stristr($oldFile, 'components/com_community/assets/default.jpg') && !JString::stristr($oldFile, 'components/com_community/assets/default_thumb.jpg') && $removeOldImage) {
// File exists, try to remove old files first.
$oldFile = JString::str_ireplace('/', DS, $oldFile);
if (JFile::exists($oldFile)) {
JFile::delete($oldFile);
}
}
}
}
示例14: ajaxRemoveWall
/**
* Delete post message
*
* @param response An ajax Response object
* @param id A unique identifier for the wall row
*
* returns response
*/
function ajaxRemoveWall($response, $id, $cache_id = "")
{
$my = CFactory::getUser();
$wallModel = CFactory::getModel('wall');
$wall = $wallModel->get($id);
CError::assert($id, '', '!empty', __FILE__, __LINE__);
CFactory::load('helpers', 'owner');
// Make sure the current user actually has the correct permission
// Only the original writer and the person the wall is meant for (and admin of course)
// can delete the wall
if ($my->id == $wall->post_by || $my->id == $wall->contentid || COwnerHelper::isCommunityAdmin()) {
if ($wallModel->deletePost($id)) {
// @rule: Remove the wall activity from the database as well
CFactory::load('libraries', 'activities');
CActivityStream::remove('walls', $id);
//add user points
if ($wall->post_by != 0) {
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('wall.remove', $wall->post_by);
}
} else {
$html = JText::_('Error while removing wall. Line:' . __LINE__);
$response->addAlert($html);
}
$cache =& JFactory::getCache('plgCommunityWalls');
$cache->remove($cache_id);
$cache =& JFactory::getCache('plgCommunityWalls_fullview');
$cache->remove($cache_id);
} else {
$html = JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING');
$response->addAlert($html);
}
return $response;
}
示例15: ajaxRemoveWall
public function ajaxRemoveWall($wallId)
{
$filter = JFilterInput::getInstance();
$wallId = $filter->clean($wallId, 'int');
CError::assert($wallId, '', '!empty', __FILE__, __LINE__);
$response = new JAXResponse();
CFactory::load('helpers', 'owner');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
//@rule: Check if user is really allowed to remove the current wall
$my = CFactory::getUser();
$wallModel =& $this->getModel('wall');
$wall = $wallModel->get($wallId);
$eventModel =& $this->getModel('events');
$event =& JTable::getInstance('Event', 'CTable');
$event->load($wall->contentid);
if (!COwnerHelper::isCommunityAdmin() && !$event->isAdmin($my->id)) {
$response->addScriptCall('alert', JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_REMOVE_WALL'));
} else {
if (!$wallModel->deletePost($wallId)) {
$response->addAlert(JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR'));
} else {
if ($wall->post_by != 0) {
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('wall.remove', $wall->post_by);
}
}
// Substract the count
$event->substractWallCount();
}
$this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
return $response->sendResponse();
}