Exemplo n.º 1
0
 /**
  * Automatically loads the by content or content addon given by parameter.
  * className & id
  *
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $modelClass = Yii::$app->request->get('contentModel');
     $pk = (int) Yii::$app->request->get('contentId');
     // Fixme
     if ($modelClass == '') {
         $modelClass = Yii::$app->request->post('contentModel');
         $pk = (int) Yii::$app->request->post('contentId');
     }
     if ($modelClass == "" || $pk == "") {
         throw new HttpException(500, 'Model & ID parameter required!');
     }
     \humhub\libs\Helpers::CheckClassType($modelClass, array(ContentAddonActiveRecord::className(), ContentActiveRecord::className()));
     $target = $modelClass::findOne(['id' => $pk]);
     if ($target === null) {
         throw new HttpException(500, 'Could not find underlying content or content addon record!');
     }
     if ($target instanceof ContentAddonActiveRecord) {
         $this->parentContentAddon = $target;
         $this->parentContent = $target->getSource();
     } else {
         $this->parentContent = $target;
     }
     if (!$this->parentContent->content->canRead()) {
         throw new HttpException(403, 'Access denied!');
     }
     $this->contentModel = get_class($target);
     $this->contentId = $target->getPrimaryKey();
     return parent::beforeAction($action);
 }
Exemplo n.º 2
0
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => array(ContentActiveRecord::className())], ['class' => \humhub\components\behaviors\GUID::className()]];
 }
Exemplo n.º 3
0
<?php

use humhub\modules\search\engine\Search;
use humhub\modules\user\Events;
use humhub\commands\IntegrityController;
use humhub\modules\content\components\ContentAddonActiveRecord;
use humhub\modules\content\components\ContentActiveRecord;
use humhub\commands\CronController;
return ['id' => 'user', 'class' => \humhub\modules\user\Module::className(), 'isCoreModule' => true, 'urlManagerRules' => [['class' => 'humhub\\modules\\user\\components\\UrlRule']], 'events' => [['class' => Search::className(), 'event' => Search::EVENT_ON_REBUILD, 'callback' => array(Events::className(), 'onSearchRebuild')], ['class' => ContentActiveRecord::className(), 'event' => ContentActiveRecord::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onContentDelete')], ['class' => ContentAddonActiveRecord::className(), 'event' => ContentAddonActiveRecord::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onContentDelete')], ['class' => IntegrityController::className(), 'event' => IntegrityController::EVENT_ON_RUN, 'callback' => array(Events::className(), 'onIntegrityCheck')], ['class' => CronController::className(), 'event' => CronController::EVENT_ON_HOURLY_RUN, 'callback' => [Events::className(), 'onHourlyCron']]]];
Exemplo n.º 4
0
<?php

use humhub\modules\content\Events;
use humhub\commands\CronController;
use humhub\commands\IntegrityController;
use humhub\modules\content\widgets\WallEntryControls;
use humhub\modules\content\widgets\WallEntryAddons;
use humhub\modules\user\models\User;
use humhub\modules\space\models\Space;
use humhub\modules\search\engine\Search;
use humhub\modules\content\components\ContentActiveRecord;
return ['id' => 'content', 'class' => \humhub\modules\content\Module::className(), 'isCoreModule' => true, 'events' => array(['class' => IntegrityController::className(), 'event' => IntegrityController::EVENT_ON_RUN, 'callback' => array(Events::className(), 'onIntegrityCheck')], ['class' => WallEntryControls::className(), 'event' => WallEntryControls::EVENT_INIT, 'callback' => array(Events::className(), 'onWallEntryControlsInit')], ['class' => WallEntryAddons::className(), 'event' => WallEntryAddons::EVENT_INIT, 'callback' => array(Events::className(), 'onWallEntryAddonInit')], ['class' => CronController::className(), 'event' => CronController::EVENT_ON_HOURLY_RUN, 'callback' => [Events::className(), 'onCronRun']], ['class' => CronController::className(), 'event' => CronController::EVENT_ON_DAILY_RUN, 'callback' => [Events::className(), 'onCronRun']], ['class' => User::className(), 'event' => User::EVENT_BEFORE_DELETE, 'callback' => [Events::className(), 'onUserDelete']], ['class' => Space::className(), 'event' => User::EVENT_BEFORE_DELETE, 'callback' => [Events::className(), 'onSpaceDelete']], ['class' => Search::className(), 'event' => Search::EVENT_ON_REBUILD, 'callback' => [Events::className(), 'onSearchRebuild']], ['class' => ContentActiveRecord::className(), 'event' => ContentActiveRecord::EVENT_AFTER_INSERT, 'callback' => [Events::className(), 'onContentActiveRecordSave']], ['class' => ContentActiveRecord::className(), 'event' => ContentActiveRecord::EVENT_AFTER_UPDATE, 'callback' => [Events::className(), 'onContentActiveRecordSave']], ['class' => ContentActiveRecord::className(), 'event' => ContentActiveRecord::EVENT_AFTER_DELETE, 'callback' => [Events::className(), 'onContentActiveRecordDelete']])];
Exemplo n.º 5
0
<?php

use humhub\modules\comment\Events;
use humhub\modules\user\models\User;
use humhub\modules\content\components\ContentActiveRecord;
use humhub\commands\IntegrityController;
use humhub\modules\content\widgets\WallEntryAddons;
use humhub\modules\content\widgets\WallEntryLinks;
return ['id' => 'comment', 'class' => \humhub\modules\comment\Module::className(), 'isCoreModule' => true, 'events' => array(array('class' => User::className(), 'event' => User::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onUserDelete')), array('class' => ContentActiveRecord::className(), 'event' => ContentActiveRecord::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onContentDelete')), array('class' => IntegrityController::className(), 'event' => IntegrityController::EVENT_ON_RUN, 'callback' => array(Events::className(), 'onIntegrityCheck')), array('class' => WallEntryLinks::className(), 'event' => WallEntryLinks::EVENT_INIT, 'callback' => array(Events::className(), 'onWallEntryLinksInit')), array('class' => WallEntryAddons::className(), 'event' => WallEntryAddons::EVENT_INIT, 'callback' => array(Events::className(), 'onWallEntryAddonInit')))];
Exemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => [ContentActiveRecord::className(), ContentContainerActiveRecord::className(), ContentAddonActiveRecord::className()]]];
 }