public function addUpdateEndorsement($skill_endorsement_id, $skill_id, $display_user_id, $logged_user_id, $message)
 {
     $dbc = mysqli_connect($GLOBALS['db_servername'], $GLOBALS['db_username'], $GLOBALS['db_password'], $GLOBALS['db_name']) or die("Not connected..");
     if ($skill_endorsement_id <= 0) {
         $q = "INSERT INTO skill_endorsements (user_id, skill_id, endorsed_by_user_id, comments)\nVALUES (" . $display_user_id . "," . $skill_id . "," . $logged_user_id . ",'" . $message . "')";
     } else {
         $q = "Update skill_endorsements \n\t\t\t\t\tset \n\t\t\t\t\t\tcomments='" . $message . "',\n\t\t\t\t\t\tendorsed_on=CURRENT_TIMESTAMP\n\t\t\t\t\twhere skill_endorsement_id=" . $skill_endorsement_id;
     }
     //echo $q . '<br>';
     $r = mysqli_query($dbc, $q);
     // Get $skill_endorsement_id of the insert query
     if ($skill_endorsement_id <= 0) {
         $skill_endorsement_id = -1;
         if ($r) {
             $skill_endorsement_id = mysqli_insert_id($dbc);
         }
     }
     mysqli_close($dbc);
     // close the connection
     if ($r) {
         // Add notification -- endorsed
         $objNotification = new notification();
         $result = $objNotification->addNotification(3, $display_user_id, $logged_user_id, $skill_endorsement_id);
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 public function checknoti()
 {
     $notifications = notification::where('user_id', Auth::user()->id)->get();
     //dd(empty($notifications));
     if ($notifications->count()) {
         return response()->json(1);
     }
     return response()->json(0);
 }
 static function album($menu, $theme)
 {
     if (!user::active()->guest) {
         $item = $theme->item();
         if ($item) {
             $watching = notification::is_watching($item);
             $menu->append(Menu::factory("link")->id("watch")->label(t("Enable notifications for this album"))->url(url::site("notification/watch/{$item->id}?csrf=" . access::csrf_token()))->css_id($watching ? "gRemoveWatchLink" : "gAddWatchLink"));
         }
     }
 }
Example #4
0
 static function site_menu($menu, $theme)
 {
     if (!user::active()->guest) {
         $item = $theme->item();
         if ($item && $item->is_album() && access::can("view", $item)) {
             $watching = notification::is_watching($item);
             $label = $watching ? t("Remove notifications") : t("Enable notifications");
             $menu->get("options_menu")->append(Menu::factory("link")->id("watch")->label($label)->css_id("gNotifyLink")->url(url::site("notification/watch/{$item->id}?csrf=" . access::csrf_token())));
         }
     }
 }
 /**
  * Takes notification data and sends a message or email.
  * Expected data:
  * - sender => stdClass (User object)
  * - subject => string
  * - content => string
  * - contentformat => int (e.g. FORMAT_HTML). Optional; default FORMAT_PLAIN
  * - notification => bool|int
  * - recipients => array (Array of user objects)
  * - recipientemails => array (Array of email addresses)
  *
  * @param array $data Notification data
  * @return array
  */
 public static function notify(\core\event\base $event)
 {
     $dataformid = $event->other['dataid'];
     $man = \mod_dataform_notification_manager::instance($dataformid);
     $result = false;
     if ($rules = $man->get_type_rules_enabled()) {
         $params = array();
         $params['event'] = $event->eventname;
         $params['dataformid'] = $dataformid;
         $params['viewid'] = !empty($event->other['viewid']) ? $event->other['viewid'] : null;
         $params['entryid'] = !empty($event->other['entryid']) ? $event->other['entryid'] : null;
         foreach ($rules as $rule) {
             if ($rule->is_applicable($params)) {
                 $notification = new notification();
                 $message = $notification->prepare_data($event, $rule);
                 $result = ($result or $notification->send_message($message));
             }
         }
     }
     return $result;
 }
Example #6
0
 function watch($id)
 {
     access::verify_csrf();
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     if (notification::is_watching($item)) {
         notification::remove_watch($item);
         message::success(sprintf(t("You are no longer watching %s"), $item->title));
     } else {
         notification::add_watch($item);
         message::success(sprintf(t("You are now watching %s"), $item->title));
     }
     url::redirect($item->url(array(), true));
 }
Example #7
0
 function watch($id)
 {
     access::verify_csrf();
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     $watching = notification::is_watching($item);
     if (!$watching) {
         notification::add_watch($item);
         message::success(sprintf(t("Watch Enabled on %s!"), $item->title));
     } else {
         notification::remove_watch($item);
         message::success(sprintf(t("Watch Removed on %s!"), $item->title));
     }
     url::redirect($item->url());
 }
Example #8
0
} else {
    //	echo "<script> alert('3'); </script>";
    $stm = "select * from users where email='" . $email . "'";
    $res = mysqli_query($conn, $stm);
    if (mysqli_num_rows($res) > 0) {
        //		echo "<script> alert('4'); </script>";
        $_SESSION['errorMess'] = 2;
        echo "<meta http-equiv='refresh' content='0; url=http://32.208.103.211/chatRegistration/registerHere.php'>";
        //		echo "<script> alert('5'); </script>";
    } else {
        //		echo "<script> alert('6'); </script>";
        $value = 0;
        $cnumber = $cc . $cnumber;
        $stm = "insert into users(name, lname, email, username, password, contactNumber, activationCode,activated) values('" . $fname . "','" . $lname . "','" . $email . "','" . $uname . "','" . $password . "'," . $cnumber . "," . $activation . "," . $value . ");";
        mysqli_query($conn, $stm);
        //		echo "<script> alert('7'); </script>";
        $not = new notification();
        $link = "http://32.208.103.211/chatRegistration/activateAccount.php?activationCode=" . $activation . "&email=" . $email;
        $body = "Thank you for registering with us.<br><br><a href='" . $link . "'>Click here</a> to activate your account.";
        $ans = $not->email("*****@*****.**", "Administration", "*****@*****.**", "mailstodeliver", $email, "Activation Email", $body);
        $_SESSION['emailSent'] = $ans;
        echo "<script> alert('" . $ans . "'); </script>";
        if ($ans == 1) {
            $refCode = $not->message("12035432147", $cnumber, $link);
        }
        //		echo "<script> alert('8'); </script>";
        $_SESSION['newlyRegistered'] = $uname;
        echo "<meta http-equiv='refresh' content='0; url=http://32.208.103.211/chatRegistration/imageUpload.php'>";
    }
}
mysqli_close($conn);
Example #9
0
 /**
  * Function to handle course recurrence events.
  *
  * @param   user      $user  CM user object representing the user in the course
  *
  * @return  boolean          TRUE is successful, otherwise FALSE
  */
 public static function course_recurrence_handler($user)
 {
     global $CFG, $CURMAN;
     require_once $CFG->dirroot . '/curriculum/lib/notifications.php';
     /// Does the user receive a notification?
     $sendtouser = $CURMAN->config->notify_courserecurrence_user;
     $sendtorole = $CURMAN->config->notify_courserecurrence_role;
     $sendtosupervisor = $CURMAN->config->notify_courserecurrence_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     $context = get_system_context();
     /// Make sure this is a valid user.
     $enroluser = new user($user->id);
     if (empty($enroluser->id)) {
         print_error('nouser', 'block_curr_admin');
         return true;
     }
     $message = new notification();
     /// Set up the text of the message
     $text = empty($CURMAN->config->notify_courserecurrence_message) ? get_string('notifycourserecurrencemessagedef', 'block_curr_admin') : $CURMAN->config->notify_courserecurrence_message;
     $search = array('%%userenrolname%%', '%%coursename%%');
     $replace = array(fullname($user), $user->coursename);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'course_recurrence';
     $eventlog->instance = $user->enrolmentid;
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_courserecurrence capability.
         if ($roleusers = get_users_by_capability($context, 'block/curr_admin:notify_courserecurrence')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = cm_get_users_by_capability('user', $user->id, 'block/curr_admin:notify_courserecurrence')) {
             $users = $users + $supervisors;
         }
     }
     foreach ($users as $u) {
         $message->send_notification($text, $u, $enroluser, $eventlog);
     }
     return true;
 }
