Пример #1
0
 /**
  * The code that needs to be called when the cron is running
  * 
  * If $this->enableUserAndGroupSupport() returns TRUE then the run function 
  * will be called for each $user. (The $user parameter will be given)
  * 
  * If $this->enableUserAndGroupSupport() returns FALSE then the 
  * $user parameter is null and the run function will be called only once.
  * 
  * @param \GO\Base\Cron\CronJob $cronJob
  * @param \GO\Base\Model\User $user [OPTIONAL]
  */
 public function run(\GO\Base\Cron\CronJob $cronJob, \GO\Base\Model\User $user = null)
 {
     \GO::session()->runAsRoot();
     \GO::debug("Start updating public calendars.");
     $calendars = \GO\Calendar\Model\Calendar::model()->findByAttribute('public', true);
     foreach ($calendars as $calendar) {
         $file = new \GO\Base\Fs\File($calendar->getPublicIcsPath());
         if (!$file->exists()) {
             \GO::debug("Creating " . $file->path() . ".");
             $file->touch(true);
         }
         $file->putContents($calendar->toVObject());
         \GO::debug("Updating " . $calendar->name . " to " . $file->path() . ".");
     }
     \GO::debug("Finished updating public calendars.");
 }
Пример #2
0
 protected function afterSave($wasNew)
 {
     if ($wasNew && $this->group) {
         $stmt = $this->group->admins;
         foreach ($stmt as $user) {
             if ($user->user_id != $this->user_id) {
                 //the owner has already been added automatically with manage permission
                 $this->acl->addUser($user->user_id, \GO\Base\Model\Acl::DELETE_PERMISSION);
             }
         }
     }
     $file = new \GO\Base\Fs\File($this->getPublicIcsPath());
     if (!$this->public) {
         if ($file->exists()) {
             $file->delete();
         }
     } else {
         if (!$file->exists()) {
             $file->touch(true);
         }
         $file->putContents($this->toVObject());
     }
     return parent::afterSave($wasNew);
 }