コード例 #1
0
        $res = db_query($sql);
        while ($row = db_fetch_object($res)) {
            $user_info = user_load($row->uid);
            if ($user_info->roles[3] == 'Sales Rep') {
                $user_email[] = $row->name . "//" . $row->mail . "//" . $key1;
            }
        }
    }
}
$user_email1 = array_unique($user_email);
foreach ($user_email1 as $key => $val) {
    $arr_res = explode("//", $val);
    $node_info = node_load($arr_res[2]);
    $user_info = user_load($node_info->uid);
    $company_name = '';
    foreach ($node_info->field_company as $com_key => $com_val) {
        $company_name .= rtrim(implode(", ", $com_val), ", ") . ", ";
    }
    $company_name = rtrim($company_name, ", ");
    //echo "<pre>";print_r($node_info->field_company);echo "</pre>";
    $subject = "M2M Search REMINDER: New Module Awaiting Approval";
    global $base_url;
    $login_url = $base_url . "/user/login";
    // $node_url="http://".$_SERVER['HTTP_HOST']."/node/".$node_info->nid."/publish?destination=manage/owndevice";
    $node_url = $base_url . "/manage/owndevice";
    $message = "Dear {$arr_res['0']},<br><bR>\r\n\r\nThis is your final reminder notifying you that <b>{$company_name}</b> has uploaded a new module, <b>{$node_info->title}</b>, to the online M2M module database. It requires your verification and approval for it to post publically; to review the module, Please <a href='" . $login_url . "'> Login </a> into the site to approve the devices waiting your approval. <br><br><br>\r\n\r\nThank you,<br>\r\nM2M Search Admin";
    //mail($row->mail, $subject, $message) or die("error in mail function");
    drupal_mail_send(array('to' => $arr_res[1], 'body' => $message, 'subject' => $subject, 'headers' => $headers));
    //echo "UPDATE {node} SET mailstatus =1 WHERE nid=$node_info->nid";
    db_query("UPDATE {node} SET mailstatus =1 WHERE nid={$node_info->nid}");
}
コード例 #2
0
ファイル: functions.php プロジェクト: rahool/maplocator
function notify_admin_of_layer_updation($layer_name , $operation , $city )
{
  global $user;
  $username = $user->name . "(" . $user->mail . ")";

  $body = "";
  switch($operation ) {
    case 'insert':
      $subject = "Layer added";
      $body = "Layer is added in the {$city}";
      break;
    case 'delete':
      $subject = "{$layer_name} deleted";
      $body = "Layer named '{$layer_name}' from {$city} is deleted";
      break;
  }

  // Get the layer admins email IDs.
  $query = "select mail from users where uid in (select uid from users_roles where rid in (select rid from role where name = '%s admin' OR name = '%s validator' OR name = '".SITE_ADMIN_ROLE."'));";
  $result = db_query($query, $layer_tablename);
  if(!$result) {
    return FALSE;
  } else {
    $admin_ids = array();
    while($obj = db_fetch_object($result)) {
      $admin_ids[] = $obj->mail;
    }

    if(sizeof($admin_ids) == 0) {
      return FALSE;
    } else {
      $to = implode(",", $admin_ids);
      if(!in_array($user->mail,$admin_ids)){
         //user mail id not present in the list already
         $to.= ",".$user->mail;
      }
    }
  }

  $default_from = variable_get('site_mail', ini_get('sendmail_from'));

  // Additional headers
  $headers['To'] = $to;

  // Bundle up the variables into a structured array for altering.
  $message = array(
    'to'       => $to,
    'from'     => isset($from) ? $from : $default_from,
    'subject'  => $subject,
    'body'     => $body,
    'headers'  => $headers
  );
  drupal_mail_send($message);
}
コード例 #3
0
/**
 * submit hook for {@link approve_grades_hod_form()}
 *
 * <p>Relevant CA & Exam locked fields become 2.</p>
 * <p>If this is a CA approval, set the student visible CA scores to the values set by the lecturer.</p>
 * <p>Create an Approval Record.</p>
 * <p>Send e-mails to those that need to be notified.</p>
 * <p>Send e-mails to Students for CA only.</p>
 * @uses findcourseparameters()
 */
function approve_grades_hod_form_submit($form, &$form_state)
{
    global $user;
    global $base_url;
    $fieldtoapprovehoda = $form_state['values']['fieldtoapprovehoda'];
    $comment = $form_state['values']['comment'];
    $course_url = $form_state['values']['course_url'];
    $hod_uid = $form_state['values']['hod_uid'];
    $dean_uid = $form_state['values']['dean_uid'];
    $coursecode = $form_state['values']['coursecode'];
    $session = $form_state['values']['session'];
    $semester = $form_state['values']['semester'];
    $location = $form_state['values']['location'];
    $number_of_ca = $form_state['values']['number_of_ca'];
    $ca_approved_onebyone = $form_state['values']['ca_approved_onebyone'];
    $gradestexthoda = $form_state['values']['gradestexthoda'];
    $srcfield = $form_state['values']['srcfield'];
    $destfield = $form_state['values']['destfield'];
    if ($semester === 'All') {
        $semesterwhere = '';
    } else {
        $semesterwhere = 'AND ci.field_semester_name_value=' . (int) $semester;
    }
    if ($location === 'All') {
        $locationwhere = '';
    } else {
        $locationwhere = 'AND ci.field_location_value=' . (int) $location;
    }
    // Don't allow an exam score approved by the VC to be changed
    if ($fieldtoapprovehoda === 'field_examscorelocked_value') {
        $protectVC = 'AND sg.field_examscorelocked_value < 5';
    } else {
        $protectVC = '';
    }
    if ($ca_approved_onebyone) {
        $setstatement = "SET sg.`{$fieldtoapprovehoda}`='2'";
    } else {
        // Approve CAs along with exam
        $setstatement = "SET\n      sg.`field_ca1locked_value`='2',\n      sg.`field_ca2locked_value`='2',\n      sg.`field_ca3locked_value`='2',\n      sg.`field_ca4locked_value`='2',\n      sg.`field_examscorelocked_value`='2'";
    }
    $sql = "UPDATE {content_type_student_grades} sg, {content_type_course_instance} ci, {content_type_course} c\n    {$setstatement}\n    WHERE\n      sg.field_course_instance_nid=ci.nid AND\n      sg.field_dropped_value=0 AND\n      ci.field_course_id_nid=c.nid AND\n      ci.field_sess_name_value='%s' {$semesterwhere} {$locationwhere} AND\n      c.field_code_value='%s'\n      {$protectVC}";
    db_query($sql, $session, $coursecode);
    cache_clear_all('content:', content_cache_tablename(), TRUE);
    if ($srcfield != 'NONE') {
        // Make the CAs visible to students
        $setstatement = "SET sg.`{$destfield}`=sg.`{$srcfield}`";
        $sql = "UPDATE {content_type_student_grades} sg, {content_type_course_instance} ci, {content_type_course} c\n      {$setstatement}\n      WHERE\n        sg.field_course_instance_nid=ci.nid AND\n        sg.field_dropped_value=0 AND\n        ci.field_course_id_nid=c.nid AND\n        ci.field_sess_name_value='%s' {$semesterwhere} {$locationwhere} AND\n        c.field_code_value='%s'";
        db_query($sql, $session, $coursecode);
        cache_clear_all('content:', content_cache_tablename(), TRUE);
    }
    list($level, $sem, $loc, $department, $college) = findcourseparameters($coursecode, $session, $semesterwhere, $locationwhere);
    $user_profile = new UserProfile($user->uid);
    $name = '';
    if (!empty($user_profile->profile_first_name) && !empty($user_profile->profile_last_name)) {
        $middle = '';
        if (!empty($user_profile->profile_middle_name)) {
            $middle = $user_profile->profile_middle_name . ' ';
        }
        $name = "{$user_profile->profile_first_name} {$middle}{$user_profile->profile_last_name}";
    }
    $firsttime = TRUE;
    // Determine who gets notified when HOD (or equiv) submits Grade approval form
    $inroles = "'Dean of Faculty', 'Faculty Grade Editor', 'Faculty Examination Officer', 'University Grade Editor'";
    $sql = "SELECT\n      d.field_college_id_nid AS college_id,\n      c.field_department_nid_nid AS department_id\n    FROM {content_type_department} d, {content_type_course} c\n    WHERE\n      d.nid=c.field_department_nid_nid AND\n      c.field_code_value='%s'";
    $staffresult = db_query($sql, $coursecode);
    $staff = db_fetch_object($staffresult);
    $sql = "SELECT DISTINCT uid AS dean_uid\n    FROM {eduerp_roles}\n    WHERE (department_id=%d OR college_id=%d OR (department_id=0 AND college_id=0)) AND role IN ({$inroles})";
    $hodresult = db_query($sql, $staff->department_id, $staff->college_id);
    while ($hod = db_fetch_object($hodresult)) {
        if (!empty($hod->dean_uid)) {
            $destination_user = user_load($hod->dean_uid);
            $user_profile = new UserProfile($hod->dean_uid);
        } else {
            $destination_user = NULL;
            $user_profile = NULL;
        }
        $subject = "{$gradestexthoda} for {$coursecode} Approved by {$name}";
        $body = '';
        if (!empty($user_profile->profile_first_name) && !empty($user_profile->profile_last_name)) {
            $middle = '';
            if (!empty($user_profile->profile_middle_name)) {
                $middle = $user_profile->profile_middle_name . ' ';
            }
            $body .= "Dear {$user_profile->profile_first_name} {$middle}{$user_profile->profile_last_name},\n\n";
        }
        $body .= "I have approved {$gradestexthoda} for {$coursecode}\n\n";
        $body .= "URL: {$course_url}\n";
        $body .= "Department: {$department}\n";
        $body .= "Faculty: {$college}\n";
        $body .= "Level: {$level}\n";
        $body .= "Session: {$session}\n";
        $body .= "Semester: {$sem}\n";
        $body .= "Location: {$loc}\n\n";
        $body .= "HOD's comment...\n";
        $body .= str_replace('<br />', "\n", $comment);
        $body .= "\n\n{$name}\n\n";
        if ($firsttime) {
            $node = new stdClass();
            $node->type = 'approval';
            $node->uid = 1;
            $node->status = 0;
            $node->promote = 0;
            $node->sticky = 0;
            $node->comment = 0;
            $node->title = $subject;
            $node->body = $comment;
            $node->field_url[0]['value'] = $course_url;
            $node->field_approver[0]['uid'] = $user->uid;
            $node->field_destination[0]['value'] = $dean_uid;
            $node->field_coursecode[0]['value'] = $coursecode;
            $node->field_programme[0]['value'] = '';
            $node->field_department1[0]['value'] = $department;
            $node->field_college1[0]['value'] = $college;
            $node->field_level1[0]['value'] = $level;
            $node->field_session1[0]['value'] = $session;
            $node->field_semester1[0]['value'] = $sem;
            $node->field_location1[0]['value'] = $loc;
            $node->field_what_approved[0]['value'] = $gradestexthoda;
            $node->field_action[0]['value'] = 'Approved by HOD';
            node_save($node);
            $firsttime = FALSE;
        }
        if (!empty($destination_user)) {
            $message = drupal_mail('grading', 'approval', $destination_user->mail, language_default(), array(), $user->mail, FALSE);
            $message['subject'] = $subject;
            $message['body'] = $body;
            drupal_mail_send($message);
        }
    }
    // Send e-mails to Students for CA only
    if ($srcfield != 'NONE') {
        $sql = "SELECT sg.field_mat_no_uid FROM {content_type_student_grades} sg, {content_type_course_instance} ci, {content_type_course} c\n      WHERE\n        sg.field_course_instance_nid=ci.nid AND\n        sg.field_dropped_value=0 AND\n        ci.field_course_id_nid=c.nid AND\n        ci.field_sess_name_value='%s' {$semesterwhere} {$locationwhere} AND\n        c.field_code_value='%s'";
        $studentresult = db_query($sql, $session, $coursecode);
        while ($student = db_fetch_object($studentresult)) {
            $student_uid = $student->field_mat_no_uid;
            $destination_user = user_load($student_uid);
            $user_profile = new UserProfile($student_uid);
            $subject = "{$gradestexthoda} for {$coursecode} Approved by {$name}";
            $body = '';
            if (!empty($user_profile->profile_first_name) && !empty($user_profile->profile_last_name)) {
                $middle = '';
                if (!empty($user_profile->profile_middle_name)) {
                    $middle = $user_profile->profile_middle_name . ' ';
                }
                $body .= "Dear {$user_profile->profile_first_name} {$middle}{$user_profile->profile_last_name},\n\n";
            }
            $body .= "I have approved {$gradestexthoda} for {$coursecode}\n\n";
            $body .= "To view your grades go to {$base_url}/student\n";
            $body .= "You will have to login first.\n\n";
            $body .= "{$name}\n";
            $message = drupal_mail('grading', 'notifystudent', $destination_user->mail, language_default(), array(), $user->mail, FALSE);
            $message['subject'] = $subject;
            $message['body'] = $body;
            drupal_mail_send($message);
            db_query("INSERT INTO cron_notification (approver_uid, student_uid, gradestext, programme, instruction) VALUES (%d, %d, '%s', '%s', %d)", $user->uid, $student_uid, $gradestexthoda, $coursecode, 1);
        }
    }
    drupal_set_message('Approval successfull');
}
コード例 #4
0
function _connect_send_email(&$message, $send_html = FALSE, $send_mail = FALSE)
{
    // sanity checks
    $send_html = $send_html && module_exists('mimemail');
    if (!isset($message->headers)) {
        $message->headers = NULL;
    }
    // filter content
    if ($send_html) {
        $message->body = filter_xss($message->body);
    } else {
        $message->body = strip_tags($message->body);
    }
    // are we just testing?
    if (!$send_mail) {
        watchdog('connect_send_email', '<pre>' . print_r($message, TRUE) . '</pre>');
        return TRUE;
    }
    // send it
    if ($message->subject && $message->body && $message->to && $message->from) {
        if ($send_html) {
            return mimemail($message->from, $message->to, $message->subject, $message->body, FALSE, $message->headers);
        } else {
            // turn the message object into param for drupal_mail_send
            $message_array = (array) $message;
            $message_array['id'] = 'connect_send_email';
            return drupal_mail_send($message_array);
        }
    } else {
        return FALSE;
    }
}
コード例 #5
0
ファイル: save_info.php プロジェクト: rahool/maplocator
function notify_layer_admin($tablename, $table_type, $fields) {
  // If the table type is neither LAYER nor LINK, we do not support it. So return.
  if($table_type != TABLE_TYPE_LAYER && $table_type != TABLE_TYPE_LINK) {
    return FALSE;
  }
  global $user;
  $to = "";

  $op = "Add";
  if(isset($fields[AUTO_DBCOL_PREFIX.'id']) && $fields[AUTO_DBCOL_PREFIX.'id'] != "''") {
    $op = "Update";
  }

  $name = "";
  // If the table type is link, the layer tablename set above will be updated to the correct one.
  if($table_type == TABLE_TYPE_LINK) {
    $query = "select link_name from \"Meta_LinkTable\" where link_tablename = '%s'";
    $result = db_query($query, $tablename);
    if(!$result) {
      return FALSE;
    } else {
      $obj = db_fetch_object($result);
      $name = '"' . $obj->link_name . '" of ';
    }

    $query = "select layer_name, layer_tablename from \"Meta_Layer\" where layer_id = (select layer_id from \"Meta_LinkTable\" where link_tablename = '%s')";
  } else {
    $query = "select layer_name, layer_tablename from \"Meta_Layer\" where layer_tablename = '%s'";
  }

  $result = db_query($query, $tablename);
  if(!$result) {
    return FALSE;
  } else {
    $obj = db_fetch_object($result);
    if($obj->layer_tablename == "") {
      return FALSE;
    }

    $layer_tablename = $obj->layer_tablename;
    $layer_name = $obj->layer_name;
  }

  $name .= '"' . $layer_name . '"';
  $subject = "{$table_type} {$op}: {$name}";

  // Get the layer admins email IDs.
  $query = "select mail from users where uid in (select uid from users_roles where rid in (select rid from role where name = '%s admin' OR name = '%s validator' OR name = '".SITE_ADMIN_ROLE."'));";
  $result = db_query($query, $layer_tablename);
  if(!$result) {
    return FALSE;
  } else {
    $admin_ids = array();
    while($obj = db_fetch_object($result)) {
      $admin_ids[] = $obj->mail;
    }

    if(sizeof($admin_ids) == 0) {
      return FALSE;
    } else {
      $to = implode(",", $admin_ids);
      if(!in_array($user->mail,$admin_ids)){
         //user mail id not present in the list already
         $to.= ",".$user->mail;
      }
    }
  }

  if($to == "") {
    return FALSE;
  } else {

    $body = $user->name . "(" . $user->mail . ") has added following details: \r\n\r\n";

    foreach($fields as $key => $value) {
      $body .= '"' . $key . '": ' . $value . "\r\n";
    }

    $default_from = variable_get('site_mail', ini_get('sendmail_from'));

    // Additional headers
    $headers['To'] = $to;
    $headers['From'] = '*****@*****.**';

    // Bundle up the variables into a structured array for altering.
    $message = array(
      'to'       => $to,
      'from'     => isset($from) ? $from : $default_from,
      'subject'  => $subject,
      'body'     => $body,
      'headers'  => $headers
    );

    return drupal_mail_send($message);
  }
}