Merge branch 'v1.3-dev' into patch-1

This commit is contained in:
Sarah Tsumayoi 2018-03-16 08:08:14 +09:00 committed by GitHub
commit 3c790c81be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 174 additions and 224 deletions

View File

@ -14,7 +14,7 @@
"minimum-stability": "stable",
"require": {
"php": ">=5.6.0",
"yiisoft/yii2": "2.0.13",
"yiisoft/yii2": "2.0.14.1",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-swiftmailer": "~2.0.0",
"yiisoft/yii2-authclient": "~2.1.0",

View File

@ -8,15 +8,15 @@
namespace humhub\components;
use Yii;
use yii\base\Component;
use yii\base\Exception;
use yii\base\Event;
use yii\base\InvalidConfigException;
use yii\helpers\FileHelper;
use yii\helpers\ArrayHelper;
use humhub\components\bootstrap\ModuleAutoLoader;
use humhub\models\ModuleEnabled;
use Yii;
use yii\base\Component;
use yii\base\Event;
use yii\base\Exception;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\FileHelper;
/**
* ModuleManager handles all installed modules.
@ -78,11 +78,11 @@ class ModuleManager extends Component
/**
* Registers a module to the manager
* This is usally done by autostart.php in modules root folder.
* This is usually done by config.php in modules root folder.
* @see \humhub\components\bootstrap\ModuleAutoLoader::bootstrap
*
* @param array $
* @throws Exception
* @param array $configs
* @throws InvalidConfigException
*/
public function registerBulk(array $configs)
{
@ -100,8 +100,9 @@ class ModuleManager extends Component
*/
public function register($basePath, $config = null)
{
if ($config === null && is_file($basePath . '/config.php')) {
$config = require($basePath . '/config.php');
$filename = $basePath . '/config.php';
if ($config === null && is_file($filename)) {
$config = require $filename;
}
// Check mandatory config options
@ -150,7 +151,7 @@ class ModuleManager extends Component
$moduleConfig = [
'class' => $config['class'],
'modules' => $config['modules']
'modules' => $config['modules'],
];
// Add config file values to module
@ -227,7 +228,7 @@ class ModuleManager extends Component
* Returns a module instance by id
*
* @param string $id Module Id
* @return \yii\base\Module
* @return Module|object
*/
public function getModule($id)
{
@ -256,7 +257,8 @@ class ModuleManager extends Component
/**
* Checks the module can removed
*
* @param type $moduleId
* @param string $moduleId
* @return bool
*/
public function canRemoveModule($moduleId)
{
@ -277,7 +279,10 @@ class ModuleManager extends Component
/**
* Removes a module
*
* @param strng $id the module id
* @param string $moduleId
* @param bool $disableBeforeRemove
* @throws Exception
* @throws \yii\base\ErrorException
*/
public function removeModule($moduleId, $disableBeforeRemove = true)
{
@ -358,6 +363,7 @@ class ModuleManager extends Component
unset($this->enabledModules[$key]);
}
// TODO setModule expected Module|array|null instead string 'null'
Yii::$app->setModule($module->id, 'null');
}

View File

@ -12,7 +12,7 @@ use Yii;
use yii\base\BootstrapInterface;
/**
* ModuleAutoLoader automatically searches for autostart.php files in module folder an executes them.
* ModuleAutoLoader automatically searches for config.php files in module folder an executes them.
*
* @author luke
*/

View File

@ -107,7 +107,7 @@ class ExportResult extends BaseObject
public function delete()
{
if (!empty($this->tempFileName) && is_writable($this->tempFileName)) {
unlink($this->tempFileName);
FileHelper::unlink($this->tempFileName);
return true;
}
return false;

View File

@ -39,4 +39,5 @@ HumHub Change Log - v1.3-dev Branch
- Fix: Birthday field refactoring (@danielkesselberg)
- Enh #2811: Added option to resend invites (@danielkesselberg)
- Enh: Added current database name to the "Administration -> Information -> Database" (githubjeka)
- Chg: Depreciated Instagram OAuthClient & removed (@Felli)
- Enh/Fix: Cache Handling + File Preview Fix (@Felli)

View File

@ -44,13 +44,14 @@ class DynamicConfig extends BaseObject
self::save([]);
}
// Load config file with file_get_contents and eval, cause require don't reload
// the file when it's changed on runtime
// Load config file with 'file_get_contents' and 'eval'
// because 'require' don't reload the file when it's changed on runtime
$configContent = str_replace(['<' . '?php', '<' . '?', '?' . '>'], '', file_get_contents($configFile));
$config = eval($configContent);
if (!is_array($config))
if (!is_array($config)) {
return [];
}
return $config;
}
@ -121,7 +122,7 @@ class DynamicConfig extends BaseObject
} elseif ($cacheClass === \yii\redis\Cache::class) {
$config['components']['cache'] = [
'class' => \yii\redis\Cache::class,
'keyPrefix' => Yii::$app->id,
'keyPrefix' => Yii::$app->id
];
}
@ -143,7 +144,7 @@ class DynamicConfig extends BaseObject
if (Yii::$app->settings->get('mailer.username')) {
$mail['transport']['username'] = Yii::$app->settings->get('mailer.username');
} else if (!Yii::$app->settings->get('mailer.password')) {
} elseif (!Yii::$app->settings->get('mailer.password')) {
$mail['transport']['authMode'] = 'null';
}
@ -158,13 +159,6 @@ class DynamicConfig extends BaseObject
if (Yii::$app->settings->get('mailer.port')) {
$mail['transport']['port'] = Yii::$app->settings->get('mailer.port');
}
/*
if (Yii::$app->settings->get('mailer.allowSelfSignedCerts')) {
$mail['transport']['ssl']['allow_self_signed'] = true;
$mail['transport']['ssl']['verify_peer'] = false;
}
*/
} elseif (Yii::$app->settings->get('mailer.transportType') == 'php') {
$mail['transport']['class'] = 'Swift_MailTransport';
} else {

View File

@ -28,7 +28,7 @@ class LogoImage
/**
* @var String folder name inside the uploads directory
*/
protected $folder_images = "logo_image";
protected $folder_images = 'logo_image';
/**
* Returns the URl of Logo Image
@ -72,9 +72,7 @@ class LogoImage
public function getPath()
{
$path = Yii::getAlias('@webroot') . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->folder_images . DIRECTORY_SEPARATOR;
FileHelper::createDirectory($path);
$path .= 'logo.png';
return $path;
@ -94,7 +92,7 @@ class LogoImage
'height' => $this->height,
'width' => 0,
'mode' => 'max',
'transparent' => ($file->getExtension() == 'png' && ImageConverter::checkTransparent($this->getPath()))
'transparent' => ($file->getExtension() === 'png' && ImageConverter::checkTransparent($this->getPath()))
]);
}
@ -103,7 +101,7 @@ class LogoImage
*/
public function delete()
{
@unlink($this->getPath());
FileHelper::unlink($this->getPath());
}
}

View File

@ -9,6 +9,7 @@
namespace humhub\libs;
use humhub\modules\file\libs\ImageConverter;
use yii\helpers\FileHelper;
/**
* ProfileBannerImage is responsible for the profile banner images.
@ -29,7 +30,7 @@ class ProfileBannerImage extends ProfileImage
/**
* @var String is the guid of user or space
*/
protected $guid = "";
protected $guid = '';
/**
* @var Integer width of the Image
@ -44,7 +45,7 @@ class ProfileBannerImage extends ProfileImage
/**
* @var String folder name inside the uploads directory
*/
protected $folder_images = "profile_image/banner";
protected $folder_images = 'profile_image/banner';
/**
* @var String name of the default image
@ -73,8 +74,8 @@ class ProfileBannerImage extends ProfileImage
{
$this->delete();
ImageConverter::TransformToJpeg($file->tempName, $this->getPath('_org'));
ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 1134, 'mode' => 'max'));
ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), ['width' => 1134, 'mode' => 'max']);
ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), ['width' => $this->width, 'height' => $this->height]);
}
/**
@ -82,8 +83,8 @@ class ProfileBannerImage extends ProfileImage
*/
public function delete()
{
@unlink($this->getPath());
@unlink($this->getPath('_org'));
FileHelper::unlink($this->getPath());
FileHelper::unlink($this->getPath('_org'));
}
}

View File

@ -139,7 +139,7 @@ class ProfileImage
return false;
}
@unlink($this->getPath(''));
FileHelper::unlink($this->getPath(''));
imagejpeg($destImage, $this->getPath(''), 100);
}
@ -165,8 +165,8 @@ class ProfileImage
*/
public function delete()
{
@unlink($this->getPath());
@unlink($this->getPath('_org'));
FileHelper::unlink($this->getPath());
FileHelper::unlink($this->getPath('_org'));
}
}

