本文整理汇总了PHP中CFactory::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP CFactory::getModel方法的具体用法?PHP CFactory::getModel怎么用?PHP CFactory::getModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactory
的用法示例。
在下文中一共展示了CFactory::getModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jomsocialForm
private function jomsocialForm($external, $groupId = '0', $blogSource = '', $isPending = 0)
{
$my = JFactory::getUser();
$file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
//extra checking incase somewhere still passing empty blogSource.
$blogSource = empty($blogSource) ? 'group' : $blogSource;
if (!JFile::exists($file)) {
return false;
}
require_once $file;
$model = CFactory::getModel('groups');
if (EasyBlogHelper::isSiteAdmin() && $isPending) {
$rows = $model->getAllGroups();
} else {
$rows = $model->getGroups($my->id, null, false);
}
$groups = array();
JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'tables');
foreach ($rows as $row) {
$group = JTable::getInstance('Group', 'CTable');
$group->load($row->id);
$data = new stdClass();
$data->id = $group->id;
$data->title = $group->name;
$data->avatar = $group->getAvatar();
$groups[] = $data;
}
$theme = EB::template();
$theme->set('blogSource', $blogSource);
$theme->set('external', $external);
$theme->set('groups', $groups);
$theme->set('groupId', $groupId);
return $theme->output('site/jomsocial/groups');
}
示例2: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
$lang =& JFactory::getLanguage();
$lang->load('com_community', JPATH_ROOT);
$model = CFactory::getModel('Groups');
$groups = $model->getAllGroups();
$fieldName = $control_name . '[' . $name . ']';
ob_start();
?>
<select name="<?php
echo $fieldName;
?>
">
<?php
foreach ($groups as $group) {
?>
<option value="<?php
echo $group->id;
?>
"<?php
echo $value == $group->id ? ' selected="selected"' : '';
?>
><?php
echo $group->name;
?>
</option>
<?php
}
?>
</select>
<?php
$html = ob_get_contents();
ob_end_clean();
return $html;
}
示例3: onProfileDisplay
function onProfileDisplay()
{
JPlugin::loadLanguage('plg_community_events', JPATH_ADMINISTRATOR);
$config = CFactory::getConfig();
if (!$config->get('enableevents')) {
return JText::_('PLG_EVENTS_EVENT_DISABLED');
}
$document = JFactory::getDocument();
$mainframe = JFactory::getApplication();
$user = CFactory::getRequestUser();
$caching = $this->params->get('cache', 1);
$model = CFactory::getModel('Events');
$my = CFactory::getUser();
$this->loadUserParams();
//CFactory::load( 'helpers' , 'event' );
$event = JTable::getInstance('Event', 'CTable');
$handler = CEventHelper::getHandler($event);
$events = $model->getEvents(null, $user->id, $this->params->get('sorting', 'latest'), null, true, false, null, null, $handler->getContentTypes(), $handler->getContentId(), $this->userparams->get('count', 5));
if ($this->params->get('hide_empty', 0) && !count($events)) {
return '';
}
if ($caching) {
$caching = $mainframe->getCfg('caching');
}
$creatable = $my->canCreateEvents();
$cache = JFactory::getCache('plgCommunityEvents');
$cache->setCaching($caching);
$callback = array($this, '_getEventsHTML');
$content = $cache->call($callback, true, $events, $user, $config, $model->getEventsCount($user->id), $creatable);
return $content;
}
示例4: __construct
public function __construct($event)
{
$this->my = CFactory::getUser();
$this->model = CFactory::getModel('events');
$this->event = $event;
$this->url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $this->event->id;
}
示例5: CommunityViewVideos
public function CommunityViewVideos()
{
//CFactory::load( 'helpers', 'videos' );
//CFactory::load( 'libraries' , 'videos' );
$this->model = CFactory::getModel('videos');
$this->videoLib = new CVideoLibrary();
}
示例6: getMediaPermission
public static function getMediaPermission($groupId)
{
// load COwnerHelper::isCommunityAdmin()
CFactory::load('helpers', 'owner');
$my = CFactory::getUser();
$isSuperAdmin = COwnerHelper::isCommunityAdmin();
$isAdmin = false;
$isMember = false;
$waitingApproval = false;
// Load the group table.
$groupModel = CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$group->load($groupId);
$params = $group->getParams();
if (!$isSuperAdmin) {
$isAdmin = $groupModel->isAdmin($my->id, $group->id);
$isMember = $group->isMember($my->id);
//check if awaiting group's approval
if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
$waitingApproval = true;
}
}
$permission = new stdClass();
$permission->isMember = $isMember;
$permission->waitingApproval = $waitingApproval;
$permission->isAdmin = $isAdmin;
$permission->isSuperAdmin = $isSuperAdmin;
$permission->params = $params;
$permission->privateGroup = $group->approvals;
return $permission;
}
示例7: exceedDaily
public static function exceedDaily($view, $userId = null, $returnRemaining = false)
{
$my = CFactory::getUser($userId);
// Guests shouldn't be even allowed here.
if ($my->id == 0) {
return true;
}
$view = JString::strtolower($view);
// We need to include the model first before using ReflectionClass so that the model file is included.
$model = CFactory::getModel($view);
// Since the model will always return a CCachingModel which is a proxy,
// for the real model, we can't really test what type of object it is.
$modelClass = 'CommunityModel' . ucfirst($view);
$reflection = new ReflectionClass($modelClass);
if (!$reflection->implementsInterface('CLimitsInterface')) {
return false;
}
$config = CFactory::getConfig();
$total = $model->getTotalToday($my->id);
$max = $config->getInt('limit_' . $view . '_perday');
if ($returnRemaining) {
return $max - $total;
}
return $total >= $max && $max != 0;
}
示例8: onProfileStatusUpdate
/**
* Method is called during the status update triggers.
**/
public function onProfileStatusUpdate($userid, $oldMessage, $newMessage)
{
$config = CFactory::getConfig();
$my = CFactory::getUser();
if ($config->get('fbconnectpoststatus')) {
//CFactory::load( 'libraries' , 'facebook' );
$facebook = new CFacebook();
if ($facebook) {
$fbuserid = $facebook->getUser();
$connectModel = CFactory::getModel('Connect');
$connectTable = JTable::getInstance('Connect', 'CTable');
$connectTable->load($fbuserid);
// Make sure the FB session match the user session
if ($connectTable->userid == $my->id) {
/**
* Check post status to facebook settings
*/
//echo "posting to facebook"; exit;
$targetUser = CFactory::getUser($my->id);
$userParams = $targetUser->getParams();
if ($userParams->get('postFacebookStatus')) {
$result = $facebook->postStatus($newMessage);
//print_r($result); exit;
}
}
}
}
}
示例9: getGroupsData
function getGroupsData(&$params)
{
$model =& CFactory::getModel('groups');
$db =& JFactory::getDBO();
$count = $params->get('count', '5');
$sql = " SELECT\n\t\t\t\t\t\t" . $db->nameQuote('cid') . ",\n\t\t\t\t\t\tCOUNT(" . $db->nameQuote('cid') . ") AS " . $db->nameQuote('count') . " \n\t\t\t\t FROM\n\t\t\t\t\t\t" . $db->nameQuote('#__community_activities') . " a \n\t\t\t INNER JOIN\t" . $db->nameQuote('#__community_groups') . " b ON a." . $db->nameQuote('cid') . " = b." . $db->nameQuote('id') . " \n\t\t\t\t WHERE\n\t\t\t\t\t\ta." . $db->nameQuote('app') . " = " . $db->quote('groups') . " AND\n\t\t\t\t\t\tb." . $db->nameQuote('published') . " = " . $db->quote('1') . " AND\n\t\t\t\t\t\ta." . $db->nameQuote('archived') . " = " . $db->quote('0') . " AND\n\t\t\t\t\t\ta." . $db->nameQuote('cid') . " != " . $db->quote('0') . "\n\t\t\t GROUP BY a." . $db->nameQuote('cid') . "\n\t\t\t ORDER BY " . $db->nameQuote('count') . " DESC\n\t\t\t LIMIT " . $count;
$query = $db->setQuery($sql);
$row = $db->loadObjectList();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
$_groups = array();
if (!empty($row)) {
foreach ($row as $data) {
$group = $model->getGroup($data->cid);
if ($group->id) {
$groupAvatar =& JTable::getInstance('group', 'CTable');
$groupAvatar->bind($group);
$_obj = new stdClass();
$_obj->id = $group->id;
$_obj->name = $group->name;
$_obj->avatar = $groupAvatar->getThumbAvatar();
$_obj->totalMembers = $model->getMembersCount($group->id);
$_groups[] = $_obj;
}
}
}
return $_groups;
}
示例10: deletegroupmembers
function deletegroupmembers($data)
{
require_once JPATH_SITE . '/components/com_community/libraries/core.php';
CFactory::load('libraries', 'apps');
$error_messages = array();
$success_messages = array();
$response = NULL;
$validated = true;
if ("" == $data['groupid'] || 0 == $data['groupid']) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Groupid cannot be blank");
}
if (false == array_key_exists('memberids', $data) || 0 == sizeof($data['memberids'])) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "memberids", "message" => "Memberids cannot be blank");
}
if (true == $validated) {
$model =& CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$group->id = $data['groupid'];
$group->ownerid = $data['ownerid'];
}
if ($data['ownerid'] == $data['memberids']) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "ownerid/memberid", "message" => "owner id and member id are same.please update 'ownwrid or memberid' fields in request");
} else {
$groupMember =& JTable::getInstance('GroupMembers', 'CTable');
$memberId = $data['memberids'];
$groupId = $data['groupid'];
$groupMember->load($memberId, $groupId);
$data = new stdClass();
$data->groupid = $groupId;
$data->memberid = $memberId;
$data = new stdClass();
$data->groupid = $groupId;
$data->memberid = $memberId;
$model->removeMember($data);
$db =& JFactory::getDBO();
$query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__community_groups_members') . ' ' . 'WHERE groupid=' . $db->Quote($groupId) . ' ' . 'AND approved=' . $db->Quote('1');
$db->setQuery($query);
$membercount = $db->loadResult();
$members = new stdClass();
$members->id = $groupId;
$members->membercount = $membercount;
$db->updateObject('#__community_groups', $members, 'id');
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('group.member.remove', $memberId);
}
if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
$res = array();
foreach ($error_messages as $key => $error_message) {
$res[] = $error_message;
}
$response = array("id" => 0, 'errors' => $res);
} else {
$response = array('id' => $memberId);
}
return $response;
}
示例11: deletewallpost
function deletewallpost($data)
{
require_once JPATH_SITE . '/components/com_community/libraries/core.php';
$error_messages = array();
$response = NULL;
$validated = true;
$db =& JFactory::getDBO();
if ($data['wall_id'] == "" || $data['wall_id'] == "0") {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "Wall id cannot be blank");
}
//@rule: Check if user is really allowed to remove the current wall
$my = CFactory::getUser();
$model =& CFactory::getModel('wall');
$wall = $model->get($data['wall_id']);
$groupModel =& CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$group->load($wall->contentid);
$query = "SELECT contentid FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'";
$db->setQuery($query);
$contentid = $db->LoadResult();
CFactory::load('helpers', 'owner');
$query = "SELECT id FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'";
$db->setQuery($query);
$isdiscussion = $db->LoadResult();
if (!$isdiscussion) {
$error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id for type groups does not exists. Modify the wall_id field");
} else {
if (!$model->deletePost($data['wall_id'])) {
$validated = false;
//$error_messages[] = 'wall id does not exists. Modify the wall_id fields in request';
$error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id does not exists. Modify the wall_id field");
} else {
if ($wall->post_by != 0) {
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('wall.remove', $wall->post_by);
}
}
//$groupModel->substractWallCount( $data['wall_id'] );
// Substract the count
$query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__community_wall') . ' ' . 'WHERE contentid=' . $db->Quote($contentid) . ' ' . 'AND type="groups"';
$db->setQuery($query);
$wall_count = $db->loadResult();
$wallcount = new stdClass();
$wallcount->id = $contentid;
$wallcount->wallcount = $wall_count;
$db->updateObject('#__community_groups', $wallcount, 'id');
}
if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
$res = array();
foreach ($error_messages as $key => $error_message) {
$res[] = $error_message;
}
$response = array("id" => 0, 'errors' => $res);
} else {
$response = array('id' => $wall->id);
}
return $response;
}
示例12: get
public function get()
{
$user = $this->plugin->get('user');
$model = CFactory::getModel('Activities');
$activities = $model->getActivities($user->get('id'), '', '', 20, false);
$this->plugin->setResponse($activities);
}
示例13: getGroupsData
function getGroupsData(&$params)
{
$model = CFactory::getModel('groups');
$db = JFactory::getDBO();
$count = $params->get('count', '5');
$query = 'SELECT *, (a.' . $db->quoteName('discusscount') . ' + a.' . $db->quoteName('wallcount') . ' ) AS count FROM ' . $db->quoteName('#__community_groups') . ' as a' . ' INNER JOIN ' . $db->quoteName('#__community_groups_members') . ' AS b ON a.' . $db->quoteName('id') . '= b.' . $db->quoteName('groupid') . ' WHERE a.' . $db->quoteName('published') . ' = ' . $db->Quote('1') . ' GROUP BY a.' . $db->quoteName('id') . ' ORDER BY ' . $db->quoteName('count') . ' DESC ' . ' LIMIT 0, ' . $count;
$db->setQuery($query);
$rows = $db->loadObjectList();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
$_groups = array();
/**
* @todo No need use JTable to get group JTable object again
*/
if (!empty($rows)) {
foreach ($rows as $row) {
$group = $model->getGroup($row->id);
if ($group->id) {
$groupAvatar = JTable::getInstance('group', 'CTable');
$groupAvatar->bind($group);
$_obj = new stdClass();
$_obj->id = $group->id;
$_obj->name = $group->name;
$_obj->avatar = $groupAvatar->getThumbAvatar();
$_obj->totalMembers = count($model->getMembers($group->id, NULL, true, false, true));
//$_obj->totalMembers = $model->getMembersCount($group->id);
$_groups[] = $_obj;
}
}
}
return $_groups;
}
示例14: send
/**
* Do a batch send
*/
function send($total = 100)
{
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
if (empty($mails)) {
return;
}
CFactory::load('helpers', 'string');
foreach ($mails as $row) {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
$user = CFactory::getUser($userid);
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new JParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$tmpl->set('content', $row->body);
$tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$replaceWith = $params->get($val[1], null);
//if the replacement start with 'index.php', we can CRoute it
if (strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if (!is_null($replaceWith)) {
$row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
}
}
}
unset($tmpl);
$mailer->setBody($row->body);
$mailer->send();
}
$mailqModel->markSent($row->id);
$mailer->ClearAllRecipients();
}
}
示例15: populateUserData
public function populateUserData($obj, $user_id)
{
// joomla fills the info
$obj = parent::populateUserData($obj, $user_id);
//populate jomsocial
require_once JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
$pModel = CFactory::getModel('profile');
$profile = $pModel->getEditableProfile($this->activationUserID);
$fields = $profile['fields'];
//$obj->jomsocial = array();
foreach ($fields as $name => $fieldGroup) {
foreach ($fieldGroup as $field) {
$name = $field['name'];
if ($field['fieldcode'] == 'XIPT_PROFILETYPE') {
require_once JPATH_BASE . DS . 'components' . DS . 'com_xipt' . DS . 'api.xipt.php';
$profiletypeName = XiptAPI::getUserProfiletype($user_id, 'name');
$obj['profile'][$name] = $profiletypeName;
continue;
}
$fieldId = $pModel->getFieldId($field['fieldcode']);
$query = 'SELECT value FROM #__community_fields_values' . ' ' . 'WHERE `field_id`=' . $this->db->Quote($fieldId) . ' ' . 'AND `user_id`=' . $this->db->Quote($user_id);
$result = $this->db->setQuery($query)->loadresult();
if (!empty($result)) {
$obj['profile'][$name] = $result;
}
}
}
return $obj;
}