本文整理汇总了PHP中GO::t方法的典型用法代码示例。如果您正苦于以下问题:PHP GO::t方法的具体用法?PHP GO::t怎么用?PHP GO::t使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GO
的用法示例。
在下文中一共展示了GO::t方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkIpAddress
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;
}
示例2: validateModel
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;
}
}
示例3: actionSave
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);
}
示例4: run
/**
* 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);
}
}
示例5: install
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;
}
示例6: install
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);
}
示例7: formatDisplay
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;
}
示例8: __construct
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);
}
示例9: beforeSubmit
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();
}
}
}
示例10: beforeSave
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();
}
示例11: validate
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();
}
示例12: beforeDelete
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();
}
示例13: loadSettings
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);
}
示例14: formatColumns
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);
}
示例15: _wraparray
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;
}