Example #10
0
 print "mailing to {$recipient_name} <{$email}>\n";
 $content = task_header($recipient_name);
 $sql = "SELECT tas.id, tas.name, pro.id, pro.name, tas.priority, tas.status, tas.due_date\r\n    FROM " . $tableCollab["tasks"] . " tas, " . $tableCollab["projects"] . " pro\r\n    WHERE tas.status IN (2,3) \r\n    AND tas.project = pro.id\r\n    AND tas.assigned_to = '{$staffid}'\r\n    ORDER BY tas.due_date, tas.status";
 $rows = mysql_query($sql, $res);
 while ($row = mysql_fetch_row($rows)) {
     if ($row[6] < $datenow) {
         $content .= task_row($row, $late_task_color);
     } elseif ($row[6] == $datenow) {
         $content .= task_row($row, $today_task_color);
     } else {
         $content .= task_row($row, $normal_task_color);
     }
 }
 $content .= task_footer();
 // set up the email object
 $tasknotice = new notification();
 $tasknotice->From = $from_email;
 $tasknotice->FromName = $from_name;
 $tasknotice->Subject = $subject_txt;
 $tasknotice->Body = $content;
 $tasknotice->AddAddress($email);
 // $tasknotice->getUserinfo($staffid,"to");
 if ($send_html) {
     $tasknotice->IsHTML("true");
     $tasknotice->AltBody = "this message uses html entities, but you prefer plain text !";
 }
 // send the email
 if (!$tasknotice->Send()) {
     echo "Message was not sent\n";
     echo "Mailer Error: " . $tasknotice->ErrorInfo . "\n\n";
 }
Example #11
0
<?php

$tmpquery = "WHERE tas.id IN({$id})";
$taskNoti = new request();
$taskNoti->openTasks($tmpquery);
$tmpquery = "WHERE pro.id = '{$project}'";
$projectNoti = new request();
$projectNoti->openProjects($tmpquery);
$tmpquery = "WHERE noti.member IN({$at})";
$listNotifications = new request();
$listNotifications->openNotifications($tmpquery);
$comptListNotifications = count($listNotifications->not_id);
if ($listNotifications->not_statustaskchange[0] == "0") {
    $mail = new notification();
    $mail->getUserinfo($idSession, "from");
    $mail->partSubject = $strings["noti_prioritytaskchange1"];
    $mail->partMessage = $strings["noti_prioritytaskchange2"];
    if ($projectNoti->pro_org_id[0] == "1") {
        $projectNoti->pro_org_name[0] = $strings["none"];
    }
    $complValue = $taskNoti->tas_completion[0] > 0 ? $taskNoti->tas_completion[0] . "0 %" : $taskNoti->tas_completion[0] . " %";
    $idStatus = $taskNoti->tas_status[0];
    $idPriority = $taskNoti->tas_priority[0];
    $body = $mail->partMessage . "\n\n" . $strings["task"] . " : " . $taskNoti->tas_name[0] . "\n" . $strings["start_date"] . " : " . $taskNoti->tas_start_date[0] . "\n" . $strings["due_date"] . " : " . $taskNoti->tas_due_date[0] . "\n" . $strings["completion"] . " : " . $complValue . "\n" . $strings["priority"] . " : {$priority[$idPriority]}\n" . $strings["status"] . " : {$status[$idStatus]}\n" . $strings["description"] . " : " . $taskNoti->tas_description[0] . "\n\n" . $strings["project"] . " : " . $projectNoti->pro_name[0] . " (" . $projectNoti->pro_id[0] . ")\n" . $strings["organization"] . " : " . $projectNoti->pro_org_name[0] . "\n\n" . $strings["noti_moreinfo"] . "\n";
    if ($taskNoti->tas_mem_organization[0] == "1") {
        $body .= "{$root}/general/login.php?url=tasks/viewtask.php%3Fid={$id}";
    } else {
        if ($taskNoti->tas_mem_organization[0] != "1" && $projectNoti->pro_published[0] == "0" && $taskNoti->tas_published[0] == "0") {
            $body .= "{$root}/general/login.php?url=projects_site/home.php%3Fproject=" . $projectNoti->pro_id[0];
        }
    }
<?php

include_once 'classes/notification.php';
if (isset($_REQUEST['user_id'])) {
    $user_id = $_REQUEST['user_id'];
    $objNotification = new notification();
    $unreadMessageCount = $objNotification->getUnreadMessageCount($user_id);
    if (isset($unreadMessageCount) && $unreadMessageCount > 0) {
        echo $unreadMessageCount;
    }
}
}
$tmpquery = "WHERE mee.id IN({$num})";
$meetingNoti = new request();
$meetingNoti->openMeetings($tmpquery);
$tmpquery = "WHERE pro.id = '{$project}'";
$projectNoti = new request();
$projectNoti->openProjects($tmpquery);
$tmpquery = "WHERE noti.member IN({$att_mem_id_list})";
$listNotifications = new request();
$listNotifications->openNotifications($tmpquery);
$comptListNotifications = count($listNotifications->not_id);
for ($i = 0; $i < $comptListNotifications; $i++) {
    if ($listNotifications->not_meetingassignment[$i] != "0") {
        continue;
    }
    $mail = new notification();
    $mail->getUserinfo($_SESSION['idSession'], "from");
    $mail->partSubject = $strings["noti_meetingassignment1"];
    $mail->partMessage = $strings["noti_meetingassignment2"];
    if ($projectNoti->pro_org_id[0] == "1") {
        $projectNoti->pro_org_name[0] = $strings["none"];
    }
    $idStatus = $meetingNoti->mee_status[0];
    $idPriority = $meetingNoti->mee_priority[0];
    $body = $mail->partMessage . "\n\n" . $strings["meeting"] . " : " . $meetingNoti->mee_name[0] . "\n" . $strings["me_agenda"] . " : " . $meetingNoti->mee_agenda[0] . "\n" . $strings["date"] . " : " . $meetingNoti->mee_date[0] . "\n" . $strings["start_time"] . " : " . $meetingNoti->mee_start_time[0] . "\n" . $strings["end_time"] . " : " . $meetingNoti->mee_end_time[0] . "\n" . $strings["me_location"] . " : " . $meetingNoti->mee_location[0] . "\n" . $strings["priority"] . " : {$priority[$idPriority]}\n" . $strings["status"] . " : {$status[$idStatus]}\n\n" . $strings["project"] . " : " . $projectNoti->pro_name[0] . " (" . $projectNoti->pro_id[0] . ")\n" . $strings["organization"] . " : " . $projectNoti->pro_org_name[0] . "\n\n" . $strings["noti_moreinfo"] . "\n";
    if ($meetingNoti->mee_mem_organization[0] == "1") {
        $body .= "{$root}/general/login.php?url=meetings/viewmeeting.php%3Fid={$num}";
    } else {
        if ($meetingNoti->mee_mem_organization[0] != "1" && $projectNoti->pro_published[0] == "0" && $meetingNoti->mee_published[0] == "0") {
            $body .= "{$root}/general/login.php?url=projects_site/home.php%3Fproject=" . $projectNoti->pro_id[0];
        }
Example #14
0
session_start();
define('DOCROOT', realpath(dirname(__FILE__)) . '/');
require DOCROOT . 'dbConn.php';
$con = new dbConn();
$password = $_POST['password'];
$email = $_SESSION['email'];
require DOCROOT . 'activationAndNotifications.php';
$stm = "select pwcr from users where email = '" . $email . "';";
$res = $con->execute($stm);
if ($res->num_rows > 0) {
    while ($row = $res->fetch_assoc()) {
        if ($row['pwcr'] == 1) {
            $stm = "update users set password = '******' where email='" . $email . "';";
            if ($con->execute($stm) === true) {
                $not = new notification();
                $body = "Password changed successfully.";
                $not->email("*****@*****.**", "Administration", "*****@*****.**", "mailstodeliver", $email, "Password Changed Successfully", $body);
                $stm = "update users set pcwr = 0 where email = '" . $email . "';";
                $con->execute($stm);
                $stm = "update users set activationCode = 0 where email = '" . $email . "';";
                $con->execute($stm);
                $_SESSION['homeMessage'] = "Password has been changed successfully.";
                echo "<meta http-equiv='refresh' content='0; url=http://32.208.103.211/chatRegistration/index.php'>";
            } else {
                $_SESSION['homeMessage'] = "Link has been expired.";
                echo "<meta http-equiv='refresh' content='0; url=http://32.208.103.211/chatRegistration/index.php'>";
            }
        }
    }
}
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      notification $value A notification object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(notification $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #16
0
function notify_admin($action, $parent, $child)
{
    $cclass = $child->get__table();
    $cname = $child->nname;
    $pclass = $parent->getClass();
    $pname = $parent->nname;
    $not = new notification(null, null, 'client-admin');
    $not->get();
    if (!array_search_bool($cclass, $not->class_list)) {
        return;
    }
    $subject = "{$cclass} {$cname} was {$action} to {$pclass} {$pname} ";
    send_mail_to_admin($subject, $subject);
}
            unset($product_row[$product_key]);
        }
    }
    $subject = "Search Ad - Search Ads products budget has ended";
    $message = "The following Search Ad products have reached balance 0 (zero)." . PHP_EOL . PHP_EOL;
    foreach ($product_row as $product_details) {
        $new_balance = $product_details['balance'] - $product_details['last_cost'];
        $new_balance = $new_balance < 0 ? 0 : number_format($new_balance, 2);
        $add_product_to_message = false;
        if ($product_details['balance'] != '') {
            try {
                $values = array('budget_credit' => $new_balance, 'last_adwords_date' => $yesterday_date);
                $db_syssql->update()->table('sYra.google_advertising_product_credit')->values($values)->where('product_data_id = :monthly_budget_product_data_id')->binds(array(':monthly_budget_product_data_id' => $product_details['monthly_budget_product_data_id']))->execute();
            } catch (DatabaseException $dbe) {
                //Show generic error for db class exceptions
                throw new Exception('An error has occurred, please try again');
            }
            if ($new_balance <= 0) {
                $add_product_to_message = true;
            }
        }
        if ($add_product_to_message) {
            $message .= "Product ID: {$product_details['product_data_id']}" . PHP_EOL . "Member ID: {$product_details['member_id']}" . PHP_EOL . "Client ID: {$product_details['client_id']}" . PHP_EOL . PHP_EOL;
            $send_email = true;
        }
    }
    if ($send_email) {
        notification::send($to, FROM_EMAIL, FROM_EMAIL_NAME, $subject, $message);
    }
}
cron_commit($execution_id);
Example #18
0
//Generated by Cobalt, a rapid application development framework. http://cobalt.jvroig.com
//Cobalt developed by JV Roig (jvroig@jvroig.com)
//****************************************************************************************
require 'path.php';
init_cobalt('View notification');
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_submit']);
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_notification.php");
    }
    if ($_POST['btn_submit']) {
        log_action('Pressed submit button');
        require 'subclasses/notification.php';
        $dbh_notification = new notification();
        if ($message == "") {
            log_action('Exported table data to CSV');
            $timestamp = date('Y-m-d');
            $token = generate_token(0, 'fs');
            $csv_name = $token . $_SESSION['user'] . '_notification_' . $timestamp . '.csv';
            $filename = TMP_DIRECTORY . '/' . $csv_name;
            $csv_contents = $dbh_notification->export_to_csv();
            $csv_file = fopen($filename, "wb");
            fwrite($csv_file, $csv_contents);
            fclose($csv_file);
            chmod($filename, 0755);
            $csv_name = urlencode($csv_name);
            $message = 'CSV file successfully generated: <a href="/' . BASE_DIRECTORY . '/download_generic.php?filename=' . $csv_name . '">Download the CSV file.</a>';
            $message_type = 'system';
        }
 private static function getIndicator()
 {
     if (!self::$indicator) {
         self::$indicator = new myFileIndicator("gogonotifications");
     }
     return self::$indicator;
 }
 /**
  * Save the locked state for a post
  * 
  * @return result array.
  */
 public function save_posts_locked_from_submit()
 {
     global $DB;
     // Ensure that post exists and get the right courseid.
     $postid = required_param('postid', PARAM_INT);
     if (!($post = $DB->get_record('format_socialwall_posts', array('id' => $postid)))) {
         print_error('invalidpostid', 'format_socialwall');
     }
     // ... check capability.
     $coursecontext = \context_course::instance($post->courseid);
     if (!has_capability('format/socialwall:lockcomment', $coursecontext)) {
         print_error('missingcaplockcomment', 'format_socialwall');
     }
     $locked = optional_param('locked', '0', PARAM_INT);
     if ($post->locked != $locked) {
         $post->locked = $locked;
         $post->timemodified = time();
         $DB->update_record('format_socialwall_posts', $post);
         // We use a instant enqueueing, if needed you might use events here.
         notification::enqueue_post_locked($post);
     }
     return array('error' => '0', 'message' => 'postsaved', 'postid' => $post->id, 'locked' => "{$post->locked}");
 }
 $tmpquery = "WHERE mem.login = '******'";
 $userDetail = new request();
 $userDetail->openMembers($tmpquery);
 $comptUserDetail = count($userDetail->mem_id);
 // test if user exists
 if ($comptUserDetail == "0") {
     $error = $strings["no_login"];
 } else {
     if ($userDetail->mem_email_work[0] != "") {
         // test if email of user exists
         password_generator();
         $pw = get_password($pass_g);
         $tmpquery = 'UPDATE ' . $tableCollab['members'] . " SET password='******' WHERE login = '******'";
         connectSql($tmpquery);
         $body = $strings['user_name'] . ' : ' . $userDetail->mem_login[0] . "\n\n" . $strings['password'] . " : {$pass_g}";
         $mail = new notification();
         $mail->getUserinfo('1', 'from');
         $subject = 'NetOffice ' . $strings['password'];
         $mail->Subject = $subject;
         $mail->Priority = '1';
         $mail->Body = $body;
         $mail->AddAddress($userDetail->mem_email_work[0], $userDetail->mem_name[0]);
         $mail->Send();
         $mail->ClearAddresses();
         // redirect to login page with message
         header('Location: ../general/login.php?msg=emailpwd');
         exit;
     } else {
         $error = $strings['no_email'];
     }
 }
Example #22
0
 /**
  * Function to handle class not completed events.
  *
  * @param   student  $student  The class enrolment / student object who is "not completed"
  * @uses    $CFG
  * @uses    $DB
  * @return  boolean            TRUE is successful, otherwise FALSE
  */
 public static function class_notcompleted_handler($student)
 {
     global $CFG, $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_classnotcompleted_user;
     $sendtorole = elis::$config->local_elisprogram->notify_classnotcompleted_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_classnotcompleted_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     if (!empty($student->moodlecourseid)) {
         if (!($context = context_course::instance($student->moodlecourseid))) {
             if (in_cron()) {
                 mtrace(get_string('invalidcontext'));
             } else {
                 debugging(get_string('invalidcontext'));
             }
             return true;
         }
     } else {
         $context = context_system::instance();
     }
     $message = new notification();
     /// Set up the text of the message
     $text = empty(elis::$config->local_elisprogram->notify_classnotcompleted_message) ? get_string('notifyclassnotcompletedmessagedef', self::LANG_FILE) : elis::$config->local_elisprogram->notify_classnotcompleted_message;
     $search = array('%%userenrolname%%', '%%classname%%', '%%coursename%%');
     $user = new user($student->userid);
     if (!$user) {
         if (in_cron()) {
             mtrace(get_string('nouser', 'local_elisprogram'));
         } else {
             debugging(get_string('nouser', 'local_elisprogram'));
         }
         return true;
     }
     $user->load();
     // Get course info
     $pmcourse = $DB->get_record(course::TABLE, array('id' => $student->courseid));
     $pmclass = $DB->get_record(pmclass::TABLE, array('id' => $student->classid));
     $replace = array($user->moodle_fullname(), $pmclass->idnumber, $pmcourse->name);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'class_notcompleted';
     $eventlog->instance = $student->classid;
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_classnotcomplete capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_classnotcomplete')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_classnotcomplete')) {
             $users = $users + $supervisors;
         }
     }
     // Send notifications to any users who need to receive them.
     foreach ($users as $touser) {
         $message->send_notification($text, $touser, $user, $eventlog);
     }
     return true;
 }
 /** save a new comment from submit
  * 
  * @global record $USER
  * @global object $DB
  * @return array, result array.
  */
 public function save_likes_from_submit()
 {
     global $USER, $DB;
     if (empty($this->course->enablelikes)) {
         print_error('likesaredisabled', 'format_socialwall');
     }
     // Ensure that post exists and get the right courseid.
     $postid = required_param('postid', PARAM_INT);
     if (!($post = $DB->get_record('format_socialwall_posts', array('id' => $postid)))) {
         print_error('invalidpostid', 'format_socialwall');
     }
     $userlike = optional_param('userlike', '0', PARAM_INT);
     // ... check capability.
     $coursecontext = \context_course::instance($post->courseid);
     if (!has_capability('format/socialwall:like', $coursecontext)) {
         print_error('missingcaplikepost', 'format_socialwall');
     }
     $refresh = false;
     if (empty($userlike)) {
         if ($like = $DB->get_records('format_socialwall_likes', array('postid' => $postid, 'fromuserid' => $USER->id))) {
             $DB->delete_records_select('format_socialwall_likes', 'fromuserid = ? AND postid = ?', array($USER->id, $postid));
             $refresh = true;
             // We use a instant enqueueing, if needed you might use events here.
             notification::enqueue_like_deleted($post);
         }
     } else {
         if (!($like = $DB->get_records('format_socialwall_likes', array('postid' => $postid, 'fromuserid' => $USER->id)))) {
             $newlike = new \stdClass();
             $newlike->courseid = $this->course->id;
             $newlike->postid = $postid;
             $newlike->fromuserid = $USER->id;
             $newlike->timecreated = time();
             $DB->insert_record('format_socialwall_likes', $newlike);
             $refresh = true;
             notification::enqueue_like_created($post);
         }
     }
     $result = array('error' => '0', 'message' => 'likesaved', 'postid' => $postid, 'userlike' => $userlike, 'countcomments' => $post->countcomments, 'countlikes' => $post->countlikes);
     if ($refresh) {
         $posts = posts::instance($this->course->id);
         $result['countlikes'] = $posts->refresh_likes_count($postid);
     }
     return $result;
 }
Example #24
0
 /**
  * Function to handle curriculum not completed events.
  *
  */
 public static function curriculum_notcompleted_handler($curstudent)
 {
     global $CFG, $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_curriculumnotcompleted_user;
     $sendtorole = elis::$config->local_elisprogram->notify_curriculumnotcompleted_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_curriculumnotcompleted_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     $context = context_system::instance();
     // Send notifications
     $message = new notification();
     /// Set up the text of the message
     $text = empty(elis::$config->local_elisprogram->notify_curriculumnotcompleted_message) ? get_string('notifycurriculumnotcompletedmessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_curriculumnotcompleted_message;
     $user = new user($curstudent->userid);
     if (!$user) {
         return true;
     }
     $user->load();
     // Get course info
     $program = $DB->get_record(curriculum::TABLE, array('id' => $curstudent->curriculumid));
     $search = array('%%userenrolname%%', '%%programname%%');
     $replace = array($user->moodle_fullname(), $program->name);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'curriculum_notcompleted';
     $eventlog->instance = $curstudent->id;
     /// Store the assignment id.
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_curriculumnotcomplete capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_programnotcomplete')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_programnotcomplete')) {
             $users = $users + $supervisors;
         }
     }
     foreach ($users as $u) {
         $message->send_notification($text, $u, $user, $eventlog);
     }
     return true;
 }
 function replace_admin_actions()
 {
     global $config, $lang;
     require_once $config['basepath'] . '/include/login.inc.php';
     $login = new login();
     $login_status = $login->loginCheck('Agent');
     if ($login_status !== true) {
         // Run theese commands even if not logged in.
         $data = '';
         switch ($_GET['action']) {
             case 'send_forgot':
                 require_once $config['basepath'] . '/include/login.inc.php';
                 $data = login::forgot_password();
                 break;
             case 'forgot':
                 require_once $config['basepath'] . '/include/login.inc.php';
                 $data = login::forgot_password_reset();
                 break;
             default:
                 $data .= $login_status;
                 break;
         }
     } else {
         switch ($_GET['action']) {
             case 'index':
                 require_once $config['basepath'] . '/include/admin.inc.php';
                 $admin = new general_admin();
                 $data = $admin->index_page();
                 break;
             case 'edit_page':
                 require_once $config['basepath'] . '/include/editor.inc.php';
                 $listing = new editor();
                 $data = $listing->page_edit();
                 break;
             case 'edit_user_images':
                 require_once $config['basepath'] . '/include/images.inc.php';
                 $images = new image_handler();
                 $data = $images->edit_user_images();
                 break;
             case 'edit_listing_images':
                 require_once $config['basepath'] . '/include/images.inc.php';
                 $images = new image_handler();
                 $data = $images->edit_listing_images();
                 break;
             case 'edit_vtour_images':
                 require_once $config['basepath'] . '/include/images.inc.php';
                 $images = new image_handler();
                 $data = $images->edit_vtour_images();
                 break;
             case 'edit_listing_files':
                 require_once $config['basepath'] . '/include/files.inc.php';
                 $files = new file_handler();
                 $data = $files->edit_listing_files();
                 break;
             case 'edit_user_files':
                 require_once $config['basepath'] . '/include/files.inc.php';
                 $files = new file_handler();
                 $data = $files->edit_user_files();
                 break;
             case 'add_listing':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->add_listing();
                 break;
             case 'edit_my_listings':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->edit_listings();
                 break;
             case 'edit_listings':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->edit_listings(false);
                 break;
             case 'configure':
                 require_once $config['basepath'] . '/include/controlpanel.inc.php';
                 $listing_editor = new configurator();
                 $data = $listing_editor->show_configurator();
                 break;
             case 'edit_listing_template':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listing_template();
                 break;
             case 'edit_listings_template_field_order':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listings_template_field_order();
                 break;
             case 'edit_agent_template_field_order':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_template_field_order($type = 'agent');
                 break;
             case 'edit_member_template_field_order':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_template_field_order($type = 'member');
                 break;
             case 'edit_agent_template_add_field':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->add_user_template_field($type = 'agent');
                 break;
             case 'edit_member_template_add_field':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $type = 'member';
                 $data = $listing->add_user_template_field($type);
                 break;
             case 'edit_listing_template_search':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listing_template_search();
                 break;
             case 'edit_listing_template_search_results':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_listing_template_search_results();
                 break;
             case 'user_manager':
                 require_once $config['basepath'] . '/include/user_manager.inc.php';
                 $user_managment = new user_managment();
                 $data = $user_managment->show_user_manager();
                 break;
             case 'edit_user_template':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->edit_user_template();
                 break;
             case 'edit_listing_template_add_field':
                 require_once $config['basepath'] . '/include/template_editor.inc.php';
                 $listing = new template_editor();
                 $data = $listing->add_listing_template_field();
                 break;
             case 'add_page':
                 require_once $config['basepath'] . '/include/editor.inc.php';
                 $listing = new editor();
                 $data = $listing->add_page();
                 break;
             case 'view_log':
                 require_once $config['basepath'] . '/include/log.inc.php';
                 $data = log::view();
                 break;
             case 'clear_log':
                 require_once $config['basepath'] . '/include/log.inc.php';
                 $data = log::clear_log();
                 break;
             case 'show_property_classes':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::show_classes();
                 break;
             case 'modify_property_class':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::modify_property_class();
                 break;
             case 'delete_property_class':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::delete_property_class();
                 break;
             case 'insert_property_class':
                 require_once $config['basepath'] . '/include/propertyclass.inc.php';
                 $data = propertyclass::insert_property_class();
                 break;
             case 'add_listing_property_class':
                 require_once $config['basepath'] . '/include/listing_editor.inc.php';
                 $listing_editor = new listing_editor();
                 $data = $listing_editor->add_listing_logic();
                 break;
                 //Todo Finish Adding Blog Items
             //Todo Finish Adding Blog Items
             case 'edit_blog':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->blog_edit_index();
                 break;
             case 'edit_blog_post':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->blog_edit();
                 break;
             case 'add_blog':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->add_post();
                 break;
             case 'edit_blog_post_comments':
                 require_once $config['basepath'] . '/include/blog_editor.inc.php';
                 $listing = new blog_editor();
                 $data = $listing->edit_post_comments();
                 break;
             case 'addon_manager':
                 require_once $config['basepath'] . '/include/addon_manager.inc.php';
                 $am = new addon_manager();
                 $data = $am->display_addon_manager();
                 break;
             case 'send_notifications':
                 require_once $config['basepath'] . '/include/notification.inc.php';
                 $notify = new notification();
                 $data = $notify->NotifyUsersOfAllNewListings();
                 break;
             default:
                 // Handle Addons
                 $addon_name = array();
                 if (preg_match("/^addon_(.\\S*?)_.*/", $_GET['action'], $addon_name)) {
                     include_once $config['basepath'] . '/addons/' . $addon_name[1] . '/addon.inc.php';
                     $function_name = $addon_name[1] . '_run_action_admin_template';
                     $data = $function_name();
                 }
         }
     }
     return $data;
 }
<?php

require 'components/get_listview_referrer.php';
require 'subclasses/notification.php';
$dbh_notification = new notification();
$dbh_notification->set_where("notification_id='" . quote_smart($notification_id) . "'");
if ($result = $dbh_notification->make_query()->result) {
    $data = $result->fetch_assoc();
    extract($data);
}
Example #27
0
/**
 * Notifies that students have not passed their classes via the notifications where applicable,
 * setting enrolment status to failed where applicable
 *
 * @param int $pmuserid  optional userid to update, default(0) updates all users
 */
function pm_update_student_enrolment($pmuserid = 0)
{
    global $DB;
    require_once elispm::lib('data/student.class.php');
    require_once elispm::lib('notifications.php');
    //look for all enrolments where status is incomplete / in progress and end time has passed
    $select = 'completestatusid = :status AND endtime > 0 AND endtime < :time';
    $params = array('status' => STUSTATUS_NOTCOMPLETE, 'time' => time());
    if ($pmuserid) {
        $select .= ' AND userid = :userid';
        $params['userid'] = $pmuserid;
    }
    $students = $DB->get_recordset_select(student::TABLE, $select, $params);
    if (!empty($students)) {
        foreach ($students as $s) {
            // Send notification, if enabled.
            $sendnotification = !empty(elis::$config->local_elisprogram->notify_incompletecourse_user) ? true : false;
            if ($sendnotification === true) {
                $a = $DB->get_field(pmclass::TABLE, 'idnumber', array('id' => $s->classid));
                $message = get_string('incomplete_course_message', 'local_elisprogram', $a);
                $cuser = new user($s->userid);
                $from = get_admin();
                notification::notify($message, $cuser, $from);
            }
            //set status to failed
            $s->completetime = time();
            $s->completestatusid = STUSTATUS_FAILED;
            $stu = new student($s->id);
            $stu->set_from_data($s);
            $stu->update();
        }
    }
    return true;
}
Example #28
0
 /**
  * @param string $query
  * @return object of mysqli query pointer
  * @throws Exception
  */
 public function sendReport($exc)
 {
     $msg = "<div style='direction:ltr;'>Error No: " . $exc->getCode() . " - " . $exc->getMessage() . "<br >" . nl2br($exc->getTraceAsString()) . '</div>';
     exit('<!-- ' . $msg . ' -->');
     if (!class_exists('notification')) {
         $notfile = dirname(__FILE__) . '/notification.php';
         if (file_exists($notfile)) {
             include $notfile;
         } else {
             exit('<!-- ' . $msg . ' -->');
         }
     }
     $subject = "database error #" . $exc->getCode();
     $userinfo = array('email' => "*****@*****.**", 'nickname' => "system tech team");
     notification::getNotifications()->sendMail($subject, $userinfo, 'blank', $msg);
 }
