当前位置: 首页>>代码示例>>PHP>>正文


PHP Foundry::info方法代码示例

本文整理汇总了PHP中Foundry::info方法的典型用法代码示例。如果您正苦于以下问题:PHP Foundry::info方法的具体用法?PHP Foundry::info怎么用?PHP Foundry::info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Foundry的用法示例。


在下文中一共展示了Foundry::info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * Creates a new discussion
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeriess
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Load up ajax lib
     $ajax = FD::ajax();
     // Load the discussion
     $id = JRequest::getInt('id');
     $discussion = FD::table('Discussion');
     $discussion->load($id);
     // Get the current logged in user.
     $my = FD::user();
     // Get the group
     $groupId = JRequest::getInt('cluster_id', 0);
     $group = FD::group($groupId);
     // Only allow owner and admin to modify the
     if ($discussion->id) {
         if ($discussion->created_by != $my->id && !$group->isAdmin() && !$my->isSiteAdmin()) {
             return $this->redirect($group->getPermalink(false));
         }
     }
     // Check if the user is allowed to create a discussion
     if (!$group->isMember()) {
         FD::info()->set(JText::_('APP_GROUP_DISCUSSIONS_NOT_ALLOWED_CREATE'), SOCIAL_MSG_ERROR);
         // Perform a redirection
         return JFactory::getApplication()->redirect(FRoute::dashboard());
     }
     // Assign discussion properties
     $discussion->uid = $group->id;
     $discussion->type = SOCIAL_TYPE_GROUP;
     $discussion->title = JRequest::getVar('title', '');
     $discussion->content = JRequest::getVar('content', '', 'POST', 'none', JREQUEST_ALLOWRAW);
     // If discussion is edited, we don't want to modify the following items
     if (!$discussion->id) {
         $discussion->created_by = $my->id;
         $discussion->parent_id = 0;
         $discussion->hits = 0;
         $discussion->state = SOCIAL_STATE_PUBLISHED;
         $discussion->votes = 0;
         $discussion->lock = false;
     }
     $app = $this->getApp();
     // Ensure that the title is valid
     if (!$discussion->title) {
         Foundry::info()->set(JText::_('APP_GROUP_DISCUSSIONS_INVALID_TITLE'), SOCIAL_MSG_ERROR);
         // Get the redirection url
         $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'create', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias()), false);
         return $this->redirect($url);
     }
     // Lock the discussion
     $state = $discussion->store();
     if (!$state) {
         FD::info()->set(JText::_('APP_GROUP_DISCUSSIONS_DISCUSSION_CREATED_FAILED'));
         // Get the redirection url
         $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'form', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias()), false);
         return $this->redirect($url);
     }
     // Process any files that needs to be created.
     $discussion->mapFiles();
     // Get the app
     $app = $this->getApp();
     // If it is a new discussion, we want to run some other stuffs here.
     if (!$id) {
         // @points: groups.discussion.create
         // Add points to the user that updated the group
         $points = FD::points();
         $points->assign('groups.discussion.create', 'com_easysocial', $my->id);
         // Create a new stream item for this discussion
         $stream = FD::stream();
         // Get the stream template
         $tpl = $stream->getTemplate();
         // Someone just joined the group
         $tpl->setActor($my->id, SOCIAL_TYPE_USER);
         // Set the context
         $tpl->setContext($discussion->id, 'discussions');
         // Set the cluster
         $tpl->setCluster($group->id, SOCIAL_TYPE_GROUP, $group->type);
         // Set the verb
         $tpl->setVerb('create');
         // Set the params to cache the group data
         $registry = FD::registry();
         $registry->set('group', $group);
         $registry->set('discussion', $discussion);
         $tpl->setParams($registry);
         $tpl->setAccess('core.view');
         // Add the stream
         $stream->add($tpl);
         // Set info message
         FD::info()->set(false, JText::_('APP_GROUP_DISCUSSIONS_DISCUSSION_CREATED_SUCCESS'), SOCIAL_MSG_SUCCESS);
         // Send notification to group members only if it is new discussion
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:discussion.php


注:本文中的Foundry::info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。