예제 #1
0
 /**
  * Loads Content Addon
  * We also validates that the content addon corresponds to the loaded content.
  *
  * @param string $className
  * @param int $pk
  */
 public function loadContentAddon($className, $pk)
 {
     if (!\humhub\libs\Helpers::CheckClassType($className, ContentAddonActiveRecord::className())) {
         throw new \yii\base\Exception("Given className is not a content addon model!");
     }
     $target = $className::findOne(['id' => $pk]);
     if ($target === null) {
         throw new HttpException(500, 'Could not find content addon record!');
     }
     if ($target->object_model != get_class($this->parentContent) && $target->object_id != $this->parentContent->getPrimaryKey()) {
         throw new HttpException(500, 'Content addon not belongs to given content record!');
     }
     $this->contentAddon = $target;
 }
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         if ($this->content->space !== null) {
             $query = User::find()->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:spaceId AND space_membership.admin_role=1', [':spaceId' => $this->content->space->id])->where(['IS NOT', 'space_membership.space_id', new \yii\db\Expression('NULL')]);
         } else {
             $query = User::find()->where(['super_admin' => 1]);
         }
         $notification = new \humhub\modules\reportcontent\notifications\NewReportAdmin();
         $notification->source = $this;
         $notification->originator = Yii::$app->user->getIdentity();
         $notification->sendBulk($query);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
예제 #3
0
파일: Like.php 프로젝트: kreativmind/humhub
 /**
  * Before Delete, remove LikeCount (Cache) of target object.
  * Remove activity
  */
 public function beforeDelete()
 {
     Yii::$app->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
     return parent::beforeDelete();
 }
예제 #4
0
 /**
  * After Saving of comments, fire an activity
  *
  * @return type
  */
 public function afterSave($insert, $changedAttributes)
 {
     // flush the cache
     $this->flushCache();
     $activity = new \humhub\modules\comment\activities\NewComment();
     $activity->source = $this;
     $activity->create();
     // Handle mentioned users
     // Execute before NewCommentNotification to avoid double notification when mentioned.
     \humhub\modules\user\models\Mentioning::parse($this, $this->message);
     if ($insert) {
         $notification = new \humhub\modules\comment\notifications\NewComment();
         $notification->source = $this;
         $notification->originator = $this->user;
         $notification->sendBulk($this->content->getPolymorphicRelation()->getFollowers(null, true, true));
     }
     $this->updateContentSearch();
     return parent::afterSave($insert, $changedAttributes);
 }
예제 #5
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']]]];
예제 #6
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => [ContentActiveRecord::className(), ContentAddonActiveRecord::className()]]];
 }