<?php

// $Revision: 1.2 $
/* vim: set expandtab ts=4 sw=4 sts=4: */
/**
 * $Id: noti_newrequest.php,v 1.2 2004/12/13 00:18:26 madbear Exp $
 * 
 * Copyright (c) 2003 by the NetOffice developers
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */
$mail = new notification();
$mail->getUserinfo($_SESSION['idSession'], "from");
$tmpquery = "WHERE sr.id = '{$num}'";
$requestDetail = new request();
$requestDetail->openSupportRequests($tmpquery);
if ($supportType == "team") {
    $tmpquery = "WHERE tea.project = '" . $requestDetail->sr_project[0] . "'";
    $listTeam = new request();
    $listTeam->openTeams($tmpquery);
    $comptListTeam = count($listTeam->tea_id);
    for ($i = 0; $i < $comptListTeam; $i++) {
        if ($_SESSION['idSession'] == $listTeam->tea_mem_id[$i]) {
            $mail->partSubject = $strings["support"] . " " . $strings["support_id"];
            $mail->partMessage = $strings["noti_support_request_new2"];
            $subject = $mail->partSubject . ": " . $requestDetail->sr_id[0];
            $body = $mail->partMessage . "";
            $body .= "" . $requestDetail->sr_subject[0] . "";
$_SESSION['db_password'] = "******";
$_SESSION['db_database'] = "oraparacollect";
#$db = mysqli_connect($_SESSION['db_host'], $_SESSION['db_user'], $_SESSION['db_password'], $_SESSION['db_database']); test commnect
include_once "../classes/class_server.php";
include_once "../classes/class_server_actions.php";
include_once "../classes/class_instance.php";
include_once "../classes/class_instance_actions.php";
include_once "../classes/class_parameter.php";
include_once "../classes/class_parameter_actions.php";
include_once "../classes/class_notification.php";
# Generating instance objects
$arr_server_objs = server_actions::get_all_server();
# FRA Monitor Notification
foreach ($arr_server_objs as $server) {
    if ($server->get_fra_assigned_percentage() >= 100) {
        if (notification::check_fra_notification_flag($server->server_id) == false) {
            notification::send_fra_notification($server, $GLOBALS['config']['fra_notification_mail']);
            notification::add_fra_notification_flag($server->server_id);
        }
    } else {
        notification::drop_fra_notification_flag($server->server_id);
    }
}
# Switchover Notificaiton
$so_data_arr = parameter_actions::get_all_switchover_as_array();
foreach ($so_data_arr as $time => $switchover) {
    if (notification::check_switchover_flag($time, $switchover['rz1_db_id'], $switchover['rz2_db_id']) == false) {
        notification::send_switchover_notification($switchover, $GLOBALS['config']['switchover_notification_mail']);
        notification::add_switchover_flag($time, $switchover['rz1_db_id'], $switchover['rz2_db_id']);
    }
}