Beispiel #1
0
 /**
  * [GROUP_ID]-group@[MAIL_HOST_NAME] (Example: "*****@*****.**")
  * @param $gid
  */
 public function onPreCreateGroup($gid)
 {
     if (!empty($gid)) {
         $prefix = $this->configurator->get('group_prefix');
         $email = $this->encodeUidToEmail($gid . $prefix);
         $result = $this->mtaConnector->insertVirtualUser($email, 'pass' . strtolower($gid));
         if (!$result) {
             $errorMessage = 'Error adding user data in the MTA database, ';
             if ($result === false) {
                 $errorMessage .= 'the domain specified in the configuration can not be found';
             } else {
                 $errorMessage .= 'possible SQL query error';
             }
             Helper::mailParserLogerError($errorMessage);
         } else {
             Helper::mailParserLoger('Added new virtual user: ' . $email);
         }
     }
 }
Beispiel #2
0
 */
$container->query('OCP\\INavigationManager')->add(function () use($container, $appName) {
    $urlGenerator = $container->query('OCP\\IURLGenerator');
    //$l10n = $container->query('OCP\IL10N');
    $l = \OC::$server->getL10N('owncollab_talks');
    return ['id' => $appName, 'order' => 10, 'href' => $urlGenerator->linkToRoute($appName . '.main.index'), 'icon' => $urlGenerator->imagePath($appName, 'app.svg'), 'name' => $l->t('Talks')];
});
/**
 * Aliaser class a listen the events "create new users" and "create new group"
 * todo: create error logs for Configurator & MtaConnector
 */
if (Helper::isAppSettingsUsers()) {
    $configurator = new Configurator();
    $mta = new MtaConnector($configurator);
    if ($mtaErrors = $mta->getErrors()) {
        Helper::mailParserLogerError($mtaErrors);
    } else {
        $aliaser = new Aliaser($appName, $configurator, $mta);
        // Sync MailServer virtual users with OwnCloud users
        $connect = new Connect(\OC::$server->getDatabaseConnection());
        $users = [];
        $usersArr = $connect->users()->getAll();
        foreach ($usersArr as $ua) {
            $users[] = strtolower($ua['uid']);
        }
        $groups = [];
        $groupsArr = $connect->users()->getAllGroups();
        foreach ($groupsArr as $ga) {
            $groups[] = strtolower($ga['gid']);
        }
        $aliaser->syncVirtualAliasesWithUsers($users, $groups);
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @return DataResponse
  */
 public function saveTalk()
 {
     $params = ['error' => null, 'errorinfo' => null, 'insert_id' => null, 'mail_is_send' => false];
     if (Helper::post('title') && Helper::post('message')) {
         $groupsusers = [];
         $all_users = $users = Helper::post('users', false);
         $groups = Helper::post('groups', false);
         $share_files = Helper::post('share', false);
         $attachements = [];
         $attachements_info = [];
         if (!empty($groups)) {
             $groupsusers = $this->connect->users()->getGroupsUsersList();
             foreach ($groups as $group) {
                 if (isset($groupsusers[$group]) && ($rm_arr = $groupsusers[$group])) {
                     $rm_list = array_map(function ($item) {
                         return $item['uid'];
                     }, $rm_arr);
                     $users = array_diff($users, $rm_list);
                 }
             }
         }
         if (!empty($share_files)) {
             $files_id_list = array_keys($share_files);
             foreach ($share_files as $_fid => $_file) {
                 $file = $this->connect->files()->getById($_fid);
                 if (!$file) {
                     Helper::mailParserLogerError('ERROR SaveTalk - Begin, file by ID not find: ' . $_fid);
                     continue;
                 }
                 $owner = $this->userId;
                 $shareType = $file['mimetype'] == 2 ? 'folder' : 'file';
                 $sharedWith = \OCP\Share::getUsersItemShared($shareType, $file['fileid'], $owner, false, true);
                 $isEnabled = \OCP\Share::isEnabled();
                 $isAllowed = \OCP\Share::isResharingAllowed();
                 if ($isEnabled && $isAllowed) {
                     $sharedUsers = is_array($sharedWith) ? array_values($sharedWith) : [];
                     foreach ($all_users as $_uid) {
                         if ($owner == $_uid || in_array($_uid, $sharedUsers)) {
                             # disable
                             # todo loger why users not find
                         } else {
                             try {
                                 $shareLink = $this->connect->files()->shareFile($this->userId, $_uid, $_fid);
                                 $formatFileInfo = false;
                                 $fileInfo = \OC\Files\Filesystem::getFileInfo(substr($file['path'], 6));
                                 if ($fileInfo) {
                                     $formatFileInfo = \OCA\Files\Helper::formatFileInfo($fileInfo);
                                 }
                                 $attachements_info[$shareLink] = ['info' => $formatFileInfo, 'file' => $file, 'share_ink' => $shareLink];
                             } catch (\Exception $e) {
                             }
                         }
                     }
                 }
             }
             $attachements = $files_id_list;
         }
         $data['rid'] = 0;
         $data['date'] = date("Y-m-d H:i:s", time());
         $data['title'] = strip_tags(Helper::post('title'));
         $data['text'] = addslashes(Helper::post('message'));
         $data['attachements'] = json_encode((array) $attachements);
         $data['author'] = $this->userId;
         $data['subscribers'] = json_encode(['groups' => $groups, 'users' => $users]);
         $data['hash'] = TalkMail::createHash($data['date'] . $data['title']);
         $data['status'] = TalkMail::SEND_STATUS_CREATED;
         if ($params['insert_id'] = $this->connect->messages()->insertTask($data)) {
             $data['id'] = $params['insert_id'];
             $this->mailsend($data, $all_users, $attachements_info);
         }
         $params['data'] = $data;
     }
     if ($params['insert_id']) {
         Helper::cookies('goto_message', $params['insert_id']);
         header("Location: /index.php/apps/owncollab_talks/started");
         exit;
     }
     return new DataResponse($params);
 }