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


PHP FD::access方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     // Define Joomla's app
     $this->app = JFactory::getApplication();
     $this->input = $this->app->input;
     // Load configuration object.
     $config = FD::config();
     $jConfig = FD::jconfig();
     // Define the current logged in user or guest
     if (is_null(self::$user)) {
         self::$user = FD::user();
     }
     // Define the current logged in user's access.
     if (is_null(self::$userAccess)) {
         self::$userAccess = FD::access();
     }
     if (is_null(self::$tmplMode)) {
         self::$tmplMode = $this->input->get('tmpl', '', 'default');
     }
     // Get the current access
     $this->my = self::$user;
     $this->access = self::$userAccess;
     // Define our own configuration
     $this->config = $config;
     // Define template's own configuration
     if (is_null(self::$templateConfig)) {
         self::$templateConfig = $this->getConfig();
     }
     $this->template = self::$templateConfig;
     // Define Joomla's configuration so the world can use it.
     $this->jConfig = $jConfig;
     // Determine if the current request has tmpl=xxx
     $this->tmpl = self::$tmplMode;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:34,代码来源:template.php

示例2: 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;
 }
开发者ID:yalive,项目名称:com_api-plugins,代码行数:60,代码来源:report.php

示例3: __construct

 public function __construct()
 {
     $this->doc = JFactory::getDocument();
     $this->config = FD::config();
     $this->app = JFactory::getApplication();
     $this->input = FD::request();
     $this->my = FD::user();
     $this->access = FD::access();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:9,代码来源:dependencies.php

示例4: getTitle

 /**
  * Displays the comments title in the stream.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getTitle()
 {
     $config = FD::config();
     $access = FD::access();
     if (!$config->get('stream.comments.enabled') || !$access->allowed('comments.add')) {
         return false;
     }
     $my = FD::user();
     return JText::_('Comment');
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:18,代码来源:comments.php

示例5: onRegister

 public function onRegister(&$post, &$session)
 {
     // Get access
     $access = FD::access($session->uid, SOCIAL_TYPE_CLUSTERS);
     if (!$access->get('events.groupevent', true)) {
         return;
     }
     $value = !empty($post['eventcreate']) ? $post['eventcreate'] : '[]';
     $value = FD::makeArray($value);
     $this->set('value', $value);
     return $this->display();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:12,代码来源:eventcreate.php

示例6: getForm

 /**
  * Generates the report link to allow users to report on an item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getForm($extension, $type, $uid, $itemTitle, $text, $title = '', $description = '', $url = '', $icon = false)
 {
     // Determine if the user is a guest
     $my = FD::user();
     $config = FD::config();
     if (!$my->id) {
         if (!$config->get('reports.guests', false)) {
             return;
         }
     } else {
         // Check if user is allowed to report.
         $access = FD::access();
         // @access: reports.submit
         // Check if user is allowed to create reports
         if (!$access->allowed('reports.submit')) {
             return;
         }
         $model = FD::model('Reports');
         $usage = $model->getCount(array('created_by' => $my->id));
         // Check if the current user exceeded the reports limit
         if ($access->exceeded('reports.limit', $usage)) {
             return;
         }
     }
     $theme = FD::themes();
     // Set a default text if API wasn't provided with a custom text.
     if (empty($text)) {
         $text = JText::_('COM_EASYSOCIAL_REPORTS_REPORT_ITEM');
     }
     // If url is not provided, use the current URL.
     if (empty($url)) {
         $url = JRequest::getURI();
     }
     // If title is not supplied, we use the text
     if (empty($title)) {
         $title = $text;
     }
     $theme->set('url', $url);
     $theme->set('extension', $extension);
     $theme->set('itemTitle', $itemTitle);
     $theme->set('title', $title);
     $theme->set('text', $text);
     $theme->set('type', $type);
     $theme->set('uid', $uid);
     $theme->set('description', $description);
     $theme->set('icon', $icon);
     $contents = $theme->output('site/reports/default.link');
     return $contents;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:57,代码来源:reports.php

示例7: upload

 public function upload()
 {
     // Get the ajax library
     $ajax = FD::ajax();
     // Get the file
     $tmp = JRequest::getVar($this->inputName, '', 'FILES');
     $file = array();
     foreach ($tmp as $k => $v) {
         $file[$k] = $v['file'];
     }
     // Check if it is a valid file
     if (empty($file['tmp_name'])) {
         return $ajax->reject(JText::_('PLG_FIELDS_AVATAR_ERROR_INVALID_FILE'));
     }
     // Get user access
     $access = FD::access($this->uid, SOCIAL_TYPE_CLUSTERS);
     // Check if the filesize is too large
     $maxFilesize = $access->get('photos.maxsize');
     $maxFilesizeBytes = (int) $maxFilesize * 1048576;
     if ($file['size'] > $maxFilesizeBytes) {
         return $ajax->reject(JText::sprintf('COM_EASYSOCIAL_PHOTOS_UPLOAD_ERROR_FILE_SIZE_LIMIT_EXCEEDED', $maxFilesize . 'mb'));
     }
     // Load up the image library so we can get the appropriate extension
     $image = FD::image();
     $image->load($file['tmp_name']);
     // Copy this to temporary location first
     $tmpPath = SocialFieldsUserAvatarHelper::getStoragePath($this->inputName);
     $tmpName = md5($file['name'] . $this->inputName . FD::date()->toMySQL()) . $image->getExtension();
     $source = $file['tmp_name'];
     $target = $tmpPath . '/' . $tmpName;
     $state = JFile::copy($source, $target);
     if (!$state) {
         return $ajax->reject(JText::_('PLG_FIELDS_AVATAR_ERROR_UNABLE_TO_MOVE_FILE'));
     }
     $tmpUri = SocialFieldsUserAvatarHelper::getStorageURI($this->inputName);
     $uri = $tmpUri . '/' . $tmpName;
     return $ajax->resolve($file, $uri, $target);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:38,代码来源:ajax.php

示例8: upload

 /**
  * Performs the file uploading here when the user selects their profile picture.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function upload()
 {
     // Get the ajax library
     $ajax = FD::ajax();
     $tmp = JRequest::getVar($this->inputName, '', 'FILES');
     $file = array();
     foreach ($tmp as $k => $v) {
         $file[$k] = $v['file'];
     }
     if (!isset($file['tmp_name']) || empty($file['tmp_name'])) {
         return $ajax->reject(JText::_('PLG_FIELDS_COVER_VALIDATION_INVALID_IMAGE'));
     }
     // Get user access
     $access = FD::access($this->uid, SOCIAL_TYPE_PROFILES);
     // Check if the filesize is too large
     $maxFilesize = $access->get('photos.uploader.maxsize');
     $maxFilesizeBytes = (int) $access->get('photos.uploader.maxsize') * 1048576;
     if ($file['size'] > $maxFilesizeBytes) {
         return $ajax->reject(JText::sprintf('COM_EASYSOCIAL_PHOTOS_UPLOAD_ERROR_FILE_SIZE_LIMIT_EXCEEDED', $maxFilesize . 'mb'));
     }
     $result = $this->createCover($file, $this->inputName);
     return $ajax->resolve($result);
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:31,代码来源:ajax.php

示例9: getAccess

 /**
  * Gets the @SocialAccess object.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	SocialAccess
  *
  * @author	Mark Lee <mark@stackideas.com>
  */
 public function getAccess()
 {
     static $data = null;
     if (!isset($data[$this->id])) {
         $access = FD::access($this->id, SOCIAL_TYPE_USER);
         $data[$this->id] = $access;
     }
     return $data[$this->id];
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:19,代码来源:user.php

示例10: uploadPhoto

 public function uploadPhoto($log_usr = 0, $type = null)
 {
     // Get current logged in user.
     $my = FD::user($log_usr);
     // Get user access
     $access = FD::access($my->id, SOCIAL_TYPE_USER);
     // Load up the photo library
     $lib = FD::photo($log_usr, $type);
     // Define uploader options
     $options = array('name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit());
     // Get uploaded file
     $file = FD::uploader($options)->getFile();
     // Load the iamge object
     $image = FD::image();
     $image->load($file['tmp_name'], $file['name']);
     // Detect if this is a really valid image file.
     if (!$image->isValid()) {
         return "invalid image";
     }
     // Load up the album's model.
     $albumsModel = FD::model('Albums');
     // Create the default album if necessary
     $album = $albumsModel->getDefaultAlbum($log_usr, $type, SOCIAL_ALBUM_STORY_ALBUM);
     // Bind photo data
     $photo = FD::table('Photo');
     $photo->uid = $log_usr;
     $photo->type = $type;
     $photo->user_id = $my->id;
     $photo->album_id = $album->id;
     $photo->title = $file['name'];
     $photo->caption = '';
     $photo->state = 1;
     $photo->ordering = 0;
     // Set the creation date alias
     $photo->assigned_date = FD::date()->toMySQL();
     // Trigger rules that should occur before a photo is stored
     $photo->beforeStore($file, $image);
     // Try to store the photo.
     $state = $photo->store();
     // Load the photos model
     $photosModel = FD::model('Photos');
     // Get the storage path for this photo
     $storage = FD::call('Photos', 'getStoragePath', array($album->id, $photo->id));
     // Get the photos library
     $photoLib = FD::get('Photos', $image);
     $paths = $photoLib->create($storage);
     // Create metadata about the photos
     if ($paths) {
         foreach ($paths as $type => $fileName) {
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_PATH;
             $meta->property = $type;
             $meta->value = $storage . '/' . $fileName;
             $meta->store();
             // We need to store the photos dimension here
             list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
             // Set the photo dimensions
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_WIDTH;
             $meta->property = $type;
             $meta->value = $width;
             $meta->store();
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
             $meta->property = $type;
             $meta->value = $height;
             $meta->store();
         }
     }
     // After storing the photo, trigger rules that should occur after a photo is stored
     //$photo->afterStore( $file , $image );
     //$sphoto = new SocialPhotos($photo_obj->id);
     return $photo;
 }
开发者ID:bellodox,项目名称:com_api-plugins,代码行数:77,代码来源:share.php

示例11: getAccess

 /**
  * Gets the SocialAccess object.
  *
  * @author  Mark Lee <mark@stackideas.com>
  * @since   1.2
  * @access  public
  * @return  SocialAccess The SocialAccess object.
  *
  */
 public function getAccess()
 {
     static $data = null;
     if (!isset($data[$this->category_id])) {
         $access = FD::access($this->category_id, SOCIAL_TYPE_CLUSTERS);
         $data[$this->category_id] = $access;
     }
     return $data[$this->category_id];
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:18,代码来源:cluster.php

示例12: getReplies

 public function getReplies()
 {
     FD::checkToken();
     $view = $this->getCurrentView();
     // Check for permission first
     $access = FD::access();
     if (!$access->allowed('comments.read')) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_COMMENTS_NOT_ALLOWED_TO_READ'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     $id = JRequest::getInt('id', 0);
     if (empty($id)) {
         return $view->call(__FUNCTION__, array());
     }
     $start = JRequest::getInt('start', '');
     $limit = JRequest::getInt('length', '');
     $model = FD::model('comments');
     $replies = $model->getComments(array('parentid' => $id, 'start' => $start, 'limit' => $limit));
     $view->call(__FUNCTION__, $replies);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:20,代码来源:comments.php

示例13: store

 /**
  * Stores a submitted report
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function store()
 {
     // Check for request forgeries
     FD::checkToken();
     // Get data from $_POST
     $post = JRequest::get('post');
     // Get current view.
     $view = $this->getCurrentView();
     // Get the current logged in user
     $my = FD::user();
     // Determine if the user is a guest
     $config = FD::config();
     if (!$my->id && !$config->get('reports.guests', false)) {
         return;
     }
     // Determine if this user has the permissions to submit reports.
     $access = FD::access();
     if (!$access->allowed('reports.submit')) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_REPORTS_NOT_ALLOWED_TO_SUBMIT_REPORTS'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Get the reports model
     $model = FD::model('Reports');
     // Determine if this user has exceeded the number of reports that they can submit
     $total = $model->getCount(array('created_by' => $my->id));
     if ($access->exceeded('reports.limit', $total)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_REPORTS_LIMIT_EXCEEDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Create the report
     $report = FD::table('Report');
     $report->bind($post);
     // Try to get the user's ip address.
     $report->ip = JRequest::getVar('REMOTE_ADDR', '', 'SERVER');
     // Set the creator id.
     $report->created_by = $my->id;
     // 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) {
         $view->setMessage($report->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // @badge: reports.create
     // Add badge for the author when a report is created.
     $badge = FD::badges();
     $badge->log('com_easysocial', 'reports.create', $my->id, 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', $my->id);
     // Determine if we should send an email
     $config = FD::config();
     if ($config->get('reports.notifications.moderators')) {
         $report->notify();
     }
     $view->setMessage(JText::_('COM_EASYSOCIAL_REPORTS_STORED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:69,代码来源:reports.php

示例14: store

 /**
  * Logics to create a new conversations.
  *
  * @since	1.0
  * @access	public
  */
 public function store()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get the current logged in user.
     $my = FD::user();
     // Get list of recipients.
     $recipients = JRequest::getVar('uid');
     // Ensure that the recipients is an array.
     $recipients = FD::makeArray($recipients);
     // The user might be writing to a friend list.
     $lists = JRequest::getVar('list_id');
     // Go through each of the list and find the member id's.
     if ($lists) {
         $ids = array();
         $listModel = FD::model('Lists');
         foreach ($lists as $listId) {
             $members = $listModel->getMembers($listId, true);
             // Merge the result set.
             $ids = array_merge($ids, $members);
         }
         if ($recipients === false) {
             $recipients = array();
         }
         // Merge the id's with the recipients and ensure that they are all unique
         $recipients = array_merge($ids, $recipients);
         $recipients = array_unique($recipients);
     }
     // Get the view.
     $view = $this->getCurrentView();
     // Get configuration
     $config = FD::config();
     // Check if user is allowed to create new conversations
     $access = FD::access();
     if (!$access->allowed('conversations.create')) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_NOT_ALLOWED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // If recipients is not provided, we need to throw an error.
     if (empty($recipients)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_EMPTY_RECIPIENTS'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Get the total number of message sent in a day
     $model = FD::model('Conversations');
     $totalSent = $model->getTotalSentDaily($my->id);
     // We need to calculate the amount of users they are sending to
     $totalSent = $totalSent + count($recipients);
     if ($access->exceeded('conversations.send.daily', $totalSent)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_EXCEEDED_DAILY_SEND_LIMIT'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Check if the creator is allowed to send a message to the target
     $privacy = $my->getPrivacy();
     // Ensure that the recipients is not only itself.
     foreach ($recipients as $recipient) {
         // When user tries to enter it's own id, we should just break out of this function.
         if ($recipient == $my->id) {
             $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_CANNOT_SEND_TO_SELF'), SOCIAL_MSG_ERROR);
             return $view->call(__FUNCTION__);
         }
         // Check if the creator is allowed
         if (!$privacy->validate('profiles.post.message', $recipient, SOCIAL_TYPE_USER)) {
             $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_CANNOT_SEND_TO_USER_DUE_TO_PRIVACY'), SOCIAL_MSG_ERROR);
             return $view->call(__FUNCTION__);
         }
     }
     // Get the message that is being posted.
     $msg = JRequest::getVar('message', '', 'REQUEST', 'none', JREQUEST_ALLOWHTML);
     // Normalize CRLF (\r\n) to just LF (\n)
     $msg = str_ireplace("\r\n", "\n", $msg);
     // Message should not be empty.
     if (empty($msg)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_EMPTY_MESSAGE'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Filter recipients and ensure all the user id's are proper!
     $total = count($recipients);
     // If there is more than 1 recipient and group conversations is disabled, throw some errors
     if ($total > 1 && !$config->get('conversations.multiple')) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CONVERSATIONS_GROUP_CONVERSATIONS_DISABLED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Go through all the recipient and make sure that they are valid.
     for ($i = 0; $i < $total; $i++) {
         $userId = $recipients[$i];
         $user = FD::user($userId);
         if (!$user || empty($userId)) {
             unset($recipients[$i]);
         }
     }
     // After processing the recipients list, and no longer has any recipients, stop the user.
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:conversations.php

示例15: uploadStory

 /**
  * Posting photos via story
  *
  * @since   1.0
  * @access  public
  */
 public function uploadStory()
 {
     // Check for request forgeries
     FD::checkToken();
     // Only registered users should be allowed to upload photos
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     // Get current logged in user.
     $my = FD::user();
     // Get user access
     $access = FD::access($my->id, SOCIAL_TYPE_USER);
     // Get the uid and type
     $uid = $this->input->get('uid', 0, 'int');
     $type = $this->input->get('type', '', 'cmd');
     // Load up the photo library
     $lib = FD::photo($uid, $type);
     // Determines if the person exceeded their upload limit
     if ($lib->exceededUploadLimit()) {
         $view->setMessage($lib->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Determines if the person exceeded their daily upload limit
     if ($lib->exceededDailyUploadLimit()) {
         $view->setMessage($lib->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Define uploader options
     $options = array('name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit());
     // Get uploaded file
     $file = FD::uploader($options)->getFile();
     // If there was an error getting uploaded file, stop.
     if ($file instanceof SocialException) {
         $view->setMessage($file, SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Load the iamge object
     $image = FD::image();
     $image->load($file['tmp_name'], $file['name']);
     // Detect if this is a really valid image file.
     if (!$image->isValid()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_FILE_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Load up the album's model.
     $albumsModel = FD::model('Albums');
     // Create the default album if necessary
     $album = $albumsModel->getDefaultAlbum($uid, $type, SOCIAL_ALBUM_STORY_ALBUM);
     // Bind photo data
     $photo = FD::table('Photo');
     $photo->uid = $uid;
     $photo->type = $type;
     $photo->user_id = $my->id;
     $photo->album_id = $album->id;
     $photo->title = $file['name'];
     $photo->caption = '';
     $photo->ordering = 0;
     // Set the creation date alias
     $photo->assigned_date = FD::date()->toMySQL();
     // Trigger rules that should occur before a photo is stored
     $photo->beforeStore($file, $image);
     // Try to store the photo.
     $state = $photo->store();
     if (!$state) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_UPLOAD_ERROR_STORING_DB'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Load the photos model
     $photosModel = FD::model('Photos');
     // Get the storage path for this photo
     $storage = FD::call('Photos', 'getStoragePath', array($album->id, $photo->id));
     // Get the photos library
     $photoLib = FD::get('Photos', $image);
     $paths = $photoLib->create($storage);
     // Create metadata about the photos
     if ($paths) {
         foreach ($paths as $type => $fileName) {
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_PATH;
             $meta->property = $type;
             $meta->value = $storage . '/' . $fileName;
             $meta->store();
             // We need to store the photos dimension here
             list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
             // Set the photo dimensions
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_WIDTH;
             $meta->property = $type;
             $meta->value = $width;
             $meta->store();
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:photos.php


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