/** * The code that needs to be called when the cron is running * * If $this->enableUserAndGroupSupport() returns TRUE then the run function * will be called for each $user. (The $user parameter will be given) * * If $this->enableUserAndGroupSupport() returns FALSE then the * $user parameter is null and the run function will be called only once. * * @param CronJob $cronJob * @param User $user [OPTIONAL] */ public function run(CronJob $cronJob, User $user = null) { GO::session()->runAsRoot(); $licenseFile = \GO::getLicenseFile(); $temporaryLicenseFile = new \GO\Base\Fs\File(GO::config()->file_storage_path . 'license/' . $licenseFile->name()); if ($temporaryLicenseFile->exists()) { if (!$temporaryLicenseFile->move($licenseFile)) { throw new \Exception("Could not move license file to Group-Office root!"); } else { if (!GO::scriptCanBeDecoded()) { GO\Base\Mail\AdminNotifier::sendMail("Group-Office license invalid", "You attempted to install a license but the license file you provided didn't work. Please contant Intermesh about this error."); } else { //add all users to the modules they have access too \GO\Professional\License::autoConfigureModulePermissions(); GO\Base\Mail\AdminNotifier::sendMail("Group-Office license installed successfully!", "Your license was installed and the new users were automatically added to the App permissions if necessary.\n\nThank you for using Group-Office!"); } } } }
public function actionUnsubscribe($params) { if (!isset($params['contact_id'])) { $params['contact_id'] = 0; } if (!isset($params['company_id'])) { $params['company_id'] = 0; } if (!empty($params['sure'])) { if ($params['contact_id']) { $contact = \GO\Addressbook\Model\Contact::model()->findByPk($params['contact_id']); if (md5($contact->ctime . $contact->addressbook_id . $contact->firstEmail) != $params['token']) { throw new \Exception("Invalid token!"); } $contact->email_allowed = 0; $contact->save(); \GO\Base\Mail\AdminNotifier::sendMail("Unsubscribe: " . $contact->email, "Contact " . $contact->email . " unsubscribed from receiving newsletters"); } else { if ($params['contact_id']) { $company = \GO\Addressbook\Model\Company::model()->findByPk($params['company_id']); if (md5($company->ctime . $company->addressbook_id . $company->email) != $params['token']) { throw new \Exception("Invalid token!"); } $company->email_allowed = 0; $company->save(); \GO\Base\Mail\AdminNotifier::sendMail("Unsubscribe: " . $company->email, "Company " . $contact->email . " unsubscribed from receiving newsletters"); } } $this->render('unsubscribed', $params); } else { $this->render('unsubscribe', $params); } }