当前位置: 首页>>代码示例>>PHP>>正文


PHP DB_Helper::get_last_insert_id方法代码示例

本文整理汇总了PHP中DB_Helper::get_last_insert_id方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_Helper::get_last_insert_id方法的具体用法?PHP DB_Helper::get_last_insert_id怎么用?PHP DB_Helper::get_last_insert_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB_Helper的用法示例。


在下文中一共展示了DB_Helper::get_last_insert_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

 /**
  * Method used to add a new canned email response to the system.
  *
  * @return  integer 1 if the insert worked, -1 otherwise
  */
 public static function insert()
 {
     if (Validation::isWhitespace($_POST['title'])) {
         return -2;
     }
     $stmt = 'INSERT INTO
                 {{%email_response}}
              (
                 ere_title,
                 ere_response_body
              ) VALUES (
                 ?, ?
              )';
     try {
         DB_Helper::getInstance()->query($stmt, array($_POST['title'], $_POST['response_body']));
     } catch (DbException $e) {
         return -1;
     }
     $new_response_id = DB_Helper::get_last_insert_id();
     // now populate the project-news mapping table
     foreach ($_POST['projects'] as $prj_id) {
         self::addProjectAssociation($new_response_id, $prj_id);
     }
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:30,代码来源:class.email_response.php

示例2: saveEmail

 /**
  * Method used to save the draft response in the database for
  * further use.
  *
  * @param   integer $issue_id The issue ID
  * @param   string $to The primary recipient of the draft
  * @param   string $cc The secondary recipients of the draft
  * @param   string $subject The subject of the draft
  * @param   string $message The draft body
  * @param   integer $parent_id The ID of the email that this draft is replying to, if any
  * @param   string $unknown_user The sender of the draft, if not a real user
  * @param   boolean $add_history_entry Whether to add a history entry automatically or not
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function saveEmail($issue_id, $to, $cc, $subject, $message, $parent_id = null, $unknown_user = null, $add_history_entry = true)
 {
     if (!$parent_id) {
         $parent_id = null;
     }
     // if unknown_user is not empty, set the usr_id to be the system user.
     if (!empty($unknown_user)) {
         $usr_id = APP_SYSTEM_USER_ID;
     } else {
         $usr_id = Auth::getUserID();
     }
     $stmt = 'INSERT INTO
                 {{%email_draft}}
              (
                 emd_updated_date,
                 emd_usr_id,
                 emd_iss_id,
                 emd_sup_id,
                 emd_subject,
                 emd_body';
     if ($unknown_user) {
         $stmt .= ', emd_unknown_user';
     }
     $stmt .= ') VALUES (
                 ?, ?, ?, ?, ?, ?
             ';
     $params = array(Date_Helper::getCurrentDateGMT(), $usr_id, $issue_id, $parent_id, $subject, $message);
     if ($unknown_user) {
         $stmt .= ', ?';
         $params[] = $unknown_user;
     }
     $stmt .= ')';
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $new_emd_id = DB_Helper::get_last_insert_id();
     self::addEmailRecipient($new_emd_id, $to, false);
     $cc = str_replace(',', ';', $cc);
     $ccs = explode(';', $cc);
     foreach ($ccs as $cc) {
         self::addEmailRecipient($new_emd_id, $cc, true);
     }
     Issue::markAsUpdated($issue_id, 'draft saved');
     if ($add_history_entry) {
         History::add($issue_id, $usr_id, 'draft_added', 'Email message saved as a draft by {user}', array('user' => User::getFullName($usr_id)));
     }
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:64,代码来源:class.draft.php

示例3: insert

 /**
  * Inserts a new group into the database
  *
  * @return integer 1 if successful, -1 or -2 otherwise
  */
 public static function insert()
 {
     $stmt = 'INSERT INTO
                 {{%group}}
              (
                 grp_name,
                 grp_description,
                 grp_manager_usr_id
              ) VALUES (
                 ?, ?, ?
              )';
     $params = array($_POST['group_name'], $_POST['description'], $_POST['manager']);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $grp_id = DB_Helper::get_last_insert_id();
     self::setProjects($grp_id, $_POST['projects']);
     foreach ($_POST['users'] as $usr_id) {
         User::setGroupID($usr_id, $grp_id);
     }
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:29,代码来源:class.group.php

示例4: insertIssue

 /**
  * Insert issue to database.
  *
  * @param   integer $prj_id The project ID
  * @param   array $data of issue to be inserted
  * @return  integer The new issue ID
  */
 private function insertIssue($prj_id, $data)
 {
     // if there is no reporter set, use the system user
     if (empty($data['reporter'])) {
         $data['reporter'] = APP_SYSTEM_USER_ID;
     }
     if (!isset($data['estimated_dev_time']) || $data['estimated_dev_time'] == '') {
         $data['estimated_dev_time'] = 0;
     }
     if (!isset($data['private'])) {
         $data['private'] = 0;
     }
     // add new issue
     $params = array('iss_usr_id' => $data['reporter'], 'iss_created_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_type' => 'created', 'iss_summary' => $data['summary'], 'iss_description' => $data['description'], 'iss_dev_time' => $data['estimated_dev_time'], 'iss_root_message_id' => $data['msg_id'], 'iss_prj_id' => $prj_id);
     if (!empty($data['group'])) {
         $params['iss_grp_id'] = $data['group'];
     }
     if (!empty($data['category'])) {
         $params['iss_prc_id'] = $data['category'];
     }
     if (!empty($data['release'])) {
         $params['iss_pre_id'] = $data['release'];
     }
     if (!empty($data['priority'])) {
         $params['iss_pri_id'] = $data['priority'];
     }
     if (!empty($data['severity'])) {
         $params['iss_sev_id'] = $data['severity'];
     }
     if (!empty($data['expected_resolution_date'])) {
         $params['iss_expected_resolution_date'] = $data['expected_resolution_date'];
     }
     $initial_status = Project::getInitialStatus($prj_id);
     if (!empty($initial_status)) {
         $params['iss_sta_id'] = $initial_status;
     }
     if (CRM::hasCustomerIntegration($prj_id)) {
         $params['iss_customer_id'] = $data['customer'];
         if (!empty($data['contract'])) {
             $params['iss_customer_contract_id'] = $data['contract'];
         }
         $params['iss_customer_contact_id'] = $data['contact'];
         $params['iss_contact_person_lname'] = $data['contact_person_lname'];
         $params['iss_contact_person_fname'] = $data['contact_person_fname'];
         $params['iss_contact_email'] = $data['contact_email'];
         $params['iss_contact_phone'] = $data['contact_phone'];
         $params['iss_contact_timezone'] = $data['contact_timezone'];
     }
     if (!empty($data['contact'])) {
         $params['iss_private'] = $data['private'];
     }
     $stmt = 'INSERT INTO {{%issue}} SET ' . DB_Helper::buildSet($params);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $issue_id = DB_Helper::get_last_insert_id();
     return $issue_id;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:67,代码来源:class.issue.php

示例5: insert

 /**
  * Method used to add a new custom field to the system.
  *
  * @return  integer 1 if the insert worked, -1 otherwise
  */
 public static function insert()
 {
     if (empty($_POST['report_form'])) {
         $_POST['report_form'] = 0;
     }
     if (empty($_POST['report_form_required'])) {
         $_POST['report_form_required'] = 0;
     }
     if (empty($_POST['anon_form'])) {
         $_POST['anon_form'] = 0;
     }
     if (empty($_POST['anon_form_required'])) {
         $_POST['anon_form_required'] = 0;
     }
     if (empty($_POST['close_form'])) {
         $_POST['close_form'] = 0;
     }
     if (empty($_POST['close_form_required'])) {
         $_POST['close_form_required'] = 0;
     }
     if (empty($_POST['list_display'])) {
         $_POST['list_display'] = 0;
     }
     if (empty($_POST['min_role'])) {
         $_POST['min_role'] = 1;
     }
     if (!isset($_POST['rank'])) {
         $_POST['rank'] = self::getMaxRank() + 1;
     }
     $stmt = 'INSERT INTO
                 {{%custom_field}}
              (
                 fld_title,
                 fld_description,
                 fld_type,
                 fld_report_form,
                 fld_report_form_required,
                 fld_anonymous_form,
                 fld_anonymous_form_required,
                 fld_close_form,
                 fld_close_form_required,
                 fld_list_display,
                 fld_min_role,
                 fld_rank,
                 fld_backend
              ) VALUES (
                  ?, ?, ?, ?, ?,
                  ?, ?, ?, ?, ?,
                  ?, ?, ?
              )';
     try {
         DB_Helper::getInstance()->query($stmt, array($_POST['title'], $_POST['description'], $_POST['field_type'], $_POST['report_form'], $_POST['report_form_required'], $_POST['anon_form'], $_POST['anon_form_required'], $_POST['close_form'], $_POST['close_form_required'], $_POST['list_display'], $_POST['min_role'], $_POST['rank'], @$_POST['custom_field_backend']));
     } catch (DbException $e) {
         return -1;
     }
     $new_id = DB_Helper::get_last_insert_id();
     if ($_POST['field_type'] == 'combo' || $_POST['field_type'] == 'multiple' || $_POST['field_type'] == 'checkbox') {
         foreach ($_POST['field_options'] as $option_value) {
             $params = self::parseParameters($option_value);
             self::addOptions($new_id, $params['value']);
         }
     }
     // add the project associations!
     foreach ($_POST['projects'] as $prj_id) {
         self::associateProject($prj_id, $new_id);
     }
     return 1;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:73,代码来源:class.custom_field.php

示例6: insert

 /**
  * Method used to add a FAQ entry to the system.
  *
  * @return  integer 1 if the insert worked, -1 otherwise
  */
 public static function insert()
 {
     if (Validation::isWhitespace($_POST['title'])) {
         return -2;
     }
     if (Validation::isWhitespace($_POST['message'])) {
         return -3;
     }
     $stmt = 'INSERT INTO
                 {{%faq}}
              (
                 faq_prj_id,
                 faq_usr_id,
                 faq_created_date,
                 faq_title,
                 faq_message,
                 faq_rank
              ) VALUES (
                 ?, ?, ?, ?, ?, ?
              )';
     $params = array($_POST['project'], Auth::getUserID(), Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['message'], $_POST['rank']);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $new_faq_id = DB_Helper::get_last_insert_id();
     if (isset($_POST['support_levels']) && count($_POST['support_levels']) > 0) {
         // now populate the faq-support level mapping table
         foreach ($_POST['support_levels'] as $support_level_id) {
             self::addSupportLevelAssociation($new_faq_id, $support_level_id);
         }
     }
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:40,代码来源:class.faq.php

示例7: insert

 /**
  * Method used to add a new user to the system.
  *
  * @param   array $user The array of user information
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function insert($user)
 {
     $projects = array();
     foreach ($user['role'] as $prj_id => $role) {
         if ($role < 1) {
             continue;
         }
         $projects[] = $prj_id;
     }
     $params = array(isset($user['customer_id']) ? $user['customer_id'] : null, isset($user['contact_id']) ? $user['contact_id'] : null, Date_Helper::getCurrentDateGMT(), Auth::hashPassword($user['password']), $user['full_name'], $user['email'], !empty($user['grp_id']) ? $user['grp_id'] : null, $user['external_id'], isset($user['par_code']) ? $user['par_code'] : null);
     $stmt = 'INSERT INTO
                 {{%user}}
              (
                 usr_customer_id,
                 usr_customer_contact_id,
                 usr_created_date,
                 usr_password,
                 usr_full_name,
                 usr_email,
                 usr_grp_id,
                 usr_external_id,
                 usr_par_code
              ) VALUES (
                 ?,
                 ?,
                 ?,
                 ?,
                 ?,
                 ?,
                 ?,
                 ?,
                 ?
              )';
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $new_usr_id = DB_Helper::get_last_insert_id();
     // add the project associations!
     $projects = array();
     foreach ($user['role'] as $prj_id => $role) {
         if ($role < 1) {
             continue;
         }
         Project::associateUser($prj_id, $new_usr_id, $role);
         $projects[] = $prj_id;
     }
     Prefs::set($new_usr_id, Prefs::getDefaults($projects));
     // send email to user
     Notification::notifyNewUser($new_usr_id, $user['password']);
     return $new_usr_id;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:59,代码来源:class.user.php

示例8: insert

 /**
  * Method used to add a new project to the system.
  *
  * @return  integer 1 if the update worked, -1 or -2 otherwise
  */
 public static function insert()
 {
     if (Validation::isWhitespace($_POST['title'])) {
         return -2;
     }
     $stmt = 'INSERT INTO
                 {{%project}}
              (
                 prj_created_date,
                 prj_title,
                 prj_status,
                 prj_lead_usr_id,
                 prj_initial_sta_id,
                 prj_outgoing_sender_name,
                 prj_outgoing_sender_email,
                 prj_mail_aliases,
                 prj_remote_invocation,
                 prj_customer_backend,
                 prj_workflow_backend
              ) VALUES (
                  ?, ?, ?, ?, ?,
                  ?, ?, ?, ?, ?, ?
              )';
     try {
         DB_Helper::getInstance()->query($stmt, array(Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['status'], $_POST['lead_usr_id'], $_POST['initial_status'], $_POST['outgoing_sender_name'], $_POST['outgoing_sender_email'], $_POST['mail_aliases'], $_POST['remote_invocation'], $_POST['customer_backend'], $_POST['workflow_backend']));
     } catch (DbException $e) {
         return -1;
     }
     $new_prj_id = DB_Helper::get_last_insert_id();
     foreach ($_POST['users'] as $user) {
         if ($user == $_POST['lead_usr_id']) {
             $role_id = User::getRoleID('Manager');
         } else {
             $role_id = User::getRoleID('Standard User');
         }
         self::associateUser($new_prj_id, $user, $role_id);
     }
     foreach ($_POST['statuses'] as $sta_id) {
         Status::addProjectAssociation($sta_id, $new_prj_id);
     }
     Display_Column::setupNewProject($new_prj_id);
     // insert default timetracking categories
     Time_Tracking::addProjectDefaults($new_prj_id);
     return 1;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:50,代码来源:class.project.php

示例9: insertEmail

 /**
  * Method used to add a new support email to the system.
  *
  * @param   array $row The support email details
  * @param   object $structure The email structure object
  * @param   integer $sup_id The support ID to be passed out
  * @param   boolean $closing If this email comes from closing the issue
  * @return  integer 1 if the insert worked, -1 otherwise
  */
 public static function insertEmail($row, &$structure, &$sup_id, $closing = false)
 {
     // get usr_id from FROM header
     $usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($row['from']));
     if (!empty($usr_id) && empty($row['customer_id'])) {
         $row['customer_id'] = User::getCustomerID($usr_id);
     }
     if (empty($row['customer_id'])) {
         $row['customer_id'] = null;
     }
     // try to get the parent ID
     $reference_message_id = Mail_Helper::getReferenceMessageID($row['full_email']);
     $parent_id = '';
     if (!empty($reference_message_id)) {
         $parent_id = self::getIDByMessageID($reference_message_id);
         // make sure it is in the same issue
         if (!empty($parent_id) && (empty($row['issue_id']) || @$row['issue_id'] != self::getIssueFromEmail($parent_id))) {
             $parent_id = '';
         }
     }
     $params = array('sup_ema_id' => $row['ema_id'], 'sup_iss_id' => $row['issue_id'], 'sup_customer_id' => $row['customer_id'], 'sup_message_id' => $row['message_id'] ?: '', 'sup_date' => $row['date'], 'sup_from' => $row['from'], 'sup_to' => $row['to'], 'sup_cc' => $row['cc'], 'sup_subject' => $row['subject'] ?: '', 'sup_has_attachment' => $row['has_attachment']);
     if (!empty($parent_id)) {
         $params['sup_parent_id'] = $parent_id;
     }
     if (!empty($usr_id)) {
         $params['sup_usr_id'] = $usr_id;
     }
     $stmt = 'INSERT INTO {{%support_email}} SET ' . DB_Helper::buildSet($params);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $new_sup_id = DB_Helper::get_last_insert_id();
     $sup_id = $new_sup_id;
     $row['sup_id'] = $sup_id;
     // now add the body and full email to the separate table
     $stmt = 'INSERT INTO
                 {{%support_email_body}}
              (
                 seb_sup_id,
                 seb_body,
                 seb_full_email
              ) VALUES (
                 ?, ?, ?
              )';
     try {
         DB_Helper::getInstance()->query($stmt, array($new_sup_id, $row['body'], $row['full_email']));
     } catch (DbException $e) {
         return -1;
     }
     if (!empty($row['issue_id'])) {
         $prj_id = Issue::getProjectID($row['issue_id']);
     } elseif (!empty($row['ema_id'])) {
         $prj_id = Email_Account::getProjectID($row['ema_id']);
     } else {
         $prj_id = false;
     }
     // FIXME: $row['ema_id'] is empty when mail is sent via convert note!
     if ($prj_id !== false) {
         Workflow::handleNewEmail($prj_id, @$row['issue_id'], $structure, $row, $closing);
     }
     return 1;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:73,代码来源:class.support.php

示例10: insert

 /**
  * Inserts a new link filter into the database.
  *
  * @return integer 1 if insert was successful, -1 otherwise
  */
 public static function insert()
 {
     $sql = 'INSERT INTO
                 {{%link_filter}}
             (
                 lfi_pattern,
                 lfi_replacement,
                 lfi_usr_role,
                 lfi_description
             ) VALUES (
                 ?, ?, ?, ?
             )';
     $params = array($_REQUEST['pattern'], $_REQUEST['replacement'], $_REQUEST['usr_role'], $_REQUEST['description']);
     try {
         DB_Helper::getInstance()->query($sql, $params);
     } catch (DbException $e) {
         return -1;
     }
     $lfi_id = DB_Helper::get_last_insert_id();
     foreach ($_REQUEST['projects'] as $prj_id) {
         $sql = 'INSERT INTO
                     {{%project_link_filter}}
                 (
                     plf_prj_id,
                     plf_lfi_id
                 ) VALUES (
                     ?, ?
                 )';
         try {
             DB_Helper::getInstance()->query($sql, array($prj_id, $lfi_id));
         } catch (DbException $e) {
             return -1;
         }
     }
     return 1;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:41,代码来源:class.link_filter.php

示例11: insert

 /**
  * Method used to create a new reminder action.
  *
  * @return  integer 1 if the insert worked, -1 or -2 otherwise
  */
 public static function insert()
 {
     $stmt = 'INSERT INTO
                 {{%reminder_action}}
              (
                 rma_rem_id,
                 rma_rmt_id,
                 rma_created_date,
                 rma_title,
                 rma_rank,
                 rma_alert_irc,
                 rma_alert_group_leader,
                 rma_boilerplate
              ) VALUES (
                 ?, ?, ?, ?, ?,
                 ?, ?, ?
              )';
     $params = array($_POST['rem_id'], $_POST['type'], Date_Helper::getCurrentDateGMT(), $_POST['title'], $_POST['rank'], $_POST['alert_irc'], $_POST['alert_group_leader'], $_POST['boilerplate']);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     $new_rma_id = DB_Helper::get_last_insert_id();
     // add the user list, if appropriate
     if (self::isUserList($_POST['type'])) {
         self::associateUserList($new_rma_id, $_POST['user_list']);
     }
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:35,代码来源:class.reminder_action.php

示例12: foreach

$prj_id = 1;
// FIXME: Customer::getAssocList does not exist
$customers = Customer::getAssocList($prj_id);
foreach ($customers as $customer_id => $customer_name) {
    echo "Customer: {$customer_name}<br />\n";
    $details = Customer::getDetails($prj_id, $customer_id);
    foreach ($details['contacts'] as $contact) {
        echo 'Contact: ' . $contact['first_name'] . ' ' . $contact['last_name'] . ' (' . $contact['email'] . ")<br />\n";
        $contact_id = User::getUserIDByContactID($contact['contact_id']);
        if (empty($contact_id)) {
            $sql = 'INSERT INTO
                        {{%user}}
                    SET
                        usr_created_date = ?,
                        usr_full_name = ?,
                        usr_email = ?,
                        usr_customer_id = ?,
                        usr_customer_contact_id = ?,
                        usr_preferences = ?';
            $params = array(Date_Helper::getCurrentDateGMT(), $contact['first_name'] . ' ' . $contact['last_name'], $contact['email'], $customer_id, $contact['contact_id'], Prefs::getDefaults(array($prj_id)));
            try {
                DB_Helper::getInstance()->query($sql, $params);
            } catch (DbException $e) {
                echo 'Error inserting user<br />';
            }
            $new_usr_id = DB_Helper::get_last_insert_id();
            Project::associateUser($prj_id, $new_usr_id, User::ROLE_CUSTOMER);
        }
    }
    echo '<hr />';
}
开发者ID:dabielkabuto,项目名称:eventum,代码行数:31,代码来源:create_customers.php

示例13: add

 /**
  * Method used to add an attachment to the database.
  *
  * @param   integer $issue_id The issue ID
  * @param   integer $usr_id The user ID
  * @param   string $description The description for this new attachment
  * @param   boolean $internal_only Whether this attachment is supposed to be internal only or not
  * @param   string $unknown_user The email of the user who originally sent this email, who doesn't have an account.
  * @param   integer $associated_note_id The note ID that these attachments should be associated with
  * @return  integer The new attachment ID
  */
 public static function add($issue_id, $usr_id, $description, $internal_only = false, $unknown_user = null, $associated_note_id = null)
 {
     if ($internal_only) {
         $attachment_status = 'internal';
     } else {
         $attachment_status = 'public';
     }
     $params = array('iat_iss_id' => $issue_id, 'iat_usr_id' => $usr_id, 'iat_created_date' => Date_Helper::getCurrentDateGMT(), 'iat_description' => $description, 'iat_status' => $attachment_status);
     if ($unknown_user) {
         $params['iat_unknown_user'] = $unknown_user;
     }
     if ($associated_note_id) {
         $params['iat_not_id'] = $associated_note_id;
     }
     $stmt = 'INSERT INTO {{%issue_attachment}} SET ' . DB_Helper::buildSet($params);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return false;
     }
     return DB_Helper::get_last_insert_id();
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:33,代码来源:class.attachment.php

示例14: subscribeEmail

 /**
  * Method used to add a new subscriber manually, by using the
  * email notification interface.
  *
  * @param   integer $usr_id The user ID of the person performing this change
  * @param   integer $issue_id The issue ID
  * @param   string $email The email address to subscribe
  * @param   array $actions The actions to subcribe to
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function subscribeEmail($usr_id, $issue_id, $email, $actions)
 {
     $email = Mail_Helper::getEmailAddress($email);
     if (!is_string($email)) {
         return -1;
     }
     $email = strtolower($email);
     // first check if this is an actual user or just an email address
     $sub_usr_id = User::getUserIDByEmail($email, true);
     if (!empty($sub_usr_id)) {
         return self::subscribeUser($usr_id, $issue_id, $sub_usr_id, $actions);
     }
     $prj_id = Issue::getProjectID($issue_id);
     // call workflow to modify actions or cancel adding this user.
     $subscriber_usr_id = false;
     $workflow = Workflow::handleSubscription($prj_id, $issue_id, $subscriber_usr_id, $email, $actions);
     if ($workflow === false) {
         // cancel subscribing the user
         return -2;
     }
     // manual check to prevent duplicates
     if (!empty($email)) {
         $stmt = 'SELECT
                     COUNT(sub_id)
                  FROM
                     {{%subscription}}
                  WHERE
                     sub_iss_id=? AND
                     sub_email=?';
         $total = DB_Helper::getInstance()->getOne($stmt, array($issue_id, $email));
         if ($total > 0) {
             return -1;
         }
     }
     $stmt = "INSERT INTO\n                    {{%subscription}}\n                 (\n                    sub_iss_id,\n                    sub_usr_id,\n                    sub_created_date,\n                    sub_level,\n                    sub_email\n                 ) VALUES (\n                    ?,\n                    0,\n                    ?,\n                    'issue',\n                    ?\n                 )";
     try {
         DB_Helper::getInstance()->query($stmt, array($issue_id, Date_Helper::getCurrentDateGMT(), $email));
     } catch (DbException $e) {
         return -1;
     }
     $sub_id = DB_Helper::get_last_insert_id();
     foreach ($actions as $sbt_type) {
         self::addType($sub_id, $sbt_type);
     }
     // need to mark the issue as updated
     Issue::markAsUpdated($issue_id);
     // need to save a history entry for this
     // FIXME: XSS possible as $email is not escaped for html?
     History::add($issue_id, $usr_id, 'notification_added', "Notification list entry ('{subscriber}') added by {user}", array('subscriber' => $email, 'user' => User::getFullName($usr_id)));
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:61,代码来源:class.notification.php

示例15: insert

 /**
  * Method used to add a phone support entry using the user
  * interface form available in the application.
  *
  * @return  integer 1 if the insert worked, -1 or -2 otherwise
  */
 public static function insert()
 {
     $usr_id = Auth::getUserID();
     $iss_id = (int) $_POST['issue_id'];
     $date = $_POST['date'];
     // format the date from the form
     $created_date = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $date['Year'], $date['Month'], $date['Day'], $date['Hour'], $date['Minute'], 0);
     // convert the date to GMT timezone
     $created_date = Date_Helper::convertDateGMT($created_date . ' ' . Date_Helper::getPreferredTimezone());
     $stmt = 'INSERT INTO
                 {{%phone_support}}
              (
                 phs_iss_id,
                 phs_usr_id,
                 phs_phc_id,
                 phs_created_date,
                 phs_type,
                 phs_phone_number,
                 phs_description,
                 phs_phone_type,
                 phs_call_from_lname,
                 phs_call_from_fname,
                 phs_call_to_lname,
                 phs_call_to_fname
              ) VALUES (
                 ?, ?, ?, ?, ?,
                 ?, ?, ?, ?, ?,
                 ?, ?
              )';
     $params = array($iss_id, $usr_id, $_POST['phone_category'], $created_date, $_POST['type'], $_POST['phone_number'], $_POST['description'], $_POST['phone_type'], $_POST['from_lname'], $_POST['from_fname'], $_POST['to_lname'], $_POST['to_fname']);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     // enter the time tracking entry about this phone support entry
     $phs_id = DB_Helper::get_last_insert_id();
     $prj_id = Auth::getCurrentProject();
     $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Telephone Discussion');
     $time_spent = (int) $_POST['call_length'];
     $summary = ev_gettext('Time entry inserted from phone call.');
     Time_Tracking::addTimeEntry($iss_id, $ttc_id, $time_spent, $date, $summary);
     $stmt = 'SELECT
                 max(ttr_id)
              FROM
                 {{%time_tracking}}
              WHERE
                 ttr_iss_id = ? AND
                 ttr_usr_id = ?';
     $ttr_id = DB_Helper::getInstance()->getOne($stmt, array($iss_id, $usr_id));
     Issue::markAsUpdated($iss_id, 'phone call');
     // need to save a history entry for this
     History::add($iss_id, $usr_id, 'phone_entry_added', 'Phone Support entry submitted by {user}', array('user' => User::getFullName($usr_id)));
     // XXX: send notifications for the issue being updated (new notification type phone_support?)
     // update phone record with time tracking ID.
     if (!empty($phs_id) && !empty($ttr_id)) {
         $stmt = 'UPDATE
                     {{%phone_support}}
                  SET
                     phs_ttr_id = ?
                  WHERE
                     phs_id = ?';
         try {
             DB_Helper::getInstance()->query($stmt, array($ttr_id, $phs_id));
         } catch (DbException $e) {
             return -1;
         }
     }
     return 1;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:76,代码来源:class.phone_support.php


注:本文中的DB_Helper::get_last_insert_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。