安全共享Google日历 [英] Secure shared Google Calendar

查看:167
本文介绍了安全共享Google日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个小型网站上工作.它有一个非常简单的想法,有两组用户,办公室用户和工作人员,都必须登录才能访问站点(该站点是使用Zend框架构建的).

I am working on a small scale website. It has a very simple idea, there are two sets of users, office and workers, both have to login to acess the site (the site is built with the Zend framework).

问题:我想拥有一个可供所有用户访问的日历.办公室工作人员可以编辑日历,而工作人员只能查看日历.

The problem: I want to have a calendar which is accessible by all the users. The office staff being able to edit the calendar and the workers only being able to view the calendar.

由于灵活性,我真的想将google用作日历的后端:几个办公室工作人员在路上(所有人都有android手机),因此可以与日历共享这些用户,他们就可以使用移动设备更新日历.

I really want to user google as the backend for the calendar due to its flexibility: A couple of the office workers work on the road (all have android phones) so the calendar can be shared with those users and they can use their mobile devices to update the calendar.

我遇到的问题是与工人共享日历.我想将可见日历嵌入到受保护的页面内-但是显然,用户必须以Google用户身份登录才能查看日历(该日历不能公开).我曾希望可以使用Zend_Gdata_Calendar,但似乎没有一种简单的方法来获取日历视图.有什么办法吗? 是否可以让网站通过Google进行身份验证并获得嵌入式日历?

The problem I've got is sharing the calendar with the workers. I wanted to embed the viewable calendar inside a secured page - but obviously the user would have to be logged in as a google user to view the calendar (it couldn't be public). I had hoped I could use the Zend_Gdata_Calendar but there doesn't appear to be an easy way to get the calendar view. Is there any way to do this? Would it be possible to get the website to auth with google and get an embeded calendar?

另一方面,我希望办公室用户能够添加到日历中-通过Zend_Gdata_Calendar很容易-也许不像我希望的那样整洁.

The other side is I want office users to be able to add to the calendar - which is easy enough through the Zend_Gdata_Calendar - maybe not as neat as I had hoped for.

我在想的另一个选择是使用Zend_Gdata_Calendar和 jQuery日历,然后允许不同的用户执行不同的任务.

The other option I was thinking was using Zend_Gdata_Calendar and a jQuery Calendar possibly, then allowing different users to do the different tasks.

在这种情况下,有没有很好的教程可以帮助您?

Is there any good tutorials out there that could help in this situation?

推荐答案

好吧,经过大量搜索之后,我决定实施自己的解决方案,因为找不到合适的解决方案.

Okay after lots of searching, I have decided to implement my own solution seeings as I couldn't find one out there that matched my needs.

我决定使用 FullCalendar插件.它确实具有gCal函数,它将从日历供稿中获取数据,但是日历必须是公共的才能使用此功能.所以我创建了自己的.

I have decided to use the FullCalendar Plugin. It does have a gCal function, where it will get the data from a calendar feed, but the calendar needs to be public to use this function. So I created my own.

在页面视图(calendar.phtml):

On the page view (calendar.phtml):

    <?php if ($this->worker == "office"): ?>
        <div id='calendar'></div>
    <?php else: ?>
        <iframe src="https://www.google.com/calendar/embed?showTitle=0&amp;showCalendars=0&amp;showTz=0&amp;height=600&amp;wkst=2&amp;hl=en_GB&amp;bgcolor=%23FFFFFF&amp;src=YOU-CALENDAR-LINK&amp;color=%2329527A&amp;ctz=Europe%2FLondon&pvttk=YOUR-PRIVATE-KEY" 
            style="border-width:0;" 
            width="580" 
            height="600" 
            frameborder="0" 
            scrolling="no"></iframe>
    <?php endif; ?>

在calendarAction方法中:

In the calendarAction method:

    $this->view->jQuery()->addStyleSheet($this->view->baseUrl('css/JQuery/fullcalendar.css'));
    $this->view->jQuery()->addJavascriptFile($this->view->baseUrl('js/fullcalendar.js'));  
    $this->view->jQuery()->addJavascriptFile($this->view->baseUrl('js/myCal.js'));  

在我的Calendar Controler中,我添加了一个返回json数组的函数(CalendarControler.php):

In my Calendar Controler I added a function to return a json array (CalendarControler.php):

    $startDate = $this->_getParam('start');
    $startDate = date("Y-m-d", $startDate);
    $endDate = $this->_getParam('end');
    $endDate = date("Y-m-d", $endDate);
    // Remove the view & layout
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender(true);
    // Query Google GData for the calendar
    $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
    $source = "YOU-APP-NAME";
    $user = "USERNAME";
    $pass = "PASSWORD";
    $client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service,null,$source);
    $cal = new Zend_Gdata_Calendar($client);
    $events = array();
    $query = $cal->newEventQuery();
    $query->setUser('default');
    $query->setVisibility('private');
    $query->setStartMin($startDate);
    $query->setStartMax($endDate);
    $eventFeed = $cal->getCalendarEventFeed($query);
    // Loop through the returned events:
    foreach ($eventFeed as $event) 
    {
        $temp['id'] = $event->id->text;
        $temp['title'] = $event->title->text;
        $temp['allDay'] = false;
        foreach ($event->when as $when) 
        {
            $temp['start'] = date("D M j Y H:i:s eO", strtotime($when->startTime));
            $temp['end'] = date("D M j Y H:i:s eO", strtotime($when->endTime));
        }
        array_push($events, $temp);
    }
    echo json_encode($events);

最后未完成的JS类(myCal.js)-未完成,因为我将挂接到fullcalendar的可编辑和添加动作,并使用一些ajax调用来创建对话框并添加新事件,编辑事件和删除事件-否则,这基本上是一个私人嵌入的Google日历(如向工作人员显示的内容):

Finally the unfinished JS class (myCal.js) - It is unfinished as I will be hooking onto the editable and adding actions of fullcalendar and using some ajax calls to create a dialog and add new events, edit events and delete events - otherwise this would basically be a private embeded google calendar (like what is shown to the workers):

    $j("#calendar").fullCalendar({    
        editable: false,            
        header: {
            left: "prev,next today",
            center: "title",
            right: "month,basicWeek,agendaDay"},
        events: "calendar/events"});

这篇关于安全共享Google日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