Mail function
- Function has possibility to mail submitting user instead of target adress

@deprecated Make a Store class

@param array $feedbackObject
@param bool $copyreporter
@return array
517487
public function mail(array $feedbackObject, $copyreporter = false) {
		$returnobject = [];
		$returnobject['result'] = false;
		$returnobject['msg'] = '';

		if (empty($feedbackObject)) {
			return $returnobject;
		}

		//Read settings from config if not in copy mode
		$to = Configure::read('Feedback.methods.mail.to');
		$from = Configure::read('Feedback.methods.mail.from');

		// Change recipient if sending a copy
		if ($copyreporter) {
			$to = $feedbackObject['email'];
		}

		//Change the sender if any given
		if (!empty($feedbackObject['email']) && !empty($feedbackObject['name'])) {
			$from = [$feedbackObject['email'] => $feedbackObject['name']];
		}

		//Tmp store the screenshot:
		$tmpfile = APP . 'tmp' . DS . time() . '_' . rand(1000, 9999) . '.png';
		if (!file_put_contents($tmpfile, base64_decode($feedbackObject['screenshot']))) {
			//Need to save tmp file
			throw new NotFoundException('Could not save tmp file for attachment in mail');
		}

		$email = new Email();
		$email->from($from);
		$email->to($to);
		$email->subject($feedbackObject['subject']);
		$email->emailFormat('html');
		$email->attachments([
		    'screenshot.png' => [
		        'file' => $tmpfile,
		        'mimetype' => 'image/png',
		        'contentId' => 'id-screenshot'
		    ]
		]);

		//Mail specific: append browser, browser version, URL, etc to feedback :
		if ($copyreporter) {
			$feedbackObject['feedback'] = '<p>' . __d('feedback', 'A copy of your submitted feedback:') . '</p>' . $feedbackObject['feedback'];
		}
		$feedbackObject['feedback'] .= '<p>';
		$feedbackObject['feedback'] .= sprintf('Browser: %s %s<br/>', $feedbackObject['browser'], $feedbackObject['browser_version']);
		$feedbackObject['feedback'] .= sprintf('Url: %s<br/>', $feedbackObject['url']);
		$feedbackObject['feedback'] .= sprintf('OS: %s<br/>', $feedbackObject['os']);
		$feedbackObject['feedback'] .= sprintf('By: %s<br/>', $feedbackObject['name']);
		$feedbackObject['feedback'] .= 'Screenshot: <br/>';
		$feedbackObject['feedback'] .= '</p>';
		$feedbackObject['feedback'] .= '<img src="cid:id-screenshot">'; //Add inline screenshot

		if ($email->send($feedbackObject['feedback'])) {
			$returnobject['result'] = true;
			$returnobject['msg'] = __d('feedback', 'Thank you. Your feedback was saved.');

			return $returnobject;
		}

		unlink($tmpfile);

		return $returnobject;
	}
265784
public function sendActivationEmailToClient($obj, array $input) {
    $mailer = App::make('palmamailer');
    // if i activate a deactivated user
    if (isset($input["activated"]) && $input["activated"] && (!$obj->activated)) {
      $mailer->sendTo($obj->email, ["email" => $obj->email],
                      "You are activated on " .
                      Config::get('authentication::app_name'), "authentication::mail.registration-activated-client");
    }
  }
24843
public function getSubscriberEmails($listId)
    {
        $emails = [];
        $members = [];
        $offset=0;
        $maxresult = 200;
        $result = $this->mailchimp->get("lists/$listId/members", ['count'=> $maxresult]);

        if (!$this->mailchimp->success()) {
            $this->throwMailchimpError($this->mailchimp->getLastResponse());
        }

        $totalItems = $result['total_items'];
        $members = array_merge($members, $result['members']);

        while ($offset < $totalItems) {
            $offset+=$maxresult;
            $result = $this->mailchimp->get("lists/$listId/members", [
                        'count'         => $maxresult,
                        'offset'        => $offset
                    ]);

            if (!$this->mailchimp->success()) {
                $this->throwMailchimpError($this->mailchimp->getLastResponse());
            }
            $members = array_merge($members, $result['members']);
        };

        foreach ($members as $key => $member) {
            array_push($emails, $member['email_address']);
        }

        return $emails;
    }
525151
public static function export_feedback_user_data(assign_plugin_request_data $exportdata) {
        $currentpath = $exportdata->get_subcontext();
        $currentpath[] = get_string('privacy:path', 'assignfeedback_file');
        $assign = $exportdata->get_assign();
        $plugin = $assign->get_plugin_by_type('assignfeedback', 'file');
        $gradeid = $exportdata->get_pluginobject()->id;
        $filefeedback = $plugin->get_file_feedback($gradeid);
        if ($filefeedback) {
            $fileareas = $plugin->get_file_areas();
            foreach ($fileareas as $filearea => $notused) {
                \core_privacy\local\request\writer::with_context($exportdata->get_context())
                        ->export_area_files($currentpath, 'assignfeedback_file', $filearea, $gradeid);
            }
        }
    }
