Yii 1.1: notifyii

A module for notifications
21 followers

Notifyii

Be shure to have the same 'db' configuratiion in these files:
protected/config/main.php
protected/config/console.php

To install notifyii, navigate to the forlder "protected/modules" of your project. If your project does not have any "modules" folder, just create id. Then, run the command:

$ git clone git@github.com:sensorario/notifyii

Now you just need to add module to confi file:

'modules'=>array(
    'notifyii',
),

And try to load these routes:

index.php?r=notifyii
index.php?r=notifyii/modelNotifyii

The first one show you a sample page that create a sample notification. The second one show you a crud to alter notifications.

If you want you can add these items to views/layouts/main.php file:

array('label'=>'Notifyii', 'url'=>array('/notifyii')),
array('label'=>'ModelNotifyii', 'url'=>array('/notifyii/modelNotifyii')),
array('label'=>'NotifyiiReads', 'url'=>array('/notifyii/notifyiiReads')),

Run migrations

/var/www/YOUR_APP_NAME/protected$ ./yiic migrate --migrationPath=webroot.modules.notifyii.migrations

Notify the end of the world

$notifyii = new Notifyii();
$notifyii->title('Mayans news!');
$notifyii->message('The end of the world');
$notifyii->expire(new DateTime("21-12-2012"));
$notifyii->from("-1 week");
$notifyii->to("+1 day");
$notifyii->role("admin");
$notifyii->link($this->createUrl('/site/index'));
$notifyii->save();

Get all notifications

ModelNotifyii::getAllNotifications()
ModelNotifyii::getAllRoledNotifications()

Usage

Suppose to load all notifications in your controller:

public function actionIndex()
{
    $this->render('index', array(
        'notifiche' => ModelNotifyii::getAllNotifications()
    ));
}

In the view, you can load all notifications

<?php foreach ($notifiche as $notifica) : ?>
    <?php if ($notifica->isNotReaded()) : ?>
        <div class="box">
            <h3><?php echo $notifica->title; ?></h3>
            <a href="<?php echo $notifica->link; ?>">
                <?php echo $notifica->expire; ?></a> - 
            <a href="<?php echo $notifica->link; ?>">
                <?php echo $notifica->content; ?></a> <br />
            <a href="<?php echo $this->createUrl('/notifyii/default/read',
                array('id' => $notifica->id)); ?>">
                    segna questa notifica come letta</a>
        </div>
    <?php endif; ?>
<?php endforeach; ?>

GitHub

https://github.com/sensorario/notifyii/

1.3 (??? ??, ????)

Bugfixes:

  • #26: Fixed title implementation

1.2 (Oct 25, 2012)

Bugfixes:

  • #16: You can add a notification with empty values bug

Enhancement:

  •  #23: Delete past notifications.
  •  #21: Added a title to notifications.
  •  #07: I can see notifications grouped by role.
  •  #22: I want to see who has read a notitication.
  •  #14: Improve notifyii backend pages UI.
  • #17: New notifications with CJuiDatePicker.
  • #13: Update form creation with roles.
  • #04: work with yii flash messages.

1.1 (Oct 10, 2012)

Enhancement:

  • #10: La notifica deve avere anche un link.
  • #09: Una notifica può essere marcata come letta.
  • #08: Aggiungere un tip per la configurazione della connessione della console.
  • #01: Migliorare la sintassi per recuperare tutte quante le notifiche.

1.0 (Oct 10, 2012)

Enhancement:

  • #3: Aggiungere rights o RBAC tra i prerequisiti della documentazione.
  • #2: Gestire anche il ruolo.

Bugfixes:

  • #6: Fix Readme bug
  • #5: Repository contains nbproject folder.

Total 5 comments

#10823 report it
sensorario at 2012/11/26 08:15am
Due to configuration:

Console and website configurations are different:

protected/config/main.php protected/config/console.php

If you have deleted database and receive that message, maybe means that you have console.php still configured with sqlite.

#10815 report it
kfahmi at 2012/11/26 04:14am
Help

I used this for a week. the database and module work nice. when i deleted the database, i do a migrate again in the command prompt to get a database/ table again. why the systems respond "no new migration found,your system is uptodate"

#10254 report it
Cheesy at 2012/10/15 03:24am
great

This exactly what i was looking for!!! great work.

#10209 report it
sensorario at 2012/10/11 04:20am
Nope

I do not write code when is not needed. But I think to introduce a "purge" function that aggregate notifications and/or delete readed (and no more useful) notifications.

At the moment notifyii has a crud. But I'll put some automatic stuff to improve performace for biggest sites.

#10208 report it
Pentium10 at 2012/10/11 03:50am
Limits

Have you tested its limits? How well performs for a large website? How can be scaled?

Leave a comment

Please to leave your comment.

Create extension