/**
  * @inheritdoc
  */
 public function getContentContainerConfigUrl(ContentContainerActiveRecord $container)
 {
     if ($container instanceof User) {
         return $container->createUrl('/dropbox/user');
     }
     return "";
 }
 /**
  * @inheritdoc
  */
 public function can(BasePermission $permission)
 {
     $groupId = $this->contentContainer->getUserGroup();
     if ($this->getGroupState($groupId, $permission) == BasePermission::STATE_ALLOW) {
         return true;
     }
     return false;
 }
 /**
  * Limits the returned records to the given ContentContainer.
  * 
  * @param ContentContainerActiveRecord $container
  * @return \humhub\modules\content\components\ActiveQueryContent
  * @throws \yii\base\Exception
  */
 public function contentContainer($container)
 {
     $this->joinWith(['content', 'content.user', 'content.space']);
     if ($container->className() == Space::className()) {
         $this->andWhere(['content.space_id' => $container->id]);
     } elseif ($container->className() == User::className()) {
         $this->andWhere(['content.user_id' => $container->id]);
         $this->andWhere('content.space_id IS NULL OR content.space_id = ""');
     } else {
         throw new \yii\base\Exception("Invalid container given!");
     }
     return $this;
 }
 /**
  * Checks if current module is enabled on this content container.
  *
  * @todo Also support submodules
  * @return boolean is current module enabled
  */
 public function checkModuleIsEnabled()
 {
     if ($this->module instanceof ContentContainerModule && $this->contentContainer !== null) {
         return $this->contentContainer->isModuleEnabled($this->module->id);
     }
     return true;
 }
Example #5
0
 /**
  * Creates url to stream BaseStreamAction including placeholders
  * which are replaced and handled by javascript.
  *
  * If a contentContainer is specified it will be used to create the url.
  *
  * @return string
  */
 protected function getStreamUrl()
 {
     $params = array_merge(['limit' => '-limit-', 'filters' => '-filter-', 'sort' => '-sort-', 'from' => '-from-', 'mode' => \humhub\modules\content\components\actions\Stream::MODE_NORMAL], $this->streamActionParams);
     if ($this->contentContainer) {
         return $this->contentContainer->createUrl($this->streamAction, $params);
     } else {
         array_unshift($params, $this->streamAction);
         return Url::to($params);
     }
 }
Example #6
0
 /**
  * After Save Addons
  *
  * @return type
  */
 public function afterSave($insert, $changedAttributes)
 {
     if ($this->status == User::STATUS_ENABLED) {
         Yii::$app->search->update($this);
     } else {
         Yii::$app->search->delete($this);
     }
     if ($insert) {
         if ($this->status == User::STATUS_ENABLED) {
             $this->setUpApproved();
         } else {
             Group::notifyAdminsForUserApproval($this);
         }
         $this->profile->user_id = $this->id;
     }
     if (Yii::$app->user->id == $this->id) {
         Yii::$app->user->setIdentity($this);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     foreach (Setting::findAll(['space_id' => $this->id]) as $spaceSetting) {
         $spaceSetting->delete();
     }
     foreach ($this->getAvailableModules() as $moduleId => $module) {
         if ($this->isModuleEnabled($moduleId)) {
             $this->disableModule($moduleId);
         }
     }
     Yii::$app->search->delete($this);
     $this->getProfileImage()->delete();
     \humhub\modules\user\models\Follow::deleteAll(['object_id' => $this->id, 'object_model' => 'Space']);
     foreach (Membership::findAll(['space_id' => $this->id]) as $spaceMembership) {
         $spaceMembership->delete();
     }
     \humhub\modules\user\models\Invite::deleteAll(['space_invite_id' => $this->id]);
     // When this workspace is used in a group as default workspace, delete the link
     foreach (\humhub\modules\user\models\Group::findAll(['space_id' => $this->id]) as $group) {
         $group->space_id = "";
         $group->save();
     }
     return parent::beforeDelete();
 }
 /**
  * @inheritdoc
  */
 public function getContentContainerConfigUrl(ContentContainerActiveRecord $container)
 {
     return $container->createUrl('/calendar/external-source/index');
 }
 /**
  * Limits the returned records to the given ContentContainer.
  * 
  * @param ContentContainerActiveRecord $container
  * @return \humhub\modules\content\components\ActiveQueryContent
  * @throws \yii\base\Exception
  */
 public function contentContainer($container)
 {
     $this->joinWith(['content', 'content.contentContainer', 'content.createdBy']);
     $this->andWhere(['contentcontainer.pk' => $container->id, 'contentcontainer.class' => $container->className()]);
     return $this;
 }
Example #10
0
 /**
  * After Save Addons
  *
  * @return type
  */
 public function afterSave($insert, $changedAttributes)
 {
     // Make sure we get an direct User model instance
     // (e.g. not UserEditForm) for search rebuild
     $user = User::findOne(['id' => $this->id]);
     if ($this->status == User::STATUS_ENABLED) {
         Yii::$app->search->update($user);
     } else {
         Yii::$app->search->delete($user);
     }
     if ($insert) {
         if ($this->status == User::STATUS_ENABLED) {
             $this->setUpApproved();
         } else {
             Group::notifyAdminsForUserApproval($this);
         }
         $this->profile->user_id = $this->id;
     }
     if (Yii::$app->user->id == $this->id) {
         Yii::$app->user->setIdentity($user);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
Example #11
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => PolymorphicRelation::className(), 'mustBeInstanceOf' => array(ContentContainerActiveRecord::className()), 'classAttribute' => 'class', 'pkAttribute' => 'pk']];
 }
Example #12
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => [ContentActiveRecord::className(), ContentContainerActiveRecord::className(), ContentAddonActiveRecord::className()]]];
 }
 /**
  * @inheritdoc
  */
 public function enableContentContainer(ContentContainerActiveRecord $container)
 {
     $container->setSetting('enableDeadLinkValidation', 0, 'linklist');
     $container->setSetting('enableWidget', 0, 'linklist');
     parent::enableContentContainer($container);
 }