836373
public function isSimilarTo(FeedbackInterface $feedback)
    {
        if (!$feedback instanceof UpdateWorkspaceInfo) {
            return false;
        }

        return $this->getWorkspace() === $feedback->getWorkspace();
    }
393056
public function setCopyTarget(int $copyTarget = self::COPY): CopyDictionaryJob
    {
        $this->copyTarget = $copyTarget;

        return $this;
    }
811404
public function invalidateEmailAddress(Garp_Db_Table_Row $user, $updateOrInsert = 'insert') {
        $authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
        $validationTokenColumn = $authVars['token_column'];
        $emailValidColumn = $authVars['email_valid_column'];

        if ($updateOrInsert == 'insert' && array_get($user, $emailValidColumn)) {
            return true;
        } 
        
        // Generate the validation code
        $validationToken = uniqid();
        $validationCode = $this->generateEmailValidationCode($user, $validationToken);

        if (!$user->isConnected()) {
            $user->setTable($this);
        }

        // Store the token in the user record
        $user->{$validationTokenColumn} = $validationToken;
        // Invalidate the user's email
        $user->{$emailValidColumn} = 0;

        if ($user->save()) {
            return $this->sendEmailValidationEmail($user, $validationCode, $updateOrInsert);
        }
        return false;
    }
259418
protected function emailOutput( Mailer $mailer, $addresses, $onlyIfOutputExists = false )
	{
		$text = file_get_contents( $this->output );

		if ( $onlyIfOutputExists && empty( $text ) )
		{
			return;
		}

		$mailer->raw( $text, function ( $m ) use ( $addresses )
		{
			$m->subject( $this->getEmailSubject() );

			foreach ( $addresses as $address )
			{
				$m->to( $address );
			}
		} );
	}
1297279
public static function sendActivationEmail( $contentObject, $subscriber, $subscription )
    {
        $transport = eZNotificationTransport::instance( 'ezmail' );

        $email = $subscriber->attribute( 'email' );
        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'contentobject', $contentObject );
        $tpl->setVariable( 'subscriber', $subscriber );
        $tpl->setVariable( 'subscription', $subscription );
        $mailSubject = $tpl->fetch( 'design:comment/notification_activation_subject.tpl' );
        $mailBody = $tpl->fetch( 'design:comment/notification_activation_body.tpl' );
        $parameters = array();
        $ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
        $mailContentType = $ezcommentsINI->variable( 'NotificationSettings', 'ActivationMailContentType' );
        $parameters['from'] = $ezcommentsINI->variable( 'NotificationSettings', 'MailFrom' );
        $parameters['content_type'] = $mailContentType;

        $result = $transport->send( array( $email ), $mailSubject, $mailBody, null, $parameters );
        return $result;
    }
509185
protected function getSampleForObject(DataObject $record) {
		$response = Director::test($record->Link());

		if($response->getStatusCode() === 200) {
			return $response->getBody();
		}

		return false;
	}
466131
private function saveScreenshot(array $feedbackObject) {
		//Get save path from config
		$savepath = ROOT . DS . 'files' . DS . 'img' . DS . 'screenshots' . DS;

		//Serialize and save the object to a store in the Cake's tmp dir.
		if (!file_exists($savepath)) {
			if (!mkdir($savepath)) {
				//Throw error, directory is requird
				throw new NotFoundException('Could not create directory to save screenshots in. Please provide write rights to webserver user on directory: ' . $savepath);
			}
		}

		$screenshotname = $this->generateScreenshotName();

		if (file_put_contents($savepath . $screenshotname, base64_decode($feedbackObject['screenshot']))) {
			//Return the screenshotname
			return $screenshotname;
		}

		return null;
	}
238365
public function sendDigestMails()
    {
        $subscriptionRepository = $this->entityManager->getRepository('PhlexibleMessageBundle:Subscription');
        $subscriptions = $subscriptionRepository->findByHandler('digest');

        $digests = [];
        foreach ($subscriptions as $subscription) {
            $filter = $this->filterManager->find($subscription->getFilterId());
            if (!$filter) {
                continue;
            }

            $user = $this->userManager->find($subscription->getUserId());
            if (!$user || !$user->getEmail()) {
                continue;
            }

            $lastSend = $subscription->getAttribute('lastSend', null);
            if (!$lastSend) {
                $lastSend = new \DateTime();
                $lastSend = $lastSend->sub(new \DateInterval('P30D'));
            } else {
                $lastSend = new \DateTime($lastSend);
            }

            $criteria = new Criteria([$filter->getCriteria()], Criteria::MODE_AND);
            $criteria->dateFrom($lastSend);
            $messages = $this->messageRepository->findByCriteria($criteria);
            if (!count($messages)) {
                continue;
            }

            if ($this->mailer->sendDigestMail($user, $messages)) {
                $digests[] = ['filter' => $filter->getTitle(), 'to' => $user->getEmail(), 'status' => 'ok'];
                $subscription->setAttribute('lastSend', date('Y-m-d H:i:s'));
                $this->subscriptionRepository->save($subscription);
            } else {
                $digests[] = ['filter' => $filter->getTitle(), 'to' => $user->getEmail(), 'status' => 'failed'];
            }
        }

        if (count($digests)) {
            $message = Message::create(
                count($digests).' digest mail(s) sent.',
                'Status: '.PHP_EOL.print_r($digests, true),
                Message::PRIORITY_NORMAL,
                null,
                'ROLE_MESSAGES',
                'cli'
            );
            $this->messageService->post($message);
        }

        return $digests;
    }
1164640
public function copy_submission(stdClass $sourcesubmission, stdClass $destsubmission) {
        global $DB;

        // Copy the files across (attached via the text editor).
        $contextid = $this->assignment->get_context()->id;
        $fs = get_file_storage();
        $files = $fs->get_area_files($contextid, 'assignsubmission_onlinetext',
                                     ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $sourcesubmission->id, 'id', false);
        foreach ($files as $file) {
            $fieldupdates = array('itemid' => $destsubmission->id);
            $fs->create_file_from_storedfile($fieldupdates, $file);
        }

        // Copy the assignsubmission_onlinetext record.
        $onlinetextsubmission = $this->get_onlinetext_submission($sourcesubmission->id);
        if ($onlinetextsubmission) {
            unset($onlinetextsubmission->id);
            $onlinetextsubmission->submission = $destsubmission->id;
            $DB->insert_record('assignsubmission_onlinetext', $onlinetextsubmission);
        }
        return true;
    }
1228902
public function get_feedbackreviewer_form($actionurl, stdclass $assessment, $options=array()) {
        global $CFG;
        require_once(__DIR__ . '/feedbackreviewer_form.php');

        $current = new stdclass();
        $current->asid                      = $assessment->id;
        $current->weight                    = $assessment->weight;
        $current->gradinggrade              = $this->real_grading_grade($assessment->gradinggrade);
        $current->gradinggradeover          = $this->real_grading_grade($assessment->gradinggradeover);
        $current->feedbackreviewer          = $assessment->feedbackreviewer;
        $current->feedbackreviewerformat    = $assessment->feedbackreviewerformat;
        if (is_null($current->gradinggrade)) {
            $current->gradinggrade = get_string('nullgrade', 'workshop');
        }
        if (!isset($options['editable'])) {
            $editable = true;   // by default
        } else {
            $editable = (bool)$options['editable'];
        }

        // prepare wysiwyg editor
        $current = file_prepare_standard_editor($current, 'feedbackreviewer', array());

        return new workshop_feedbackreviewer_form($actionurl,
                array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options),
                'post', '', null, $editable);
    }
152186
public JSONObject report(JSONArray reportData) {
        AipRequest request = new AipRequest();
        preOperation(request);
        request.addBody("feedback", reportData);
        request.setUri(ContentCensorConsts.REPORT_URL);
        request.setBodyFormat(EBodyFormat.RAW_JSON);
        request.addHeader(Headers.CONTENT_TYPE, HttpContentType.JSON_DATA);
        postOperation(request);
        return requestServer(request);
    }
986606
public function emailOutputTo($addresses, $onlyIfOutputExists = false)
    {
        $this->ensureOutputIsBeingCapturedForEmail();

        if (! is_array($addresses)) {
            $addresses = array($addresses);
        }

        return $this->then(function (Mailer $mailer) use ($addresses, $onlyIfOutputExists)
        {
            $this->emailOutput($mailer, $addresses, $onlyIfOutputExists);
        });
    }
669822
private function helper_render_feedback($feedback) {

        $o  = '';    // output HTML code
        $o .= $this->output->container_start('feedback feedbackforauthor');
        $o .= $this->output->container_start('header');
        $o .= $this->output->heading(get_string('feedbackby', 'workshop', s(fullname($feedback->get_provider()))), 3, 'title');

        $userpic = $this->output->user_picture($feedback->get_provider(), array('courseid' => $this->page->course->id, 'size' => 32));
        $o .= $this->output->container($userpic, 'picture');
        $o .= $this->output->container_end(); // end of header

        $content = format_text($feedback->get_content(), $feedback->get_format(), array('overflowdiv' => true));
        $o .= $this->output->container($content, 'content');

        $o .= $this->output->container_end();

        return $o;
    }