Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2063

Přidáno uživatelem Ondřej Fibich před asi 11 roky(ů)

Upravy:
- optimalizace javascriptu ve formulari s mezistrankou presmerovani

Zobrazit rozdíly:

freenetis/branches/1.1/application/controllers/messages.php
Message_Model::has_email_content($message->type))
{
$grid->form_field('email')
->label('E-Mail')
->label('E-mail')
->type('dropdown')
->options(notification::redirection_form_array(TRUE))
->callback(
freenetis/branches/1.1/application/controllers/notifications.php
Message_Model::has_email_content($message->type))
{
$grid->form_field('email')
->label('E-Mail')
->label('E-mail')
->type('dropdown')
->options(notification::redirection_form_array(TRUE))
->callback(
......
)->class('center');
}
// only if e-mail is enabled
// only if E-mail is enabled
if (module::e('email') &&
Message_Model::has_email_content($message->type))
{
$grid->form_field('email')
->label('E-Mail')
->label('E-mail')
->type('dropdown')
->options(notification::redirection_form_array(TRUE))
->callback(
......
);
}
// only if e-mail is enabled
// only if E-mail is enabled
if (module::e('email') &&
Message_Model::has_email_content($message->type))
{
$grid->form_field('email')
->label('E-Mail')
->label('E-mail')
->type('dropdown')
->options(notification::redirection_form_array(TRUE))
->callback(
......
* @param integer $user_id Who notify or on empty association main user [optional]
* @param string $comment Comment for the message [optional]
* @param boolean $activate_redir Should be redirection activated [optional]
* @param boolean $activate_email Should be e-mail activated [optional]
* @param boolean $activate_email Should be E-mail activated [optional]
* @param boolean $activate_sms Should be SMS activated [optional]
* @param boolean $truncate_redir Should be all redirection of this type removed
* before adding [optional]
......
throw new Exception($m, 0, $e);
}
}
// activate e-mail notification
// activate E-mail notification
if (module::e('email') && $activate_email &&
$message->has_email_content($message->type))
{
freenetis/branches/1.1/application/models/message.php
$eq_model = new Email_queue_Model();
// start transaction
$eq_model->transaction_start();
// for each contact
foreach ($contacts as $contact)
{
......
$subject = Settings::get('email_subject_prefix')
. ': ' . __($message->name);
// add Email to queue
// add Email to queue
$eq_model->clear();
$eq_model->from = Settings::get('email_default_email');
$eq_model->to = $contact->value;
......
$eq_model->body = $text;
$eq_model->state = Email_queue_Model::STATE_NEW;
$eq_model->save_throwable();
// add SMS to counter
// add E-mail to counter
$email_count++;
}
// commit
$eq_model->transaction_commit();
}
freenetis/branches/1.1/application/views/js/__pieces/notification_activate.php
?>
$("<div>"+
"<table class=state_change_all_table>" +
" <tr>" +
" <td>&nbsp;</td>" +
<?php if (Settings::get('redirection_enabled')): ?> " <td class=center><b><?php echo __("Redirection") ?>:</b></td>" + <?php endif ?>
<?php if (Settings::get('email_enabled')): ?> " <td class=center><b><?php echo __("E-Mail") ?>:</b></td>" + <?php endif ?>
<?php if (Settings::get('sms_enabled')): ?> " <td class=center><b><?php echo __("SMS") ?>:</b></td>" + <?php endif ?>
" </tr>" +
" <tr>" +
" <td><?php echo __("For all items") ?>:</td>" +
<?php if (Settings::get('redirection_enabled')): ?> " <td class='state_change_all' id='state_change_all_redirection_activate'><img src='<?php echo url::base() ?>media/images/icons/activate.png'> <?php echo __("Activate") ?></td>" + <?php endif ?>
<?php if (Settings::get('email_enabled')): ?> " <td class='state_change_all' id='state_change_all_email_activate'><img src='<?php echo url::base() ?>media/images/icons/activate.png'> <?php echo __("Activate") ?></td>" + <?php endif ?>
<?php if (Settings::get('sms_enabled')): ?> " <td class='state_change_all' id='state_change_all_sms_activate'><img src='<?php echo url::base() ?>media/images/icons/activate.png'> <?php echo __("Activate") ?></td>" + <?php endif ?>
" </tr>" +
" <tr>" +
" <td><?php echo __("For all items") ?>:</td>" +
<?php if (Settings::get('redirection_enabled')): ?> " <td class='state_change_all' id='state_change_all_redirection_keep'><img src='<?php echo url::base() ?>media/images/icons/keep.png'> <?php echo __("Without change") ?></td>" + <?php endif ?>
<?php if (Settings::get('email_enabled')): ?> " <td class='state_change_all' id='state_change_all_email_keep'><img src='<?php echo url::base() ?>media/images/icons/keep.png'> <?php echo __("Without change") ?></td>" + <?php endif ?>
<?php if (Settings::get('sms_enabled')): ?> " <td class='state_change_all' id='state_change_all_sms_keep'><img src='<?php echo url::base() ?>media/images/icons/keep.png'> <?php echo __("Without change") ?></td>" + <?php endif ?>
" </tr>" +
" <tr>" +
" <td><?php echo __("For all items") ?>:</td>" +
<?php if (Settings::get('redirection_enabled')): ?> " <td class='state_change_all' id='state_change_all_redirection_deactivate'><img src='<?php echo url::base() ?>media/images/icons/deactivate.png'> <?php echo __("Deactivate") ?></td>" +<?php endif ?>
" </tr>" +
"</table>" +
"</div>").insertBefore($(".grid_table", context));
var notif_dd_img_src = {
<?php echo Notifications_Controller::ACTIVATE ?> : '<?php echo url::base() ?>media/images/icons/activate.png',
<?php echo Notifications_Controller::KEEP ?> : '<?php echo url::base() ?>media/images/icons/keep.png',
<?php echo Notifications_Controller::DEACTIVATE ?> : '<?php echo url::base() ?>media/images/icons/deactivate.png'
};
$(".state_change_all").click(function (){
var notif_dd_img_title = {
<?php echo Notifications_Controller::ACTIVATE ?> : '<?php echo __('Activate') ?>',
<?php echo Notifications_Controller::KEEP ?> : '<?php echo __('Keep') ?>',
<?php echo Notifications_Controller::DEACTIVATE ?> : '<?php echo __('Deactivate') ?>'
};
$("<div> \
<table class=state_change_all_table> \
<tr> \
<td>&nbsp;</td> \
<?php if (Settings::get('redirection_enabled')): ?> <td class=center><b><?php echo __("Redirection") ?>:</b></td> <?php endif ?> \
<?php if (Settings::get('email_enabled')): ?> <td class=center><b><?php echo __("E-mail") ?>:</b></td> <?php endif ?> \
<?php if (Settings::get('sms_enabled')): ?> <td class=center><b><?php echo __("SMS") ?>:</b></td> <?php endif ?> \
</tr> \
<tr> \
<td><?php echo __("For all items") ?>:</td> \
<?php if (Settings::get('redirection_enabled')): ?> <td class='state_change_all' id='state_change_all_redirection_activate'><img src='<?php echo url::base() ?>media/images/icons/activate.png'> <?php echo __("Activate") ?></td><?php endif ?> \
<?php if (Settings::get('email_enabled')): ?> <td class='state_change_all' id='state_change_all_email_activate'><img src='<?php echo url::base() ?>media/images/icons/activate.png'> <?php echo __("Activate") ?></td><?php endif ?> \
<?php if (Settings::get('sms_enabled')): ?> <td class='state_change_all' id='state_change_all_sms_activate'><img src='<?php echo url::base() ?>media/images/icons/activate.png'> <?php echo __("Activate") ?></td><?php endif ?> \
</tr> \
<tr> \
<td><?php echo __("For all items") ?>:</td> \
<?php if (Settings::get('redirection_enabled')): ?> <td class='state_change_all' id='state_change_all_redirection_keep'><img src='<?php echo url::base() ?>media/images/icons/keep.png'> <?php echo __("Without change") ?></td><?php endif ?> \
<?php if (Settings::get('email_enabled')): ?> <td class='state_change_all' id='state_change_all_email_keep'><img src='<?php echo url::base() ?>media/images/icons/keep.png'> <?php echo __("Without change") ?></td><?php endif ?> \
<?php if (Settings::get('sms_enabled')): ?> <td class='state_change_all' id='state_change_all_sms_keep'><img src='<?php echo url::base() ?>media/images/icons/keep.png'> <?php echo __("Without change") ?></td><?php endif ?> \
</tr> \
<tr> \
<td><?php echo __("For all items") ?>:</td> \
<?php if (Settings::get('redirection_enabled')): ?> <td class='state_change_all' id='state_change_all_redirection_deactivate'><img src='<?php echo url::base() ?>media/images/icons/deactivate.png'> <?php echo __("Deactivate") ?></td><?php endif ?> \
</tr> \
</table> \
</div>").insertBefore($(".grid_table", context));
$(".state_change_all").click(function ()
{
var arr = explode("_", str_replace("state_change_all_", "", this.id));
$("select[name^="+arr[0]+"]").each(function () {
$("select[name^="+arr[0]+"]").each(function ()
{
switch (arr[1])
{
case "activate":
$(this).val(<?php echo Notifications_Controller::ACTIVATE?>);
$(this).val(<?php echo Notifications_Controller::ACTIVATE ?>);
break;
case "keep":
$(this).val(<?php echo Notifications_Controller::KEEP?>);
$(this).val(<?php echo Notifications_Controller::KEEP ?>);
break;
case "deactivate":
$(this).val(<?php echo Notifications_Controller::DEACTIVATE?>);
$(this).val(<?php echo Notifications_Controller::DEACTIVATE ?>);
break;
}
$(this).trigger("change");
notif_dd_change(false, $(this));
});
});
$("select[name^=redirection],select[name^=email],select[name^=sms]").each(function (){
$(this).attr("id", str_replace("]","", str_replace("[","_", $(this).attr("name"))));
notif_dd_change(false, $(this));
});
$("select[name^=redirection],select[name^=email],select[name^=sms]").change(function (){
if (!$(this).hasClass("dispNone"))
{
$(this).addClass("dispNone");
$(this).parent().attr("class", "state_change center").attr("id", "state_change_"+this.id);
$(this).parent().append("<img src='' class='state_change_image' id='state_change_image_"+this.id+"'>");
}
$("#state_change_image_"+this.id).removeClass("dispNone");
function notif_dd_change(eventObj, elem)
{
var $this = (elem === undefined) ? $(this) : elem;
switch ($(this).val())
{
case '<?php echo Notifications_Controller::ACTIVATE ?>':
//$(this).parent().addClass('active');
//$(this).parent().removeClass('deactive');
$("#state_change_image_"+this.id).attr("src", "<?php echo url::base() ?>media/images/icons/activate.png");
title = "<?php echo __('Activate') ?>";
break;
case '<?php echo Notifications_Controller::KEEP ?>':
//$(this).parent().removeClass('active');
//$(this).parent().removeClass('deactive');
$("#state_change_image_"+this.id).attr("src", "<?php echo url::base() ?>media/images/icons/keep.png");
title = "<?php echo __('Without change') ?>";
break;
case '<?php echo Notifications_Controller::DEACTIVATE ?>':
//$(this).parent().addClass('deactive');
//$(this).parent().removeClass('active');
$("#state_change_image_"+this.id).attr("src", "<?php echo url::base() ?>media/images/icons/deactivate.png");
title = "<?php echo __('Deactivate') ?>";
break;
}
$("#state_change_image_"+this.id).attr("title", title);
}).trigger('change');
var val = $this.val();
var id = $this.attr('id');
if (!$this.hasClass("dispNone"))
{
$this.addClass("dispNone").parent()
.attr("class", "state_change center")
.attr("id", "state_change_" + id)
.append("<img src='" + notif_dd_img_src[val] + "' title='" + notif_dd_img_title[val] +
"' class='state_change_image' id='state_change_image_" + id + "'>");
}
else
{
$("#state_change_image_" + id).removeClass("dispNone")
.attr("src", notif_dd_img_src[val])
.attr("title", notif_dd_img_title[val]);
}
}
$(".state_change").click(function (){
$("select[name^=redirection],select[name^=email],select[name^=sms]").change(notif_dd_change);
$(".state_change").click(function ()
{
var id = str_replace("state_change_", "", this.id);
var value = $("#"+id+" option:selected").attr("value");
......
$("#"+id+" option").removeAttr("selected");
$("#"+id+" option[value='"+value+"']").attr("selected", "selected");
$("#"+id+" option[value='"+value+"']").trigger("change");
$("#"+id+" option[value='"+value+"']").attr("selected", "selected")
.trigger("change");
});
$(".grid_form").submit(function (){
$(".grid_form").submit(function ()
{
return window.confirm('<?php echo __('Do you really want to activate notifications') ?>?');
});

Také k dispozici: Unified diff