Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_public does not work #13

Closed
diesan100 opened this issue Mar 20, 2015 · 1 comment
Closed

is_public does not work #13

diesan100 opened this issue Mar 20, 2015 · 1 comment

Comments

@diesan100
Copy link

There is a property called like the title of this issue which does not save and... I don´t know what is it for... :)

@hubrajesh
Copy link

This property is used to check if user allowed to create/edit public event/content in a space or not.
If user is not allowed to created public content in a space and tries to do so then it will fail.
A quick fix for this -
edit file : /protected/modules/calendar/models/CalendarEntry.php

public function rules()
    {
        return array(
            array('title, start_time, end_time, all_day', 'required'),
            ...
            array('is_public', 'checkVisibility'), //add this array to fix issue
            array('all_day, recur, recur_type, recur_interval', 'numerical', 'integerOnly' => true),
            ...
        );
    }

and add a function for this rule to work in same class

    /**
     * Checks if current user can create public event
     * 
     */
    public function checkVisibility()
    {
       if (get_class($this->content->container) == 'Space') {
            if (!$this->content->container->canShare() && $this->is_public == 1) {
                $this->addError('is_public', Yii::t('base', 'You cannot create public visible content for this  space!'));
            }
        }
    }

There is other way too but will require editing 2 files controller and view file.
You can pass content model ( 'content' => $calendarEntry->content) to edit.php (view file) and then create input field for content->visibility instead of is_public.
In that case is_public will not be needed and validation error message will be acquired directly from content model class.
Better use quick fix for now and wait for proper fix by developers ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants