protected function afterDelete() { if (\GO::modules()->isInstalled('log')) { Log::create(Log::ACTION_DELETE, 'Removed ' . $this->contact->name . ' from addresslist ' . $this->addresslist->name, $this->className(), $this->contact_id . ':' . $this->addresslist_id); } return parent::afterDelete(); }
public function isAvailable() { if (!\GO::scriptCanBeDecoded($this->package())) { return false; } else { return true; } // if we can run this file without ioncube it must be open source. // if(!function_exists('ioncube_file_is_encoded') || !ioncube_file_is_encoded()){ // return true; // } /*if(!GO::user()){ return true; } $className = get_class($this); $classParts = explode('\\', $className); if(!License::userHasModule(GO::user()->username, strtolower($classParts[1]))){ return false; } return true;*/ }
public function formatStoreRecord($record, $model, $store) { $r = new \GO\Base\Mail\EmailRecipients(); $r->addRecipient($model->email, $model->name); $record['from'] = (string) $r; $record['html_signature'] = \GO\Base\Util\String::text_to_html($model->signature); $record['plain_signature'] = $model->signature; $record['signature_below_reply'] = $model->account->signature_below_reply; $record['template_id'] = 0; if (\GO::modules()->addressbook) { $defaultAccountTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($model->account_id); if ($defaultAccountTemplateModel) { $record['template_id'] = $defaultAccountTemplateModel->template_id; } else { $defaultUserTemplateModel = \GO\Addressbook\Model\DefaultTemplate::model()->findByPk(\GO::user()->id); if (!$defaultUserTemplateModel) { $defaultUserTemplateModel = new \GO\Addressbook\Model\DefaultTemplateForAccount(); $defaultUserTemplateModel->account_id = $model->account_id; $defaultUserTemplateModel->save(); } $record['template_id'] = $defaultUserTemplateModel->template_id; } } unset($record['signature']); return parent::formatStoreRecord($record, $model, $store); }
/** * 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; }
protected function actionGroupsWithResources($params) { $stmt = \GO\Calendar\Model\Group::model()->find(\GO\Base\Db\FindParams::newInstance()->order('t.name')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('id', 1, '>'))); $response['results'] = array(); $response['total'] = 0; while ($group = $stmt->fetch()) { $record = $group->getAttributes('formatted'); if (\GO::modules()->customfields) { $record['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Calendar\\Model\\Event", $group->id); } else { $record['customfields'] = array(); } $record['resources'] = array(); $calStmt = \GO\Calendar\Model\Calendar::model()->find(\GO\Base\Db\FindParams::newInstance()->permissionLevel(\GO\Base\Model\Acl::READ_PERMISSION)->joinCustomFields()->order('t.name')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('group_id', $group->id))); while ($resource = $calStmt->fetch()) { $resourceRecord = $resource->getAttributes('formatted'); $record['resources'][] = $resourceRecord; } $num_resources = count($record['resources']); if ($num_resources > 0) { $response['results'][] = $record; $response['total'] += $num_resources; } } return $response; }
public static function validateModel($model, $attrmapping = false) { // if(\GO\Base\Util\Http::isPostRequest()){ // if(!empty($attrmapping)){ // foreach($attrmapping as $attr=>$replaceattr){ // $model->$replaceattr = $_POST[$attr]; // } // } $errors = array(); if (!$model->validate()) { $errors = $model->getValidationErrors(); } if ($model->customfieldsRecord && !$model->customfieldsRecord->validate()) { $errors = array_merge($errors, $model->customfieldsRecord->getValidationErrors()); } if (count($errors)) { foreach ($errors as $attribute => $message) { $formAttribute = isset($attrmapping[$attribute]) ? $attrmapping[$attribute] : $attribute; Input::setError($formAttribute, $message); // replace is needed because of a mix up with order model and company model } Error::setError(\GO::t('errorsInForm')); return false; } else { return true; } }
private function _write($data) { if (!isset($this->_fp)) { $this->_fp = fopen('php://output', 'w+'); } fputcsv($this->_fp, $data, \GO::user()->list_separator, \GO::user()->text_separator); }
public static function checkIpAddress(array &$params, array &$response) { $oldIgnoreAcl = \GO::setIgnoreAclPermissions(); $userModel = \GO\Base\Model\User::model()->findSingleByAttribute('username', $params['username']); if (!$userModel) { return true; } $allowedIpAddresses = array(); //"127.0.0.1"); $whitelistIpAddressesStmt = Model\IpAddress::model()->find(\GO\Base\Db\FindParams::newInstance()->select('t.ip_address')->joinModel(array('model' => 'GO\\Ipwhitelist\\Model\\EnableWhitelist', 'localTableAlias' => 't', 'localField' => 'group_id', 'foreignField' => 'group_id', 'tableAlias' => 'ew', 'type' => 'INNER'))->joinModel(array('model' => 'GO\\Base\\Model\\UserGroup', 'localTableAlias' => 'ew', 'localField' => 'group_id', 'foreignField' => 'group_id', 'tableAlias' => 'usergroup', 'type' => 'INNER'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', $userModel->id, '=', 'usergroup'))); if (!empty($whitelistIpAddressesStmt) && $whitelistIpAddressesStmt->rowCount() > 0) { foreach ($whitelistIpAddressesStmt as $ipAddressModel) { // $enabledWhitelistModel = Model\EnableWhitelist::model()->findByPk($groupModel->id); // if (!empty($enabledWhitelistModel)) { // $ipAddressesStmt = Model\IpAddress::model()->findByAttribute('group_id',$groupModel->id); // foreach ($ipAddressesStmt as $ipAddressModel) { if (!in_array($ipAddressModel->ip_address, $allowedIpAddresses)) { $allowedIpAddresses[] = $ipAddressModel->ip_address; } // } // } } } \GO::setIgnoreAclPermissions($oldIgnoreAcl); if (count($allowedIpAddresses) > 0 && !in_array($_SERVER['REMOTE_ADDR'], $allowedIpAddresses)) { $response['feedback'] = sprintf(\GO::t('wrongLocation', 'ipwhitelist'), $_SERVER['REMOTE_ADDR']); $response['success'] = false; return false; } return true; }
/** * 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;" />'; }
/** * 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 actionSave($params) { if (empty($params['number']) || empty($params['remind_date']) || empty($params['remind_time'])) { throw new \Exception('Not all parameters are given'); } $scheduleCall = new \GO\Tasks\Model\Task(); $scheduleCall->setAttributes($params); // Check if the contact_id is really an ID or if it is a name. (The is_contact is true when it is an ID) if (!empty($params['contact_id'])) { $contact = \GO\Addressbook\Model\Contact::model()->findByPk($params['contact_id']); if (!empty($params['number']) && !empty($params['save_as'])) { $contact->{$params['save_as']} = $params['number']; $contact->save(); } $name = $contact->name; } else { $name = $params['contact_name']; } $scheduleCall->name = str_replace(array('{name}', '{number}'), array($name, $params['number']), \GO::t('scheduleCallTaskName', 'tasks')); $scheduleCall->reminder = \GO\Base\Util\Date::to_unixtime($params['remind_date'] . ' ' . $params['remind_time']); $scheduleCall->save(); if (isset($contact)) { $scheduleCall->link($contact); } echo $this->renderSubmit($scheduleCall); }
/** * 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); } }
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; }
/** * Get the data for the grid that shows all the tasks from the selected tasklists. * * @param Array $params * @return Array The array with the data for the grid. */ protected function actionBirthdays($params) { $today = mktime(0, 0, 0); $next_month = \GO\Base\Util\Date::date_add(mktime(0, 0, 0), 30); //\GO::debug($yesterday); $start = date('Y-m-d', $today); $end = date('Y-m-d', $next_month); //\GO::debug($start); $select = "t.id, birthday, first_name, middle_name, last_name, addressbook_id, photo, " . "IF (STR_TO_DATE(CONCAT(YEAR('{$start}'),'/',MONTH(birthday),'/',DAY(birthday)),'%Y/%c/%e') >= '{$start}', " . "STR_TO_DATE(CONCAT(YEAR('{$start}'),'/',MONTH(birthday),'/',DAY(birthday)),'%Y/%c/%e') , " . "STR_TO_DATE(CONCAT(YEAR('{$start}')+1,'/',MONTH(birthday),'/',DAY(birthday)),'%Y/%c/%e')) " . "as upcoming "; $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('birthday', '0000-00-00', '!=')->addRawCondition('birthday', 'NULL', 'IS NOT'); $settings = \GO\Addressbook\Model\BirthdaysPortletSetting::model()->findByAttribute('user_id', \GO::user()->id); if (count($settings)) { $abooks = array_map(function ($value) { return $value->addressbook_id; }, $settings->fetchAll()); $findCriteria->addInCondition('addressbook_id', $abooks); } $having = "upcoming BETWEEN '{$start}' AND '{$end}'"; $findParams = \GO\Base\Db\FindParams::newInstance()->distinct()->select($select)->criteria($findCriteria)->having($having)->order('upcoming'); //$response['data']['original_photo_url']=$model->photoURL; $columnModel = new \GO\Base\Data\ColumnModel('GO\\Addressbook\\Model\\Contact'); $columnModel->formatColumn('addressbook_id', '$model->addressbook->name'); $columnModel->formatColumn('photo_url', '$model->getPhotoThumbURL()'); $columnModel->formatColumn('age', '($model->upcoming != date("Y-m-d")) ? $model->age+1 : $model->age'); $store = new \GO\Base\Data\DbStore('GO\\Addressbook\\Model\\Contact', $columnModel, $_POST, $findParams); return $store->getData(); }
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(); }
/** * Set an authorization for an action so the current session is authorized to * process the action. * * @param string $name */ public static function setAuthorized($name) { if (empty(\GO::session()->values['Authorized'])) { \GO::session()->values['Authorized'] = array(); } \GO::session()->values['Authorized'][] = $name; }
public function __construct($mailbox, $imap) { // $imap->last_error(); // Get the last error $message = sprintf(\GO::t('MailboxNotFoundException'), $mailbox); $imap->clear_errors(); // Needed to clear the imap errors parent::__construct($message); }
protected function actionDisplay($params) { $findParams = \GO\Base\Db\FindParams::newInstance()->select('count(*) AS count')->join(\GO\Base\Model\ReminderUser::model()->tableName(), \GO\Base\Db\FindCriteria::newInstance()->addModel(\GO\Base\Model\Reminder::model())->addCondition('id', 'ru.reminder_id', '=', 't', true, true), 'ru')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(\GO\Base\Model\ReminderUser::model(), 'ru')->addCondition('user_id', \GO::user()->id, '=', 'ru')->addCondition('time', time(), '<', 'ru')); $model = \GO\Base\Model\Reminder::model()->findSingle($findParams); $html = ""; $this->fireEvent('reminderdisplay', array($this, &$html, $params)); $this->render("Reminder", array('count' => intval($model->count), 'html' => $html)); }
public function __construct($filename) { if (\GO::user()) { $this->delimiter = \GO::user()->list_separator; $this->enclosure = \GO::user()->text_separator; } $this->filename = $filename; }
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); }
public static function getDefaultLangId() { if (!isset(self::$_defaultLangId)) { $lang = Model\Language::model()->findSingleByAttribute('language', \GO::language()->getLanguage()); self::$_defaultLangId = $lang ? $lang->id : 1; } return self::$_defaultLangId; }
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 function defaultAttributes() { $attr = parent::defaultAttributes(); $attr['modified_user_id'] = \GO::user()->id; $attr['mtime'] = time(); $attr['status'] = 0; return $attr; }
public function formatDisplay($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model) { if (\GO\Customfields\Model\AbstractCustomFieldsRecord::$formatForExport) { return \GO\Base\Util\Crypt::decrypt($attributes[$key]); } $decrypted = !empty($attributes[$key]) ? '<div ext:qtip="' . htmlspecialchars(\GO\Base\Util\Crypt::decrypt($attributes[$key]), ENT_COMPAT, 'utf-8') . '">' . \GO::t('pointForText') . '</div>' : ''; return $decrypted; }
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; }
/** * Moves a file from one location to another * * @param string $sourcePath The path to the file which should be moved * @param string $destinationPath The full destination path, so not just the destination parent node * @return int */ public function move($sourcePath, $destinationPath) { \GO::debug("ObjectTree::move({$sourcePath}, {$destinationPath})"); $moveable = $this->getNodeForPath($sourcePath); $destination = $this->getNodeForPath(dirname($destinationPath)); $targetServerPath = $destination->getServerPath() . '/' . \GO\Base\Fs\File::utf8Basename($destinationPath); $moveable->move($targetServerPath); }
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 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);});'; } }
public static function initListeners() { if (\GO::modules()->isInstalled('calendar')) { \GO\Calendar\Model\Event::model()->addListener("delete", "GO\\Caldav\\CaldavModule", "deleteEvent"); } if (\GO::modules()->isInstalled('tasks')) { \GO\Tasks\Model\Task::model()->addListener("delete", "GO\\Caldav\\CaldavModule", "deleteTask"); } }