/**
  * Creates the given ContentActiveRecord based on given submitted form information.
  * 
  * - Automatically assigns ContentContainer
  * - Access Check
  * - User Notification / File Uploads
  * - Reloads Wall after successfull creation or returns error json
  * 
  * [See guide section](guide:dev-module-stream.md#CreateContentForm)
  * 
  * @param ContentActiveRecord $record
  * @return string json 
  */
 public static function create(ContentActiveRecord $record)
 {
     Yii::$app->response->format = 'json';
     // Set Content Container
     $contentContainer = null;
     $containerClass = Yii::$app->request->post('containerClass');
     $containerGuid = Yii::$app->request->post('containerGuid', "");
     if ($containerClass === User::className()) {
         $contentContainer = User::findOne(['guid' => $containerGuid]);
         $record->content->visibility = 1;
     } elseif ($containerClass === Space::className()) {
         $contentContainer = Space::findOne(['guid' => $containerGuid]);
         $record->content->visibility = Yii::$app->request->post('visibility');
     }
     $record->content->container = $contentContainer;
     // Handle Notify User Features of ContentFormWidget
     // ToDo: Check permissions of user guids
     $userGuids = Yii::$app->request->post('notifyUserInput');
     if ($userGuids != "") {
         foreach (explode(",", $userGuids) as $guid) {
             $user = User::findOne(['guid' => trim($guid)]);
             if ($user) {
                 $record->content->notifyUsersOfNewContent[] = $user;
             }
         }
     }
     // Store List of attached Files to add them after Save
     $record->content->attachFileGuidsAfterSave = Yii::$app->request->post('fileList');
     if ($record->validate() && $record->save()) {
         return array('wallEntryId' => $record->content->getFirstWallEntryId());
     }
     return array('errors' => $record->getErrors());
 }
 /**
  * Creates the given ContentActiveRecord based on given submitted form information.
  *
  * - Automatically assigns ContentContainer
  * - Access Check
  * - User Notification / File Uploads
  * - Reloads Wall after successfull creation or returns error json
  *
  * [See guide section](guide:dev-module-stream.md#CreateContentForm)
  *
  * @param ContentActiveRecord $record
  * @return string json
  */
 public static function create(ContentActiveRecord $record, ContentContainerActiveRecord $contentContainer = null)
 {
     Yii::$app->response->format = 'json';
     $visibility = Yii::$app->request->post('visibility');
     if ($visibility == Content::VISIBILITY_PUBLIC && !$contentContainer->permissionManager->can(new \humhub\modules\content\permissions\CreatePublicContent())) {
         $visibility = Content::VISIBILITY_PRIVATE;
     }
     $record->content->visibility = $visibility;
     $record->content->container = $contentContainer;
     // Handle Notify User Features of ContentFormWidget
     // ToDo: Check permissions of user guids
     $userGuids = Yii::$app->request->post('notifyUserInput');
     if ($userGuids != "") {
         foreach (explode(",", $userGuids) as $guid) {
             $user = User::findOne(['guid' => trim($guid)]);
             if ($user) {
                 $record->content->notifyUsersOfNewContent[] = $user;
             }
         }
     }
     // Store List of attached Files to add them after Save
     $record->content->attachFileGuidsAfterSave = Yii::$app->request->post('fileList');
     if ($record->validate() && $record->save()) {
         return array('wallEntryId' => $record->content->getFirstWallEntryId());
     }
     return array('errors' => $record->getErrors());
 }