本文整理汇总了PHP中FD::table方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::table方法的具体用法?PHP FD::table怎么用?PHP FD::table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Displays the application output in the canvas.
*
* @since 1.0
* @access public
* @param int The user id that is currently being viewed.
*/
public function display($uid = null, $docType = null)
{
$event = FD::event($uid);
// Get the article item
$news = FD::table('EventNews');
$news->load($this->input->get('newsId', 0, 'int'));
// Check if the user is really allowed to view this item
if (!$event->canViewItem()) {
return $this->redirect($event->getPermalink(false));
}
// Get the author of the article
$author = FD::user($news->created_by);
// Get the url for the article
$url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false);
// Apply comments for the article
$comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT, array('url' => $url));
// Apply likes for the article
$likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT);
// Set the page title
FD::page()->title($news->get('title'));
// Retrieve the params
$params = $this->app->getParams();
$this->set('app', $this->app);
$this->set('params', $params);
$this->set('event', $event);
$this->set('likes', $likes);
$this->set('comments', $comments);
$this->set('author', $author);
$this->set('news', $news);
echo parent::display('canvas/item');
}
示例2: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
// First we get the core.view privacy id
$sql->select('#__social_privacy')->column('id')->where('type', 'core')->where('rule', 'view');
$db->setQuery($sql);
$origId = $db->loadResult();
// Then we cache a copy of all the new field rules and the id
$sql->clear();
$sql->select('#__social_privacy')->column('id')->column('rule')->where('type', 'field');
$db->setQuery($sql);
$rules = $db->loadObjectList('rule');
// Then we get all the privacy items with this id and type = 'field'
$sql->clear();
$sql->select('#__social_privacy_items', 'a')->column('a.*')->column('c.element')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.uid')->leftjoin('#__social_apps', 'c')->on('b.app_id', 'c.id')->where('(')->where('a.type', 'field')->where('a.type', 'field.datetime.year', '=', 'OR')->where(')');
$db->setQuery($sql);
$result = $db->loadObjectList();
// Based on the element, we need to find the new id to map it to the rule
foreach ($result as $row) {
if (isset($rules[$row->element])) {
$table = FD::table('privacyitems');
$table->bind($row);
$table->privacy_id = $rules[$row->element]->id;
$table->store();
}
}
// field.datetime.year need to change to year
$sql->clear();
$sql->update('#__social_privacy_items')->set('type', 'year')->where('type', 'field.datetime.year');
$db->setQuery($sql);
$db->query();
return true;
}
示例3: execute
public function execute($item)
{
$model = FD::model('likes');
$users = $model->getLikerIds($item->uid, $item->context_type);
$users[] = $item->actor_id;
$users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
$names = FD::string()->namesToNotifications($users);
$plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
list($element, $group, $verb) = explode('.', $item->context_type);
$streamItem = FD::table('streamitem');
$state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid));
if (!$state) {
return;
}
$owner = $streamItem->actor_id;
if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) {
$item->title = JText::sprintf('APP_USER_ARTICLE_USER_LIKES_YOUR_ITEM' . $plurality, $names);
return $item;
}
if ($item->actor_id == $owner && count($users) == 1) {
$item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_LIKES_ITEM' . FD::user($owner)->getGenderLang(), $names);
return $item;
}
$item->title = JText::sprintf('APP_USER_ARTICLE_USER_LIKES_USER_ITEM' . $plurality, $names, FD::user($owner)->getName());
return $item;
}
示例4: create_report
public function create_report()
{
$app = JFactory::getApplication();
$msg = $app->input->get('message', '', 'STRING');
$title = $app->input->get('user_title', '', 'STRING');
$item_id = $app->input->get('itemId', 0, 'INT');
$log_user = $this->plugin->get('user')->id;
$data = array();
$data['message'] = $msg;
$data['uid'] = $item_id;
$data['type'] = 'stream';
$data['title'] = $title;
$data['extension'] = 'com_easysocial';
//build share url use for share post through app
$sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item_id, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
$url = $sharing->url;
$data['url'] = $url;
// Get the reports model
$model = FD::model('Reports');
// Determine if this user has the permissions to submit reports.
$access = FD::access();
// Determine if this user has exceeded the number of reports that they can submit
$total = $model->getCount(array('created_by' => $log_user));
if ($access->exceeded('reports.limit', $total)) {
$final_result['message'] = "Limit exceeds";
$final_result['status'] = true;
return $final_result;
}
// Create the report
$report = FD::table('Report');
$report->bind($data);
// Set the creator id.
$report->created_by = $log_user;
// Set the default state of the report to new
$report->state = 0;
// Try to store the report.
$state = $report->store();
// If there's an error, throw it
if (!$state) {
$final_result['message'] = "Can't save report";
$final_result['status'] = true;
return $final_result;
}
// @badge: reports.create
// Add badge for the author when a report is created.
$badge = FD::badges();
$badge->log('com_easysocial', 'reports.create', $log_user, JText::_('COM_EASYSOCIAL_REPORTS_BADGE_CREATED_REPORT'));
// @points: reports.create
// Add points for the author when a report is created.
$points = FD::points();
$points->assign('reports.create', 'com_easysocial', $log_user);
// Determine if we should send an email
$config = FD::config();
if ($config->get('reports.notifications.moderators')) {
$report->notify();
}
$final_result['message'] = "Report logged successfully!";
$final_result['status'] = true;
return $final_result;
}
示例5: delete
/**
* Allows caller to delete an activity item
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function delete()
{
FD::checkToken();
FD::requireLogin();
// get required form post variable
$id = JRequest::getInt('id');
// Get the view.
$view = $this->getCurrentView();
// Load the stream item
$item = FD::table('StreamItem');
$item->load($id);
// If id is invalid, throw an error.
if (!$id || !$item->id) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Activity Log: Unable to delete item because id provided is invalid.');
$view->setError(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID'));
return $view->call(__FUNCTION__);
}
// Check if the current user is allowed to delete this stream item
if (!$item->deleteable()) {
$view->setError(JText::_('COM_EASYSOCIAL_ACTIVITIES_NOT_ALLOWED_TO_DELETE_ITEM'));
return $view->call(__FUNCTION__);
}
$model = FD::model('Activities');
$state = $model->delete($id);
if (!$state) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Activity Log: Unable to delete item because model returned the error, ' . $model->getError());
$view->setError($model->getError());
return $view->call(__FUNCTION__);
}
return $view->call(__FUNCTION__);
}
示例6: route
/**
* Redirects a notification item to the intended location
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function route()
{
// The user needs to be logged in to access notifications
FD::requireLogin();
// Check for user profile completeness
FD::checkCompleteProfile();
$id = JRequest::getInt('id');
$table = FD::table('Notification');
$table->load($id);
if (!$id || !$table->id) {
FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::dashboard(array(), false));
}
// Check if the user is allowed to view this notification item.
$my = FD::user();
if ($table->target_id != $my->id) {
FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_NOT_ALLOWED'), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::dashboard(array(), false));
}
// Mark the notification item as read
$table->markAsRead();
// Ensure that all & are replaced with &
$url = str_ireplace('&', '&', $table->url);
$this->redirect(FRoute::_($url, false));
$this->close();
}
示例7: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_apps');
$sql->where('type', 'fields');
$db->setQuery($sql);
$result = $db->loadObjectList();
foreach ($result as $row) {
$file = SOCIAL_FIELDS . '/' . $row->group . '/' . $row->element . '/' . $row->element . '.xml';
if (!JFile::exists($file)) {
continue;
}
$table = FD::table('App');
$table->bind($row);
$parser = FD::get('Parser');
$parser->load($file);
$val = $parser->xpath('unique');
$unique = 0;
if ($val) {
$unique = (string) $val[0];
$unique = $unique == 'true' ? 1 : 0;
}
$table->unique = $unique;
$table->store();
}
return true;
}
示例8: getBroadcasts
/**
* Retrieves a list of broadcasts created on the site
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function getBroadcasts($userId)
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_broadcasts');
$sql->where('target_id', $userId);
$sql->where('target_type', SOCIAL_TYPE_USER);
$sql->where('state', 1);
$sql->order('created', 'DESC');
$db->setQuery($sql);
$result = $db->loadObjectList();
if (!$result) {
return false;
}
$broadcasts = array();
foreach ($result as $row) {
$broadcast = FD::table('Broadcast');
$broadcast->bind($row);
// When the broadcasts are alredy retrieved from the system, it should be marked as read.
// Otherwise it would keep on spam the user's screen.
$broadcast->markAsRead();
$broadcasts[] = $broadcast;
}
return $broadcasts;
}
示例9: getLoginButton
/**
* Renders a login button.
*
* @since 1.0
* @access public
*/
public function getLoginButton($uid, $type, $callback = '', $permissions = array(), $display = 'popup')
{
$theme = FD::themes();
// Check if the user has already authenticated.
$table = FD::table('OAuth');
$exists = $table->load(array('uid' => $uid, 'type' => $type));
if ($exists) {
$output = $theme->output('site/login/linkedin.authenticated');
} else {
$callback = urlencode($callback);
// Ensure that the callback is urlencoded
$callback = trim(JURI::root(), '/') . '/administrator/index.php?option=com_easysocial&controller=oauth&task=grant&client=linkedin&uid=' . $uid . '&type=' . $type . '&callback=' . $callback;
$this->setCallbackUrl($callback);
$requestToken = $this->retrieveTokenRequest();
$_SESSION['oauth']['linkedin']['request'] = $requestToken['linkedin'];
$url = LINKEDIN::_URL_AUTH . $requestToken['linkedin']['oauth_token'];
$theme->set('url', $url);
$theme->set('appId', $this->appId);
$theme->set('appSecret', $this->appSecret);
$theme->set('callback', $callback);
$theme->set('permissions', $permissions);
$output = $theme->output('site/login/linkedin');
}
return $output;
}
示例10: makeDefault
/**
* Set's the template as the default template
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function makeDefault()
{
// Check for request forgeries
FD::checkToken();
$element = JRequest::getVar('cid');
$element = $element[0];
$element = strtolower($element);
// Get the current view
$view = $this->getCurrentView();
// Get the configuration object
$configTable = FD::table('Config');
$config = FD::registry();
if ($configTable->load('site')) {
$config->load($configTable->value);
}
// Convert the config object to a json string.
$config->set('theme.site', $element);
// Convert the configuration to string
$jsonString = $config->toString();
// Store the setting
$configTable->value = $jsonString;
if (!$configTable->store()) {
$view->setMessage($configTable->getError(), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__);
}
return $view->call(__FUNCTION__);
}
示例11: getTitle
/**
* Retrieve the title of the stream
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function getTitle()
{
// Get the actors
$actors = $this->item->actors;
// Get the source id
$sourceId = $this->share->uid;
// Load the stream
$stream = FD::table('Stream');
$stream->load($sourceId);
// If stream cannot be loaded, skip this altogether
if (!$stream->id) {
return;
}
// Build the permalink to the stream item
$link = FRoute::stream(array('layout' => 'item', 'id' => $sourceId));
// Get the target user.
$target = FD::user($stream->actor_id);
$actor = $actors[0];
$theme = FD::get('Themes');
$theme->set('actor', $actor);
$theme->set('link', $link);
$theme->set('target', $target);
$title = $theme->output('apps/group/shares/streams/stream/title');
return $title;
}
示例12: display
/**
* Displays the application output in the canvas.
*
* @since 1.2
* @access public
* @param int The user id that is currently being viewed.
*/
public function display($groupId = null, $docType = null)
{
$group = FD::group($groupId);
// Check if the viewer is allowed here.
if (!$group->canViewItem()) {
return $this->redirect($group->getPermalink(false));
}
// Get app params
$params = $this->app->getParams();
// Load the milestone
$id = JRequest::getInt('milestoneId');
$milestone = FD::table('Milestone');
$milestone->load($id);
FD::page()->title(JText::_('APP_GROUP_TASKS_TITLE_CREATE_MILESTONE'));
if ($id && $milestone->id) {
FD::page()->title(JText::_('APP_GROUP_TASKS_TITLE_EDITING_MILESTONE'));
}
// Get a list of members from the group
$groupModel = FD::model('Groups');
$members = $groupModel->getMembers($group->id);
$this->set('members', $members);
$this->set('milestone', $milestone);
$this->set('params', $params);
$this->set('group', $group);
echo parent::display('views/form');
}
示例13: fetch
/**
* Does a remote call to the server to fetch contents of a given url.
*
* @since 1.0
* @access public
*/
public function fetch()
{
// Check for request forgeries!
$urls = $this->input->get('urls', array(), 'array');
// Result placeholder
$result = array();
if (!$urls) {
$this->view->setMessage('COM_EASYSOCIAL_CRAWLER_INVALID_URL_PROVIDED', SOCIAL_MSG_ERROR);
return $this->view->call(__FUNCTION__);
}
// Get the crawler
$crawler = FD::get('crawler');
foreach ($urls as $url) {
// Generate a hash for the url
$hash = md5($url);
$link = FD::table('Link');
$exists = $link->load(array('hash' => $hash));
// If it doesn't exist, store it.
if (!$exists) {
$crawler->crawl($url);
// Get the data from our crawler library
$data = $crawler->getData();
// Now we need to cache the link so that the next time, we don't crawl it again.
$link->hash = $hash;
$link->data = json_encode($data);
$link->store();
}
$result[$url] = json_decode($link->data);
}
return $this->view->call(__FUNCTION__, $result);
}
示例14: add
/**
* type : 'profile' == profile status,
* content : shared content.
*/
public function add()
{
$type = JRequest::getString('type');
$content = JRequest::getVar('text');
$my = FD::get('People');
$streamId = '';
switch ($type) {
case 'profile':
$data = array();
$data['actor_node_id'] = $my->get('node_id');
$data['node_id'] = '1';
$data['content'] = $content;
$storyTbl = FD::table('Story');
$storyTbl->bind($data);
$storyTbl->store();
$streamId = $storyTbl->streamId;
if (!empty($streamId)) {
$story = FD::get('Stream')->get('people', '', '', false, $streamId);
FD::get('AJAX')->success($story[0]);
return;
}
break;
default:
break;
}
FD::get('AJAX')->success();
}
示例15: display
/**
* Displays the application output in the canvas.
*
* @since 1.0
* @access public
* @param int The user id that is currently being viewed.
*/
public function display($groupId = null, $docType = null)
{
$group = FD::group($groupId);
// Render the rss model
$model = FD::model('RSS');
$result = $model->getItems($group->id, SOCIAL_TYPE_GROUP);
// If there are tasks, we need to bind them with the table.
$feeds = array();
if ($result) {
foreach ($result as $row) {
// Bind the result back to the note object.
$rss = FD::table('Rss');
$rss->bind($row);
// Initialize the parser.
$parser = @JFactory::getFeedParser($rss->url);
$rss->parser = $parser;
$rss->total = @$parser->get_item_quantity();
$rss->items = @$parser->get_items();
$feeds[] = $rss;
}
}
// Get the app params
$params = $this->app->getParams();
$limit = $params->get('total', 5);
$this->set('totalDisplayed', $limit);
$this->set('appId', $this->app->id);
$this->set('group', $group);
$this->set('feeds', $feeds);
echo parent::display('views/default');
}