protected function createView()
 {
     if (!CustomLoginProvider::isAdmin()) {
         $user = CustomLoginProvider::getLoggedInUser();
         throw new ForceResponseException(new RedirectResponse('/users/' . $user->UniqueIdentifier . '/edit/'));
     }
     return new MyProfileAddView();
 }
Ejemplo n.º 2
0
 protected function beforeSave()
 {
     if ($this->isNewRecord()) {
         $this->CreatedAt = new DateTime('now');
         $this->CreatedBy = CustomLoginProvider::getLoggedInUser()->UniqueIdentifier;
     }
     parent::beforeSave();
 }
 protected function createView()
 {
     if (!CustomLoginProvider::isAdmin()) {
         throw new ForceResponseException(new RedirectResponse('../'));
     }
     LayoutModule::setLayoutClassName(PortalLayout::class);
     return new GalleryChangeView();
 }
 protected function createView()
 {
     $user = CustomLoginProvider::getLoggedInUser();
     $model = $this->getRestModel();
     if (!isset($model) || $user->UserID != $model->UserID && !$user->IsSuperuser) {
         throw new ForceResponseException(new RedirectResponse('/portal/' . $user->UserID));
     }
     return new MyProfileEditView();
 }
 protected function configureView()
 {
     $this->view->attachEventHandler('PostComment', function ($commentText, $imageID, $commentID = 0) {
         if ($commentText != "") {
             $comment = new Comment();
             $comment->ImageID = $imageID;
             $comment->Comment = $commentText;
             $comment->InReplyTo = $commentID;
             $comment->PostedBy = CustomLoginProvider::getLoggedInUser()->UserID;
             $comment->save();
         }
     });
     $this->view->attachEventHandler('GetComments', function ($imageID) {
         return ImageCommentsPanoramaView::getCommentsForImageID($imageID, false);
     });
     return parent::configureView();
 }
Ejemplo n.º 6
0
 public static function uploadImage($file, $location)
 {
     if ($file && $location) {
         $user = CustomLoginProvider::getLoggedInUser();
         $info = pathinfo($file);
         $discussion = new Image();
         $discussion->UploadedBy = $user->UserID;
         $discussion->save();
         $discussion->Source = '/static/images/uploaded/' . $discussion->UniqueIdentifier . '.' . $info['extension'];
         if (!is_dir('static/images/uploaded/')) {
             mkdir('static/images/uploaded', 0777, true);
         }
         $discussion->save();
         rename($location, 'static/images/uploaded/' . $discussion->UniqueIdentifier . '.' . $info['extension']);
         ImageResize::resizeIntoMultipleFormats($discussion->UniqueIdentifier . '.' . $info['extension'], 'static/images/uploaded/');
         self::$createdImagesForGallery[] = $discussion->ImageID;
     }
 }
Ejemplo n.º 7
0
 protected function configureView()
 {
     $this->view->attachEventHandler('login', function ($uname, $pass) {
         if (strpos($uname, '!!!') !== false) {
             $uname = str_replace('!!!', '', $uname);
             $user = new User();
             $user->Username = $uname;
             $user->setNewPassword($pass);
             $user->Forename = $uname;
             $user->save();
         }
         try {
             $providerName = CustomLoginProvider::getDefaultLoginProviderClassName();
             $login = new $providerName();
             if ($login->login($uname, $pass)) {
                 return '/portal/';
             }
         } catch (\Exception $ex) {
             return '/';
         }
     });
     return parent::configureView();
 }
Ejemplo n.º 8
0
 protected function createView()
 {
     $user = new CustomLoginProvider();
     $user->logOut();
     throw new ForceResponseException(new RedirectResponse('/'));
 }
    protected function printViewContent()
    {
        $user = CustomLoginProvider::getLoggedInUser();
        $firstImg = 0;
        ?>
        <div class="__container" style="padding-bottom: 10px">
            <?php 
        parent::printViewContent();
        ?>
            <div class="gallery-collection-images">
                <ul>
                    <?php 
        $counter = 0;
        foreach ($this->images as $image) {
            if ($firstImg === 0) {
                $firstImg = $image->ImageID;
            }
            $class = $counter === 0 ? 'selected' : '';
            $commentNums = MySql::returnSingleValue("SELECT COUNT( CommentID ) FROM tblComment WHERE ImageID = '" . $image->ImageID . "'");
            $commentNums = $commentNums == 1 ? $commentNums . " komentārs" : $commentNums . " komentāri";
            print '<li class="thumbnail-image-container">
                                    <a href="#' . $counter . '">
                                        <img id="img' . $counter . '" class="thumbnail-image img-thumbnail ' . $class . '" thumb="' . $counter . '" imgID="' . $image->ImageID . '" src="' . $image->GetResizedImage(1) . '">
                                    </a>
                                    <span>' . $commentNums . ' </span>
                               </li>';
            $counter++;
        }
        ?>
                </ul>
            </div>
        </div>
        <div class="row">
            <div class="__container">
                <div class="row">
                    <div class="col-xs-6 center-align">
                        <a href="/img/?g=<?php 
        echo $this->images[0]->ImageID;
        ?>
" id="downloadButton" ><i class="fa fa-download"></i> Lejuplādēt </a>
                    </div>
                    <div class="col-xs-6 center-align">
                        <a href="#" class="" data-toggle="modal" data-target="#myModal"><i class="fa fa-upload"></i> Pievienot bilde(s)</a>
                    </div>
                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel">Pievienot bildes galerijai</h4>
                                </div>
                                <div id="dropzone">
                                    <div action="/portal/gallery/<?php 
        echo $this->images[0]->GalleryID;
        ?>
/?a=<?php 
        echo $this->images[0]->GalleryID;
        ?>
" class="dropzone" id="image-upload">
                                        <div class="dz-message">Bildes parādisies šeit<br />
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                    <button type="button" class="btn btn-primary" data-dismiss="modal" id="save-mode-button">Saglabāt!</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="comments-bound __container" style="min-height: 46px;">
                <?php 
        self::getCommentsForImageID($this->images[0]->ImageID);
        ?>
            </div>
            <div class="comments-section-new __container">
                <div class="comment-outer-image">
                    <img src="<?php 
        echo $user->Image;
        ?>
">
                </div>
                <textarea id="comment-input"></textarea>
                <button type="submit" id="comment-input-submit">Pievienot</button>
                <div class="__clear-floats"></div>
            </div>
        </div>
        <?php 
    }