Esempio n. 1
0
 function addAcl($calendarId)
 {
     $rule = new Google_Service_Calendar_AclRule();
     $scope = new Google_Service_Calendar_AclRuleScope();
     $scope->setType("default");
     //$scope->setValue("scopeValue");
     $rule->setScope($scope);
     $rule->setRole("reader");
     $createdRule = $this->service->acl->insert($calendarId, $rule);
     return $createdRule->getId();
 }
 function USRC_shareUnSharecalender($URSRC_loginid,$role,$service){
     $this->load->model('EILIB/Mdl_eilib_calender');
     $calendarId=$this->Mdl_eilib_calender->GetEICalendarId();
     try{
         $cal = $this->Mdl_eilib_calender->createCalendarService();
         $rule = new Google_Service_Calendar_AclRule();
         $scope = new Google_Service_Calendar_AclRuleScope();
         $scope->setType("user");
         $scope->setValue($URSRC_loginid);
         $rule->setScope($scope);
         $rule->setRole($role);
         $createdRule = $cal->acl->insert($calendarId, $rule);
         return 1;
     }
     catch(Exception $e){
         return 0;
     }
 }
                 $scope->setValue($email);
                 $rule->setScope($scope);
                 $rule->setRole("none");
                 try {
                     $createdRule = $service->acl->insert($oldcalenderid, $rule);
                 } catch (Exception $e) {
                     echo $e;
                 }
             }
         }
         for ($x = 0; $x <= count($emailadrress); $x++) {
             if ($role[$x] == 'reader') {
                 $email = explode(":", $emailadrress[$x]);
                 $email = $email[1];
                 $rule = new Google_Service_Calendar_AclRule();
                 $scope = new Google_Service_Calendar_AclRuleScope();
                 $scope->setType("user");
                 $scope->setValue($email);
                 $rule->setScope($scope);
                 $rule->setRole($role[$x]);
                 $createdRule = $service->acl->insert($CONFIG_SRCH_UPD_data, $rule);
             }
         }
     }
 }
 //        url id
 if ($CONFIG_SRCH_UPD_type == 9) {
     $new_url = $CONFIG_SRCH_UPD_data;
     if ($new_url != null) {
         $new_url_id = explode("/", $new_url);
         $new_fileId = $new_url_id[7];
Esempio n. 4
0
 /** Batch version of function to add user calendar permissions based on user's role in course
  *  Uses Batch Execution in addition to google's Access Control List (Acl)
  *  @param $calendarId: calendar to which we want to add batch user permissions
  *  @param $value: should be an array of user emails and their access levels e.g ('student'=>'reader')
  * 
  */
 function batch_add_user_permissions($calendarId, $value = array())
 {
     $this->get_token('calendar');
     $this->client->setUseBatch(true);
     //enable batch use
     $batch = new Google_Http_Batch($this->client);
     //Http batch object
     $rule = new Google_Service_Calendar_AclRule();
     $scope = new Google_Service_Calendar_AclRuleScope();
     $scope->setType('user');
     foreach ($value as $user => $role) {
         try {
             $scope->setValue($user);
             $rule->setScope($scope);
             $rule->setRole($role);
             $return = $this->service->acl->insert($calendarId, $rule, array('sendNotificationEmails' => 0));
             $batch->add($return, $user);
         } catch (Exception $e) {
             print "An error occurred: " . $e->getMessage();
         }
     }
     $batch->execute();
     $this->client->setUseBatch(false);
     return true;
 }
Esempio n. 5
0
 /**
  * Creates a new calendar
  *
  * @param string calendar name
  * @return string calendar ID (or false on failure)
  */
 public function createCalendar($calendarName)
 {
     if ($this->authorised()) {
         // set up the calendar and save
         $calendar = new Google_Service_Calendar_Calendar();
         $calendar->setSummary($calendarName);
         $calendar->setTimeZone('Europe/London');
         $calendar->setLocation('United Kingdom');
         try {
             $calendar = $this->__service->calendars->insert($calendar);
         } catch (Exception $e) {
             return false;
         }
         // make it public, delete if this fails
         try {
             $acl = new Google_Service_Calendar_AclRule();
             $acl->setRole('reader');
             $scope = new Google_Service_Calendar_AclRuleScope();
             $scope->setType('default');
             $acl->setScope($scope);
             $this->__service->acl->insert($calendar->getId(), $acl);
         } catch (Exception $e) {
             $this->__service->calendars->delete($calendar->getId());
             return false;
         }
         return $calendar->getId();
     }
     return false;
 }