本文整理汇总了PHP中CError::assert方法的典型用法代码示例。如果您正苦于以下问题:PHP CError::assert方法的具体用法?PHP CError::assert怎么用?PHP CError::assert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CError
的用法示例。
在下文中一共展示了CError::assert方法的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: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例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: 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);
}
示例9: 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;
}
示例10: 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);
}
}
}
示例11: triggerWallComments
/**
* Formats the comment in the rows
*
* @param Array An array of wall objects
**/
function triggerWallComments(&$rows)
{
CError::assert($rows, 'array', 'istype', __FILE__, __LINE__);
require_once COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'apps.php';
$appsLib =& CAppPlugins::getInstance();
$appsLib->loadApplications();
for ($i = 0; $i < count($rows); $i++) {
$args = array();
$args[] =& $rows[$i];
$appsLib->triggerEvent('onWallDisplay', $args);
}
return true;
}
示例12: _groupAlbum
function _groupAlbum()
{
CFactory::load('models', 'photos');
CFactory::load('helpers', 'friends');
CFactory::load('models', 'groups');
$mainframe =& JFactory::getApplication();
$document =& JFactory::getDocument();
$config = CFactory::getConfig();
$my = CFactory::getUser();
$model = CFactory::getModel('photos');
$groupModel = CFactory::getModel('groups');
$albumId = JRequest::getInt('albumid', '', 'GET');
$defaultId = JRequest::getVar('photo', '', 'GET');
$groupId = JRequest::getInt('groupid', '', 'REQUEST');
$group =& JTable::getInstance('Group', 'CTable');
$group->load($groupId);
if (empty($albumId)) {
echo JText::_('CC NO PROPER ALBUM ID');
return;
}
CFactory::load('helpers', 'owner');
//@rule: Do not allow non members to view albums for private group
if ($group->approvals == COMMUNITY_PRIVATE_GROUP && !$group->isMember($my->id) && !$group->isAdmin($my->id) && !COwnerHelper::isCommunityAdmin()) {
// Set document title
$document->setTitle(JText::_('CC RESTRICTED ACCESS'));
$mainframe->enqueueMessage(JText::_('CC RESTRICTED ACCESS', 'notice'));
echo JText::_('CC ALBUM NEED GROUP MEMBER PERMISSION');
return;
}
$album =& JTable::getInstance('Album', 'CTable');
$album->load($albumId);
// Set document title
CFactory::load('helpers', 'string');
$document->setTitle(JText::sprintf('CC USER PHOTOS TITLE', $group->name) . ' - ' . $album->name);
$this->setTitle($album->name);
$pathway =& $mainframe->getPathway();
$pathway->addItem($album->name, '');
CError::assert($group, 'object', 'istype', __FILE__, __LINE__);
// Get list of photos and set some limit to be displayed.
// @todo: make limit configurable?
$photos = $model->getAllPhotos($albumId, PHOTOS_GROUP_TYPE, null, null, COMMUNITY_ORDER_BY_DESC, COMMUNITY_ORDERING_BY_CREATED);
// Need to append the absolute path for the captions
for ($i = 0; $i < count($photos); $i++) {
$item =& JTable::getInstance('Photo', 'CTable');
$item->bind($photos[$i]);
$photos[$i] = $item;
$photo =& $photos[$i];
$photo->link = CRoute::_('index.php?option=com_community&view=photos&task=photo&groupid=' . $groupId . '&albumid=' . $photo->albumid) . '#photoid=' . $photo->id;
}
CFactory::load('helpers', 'group');
$allowManagePhotos = CGroupHelper::allowManagePhoto($groupId);
if (($group->isAdmin($my->id) || $allowManagePhotos) && $my->id != 0) {
$this->addSubmenuItem('index.php?option=com_community&view=photos&task=uploader&albumid=' . $album->id . '&groupid=' . $group->id, JText::_('CC UPLOAD PHOTOS'), '', true);
$this->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $group->id, JText::_('CC ADD ALBUM'), '', true);
}
$tmpl = new CTemplate();
CFactory::load('libraries', 'bookmarks');
$bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $group->id));
$bookmarksHTML = $bookmarks->getHTML();
$tmpl->set('bookmarksHTML', $bookmarksHTML);
$tmpl->set('isOwner', $group->isAdmin($my->id));
$tmpl->set('photos', $photos);
$tmpl->set('album', $album);
echo $tmpl->fetch('photos.album');
}
示例13: viewGroup
/**
* Displays specific groups
**/
public function viewGroup($group)
{
$mainframe =& JFactory::getApplication();
CFactory::load('libraries', 'tooltip');
CFactory::load('libraries', 'wall');
CFactory::load('libraries', 'window');
CFactory::load('libraries', 'videos');
CFactory::load('libraries', 'activities');
CFactory::load('helpers', 'group');
CWindow::load();
$config = CFactory::getConfig();
$document = JFactory::getDocument();
$groupLib = new CGroups();
// Load appropriate models
$groupModel = CFactory::getModel('groups');
$wallModel = CFactory::getModel('wall');
$userModel = CFactory::getModel('user');
$discussModel = CFactory::getModel('discussions');
$bulletinModel = CFactory::getModel('bulletins');
$photosModel = CFactory::getModel('photos');
$activityModel = CFactory::getModel('activities');
//$groupid = JRequest::getInt( 'groupid' , '' );
//CError::assert( $groupid , '' , '!empty' , __FILE__ , __LINE__ );
$editGroup = JRequest::getVar('edit', false, 'GET');
$editGroup = $editGroup == 1 ? true : false;
$params = $group->getParams();
CFactory::load('helpers', 'string');
$document->setMetaData('title', CStringHelper::escape($group->name));
$document->setMetaData('description', CStringHelper::escape(strip_tags($group->description)));
$document->addCustomTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />');
// @rule: Test if the group is unpublished, don't display it at all.
if (!$group->published) {
$this->_redirectUnpublishGroup();
return;
}
// Show submenu
$this->showSubmenu();
// Set the group info to contain proper <br>
$group->description = nl2br($group->description);
$this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
$this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_NAME_TITLE', $group->name), '');
// Load the current browsers data
$my = CFactory::getUser();
// If user are invited
$isInvited = $groupModel->isInvited($my->id, $group->id);
// Get members list for display
//$members = $groupModel->getAllMember($group->id);
//Set limit for member listing on view group page
$limit = 12;
$approvedMembers = $groupModel->getMembers($group->id, $limit, true, false, true);
CError::assert($approvedMembers, 'array', 'istype', __FILE__, __LINE__);
$membersCount = $groupModel->total;
// Is there any my friend is the member of this group?
$join = '';
$friendsCount = 0;
if ($isInvited) {
// Get the invitors
$invitors = $groupModel->getInvitors($my->id, $group->id);
if (count($invitors) == 1) {
$user = CFactory::getUser($invitors[0]->creator);
$join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
} else {
for ($i = 0; $i < count($invitors); $i++) {
$user = CFactory::getUser($invitors[$i]->creator);
if ($i + 1 == count($invitors)) {
$join .= ' ' . JText::_('COM_COMMUNITY_AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
} else {
$join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
}
}
}
// Get users friends in this group
$friendsCount = $groupModel->getFriendsCount($my->id, $group->id);
}
$admins = $groupModel->getAdmins($group->id, $limit, CC_RANDOMIZE);
// Get list of unapproved members
$groupModel->getMembers($group->id, null, false);
$unapproved = $groupModel->total;
//Get list of approved members
// Test if the current user is admin
$isAdmin = $groupModel->isAdmin($my->id, $group->id);
// Test if the current browser is a member of the group
$isMember = $groupModel->isMember($my->id, $group->id);
$waitingApproval = false;
// Test if the current user is banned from this group
$isBanned = $group->isBanned($my->id);
// Attach avatar of the member
// Pre-load multiple users at once
$userids = array();
$limitloop = $limit;
foreach ($approvedMembers as $uid) {
$userids[] = $uid->id;
if (--$limitloop < 1) {
break;
}
}
CFactory::loadUsers($userids);
//.........这里部分代码省略.........
示例14: _getFieldIdFromFieldCode
public function _getFieldIdFromFieldCode($code)
{
CError::assert($code, '', '!empty', __FILE__, __LINE__);
$db = $this->getDBO();
$query = 'SELECT' . $db->quoteName('id') . ' ' . 'FROM ' . $db->quoteName('#__community_fields') . ' ' . 'WHERE ' . $db->quoteName('fieldcode') . '=' . $db->Quote($code);
$db->setQuery($query);
$id = $db->loadResult();
CError::assert($id, '', '!empty', __FILE__, __LINE__);
return $id;
}
示例15: triggerEvent
public function triggerEvent($eventName, &$args, $target = null)
{
CError::assert($args, 'object', 'istype', __FILE__, __LINE__);
require_once COMMUNITY_COM_PATH . '/libraries/apps.php';
$appsLib = CAppPlugins::getInstance();
$appsLib->loadApplications();
$params = array();
$params[] = $args;
if (!is_null($target)) {
$params[] = $target;
}
$appsLib->triggerEvent($eventName, $params);
return true;
}