/** * Retreive all users that belong to the given group. * * @param int $id * @return array Users */ protected function actionGetUsers($params) { //don't check ACL here because this method may be called by anyone. $group = \GO\Base\Model\Group::model()->findByPk($params['id'], false, true); if (empty($group)) { $group = new \GO\Base\Model\Group(); } if (isset($params['add_users']) && !empty($group->id)) { $users = json_decode($params['add_users']); foreach ($users as $usr_id) { if ($group->addUser($usr_id)) { \GO\Base\Model\User::model()->findByPk($usr_id)->checkDefaultModels(); } } } $store = \GO\Base\Data\Store::newInstance(\GO\Base\Model\User::model()); $store->getColumnModel()->formatColumn('name', '$model->name', array(), array('first_name', 'last_name')); $storeParams = $store->getDefaultParams($params)->joinCustomFields(false); $delresponse = array(); //manually check permission here because this method may be accessed by any logged in user. allowWithoutModuleAccess is used above. if ($group->checkPermissionLevel(\GO\Base\Model\Acl::DELETE_PERMISSION)) { // The users in the group "everyone" cannot be deleted if ($group->id != \GO::config()->group_everyone) { $store->processDeleteActions($params, 'GO\\Base\\Model\\UserGroup', array('group_id' => $group->id)); } else { $delresponse['deleteSuccess'] = false; $delresponse['deleteFeedback'] = 'Members of the group everyone cannot be deleted.'; } } $stmt = $group->users($storeParams); $store->setStatement($stmt); $response = $store->getData(); $response = array_merge($response, $delresponse); return $response; }
public function install() { parent::install(); $lang = new Model\Language(); $lang->id = 1; $lang->name = \GO::t('default', 'billing'); $lang->language = \GO::config()->language; $lang->save(); $quoteBook = new Model\Book(); $quoteBook->name = \GO::t('quotes', 'billing'); $quoteBook->order_id_prefix = "Q%y"; $quoteBook->call_after_days = 3; $quoteBook->createStatuses = array('sent', 'accepted', 'lost', 'in_process'); $quoteBook->save(); $orderBook = new Model\Book(); $orderBook->name = \GO::t('orders', 'billing'); $orderBook->order_id_prefix = "O%y"; $quoteBook->createStatuses = array('in_process', 'delivered', 'sent', 'billed'); $orderBook->save(); $invoiceBook = new Model\Book(); $invoiceBook->name = \GO::t('invoices', 'billing'); $invoiceBook->order_id_prefix = "I%y"; $invoiceBook->save(); return true; }
/** * 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 \GO\Base\Model\User $user [OPTIONAL] */ public function run(CronJob $cronJob, \GO\Base\Model\User $user = null) { \GO::session()->runAsRoot(); $usersStmt = \GO\Base\Model\User::model()->findByAttribute('mail_reminders', 1); while ($userModel = $usersStmt->fetch()) { \GO::debug("Sending mail reminders to " . $userModel->username); $remindersStmt = \GO\Base\Model\Reminder::model()->find(\GO\Base\Db\FindParams::newInstance()->joinModel(array('model' => 'GO\\Base\\Model\\ReminderUser', 'localTableAlias' => 't', 'localField' => 'id', 'foreignField' => 'reminder_id', 'tableAlias' => 'ru'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', $userModel->id, '=', 'ru')->addCondition('time', time(), '<', 'ru')->addCondition('mail_sent', '0', '=', 'ru'))); while ($reminderModel = $remindersStmt->fetch()) { // $relatedModel = $reminderModel->getRelatedModel(); // var_dump($relatedModel->name); // $modelName = $relatedModel ? $relatedModel->localizedName : \GO::t('unknown'); $subject = \GO::t('reminder') . ': ' . $reminderModel->name; $time = !empty($reminderModel->vtime) ? $reminderModel->vtime : $reminderModel->time; date_default_timezone_set($userModel->timezone); $body = \GO::t('time') . ': ' . date($userModel->completeDateFormat . ' ' . $userModel->time_format, $time) . "\n"; $body .= \GO::t('name') . ': ' . str_replace('<br />', ',', $reminderModel->name) . "\n"; // date_default_timezone_set(\GO::user()->timezone); $message = \GO\Base\Mail\Message::newInstance($subject, $body); $message->addFrom(\GO::config()->noreply_email, \GO::config()->title); $message->addTo($userModel->email, $userModel->name); \GO\Base\Mail\Mailer::newGoInstance()->send($message, $failedRecipients); if (!empty($failedRecipients)) { trigger_error("Reminder mail failed for recipient: " . implode(',', $failedRecipients), E_USER_NOTICE); } $reminderUserModelSend = \GO\Base\Model\ReminderUser::model()->findSingleByAttributes(array('user_id' => $userModel->id, 'reminder_id' => $reminderModel->id)); $reminderUserModelSend->mail_sent = 1; $reminderUserModelSend->save(); } date_default_timezone_set(\GO::user()->timezone); } }
/** * Query the file_storage_usage once; * @return integer total file storage usage in bytes */ protected function getTotalUsage() { if (!isset($this->_total_file_storage)) { $this->_total_file_storage = \GO::config()->get_setting('file_storage_usage'); } return $this->_total_file_storage; }
function printHead() { echo '<html><head>' . '<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />' . '<link href="install.css" rel="stylesheet" type="text/css" />' . '<title>' . \GO::config()->product_name . ' Installation</title>' . '</head>' . '<body style="font-family: Arial,Helvetica;background-color:#f1f1f1">'; echo '<form method="post">'; echo '<div style="width:800px;padding:20px;margin:10px auto;background-color:white">'; echo '<img src="logo.gif" border="0" align="middle" style="margin:0px;margin-bottom:20px;" />'; }
public function init() { $this->formModel = new \GO\Site\Widget\ContactForm\ContactForm(); $this->formModel->receipt = isset($this->receipt) ? $this->receipt : \GO::config()->webmaster_email; $this->formModel->name = \GO::user() ? \GO::user()->name : 'Website Guest'; $this->form = new \GO\Site\Widget\Form(); }
/** * Get the path to the template folder * * @return string */ public function getPath() { if (empty(\Site::model()->module)) { return false; } return \GO::config()->root_path . 'modules/' . \Site::model()->module . '/views/site/'; }
protected function actionSubmit($params) { $text = $params['login_screen_text']; $reportFeedback = ''; if (preg_match("/^<br[^>]*>\$/", $text)) { $text = ""; } \GO::config()->save_setting('login_screen_text', $text); \GO::config()->save_setting('login_screen_text_title', $_POST['login_screen_text_title']); \GO::config()->save_setting('login_screen_text_enabled', !empty($_POST['login_screen_text_enabled']) ? '1' : '0'); if (!empty($params['addressbook_name_template'])) { \GO\Base\Model\AbstractUserDefaultModel::setNameTemplate("GO\\Addressbook\\Model\\Addressbook", $params['addressbook_name_template']); } if (!empty($params['task_name_template'])) { \GO\Base\Model\AbstractUserDefaultModel::setNameTemplate("GO\\Tasks\\Model\\Tasklist", $params['task_name_template']); } if (isset($params['GO\\Tasks\\Model\\Tasklist_change_all_names'])) { $this->_updateAllDefaultTasklists($reportFeedback); } if (!empty($params['calendar_name_template'])) { \GO\Base\Model\AbstractUserDefaultModel::setNameTemplate("GO\\Calendar\\Model\\Calendar", $params['calendar_name_template']); } if (isset($params['GO\\Calendar\\Model\\Calendar_change_all_names'])) { $this->_updateAllDefaultCalendars($reportFeedback); } $response['feedback'] = !empty($reportFeedback) ? $reportFeedback : ''; $response['success'] = true; return $response; }
public static function head() { $font_size = \GO::user() ? \GO::config()->get_setting('email_font_size', \GO::user()->id) : false; if (!$font_size) { $font_size = '12px'; } echo "\n<!-- Inserted by EmailModule::head() -->\n<style>\n" . '.message-body,.message-body p, .message-body li, .go-html-formatted td, .em-composer .em-plaintext-body-field{' . 'font-size: ' . $font_size . ';!important' . "}\n</style>\n<!-- End EmailModule::head() -->\n"; }
public static function newGoInstance() { $o = self::newInstance(\GO::config()->smtp_server, \GO::config()->smtp_port, strtolower(\GO::config()->smtp_encryption)); if (!empty(\GO::config()->smtp_username)) { $o->setUsername(\GO::config()->smtp_username)->setPassword(\GO::config()->smtp_password); } return $o; }
public function getTempDir() { $this->_tmpDir = \GO::config()->tmpdir . 'imap_messages/' . $this->account->id . '-' . $this->mailbox . '-' . $this->uid . '/'; if (!is_dir($this->_tmpDir)) { mkdir($this->_tmpDir, 0700, true); } return $this->_tmpDir; }
public function install() { parent::install(); $category = new Model\Category(); $category->name = \GO::t('general', 'bookmarks'); $category->save(); $category->acl->addGroup(\GO::config()->group_internal, \GO\Base\Model\Acl::READ_PERMISSION); }
public function actionExport($params) { // $params['book_id']=2; $params['attributes'] = empty($params['attributes']) ? $this->exportableAttributes() : explode(',', $params['attributes']); $className = get_class($this); \GO::config()->save_setting($className . '_attributes', serialize($params['attributes'])); $this->export($params); }
protected function beforeSubmit(&$response, &$model, &$params) { if (!\GO::user()) { if (empty($params['serverclient_token']) || $params['serverclient_token'] != \GO::config()->serverclient_token) { throw new \GO\Base\Exception\AccessDenied(); } else { \GO::session()->runAsRoot(); } } if (isset($params['domain_id'])) { $domainModel = \GO\Postfixadmin\Model\Domain::model()->findByPk($params['domain_id']); } else { $domainModel = \GO\Postfixadmin\Model\Domain::model()->findSingleByAttribute("domain", $params['domain']); //serverclient module doesn't know the domain_id. It sends the domain name as string. if (!$domainModel) { //todo create new domain $domainModel = new \GO\Postfixadmin\Model\Domain(); $domainModel->domain = $params['domain']; $domainModel->user_id = \GO::user()->id; $domainModel->save(); } $params['domain_id'] = $domainModel->id; $model->quota = $domainModel->default_quota; } if (isset($params['quota'])) { $model->quota = \GO\Base\Util\Number::unlocalize($params['quota']) * 1024; unset($params['quota']); } if ($params['password'] != $params['password2']) { throw new \Exception(\GO::t('passwordMatchError')); } if (empty($params['password'])) { unset($params['password']); } if (isset($params['username'])) { $params['username'] .= '@' . $domainModel->domain; } if ($model->isNew) { // $aliasModel = \GO\Postfixadmin\Model\Alias::model()->findSingleByAttribute('address', $params['username']); // if (empty($aliasModel)) { // $aliasModel = new \GO\Postfixadmin\Model\Alias(); // } // $aliasModel->domain_id = $params['domain_id']; // $aliasModel->address = $params['username']; // $aliasModel->goto = $params['username']; // $aliasModel->save(); if (!empty($params['alias']) && $params['alias'] != $params['username']) { $aliasModel = \GO\Postfixadmin\Model\Alias::model()->findSingleByAttribute('address', $params['alias']); if (empty($aliasModel)) { $aliasModel = new \GO\Postfixadmin\Model\Alias(); } $aliasModel->domain_id = $params['domain_id']; $aliasModel->address = $params['alias']; $aliasModel->goto = $params['username']; $aliasModel->save(); } } }
public static function inlinescripts() { $t = \GO::config()->get_setting('login_screen_text_enabled'); if (!empty($t)) { $login_screen_text = \GO::config()->get_setting('login_screen_text'); $login_screen_text_title = \GO::config()->get_setting('login_screen_text_title'); echo 'GO.mainLayout.on("login", function(mainLayout){mainLayout.msg("' . \GO\Base\Util\String::escape_javascript($login_screen_text_title) . '", "' . \GO\Base\Util\String::escape_javascript($login_screen_text) . '", 3600, 400);});'; } }
/** * Can be used to notify the administrator by email * * @param string $subject * @param string $message */ public static function sendMail($subject, $body) { $message = Message::newInstance(); $message->setSubject($subject); $message->setBody($body, 'text/plain'); $message->setFrom(\GO::config()->webmaster_email, \GO::config()->title); $message->addTo(\GO::config()->webmaster_email, 'Webmaster'); Mailer::newGoInstance()->send($message); }
/** * Get the name of the theme that is selected by the user. * * @return string */ public function getName() { $theme = \GO::config()->allow_themes && \GO::user() ? \GO::user()->theme : \GO::config()->theme; if (!file_exists(\GO::view()->getPath() . 'themes/' . $theme . '/Layout.php')) { return 'Default'; } else { return $theme; } }
public function send(\Swift_Mime_Message $message, &$failedRecipients = null) { if (!empty(\GO::config()->disable_mail)) { throw new \Exception("E-mail sending is disabled!"); } if (\GO::config()->debug) { $getTo = $message->getTo(); if (!empty($getTo)) { $getTo = implode(",", array_keys($getTo)); } else { $getTo = ''; } \GO::debug("Sending e-mail to " . $getTo); } if (\GO::modules()->isInstalled("log")) { $str = ""; $from = $message->getFrom(); if (!empty($from)) { $str .= implode(",", array_keys($from)); } else { $str .= "unknown"; } $str .= " -> "; $to = $message->getTo(); if (!empty($to)) { $str .= implode(",", array_keys($to)); } $to = $message->getCc(); if (!empty($to)) { $str .= implode(",", array_keys($to)); } $to = $message->getBcc(); if (!empty($to)) { $str .= implode(",", array_keys($to)); } \GO\Log\Model\Log::create("email", $str); } // debug_print_backtrace(); // exit("NO MAIL"); //workaround https://github.com/swiftmailer/swiftmailer/issues/335 $messageId = $message->getId(); $count = parent::send($message, $failedRecipients); $message->setId($messageId); // Check if a tmp dir is created to store attachments. // If so, then remove the tmp dir if the mail is send successfully. $tmpDir = $message->getTmpDir(); if (!empty($tmpDir)) { $folder = new \GO\Base\Fs\Folder($tmpDir); // Check if folder is deleted successfully if ($folder->delete()) { \GO::debug('Clear attachments tmp directory: ' . $tmpDir); } else { \GO::debug('Failed to clear attachments tmp directory: ' . $tmpDir); } } return $count; }
public static function create($type, $name) { //get or create namespace uuid for Group-Office $namespace = \GO::config()->get_setting('uuid_namespace'); if (!$namespace) { $namespace = UUID::v4(); \GO::config()->save_setting('uuid_namespace', $namespace); } return UUID::v5($namespace, $type . $name); }
protected function actionRedirect() { $tmpFile = \GO\Base\Fs\File::tempFile(); $tmpFile->putContents(\GO::user()->id); if (empty(\GO::config()->phpbb3_url)) { throw new \Exception('You must configure phpbb3_url in your config.php file'); } $url = \GO::config()->phpbb3_url . '?goauth=' . base64_encode($tmpFile->path()) . '&sid=' . md5(uniqid(time())); header('Location: ' . $url); exit; }
public function __construct($config = array()) { parent::__construct($config); if (empty(\GO::config()->googledrive_oauth2_client_id) || empty(\GO::config()->googledrive_oauth2_client_secret) || empty(\GO::config()->googledrive_simple_api_key)) { throw new \Exception("Google drive API client not setup. \$config['googledrive_oauth2_client_id'], \$config['googledrive_oauth2_client_secret'] and \$config['googledrive_simple_api_key'] must be set."); } $this->setApplicationName(\GO::config()->title); $this->setUseObjects(true); $this->setClientId(\GO::config()->googledrive_oauth2_client_id); $this->setClientSecret(\GO::config()->googledrive_oauth2_client_secret); // $this->setDeveloperKey(\GO::config()->googledrive_simple_api_key); }
public function __construct() { // \GO::debug("Using Disk cache"); $this->_dir = \GO::config()->tmpdir . 'diskcache/'; if (!is_dir($this->_dir)) { mkdir($this->_dir, 0777, true); } $this->_ttlFile = $this->_dir . 'ttls.txt'; //if(!\GO::config()->debug) $this->_load(); $this->_time = time(); }
public function request($url, $params = array()) { if (empty(\GO::config()->serverclient_server_url)) { \GO::config()->serverclient_server_url = \GO::config()->full_url; } $url = \GO::config()->serverclient_server_url . '?r=' . $url; if (empty(\GO::config()->serverclient_token)) { throw new \Exception("Could not connect to mailserver. Please set a strong password in /etc/groupoffice/globalconfig.inc.php.\n\nPlease remove serverclient_username and serverclient_password.\n\nPlease add:\n\n \$config['serverclient_token']='aStrongPasswordOfYourChoice';"); } $params['serverclient_token'] = \GO::config()->serverclient_token; return parent::request($url, $params); }
/** * This will copy a file in the files module to a public accessable folder * * @param array $params * - stromg src: path the the file relative the the sites public storage folder. * @return the rsult of the thumb action on the core controller * @throws \GO\Base\Exception\AccessDenied when unable to create the folder? */ protected function actionThumb($params) { $rootFolder = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . 'site/' . \Site::model()->id); $file = new \GO\Base\Fs\File(\GO::config()->file_storage_path . 'site/' . \Site::model()->id . '/' . $params['src']); $folder = $file->parent(); $ok = $folder->isSubFolderOf($rootFolder); if (!$ok) { throw new \GO\Base\Exception\AccessDenied(); } $c = new \GO\Core\Controller\CoreController(); return $c->run('thumb', $params, true, false); }
public function __construct() { $f = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . 'cache'); $f->create(); $this->_cacheFile = \GO::config()->file_storage_path . 'cache/script-'; if (\GO::user()) { $this->_cacheFile .= \GO::user()->username; } else { $this->_cacheFile .= "loggedoff"; } $this->_cacheFile .= '.js'; }
private function rewrite_host($host) { if (isset(\GO::config()->sieve_rewrite_hosts)) { $maps = explode(',', \GO::config()->sieve_rewrite_hosts); foreach ($maps as $map) { $pair = explode('=', $map); if ($pair[0] == $host && isset($pair[1])) { return $pair[1]; } } } return $host; }
public function init() { if (isset($_GET[$this->pageParam])) { $this->currentPage = $_GET[$this->pageParam]; } if (empty($this->pageSize)) { $this->pageSize = \GO::user() ? \GO::user()->max_rows_list : \GO::config()->nav_page_size; } if (!$this->store instanceof \GO\Base\Data\DbStore) { throw new \Exception('store needs to be an instance of \\GO\\Base\\Data\\Store'); } $this->store->start = $this->pageSize * ($this->currentPage - 1); $this->store->limit = $this->pageSize; }
/** * Conver a number formatted by using the user preferences to a number understood by PHP * * @param int $number The number * @param int $decimals Number of decimals to display * @access public * @return string */ public static function unlocalize($number) { if ($number == "") { return null; } $ts = \GO::user() ? \GO::user()->thousands_separator : \GO::config()->default_thousands_separator; $ds = \GO::user() ? \GO::user()->decimal_separator : \GO::config()->default_decimal_separator; $number = str_replace($ts, '', $number); $number = str_replace($ds, '.', $number); if (!empty($number) && !is_numeric($number)) { return false; } return floatval($number); //return str_replace($ds,'.',$number); }
public function __construct($arguments) { if (isset($arguments['user'])) { $this->id = 'groupoffice::' . $arguments['user'] . '/'; $this->groupoffice_data = \GO::config()->file_storage_path; \GO::session()->setCurrentUser(\GO\Base\Model\User::model()->findSingleByAttribute('username', $arguments['user'])); $this->groupoffice_shares['ownFolder'] = 'users/' . $arguments['user']; $shares = \GO\Files\Model\Folder::model()->getTopLevelShares(\GO\Base\Db\FindParams::newInstance()->limit(100)); foreach ($shares as $folder) { $this->groupoffice_shares[$folder->name] = $folder->path; } } else { throw new \Exception('Creating \\OC\\Files\\Storage\\Groupoffice storage failed'); } }
public function __construct($prefixString = '') { if (!\GO::modules()->isInstalled('files')) { throw new \Exception('The current action requires the files module to be activated for the current user.'); } // Make sure the current user's folder exists. $userFolderModel = \GO\Files\Model\Folder::model()->findHomeFolder(\GO::user()); if (empty($userFolderModel)) { $userFolder = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . 'users/' . \GO::user()->username); $userFolder->create(); $userFolderModel = new \GO\Files\Model\Folder(); $userFolderModel->findByPath('users/' . \GO::user()->username, true); } parent::__construct(\GO::config()->file_storage_path . $userFolderModel->path . '/' . $prefixString . \GO\Base\Util\Date::get_timestamp(time(), true) . '.log'); }