安全共享的 Google 日历

发布于 2024-10-04 13:45:32 字数 668 浏览 11 评论 0原文

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

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

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

我遇到的问题是与工作人员共享日历。我想将可查看的日历嵌入到安全页面中 - 但显然用户必须以谷歌用户身份登录才能查看日历(它不能公开)。我曾希望可以使用 Zend_Gdata_Calendar 但似乎没有一种简单的方法来获取日历视图。有什么办法可以做到这一点吗? 是否可以让网站通过谷歌进行身份验证并获得嵌入的日历?

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

我想到的另一个选择是使用 Zend_Gdata_Calendar 和 jQuery Calendar 可能,然后允许不同的用户执行不同的任务。

有没有什么好的教程可以在这种情况下提供帮助?

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.

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.

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?

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她如夕阳 2024-10-11 13:45:32

好吧,经过大量搜索后,我决定实施自己的解决方案,因为我找不到符合我需求的解决方案。

我决定使用 FullCalendar 插件。它确实有一个 gCal 功能,可以从日历提要中获取数据,但日历需要公开才能使用此功能。所以我创建了自己的。

在页面视图(calendar.phtml)上:

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

在calendarAction方法中:

    $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'));  

在我的日历控制器中,我添加了一个返回json数组的函数(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 调用来创建对话框并添加新事件、编辑事件和删除事件 - 否则这基本上将是一个私有的嵌入式谷歌日历(就像向工作人员显示的那样) :

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

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.

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.

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&showCalendars=0&showTz=0&height=600&wkst=2&hl=en_GB&bgcolor=%23FFFFFF&src=YOU-CALENDAR-LINK&color=%2329527A&ctz=Europe%2FLondon&pvttk=YOUR-PRIVATE-KEY" 
            style="border-width:0;" 
            width="580" 
            height="600" 
            frameborder="0" 
            scrolling="no"></iframe>
    <?php endif; ?>

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'));  

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);

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"});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文