mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Merge remote-tracking branch 'origin/master'
Conflicts: protected/modules_core/admin/views/logging/index.php protected/modules_core/admin/views/module/list.php protected/modules_core/comment/widgets/views/showComment.php protected/modules_core/dashboard/DashboardModule.php protected/modules_core/directory/DirectoryModule.php protected/modules_core/space/views/admin/modules.php
This commit is contained in:
commit
45169f4861
@ -26,11 +26,13 @@ Yii::import('application.extensions.migrate-command.EMigrateCommand');
|
||||
* @package humhub.commands
|
||||
* @since 0.5
|
||||
*/
|
||||
class ZMigrateCommand extends EMigrateCommand {
|
||||
class ZMigrateCommand extends EMigrateCommand
|
||||
{
|
||||
|
||||
public $migrationTable = 'migration';
|
||||
|
||||
public static function AutoMigrate() {
|
||||
public static function AutoMigrate()
|
||||
{
|
||||
|
||||
|
||||
/** $commandPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'commands';
|
||||
@ -52,7 +54,8 @@ class ZMigrateCommand extends EMigrateCommand {
|
||||
return htmlentities(ob_get_clean(), null, Yii::app()->charset);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
print "Flushing Caches....\n";
|
||||
Yii::app()->cache->flush();
|
||||
@ -60,11 +63,14 @@ class ZMigrateCommand extends EMigrateCommand {
|
||||
|
||||
print "Autodetecting Modules....\n";
|
||||
|
||||
|
||||
|
||||
|
||||
$modulePaths = array();
|
||||
foreach (Yii::app()->moduleManager->getRegisteredModules() as $moduleId => $moduleInfo) {
|
||||
foreach (Yii::app()->moduleManager->getInstalledModules(true, true) as $moduleId => $classAlias) {
|
||||
|
||||
// Convert path.to.example.ExampleModule to path.to.example.migrations
|
||||
$path = explode(".", $moduleInfo['class']);
|
||||
$path = explode(".", $classAlias);
|
||||
array_pop($path);
|
||||
$path[] = $this->migrationSubPath;
|
||||
$migrationPath = implode(".", $path);
|
||||
@ -77,7 +83,8 @@ class ZMigrateCommand extends EMigrateCommand {
|
||||
$this->modulePaths = $modulePaths;
|
||||
}
|
||||
|
||||
protected function instantiateMigration($class) {
|
||||
protected function instantiateMigration($class)
|
||||
{
|
||||
|
||||
$migration = new $class;
|
||||
$migration->setDbConnection($this->getDbConnection());
|
||||
@ -88,7 +95,8 @@ class ZMigrateCommand extends EMigrateCommand {
|
||||
return $migration;
|
||||
}
|
||||
|
||||
public function run($args) {
|
||||
public function run($args)
|
||||
{
|
||||
|
||||
$exitCode = parent::run($args);
|
||||
|
||||
@ -96,7 +104,8 @@ class ZMigrateCommand extends EMigrateCommand {
|
||||
ModuleManager::flushCache();
|
||||
}
|
||||
|
||||
protected function getTemplate() {
|
||||
protected function getTemplate()
|
||||
{
|
||||
if ($this->templateFile !== null) {
|
||||
return parent::getTemplate();
|
||||
} else {
|
||||
|
@ -21,7 +21,7 @@
|
||||
/**
|
||||
* HActiveRecordContent is the base AR for all content models.
|
||||
*
|
||||
* Each model which represents a content should derived from it.
|
||||
* Each model which represents a piece of content should derived from it.
|
||||
* (e.g. Post, Question, Task, Note, ...)
|
||||
*
|
||||
* It automatically binds a Content model to each instance.
|
||||
@ -33,14 +33,15 @@
|
||||
* - ...
|
||||
* (See Content Model for more details.)
|
||||
*
|
||||
* Note: Comments, Likes or Files are NOT Content Objects. These objects are
|
||||
* ContentAddons which always belongs to one Content Object.
|
||||
* Note: Comments, Likes or Files are NOT Content Objects.
|
||||
* These objects are ContentAddons which always belongs to one Content Object.
|
||||
*
|
||||
* @author Lucas Bartholemy <lucas@bartholemy.com>
|
||||
* @package humhub.components
|
||||
* @since 0.5
|
||||
*/
|
||||
class HActiveRecordContent extends HActiveRecord {
|
||||
class HActiveRecordContent extends HActiveRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* Should this content automatically added to the wall.
|
||||
@ -56,7 +57,8 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
*/
|
||||
public $content = null;
|
||||
|
||||
public function __construct($scenario = 'insert') {
|
||||
public function __construct($scenario = 'insert')
|
||||
{
|
||||
$this->content = new Content($scenario);
|
||||
parent::__construct($scenario);
|
||||
}
|
||||
@ -69,7 +71,8 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getContentTitle() {
|
||||
public function getContentTitle()
|
||||
{
|
||||
$objectModel = get_class($this); // e.g. Post
|
||||
return $objectModel . " (" . $this->id . ")";
|
||||
}
|
||||
@ -86,21 +89,25 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getWallOut() {
|
||||
public function getWallOut()
|
||||
{
|
||||
return "Default Wall Output for Class " . get_class($this);
|
||||
}
|
||||
|
||||
public function afterFind() {
|
||||
public function afterFind()
|
||||
{
|
||||
$this->content = Content::model()->findByAttributes(array('object_model' => get_class($this), 'object_id' => $this->getPrimaryKey()));
|
||||
parent::afterFind();
|
||||
}
|
||||
|
||||
public function afterDelete() {
|
||||
public function afterDelete()
|
||||
{
|
||||
$this->content->delete();
|
||||
parent::afterDelete();
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
public function afterSave()
|
||||
{
|
||||
|
||||
if ($this->isNewRecord) {
|
||||
$this->content->user_id = $this->created_by;
|
||||
@ -130,11 +137,13 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeValidate() {
|
||||
public function beforeValidate()
|
||||
{
|
||||
return parent::beforeValidate();
|
||||
}
|
||||
|
||||
public function afterValidate() {
|
||||
public function afterValidate()
|
||||
{
|
||||
if (!$this->content->validate())
|
||||
return false;
|
||||
|
||||
@ -145,7 +154,8 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getErrors($attribute = null) {
|
||||
public function getErrors($attribute = null)
|
||||
{
|
||||
if ($attribute != null) {
|
||||
return parent::getErrors($attribute);
|
||||
}
|
||||
@ -153,14 +163,16 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
return CMap::mergeArray(parent::getErrors(), $this->content->getErrors());
|
||||
}
|
||||
|
||||
public function validate($attributes = null, $clearErrors = true) {
|
||||
public function validate($attributes = null, $clearErrors = true)
|
||||
{
|
||||
if (parent::validate($attributes, $clearErrors) && $this->content->validate($attributes, $clearErrors))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasErrors($attribute = null) {
|
||||
public function hasErrors($attribute = null)
|
||||
{
|
||||
if ($attribute != null)
|
||||
return parent::hasErrors($attribute);
|
||||
|
||||
@ -172,7 +184,8 @@ class HActiveRecordContent extends HActiveRecord {
|
||||
*
|
||||
* @param HActiveRecordContentContainer $container
|
||||
*/
|
||||
public function contentContainer($container) {
|
||||
public function contentContainer($container)
|
||||
{
|
||||
|
||||
$criteria = new CDbCriteria();
|
||||
$criteria->join = "LEFT JOIN content ON content.object_model='" . get_class($this) . "' AND content.object_id=t." . $this->tableSchema->primaryKey;
|
||||
|
248
protected/components/HWebModule.php
Normal file
248
protected/components/HWebModule.php
Normal file
@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HumHub
|
||||
* Copyright © 2014 The HumHub Project
|
||||
*
|
||||
* The texts of the GNU Affero General Public License with an additional
|
||||
* permission and of our proprietary license can be found at and
|
||||
* in the LICENSE file you have received along with this program.
|
||||
*
|
||||
* According to our dual licensing model, this program can be used either
|
||||
* under the terms of the GNU Affero General Public License, version 3,
|
||||
* or under a proprietary license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base Class for Modules / Extensions
|
||||
*
|
||||
* @author luke
|
||||
*/
|
||||
class HWebModule extends CWebModule
|
||||
{
|
||||
|
||||
/**
|
||||
* Loaded Module JSON File
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $_moduleInfo = null;
|
||||
|
||||
public function preinit()
|
||||
{
|
||||
$this->attachBehaviors($this->behaviors());
|
||||
|
||||
parent::preinit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add behaviors to this module
|
||||
*
|
||||
* You may want to enable one of these behavior to alos make this module
|
||||
* available on space and/or user context.
|
||||
*
|
||||
* See related behaviors classes for more details.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return array(
|
||||
/*
|
||||
'SpaceModuleBehavior' => array(
|
||||
'class' => 'application.modules_core.space.SpaceModuleBehavior',
|
||||
),
|
||||
|
||||
'UserModuleBehavior' => array(
|
||||
'class' => 'application.modules_core.user.UserModuleBehavior',
|
||||
),
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns modules name provided by module.json file
|
||||
*
|
||||
* @return string Description
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
$info = $this->getModuleInfo();
|
||||
|
||||
if ($info['name']) {
|
||||
return $info['name'];
|
||||
}
|
||||
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns modules description provided by module.json file
|
||||
*
|
||||
* @return string Description
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
$info = $this->getModuleInfo();
|
||||
|
||||
if ($info['description']) {
|
||||
return $info['description'];
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns modules version number provided by module.json file
|
||||
*
|
||||
* @return string Version Number
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
$info = $this->getModuleInfo();
|
||||
|
||||
if ($info['version']) {
|
||||
return $info['version'];
|
||||
}
|
||||
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns image url for this module
|
||||
*
|
||||
* @return String Image Url
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
return Yii::app()->baseUrl . '/uploads/profile_image/default_module.jpg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns URL of configuration controller for this module.
|
||||
*
|
||||
* You may overwrite this method to provide advanced module configuration
|
||||
* possibilities.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConfigUrl()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this module is enabled or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return Yii::app()->moduleManager->isEnabled($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables this module
|
||||
*/
|
||||
public function enable()
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
|
||||
$moduleEnabled = ModuleEnabled::model()->findByPk($this->getId());
|
||||
if ($moduleEnabled == null) {
|
||||
|
||||
$moduleEnabled = new ModuleEnabled();
|
||||
$moduleEnabled->module_id = $this->getId();
|
||||
$moduleEnabled->save();
|
||||
|
||||
// Auto Migrate (add module database changes)
|
||||
Yii::import('application.commands.shell.ZMigrateCommand');
|
||||
$migrate = ZMigrateCommand::AutoMigrate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @todo also disable it on all spaces/users
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
if ($this->isEnabled()) {
|
||||
$moduleEnabled = ModuleEnabled::model()->findByPk($this->getId());
|
||||
if ($moduleEnabled != null) {
|
||||
$moduleEnabled->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads module.json which contains basic module informations and
|
||||
* returns it as array
|
||||
*
|
||||
* @return Array module.json content
|
||||
*/
|
||||
protected function getModuleInfo()
|
||||
{
|
||||
if ($this->_moduleInfo != null) {
|
||||
return $this->_moduleInfo;
|
||||
}
|
||||
|
||||
$moduleJson = file_get_contents($this->getPath() . DIRECTORY_SEPARATOR . 'module.json');
|
||||
return CJSON::decode($moduleJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Base Path of Module
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
$reflection = new ReflectionClass($this);
|
||||
return dirname($reflection->getFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls a module
|
||||
*
|
||||
* Removes module folder from system.
|
||||
* You may overwrite this method to add more cleanup stuff.
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
|
||||
if ($this->isEnabled()) {
|
||||
$this->disable();
|
||||
}
|
||||
|
||||
$this->removeModuleFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a module
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
print "Install called" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes module folder in case of uninstall or update
|
||||
*/
|
||||
protected function removeModuleFolder()
|
||||
{
|
||||
|
||||
$moduleBackupFolder = Yii::app()->getRuntimePath() . DIRECTORY_SEPARATOR . 'module_backups';
|
||||
if (!is_dir($moduleBackupFolder)) {
|
||||
mkdir($moduleBackupFolder);
|
||||
}
|
||||
|
||||
$backupFolderName = $moduleBackupFolder . DIRECTORY_SEPARATOR . $this->getId() . "_" . time();
|
||||
rename($this->getPath(), $backupFolderName);
|
||||
}
|
||||
|
||||
}
|
@ -19,156 +19,134 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* ModuleManager allows dynamic enabling/disabling of application modules.
|
||||
*
|
||||
* Each module has a autostart.php which can register the module.
|
||||
*
|
||||
* Modules must register with a module definition, which holds all relevant
|
||||
* information about it.
|
||||
*
|
||||
* Module Definition Array:
|
||||
* id => mymodule (also folder name under /modules/...)
|
||||
* title => My Module
|
||||
* icon => cssClass
|
||||
* description => someText (For Admin Manage Modules)
|
||||
* isSpaceModule => true/FALSE (Is a workspace module)
|
||||
* isCoreModule => true/FALSE (Is core module, always enabled)
|
||||
* configRoute => 'mymodule/configure' (Configuration URL for SuperAdmin)
|
||||
*
|
||||
* @todo cache enabled modules - problem module manager started before caching
|
||||
*
|
||||
* @package humhub.components
|
||||
* @since 0.5
|
||||
* Module Manager
|
||||
*
|
||||
* - Starts module autostart files
|
||||
* - Handles enabled modules
|
||||
* - Modules autostarts.php registers to it for events & co
|
||||
*
|
||||
*/
|
||||
class ModuleManager extends CApplicationComponent {
|
||||
class ModuleManager extends CApplicationComponent
|
||||
{
|
||||
|
||||
const AUTOSTART_CACHE_FILE_NAME = "cache_autostart.php";
|
||||
|
||||
/**
|
||||
* @var Array of all registered module definitions
|
||||
* List of all enabled module ids
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
public $registeredModules;
|
||||
private $enabledModules = array();
|
||||
|
||||
/**
|
||||
* @var Array of enabled module ids.
|
||||
* Array of installed modules populated on autostart.php register
|
||||
*
|
||||
* @var Array moduleId => moduleClass
|
||||
*/
|
||||
public $enabledModules;
|
||||
private $installedModules = array();
|
||||
|
||||
/**
|
||||
* @var Array of registered content model classes.
|
||||
* Initializes the module manager
|
||||
*/
|
||||
public $registeredContentModels = array();
|
||||
|
||||
/**
|
||||
* Initializes the application component.
|
||||
* This should also should check which module is enabled
|
||||
*/
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
parent::init();
|
||||
|
||||
if (Yii::app()->params['installed'])
|
||||
$this->loadEnabledModules();
|
||||
if (Yii::app()->params['installed']) {
|
||||
|
||||
// Load all enabled modules
|
||||
$cacheId = "enabledModules";
|
||||
$cacheValue = Yii::app()->cache->get($cacheId);
|
||||
|
||||
if ($cacheValue === false || !is_array($cacheValue)) {
|
||||
|
||||
foreach (ModuleEnabled::model()->findAll() as $em) {
|
||||
$this->enabledModules[] = $em->module_id;
|
||||
}
|
||||
|
||||
Yii::app()->cache->set($cacheId, $this->enabledModules, HSetting::Get('expireTime', 'cache'));
|
||||
} else {
|
||||
$this->enabledModules = $cacheValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Intercept this controller
|
||||
Yii::app()->interceptor->intercept($this);
|
||||
}
|
||||
|
||||
public function start() {
|
||||
|
||||
$this->executeAutoloaders();
|
||||
#print "start";
|
||||
#die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches and executes all module autoloaders.
|
||||
*
|
||||
* The module autoloaders are stored in a file "autostart.php" which can be
|
||||
* placed in the root directory of the module.
|
||||
*
|
||||
* @todo Caching autostarts
|
||||
* @todo Remove rendundant code
|
||||
* Starts module manager which executes all enabled autoloaders
|
||||
*/
|
||||
private function executeAutoloaders() {
|
||||
|
||||
public function start()
|
||||
{
|
||||
$cacheEnabled = (get_class(Yii::app()->cache) != 'CDummyCache');
|
||||
|
||||
$cacheFileName = Yii::app()->getRuntimePath() . DIRECTORY_SEPARATOR . self::AUTOSTART_CACHE_FILE_NAME;
|
||||
|
||||
// Fastlane, when cache enabled and cachefile exists
|
||||
if ($cacheEnabled && file_exists($cacheFileName)) {
|
||||
require_once($cacheFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
$fileNames = array();
|
||||
$autostartFiles = array();
|
||||
|
||||
// Looking up 3rd party modules
|
||||
/*
|
||||
// Recursively collect all module_core autostarts
|
||||
$modulesCorePath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'modules_core';
|
||||
$modules = scandir($modulesCorePath);
|
||||
foreach ($modules as $moduleId) {
|
||||
$autostartFiles[] = $modulesCorePath . DIRECTORY_SEPARATOR . $moduleId . DIRECTORY_SEPARATOR . 'autostart.php';
|
||||
}
|
||||
|
||||
// Collect autostarts of enabled modules
|
||||
$modulesCustomPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'modules';
|
||||
foreach ($this->enabledModules as $moduleId) {
|
||||
$autostartFiles[] = $modulesCustomPath . DIRECTORY_SEPARATOR . $moduleId . DIRECTORY_SEPARATOR . 'autostart.php';
|
||||
}
|
||||
*/
|
||||
|
||||
// Recursively collect all moodules / modules_core autostarts
|
||||
$modulesPaths = array(Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'modules', Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'modules_core');
|
||||
foreach ($modulesPaths as $modulePath) {
|
||||
$modules = scandir($modulePath);
|
||||
foreach ($modules as $moduleId) {
|
||||
$autostartFiles[] = $modulePath . DIRECTORY_SEPARATOR . $moduleId . DIRECTORY_SEPARATOR . 'autostart.php';
|
||||
}
|
||||
}
|
||||
|
||||
// Execute Autoloaders in each modules paths
|
||||
foreach ($modulesPaths as $modulesPath) {
|
||||
// Execute (and cache) found autostarts
|
||||
$cacheFileContent = "";
|
||||
foreach ($autostartFiles as $autoloadFile) {
|
||||
if (is_file($autoloadFile)) {
|
||||
|
||||
// Scan Modules
|
||||
$modules = scandir($modulesPath);
|
||||
foreach ($modules as $module) {
|
||||
if ($module == '.' || $module == '..')
|
||||
continue;
|
||||
require_once($autoloadFile);
|
||||
|
||||
$moduleDir = $modulesPath . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (is_dir($moduleDir) && is_file($moduleDir . 'autostart.php')) {
|
||||
|
||||
// Store Filename to Cache Content
|
||||
$fileNames[] = $moduleDir . 'autostart.php';
|
||||
|
||||
// Execute Autoloader
|
||||
require_once($moduleDir . 'autostart.php');
|
||||
// Cache content of autostart file
|
||||
if ($cacheEnabled) {
|
||||
$cacheFileContent .= file_get_contents($autoloadFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cacheEnabled) {
|
||||
// Created a cache file which contains all autoloaders
|
||||
$content = "";
|
||||
foreach ($fileNames as $fileName) {
|
||||
$content .= file_get_contents($fileName);
|
||||
}
|
||||
file_put_contents($cacheFileName, $content);
|
||||
file_put_contents($cacheFileName, $cacheFileContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all enabled modules from the database. (Cached)
|
||||
* Flushes Module Managers Cache
|
||||
*/
|
||||
private function loadEnabledModules() {
|
||||
public static function flushCache()
|
||||
{
|
||||
|
||||
$cacheId = "enabledModules";
|
||||
$cacheValue = Yii::app()->cache->get($cacheId);
|
||||
|
||||
if ($cacheValue === false || !is_array($cacheValue)) {
|
||||
|
||||
$enabledModules = array();
|
||||
foreach (ModuleEnabled::model()->findAll() as $em) {
|
||||
$enabledModules[$em->module_id] = $em->module_id;
|
||||
}
|
||||
Yii::app()->cache->set($cacheId, $enabledModules, HSetting::Get('expireTime', 'cache'));
|
||||
$this->enabledModules = $enabledModules;
|
||||
} else {
|
||||
$this->enabledModules = $cacheValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes Module Managers cache
|
||||
*/
|
||||
public static function flushCache() {
|
||||
|
||||
// Autoloader Cache File
|
||||
// Delete Autoloader Cache File
|
||||
$cacheFileName = Yii::app()->getRuntimePath() . DIRECTORY_SEPARATOR . self::AUTOSTART_CACHE_FILE_NAME;
|
||||
if (file_exists($cacheFileName)) {
|
||||
unlink($cacheFileName);
|
||||
}
|
||||
|
||||
// Delete Enabled Modules List
|
||||
$cacheId = "enabledModules";
|
||||
Yii::app()->cache->delete($cacheId);
|
||||
}
|
||||
@ -176,243 +154,145 @@ class ModuleManager extends CApplicationComponent {
|
||||
/**
|
||||
* Registers a module
|
||||
* This is usally called in the autostart file of the module.
|
||||
*
|
||||
* - id
|
||||
* - class Module Base Class
|
||||
* - import Global Module Imports
|
||||
* - events Events to catch
|
||||
*
|
||||
* - isCoreModule Core Modules only
|
||||
*
|
||||
* @param Array $definition
|
||||
*/
|
||||
public function register($definition) {
|
||||
$id = $definition['id'];
|
||||
public function register($definition)
|
||||
{
|
||||
|
||||
if (!isset($definition['isSpaceModule']))
|
||||
$definition['isSpaceModule'] = false;
|
||||
if (!isset($definition['class']) || !isset($definition['id'])) {
|
||||
throw new Exception("Register Module needs module Id and Class!");
|
||||
}
|
||||
|
||||
if (!isset($definition['isCoreModule']))
|
||||
$definition['isCoreModule'] = false;
|
||||
$isCoreModule = (isset($definition['isCoreModule']) && $definition['isCoreModule']);
|
||||
|
||||
if (!isset($definition['configRoute']))
|
||||
$definition['configRoute'] = '';
|
||||
$this->installedModules[$definition['id']] = $definition['class'];
|
||||
|
||||
if (!isset($definition['spaceConfigRoute']))
|
||||
$definition['spaceConfigRoute'] = '';
|
||||
// Not enabled and no core module
|
||||
if (!$isCoreModule && !in_array($definition['id'], $this->enabledModules)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Yii Module
|
||||
Yii::app()->setModules(array(
|
||||
$definition['id'] => array(
|
||||
'class' => $definition['class']
|
||||
),
|
||||
));
|
||||
|
||||
$this->registeredModules[$id] = $definition;
|
||||
// Set Imports
|
||||
if (isset($definition['import'])) {
|
||||
Yii::app()->setImport($definition['import']);
|
||||
}
|
||||
|
||||
// Check if module is enabled
|
||||
if (Yii::app()->moduleManager->isEnabled($id)) {
|
||||
|
||||
// Register Yii Module
|
||||
if (isset($definition['class'])) {
|
||||
Yii::app()->setModules(array(
|
||||
$id => array(
|
||||
'class' => $definition['class']
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
// Set Imports
|
||||
if (isset($definition['import'])) {
|
||||
Yii::app()->setImport($definition['import']);
|
||||
}
|
||||
|
||||
// Register Event Handlers
|
||||
if (isset($definition['events'])) {
|
||||
foreach ($definition['events'] as $event) {
|
||||
Yii::app()->interceptor->preattachEventHandler(
|
||||
$event['class'], $event['event'], $event['callback']
|
||||
);
|
||||
}
|
||||
// Register Event Handlers
|
||||
if (isset($definition['events'])) {
|
||||
foreach ($definition['events'] as $event) {
|
||||
Yii::app()->interceptor->preattachEventHandler(
|
||||
$event['class'], $event['event'], $event['callback']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a module is enabled or not.
|
||||
*
|
||||
* @param type $moduleId
|
||||
* @return boolean
|
||||
* Returns Module Base Class of installed module neither when not enabled.
|
||||
*
|
||||
* @param String $id Module Id
|
||||
* @return HWebModule
|
||||
*/
|
||||
public function isEnabled($moduleId) {
|
||||
public function getModule($id)
|
||||
{
|
||||
|
||||
$definition = $this->getDefinition($moduleId);
|
||||
|
||||
if ($definition['isCoreModule'])
|
||||
return true;
|
||||
|
||||
// Core installed yet?
|
||||
if (!Yii::app()->params['installed'])
|
||||
return false;
|
||||
|
||||
if (in_array($moduleId, $this->enabledModules)) {
|
||||
return true;
|
||||
// When enabled, returned it directly
|
||||
if (Yii::app()->getModule($id) != null) {
|
||||
return Yii::app()->getModule($id);
|
||||
}
|
||||
|
||||
#$moduleEnabled = ModuleEnabled::model()->findByPk($moduleId);
|
||||
#if ($moduleEnabled != null) {
|
||||
# return true;
|
||||
#}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all registered modules
|
||||
* This contains all enabled & disabled modules.
|
||||
* Key is the moduleId and value is the module definition
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getRegisteredModules() {
|
||||
return $this->registeredModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with enabled modules
|
||||
* Key of the array is the module id and value is the module definition.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEnabledModules() {
|
||||
|
||||
$enabledModules = array();
|
||||
|
||||
foreach ($this->getRegisteredModules() as $moduleId => $definition) {
|
||||
if ($this->isEnabled($moduleId)) {
|
||||
$enabledModules[$moduleId] = $definition;
|
||||
}
|
||||
// Not enabled, but installed - create it
|
||||
if (isset($this->installedModules[$id])) {
|
||||
$class = $this->installedModules[$id];
|
||||
return Yii::createComponent($class, $id, null);
|
||||
}
|
||||
|
||||
return $enabledModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a module by given module id.
|
||||
*
|
||||
* @param String $id
|
||||
*/
|
||||
public function enable($id) {
|
||||
|
||||
$definition = $this->getDefinition($id);
|
||||
if ($definition != null) {
|
||||
|
||||
// Core Modules doesn´t need to enabled
|
||||
if (!$definition['isCoreModule']) {
|
||||
|
||||
$moduleEnabled = ModuleEnabled::model()->findByPk($id);
|
||||
if ($moduleEnabled == null) {
|
||||
|
||||
$moduleEnabled = new ModuleEnabled();
|
||||
$moduleEnabled->module_id = $id;
|
||||
$moduleEnabled->save();
|
||||
|
||||
// Auto Migrate (add module database changes)
|
||||
Yii::import('application.commands.shell.ZMigrateCommand');
|
||||
$migrate = ZMigrateCommand::AutoMigrate();
|
||||
|
||||
// Fire Event Disabled Event
|
||||
if ($this->hasEventHandler('onEnable'))
|
||||
$this->onEnable(new CEvent($this, $id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModuleManager::flushCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables a active module by given module id
|
||||
*
|
||||
* @param String $id
|
||||
*/
|
||||
public function disable($id) {
|
||||
|
||||
$definition = $this->getDefinition($id);
|
||||
if ($definition != null) {
|
||||
|
||||
// Core Modules couldn´t disabled
|
||||
if (!$definition['isCoreModule']) {
|
||||
|
||||
if (isset($definition['userModules']) && is_array($definition['userModules'])) {
|
||||
$modulesToDisable = array_keys($definition['userModules']);
|
||||
foreach (User::model()->findAll() as $user) {
|
||||
foreach ($modulesToDisable as $userModuleId) {
|
||||
if ($user->isModuleEnabled($userModuleId))
|
||||
$user->uninstallModule($userModuleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($definition['spaceModules']) && is_array($definition['spaceModules'])) {
|
||||
$modulesToDisable = array_keys($definition['spaceModules']);
|
||||
foreach (Space::model()->findAll() as $space) {
|
||||
foreach ($modulesToDisable as $spaceModuleId) {
|
||||
if ($space->isModuleEnabled($spaceModuleId))
|
||||
$space->uninstallModule($spaceModuleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get Enabled Module Record
|
||||
$moduleEnabled = ModuleEnabled::model()->findByPk($id);
|
||||
if ($moduleEnabled != null)
|
||||
$moduleEnabled->delete();
|
||||
|
||||
// Fire Event Disabled Event
|
||||
if ($this->hasEventHandler('onDisable'))
|
||||
$this->onDisable(new CEvent($this, $id));
|
||||
}
|
||||
}
|
||||
ModuleManager::flushCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is raised after disabling a module
|
||||
*
|
||||
* @param CEvent $event the event parameter
|
||||
* @see disable
|
||||
*/
|
||||
public function onDisable($event) {
|
||||
$this->raiseEvent('onDisable', $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is raised after enabling a module
|
||||
*
|
||||
* @param CEvent $event the event parameter
|
||||
* @see enable
|
||||
*/
|
||||
public function onEnable($event) {
|
||||
$this->raiseEvent('onEnable', $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the definition array of a registered module
|
||||
*
|
||||
* @param type $id
|
||||
* @return null
|
||||
*/
|
||||
public function getDefinition($id) {
|
||||
if (isset($this->registeredModules[$id]))
|
||||
return $this->registeredModules[$id];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new Content Model
|
||||
*
|
||||
* @param String $className
|
||||
* Returns a list of all installed modules
|
||||
*
|
||||
* @param boolean $includeCoreModules include also core modules
|
||||
* @param boolean $returnClassName instead of instance
|
||||
* @return Array of installed Modules
|
||||
*/
|
||||
public function registerContentModel($className) {
|
||||
$this->registeredContentModels[] = $className;
|
||||
public function getInstalledModules($includeCoreModules = false, $returnClassName = false)
|
||||
{
|
||||
|
||||
$installed = array();
|
||||
foreach ($this->installedModules as $moduleId => $className) {
|
||||
|
||||
if (!$includeCoreModules && strpos($className, 'application.modules_core') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($returnClassName) {
|
||||
$installed[] = $className;
|
||||
} else {
|
||||
$module = $this->getModule($moduleId);
|
||||
|
||||
if ($module != null) {
|
||||
$installed[$moduleId] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all registered content models
|
||||
*
|
||||
* @return Array
|
||||
* Returns a list of all enabled modules
|
||||
*/
|
||||
public function getContentModels() {
|
||||
return $this->registeredContentModels;
|
||||
public function getEnabledModules()
|
||||
{
|
||||
|
||||
$modules = array();
|
||||
foreach ($this->enabledModules as $moduleId) {
|
||||
$module = $this->getModule($moduleId);
|
||||
if ($module != null) {
|
||||
$modules[] = $module;
|
||||
}
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a module is enabled.
|
||||
*
|
||||
* @param String $moduleId
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled($moduleId)
|
||||
{
|
||||
return (in_array($moduleId, $this->enabledModules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a module id is installed.
|
||||
*
|
||||
* @param String $moduleId
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInstalled($moduleId)
|
||||
{
|
||||
return (array_key_exists($moduleId, $this->installedModules));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
autostart.php
|
||||
=============
|
||||
|
||||
|
||||
Each module definition is stored within a file ``autostart.php`` inside the module root folder.
|
||||
This file is required by each module.
|
||||
|
||||
``Note:`` Contents of autostart.php are cached in file /protected/runtime/cache_autostart.php - delete this file or flush caches after modifing this file!
|
||||
|
||||
Example of a autostart.php File
|
||||
-------------------------------
|
||||
|
||||
<?php
|
||||
Yii::app()->moduleManager->register(array(
|
||||
|
||||
// Unique ID of the module, same as the module folder
|
||||
'id' => 'example',
|
||||
|
||||
// Module Base Class (http://www.yiiframework.com/doc/guide/1.1/en/basics.module)
|
||||
'class' => 'application.modules.example.ExampleModule',
|
||||
|
||||
// Title of the Module inside Administration Interface
|
||||
'title' => Yii::t('ExampleModule.base', 'Example'),
|
||||
|
||||
// Short Description
|
||||
'description' => Yii::t('ExampleModule.base', 'This Module shows some examples of the Module Interface.'),
|
||||
|
||||
// Optional Section: Auto Imports when module is enabled
|
||||
'import' => array(
|
||||
'application.modules.example.*',
|
||||
[...]
|
||||
),
|
||||
|
||||
// Optional Section: Events to catch when module is enabled
|
||||
// Use this to modify e.g. menus
|
||||
// http://www.yiiframework.com/doc/guide/1.1/en/basics.component#event
|
||||
'events' => array(
|
||||
// Listen for onInit Event of AdminMenuWidget and sent to
|
||||
// Module Class File to handle it
|
||||
array('class' => 'AdminMenuWidget', 'event' => 'onInit',
|
||||
'callback' => array('ExampleModule', 'onAdminMenuInit')),
|
||||
|
||||
[...]
|
||||
),
|
||||
|
||||
// Optional Section: When this module provides some modules to the user
|
||||
'userModules' => array(
|
||||
|
||||
// Some unique id for a user module
|
||||
'example_someuser_feature' => array(
|
||||
|
||||
// Basic Informations for the user
|
||||
'title' => Yii::t('ExampleModule.base','Shows Example Link on your profile'),
|
||||
'image' => '',
|
||||
'description' => Yii::t('ExampleModule.base', 'Awesome example link on your own profile!'),
|
||||
),
|
||||
|
||||
[...]
|
||||
),
|
||||
|
||||
// Optional Section: When this module provides some modules for spaces
|
||||
'spaceModules' => array(
|
||||
|
||||
// Some unique id for a user module
|
||||
'example_somespace_feature' => array(
|
||||
|
||||
// Basic Informations for the user
|
||||
'title' => Yii::t('ExampleModule.base','Shows Example Link on your space'),
|
||||
'image' => '',
|
||||
'description' => Yii::t('ExampleModule.base', 'Awesome example link on this space!'),
|
||||
),
|
||||
|
||||
[...]
|
||||
),
|
||||
|
||||
));
|
||||
?>
|
@ -1,7 +1,14 @@
|
||||
Core Changes / Changelog
|
||||
=========================
|
||||
|
||||
This file shows changes of the core api and notes for migrating your modules between new versions.
|
||||
This file shows changes of the core api for migrating your modules between new versions.
|
||||
|
||||
|
||||
# 0.6
|
||||
|
||||
- New required "module.json" file with informations about module (see documentation)
|
||||
- Cleanup of autostart.php (see documentation) New only: id, class, imports & events
|
||||
- New HWebModule Base Class for Modules (Change CWebModule to HWebModule)
|
||||
- No longer need to check on events whether module is enabled or not (besides spaces, user)
|
||||
- Spaces/Users Modules need to add new behavior to its module class
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
## Modules
|
||||
- [General](modules_general.md)
|
||||
- [Autostart](autostart.md)
|
||||
- [Database](database.md)
|
||||
- [User](user.md)
|
||||
- [Space](space.md)
|
||||
|
@ -9,15 +9,80 @@ to add them into a global configuration file like main.php.
|
||||
|
||||
Module Folder Structure
|
||||
------------------------
|
||||
/modules/ - Modules Base Folder
|
||||
/mymodule/ - My Module Id
|
||||
MyModule.php - Base Module Class
|
||||
autostart.php - Holds basic definition/config of module
|
||||
|
||||
```
|
||||
/protected/
|
||||
/modules/
|
||||
/mymodule/ - Module Folder
|
||||
module.json - Meta Information about this module (name, version & co.)
|
||||
autostart.php - Information about Id, BaseClass, Events and Imports
|
||||
MyModule.php - Base Module Class inherit from HWebModule
|
||||
/views/ - Views Folder
|
||||
/controllers/ - Controllers Folder
|
||||
/models/ - Models Folder
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
|
||||
autostart.php
|
||||
-------------
|
||||
|
||||
Each module requires a ``autostart.php`` File which registers the module to the main application.
|
||||
``Note:`` Contents of autostart.php are cached in file /protected/runtime/cache_autostart.php - delete this file or flush caches after modifing this file!
|
||||
|
||||
__Example of a autostart.php File__
|
||||
|
||||
```php
|
||||
<?php
|
||||
Yii::app()->moduleManager->register(array(
|
||||
|
||||
// Unique ID of the module, same as the module folder
|
||||
'id' => 'example',
|
||||
|
||||
// Module Base Class (http://www.yiiframework.com/doc/guide/1.1/en/basics.module)
|
||||
'class' => 'application.modules.example.ExampleModule',
|
||||
|
||||
// Optional Section: Global Imports
|
||||
'import' => array(
|
||||
'application.modules.example.*',
|
||||
[...]
|
||||
),
|
||||
|
||||
// Optional Section: Events to catch when module is enabled
|
||||
// Use this to modify e.g. menus
|
||||
// http://www.yiiframework.com/doc/guide/1.1/en/basics.component#event
|
||||
'events' => array(
|
||||
// Listen for onInit Event of AdminMenuWidget and sent to
|
||||
// Module Class File to handle it
|
||||
array('class' => 'AdminMenuWidget', 'event' => 'onInit',
|
||||
'callback' => array('ExampleModule', 'onAdminMenuInit')),
|
||||
|
||||
[...]
|
||||
),
|
||||
|
||||
));
|
||||
?>
|
||||
```
|
||||
|
||||
|
||||
module.json
|
||||
-----------
|
||||
|
||||
This file holds basic information about the module like name, description or
|
||||
current version.
|
||||
|
||||
__Example of a ´´module.json´´ File__
|
||||
```
|
||||
{
|
||||
"id": "mymoduleid",
|
||||
"name": "My Module",
|
||||
"description": "My testing module.",
|
||||
"keywords": ["my", "cool", "module"],
|
||||
"version": "1.0",
|
||||
"humhub": {
|
||||
"minVersion": "0.6"
|
||||
"maxVersion": "1.0"
|
||||
}
|
||||
}
|
||||
```
|
@ -1,24 +1,52 @@
|
||||
Space
|
||||
=====
|
||||
|
||||
Space Modules can be enabled/disabled per space.
|
||||
When your module should also appear in space module section you need to add the
|
||||
SpaceModuleBehavior to your Module Class.
|
||||
|
||||
```php
|
||||
|
||||
You need to the enable the flag **isSpaceModule** in the register module array.
|
||||
class SomeModule extends HWebModule
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
|
||||
return array(
|
||||
'SpaceModuleBehavior' => array(
|
||||
'class' => 'application.modules_core.space.SpaceModuleBehavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//...
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
See SpaceModuleBehavior Class for further details.
|
||||
|
||||
## Example: Add item to space navigation
|
||||
|
||||
Catch Space Navigation Init Event in your modules autostart.php.
|
||||
|
||||
```autostart.php
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
//...
|
||||
|
||||
'events' => array(
|
||||
array('class' => 'SpaceMenuWidget', 'event' => 'onInit', 'callback' => array('ExampleModule', 'onSpaceMenuInit')),
|
||||
)
|
||||
|
||||
Yii::app()->moduleManager->registerModule(array(
|
||||
'id' => 'example',
|
||||
'title' => 'Example Space Module',
|
||||
'description' => 'A space example module',
|
||||
'isSpaceModule' => true
|
||||
));
|
||||
|
||||
Then the module is available under the **Space -> Modules** Section.
|
||||
```
|
||||
|
||||
Before manipulating e.g. the SpaceMenu you need to check that the module is enabled in the space.
|
||||
|
||||
You can check this by:
|
||||
Define callback in your module to add item.
|
||||
|
||||
```php
|
||||
/**
|
||||
* On build of a Space Navigation, check if this module is enabled.
|
||||
* When enabled add a menu item
|
||||
@ -31,19 +59,51 @@ You can check this by:
|
||||
|
||||
// Is Module enabled on this workspace?
|
||||
if ($space->isModuleEnabled('example')) {
|
||||
|
||||
$event->sender->addItem(array(
|
||||
'label' => 'Some space navigation entry',
|
||||
'url' => '#',
|
||||
'icon' => 'icon',
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'example'),
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
At this release it´s not possible to create on space types.
|
||||
This feature will be available in a future release.
|
||||
```
|
||||
|
||||
|
||||
## Access space by by module controller
|
||||
|
||||
By adding the SpaceControllerBehavior you are able to access current space in your controllers.
|
||||
Make sure you always pass the current space guid (sguid) in your urls.
|
||||
|
||||
When using the method createContainerUrl (provided by SpaceControllerBehavior or UserControllerBehavior) the current space or user guid is automatically added to urls.
|
||||
|
||||
```php
|
||||
|
||||
/**
|
||||
* Add mix-ins to this model
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return array(
|
||||
'SpaceControllerBehavior' => array(
|
||||
'class' => 'application.modules_core.space.SpaceControllerBehavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
$currentSpace = $this->getSpace();
|
||||
|
||||
$this->redirect($this->createContainerUrl('test2'));
|
||||
|
||||
}
|
||||
|
||||
public function actionTest2() {
|
||||
$currentSpace = $this->getSpace();
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -1,39 +1,4 @@
|
||||
User
|
||||
====
|
||||
|
||||
After you defined some userModules in your autostart.php file the module is available
|
||||
under the **Account Settings -> Modules** Section.
|
||||
|
||||
User Profiles
|
||||
-------------
|
||||
|
||||
When providing extra functionalities for user profiles be sure that you always add the
|
||||
ProfileControllerBehavior to your controller and pass the parameter uguid (User GUID).
|
||||
This way you can access the current user with getUser() Method provided by behavior.
|
||||
|
||||
|
||||
Example of a User Profile Addon Controller:
|
||||
|
||||
class MyModuleControllerController extends Controller {
|
||||
|
||||
// Use standard profile layout (menu, ...)
|
||||
public $subLayout = "application.modules_core.user.views.profile._layout";
|
||||
|
||||
/**
|
||||
* Add behaviors to this controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function behaviors() {
|
||||
return array(
|
||||
/**
|
||||
* This behavior provides the method getUser() inside your controller
|
||||
* which always returns the user of the current profile
|
||||
*/
|
||||
'ProfileControllerBehavior' => array(
|
||||
'class' => 'application.modules_core.user.ProfileControllerBehavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
...
|
||||
}
|
||||
TBD
|
@ -6,9 +6,11 @@
|
||||
* @package humhub.modules.mail
|
||||
* @since 0.5
|
||||
*/
|
||||
class MailModule extends CWebModule {
|
||||
class MailModule extends HWebModule
|
||||
{
|
||||
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->setImport(array(
|
||||
'mail.models.*',
|
||||
@ -23,7 +25,8 @@ class MailModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onUserDelete($event) {
|
||||
public static function onUserDelete($event)
|
||||
{
|
||||
|
||||
Yii::import('application.modules.mail.models.*');
|
||||
|
||||
@ -45,7 +48,8 @@ class MailModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onIntegrityCheck($event) {
|
||||
public static function onIntegrityCheck($event)
|
||||
{
|
||||
|
||||
$integrityChecker = $event->sender;
|
||||
#$integrityChecker->showTestHeadline("Validating Mail Module (" . Message::model()->count() . " entries)");
|
||||
@ -57,26 +61,21 @@ class MailModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onTopMenuInit($event) {
|
||||
public static function onTopMenuInit($event)
|
||||
{
|
||||
|
||||
// Is Module enabled on this workspace?
|
||||
if (Yii::app()->moduleManager->isEnabled('mail')) {
|
||||
$event->sender->addItem(array(
|
||||
'label' => Yii::t('MailModule.base', 'Messages'),
|
||||
'url' => Yii::app()->createUrl('//mail/mail/index', array()),
|
||||
'icon' => 'mail',
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'mail'),
|
||||
'sortOrder' => 300,
|
||||
));
|
||||
}
|
||||
$event->sender->addItem(array(
|
||||
'label' => Yii::t('MailModule.base', 'Messages'),
|
||||
'url' => Yii::app()->createUrl('//mail/mail/index', array()),
|
||||
'icon' => 'mail',
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'mail'),
|
||||
'sortOrder' => 300,
|
||||
));
|
||||
}
|
||||
|
||||
public static function onNotificationAddonInit($event) {
|
||||
|
||||
// Is Module enabled on this workspace?
|
||||
if (Yii::app()->moduleManager->isEnabled('mail')) {
|
||||
$event->sender->addWidget('application.modules.mail.widgets.MailNotificationWidget', array(), array('sortOrder' => 90));
|
||||
}
|
||||
public static function onNotificationAddonInit($event)
|
||||
{
|
||||
$event->sender->addWidget('application.modules.mail.widgets.MailNotificationWidget', array(), array('sortOrder' => 90));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'mail',
|
||||
'title' => Yii::t('MailModule.base', 'Mail'),
|
||||
'description' => Yii::t('MailModule.base', 'Adds the mailing core module.'),
|
||||
'class' => 'application.modules.mail.MailModule',
|
||||
'import' => array(
|
||||
'application.modules.mail.*',
|
||||
|
10
protected/modules/mail/module.json
Normal file
10
protected/modules/mail/module.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "mail",
|
||||
"name": "Mail",
|
||||
"description": "Simple user to user mailing system",
|
||||
"keywords": ["mail", "messaging", "communication"],
|
||||
"version": "0.4",
|
||||
"humhub": {
|
||||
"minVersion": "0.5"
|
||||
}
|
||||
}
|
@ -9,12 +9,14 @@
|
||||
* @since 0.5
|
||||
* @author Luke
|
||||
*/
|
||||
class PollsModule extends CWebModule {
|
||||
class PollsModule extends HWebModule
|
||||
{
|
||||
|
||||
/**
|
||||
* Inits the Module
|
||||
*/
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->setImport(array(
|
||||
'polls.models.*',
|
||||
@ -22,13 +24,24 @@ class PollsModule extends CWebModule {
|
||||
));
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
|
||||
return array(
|
||||
'SpaceModuleBehavior' => array(
|
||||
'class' => 'application.modules_core.space.SpaceModuleBehavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* On build of a Space Navigation, check if this module is enabled.
|
||||
* When enabled add a menu item
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onSpaceMenuInit($event) {
|
||||
public static function onSpaceMenuInit($event)
|
||||
{
|
||||
|
||||
$space = Yii::app()->getController()->getSpace();
|
||||
|
||||
@ -49,7 +62,8 @@ class PollsModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onUserDelete($event) {
|
||||
public static function onUserDelete($event)
|
||||
{
|
||||
|
||||
foreach (Content::model()->findAllByAttributes(array('user_id' => $event->sender->id, 'object_model' => 'Poll')) as $content) {
|
||||
$content->delete();
|
||||
@ -67,7 +81,8 @@ class PollsModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onSpaceDelete($event) {
|
||||
public static function onSpaceDelete($event)
|
||||
{
|
||||
foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Poll')) as $content) {
|
||||
$content->delete();
|
||||
}
|
||||
@ -79,7 +94,8 @@ class PollsModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onSpaceUninstallModule($event) {
|
||||
public static function onSpaceUninstallModule($event)
|
||||
{
|
||||
if ($event->params == 'polls') {
|
||||
foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Poll')) as $content) {
|
||||
$content->delete();
|
||||
@ -93,7 +109,8 @@ class PollsModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onDisableModule($event) {
|
||||
public static function onDisableModule($event)
|
||||
{
|
||||
if ($event->params == 'polls') {
|
||||
|
||||
foreach (Content::model()->findAllByAttributes(array('object_model' => 'Poll')) as $content) {
|
||||
@ -107,10 +124,11 @@ class PollsModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onIntegrityCheck($event) {
|
||||
public static function onIntegrityCheck($event)
|
||||
{
|
||||
|
||||
$integrityChecker = $event->sender;
|
||||
$integrityChecker->showTestHeadline("Validating Polls Module (" . Poll::model()->count() . " entries)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'polls',
|
||||
'class' => 'application.modules.polls.PollsModule',
|
||||
'title' => Yii::t('PollsModule.base', 'Polls'),
|
||||
'description' => Yii::t('PollsModule.base', 'Adds polling features to spaces.'),
|
||||
'import' => array(
|
||||
'application.modules.polls.models.*',
|
||||
'application.modules.polls.behaviors.*',
|
||||
@ -20,12 +18,5 @@ Yii::app()->moduleManager->register(array(
|
||||
array('class' => 'ModuleManager', 'event' => 'onDisable', 'callback' => array('PollsModule', 'onDisableModule')),
|
||||
array('class' => 'IntegrityChecker', 'event' => 'onRun', 'callback' => array('PollsModule', 'onIntegrityCheck')),
|
||||
),
|
||||
'spaceModules' => array(
|
||||
'polls' => array(
|
||||
'title' => Yii::t('PollsModule.base', 'Polls'),
|
||||
'description' => Yii::t('PollsModule.base', 'Adds polling features to your space.'),
|
||||
),
|
||||
),
|
||||
'contentModels' => array('Poll'),
|
||||
));
|
||||
?>
|
@ -17,32 +17,38 @@
|
||||
* @since 0.5
|
||||
* @author Luke
|
||||
*/
|
||||
class Poll extends HActiveRecordContent {
|
||||
class Poll extends HActiveRecordContent
|
||||
{
|
||||
|
||||
const MIN_REQUIRED_ANSWERS = 2;
|
||||
|
||||
public $userToNotify = "";
|
||||
public $answersText;
|
||||
public $autoAddToWall = true;
|
||||
|
||||
/**
|
||||
* Returns the static model of the specified AR class.
|
||||
* @param string $className active record class name.
|
||||
* @return Question the static model class
|
||||
*/
|
||||
public static function model($className = __CLASS__) {
|
||||
public static function model($className = __CLASS__)
|
||||
{
|
||||
return parent::model($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the associated database table name
|
||||
*/
|
||||
public function tableName() {
|
||||
public function tableName()
|
||||
{
|
||||
return 'poll';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array validation rules for model attributes.
|
||||
*/
|
||||
public function rules() {
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('question, answersText, created_at, created_by, updated_at, updated_by', 'required'),
|
||||
array('answersText', 'validateAnswersText'),
|
||||
@ -54,7 +60,8 @@ class Poll extends HActiveRecordContent {
|
||||
/**
|
||||
* @return array customized attribute labels (name=>label)
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'answersText' => Yii::t('PollsModule.base', 'Answers'),
|
||||
'question' => Yii::t('PollsModule.base', 'Question'),
|
||||
@ -65,13 +72,15 @@ class Poll extends HActiveRecordContent {
|
||||
/**
|
||||
* @return array relational rules.
|
||||
*/
|
||||
public function relations() {
|
||||
public function relations()
|
||||
{
|
||||
return array(
|
||||
'answers' => array(self::HAS_MANY, 'PollAnswer', 'poll_id'),
|
||||
);
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
public function afterSave()
|
||||
{
|
||||
parent::afterSave();
|
||||
|
||||
if ($this->isNewRecord) {
|
||||
@ -111,7 +120,8 @@ class Poll extends HActiveRecordContent {
|
||||
/**
|
||||
* Deletes a Poll including its dependencies.
|
||||
*/
|
||||
public function beforeDelete() {
|
||||
public function beforeDelete()
|
||||
{
|
||||
|
||||
// Delete all dependencies
|
||||
foreach ($this->answers as $answer) {
|
||||
@ -132,7 +142,8 @@ class Poll extends HActiveRecordContent {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function hasUserVoted($userId = "") {
|
||||
public function hasUserVoted($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -145,7 +156,8 @@ class Poll extends HActiveRecordContent {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function vote($votes = array()) {
|
||||
public function vote($votes = array())
|
||||
{
|
||||
|
||||
if ($this->hasUserVoted()) {
|
||||
return;
|
||||
@ -180,7 +192,8 @@ class Poll extends HActiveRecordContent {
|
||||
*
|
||||
* @param type $userId
|
||||
*/
|
||||
public function resetAnswer($userId = "") {
|
||||
public function resetAnswer($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -205,14 +218,16 @@ class Poll extends HActiveRecordContent {
|
||||
}
|
||||
}
|
||||
|
||||
public function setAnswers() {
|
||||
public function setAnswers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Wall Output
|
||||
*/
|
||||
public function getWallOut() {
|
||||
public function getWallOut()
|
||||
{
|
||||
return Yii::app()->getController()->widget('application.modules.polls.widgets.PollWallEntryWidget', array('poll' => $this), true);
|
||||
}
|
||||
|
||||
@ -223,11 +238,13 @@ class Poll extends HActiveRecordContent {
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getContentTitle() {
|
||||
public function getContentTitle()
|
||||
{
|
||||
return Yii::t('PollsModule.base', "Question") . " \"" . Helpers::truncateText($this->question, 25) . "\"";
|
||||
}
|
||||
|
||||
public function validateAnswersText() {
|
||||
public function validateAnswersText()
|
||||
{
|
||||
|
||||
$answers = explode("\n", $this->answersText);
|
||||
$answerCount = 0;
|
||||
@ -267,7 +284,6 @@ class Poll extends HActiveRecordContent {
|
||||
$notification->target_object_model = 'Poll';
|
||||
$notification->target_object_id = $this->id;
|
||||
$notification->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
10
protected/modules/polls/module.json
Normal file
10
protected/modules/polls/module.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "polls",
|
||||
"name": "Polls",
|
||||
"description": "Simple polling system",
|
||||
"keywords": ["poll", "votes"],
|
||||
"version": "0.5",
|
||||
"humhub": {
|
||||
"minVersion": "0.5"
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
class TasksModule extends CWebModule {
|
||||
class TasksModule extends HWebModule
|
||||
{
|
||||
|
||||
/**
|
||||
* Inits the Module
|
||||
*/
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
$this->setImport(array(
|
||||
'tasks.*',
|
||||
'tasks.models.*',
|
||||
@ -14,12 +16,23 @@ class TasksModule extends CWebModule {
|
||||
));
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
|
||||
return array(
|
||||
'SpaceModuleBehavior' => array(
|
||||
'class' => 'application.modules_core.space.SpaceModuleBehavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* On User delete, also delete all tasks
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onUserDelete($event) {
|
||||
public static function onUserDelete($event)
|
||||
{
|
||||
|
||||
foreach (Content::model()->findAllByAttributes(array('created_by' => $event->sender->id, 'object_model' => 'Task')) as $content) {
|
||||
$content->delete();
|
||||
@ -44,7 +57,8 @@ class TasksModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onSpaceDelete($event) {
|
||||
public static function onSpaceDelete($event)
|
||||
{
|
||||
foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Task')) as $content) {
|
||||
$content->delete();
|
||||
}
|
||||
@ -56,10 +70,11 @@ class TasksModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onSpaceMenuInit($event) {
|
||||
public static function onSpaceMenuInit($event)
|
||||
{
|
||||
|
||||
$space = Yii::app()->getController()->getSpace();
|
||||
|
||||
|
||||
// Is Module enabled on this workspace?
|
||||
if ($space->isModuleEnabled('tasks')) {
|
||||
$event->sender->addItem(array(
|
||||
@ -78,7 +93,8 @@ class TasksModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onSpaceUninstallModule($event) {
|
||||
public static function onSpaceUninstallModule($event)
|
||||
{
|
||||
if ($event->params == 'tasks') {
|
||||
foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Task')) as $content) {
|
||||
$content->delete();
|
||||
@ -92,7 +108,8 @@ class TasksModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onDisableModule($event) {
|
||||
public static function onDisableModule($event)
|
||||
{
|
||||
if ($event->params == 'tasks') {
|
||||
foreach (Content::model()->findAllByAttributes(array('object_model' => 'Task')) as $content) {
|
||||
$content->delete();
|
||||
@ -105,10 +122,11 @@ class TasksModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onIntegrityCheck($event) {
|
||||
public static function onIntegrityCheck($event)
|
||||
{
|
||||
|
||||
$integrityChecker = $event->sender;
|
||||
$integrityChecker->showTestHeadline("Validating Tasks Module (" . Task::model()->count() . " entries)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'tasks',
|
||||
'class' => 'application.modules.tasks.TasksModule',
|
||||
'title' => Yii::t('TasksModule.base', 'Tasks'),
|
||||
'description' => Yii::t('TasksModule.base', 'Adds a taskmanager to your spaces. With this module you can create and assign tasks to users in spaces.'),
|
||||
'import' => array(
|
||||
'application.modules.tasks.*',
|
||||
'application.modules.tasks.models.*',
|
||||
@ -19,12 +17,5 @@ Yii::app()->moduleManager->register(array(
|
||||
array('class' => 'ModuleManager', 'event' => 'onDisable', 'callback' => array('TasksModule', 'onDisableModule')),
|
||||
array('class' => 'IntegrityChecker', 'event' => 'onRun', 'callback' => array('TasksModule', 'onIntegrityCheck')),
|
||||
),
|
||||
'spaceModules' => array(
|
||||
'tasks' => array(
|
||||
'title' => Yii::t('TasksModule.base', 'Tasks'),
|
||||
'description' => Yii::t('TasksModule.base', 'Adds a taskmanager to your spaces. With this module you can create and assign tasks to users in spaces.'),
|
||||
),
|
||||
),
|
||||
'contentModels' => array('Task'),
|
||||
));
|
||||
?>
|
@ -15,7 +15,8 @@
|
||||
* @property string $updated_at
|
||||
* @property integer $updated_by
|
||||
*/
|
||||
class Task extends HActiveRecordContent {
|
||||
class Task extends HActiveRecordContent
|
||||
{
|
||||
|
||||
public $preassignedUsers;
|
||||
public $userToNotify = "";
|
||||
@ -24,26 +25,31 @@ class Task extends HActiveRecordContent {
|
||||
const STATUS_OPEN = 1;
|
||||
const STATUS_FINISHED = 5;
|
||||
|
||||
public $autoAddToWall = true;
|
||||
|
||||
/**
|
||||
* Returns the static model of the specified AR class.
|
||||
* @param string $className active record class name.
|
||||
* @return Task the static model class
|
||||
*/
|
||||
public static function model($className = __CLASS__) {
|
||||
public static function model($className = __CLASS__)
|
||||
{
|
||||
return parent::model($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the associated database table name
|
||||
*/
|
||||
public function tableName() {
|
||||
public function tableName()
|
||||
{
|
||||
return 'task';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array validation rules for model attributes.
|
||||
*/
|
||||
public function rules() {
|
||||
public function rules()
|
||||
{
|
||||
// NOTE: you should only define rules for those attributes that
|
||||
// will receive user inputs.
|
||||
return array(
|
||||
@ -56,7 +62,8 @@ class Task extends HActiveRecordContent {
|
||||
/**
|
||||
* @return array relational rules.
|
||||
*/
|
||||
public function relations() {
|
||||
public function relations()
|
||||
{
|
||||
// NOTE: you may need to adjust the relation name and the related
|
||||
// class name for the relations automatically generated below.
|
||||
return array(
|
||||
@ -68,7 +75,8 @@ class Task extends HActiveRecordContent {
|
||||
/**
|
||||
* Deletes a Task including its dependencies.
|
||||
*/
|
||||
public function delete() {
|
||||
public function delete()
|
||||
{
|
||||
|
||||
// delete all tasks user assignments
|
||||
$taskUser = TaskUser::model()->findAllByAttributes(array('task_id' => $this->id));
|
||||
@ -84,7 +92,8 @@ class Task extends HActiveRecordContent {
|
||||
/**
|
||||
* Returns the Wall Output
|
||||
*/
|
||||
public function getWallOut() {
|
||||
public function getWallOut()
|
||||
{
|
||||
return Yii::app()->getController()->widget('application.modules.tasks.widgets.TaskWallEntryWidget', array('task' => $this), true);
|
||||
}
|
||||
|
||||
@ -93,7 +102,8 @@ class Task extends HActiveRecordContent {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function afterSave() {
|
||||
public function afterSave()
|
||||
{
|
||||
|
||||
parent::afterSave();
|
||||
|
||||
@ -133,7 +143,8 @@ class Task extends HActiveRecordContent {
|
||||
/**
|
||||
* Returns assigned users to this task
|
||||
*/
|
||||
public function getAssignedUsers() {
|
||||
public function getAssignedUsers()
|
||||
{
|
||||
$users = array();
|
||||
$tus = TaskUser::model()->findAllByAttributes(array('task_id' => $this->id));
|
||||
foreach ($tus as $tu) {
|
||||
@ -147,7 +158,8 @@ class Task extends HActiveRecordContent {
|
||||
/**
|
||||
* Assign user to this task
|
||||
*/
|
||||
public function assignUser($user = "") {
|
||||
public function assignUser($user = "")
|
||||
{
|
||||
|
||||
if ($user == "")
|
||||
$user = Yii::app()->user->getModel();
|
||||
@ -186,7 +198,8 @@ class Task extends HActiveRecordContent {
|
||||
/**
|
||||
* UnAssign user to this task
|
||||
*/
|
||||
public function unassignUser($user = "") {
|
||||
public function unassignUser($user = "")
|
||||
{
|
||||
if ($user == "")
|
||||
$user = Yii::app()->user->getModel();
|
||||
|
||||
@ -214,7 +227,8 @@ class Task extends HActiveRecordContent {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function changePercent($newPercent) {
|
||||
public function changePercent($newPercent)
|
||||
{
|
||||
|
||||
if ($this->percent != $newPercent) {
|
||||
$this->percent = $newPercent;
|
||||
@ -232,7 +246,8 @@ class Task extends HActiveRecordContent {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function changeStatus($newStatus) {
|
||||
public function changeStatus($newStatus)
|
||||
{
|
||||
|
||||
$this->status = $newStatus;
|
||||
$this->save();
|
||||
@ -292,7 +307,8 @@ class Task extends HActiveRecordContent {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function GetUsersOpenTasks() {
|
||||
public static function GetUsersOpenTasks()
|
||||
{
|
||||
|
||||
$sql = " SELECT task.* FROM task_user " .
|
||||
" LEFT JOIN task ON task.id = task_user.task_id " .
|
||||
@ -314,11 +330,11 @@ class Task extends HActiveRecordContent {
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getContentTitle() {
|
||||
public function getContentTitle()
|
||||
{
|
||||
return "\"" . Helpers::truncateText($this->title, 25) . "\"";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign user to this task
|
||||
*/
|
||||
@ -339,7 +355,6 @@ class Task extends HActiveRecordContent {
|
||||
$notification->target_object_model = 'Task';
|
||||
$notification->target_object_id = $this->id;
|
||||
$notification->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
11
protected/modules/tasks/module.json
Normal file
11
protected/modules/tasks/module.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "tasks",
|
||||
"name": "Tasks",
|
||||
"description": "Adds a taskmanager to your spaces. With this module you can create and assign tasks to users in spaces.",
|
||||
"keywords": ["task", "todo"],
|
||||
"version": "0.9",
|
||||
"humhub": {
|
||||
"minVersion": "0.5",
|
||||
"maxVersion": "0.7"
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class YiiGiiModule extends CWebModule {
|
||||
class YiiGiiModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
$this->setImport(array(
|
||||
|
11
protected/modules/yiigii/module.json
Normal file
11
protected/modules/yiigii/module.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "yiigii",
|
||||
"name": "Yii Gii Integration",
|
||||
"description": "Integrates Yii Code Generator",
|
||||
"keywords": ["yii", "gii", "development"],
|
||||
"version": "0.9",
|
||||
"humhub": {
|
||||
"minVersion": "0.5",
|
||||
"maxVersion": "0.7"
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
* @package humhub.modules_core.activity
|
||||
* @since 0.5
|
||||
*/
|
||||
class ActivityModule extends CWebModule {
|
||||
class ActivityModule extends HWebModule {
|
||||
|
||||
/**
|
||||
* Inits the activity module
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'activity',
|
||||
'title' => Yii::t('ActivityModule.base', 'Activities'),
|
||||
'description' => Yii::t('ActivityModule.base', 'Adds the activities core module.'),
|
||||
'class' => 'application.modules_core.activity.ActivityModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
@ -18,6 +16,5 @@ Yii::app()->moduleManager->register(array(
|
||||
array('class' => 'HActiveRecord', 'event' => 'onBeforeDelete', 'callback' => array('ActivityModule', 'onActiveRecordDelete')),
|
||||
array('class' => 'IntegrityChecker', 'event' => 'onRun', 'callback' => array('ActivityModule', 'onIntegrityCheck')),
|
||||
),
|
||||
'contentModels' => array('Activity'),
|
||||
));
|
||||
?>
|
9
protected/modules_core/activity/module.json
Normal file
9
protected/modules_core/activity/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "activity",
|
||||
"name": "Activity",
|
||||
"description": "Activity Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* @package humhub.modules_core.admin
|
||||
* @since 0.5
|
||||
*/
|
||||
class AdminModule extends CWebModule {
|
||||
class AdminModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'admin',
|
||||
'title' => Yii::t('AdminModule.base', 'Admin'),
|
||||
'description' => Yii::t('AdminModule.base', 'Provides general admin functions.'),
|
||||
'class' => 'application.modules_core.admin.AdminModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
@ -4,14 +4,16 @@
|
||||
* @package humhub.modules_core.admin.controllers
|
||||
* @since 0.5
|
||||
*/
|
||||
class ModuleController extends Controller {
|
||||
class ModuleController extends Controller
|
||||
{
|
||||
|
||||
public $subLayout = "/_layout";
|
||||
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters() {
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl', // perform access control for CRUD operations
|
||||
);
|
||||
@ -22,7 +24,8 @@ class ModuleController extends Controller {
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules() {
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'expression' => 'Yii::app()->user->isAdmin()'
|
||||
@ -33,33 +36,35 @@ class ModuleController extends Controller {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function actionIndex() {
|
||||
public function actionIndex()
|
||||
{
|
||||
ModuleManager::flushCache();
|
||||
|
||||
|
||||
// Require this initial redirect to ensure Module Cache is flushed
|
||||
// before list it.
|
||||
$this->redirect(Yii::app()->createUrl('admin/module/list'));
|
||||
$this->redirect(Yii::app()->createUrl('admin/module/list'));
|
||||
}
|
||||
|
||||
public function actionList() {
|
||||
ModuleManager::flushCache();
|
||||
$this->render('list', array());
|
||||
public function actionList()
|
||||
{
|
||||
|
||||
$installedModules = Yii::app()->moduleManager->getInstalledModules();
|
||||
|
||||
ModuleManager::flushCache();
|
||||
$this->render('list', array('installedModules' => $installedModules));
|
||||
}
|
||||
|
||||
public function actionEnable() {
|
||||
public function actionEnable()
|
||||
{
|
||||
|
||||
$moduleId = Yii::app()->request->getQuery('moduleId');
|
||||
$module = Yii::app()->moduleManager->getModule($moduleId);
|
||||
|
||||
$definition = Yii::app()->moduleManager->getDefinition($moduleId);
|
||||
if ($definition == null) {
|
||||
if ($module == null) {
|
||||
throw new CHttpException(500, Yii::t('AdminModule.base', 'Could not find requested module!'));
|
||||
}
|
||||
|
||||
if (!Yii::app()->moduleManager->isEnabled($moduleId)) {
|
||||
Yii::app()->moduleManager->enable($moduleId);
|
||||
}
|
||||
$module->enable();
|
||||
|
||||
$this->redirect(Yii::app()->createUrl('admin/module/list'));
|
||||
}
|
||||
@ -68,18 +73,17 @@ class ModuleController extends Controller {
|
||||
*
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function actionDisable() {
|
||||
public function actionDisable()
|
||||
{
|
||||
|
||||
$moduleId = Yii::app()->request->getQuery('moduleId');
|
||||
$module = Yii::app()->moduleManager->getModule($moduleId);
|
||||
|
||||
$definition = Yii::app()->moduleManager->getDefinition($moduleId);
|
||||
if ($definition == null) {
|
||||
if ($module == null) {
|
||||
throw new CHttpException(500, Yii::t('AdminModule.base', 'Could not find requested module!'));
|
||||
}
|
||||
|
||||
if (Yii::app()->moduleManager->isEnabled($moduleId)) {
|
||||
Yii::app()->moduleManager->disable($moduleId);
|
||||
}
|
||||
$module->disable();
|
||||
|
||||
$this->redirect(Yii::app()->createUrl('admin/module/list'));
|
||||
}
|
||||
|
9
protected/modules_core/admin/module.json
Normal file
9
protected/modules_core/admin/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "admin",
|
||||
"name": "Admin",
|
||||
"description": "Admin Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -1,59 +1,57 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><?php echo Yii::t('AdminModule.logging', '<strong>Error</strong> logging'); ?></div>
|
||||
<div class="panel-body">
|
||||
<h1><?php echo Yii::t('AdminModule.logging', 'Logging'); ?></h1>
|
||||
|
||||
|
||||
<?php echo Yii::t('AdminModule.logging', 'Total {count} entries found.', array("{count}" => $itemCount)); ?>
|
||||
<?php echo Yii::t('AdminModule.logging', 'Displaying {count} entries per page.', array("{count}" => $pageSize)); ?>
|
||||
<div>
|
||||
<?php echo Yii::t('AdminModule.logging', 'Total {count} entries found.', array("{count}"=>$itemCount)); ?>
|
||||
<span class="pull-right"><?php echo Yii::t('AdminModule.logging', 'Displaying {count} entries per page.', array("{count}"=>$pageSize)); ?></span>
|
||||
</div>
|
||||
|
||||
<ul class="media-list">
|
||||
<?php foreach ($entries as $entry) : ?>
|
||||
<hr>
|
||||
|
||||
<li class="media">
|
||||
<div class="media-body">
|
||||
<ul class="media-list">
|
||||
<?php foreach ($entries as $entry) : ?>
|
||||
|
||||
<?php
|
||||
$labelClass = "label-primary";
|
||||
if ($entry->level == 'error') {
|
||||
$labelClass = "label-danger";
|
||||
} elseif ($entry->level == 'error') {
|
||||
$labelClass = "label-warning";
|
||||
} elseif ($entry->level == 'info') {
|
||||
$labelClass = "label-info";
|
||||
}
|
||||
?>
|
||||
<li class="media">
|
||||
<div class="media-body">
|
||||
|
||||
<?php
|
||||
$labelClass = "label-primary";
|
||||
if ($entry->level == 'error') {
|
||||
$labelClass = "label-danger";
|
||||
} elseif ($entry->level == 'error') {
|
||||
$labelClass = "label-warning";
|
||||
} elseif ($entry->level == 'info') {
|
||||
$labelClass = "label-info";
|
||||
}
|
||||
?>
|
||||
|
||||
<h4 class="media-heading">
|
||||
<span class="label <?php echo $labelClass; ?>"><?php echo $entry->level; ?></span>
|
||||
<?php echo date('r', $entry->logtime); ?>
|
||||
<span class="pull-right"><?php echo $entry->category; ?></span>
|
||||
</h4>
|
||||
<?php echo $entry->message; ?>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4 class="media-heading"><span
|
||||
class="pull-left label <?php echo $labelClass; ?>"><?php echo $entry->level; ?></span>
|
||||
(<?php echo $entry->id; ?>)
|
||||
<?php echo date('r', $entry->logtime); ?>
|
||||
<strong><?php echo $entry->category; ?></strong>
|
||||
</h4>
|
||||
<?php echo $entry->message; ?>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
|
||||
<center>
|
||||
<?php
|
||||
$this->widget('CLinkPager', array(
|
||||
'currentPage' => $pagination->getCurrentPage(),
|
||||
'itemCount' => $itemCount,
|
||||
'pageSize' => $pageSize,
|
||||
'maxButtonCount' => 5,
|
||||
'header' => '',
|
||||
'nextPageLabel' => '<i class="icon-step-forward"></i>',
|
||||
'prevPageLabel' => '<i class="icon-step-backward"></i>',
|
||||
'firstPageLabel' => '<i class="icon-fast-backward"></i>',
|
||||
'lastPageLabel' => '<i class="icon-fast-forward"></i>',
|
||||
'htmlOptions' => array('class' => 'pagination'),
|
||||
));
|
||||
?>
|
||||
</center>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<center>
|
||||
<?php
|
||||
$this->widget('CLinkPager', array(
|
||||
'currentPage' => $pagination->getCurrentPage(),
|
||||
'itemCount' => $itemCount,
|
||||
'pageSize' => $pageSize,
|
||||
'maxButtonCount' => 5,
|
||||
'header' => '',
|
||||
'nextPageLabel' => '<i class="icon-step-forward"></i>',
|
||||
'prevPageLabel' => '<i class="icon-step-backward"></i>',
|
||||
'firstPageLabel' => '<i class="icon-fast-backward"></i>',
|
||||
'lastPageLabel' => '<i class="icon-fast-forward"></i>',
|
||||
'htmlOptions' => array('class' => 'pagination'),
|
||||
));
|
||||
?>
|
||||
</center>
|
@ -1,106 +1,53 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><?php echo Yii::t('AdminModule.base', '<strong>Manage</strong> modules'); ?></div>
|
||||
<div class="panel-body">
|
||||
<h1><?php echo Yii::t('AdminModule.base', 'Modules'); ?></h1>
|
||||
|
||||
<p>Manage installed/active modules in your HumHub Installation!</p><br>
|
||||
<ul class="nav nav-pills" id="moduleTabs">
|
||||
<li class="active"><a href="#extensions">Installed</a></li>
|
||||
<!--<li><?php echo CHtml::link('Browse online', $this->createUrl('listOnline')); ?></li>-->
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<h2>Installed Modules</h2>
|
||||
|
||||
|
||||
<ul class="nav nav-pills" id="moduleTabs">
|
||||
<li class="active"><a href="#extensions">Third party modules</a></li>
|
||||
<li><a href="#core">Installed core modules</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
<hr>
|
||||
<?php foreach ($installedModules as $moduleId => $module) : ?>
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="<?php echo $module->getImage(); ?>">
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="extensions">
|
||||
|
||||
<?php foreach (Yii::app()->moduleManager->getRegisteredModules() as $moduleDefinition) : ?>
|
||||
|
||||
<?php
|
||||
$moduleId = $moduleDefinition['id'];
|
||||
?>
|
||||
|
||||
<?php if (!$moduleDefinition['isCoreModule']) : ?>
|
||||
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="<?php echo Yii::app()->baseUrl; ?>/uploads/profile_image/default_module.jpg">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><?php echo $moduleDefinition['title']; ?>
|
||||
<small>
|
||||
<?php if (Yii::app()->moduleManager->isEnabled($moduleId)) : ?>
|
||||
<span
|
||||
class="label label-success"><?php echo Yii::t('SpaceModule.base', 'Activated'); ?></span>
|
||||
<?php endif; ?>
|
||||
</small>
|
||||
</h4>
|
||||
|
||||
<p><?php echo $moduleDefinition['description']; ?></p>
|
||||
<?php if (Yii::app()->moduleManager->isEnabled($moduleId)) : ?>
|
||||
<?php echo CHtml::link(Yii::t('base', 'Disable'), array('//admin/module/disable', 'moduleId' => $moduleId), array('class' => 'btn btn-sm btn-primary', 'onClick' => 'return moduleDisableWarning()')); ?>
|
||||
|
||||
<?php if (isset($moduleDefinition['configRoute']) && $moduleDefinition['configRoute'] != "") : ?>
|
||||
<?php echo CHtml::link(Yii::t('AdminModule.base', 'Configure'), array($moduleDefinition['configRoute']), array('class' => 'btn btn-default btn-sm')); ?>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php echo CHtml::link(Yii::t('base', 'Enable'), array('//admin/module/enable', 'moduleId' => $moduleId), array('class' => 'btn btn-sm btn-primary')); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Start: Module update message for the future -->
|
||||
<!-- <br>
|
||||
<div class="alert alert-warning">
|
||||
New Update for this module is available! <a href="#">See details</a>
|
||||
</div>-->
|
||||
<!-- End: Module update message for the future -->
|
||||
<hr>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><?php echo $module->getName(); ?>
|
||||
<small>
|
||||
<?php if ($module->isEnabled()) : ?>
|
||||
<span
|
||||
class="label label-success"><?php echo Yii::t('SpaceModule.base', 'Activated'); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</small>
|
||||
</h4>
|
||||
|
||||
<p><?php echo $module->getDescription(); ?></p>
|
||||
|
||||
</div>
|
||||
<p><small>
|
||||
<?php if ($module->isEnabled()) : ?>
|
||||
<?php echo CHtml::link(Yii::t('AdminModule.modules', 'Disable'), array('//admin/module/disable', 'moduleId' => $moduleId)); ?>
|
||||
|
||||
<div class="tab-pane" id="core">
|
||||
|
||||
|
||||
<?php foreach (Yii::app()->moduleManager->getRegisteredModules() as $moduleDefinition) : ?>
|
||||
|
||||
<?php if ($moduleDefinition['isCoreModule']) : ?>
|
||||
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="<?php echo Yii::app()->baseUrl; ?>/uploads/profile_image/default_module.jpg">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><?php echo $moduleDefinition['title']; ?></h4>
|
||||
|
||||
<p><?php echo $moduleDefinition['description']; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<?php if ($module->getConfigUrl()) : ?>
|
||||
· <?php echo CHtml::link(Yii::t('AdminModule.modules', 'Configure'), $module->getConfigUrl()); ?>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php echo CHtml::link(Yii::t('AdminModule.modules', 'Enable'), array('//admin/module/enable', 'moduleId' => $moduleId)); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!--
|
||||
· <?php echo CHtml::link(Yii::t('AdminModule.modules', 'Uninstall'), array('//admin/module/uninstall', 'moduleId' => $moduleId)); ?>
|
||||
-->
|
||||
|
||||
<!--
|
||||
· <a href="#"> Details</a>
|
||||
· <a href="#"> Uninstall</a>
|
||||
-->
|
||||
</small></p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$('#moduleTabs a').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
})
|
||||
|
||||
|
||||
function moduleDisableWarning() {
|
||||
return confirm("<?php echo Yii::t('AdminModule.base', 'Are you really sure?\nAll module specific content will be ***DELETED***!'); ?>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
@ -6,14 +6,16 @@
|
||||
* @package humhub.modules_core.comment
|
||||
* @since 0.5
|
||||
*/
|
||||
class CommentModule extends CWebModule {
|
||||
class CommentModule extends HWebModule
|
||||
{
|
||||
|
||||
/**
|
||||
* On content deletion make sure to delete all its comments
|
||||
*
|
||||
* @param CEvent $event
|
||||
*/
|
||||
public static function onContentDelete($event) {
|
||||
public static function onContentDelete($event)
|
||||
{
|
||||
|
||||
foreach (Comment::model()->findAllByAttributes(array('object_model' => get_class($event->sender), 'object_id' => $event->sender->id)) as $comment) {
|
||||
$comment->delete();
|
||||
@ -25,7 +27,8 @@ class CommentModule extends CWebModule {
|
||||
*
|
||||
* @param CEvent $event
|
||||
*/
|
||||
public static function onUserDelete($event) {
|
||||
public static function onUserDelete($event)
|
||||
{
|
||||
|
||||
foreach (Comment::model()->findAllByAttributes(array('created_by' => $event->sender->id)) as $comment) {
|
||||
$comment->delete();
|
||||
@ -38,7 +41,8 @@ class CommentModule extends CWebModule {
|
||||
*
|
||||
* @param CEvent $event
|
||||
*/
|
||||
public static function onIntegrityCheck($event) {
|
||||
public static function onIntegrityCheck($event)
|
||||
{
|
||||
|
||||
$integrityChecker = $event->sender;
|
||||
$integrityChecker->showTestHeadline("Validating Comment Module (" . Comment::model()->count() . " entries)");
|
||||
@ -59,13 +63,9 @@ class CommentModule extends CWebModule {
|
||||
*
|
||||
* @param CEvent $event
|
||||
*/
|
||||
public static function onWallEntryLinksInit($event) {
|
||||
|
||||
$event->sender->addWidget('application.modules_core.comment.widgets.CommentLinkWidget', array(
|
||||
'modelName' => $event->sender->object->content->object_model,
|
||||
'modelId' => $event->sender->object->content->object_id,
|
||||
), array('sortOrder' => 10)
|
||||
);
|
||||
public static function onWallEntryLinksInit($event)
|
||||
{
|
||||
$event->sender->addWidget('application.modules_core.comment.widgets.CommentLinkWidget', array('object' => $event->sender->object), array('sortOrder' => 10));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,13 +73,9 @@ class CommentModule extends CWebModule {
|
||||
*
|
||||
* @param CEvent $event
|
||||
*/
|
||||
public static function onWallEntryAddonInit($event) {
|
||||
|
||||
$event->sender->addWidget('application.modules_core.comment.widgets.CommentsWidget', array(
|
||||
'modelName' => $event->sender->object->content->object_model,
|
||||
'modelId' => $event->sender->object->content->object_id,
|
||||
), array('sortOrder' => 20)
|
||||
);
|
||||
public static function onWallEntryAddonInit($event)
|
||||
{
|
||||
$event->sender->addWidget('application.modules_core.comment.widgets.CommentsWidget', array('object' => $event->sender->object), array('sortOrder' => 20));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'comment',
|
||||
'title' => Yii::t('CommentModule.base', 'Comments'),
|
||||
'description' => Yii::t('CommentModule.base', 'Comments core module.'),
|
||||
'class' => 'application.modules_core.comment.CommentModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
@ -6,7 +6,8 @@
|
||||
* @package humhub.modules_core.comment.controllers
|
||||
* @since 0.5
|
||||
*/
|
||||
class CommentController extends Controller {
|
||||
class CommentController extends Controller
|
||||
{
|
||||
|
||||
// Used by loadTargetModel() to avoid multiple loading
|
||||
private $cachedLoadedTarget = null;
|
||||
@ -14,7 +15,8 @@ class CommentController extends Controller {
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters() {
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl', // perform access control for CRUD operations
|
||||
);
|
||||
@ -25,7 +27,8 @@ class CommentController extends Controller {
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules() {
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow', // allow authenticated user to perform 'create' and 'update' actions
|
||||
'users' => array('@'),
|
||||
@ -42,7 +45,8 @@ class CommentController extends Controller {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
private function loadTargetModel() {
|
||||
private function loadTargetModel()
|
||||
{
|
||||
|
||||
// Fast lane
|
||||
if ($this->cachedLoadedTarget != null)
|
||||
@ -83,7 +87,8 @@ class CommentController extends Controller {
|
||||
/**
|
||||
* Returns a List of all Comments belong to this Model
|
||||
*/
|
||||
public function actionShow() {
|
||||
public function actionShow()
|
||||
{
|
||||
|
||||
$target = $this->loadTargetModel();
|
||||
|
||||
@ -101,10 +106,31 @@ class CommentController extends Controller {
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
public function actionShowPopup()
|
||||
{
|
||||
|
||||
$target = $this->loadTargetModel();
|
||||
|
||||
$output = "";
|
||||
|
||||
// Get new current comments
|
||||
$comments = Comment::model()->findAllByAttributes(array('object_model' => get_class($target), 'object_id' => $target->id));
|
||||
|
||||
foreach ($comments as $comment) {
|
||||
$output .= $this->widget('application.modules_core.comment.widgets.ShowCommentWidget', array('comment' => $comment), true);
|
||||
}
|
||||
|
||||
|
||||
$id = get_class($target) . "_" . $target->id;
|
||||
$this->renderPartial('show', array('object' => $target, 'output' => $output, 'id' => $id), false, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles AJAX Post Request to submit new Comment
|
||||
*/
|
||||
public function actionPost() {
|
||||
public function actionPost()
|
||||
{
|
||||
|
||||
$this->forcePostRequest();
|
||||
$target = $this->loadTargetModel();
|
||||
@ -151,7 +177,8 @@ class CommentController extends Controller {
|
||||
* Handles AJAX Request for Comment Deletion.
|
||||
* Currently this is only allowed for the Comment Owner.
|
||||
*/
|
||||
public function actionDelete() {
|
||||
public function actionDelete()
|
||||
{
|
||||
|
||||
$this->forcePostRequest();
|
||||
$target = $this->loadTargetModel();
|
||||
@ -175,4 +202,4 @@ class CommentController extends Controller {
|
||||
return $this->actionShow();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
9
protected/modules_core/comment/module.json
Normal file
9
protected/modules_core/comment/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "comment",
|
||||
"name": "Comment",
|
||||
"description": "Comments Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
47
protected/modules_core/comment/views/comment/show.php
Normal file
47
protected/modules_core/comment/views/comment/show.php
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"
|
||||
id="myModalLabel">
|
||||
<?php echo Yii::t('CommentModule.base', 'Comments'); ?>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="userlist-content">
|
||||
<div class="well well-small" id="comment_<?php echo $id; ?>">
|
||||
<div class="comment" id="comments_area_<?php echo $id; ?>">
|
||||
<?php echo $output; ?>
|
||||
</div>
|
||||
<?php $this->widget('application.modules_core.comment.widgets.CommentFormWidget', array('object' => $object)); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/*
|
||||
* Modal handling by close event
|
||||
*/
|
||||
$('#globalModal').on('hidden.bs.modal', function(e) {
|
||||
|
||||
// Reload whole page (to see changes on it)
|
||||
//window.location.reload();
|
||||
|
||||
// just close modal and reset modal content to default (shows the loader)
|
||||
$('#globalModal').html('<div class="modal-dialog"><div class="modal-content"><div class="modal-body"><div class="loader"></div></div></div></div>');
|
||||
})
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// scroll to top of list
|
||||
$(".modal-body").animate({scrollTop: 0}, 200);
|
||||
|
||||
</script>
|
||||
|
||||
|
57
protected/modules_core/comment/widgets/CommentFormWidget.php
Normal file
57
protected/modules_core/comment/widgets/CommentFormWidget.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HumHub
|
||||
* Copyright © 2014 The HumHub Project
|
||||
*
|
||||
* The texts of the GNU Affero General Public License with an additional
|
||||
* permission and of our proprietary license can be found at and
|
||||
* in the LICENSE file you have received along with this program.
|
||||
*
|
||||
* According to our dual licensing model, this program can be used either
|
||||
* under the terms of the GNU Affero General Public License, version 3,
|
||||
* or under a proprietary license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This widget is used include the comments functionality to a wall entry.
|
||||
*
|
||||
* Normally it shows a excerpt of all comments, but provides the functionality
|
||||
* to show all comments.
|
||||
*
|
||||
* @package humhub.modules_core.comment
|
||||
* @since 0.5
|
||||
*/
|
||||
class CommentFormWidget extends HWidget
|
||||
{
|
||||
|
||||
/**
|
||||
* Content Object
|
||||
*/
|
||||
public $object;
|
||||
|
||||
/**
|
||||
* Executes the widget.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
$modelName = $this->object->content->object_model;
|
||||
$modelId = $this->object->content->object_id;
|
||||
$id = $modelName . "_" . $modelId;
|
||||
|
||||
$this->render('form', array(
|
||||
'modelName' => $modelName,
|
||||
'modelId' => $modelId,
|
||||
'id' => $modelName . "_" . $modelId,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -6,27 +6,52 @@
|
||||
* @package humhub.modules_core.comment
|
||||
* @since 0.5
|
||||
*/
|
||||
class CommentLinkWidget extends HWidget {
|
||||
class CommentLinkWidget extends HWidget
|
||||
{
|
||||
|
||||
const MODE_INLINE = 'inline';
|
||||
const MODE_POPUP = 'popup';
|
||||
|
||||
/**
|
||||
* Model Name (e.g. Post) to identify which posts we shall show
|
||||
*
|
||||
* @var String
|
||||
* Content Object
|
||||
*/
|
||||
public $modelName = "";
|
||||
public $object;
|
||||
|
||||
/**
|
||||
* The primary key of the model
|
||||
*
|
||||
* @var String
|
||||
* Mode
|
||||
*
|
||||
* inline: Show comments on the same page with CommentsWidget (default)
|
||||
* popup: Open comments popup, display only link
|
||||
*
|
||||
* @var type
|
||||
*/
|
||||
public $modelId = "";
|
||||
public $mode;
|
||||
|
||||
/**
|
||||
* Executes the widget.
|
||||
*/
|
||||
public function run() {
|
||||
$this->render('commentsLink', array('id' => $this->modelName . "_" . $this->modelId));
|
||||
public function run()
|
||||
{
|
||||
|
||||
if ($this->mode == "")
|
||||
$this->mode = self::MODE_INLINE;
|
||||
|
||||
$this->render('link', array(
|
||||
'id' => $this->object->content->object_model . "_" . $this->object->content->object_id,
|
||||
'mode' => $this->mode,
|
||||
'objectModel' => $this->object->content->object_model,
|
||||
'objectId' => $this->object->content->object_id,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns count of existing comments
|
||||
*
|
||||
* @return Int Comment Count
|
||||
*/
|
||||
public function getCommentsCount()
|
||||
{
|
||||
return Comment::GetCommentCount(get_class($this->object), $this->object->getPrimaryKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,42 +9,40 @@
|
||||
* @package humhub.modules_core.comment
|
||||
* @since 0.5
|
||||
*/
|
||||
class CommentsWidget extends HWidget {
|
||||
class CommentsWidget extends HWidget
|
||||
{
|
||||
|
||||
/**
|
||||
* Model Name (e.g. Post) to identify which posts we shall show
|
||||
*
|
||||
* @var String
|
||||
* Content Object
|
||||
*/
|
||||
public $modelName = "";
|
||||
|
||||
/**
|
||||
* The primary key of the Model
|
||||
*
|
||||
* @var Integer
|
||||
*/
|
||||
public $modelId = "";
|
||||
public $object;
|
||||
|
||||
/**
|
||||
* Executes the widget.
|
||||
*/
|
||||
public function run() {
|
||||
public function run()
|
||||
{
|
||||
|
||||
$modelName = $this->object->content->object_model;
|
||||
$modelId = $this->object->content->object_id;
|
||||
|
||||
// Indicates that the number of comments was limited
|
||||
$isLimited = false;
|
||||
|
||||
// Count all Comments
|
||||
$commentCount = Comment::GetCommentCount($this->modelName, $this->modelId);
|
||||
$comments = Comment::GetCommentsLimited($this->modelName, $this->modelId, 2);
|
||||
$commentCount = Comment::GetCommentCount($modelName, $modelId);
|
||||
$comments = Comment::GetCommentsLimited($modelName, $modelId, 2);
|
||||
|
||||
if ($commentCount > 2)
|
||||
$isLimited = true;
|
||||
|
||||
$this->render('comments', array(
|
||||
'object' => $this->object,
|
||||
|
||||
'comments' => $comments,
|
||||
'modelName' => $this->modelName,
|
||||
'modelId' => $this->modelId,
|
||||
'id' => $this->modelName . "_" . $this->modelId,
|
||||
'modelName' => $modelName,
|
||||
'modelId' => $modelId,
|
||||
'id' => $modelName . "_" . $modelId,
|
||||
'isLimited' => $isLimited,
|
||||
'total' => $commentCount
|
||||
)
|
||||
|
@ -25,7 +25,7 @@
|
||||
$reloadUrl = CHtml::normalizeUrl(Yii::app()->createUrl('comment/comment/show', array('model' => $modelName, 'id' => $modelId)));
|
||||
echo HHtml::ajaxLink($showAllLabel, $reloadUrl, array(
|
||||
'success' => "function(html) { $('#comments_area_" . $id . "').html(html); }",
|
||||
), array('id' => $id . "_showAllLink", 'class' => 'show show-all-link'));
|
||||
), array('id' => $id . "_showAllLink", 'class' => 'show show-all-link'));
|
||||
?>
|
||||
<hr>
|
||||
<?php endif; ?>
|
||||
@ -35,87 +35,16 @@
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php /* BEGIN: Comment Create Form */ ?>
|
||||
<div id="comment_create_form_<?php echo $id; ?>">
|
||||
<?php echo CHtml::form("#"); ?>
|
||||
<?php echo CHtml::hiddenField('model', $modelName); ?>
|
||||
<?php echo CHtml::hiddenField('id', $modelId); ?>
|
||||
<?php $this->widget('application.modules_core.comment.widgets.CommentFormWidget', array('object' => $object)); ?>
|
||||
|
||||
|
||||
|
||||
<?php echo CHtml::textArea("message", Yii::t('CommentModule.base', ""), array('id' => 'newCommentForm_' . $id, 'rows' => '1', 'class' => 'form-control autosize commentForm', 'placeholder' => 'Write a new comment...')); ?>
|
||||
|
||||
<?php
|
||||
|
||||
/* Modify textarea for mention input */
|
||||
$this->widget('application.widgets.MentionWidget', array(
|
||||
'element' => '#newCommentForm_' . $id,
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo HHtml::ajaxSubmitButton(Yii::t('base', 'Post'), CHtml::normalizeUrl(array('/comment/comment/post')), array(
|
||||
'beforeSend' => "function() {
|
||||
$('#newCommentForm_" . $id . "').blur();
|
||||
}",
|
||||
'success' => "function(html) {
|
||||
$('#comments_area_" . $id . "').html(html);
|
||||
$('#newCommentForm_" . $id . "').val('').trigger('autosize.resize');
|
||||
$.fn.mention.reset('#newCommentForm_" . $id . "');
|
||||
|
||||
}",
|
||||
), array(
|
||||
'id' => "comment_create_post_" . $id,
|
||||
'class' => 'btn btn-small btn-primary',
|
||||
'style' => 'position: absolute; top: -3000px; left: -3000px;',
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
<?php echo Chtml::endForm(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php /* END: Comment Create Form */ ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
<?php if (count($comments) != 0) { ?>
|
||||
// make comments visible at this point to fixing autoresizing issue for textareas in Firefox
|
||||
$('#comment_<?php echo $id; ?>').show();
|
||||
<?php } ?>
|
||||
|
||||
// Fire click event for comment button by typing enter
|
||||
$('#newCommentForm_<?php echo $id; ?>').keydown(function (event) {
|
||||
|
||||
if (event.keyCode == 13) {
|
||||
|
||||
|
||||
if ($.fn.mention.defaults.stateUserList == false) {
|
||||
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
|
||||
$('#comment_create_post_<?php echo $id; ?>').focus();
|
||||
$('#comment_create_post_<?php echo $id; ?>').click();
|
||||
|
||||
// empty input
|
||||
//$(this).val('');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return event.returnValue;
|
||||
|
||||
});
|
||||
|
||||
// set the size for one row (Firefox)
|
||||
$('#newCommentForm_<?php echo $id; ?>').css({height: '36px'});
|
||||
|
||||
// add autosize function to input
|
||||
$('.autosize').autosize();
|
||||
|
||||
<?php if (count($comments) != 0) { ?>
|
||||
// make comments visible at this point to fixing autoresizing issue for textareas in Firefox
|
||||
$('#comment_<?php echo $id; ?>').show();
|
||||
<?php } ?>
|
||||
|
||||
</script>
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This view is used by the CommentLinkWidget to inject a link to the
|
||||
* Wall Entry Controls.
|
||||
*
|
||||
* The primary goal is to show the new comment input when clicking it.
|
||||
* The Input Form is defined in comments.php
|
||||
*
|
||||
* @property String $id is a unique Id on Model and PK e.g. (Post_1)
|
||||
*
|
||||
* @package humhub.modules_core.comment
|
||||
* @since 0.5
|
||||
*/
|
||||
echo CHtml::link(Yii::t('CommentModule.base', "Comment") . "", "#", array('onClick' => "$('#comment_" . $id . "').show();$('#newCommentForm_" . $id . "').focus();return false;"));
|
||||
?>
|
81
protected/modules_core/comment/widgets/views/form.php
Normal file
81
protected/modules_core/comment/widgets/views/form.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
?>
|
||||
|
||||
|
||||
<?php /* BEGIN: Comment Create Form */ ?>
|
||||
<div id="comment_create_form_<?php echo $id; ?>">
|
||||
|
||||
<?php echo CHtml::form("#"); ?>
|
||||
<?php echo CHtml::hiddenField('model', $modelName); ?>
|
||||
<?php echo CHtml::hiddenField('id', $modelId); ?>
|
||||
|
||||
<?php echo CHtml::textArea("message", Yii::t('CommentModule.base', ""), array('id' => 'newCommentForm_' . $id, 'rows' => '1', 'class' => 'form-control autosize commentForm', 'placeholder' => 'Write a new comment...')); ?>
|
||||
|
||||
<?php
|
||||
/* Modify textarea for mention input */
|
||||
$this->widget('application.widgets.MentionWidget', array(
|
||||
'element' => '#newCommentForm_' . $id,
|
||||
));
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo HHtml::ajaxSubmitButton(Yii::t('base', 'Post'), CHtml::normalizeUrl(array('/comment/comment/post')), array(
|
||||
'beforeSend' => "function() {
|
||||
$('#newCommentForm_" . $id . "').blur();
|
||||
}",
|
||||
'success' => "function(html) {
|
||||
|
||||
$('#comments_area_" . $id . "').html(html);
|
||||
$('#newCommentForm_" . $id . "').val('').trigger('autosize.resize');
|
||||
$.fn.mention.reset('#newCommentForm_" . $id . "');
|
||||
|
||||
}",
|
||||
), array(
|
||||
'id' => "comment_create_post_" . $id,
|
||||
'class' => 'btn btn-small btn-primary',
|
||||
'style' => 'position: absolute; top: -3000px; left: -3000px;',
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
<?php echo Chtml::endForm(); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Fire click event for comment button by typing enter
|
||||
$('#newCommentForm_<?php echo $id; ?>').keydown(function(event) {
|
||||
|
||||
if (event.keyCode == 13) {
|
||||
|
||||
if ($.fn.mention.defaults.stateUserList == false) {
|
||||
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
|
||||
$('#comment_create_post_<?php echo $id; ?>').focus();
|
||||
$('#comment_create_post_<?php echo $id; ?>').click();
|
||||
|
||||
// empty input
|
||||
//$(this).val('');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event.returnValue;
|
||||
|
||||
});
|
||||
|
||||
// set the size for one row (Firefox)
|
||||
$('#newCommentForm_<?php echo $id; ?>').css({height: '36px'});
|
||||
|
||||
// add autosize function to input
|
||||
$('.autosize').autosize();
|
||||
|
||||
</script>
|
23
protected/modules_core/comment/widgets/views/link.php
Normal file
23
protected/modules_core/comment/widgets/views/link.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* This view is used by the CommentLinkWidget to inject a link to the
|
||||
* Wall Entry Controls.
|
||||
*
|
||||
* The primary goal is to show the new comment input when clicking it.
|
||||
* The Input Form is defined in comments.php
|
||||
*
|
||||
* @property String $id is a unique Id on Model and PK e.g. (Post_1)
|
||||
*
|
||||
* @package humhub.modules_core.comment
|
||||
* @since 0.5
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php if ($mode == CommentLinkWidget::MODE_POPUP): ?>
|
||||
<a href="<?php echo $this->createUrl('//comment/comment/showPopup', array('model' => $objectModel, 'id' => $objectId)); ?>"
|
||||
class="tt" data-toggle="modal"
|
||||
data-placement="top" title="" data-target="#globalModal"
|
||||
data-original-title="Comments">Comments (<?php echo $this->getCommentsCount(); ?>)</a>
|
||||
<?php else: ?>
|
||||
<?php echo CHtml::link(Yii::t('CommentModule.base', "Comment") . "", "#", array('onClick' => "$('#comment_" . $id . "').show();$('#newCommentForm_" . $id . "').focus();return false;")); ?>
|
||||
<?php endif; ?>
|
@ -9,47 +9,41 @@
|
||||
* @since 0.5
|
||||
*/
|
||||
?>
|
||||
<div class="media">
|
||||
<a href="<?php echo $user->getUrl(); ?>" class="pull-left">
|
||||
<img class="media-object img-rounded user-image" src="<?php echo $user->getProfileImage()->getUrl(); ?>" width="40"
|
||||
height="40" alt="40x40" data-src="holder.js/40x40" style="width: 40px; height: 40px;"/>
|
||||
</a>
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><a href="<?php echo $user->getProfileUrl(); ?>"><?php echo $user->displayName; ?></a> <small><?php echo HHtml::timeago($comment->created_at); ?></small></h4>
|
||||
<span class="content">
|
||||
<?php
|
||||
print HHtml::enrichText($comment->message);
|
||||
//print nl2br($comment->message);
|
||||
?>
|
||||
</span>
|
||||
<div class="media">
|
||||
<a href="<?php echo $user->getUrl(); ?>" class="pull-left">
|
||||
<img class="media-object img-rounded user-image" src="<?php echo $user->getProfileImage()->getUrl(); ?>" width="40"
|
||||
height="40" alt="40x40" data-src="holder.js/40x40" style="width: 40px; height: 40px;"/>
|
||||
</a>
|
||||
|
||||
<?php //echo CHtml::link(Yii::t('base', "Delete"), '#'); ?>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><a href="<?php echo $user->getProfileUrl(); ?>"><?php echo $user->displayName; ?></a> <small><?php echo HHtml::timeago($comment->created_at); ?></small></h4>
|
||||
<span class="content">
|
||||
<?php
|
||||
print HHtml::enrichText($comment->message);
|
||||
?>
|
||||
</span>
|
||||
|
||||
<div class="wall-entry-controls">
|
||||
<?php
|
||||
if ($comment->canDelete()) {
|
||||
$deleteUrl = CHtml::normalizeUrl(array('//comment/comment/delete', 'model' => $comment->object_model, 'id' => $comment->object_id, 'cid' => $comment->id));
|
||||
echo HHtml::ajaxLink(Yii::t('base', 'Delete'), $deleteUrl, array(
|
||||
'type' => 'POST',
|
||||
'data' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken),
|
||||
'success' => "function(html) {
|
||||
$('#comments_area_" . $comment->object_model . "_" . $comment->object_id . "').html(html);
|
||||
}",
|
||||
<?php //echo CHtml::link(Yii::t('base', "Delete"), '#'); ?>
|
||||
|
||||
<div class="wall-entry-controls">
|
||||
<?php
|
||||
if ($comment->canDelete()) {
|
||||
$deleteUrl = CHtml::normalizeUrl(array('//comment/comment/delete', 'model' => $comment->object_model, 'id' => $comment->object_id, 'cid' => $comment->id));
|
||||
echo HHtml::ajaxLink(Yii::t('base', 'Delete'), $deleteUrl, array(
|
||||
'type' => 'POST',
|
||||
'data' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken),
|
||||
'success' => "function(html) { $('#comments_area_" . $comment->object_model . "_" . $comment->object_id . "').html(html); }",
|
||||
), array(
|
||||
'id' => "comment_delete_link" . $comment->id
|
||||
'id' => "comment_delete_link" . $comment->id
|
||||
)
|
||||
);
|
||||
echo " - ";
|
||||
}
|
||||
?>
|
||||
);
|
||||
echo " - ";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php Yii::app()->getController()->widget('application.modules_core.like.widgets.LikeLinkWidget', array('object' => $comment)); ?>
|
||||
</div>
|
||||
<?php Yii::app()->getController()->widget('application.modules_core.like.widgets.LikeLinkWidget', array('object' => $comment)); ?>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<!-- Maybe use another, smaller version here? -->
|
||||
<?php
|
||||
//Yii::app()->getController()->widget('application.modules_core.like.widgets.ShowLikesWidget', array('object' => $comment));
|
||||
?>
|
||||
</div>
|
||||
<hr>
|
||||
|
@ -6,12 +6,14 @@
|
||||
* @package humhub.modules_core.dashboard
|
||||
* @since 0.5
|
||||
*/
|
||||
class DashboardModule extends CWebModule {
|
||||
class DashboardModule extends HWebModule
|
||||
{
|
||||
|
||||
/**
|
||||
* Inits the Module
|
||||
*/
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->setImport(array(
|
||||
));
|
||||
@ -23,18 +25,17 @@ class DashboardModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onTopMenuInit($event) {
|
||||
public static function onTopMenuInit($event)
|
||||
{
|
||||
|
||||
// Is Module enabled on this workspace?
|
||||
if (Yii::app()->moduleManager->isEnabled('dashboard')) {
|
||||
$event->sender->addItem(array(
|
||||
'label' => Yii::t('DashboardModule.base', 'Dashboard'),
|
||||
'icon' => '<i class="fa fa-tachometer"></i>',
|
||||
'url' => Yii::app()->createUrl('//dashboard/dashboard'),
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'dashboard'),
|
||||
));
|
||||
}
|
||||
$event->sender->addItem(array(
|
||||
'label' => Yii::t('DashboardModule.base', 'Dashboard'),
|
||||
'icon' => '<i class="fa fa-tachometer"></i>',
|
||||
'url' => Yii::app()->createUrl('//dashboard/dashboard'),
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'dashboard'),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'dashboard',
|
||||
'title' => Yii::t('DashboardModule.base', 'Dashboard'),
|
||||
'description' => Yii::t('DashboardModule.base', 'Dashboard at main navigation.'),
|
||||
'class' => 'application.modules_core.dashboard.DashboardModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
9
protected/modules_core/dashboard/module.json
Normal file
9
protected/modules_core/dashboard/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "dashboard",
|
||||
"name": "Dashboard",
|
||||
"description": "Dashboard Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -9,12 +9,14 @@
|
||||
* @package humhub.modules_core.directory
|
||||
* @since 0.5
|
||||
*/
|
||||
class DirectoryModule extends CWebModule {
|
||||
class DirectoryModule extends HWebModule
|
||||
{
|
||||
|
||||
/**
|
||||
* Inits the Module
|
||||
*/
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->setImport(array(
|
||||
));
|
||||
@ -26,18 +28,15 @@ class DirectoryModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onTopMenuInit($event) {
|
||||
|
||||
// Is Module enabled on this workspace?
|
||||
if (Yii::app()->moduleManager->isEnabled('directory')) {
|
||||
$event->sender->addItem(array(
|
||||
'label' => Yii::t('DirectoryModule.base', 'Directory'),
|
||||
'icon' => '<i class="fa fa-book"></i>',
|
||||
'url' => Yii::app()->createUrl('//directory/directory'),
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'directory'),
|
||||
));
|
||||
}
|
||||
public static function onTopMenuInit($event)
|
||||
{
|
||||
$event->sender->addItem(array(
|
||||
'label' => Yii::t('DirectoryModule.base', 'Directory'),
|
||||
'icon' => '<i class="fa fa-book"></i>',
|
||||
'url' => Yii::app()->createUrl('//directory/directory'),
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'directory'),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'directory',
|
||||
'title' => Yii::t('DirectoryModule.base', 'Directory'),
|
||||
'description' => Yii::t('DirectoryModule.base', 'Adds an directory to the main navigation.'),
|
||||
'class' => 'application.modules_core.directory.DirectoryModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
9
protected/modules_core/directory/module.json
Normal file
9
protected/modules_core/directory/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "directory",
|
||||
"name": "Directory",
|
||||
"description": "Directory Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* @package humhub.modules_core.file
|
||||
* @since 0.5
|
||||
*/
|
||||
class FileModule extends CWebModule {
|
||||
class FileModule extends HWebModule {
|
||||
|
||||
/**
|
||||
* Inits the Module
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'file',
|
||||
'title' => Yii::t('FileModule.base', 'File'),
|
||||
'description' => Yii::t('FileModule.base', 'Files core module.'),
|
||||
'class' => 'application.modules_core.file.FileModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
@ -44,6 +44,7 @@ class FileController extends Controller {
|
||||
foreach (CUploadedFile::getInstancesByName('files') as $cFile) {
|
||||
$files[] = $this->handleFileUpload($cFile);
|
||||
}
|
||||
|
||||
|
||||
return $this->renderJson(array('files' => $files));
|
||||
}
|
||||
|
9
protected/modules_core/file/module.json
Normal file
9
protected/modules_core/file/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "file",
|
||||
"name": "File",
|
||||
"description": "File Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
* @package humhub.modules_core.installer
|
||||
* @since 0.5
|
||||
*/
|
||||
class InstallerModule extends CWebModule {
|
||||
class InstallerModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
$this->setLayoutPath(Yii::getPathOfAlias('installer.views'));
|
||||
|
@ -4,8 +4,6 @@
|
||||
if (!Yii::app()->params['installed']) {
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'installer',
|
||||
'title' => Yii::t('InstallerModule.base', 'Installer'),
|
||||
'description' => Yii::t('InstallerModule.base', 'Initial Installer.'),
|
||||
'class' => 'application.modules_core.installer.InstallerModule',
|
||||
'isCoreModule' => true,
|
||||
));
|
||||
|
9
protected/modules_core/installer/module.json
Normal file
9
protected/modules_core/installer/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "installer",
|
||||
"name": "Installer",
|
||||
"description": "Installer Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -7,9 +7,11 @@
|
||||
* @package humhub.modules_core.like
|
||||
* @since 0.5
|
||||
*/
|
||||
class LikeModule extends CWebModule {
|
||||
class LikeModule extends HWebModule
|
||||
{
|
||||
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
// import the module-level models and components
|
||||
$this->setImport(array(
|
||||
'like.models.*',
|
||||
@ -17,21 +19,13 @@ class LikeModule extends CWebModule {
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Install some event listeners for the module
|
||||
*/
|
||||
public static function install() {
|
||||
|
||||
// Install Event Handler & Behaviors
|
||||
Yii::app()->interceptor->preattachEventHandler('User', 'onBeforeDelete', array('LikeInterceptor', 'onUserDelete'));
|
||||
}
|
||||
|
||||
/**
|
||||
* On User delete, also delete all comments
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onUserDelete($event) {
|
||||
public static function onUserDelete($event)
|
||||
{
|
||||
|
||||
foreach (Like::model()->findAllByAttributes(array('created_by' => $event->sender->id)) as $like) {
|
||||
$like->delete();
|
||||
@ -43,7 +37,8 @@ class LikeModule extends CWebModule {
|
||||
/**
|
||||
* On delete of a content object, also delete all corresponding likes
|
||||
*/
|
||||
public static function onContentDelete($event) {
|
||||
public static function onContentDelete($event)
|
||||
{
|
||||
|
||||
foreach (Like::model()->findAllByAttributes(array('object_id' => $event->sender->id, 'object_model' => get_class($event->sender))) as $like) {
|
||||
$like->delete();
|
||||
@ -54,7 +49,8 @@ class LikeModule extends CWebModule {
|
||||
* On delete of a content addon object, e.g. a comment
|
||||
* also delete all likes
|
||||
*/
|
||||
public static function onContentAddonDelete($event) {
|
||||
public static function onContentAddonDelete($event)
|
||||
{
|
||||
|
||||
foreach (Like::model()->findAllByAttributes(array('object_id' => $event->sender->id, 'object_model' => get_class($event->sender))) as $like) {
|
||||
$like->delete();
|
||||
@ -66,10 +62,11 @@ class LikeModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onIntegrityCheck($event) {
|
||||
public static function onIntegrityCheck($event)
|
||||
{
|
||||
|
||||
$integrityChecker = $event->sender;
|
||||
$integrityChecker->showTestHeadline("Validating Like Module (".Like::model()->count()." entries)");
|
||||
$integrityChecker->showTestHeadline("Validating Like Module (" . Like::model()->count() . " entries)");
|
||||
|
||||
foreach (Like::model()->findAll() as $l) {
|
||||
if ($l->source === null) {
|
||||
@ -85,7 +82,8 @@ class LikeModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onWallEntryLinksInit($event) {
|
||||
public static function onWallEntryLinksInit($event)
|
||||
{
|
||||
|
||||
$event->sender->addWidget('application.modules_core.like.widgets.LikeLinkWidget', array('object' => $event->sender->object), array('sortOrder' => 10));
|
||||
}
|
||||
@ -95,8 +93,9 @@ class LikeModule extends CWebModule {
|
||||
*
|
||||
* @param type $event
|
||||
*/
|
||||
public static function onWallEntryAddonInit($event) {
|
||||
|
||||
public static function onWallEntryAddonInit($event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'like',
|
||||
'title' => Yii::t('LikeModule.base', 'Likes'),
|
||||
'description' => Yii::t('LikeModule.base', 'Likes core module.'),
|
||||
'class' => 'application.modules_core.like.LikeModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
9
protected/modules_core/like/module.json
Normal file
9
protected/modules_core/like/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "like",
|
||||
"name": "Like",
|
||||
"description": "Like Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* @package humhub.modules_core.notification
|
||||
* @since 0.5
|
||||
*/
|
||||
class NotificationModule extends CWebModule {
|
||||
class NotificationModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
$this->setImport(array(
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'notification',
|
||||
'title' => Yii::t('NotificationModule.base', 'Notification'),
|
||||
'description' => Yii::t('FeedbackModule.base', 'Basic subsystem for notifications.'),
|
||||
'class' => 'application.modules_core.notification.NotificationModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
9
protected/modules_core/notification/module.json
Normal file
9
protected/modules_core/notification/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "notification",
|
||||
"name": "Notifications",
|
||||
"description": "Notification Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* @package humhub.modules_core.post
|
||||
* @since 0.5
|
||||
*/
|
||||
class PostModule extends CWebModule {
|
||||
class PostModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'post',
|
||||
'title' => Yii::t('PostModule.base', 'Post'),
|
||||
'description' => Yii::t('PostModule.base', 'Basic subsystem for workspace/user post.'),
|
||||
'class' => 'application.modules_core.post.PostModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
9
protected/modules_core/post/module.json
Normal file
9
protected/modules_core/post/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "post",
|
||||
"name": "Post",
|
||||
"description": "Post Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -69,6 +69,16 @@ class SpaceControllerBehavior extends CBehavior {
|
||||
return $space;
|
||||
}
|
||||
|
||||
|
||||
public function createContainerUrl($route, $params = array(), $ampersand = '&') {
|
||||
|
||||
if (!isset($params['sguid'])) {
|
||||
$params['sguid'] = $this->getSpace()->guid;
|
||||
}
|
||||
|
||||
return $this->owner->createUrl($route, $params, $ampersand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @package humhub.modules_core.space
|
||||
* @since 0.5
|
||||
*/
|
||||
class SpaceModule extends CWebModule {
|
||||
class SpaceModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
$this->setImport(array(
|
||||
|
87
protected/modules_core/space/SpaceModuleBehavior.php
Normal file
87
protected/modules_core/space/SpaceModuleBehavior.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HumHub
|
||||
* Copyright © 2014 The HumHub Project
|
||||
*
|
||||
* The texts of the GNU Affero General Public License with an additional
|
||||
* permission and of our proprietary license can be found at and
|
||||
* in the LICENSE file you have received along with this program.
|
||||
*
|
||||
* According to our dual licensing model, this program can be used either
|
||||
* under the terms of the GNU Affero General Public License, version 3,
|
||||
* or under a proprietary license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This behavior should attached to a HWebModule when it provides a space module.
|
||||
*
|
||||
* @author luke
|
||||
*/
|
||||
class SpaceModuleBehavior extends CBehavior
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns current space by context
|
||||
*
|
||||
* @return Space
|
||||
*/
|
||||
public function getSpace()
|
||||
{
|
||||
return Yii::app()->getController()->getSpace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this module is enabled on given space.
|
||||
*
|
||||
* @param Space $space
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSpaceModuleEnabled(Space $space = null)
|
||||
{
|
||||
if ($space == null) {
|
||||
$space = $this->getSpace();
|
||||
}
|
||||
|
||||
return $space->isModuleEnabled($this->getOwner()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns module name for spaces of your module.
|
||||
* You may want to overwrite it in your module.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getSpaceModuleName()
|
||||
{
|
||||
return $this->getOwner()->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns module description for spaces of your module.
|
||||
* You may want to overwrite it in your module.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getSpaceModuleDescription()
|
||||
{
|
||||
return $this->getOwner()->getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns module config url for spaces of your module.
|
||||
* You may want to overwrite it in your module.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getSpaceModuleConfigUrl(Space $space)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'space',
|
||||
'title' => Yii::t('SpaceModule.base', 'Spaces'),
|
||||
'description' => Yii::t('SpaceModule.base', 'Spaces core'),
|
||||
'class' => 'application.modules_core.space.SpaceModule',
|
||||
'import' => array(
|
||||
'application.modules_core.space.widgets.*',
|
||||
|
@ -32,7 +32,8 @@
|
||||
* @package humhub.modules_core.space.models
|
||||
* @since 0.5
|
||||
*/
|
||||
class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
class Space extends HActiveRecordContentContainer implements ISearchable
|
||||
{
|
||||
|
||||
// Join Policies
|
||||
const JOIN_POLICY_NONE = 0; // No Self Join Possible
|
||||
@ -54,7 +55,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function behaviors() {
|
||||
public function behaviors()
|
||||
{
|
||||
return array(
|
||||
'HGuidBehavior' => array(
|
||||
'class' => 'application.behaviors.HGuidBehavior',
|
||||
@ -67,21 +69,24 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param string $className active record class name.
|
||||
* @return Space the static model class
|
||||
*/
|
||||
public static function model($className = __CLASS__) {
|
||||
public static function model($className = __CLASS__)
|
||||
{
|
||||
return parent::model($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the associated database table name
|
||||
*/
|
||||
public function tableName() {
|
||||
public function tableName()
|
||||
{
|
||||
return 'space';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array validation rules for model attributes.
|
||||
*/
|
||||
public function rules() {
|
||||
public function rules()
|
||||
{
|
||||
|
||||
$rules = array();
|
||||
|
||||
@ -124,7 +129,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* @return array relational rules.
|
||||
*/
|
||||
public function relations() {
|
||||
public function relations()
|
||||
{
|
||||
// NOTE: you may need to adjust the relation name and the related
|
||||
// class name for the relations automatically generated below.
|
||||
return array(
|
||||
@ -154,7 +160,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* @return array customized attribute labels (name=>label)
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'id' => 'ID',
|
||||
'wall_id' => 'Wall',
|
||||
@ -178,7 +185,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* Scopes
|
||||
*
|
||||
*/
|
||||
public function scopes() {
|
||||
public function scopes()
|
||||
{
|
||||
return array(
|
||||
// Coming soon
|
||||
'active' => array(
|
||||
@ -200,7 +208,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $limit
|
||||
* @return User
|
||||
*/
|
||||
public function recently($limit = 10) {
|
||||
public function recently($limit = 10)
|
||||
{
|
||||
$this->getDbCriteria()->mergeWith(array(
|
||||
'order' => 'created_at DESC',
|
||||
'limit' => $limit,
|
||||
@ -212,7 +221,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* Retrieves a list of models based on the current search/filter conditions.
|
||||
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
|
||||
*/
|
||||
public function search() {
|
||||
public function search()
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->compare('id', $this->id);
|
||||
$criteria->compare('wall_id', $this->wall_id);
|
||||
@ -238,7 +248,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* After Save Addons
|
||||
*/
|
||||
protected function afterSave() {
|
||||
protected function afterSave()
|
||||
{
|
||||
|
||||
// Try To Delete Search Model
|
||||
HSearch::getInstance()->deleteModel($this);
|
||||
@ -254,13 +265,14 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Before deletion of a Space
|
||||
*/
|
||||
protected function beforeDelete() {
|
||||
protected function beforeDelete()
|
||||
{
|
||||
if (parent::beforeDelete()) {
|
||||
|
||||
foreach (SpaceSetting::model()->findAllByAttributes(array('space_id'=>$this->id)) as $spaceSetting) {
|
||||
foreach (SpaceSetting::model()->findAllByAttributes(array('space_id' => $this->id)) as $spaceSetting) {
|
||||
$spaceSetting->delete();
|
||||
}
|
||||
|
||||
|
||||
HSearch::getInstance()->deleteModel($this);
|
||||
return true;
|
||||
}
|
||||
@ -270,7 +282,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* Delete a Space
|
||||
*
|
||||
*/
|
||||
public function delete() {
|
||||
public function delete()
|
||||
{
|
||||
|
||||
$this->getProfileImage()->delete();
|
||||
|
||||
@ -314,7 +327,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function insert($attributes = null) {
|
||||
public function insert($attributes = null)
|
||||
{
|
||||
|
||||
if (parent::insert($attributes)) {
|
||||
|
||||
@ -340,7 +354,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @param $userId User Id of User
|
||||
*/
|
||||
public function isFollowedBy($userId = "") {
|
||||
public function isFollowedBy($userId = "")
|
||||
{
|
||||
// Take current userid if none is given
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -358,7 +373,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @param $userId User Id of User
|
||||
*/
|
||||
public function canJoin($userId = "") {
|
||||
public function canJoin($userId = "")
|
||||
{
|
||||
// Take current userid if none is given
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -379,7 +395,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @param $userId User Id of User
|
||||
*/
|
||||
public function canJoinFree($userId = "") {
|
||||
public function canJoinFree($userId = "")
|
||||
{
|
||||
// Take current userid if none is given
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -401,7 +418,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function canWrite($userId = "") {
|
||||
public function canWrite($userId = "")
|
||||
{
|
||||
|
||||
// No writes allowed for archived workspaces
|
||||
if ($this->status == Space::STATUS_ARCHIVED)
|
||||
@ -424,7 +442,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function isMember($userId = "") {
|
||||
public function isMember($userId = "")
|
||||
{
|
||||
|
||||
// Take current userid if none is given
|
||||
if ($userId == "")
|
||||
@ -446,7 +465,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function isAdmin($userId = "") {
|
||||
public function isAdmin($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == 0)
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -471,7 +491,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function setOwner($userId = "") {
|
||||
public function setOwner($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == 0)
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -489,7 +510,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getOwner() {
|
||||
public function getOwner()
|
||||
{
|
||||
|
||||
$user = User::model()->findByPk($this->created_by);
|
||||
return $user;
|
||||
@ -501,7 +523,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function setAdmin($userId = "") {
|
||||
public function setAdmin($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == 0)
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -521,7 +544,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function canInvite($userId = "") {
|
||||
public function canInvite($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == 0)
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -545,7 +569,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @return type
|
||||
*/
|
||||
public function canShare($userId = "") {
|
||||
public function canShare($userId = "")
|
||||
{
|
||||
|
||||
// There is no visibility for guests, so sharing is useless anyway.
|
||||
if ($this->visibility != Space::VISIBILITY_ALL)
|
||||
@ -567,7 +592,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* If none Record is found, null is given
|
||||
*/
|
||||
public function getMembership($userId = "") {
|
||||
public function getMembership($userId = "")
|
||||
{
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
|
||||
@ -586,7 +612,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Is given User owner of this Space
|
||||
*/
|
||||
public function isOwner($userId = "") {
|
||||
public function isOwner($userId = "")
|
||||
{
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
|
||||
@ -602,7 +629,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @param $userId UserId of User to Remove
|
||||
*/
|
||||
public function removeMember($userId = "") {
|
||||
public function removeMember($userId = "")
|
||||
{
|
||||
|
||||
if ($userId == "")
|
||||
$userId = Yii::app()->user->id;
|
||||
@ -656,7 +684,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @param type $userId
|
||||
*/
|
||||
public function addMember($userId) {
|
||||
public function addMember($userId)
|
||||
{
|
||||
|
||||
$user = User::model()->findByPk($userId);
|
||||
|
||||
@ -718,7 +747,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @param type $originatorUserId
|
||||
*/
|
||||
public function inviteMember($userId, $originatorUserId) {
|
||||
public function inviteMember($userId, $originatorUserId)
|
||||
{
|
||||
|
||||
$membership = $this->getMembership($userId);
|
||||
|
||||
@ -765,7 +795,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $email
|
||||
* @param type $originatorUserId
|
||||
*/
|
||||
public function inviteMemberByEMail($email, $originatorUserId) {
|
||||
public function inviteMemberByEMail($email, $originatorUserId)
|
||||
{
|
||||
|
||||
// Invalid E-Mail
|
||||
$validator = new CEmailValidator;
|
||||
@ -808,7 +839,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param type $userId
|
||||
* @param type $message
|
||||
*/
|
||||
public function requestMembership($userId, $message = "") {
|
||||
public function requestMembership($userId, $message = "")
|
||||
{
|
||||
|
||||
// Add Membership
|
||||
$membership = new SpaceMembership;
|
||||
@ -828,7 +860,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* Checks if there is already a wall created for this workspace.
|
||||
* If not, a new wall will be created and automatically assigned.
|
||||
*/
|
||||
public function checkWall() {
|
||||
public function checkWall()
|
||||
{
|
||||
|
||||
// Check if wall exists
|
||||
if ($this->wall == null) {
|
||||
@ -856,7 +889,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getSearchAttributes() {
|
||||
public function getSearchAttributes()
|
||||
{
|
||||
|
||||
return array(
|
||||
// Assignment
|
||||
@ -876,14 +910,16 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Returns the Search Result Output
|
||||
*/
|
||||
public function getSearchResult() {
|
||||
public function getSearchResult()
|
||||
{
|
||||
return Yii::app()->getController()->widget('application.modules_core.space.widgets.SpaceSearchResultWidget', array('space' => $this), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Admins of this Space
|
||||
*/
|
||||
public function getAdmins() {
|
||||
public function getAdmins()
|
||||
{
|
||||
|
||||
$admins = array();
|
||||
|
||||
@ -900,7 +936,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* Counts all Content Items related to this workspace except of Activities.
|
||||
* Additonally Comments (normally ContentAddon) will be included.
|
||||
*/
|
||||
public function countItems() {
|
||||
public function countItems()
|
||||
{
|
||||
|
||||
$count = 0;
|
||||
$count += Content::model()->countByAttributes(array('space_id' => $this->id), 'object_model != :activityModel', array(':activityModel' => 'Activity'));
|
||||
@ -914,7 +951,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @return Integer
|
||||
*/
|
||||
public function countPosts() {
|
||||
public function countPosts()
|
||||
{
|
||||
/*
|
||||
$criteria = new CDbCriteria();
|
||||
$criteria->condition = "content.space_id=:space_id";
|
||||
@ -927,7 +965,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Sets Comments Count for this workspace
|
||||
*/
|
||||
public function getCommentCount() {
|
||||
public function getCommentCount()
|
||||
{
|
||||
$cacheId = "workspaceCommentCount_" . $this->id;
|
||||
$cacheValue = Yii::app()->cache->get($cacheId);
|
||||
|
||||
@ -943,7 +982,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Returns an array with assigned Tags
|
||||
*/
|
||||
public function getTags() {
|
||||
public function getTags()
|
||||
{
|
||||
|
||||
// split tags string into individual tags
|
||||
return preg_split("/[;,# ]+/", $this->tags);
|
||||
@ -952,7 +992,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Archive this Space
|
||||
*/
|
||||
public function archive() {
|
||||
public function archive()
|
||||
{
|
||||
$this->status = self::STATUS_ARCHIVED;
|
||||
$this->save();
|
||||
}
|
||||
@ -960,7 +1001,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Unarchive this Space
|
||||
*/
|
||||
public function unarchive() {
|
||||
public function unarchive()
|
||||
{
|
||||
$this->status = self::STATUS_ENABLED;
|
||||
$this->save();
|
||||
}
|
||||
@ -971,32 +1013,29 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
* @param array $parameters
|
||||
* @return string url
|
||||
*/
|
||||
public function getUrl($parameters = array()) {
|
||||
public function getUrl($parameters = array())
|
||||
{
|
||||
$parameters['sguid'] = $this->guid;
|
||||
return Yii::app()->createUrl('//space/space', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available workspace modules
|
||||
* Collects a list of all modules which are available for this space
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableModules() {
|
||||
public function getAvailableModules()
|
||||
{
|
||||
|
||||
$availableModules = array();
|
||||
$modules = array();
|
||||
|
||||
// Loop over all enabled modules
|
||||
foreach (Yii::app()->moduleManager->getEnabledModules() as $moduleId => $definition) {
|
||||
|
||||
if (isset($definition['spaceModules']) && is_array($definition['spaceModules'])) {
|
||||
|
||||
foreach ($definition['spaceModules'] as $moduleId => $moduleInfo) {
|
||||
$availableModules[$moduleId] = $moduleInfo;
|
||||
}
|
||||
foreach (Yii::app()->moduleManager->getEnabledModules() as $moduleId => $module) {
|
||||
if (array_key_exists('SpaceModuleBehavior', $module->behaviors())) {
|
||||
$modules[$module->getId()] = $module;
|
||||
}
|
||||
}
|
||||
|
||||
return $availableModules;
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1004,7 +1043,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEnabledModules() {
|
||||
public function getEnabledModules()
|
||||
{
|
||||
|
||||
$modules = array();
|
||||
foreach (SpaceApplicationModule::model()->findAllByAttributes(array('space_id' => $this->id)) as $SpaceModule) {
|
||||
@ -1014,6 +1054,7 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
$modules[] = $moduleId;
|
||||
}
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
@ -1022,7 +1063,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
*
|
||||
* @param type $moduleId
|
||||
*/
|
||||
public function isModuleEnabled($moduleId) {
|
||||
public function isModuleEnabled($moduleId)
|
||||
{
|
||||
|
||||
// Not enabled globally
|
||||
if (!array_key_exists($moduleId, $this->getAvailableModules())) {
|
||||
@ -1041,7 +1083,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
/**
|
||||
* Installs a Module
|
||||
*/
|
||||
public function installModule($moduleId) {
|
||||
public function installModule($moduleId)
|
||||
{
|
||||
|
||||
// Not enabled globally
|
||||
if (!array_key_exists($moduleId, $this->getAvailableModules())) {
|
||||
@ -1068,14 +1111,16 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onInstallModule($event) {
|
||||
public function onInstallModule($event)
|
||||
{
|
||||
$this->raiseEvent('onInstallModule', $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls a Module
|
||||
*/
|
||||
public function uninstallModule($moduleId) {
|
||||
public function uninstallModule($moduleId)
|
||||
{
|
||||
|
||||
// Not enabled globally
|
||||
if (!array_key_exists($moduleId, $this->getAvailableModules())) {
|
||||
@ -1098,7 +1143,8 @@ class Space extends HActiveRecordContentContainer implements ISearchable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onUninstallModule($event) {
|
||||
public function onUninstallModule($event)
|
||||
{
|
||||
$this->raiseEvent('onUninstallModule', $event);
|
||||
}
|
||||
|
||||
|
9
protected/modules_core/space/module.json
Normal file
9
protected/modules_core/space/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "space",
|
||||
"name": "Space",
|
||||
"description": "Space Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -1,181 +1,32 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<?php echo Yii::t('SpaceModule.base', '<strong>Space</strong> modules'); ?>
|
||||
<?php echo Yii::t('SpaceModule.base', 'Modules'); ?>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?php echo Yii::t('SpaceModule.base', 'Enhance this space with modules.'); ?><br/><br/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="alert alert-default text-center">
|
||||
<img class="img-rounded" data-src="holder.js/48x48" alt="48x48" style="width: 48px; height: 48px;"
|
||||
src="http://localhost/notes-icon.png">
|
||||
<br/>
|
||||
|
||||
<div class="info">
|
||||
<strong>Notes</strong><br/>
|
||||
Edit with other user at notes <br/>
|
||||
</div>
|
||||
<a href="" class="btn btn-primary btn-sm">Disable</a> <a href="" class="btn btn-default btn-sm">Configure</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="alert alert-default text-center" style="position: relative;">
|
||||
|
||||
<ul class="nav nav-pills preferences text-left">
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style="font-size: 14px;"><i
|
||||
class="fa fa-info-circle"></i></a>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li><a href="#" class="panel-collapse"
|
||||
style="font-size: 13px !important;">Description</a></li>
|
||||
<li><a href="#" class="panel-collapse" style="font-size: 13px !important;">Module
|
||||
website</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<img class="img-rounded" data-src="holder.js/48x48" alt="48x48" style="width: 48px; height: 48px;"
|
||||
src="https://dt8kf6553cww8.cloudfront.net/static/images/brand/glyph@2x-vflJ1vxbq.png">
|
||||
<br/>
|
||||
|
||||
<div class="info">
|
||||
<strong>Dropbox</strong><br/>
|
||||
Edit with other user at notes <br/>
|
||||
</div>
|
||||
<a href="" class="btn btn-info">Enable</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="alert alert-default text-center">
|
||||
<img class="img-rounded" data-src="holder.js/48x48" alt="48x48" style="width: 48px; height: 48px;"
|
||||
src="http://screenshots.de.sftcdn.net/blog/de/2012/04/Google_Drive_Logo_lrg-580x461.jpg">
|
||||
<br/>
|
||||
|
||||
<div class="info">
|
||||
<strong>Google Drive</strong><br/>
|
||||
Edit with other user at notes <br/>
|
||||
</div>
|
||||
<a href="" class="btn btn-info">Enable</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="alert alert-default text-center">
|
||||
<img class="img-rounded" data-src="holder.js/48x48" alt="48x48" style="width: 48px; height: 48px;"
|
||||
src="https://lh3.ggpht.com/si0cgkp2rkVX5JhhBYrtZ4cy2I1hZcrx8aiz-v8MjvPykfhT7-YAM2B8MNi0OCF9AQ=w300">
|
||||
<br/>
|
||||
|
||||
<div class="info">
|
||||
<strong>Evernote</strong><br/>
|
||||
Edit with other user at notes <br/>
|
||||
</div>
|
||||
<a href="" class="btn btn-info">Enable</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo Yii::t('SpaceModule.base', 'Enhance this space with modules.'); ?><br>
|
||||
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<div class="alert alert-default">
|
||||
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/48x48" alt="48x48"
|
||||
style="width: 48px; height: 48px;" src="http://localhost/notes-icon.png">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">Notes 2.0.2<a class="btn btn-primary pull-right"
|
||||
onclick="return moduleDisableWarning()"
|
||||
href="/humhub/index.php?r=space/admin/disableModule&moduleId=notes&sguid=8f775bd0-f4cd-4aee-b983-537f80ab4075">Enable</a>
|
||||
</h4>
|
||||
|
||||
<p>Integrates etherpads to your space.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="alert alert-default">
|
||||
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="https://dt8kf6553cww8.cloudfront.net/static/images/brand/glyph@2x-vflJ1vxbq.png">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">Dropbox<a class="btn btn-primary pull-right"
|
||||
onclick="return moduleDisableWarning()"
|
||||
href="/humhub/index.php?r=space/admin/disableModule&moduleId=notes&sguid=8f775bd0-f4cd-4aee-b983-537f80ab4075">Enable</a>
|
||||
</h4>
|
||||
|
||||
<p>Integrates etherpads to your space.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="alert alert-default">
|
||||
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="http://screenshots.de.sftcdn.net/blog/de/2012/04/Google_Drive_Logo_lrg-580x461.jpg">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">Google Drive<a class="btn btn-primary pull-right"
|
||||
onclick="return moduleDisableWarning()"
|
||||
href="/humhub/index.php?r=space/admin/disableModule&moduleId=notes&sguid=8f775bd0-f4cd-4aee-b983-537f80ab4075">Enable</a>
|
||||
</h4>
|
||||
|
||||
<p>Integrates etherpads to your space.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="alert alert-default">
|
||||
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="https://lh3.ggpht.com/si0cgkp2rkVX5JhhBYrtZ4cy2I1hZcrx8aiz-v8MjvPykfhT7-YAM2B8MNi0OCF9AQ=w300">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">Evernote<a class="btn btn-primary pull-right"
|
||||
onclick="return moduleDisableWarning()"
|
||||
href="/humhub/index.php?r=space/admin/disableModule&moduleId=notes&sguid=8f775bd0-f4cd-4aee-b983-537f80ab4075">Enable</a>
|
||||
</h4>
|
||||
|
||||
<p>Integrates etherpads to your space. <br/>
|
||||
<a href="">Description</a> | <a href="">Author website</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php foreach ($this->getSpace()->getAvailableModules() as $moduleId => $moduleInfo): ?>
|
||||
<?php foreach ($this->getSpace()->getAvailableModules() as $moduleId => $module): ?>
|
||||
<div class="media">
|
||||
<img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
|
||||
style="width: 64px; height: 64px;"
|
||||
src="<?php echo Yii::app()->baseUrl; ?>/uploads/profile_image/default_module.jpg">
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><?php echo $moduleInfo['title']; ?>
|
||||
<h4 class="media-heading"><?php echo $module->getSpaceModuleName(); ?>
|
||||
<?php if ($this->getSpace()->isModuleEnabled($moduleId)) : ?>
|
||||
<small><span
|
||||
class="label label-success"><?php echo Yii::t('SpaceModule.base', 'Activated'); ?></span>
|
||||
</small>
|
||||
<?php endif; ?>
|
||||
<small><span class="label label-success"><?php echo Yii::t('SpaceModule.base', 'Activated'); ?></span></small>
|
||||
<?php endif; ?>
|
||||
</h4>
|
||||
|
||||
<p><?php echo $moduleInfo['description']; ?></p>
|
||||
<p><?php echo $module->getSpaceModuleDescription(); ?></p>
|
||||
<?php if ($this->getSpace()->isModuleEnabled($moduleId)) : ?>
|
||||
<?php echo CHtml::link(Yii::t('base', 'Disable'), array('//space/admin/disableModule', 'moduleId' => $moduleId, 'sguid' => $this->getSpace()->guid), array('class' => 'btn btn-sm btn-primary', 'onClick' => 'return moduleDisableWarning()')); ?>
|
||||
|
||||
<?php if (isset($moduleInfo['configRoute'])) : ?>
|
||||
<?php if ($module->getSpaceModuleConfigUrl($this->getSpace()) != "") : ?>
|
||||
<?php
|
||||
echo CHtml::link(
|
||||
Yii::t('SpaceModule.base', 'Configure'), $this->createUrl($moduleInfo['configRoute'], array('sguid' => $this->getSpace()->guid)), array('class' => 'btn btn-default')
|
||||
Yii::t('SpaceModule.base', 'Configure'), $module->getSpaceModuleConfigUrl($this->getSpace()), array('class' => 'btn btn-default')
|
||||
);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @since 0.5
|
||||
* @author Luke
|
||||
*/
|
||||
class UserModule extends CWebModule {
|
||||
class UserModule extends HWebModule {
|
||||
|
||||
public function init() {
|
||||
$this->setImport(array(
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'user',
|
||||
'title' => Yii::t('UserModule.base', 'User'),
|
||||
'description' => Yii::t('SpaceModule.base', 'Users core'),
|
||||
'class' => 'application.modules_core.user.UserModule',
|
||||
'isCoreModule' => true,
|
||||
'import' => array(
|
||||
|
@ -24,9 +24,11 @@
|
||||
* @package humhub.modules_core.user.controllers
|
||||
* @since 0.5
|
||||
*/
|
||||
class AuthController extends Controller {
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
public function actions() {
|
||||
public function actions()
|
||||
{
|
||||
return array(
|
||||
// captcha action renders the CAPTCHA image displayed on the password recovery page
|
||||
'captcha' => array(
|
||||
@ -39,7 +41,8 @@ class AuthController extends Controller {
|
||||
/**
|
||||
* Displays the login page
|
||||
*/
|
||||
public function actionLogin() {
|
||||
public function actionLogin()
|
||||
{
|
||||
|
||||
// If user is already logged in, redirect him to the dashboard
|
||||
if (!Yii::app()->user->isGuest) {
|
||||
@ -58,7 +61,7 @@ class AuthController extends Controller {
|
||||
$model = new AccountLoginForm;
|
||||
|
||||
//TODO: Solve this via events!
|
||||
if (Yii::app()->moduleManager->isEnabled('zsso')) {
|
||||
if (Yii::app()->getModule('zsso') != null) {
|
||||
ZSsoModule::beforeActionLogin();
|
||||
}
|
||||
|
||||
@ -130,7 +133,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @todo check local auth_mode
|
||||
*/
|
||||
public function actionRecoverPassword() {
|
||||
public function actionRecoverPassword()
|
||||
{
|
||||
|
||||
// Disable Sublayout
|
||||
$this->subLayout = "";
|
||||
@ -169,7 +173,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* This action is called after e-mail validation.
|
||||
*/
|
||||
public function actionCreateAccount() {
|
||||
public function actionCreateAccount()
|
||||
{
|
||||
|
||||
$_POST = Yii::app()->input->stripClean($_POST);
|
||||
|
||||
@ -212,7 +217,7 @@ class AuthController extends Controller {
|
||||
'type' => (HSetting::Get('defaultUserGroup', 'authentication_internal')) ? 'hidden' : 'dropdownlist',
|
||||
'class' => 'form-control',
|
||||
'items' => CHtml::listData($groupModels, 'id', 'name'),
|
||||
'value' => (HSetting::Get('defaultUserGroup', 'authentication_internal')) ? HSetting::Get('defaultUserGroup', 'authentication_internal') : '',
|
||||
'value' => (HSetting::Get('defaultUserGroup', 'authentication_internal')) ? HSetting::Get('defaultUserGroup', 'authentication_internal') : '',
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -287,7 +292,8 @@ class AuthController extends Controller {
|
||||
* Logouts a User
|
||||
*
|
||||
*/
|
||||
public function actionLogout() {
|
||||
public function actionLogout()
|
||||
{
|
||||
|
||||
Yii::app()->user->logout();
|
||||
|
||||
@ -302,7 +308,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* Can also used as a kind of keep alive.
|
||||
*/
|
||||
public function actionCheckSessionState() {
|
||||
public function actionCheckSessionState()
|
||||
{
|
||||
$out = array();
|
||||
$out['loggedIn'] = false;
|
||||
|
||||
@ -318,7 +325,8 @@ class AuthController extends Controller {
|
||||
* Allows third party applications to convert a valid sessionId
|
||||
* into a username.
|
||||
*/
|
||||
public function actionGetSessionUserJson() {
|
||||
public function actionGetSessionUserJson()
|
||||
{
|
||||
|
||||
$sessionId = Yii::app()->request->getQuery('sessionId');
|
||||
|
||||
|
@ -204,7 +204,7 @@ class Profile extends HActiveRecord
|
||||
{
|
||||
$fields = array();
|
||||
|
||||
foreach (ProfileField::model()->findAllByAttributes(array('profile_field_category_id' => $category->id), array('order' => 'sort_order')) as $field) {
|
||||
foreach (ProfileField::model()->findAllByAttributes(array('profile_field_category_id' => $category->id, 'visible' => 1), array('order' => 'sort_order')) as $field) {
|
||||
|
||||
if ($field->getUserValue($this->user) != "") {
|
||||
$fields[] = $field;
|
||||
|
9
protected/modules_core/user/module.json
Normal file
9
protected/modules_core/user/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "user",
|
||||
"name": "User",
|
||||
"description": "User Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
* @since 0.5
|
||||
* @author Luke
|
||||
*/
|
||||
class WallModule extends CWebModule {
|
||||
class WallModule extends HWebModule {
|
||||
|
||||
/**
|
||||
* Inits the wall module
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Yii::app()->moduleManager->register(array(
|
||||
'id' => 'wall',
|
||||
'title' => Yii::t('WallModule.base', 'Wall'),
|
||||
'description' => Yii::t('WallModule.base', 'Adds the wall/streaming core module.'),
|
||||
'class' => 'application.modules_core.wall.WallModule',
|
||||
'import' => array(
|
||||
'application.modules_core.wall.*',
|
||||
|
9
protected/modules_core/wall/module.json
Normal file
9
protected/modules_core/wall/module.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "wall",
|
||||
"name": "Wall",
|
||||
"description": "Wall Core",
|
||||
"keywords": [
|
||||
"core"
|
||||
],
|
||||
"version": "1.0"
|
||||
}
|
@ -60,17 +60,11 @@ class MentionWidget extends HWidget
|
||||
Yii::app()->clientScript->registerScriptFile($assetPrefix . '/jquery.mention.js', CClientScript::POS_END);
|
||||
Yii::app()->clientScript->registerCssFile($assetPrefix . '/mention.css');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays / Run the Widget
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->render('mention', array(
|
||||
'element' => $this->element,
|
||||
'userSearchUrl' => $this->userSearchUrl,
|
||||
));
|
||||
|
||||
$js = '$("'.$this->element.'").mention({searchUrl: "'.$this->userSearchUrl.'"})';
|
||||
Yii::app()->clientScript->registerScript('mentioning_'.$this->element, $js);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
$('<?php echo $element; ?>').mention({
|
||||
searchUrl: '<?php echo $userSearchUrl; ?>'
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user