View File

@ -8,10 +8,11 @@
namespace humhub\models;
use Yii;
use yii\base\InvalidParamException;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\db\ActiveRecord;
use Yii;
/**
* This is the model class for table "url_oembed".
@ -19,7 +20,7 @@ use yii\helpers\Json;
* @property string $url
* @property string $preview
*/
class UrlOembed extends \yii\db\ActiveRecord
class UrlOembed extends ActiveRecord
{
/**
@ -66,7 +67,7 @@ class UrlOembed extends \yii\db\ActiveRecord
$url = trim($url);
// Check if the given URL has OEmbed Support
if (UrlOembed::HasOEmbedSupport($url)) {
if (UrlOembed::hasOEmbedSupport($url)) {
// Lookup Cached OEmebed Item from Database
$urlOembed = UrlOembed::findOne(['url' => $url]);
@ -110,12 +111,12 @@ class UrlOembed extends \yii\db\ActiveRecord
{
$urlOembed = new UrlOembed();
$urlOembed->url = $url;
$html = "";
$html = '';
if ($urlOembed->getProviderUrl() != "") {
if ($urlOembed->getProviderUrl() != '') {
// Build OEmbed Preview
$jsonOut = UrlOembed::fetchUrl($urlOembed->getProviderUrl());
if ($jsonOut != "" && $jsonOut != "Unauthorized") {
if ($jsonOut != '' && $jsonOut != 'Unauthorized') {
try {
$data = Json::decode($jsonOut);
if (isset($data['html']) && isset($data['type']) && ($data['type'] === "video" || $data['type'] === 'rich' || $data['type'] === 'photo')) {
@ -127,7 +128,7 @@ class UrlOembed extends \yii\db\ActiveRecord
}
}
if ($html != "") {
if ($html != '') {
$urlOembed->preview = $html;
$urlOembed->save();
}
@ -145,7 +146,7 @@ class UrlOembed extends \yii\db\ActiveRecord
return str_replace("%url%", urlencode($this->url), $providerAPI);
}
}
return "";
return '';
}
/**
@ -155,7 +156,7 @@ class UrlOembed extends \yii\db\ActiveRecord
*
* @return boolean
*/
public static function HasOEmbedSupport($url)
public static function hasOEmbedSupport($url)
{
foreach (UrlOembed::getProviders() as $providerBaseUrl => $providerAPI) {
if (strpos($url, $providerBaseUrl) !== false) {
@ -179,9 +180,11 @@ class UrlOembed extends \yii\db\ActiveRecord
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
// Not available when open_basedir is set.
@curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
// Not available when open_basedir or safe_mode is set.
if (!function_exists('ini_get') || !ini_get('open_basedir')) || !ini_get('safe_mode')) {
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
}
if (Yii::$app->settings->get('proxy.enabled')) {
curl_setopt($curl, CURLOPT_PROXY, Yii::$app->settings->get('proxy.server'));
curl_setopt($curl, CURLOPT_PROXYPORT, Yii::$app->settings->get('proxy.port'));
@ -211,7 +214,7 @@ class UrlOembed extends \yii\db\ActiveRecord
public static function getProviders()
{
$providers = Yii::$app->settings->get('oembedProviders');
if ($providers != "") {
if ($providers != '') {
return Json::decode($providers);
}

View File

@ -8,16 +8,18 @@
namespace humhub\modules\content;
use Yii;
use humhub\modules\content\models\Content;
use humhub\modules\user\events\UserEvent;
use humhub\modules\search\interfaces\Searchable;
use Yii;
use yii\base\BaseObject;
/**
* Events provides callbacks to handle events.
*
* @author luke
*/
class Events extends \yii\base\BaseObject
class Events extends BaseObject
{
/**
@ -68,15 +70,15 @@ class Events extends \yii\base\BaseObject
{
$integrityController = $event->sender;
$integrityController->showTestHeadline("Content Objects (" . Content::find()->count() . " entries)");
$integrityController->showTestHeadline('Content Objects (' . Content::find()->count() . ' entries)');
foreach (Content::find()->each() as $content) {
if ($content->user == null) {
if ($integrityController->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid user!")) {
if ($integrityController->showFix('Deleting content id ' . $content->id . ' of type ' . $content->object_model . ' without valid user!')) {
$content->delete();
}
}
if ($content->getPolymorphicRelation() == null) {
if ($integrityController->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid content object!")) {
if ($content->getPolymorphicRelation() === null) {
if ($integrityController->showFix('Deleting content id ' . $content->id . ' of type ' . $content->object_model . ' without valid content object!')) {
$content->delete();
}
}
@ -90,11 +92,11 @@ class Events extends \yii\base\BaseObject
*/
public static function onWallEntryAddonInit($event)
{
$event->sender->addWidget(widgets\WallEntryLinks::className(), array(
$event->sender->addWidget(widgets\WallEntryLinks::className(), [
'object' => $event->sender->object,
'seperator' => "&nbsp;&middot;&nbsp;",
'seperator' => '&nbsp;&middot;&nbsp;',
'template' => '<div class="wall-entry-controls">{content}</div>',
), array('sortOrder' => 10)
], ['sortOrder' => 10]
);
}
@ -107,7 +109,7 @@ class Events extends \yii\base\BaseObject
{
foreach (Content::find()->each() as $content) {
$contentObject = $content->getPolymorphicRelation();
if ($contentObject instanceof \humhub\modules\search\interfaces\Searchable) {
if ($contentObject instanceof Searchable) {
Yii::$app->search->add($contentObject);
}
}
@ -120,7 +122,7 @@ class Events extends \yii\base\BaseObject
*/
public static function onContentActiveRecordSave($event)
{
if ($event->sender instanceof \humhub\modules\search\interfaces\Searchable) {
if ($event->sender instanceof Searchable) {
Yii::$app->search->update($event->sender);
}
}
@ -132,7 +134,7 @@ class Events extends \yii\base\BaseObject
*/
public static function onContentActiveRecordDelete($event)
{
if ($event->sender instanceof \humhub\modules\search\interfaces\Searchable) {
if ($event->sender instanceof Searchable) {
Yii::$app->search->delete($event->sender);
}
}

View File

@ -17,7 +17,6 @@ use humhub\libs\ProfileImage;
use humhub\modules\user\models\User;
use humhub\modules\content\models\Content;
use humhub\modules\content\models\ContentContainer;
use humhub\modules\content\components\ContentContainerModuleManager;
/**
* ContentContainerActiveRecord for ContentContainer Models e.g. Space or User.
@ -44,13 +43,13 @@ abstract class ContentContainerActiveRecord extends ActiveRecord
protected $permissionManager = null;
/**
* @var ModuleManager
* @var ContentContainerModuleManager
*/
protected $moduleManager = null;
/**
* The behavior which will be attached to the base controller.
*
*
* @since 1.3
* @see \humhub\modules\contentcontainer\components\Controller
* @var string class name of additional the controller behavior
@ -209,9 +208,9 @@ abstract class ContentContainerActiveRecord extends ActiveRecord
* ```php
* $contentContainer->can(MyPermisison::class);
* ```
*
*
* Note: This method is used to verify ContentContainerPermissions and not GroupPermissions.
*
*
* @param string|string[]|BasePermission $permission
* @see PermissionManager::can()
* @return boolean
@ -285,7 +284,7 @@ abstract class ContentContainerActiveRecord extends ActiveRecord
/**
* Returns weather or not the contentcontainer is archived. (Default false).
* @return boolean
* @return boolean
* @since 1.2
*/
public function isArchived()

View File

@ -18,25 +18,25 @@ use humhub\modules\content\components\ContentContainerControllerAccess;
/**
* Controller is the base class of web controllers which acts in scope of a ContentContainer (e.g. Space or User).
*
*
* To automatically load the current contentcontainer the containers guid must be passed as GET parameter 'cguid'.
* You can create URLs in the scope of an ContentContainer by passing the contentContainer instance as 'container' or 'contentContainer'
* as parameter to the URLManager.
*
*
* Example:
*
*
* ```
* $url = Url::to(['my/action', 'container' => $this->contentContainer');
* ```
*
*
* Based on the current ContentContainer a behavior (defined in ContentContainerActiveRecord::controllerBehavior) will be automatically
* attached to this controller instance.
* The attached behavior will perform basic access checks, adds the container sublayout and perform other tasks
* The attached behavior will perform basic access checks, adds the container sublayout and perform other tasks
* (e.g. the space behavior will update the last visit membership attribute).
*
* @see \humhub\modules\space\behaviors\SpaceController
* @see \humhub\modules\user\behaviors\ProfileController
*
* @mixin \humhub\modules\space\behaviors\SpaceController
* @mixin \humhub\modules\user\behaviors\ProfileController
*/
class ContentContainerController extends Controller
{
@ -44,8 +44,8 @@ class ContentContainerController extends Controller
/**
* Specifies if a contentContainer (e.g. Space or User) is required to run this controller.
* Set this to false, if your controller should also act on global scope.
*
* @var boolean require cguid container parameter
*
* @var boolean require cguid container parameter
*/
public $requireContainer = true;
@ -56,7 +56,7 @@ class ContentContainerController extends Controller
/**
* Limit this controller only for usage on given contentcontainer types (e.g. Space).
*
*
* @since 1.3
* @var array|null an array of valid content container classes. if null all container types (User & Space) are allowed.
*/
@ -123,7 +123,7 @@ class ContentContainerController extends Controller
/**
* Checks if the requested module is available in this contentContainer.
*
*
* @throws HttpException if the module is not enabled
*/
protected function checkModuleIsEnabled()

View File

@ -10,14 +10,12 @@ namespace humhub\modules\content\components;
use ReflectionClass;
use Yii;
use yii\db\ActiveQuery;
use humhub\modules\content\components\ContentContainerModule;
use humhub\modules\content\models\ContentContainerModuleState;
use humhub\modules\content\models\ContentContainer;
/**
* ModuleManager handles modules of a content container.
*
*
* @since 1.3
* @author Luke
*/
@ -36,7 +34,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Disables a module for the content container
*
*
* @param string $id the module id
* @return boolean
*/
@ -56,8 +54,8 @@ class ContentContainerModuleManager extends \yii\base\Component
}
/**
* Enables a module for this content container
*
* Enables a module for this content container
*
* @param string $id the module id
* @return boolean
*/
@ -78,9 +76,9 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Checks whether the module is activated or not
*
*
* @param string $id the module id
* @return boolean
* @return boolean
*/
public function isEnabled($id)
{
@ -89,7 +87,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Checks whether the module can be enabled or not
*
*
* @param string $id the module id
* @return boolean
*/
@ -105,7 +103,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Checks whether the module can be disabled or not
*
*
* @param string $id the module id
* @return boolean
*/
@ -120,7 +118,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Returns an array of all enabled module ids
*
*
* @return array a list of enabled module ids
*/
public function getEnabled()
@ -138,7 +136,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Returns an array of all available modules
*
*
* @return ContentContainerModule[] a list of modules
*/
public function getAvailable()
@ -161,7 +159,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Returns an array of all module states.
*
*
* @see Module
* @return array a list of modules with the corresponding state
*/
@ -186,7 +184,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Sets the default state for a module based on the contentcontainer class
*
*
* @param string $class the class name (e.g. Space or User)
* @param string $id the module id
* @param int $state the state
@ -199,7 +197,7 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Returns the default module state for a given contentcontainer class
*
*
* @param string $class the class name (e.g. Space or User)
* @param string $id the module id
* @return int|null the default state or null when no default state is defined
@ -218,10 +216,10 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Returns an Module record instance for the given module id
*
*
* @see Module
* @param string $id the module id
* @return Module the Module record instance
* @return ContentContainerModuleState
*/
protected function getModuleStateRecord($id)
{
@ -237,9 +235,9 @@ class ContentContainerModuleManager extends \yii\base\Component
/**
* Returns a query for \humhub\modules\content\models\ContentContainer where the given module is enabled.
*
*
* @param string $id the module mid
* @return \yii\db\ActiveQuerythe list of content container
* @return \yii\db\ActiveQuery the list of content container
*/
public static function getContentContainerQueryByModule($id)
{

View File

@ -1,5 +1,4 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
@ -11,18 +10,19 @@ namespace humhub\modules\content\components\behaviors;
use yii\base\Behavior;
/**
* Compatiblity layer for old ContentContainer ModuleManager calls.
*
* @see \humhub\modules\contentcontainer\components\ModuleManager
* Compatibility layer for old ContentContainer ModuleManager calls.
*
* @see \humhub\modules\content\components\ContentContainerModuleManager
* @see \humhub\modules\content\components\ContentContainerActiveRecord
* @since 1.3
* @author luke
*
* @property \humhub\modules\content\components\ContentContainerActiveRecord $owner
*/
class CompatModuleManager extends Behavior
{
/**
* @var \humhub\modules\contentcontainer\components\ModuleManager
* @var \humhub\modules\content\components\ContentContainerModuleManager
*/
public $moduleManager;
@ -61,5 +61,4 @@ class CompatModuleManager extends Behavior
{
return $this->moduleManager->disable($moduleId);
}
}

View File

@ -14,6 +14,7 @@ use humhub\modules\file\libs\FileHelper;
use Yii;
use yii\base\Component;
use yii\web\UploadedFile;
use yii\helpers\FileHelper;
/**
* StorageManager for File records
@ -85,7 +86,7 @@ class StorageManager extends Component implements StorageManagerInterface
* For uploaded jpeg files convert them again - to handle special
* exif attributes (e.g. orientation)
*/
if ($file->type == 'image/jpeg') {
if ($file->type === 'image/jpeg') {
ImageConverter::TransformToJpeg($this->get($variant), $this->get($variant));
}
}
@ -112,13 +113,13 @@ class StorageManager extends Component implements StorageManagerInterface
$files = glob($path . DIRECTORY_SEPARATOR . '*');
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
FileHelper::unlink($file);
}
}
FileHelper::removeDirectory($path);
}
} elseif (is_file($this->get($variant))) {
unlink($this->get($variant));
FileHelper::unlink($this->get($variant));
}
}

View File

@ -129,7 +129,7 @@ class ZendLuceneSearch extends Search
foreach (new \DirectoryIterator($indexPath) as $fileInfo) {
if ($fileInfo->isDot())
continue;
unlink($indexPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename());
FileHelper::unlink($indexPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename());
}
$this->index = null;

View File

@ -19,9 +19,9 @@ use humhub\components\Controller;
/**
* SpaceController Behavior
*
*
* In Space scopes, this behavior will automatically attached to a contentcontainer controller.
*
*
* @see Space::controllerBehavior
* @see \humhub\modules\contentcontainer\components\Controller
* @property \humhub\modules\contentcontainer\components\Controller $owner the controller
@ -30,7 +30,7 @@ class SpaceController extends Behavior
{
/**
* @var humhub\modules\space\models\Space
* @var \humhub\modules\space\models\Space
*/
public $space;
@ -112,5 +112,3 @@ class SpaceController extends Behavior
}
}
?>

View File

@ -40,6 +40,12 @@ use humhub\modules\user\models\Group;
* @property integer $default_content_visibility
* @property string $color
* @property User $ownerUser the owner of this space
*
* @mixin \humhub\components\behaviors\GUID
* @mixin \humhub\modules\content\components\behaviors\SettingsBehavior
* @mixin \humhub\modules\space\behaviors\SpaceModelMembership
* @mixin \humhub\modules\user\behaviors\Followable
* @mixin \humhub\modules\content\components\behaviors\CompatModuleManager
*/
class Space extends ContentContainerActiveRecord implements \humhub\modules\search\interfaces\Searchable
{

View File

@ -18,7 +18,6 @@ use humhub\modules\space\modules\manage\components\Controller;
*/
class ModuleController extends Controller
{
/**
* Modules Administration Action
*/
@ -31,7 +30,7 @@ class ModuleController extends Controller
/**
* Enables a space module
*
* @return string the output
* @return string|array the output
*/
public function actionEnable()
{
@ -57,7 +56,7 @@ class ModuleController extends Controller
/**
* Disables a space module
*
* @return string the output
* @return string|array the output
*/
public function actionDisable()
{
@ -81,5 +80,3 @@ class ModuleController extends Controller
}
}
?>

View File

@ -1,15 +1,13 @@
<?php
use humhub\widgets\ModalDialog;
use humhub\modules\user\widgets\UserPickerField;
use yii\bootstrap\ActiveForm;
?>
<?php $modal = \humhub\widgets\ModalDialog::begin([
$modal = ModalDialog::begin([
'header' => Yii::t('SpaceModule.views_space_invite', '<strong>Invite</strong> members')
])?>
]);
<?php
$modalAnimationClass = ($model->hasErrors()) ? 'shake' : 'fadeIn';
if ($canInviteExternal && $model->hasErrors('inviteExternal')) {
@ -19,9 +17,12 @@ if ($canInviteExternal && $model->hasErrors('inviteExternal')) {
$isInviteExternalTabActiveClass = '';
$isInviteTabActiveClass = 'active';
}
?>
<?php $form = ActiveForm::begin(['id' => 'space-invite-modal-form', 'action' => $submitAction]) ?>
$form = ActiveForm::begin([
'id' => 'space-invite-modal-form',
'action' => $submitAction
]);
?>
<div class="modal-body">
<?php if ($canInviteExternal) : ?>
<div class="text-center">
@ -42,8 +43,8 @@ if ($canInviteExternal && $model->hasErrors('inviteExternal')) {
<?= Yii::t('SpaceModule.views_space_invite', 'To invite users to this space, please type their names below to find and pick them.'); ?>
<br/><br/>
<?= \humhub\modules\user\widgets\UserPickerField::widget([
<br><br>
<?= UserPickerField::widget([
'id' => 'space-invite-user-picker',
'form' => $form,
'model' => $model,
@ -51,7 +52,8 @@ if ($canInviteExternal && $model->hasErrors('inviteExternal')) {
'url' => $searchUrl,
'disabledItems' => [Yii::$app->user->guid],
'focus' => true
])?>
]);
?>
</div>
@ -62,6 +64,7 @@ if ($canInviteExternal && $model->hasErrors('inviteExternal')) {
<?= $form->field($model, 'inviteExternal')->textarea(['id' => 'space-invite-external', 'rows' => '3', 'placeholder' => Yii::t('SpaceModule.views_space_invite', 'Email addresses')]); ?>
</div>
<?php endif; ?>
<script>
$('.tab-internal a').on('shown.bs.tab', function (e) {
$('#space-invite-user-picker').data('picker').focus();
@ -71,11 +74,12 @@ if ($canInviteExternal && $model->hasErrors('inviteExternal')) {
$('#space-invite-external').focus();
});
</script>
</div>
</div>
<div class="modal-footer">
<a href="#" data-action-click="ui.modal.submit" data-action-submit class="btn btn-primary" data-ui-loader><?= $submitText ?></a>
<a href="#" data-action-click="ui.modal.submit" data-action-submit class="btn btn-primary" data-ui-loader><?= $submitText ?></a>
</div>
<?php ActiveForm::end() ?>
<?php \humhub\widgets\ModalDialog::end(); ?>
<?php ModalDialog::end(); ?>

View File

@ -1,12 +1,15 @@
<?php
/* @var $this \humhub\components\WebView */
/* @var $currentSpace \humhub\modules\space\models\Space */
use humhub\modules\space\assets\SpaceChooserAsset;
use humhub\modules\space\widgets\SpaceChooserItem;
use humhub\modules\space\widgets\Image;
use yii\helpers\Url;
use yii\helpers\Html;
use humhub\modules\space\widgets\SpaceChooserItem;
\humhub\modules\space\assets\SpaceChooserAsset::register($this);
SpaceChooserAsset::register($this);
$noSpaceView = '<div class="no-space"><i class="fa fa-dot-circle-o"></i><br>' . Yii::t('SpaceModule.widgets_views_spaceChooser', 'My spaces') . '<b class="caret"></b></div>';
@ -25,13 +28,13 @@ $this->registerJsConfig('space.chooser', [
<a href="#" id="space-menu" class="dropdown-toggle" data-toggle="dropdown">
<!-- start: Show space image and name if chosen -->
<?php if ($currentSpace) : ?>
<?=
\humhub\modules\space\widgets\Image::widget([
<?= Image::widget([
'space' => $currentSpace,
'width' => 32,
'htmlOptions' => [
'class' => 'current-space-image',
]]);
]
]);
?>
<b class="caret"></b>
<?php endif; ?>
@ -40,8 +43,8 @@ $this->registerJsConfig('space.chooser', [
<?= $noSpaceView ?>
<?php endif; ?>
<!-- end: Show space image and name if chosen -->
</a>
<ul class="dropdown-menu" id="space-menu-dropdown">
<li>
<form action="" class="dropdown-controls">
@ -51,7 +54,7 @@ $this->registerJsConfig('space.chooser', [
title="<?= Yii::t('SpaceModule.widgets_views_spaceChooser', 'Search for spaces'); ?>">
<span id="space-directory-link" class="input-group-addon" >
<a href="<?= Url::to(['/directory/directory/spaces']); ?>">
<i class="fa fa-book"></i>
<i class="fa fa-book"></i>
</a>
</span>
<div class="search-reset" id="space-search-reset"><i class="fa fa-times-circle"></i></div>
@ -62,11 +65,20 @@ $this->registerJsConfig('space.chooser', [
<li class="divider"></li>
<li>
<ul class="media-list notLoaded" id="space-menu-spaces">
<?php foreach ($memberships as $membership): ?>
<?= SpaceChooserItem::widget(['space' => $membership->space, 'updateCount' => $membership->countNewItems(), 'isMember' => true]); ?>
<?php foreach ($memberships as $membership) : ?>
<?= SpaceChooserItem::widget([
'space' => $membership->space,
'updateCount' => $membership->countNewItems(),
'isMember' => true
]);
?>
<?php endforeach; ?>
<?php foreach ($followSpaces as $followSpace): ?>
<?= SpaceChooserItem::widget(['space' => $followSpace, 'isFollowing' => true]); ?>
<?php foreach ($followSpaces as $followSpace) : ?>
<?= SpaceChooserItem::widget([
'space' => $followSpace,
'isFollowing' => true
]);
?>
<?php endforeach; ?>
</ul>
</li>
@ -74,7 +86,7 @@ $this->registerJsConfig('space.chooser', [
<ul id="space-menu-remote-search" class="media-list notLoaded"></ul>
</li>
<?php if ($canCreateSpace): ?>
<?php if ($canCreateSpace) : ?>
<li>
<div class="dropdown-footer">
<a href="#" class="btn btn-info col-md-12" data-action-click="ui.modal.load" data-action-url="<?= Url::to(['/space/create/create']) ?>">

View File

@ -1,69 +0,0 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\user\authclient;
use yii\authclient\OAuth2;
class Instagram extends OAuth2
{
/**
* @inheritdoc
*/
protected function defaultViewOptions()
{
return [
'popupWidth' => 860,
'popupHeight' => 480,
'cssIcon' => 'fa fa-instagram',
'buttonBackgroundColor' => '#395697',
];
}
/**
* @inheritdoc
*/
public $authUrl = 'https://api.instagram.com/oauth/authorize';
/**
* @inheritdoc
*/
public $tokenUrl = 'https://api.instagram.com/oauth/access_token';
/**
* @inheritdoc
*/
public $apiBaseUrl = 'https://api.instagram.com/v1';
/**
* @inheritdoc
*/
protected function initUserAttributes()
{
$response = $this->api('users/self', 'GET');
return $response['data'];
}
/**
* @inheritdoc
*/
protected function apiInternal($accessToken, $url, $method, array $params, array $headers)
{
return $this->sendRequest($method, $url . '?access_token=' . $accessToken->getToken(), $params, $headers);
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'instagram';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Instagram';
}
}