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; }
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; } }
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); } }
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; }
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 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 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 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(); } } }
protected function beforeSave() { $folderModel = Folder::model()->findByPk($this->folder_id); $existingBookmarkModel = Bookmark::model()->findSingleByAttributes(array('user_id' => \GO::user()->id, 'folder_id' => $folderModel->id)); if (!empty($existingBookmarkModel)) { throw new \Exception(str_replace('%fn', $folderModel->name, \GO::t('bookmarkAlreadyExists', 'files'))); } return parent::beforeSave(); }
public function validate() { foreach ($this->requiredAttributes as $attributeName) { if (empty($this->{$attributeName})) { $this->setValidationError($attributeName, sprintf(\GO::t('attributeRequired'), '"' . $this->getAttributeLabel($attributeName) . '"')); } } return !$this->hasValidationErrors(); }
protected function beforeDelete() { if ($this->id == \GO::config()->group_root) { throw new \Exception(\GO::t('noDeleteAdmins', 'groups')); } if ($this->id == \GO::config()->group_everyone) { throw new \Exception(\GO::t('noDeleteEveryone', 'groups')); } return parent::beforeDelete(); }
public static function loadSettings(&$settingsController, &$params, &$response, $user) { $startModule = \GO\Base\Model\Module::model()->findByPk($user->start_module); $response['data']['start_module_name'] = $startModule ? $startModule->moduleManager->name() : ''; $company = \GO\Addressbook\Model\Company::model()->findByPk($response['data']['company_id'], false, true); if ($company) { $response['data']['company_name'] = $company->name; } $response['remoteComboTexts']['holidayset'] = \GO::t($user->holidayset); return parent::loadSettings($settingsController, $params, $response, $user); }
public function formatColumns(\GO\Base\Data\ColumnModel $columnModel) { $sortAlias = \GO::user()->sort_name == "first_name" ? array('first_name', 'last_name') : array('last_name', 'first_name'); $columnModel->formatColumn('name', '$model->getName(\\GO::user()->sort_name)', array(), $sortAlias, \GO::t('strName')); $columnModel->formatColumn('company_name', '$model->company_name', array(), '', \GO::t('company', 'addressbook')); $columnModel->formatColumn('ab_name', '$model->ab_name', array(), '', \GO::t('addressbook', 'addressbook')); $columnModel->formatColumn('age', '$model->age', array(), 'birthday'); $columnModel->formatColumn('action_date', '$model->getActionDate()', array(), 'action_date'); $columnModel->formatColumn('cf', '$model->id.":".$model->name'); //special field used by custom fields. They need an id an value in one.) return parent::formatColumns($columnModel); }
private static function _wraparray($before, $after, $sugestions) { $out = ''; if (is_array($sugestions) && !empty($sugestions)) { foreach ($sugestions as $sugestion) { $out .= $before . $sugestion . $after; } } else { $out .= $before . \GO::t('No Sugestions') . $after; } return $out; }
public function formatFormOutput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model) { $column = $model->getColumn($key); if (!$column) { return null; } $fieldId = $column['customfield']->id; $findParams = \GO\Base\Db\FindParams::newInstance()->select('COUNT(*) AS count')->single()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('model_id', $model->model_id)->addCondition('field_id', $fieldId)); $model = \GO\Site\Model\MultifileFile::model()->find($findParams); $string = ''; $string = sprintf(\GO::t('multifileSelectValue', 'site'), $model->count); return $string; }
public function install() { if (\GO::modules()->isInstalled('site')) { $alreadyExists = \GO\Site\Model\Site::model()->findSingleByAttribute('module', 'defaultsite'); if (!$alreadyExists) { $siteProperties = array('name' => \GO::t('name', 'defaultsite'), 'user_id' => 1, 'domain' => '*', 'module' => 'defaultsite', 'ssl' => '0', 'mod_rewrite' => '0', 'mod_rewrite_base_path' => '/', 'base_path' => '', 'language' => ''); $defaultSite = new \GO\Site\Model\Site(); $defaultSite->setAttributes($siteProperties); $defaultSite->save(); } } return parent::install(); }
public function validate() { if (!empty($this->validation_regex)) { $this->_regex_has_errors = false; set_error_handler(array($this, "exception_error_handler")); preg_match($this->validation_regex, ""); if ($this->_regex_has_errors) { $this->setValidationError("validation_regex", \GO::t("invalidRegex", "customfields")); } restore_error_handler(); } return parent::validate(); }
public static function userSubmitted(\GO\Users\Controller\UserController $userController, &$response, &$userModel, &$submitParams, $modifiedAttributes) { $wwModel = \GO\Base\Model\WorkingWeek::model()->findSingleByAttribute('user_id', $userModel->id); if (empty($wwModel)) { $wwModel = new \GO\Base\Model\WorkingWeek(); } $wwModel->user_id = $userModel->id; $params = array('mo_work_hours' => $submitParams['mo_work_hours'], 'tu_work_hours' => $submitParams['tu_work_hours'], 'we_work_hours' => $submitParams['we_work_hours'], 'th_work_hours' => $submitParams['th_work_hours'], 'fr_work_hours' => $submitParams['fr_work_hours'], 'sa_work_hours' => $submitParams['sa_work_hours'], 'su_work_hours' => $submitParams['su_work_hours']); $wwModel->setAttributes($params); if (!$wwModel->save()) { $validationErrors = $wwModel->getValidationErrors(); throw new \Exception(\GO::t('couldNotSaveWW', 'leavedays') . ' ' . implode(', ', $validationErrors)); } }
protected function actionMove($params) { $account = \GO\Email\Model\Account::model()->findByPk($params['account_id']); $sourceMailbox = new \GO\Email\Model\ImapMailbox($account, array("name" => $params["sourceMailbox"])); if ($sourceMailbox->isSpecial()) { throw new \Exception(\GO::t("cantMoveSpecialFolder", "email")); } $targetMailbox = new \GO\Email\Model\ImapMailbox($account, array("name" => $params["targetMailbox"])); $response['success'] = $sourceMailbox->move($targetMailbox); if (!$response['success']) { $response['feedback'] = "Could not move folder {$sourceMailbox} to {$targetMailbox}.<br /><br />" . $account->getImapConnection()->last_error(); } return $response; }
/** * Returns the validation rules of the model. * @return array validation rules */ public function validate() { if (empty($this->name)) { $this->setValidationError('name', sprintf(\GO::t('attributeRequired'), 'name')); } if (empty($this->email)) { $this->setValidationError('email', sprintf(\GO::t('attributeRequired'), 'email')); } if (empty($this->message)) { $this->setValidationError('message', sprintf(\GO::t('attributeRequired'), 'message')); } if (!\GO\Base\Util\Validate::email($this->email)) { $this->setValidationError('email', \GO::t('invalidEmailError')); } return parent::validate(); }
public static function beforeLogin($params, &$response) { $oldIgnoreAcl = \GO::setIgnoreAclPermissions(true); $ia = new Authenticator(); if ($ia->setCredentials($params['username'], $params['password'])) { if ($ia->imapAuthenticate()) { if (!$ia->user) { \GO::debug("IMAPAUTH: Group-Office user doesn't exist."); if (!isset($params['first_name'])) { $response['needCompleteProfile'] = true; $response['success'] = false; $response['feedback'] = \GO::t('pleaseCompleteProfile', 'imapauth'); return false; } else { //user doesn't exist. create it now $user = new \GO\Base\Model\User(); $user->email = $ia->email; $user->username = $ia->goUsername; $user->password = $ia->imapPassword; $user->first_name = $params['first_name']; $user->middle_name = $params['middle_name']; $user->last_name = $params['last_name']; try { if (!$user->save()) { throw new \Exception("Could not save user: "******"\n", $user->getValidationErrors())); } if (!empty($ia->config['groups'])) { $user->addToGroups($ia->config['groups']); } $ia->user = $user; $user->checkDefaultModels(); //todo testen of deze regel nodig is om e-mail account aan te maken voor nieuwe gebruiker $ia->createEmailAccount($user, $ia->config, $ia->imapUsername, $ia->imapPassword); } catch (\Exception $e) { \GO::debug('IMAPAUTH: Failed creating user ' . $ia->goUsername . ' and e-mail ' . $ia->email . 'Exception: ' . $e->getMessage(), E_USER_WARNING); } } } } else { $response['feedback'] = GO::t('badLogin') . ' (IMAP)'; return false; } } \GO::setIgnoreAclPermissions($oldIgnoreAcl); }
public function install() { parent::install(); $group = new Model\Group(); $group->name = \GO::t('calendars', 'calendar'); $group->save(); $cron = new \GO\Base\Cron\CronJob(); $cron->name = 'Calendar publisher'; $cron->active = true; $cron->runonce = false; $cron->minutes = '0'; $cron->hours = '*'; $cron->monthdays = '*'; $cron->months = '*'; $cron->weekdays = '*'; $cron->job = 'GO\\Calendar\\Cron\\CalendarPublisher'; $cron->save(); }
protected function afterDisplay(&$response, &$model, &$params) { $response['data']['user_name'] = $model->user ? $model->user->name : ''; $response['data']['tasklist_name'] = $model->tasklist->name; $statuses = \GO::t('statuses', 'tasks'); $response['data']['status_text'] = isset($statuses[$model->status]) ? $statuses[$model->status] : $model->status; $response['data']['late'] = $model->isLate(); if ($model->percentage_complete > 0 && $model->status != 'COMPLETED') { $response['data']['status_text'] .= ' (' . $model->percentage_complete . '%)'; } $response['data']['project_name'] = ''; if (\GO::modules()->projects && $model->project) { $response['data']['project_name'] = $model->project->name; } if (\GO::modules()->projects2 && $model->project2) { $response['data']['project_name'] = $model->project2->name; } return parent::afterDisplay($response, $model, $params); }
protected function actionLoad($params) { $response = array(); $settings = \GO\Users\Model\Settings::load(); if (empty($settings->register_email_subject)) { $settings->register_email_subject = \GO::t('register_email_subject', 'users'); } if (empty($settings->register_email_body)) { $settings->register_email_body = \GO::t('register_email_body', 'users'); } // Load the custom field categories of the contact model if (\GO::modules()->customfields) { $tabs = \GO\Users\Model\CfSettingTab::model()->find(); foreach ($tabs as $t) { $response['tab_cf_cat_' . $t->cf_category_id] = true; } } $responseData = array_merge($response, $settings->getArray()); return array('success' => true, 'data' => $responseData); }
/** * Get the data for the grid that shows all the tasks from the selected calendars. * * @param Array $params * @return Array The array with the data for the grid. */ protected function actionPortletGrid($params) { $local_time = time(); $year = date("Y", $local_time); $month = date("m", $local_time); $day = date("j", $local_time); $periodStartTime = mktime(0, 0, 0, $month, $day, $year); $periodEndTime = mktime(0, 0, 0, $month, $day + 2, $year); $today_end = mktime(0, 0, 0, $month, $day + 1, $year); $joinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'pt')->addCondition('calendar_id', 'pt.calendar_id', '=', 't', true, true); $calendarJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('calendar_id', 'tl.id', '=', 't', true, true); $findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*, tl.name AS calendar_name')->join(\GO\Calendar\Model\PortletCalendar::model()->tableName(), $joinCriteria, 'pt')->join(\GO\Calendar\Model\Calendar::model()->tableName(), $calendarJoinCriteria, 'tl'); $events = \GO\Calendar\Model\Event::model()->findCalculatedForPeriod($findParams, $periodStartTime, $periodEndTime); $store = new \GO\Base\Data\ArrayStore(); foreach ($events as $event) { $record = $event->getResponseData(); $record['day'] = $event->getAlternateStartTime() < $today_end ? \GO::t('today') : \GO::t('tomorrow'); $record['time'] = $event->getEvent()->all_day_event == 1 ? '-' : $record['time']; $store->addRecord($record); } return $store->getData(); }
protected function actionContacts($params) { $store = \GO\Base\Data\Store::newInstance(\GO\Addressbook\Model\Contact::model()); $sortAlias = \GO::user()->sort_name == "first_name" ? array('first_name', 'last_name') : array('last_name', 'first_name'); $store->getColumnModel()->formatColumn('name', '$model->getName(\\GO::user()->sort_name)', array(), $sortAlias, \GO::t('strName')); //$store->getColumnModel()->formatColumn('name', '$model->name', array(), array('first_name', 'last_name')); $store->getColumnModel()->formatColumn('company_name', '$model->company->name', array(), 'company_id'); $store->getColumnModel()->formatColumn('addressbook_name', '$model->addressbook->name', array(), 'addressbook_id'); $store->processDeleteActions($params, "GO\\Addressbook\\Model\\AddresslistContact", array('addresslist_id' => $params['addresslist_id'])); $response = array(); if (!empty($params['add_addressbook_id'])) { $addressbook = \GO\Addressbook\Model\Addressbook::model()->findByPk($params['add_addressbook_id']); $model = \GO\Addressbook\Model\Addresslist::model()->findByPk($params['addresslist_id']); $stmt = $addressbook->contacts(); while ($contact = $stmt->fetch()) { $model->addManyMany('contacts', $contact->id); } } elseif (!empty($params['add_keys'])) { $add_keys = json_decode($params['add_keys'], true); $model = \GO\Addressbook\Model\Addresslist::model()->findByPk($params['addresslist_id']); foreach ($add_keys as $add_key) { $model->addManyMany('contacts', $add_key); } } elseif (!empty($params['add_search_result'])) { $findParams = \GO::session()->values["contact"]['findParams']; $findParams->getCriteria()->recreateTemporaryTables(); $findParams->limit(0)->select('t.id'); $model = \GO\Addressbook\Model\Addresslist::model()->findByPk($params['addresslist_id']); $stmt = \GO\Addressbook\Model\Contact::model()->find($findParams); foreach ($stmt as $contact) { $model->addManyMany('contacts', $contact->id); } } $stmt = \GO\Addressbook\Model\Addresslist::model()->findByPk($params['addresslist_id'])->contacts($store->getDefaultParams($params)); $store->setDefaultSortOrder('name', 'ASC'); $store->setStatement($stmt); return array_merge($response, $store->getData()); }
public function formatReminderRecord($record, $model, $store) { $record['iconCls'] = 'go-icon-reminders'; $record['type'] = \GO::t('other'); $record['model_name'] = ''; if (!empty($record['model_type_id'])) { $modelType = \GO\Base\Model\ModelType::model()->findByPk($record['model_type_id']); if ($modelType && \GO::getModel($modelType->model_name)) { $record['iconCls'] = 'go-model-icon-' . $modelType->model_name; $record['type'] = \GO::getModel($modelType->model_name)->localizedName; $record['model_name'] = $modelType->model_name; } } $now = \GO\Base\Util\Date::clear_time(time()); $time = $model->vtime ? $model->vtime : $model->time; if (\GO\Base\Util\Date::clear_time($time) != $now) { $record['local_time'] = date(\GO::user()->completeDateFormat, $time); } else { $record['local_time'] = date(\GO::user()->time_format, $time); } $record['text'] = htmlspecialchars_decode($record['text']); return $record; }
protected function actionInstallModules($params) { $response = array('success' => true, 'feedback' => ''); if (!\GO::modules()->isAvailable('site')) { throw new \Exception("site module is not available!"); } if (!\GO::modules()->isAvailable('defaultsite')) { throw new \Exception("defaultsite module is not available!"); } $siteModule = new \GO\Base\Model\Module(); $siteModule->id = 'site'; if (\GO::modules()->isInstalled('site') || $siteModule->save()) { $defaultSiteModule = new \GO\Base\Model\Module(); $defaultSiteModule->id = 'defaultsite'; if (!$defaultSiteModule->save()) { $response['success'] = false; $response['feedback'] = \GO::t('installdefaultsiteerror', 'defaultsite'); } } else { $response['success'] = false; $response['feedback'] = \GO::t('installsiteerror', 'defaultsite'); } echo $this->renderJson($response); }
/** * Page with a login form * If $siteconfig['tickets_allow_anonymous'] is set to TRUE then this page * shows also a link to the "New ticket" page. */ protected function actionTicketLogin() { // Create an empty user model $model = new \GO\Base\Model\User(); if (\GO\Base\Util\Http::isPostRequest()) { // Set the posted values to the user model $model->username = $_POST['User']['username']; $password = $_POST['User']['password']; // Check if the login is correct, then the correct user object is returned $user = \GO::session()->login($model->username, $password); if (!$user) { // set the correct login failure message GOS::site()->notifier->setMessage('error', \GO::t('badLogin')); } else { if (!empty($_POST['rememberMe'])) { // Encrypt the username for the rememberMe cookie $encUsername = \GO\Base\Util\Crypt::encrypt($model->username); if ($encUsername) { $encUsername = $model->username; } // Encrypt the password for the rememberMe cookie $encPassword = \GO\Base\Util\Crypt::encrypt($password); if ($encPassword) { $encPassword = $password; } // Set the rememberMe cookies \GO\Base\Util\Http::setCookie('GO_UN', $encUsername); \GO\Base\Util\Http::setCookie('GO_PW', $encPassword); } // Login is successfull, redirect to the ticketlist page $this->redirect(array('tickets/site/ticketlist')); } } // Render the loginselection form $this->render('loginSelection', array('model' => $model)); }