Apply open writable permissions to logs and cache folders

@param $event
434690
public static function permissionDirs(Event $event)
    {
        $options = self::getOptions($event);
        $appDir = $options['ppi-app-dir'];
        $logsDir = realpath($appDir) . '/logs';
        $cacheDir = realpath($appDir) . '/cache';
        foreach(array($logsDir, $cacheDir) as $dir) {
            if(is_dir($dir) && is_writable($dir)) {
                @chmod($dir, 0777);
            }
        }

    }
114756
protected function beforeSave($event)
    {
        if ($this->autoSave) {
            $this->saveFile($this->owner->{$this->uploadAttribute}, $this->name, $this->path);
        }
    }
1228526
public static function setPermissionsSetfacl(Event $event)
	{
		$http_user = self::getHttpdUser($event);
		foreach (self::getWritableDirs($event) as $path) {
			self::SetfaclPermissionsSetter($event, $http_user, $path);
		}
		foreach (self::getWritableFiles($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
		}
	}
205117
protected function _write($event)
    {
        // $output = '<table cellspacing="10">';
        $output = '<tr>';
        $output .= '<td style="color:%color%;text-align:right;padding-right:1em">%priorityName%</td>';
        $output .= '<td style="color:%color%;text-align:right;padding-right:1em">%memory%</td>';
        $output .= '<td style="color:%color%;">%message%</td></tr>'; // (%priority%)
        $event['color'] = '#C9C9C9';
        // Count errors
        if ($event['priority'] < 7) {
            $event['color'] = 'green';
        }
        if ($event['priority'] < 6) {
            $event['color'] = '#fd9600';
        }
        if ($event['priority'] < 5) {
            $event['color'] = 'red';
            $this->_errors++;
        }

        if ($event['priority'] == ZFDebug_Controller_Plugin_Debug_Plugin_Log::ZFLOG) {
            $event['priorityName'] = $event['message']['time'];
            $event['memory'] = $event['message']['memory'];
            $event['message'] = $event['message']['message'];
        } else {
            // self::$_lastEvent = null;
            $event['message'] = $event['priorityName'] .': '. $event['message'];
            $event['priorityName'] = '&nbsp;';
            $event['memory'] = '&nbsp;';
        }
        foreach ($event as $name => $value) {
            if ('message' == $name) {
                $measure = '&nbsp;';
                if ((is_object($value) && !method_exists($value,'__toString'))) {
                    $value = gettype($value);
                } elseif (is_array($value)) {
                    $measure = $value[0];
                    $value = $value[1];
                }
            }
            $output = str_replace("%$name%", $value, $output);
        }
        $this->_messages[] = $output;
    }
77975
public function setCacheDir($dir)
    {
        $this->cacheDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
        if (!file_exists($this->cacheDir)) {
            mkdir($this->cacheDir, 0777, true);
        }
        if (is_writable($this->cacheDir) === false) {
            throw new Exception('The cache directory must be writable, chmod "' . $this->cacheDir . '" to make it writable');
        }
    }
1350238
public function disablePermissionManager(AbstractEditableSecurityEvent $event): void
    {
        $event->setPermissionEnabled($this->permManager->isEnabled());
        $this->permManager->setEnabled(false);
    }
55390
public void logSetPermissions(String src, FsPermission permissions) {
    SetPermissionsOp op = SetPermissionsOp.getInstance();
    op.set(src, permissions);
    logEdit(op);
  }
177832
public function trigger(Event $event) {
    $request = $event->getTarget();
    
    $cachedRequest = new CachedRequest($request->getURL());
    $cachedRequest->setCachedResponse($event->getData()->response);
    $cachedRequest->setHeaders($event->getData()->headers);
    
    $this->addCachedRequest($cachedRequest);
  }
761521
protected function dispatchEvent($event)
    {
        if (!$this->container) {
            throw new \RuntimeException("The container has not been set up.");
        }
        $dir = $this->container->getParameter('base_dir');
        if (!is_dir($dir) || !is_readable($dir)) {
            throw new \RuntimeException("'${dir}' is not a valid readable directory.");
        }
        $dispatcher = $this->container->get('event_dispatcher');
        $dispatcher->dispatch($event);
    }
71984
public function setLogsDir(string $logsDir): void
    {
        if (!file_exists($logsDir) || !is_writable($logsDir)) {
            throw new LoggerException('Logs path does not exist or is not writable.');
        }
        $this->logsDir = rtrim($logsDir, '/') . '/';
    }
1194841
public function addLogRecord($event) {
        /**
         * If logging is enabled
         */
        if ($event->sender->module->enableLog) {

            $userId = \Yii::$app->user->id;
            $order = $event->model;

            $message = "ID: $order->id userId: $userId";

            Yii::info($message, $event->name);
        }
    }
826734
public function runEvent($event)
    {
        $this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
        $event->run($this->laravel);
        $this->eventsRan = true;
    }
932707
public function recordThat(Event $event): void
    {
        $this->handleRecursively($event);
        parent::recordThat($event);
    }
961615
public function buildLogs($event)
    {
        $refPath  = '/composer/installed.json';
        $packages = [];

        if (file_exists($path = "{$this->vendorPath}{$refPath}")) {
            $packages = json_decode(file_get_contents($path), true);
        }

        $no_log = true;

        foreach ($packages as $one) {
            if (isset($one['extra']['changeLog'])) {
                $name           = $this->format($one['name']);
                $log_path       = $one['extra']['changeLog'];
                $version        = $one['version'];
                $package_path   = "$this->vendorPath/{$name}";
                $log_file       = glob("$package_path/$log_path/$version.*");

                if (!$log_file) {
                    continue;
                }

                $no_log      = false;
                $log_content = file_get_contents($log_file[0]);

                $this->alert("\"$name\" {$version} ChangeLog:", $event);
                $this->info($log_content, $event);

                // rename file so we dont display it again
                rename($log_file[0], "$package_path/$log_path/$version");
            }
        }

        if ($no_log) {
            $this->alert('No Available ChangeLogs At The Moment', $event);
        }
    }
637271
public static function setPermissions(Event $event)
	{
		if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
			$event->getIO()->write('<info>No permissions setup is required on Windows.</info>');
			return;
		}
		$event->getIO()->write('Setting up permissions.');
		/*		try {
					self::setPermissionsSetfacl($event);
					return;
				} catch (\Exception $setfaclException) {
					$event->getIO()->write(sprintf('<error>%s</error>', $setfaclException->getMessage()));
					$event->getIO()->write('<info>Trying chmod...</info>');
				}*/
		try {
			self::setPermissionsChmod($event);
			return;
		} catch (\Exception $chmodException) {
			$event->getIO()->write(sprintf('<error>%s</error>', $chmodException->getMessage()));
		}
	}
85254
public function logActivity($event)
    {
        // if cronjob / no user
        if (user()->id <= 0) {
            return;
        }

        // log adjustment
        LogAdminActivity::create([
            'subject_id'   => $this->id,
            'subject_type' => get_class($this),
            'name'         => $this->getActivityName($this, $event),
            'before'       => $this->before,
            'after'        => $this->after,
            'user_id'      => user()->id,
        ]);
    }
1191608
public function onOpenPlatformLogs(OpenAdministrationToolEvent $event)
    {
        $params = array();
        $params['_controller'] = 'ClarolineCoreBundle:Administration\Logs:logList';
        $params['page'] = 1;
        $this->redirect($params, $event);
    }