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


PHP PHOTO_BOL_PhotoService::countUserPhotos方法代码示例

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


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

示例1: checkUploadPermissins

 protected function checkUploadPermissins($entityType, $entityId)
 {
     // disallow not authenticated access
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $language = OW::getLanguage();
     $userId = OW::getUser()->getId();
     $config = OW::getConfig();
     $userQuota = (int) $config->getValue('photo', 'user_quota');
     if (!OW::getUser()->isAuthorized('photo', 'upload')) {
         throw new PHOTO_Exception($language->text('photo', 'auth_upload_permissions'));
     }
     $eventParams = array('pluginKey' => 'photo', 'action' => 'add_photo');
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         throw new PHOTO_Exception(OW::getEventManager()->call('usercredits.error_message', $eventParams));
     } else {
         if (!($this->photoService->countUserPhotos($userId) <= $userQuota)) {
             throw new PHOTO_Exception($language->text('photo', 'quota_exceeded', array('limit' => $userQuota)));
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:23,代码来源:upload.php

示例2: photo

    public function photo(array $params = null)
    {
        if (!OW::getUser()->isAuthenticated()) {
            throw new AuthenticateException();
        }
        $language = OW::getLanguage();
        if (!OW::getUser()->isAuthorized('photo', 'upload')) {
            $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'upload');
            $this->assign('auth_msg', $status['msg']);
            return;
        }
        $config = OW::getConfig();
        $userQuota = (int) $config->getValue('photo', 'user_quota');
        $userId = OW::getUser()->getId();
        if (!($this->photoService->countUserPhotos($userId) <= $userQuota)) {
            $this->assign('auth_msg', $language->text('photo', 'quota_exceeded', array('limit' => $userQuota)));
        } else {
            $accepted = floatval($config->getValue('photo', 'accepted_filesize') * 1024 * 1024);
            $this->assign('auth_msg', null);
            $form = new PHOTO_MCLASS_UploadForm();
            $this->addForm($form);
            $photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
            $albums = $photoAlbumService->findUserAlbumList($userId, 1, 100);
            $this->assign('albums', $albums);
            if (!empty($params['album']) && (int) $params['album']) {
                $albumId = (int) $params['album'];
                $uploadToAlbum = $photoAlbumService->findAlbumById($albumId);
                if (!$uploadToAlbum || $uploadToAlbum->userId != $userId) {
                    $this->redirect(OW::getRouter()->urlForRoute('photo_upload'));
                }
                $form->getElement('album')->setValue($uploadToAlbum->name);
            }
            if ($albums) {
                $script = '$("#album_select").change(function(event){
                    $("#album_input").val($(this).val());
                });';
                OW::getDocument()->addOnloadScript($script);
            }
            $script = '$("#upload-file-field").change(function(){
                var img = $("#photo-file-prevew");
                var name = $(".owm_upload_img_name_label span");

                img.hide();
                name.text("");

                if (!this.files || !this.files[0]) return;

                if ( window.FileReader ) {
                    var reader = new FileReader();
                    reader.onload = function (e) {
                        img.show().attr("src", e.target.result);
                    }
                    reader.readAsDataURL(this.files[0]);
                } else {
                    name.text(this.files[0].name);
                }
                $(".owm_upload_photo_browse_wrap").addClass("owm_upload_photo_attach_wrap");
            });';
            OW::getDocument()->addOnloadScript($script);
            if (OW::getRequest()->isPost()) {
                $form->isValid($_POST);
                $values = $form->getValues();
                // Delete old temporary photos
                $tmpPhotoService = PHOTO_BOL_PhotoTemporaryService::getInstance();
                $photoService = PHOTO_BOL_PhotoService::getInstance();
                $file = $_FILES['photo'];
                $tmpPhotoService->deleteUserTemporaryPhotos($userId);
                if (strlen($file['tmp_name'])) {
                    if (!UTIL_File::validateImage($file['name']) || $file['size'] > $accepted) {
                        OW::getFeedback()->warning($language->text('photo', 'no_photo_uploaded'));
                        $this->redirect();
                    }
                    $tmpPhotoService->addTemporaryPhoto($file['tmp_name'], $userId, 1);
                    $tmpList = $tmpPhotoService->findUserTemporaryPhotos($userId, 'order');
                    $tmpList = array_reverse($tmpList);
                    // check album exists
                    if (!($album = $photoAlbumService->findAlbumByName($values['album'], $userId))) {
                        $album = new PHOTO_BOL_PhotoAlbum();
                        $album->name = $values['album'];
                        $album->userId = $userId;
                        $album->createDatetime = time();
                        $photoAlbumService->addAlbum($album);
                    }
                    foreach ($tmpList as $tmpPhoto) {
                        $photo = $tmpPhotoService->moveTemporaryPhoto($tmpPhoto['dto']->id, $album->id, $values['description']);
                        if ($photo) {
                            BOL_AuthorizationService::getInstance()->trackAction('photo', 'upload');
                            $photoService->createAlbumCover($album->id, array($photo));
                            $photoService->triggerNewsfeedEventOnSinglePhotoAdd($album, $photo);
                            $photoParams = array('addTimestamp' => $photo->addDatetime, 'photoId' => $photo->id, 'hash' => $photo->hash, 'description' => $photo->description);
                            $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_ADD, array($photoParams));
                            OW::getEventManager()->trigger($event);
                            $photo = $this->photoService->findPhotoById($photo->id);
                            if ($photo->status != PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
                                OW::getFeedback()->info(OW::getLanguage()->text('photo', 'photo_uploaded_pending_approval'));
                                if (PHOTO_BOL_PhotoAlbumService::getInstance()->countAlbumPhotos($photo->albumId)) {
                                    $this->redirect(OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($userId), 'album' => $album->id)));
                                } else {
                                    $this->redirect(OW::getRouter()->urlForRoute('photo_user_albums', array('user' => BOL_UserService::getInstance()->getUserName($userId))));
                                }
//.........这里部分代码省略.........
开发者ID:tammyrocks,项目名称:photo,代码行数:101,代码来源:upload.php


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