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


PHP History::formatChanges方法代码示例

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


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

示例1: updateValues

 /**
  * Method used to update the values stored in the database.
  *
  * @return  integer 1 if the update worked properly, any other value otherwise
  */
 public static function updateValues()
 {
     $prj_id = Auth::getCurrentProject();
     $issue_id = $_POST['issue_id'];
     $old_values = self::getValuesByIssue($prj_id, $issue_id);
     if (isset($_POST['custom_fields']) && count($_POST['custom_fields']) > 0) {
         $custom_fields = $_POST['custom_fields'];
         // get the types for all of the custom fields being submitted
         $cf = array_keys($custom_fields);
         $cf_list = DB_Helper::buildList($cf);
         $stmt = "SELECT\n                        fld_id,\n                        fld_type\n                     FROM\n                        {{%custom_field}}\n                     WHERE\n                        fld_id IN ({$cf_list})";
         $field_types = DB_Helper::getInstance()->getPair($stmt, $cf);
         // get the titles for all of the custom fields being submitted
         $stmt = "SELECT\n                        fld_id,\n                        fld_title\n                     FROM\n                        {{%custom_field}}\n                     WHERE\n                        fld_id IN ({$cf_list})";
         $field_titles = DB_Helper::getInstance()->getPair($stmt, $cf);
         $updated_fields = array();
         foreach ($custom_fields as $fld_id => $value) {
             // security check
             $sql = 'SELECT
                         fld_min_role
                     FROM
                         {{%custom_field}}
                     WHERE
                         fld_id = ?';
             $min_role = DB_Helper::getInstance()->getOne($sql, array($fld_id));
             if ($min_role > Auth::getCurrentRole()) {
                 continue;
             }
             $option_types = array('multiple', 'combo', 'checkbox');
             if (!in_array($field_types[$fld_id], $option_types)) {
                 // check if this is a date field
                 $fld_db_name = self::getDBValueFieldNameByType($field_types[$fld_id]);
                 // first check if there is actually a record for this field for the issue
                 $stmt = "SELECT\n                                icf_id,\n                                {$fld_db_name} as value\n                             FROM\n                                {{%issue_custom_field}}\n                             WHERE\n                                icf_iss_id=? AND\n                                icf_fld_id=?";
                 try {
                     $res = DB_Helper::getInstance()->getRow($stmt, array($issue_id, $fld_id));
                 } catch (DbException $e) {
                     return -1;
                 }
                 $icf_id = $res['icf_id'];
                 $old_value = $res['value'];
                 if ($old_value == $value) {
                     continue;
                 }
                 if (empty($icf_id)) {
                     // record doesn't exist, insert new record
                     $stmt = "INSERT INTO\n                                    {{%issue_custom_field}}\n                                 (\n                                    icf_iss_id,\n                                    icf_fld_id,\n                                    {$fld_db_name}\n                                 ) VALUES (\n                                    ?, ?, ?\n                                 )";
                     $params = array($issue_id, $fld_id, $value);
                     try {
                         DB_Helper::getInstance()->query($stmt, $params);
                     } catch (DbException $e) {
                         return -1;
                     }
                 } else {
                     // record exists, update it
                     $stmt = "UPDATE\n                                    {{%issue_custom_field}}\n                                 SET\n                                    {$fld_db_name}=?\n                                 WHERE\n                                    icf_id=?";
                     $params = array($value, $icf_id);
                     try {
                         DB_Helper::getInstance()->query($stmt, $params);
                     } catch (DbException $e) {
                         return -1;
                     }
                 }
                 if ($field_types[$fld_id] == 'textarea') {
                     $updated_fields[$field_titles[$fld_id]] = '';
                 } else {
                     $updated_fields[$field_titles[$fld_id]] = History::formatChanges($old_value, $value);
                 }
             } else {
                 $old_value = self::getDisplayValue($issue_id, $fld_id, true);
                 if (!is_array($old_value)) {
                     $old_value = array($old_value);
                 }
                 if (!is_array($value)) {
                     $value = array($value);
                 }
                 if (count(array_diff($old_value, $value)) > 0 || count(array_diff($value, $old_value)) > 0) {
                     $old_display_value = self::getDisplayValue($issue_id, $fld_id);
                     // need to remove all associated options from issue_custom_field and then
                     // add the selected options coming from the form
                     self::removeIssueAssociation($fld_id, $issue_id);
                     if (@count($value) > 0) {
                         self::associateIssue($issue_id, $fld_id, $value);
                     }
                     $new_display_value = self::getDisplayValue($issue_id, $fld_id);
                     $updated_fields[$field_titles[$fld_id]] = History::formatChanges($old_display_value, $new_display_value);
                 }
             }
         }
         Workflow::handleCustomFieldsUpdated($prj_id, $issue_id, $old_values, self::getValuesByIssue($prj_id, $issue_id));
         Issue::markAsUpdated($issue_id);
         // need to save a history entry for this
         if (count($updated_fields) > 0) {
             // log the changes
             $changes = '';
//.........这里部分代码省略.........
开发者ID:korusdipl,项目名称:eventum,代码行数:101,代码来源:class.custom_field.php

示例2: setAssignees

 /**
  * Sets the assignees for the issue
  *
  * @param   integer $issue_id
  * @param   array $assignees
  * @return  int 1 if success, -1 if error, 0 if no change was needed.
  */
 public static function setAssignees($issue_id, $assignees)
 {
     if (!is_array($assignees)) {
         $assignees = array();
     }
     // see if there is anything to change
     $old_assignees = self::getAssignedUserIDs($issue_id);
     if (count(array_diff($old_assignees, $assignees)) == 0 && count(array_diff($assignees, $old_assignees)) == 0) {
         return 0;
     }
     $old_assignee_names = self::getAssignedUsers($issue_id);
     Workflow::handleAssignmentChange(self::getProjectID($issue_id), $issue_id, Auth::getUserID(), self::getDetails($issue_id), $assignees, true);
     // clear up the assignments for this issue, and then assign it to the current user
     self::deleteUserAssociations($issue_id);
     $assignee_names = array();
     foreach ($assignees as $assignee) {
         $res = self::addUserAssociation(Auth::getUserID(), $issue_id, $assignee, false);
         if ($res == -1) {
             return -1;
         }
         $assignee_names[] = User::getFullName($assignee);
         Notification::subscribeUser(Auth::getUserID(), $issue_id, $assignee, Notification::getDefaultActions($issue_id, User::getEmail($assignee), 'set_assignees'), false);
     }
     Notification::notifyNewAssignment($assignees, $issue_id);
     $usr_id = Auth::getUserID();
     History::add($issue_id, $usr_id, 'user_associated', 'Issue assignment to changed ({changes}) by {user}', array('changes' => History::formatChanges(implode(', ', $old_assignee_names), implode(', ', $assignee_names)), 'user' => User::getFullName($usr_id)));
     return 1;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:35,代码来源:class.issue.php

示例3: updateValues

 /**
  * Method used to update the values stored in the database.
  *
  * @param $issue_id
  * @param $custom_fields
  * @return array|int -1 if there is an error, otherwise an array of the updated fields
  */
 public static function updateValues($issue_id, $custom_fields)
 {
     $prj_id = Auth::getCurrentProject();
     $old_values = self::getValuesByIssue($prj_id, $issue_id);
     if (count($custom_fields) > 0) {
         // get the types for all of the custom fields being submitted
         $cf = array_keys($custom_fields);
         $cf_list = DB_Helper::buildList($cf);
         $stmt = "SELECT\n                        fld_id,\n                        fld_type\n                     FROM\n                        {{%custom_field}}\n                     WHERE\n                        fld_id IN ({$cf_list})";
         $field_types = DB_Helper::getInstance()->getPair($stmt, $cf);
         // get the titles for all of the custom fields being submitted
         $stmt = "SELECT\n                        fld_id,\n                        fld_title\n                     FROM\n                        {{%custom_field}}\n                     WHERE\n                        fld_id IN ({$cf_list})";
         $field_titles = DB_Helper::getInstance()->getPair($stmt, $cf);
         $updated_fields = array();
         foreach ($custom_fields as $fld_id => $value) {
             // security check
             $sql = 'SELECT
                         fld_min_role
                     FROM
                         {{%custom_field}}
                     WHERE
                         fld_id = ?';
             $min_role = DB_Helper::getInstance()->getOne($sql, array($fld_id));
             if ($min_role > Auth::getCurrentRole()) {
                 continue;
             }
             $updated_fields[$fld_id] = array('title' => $field_titles[$fld_id], 'type' => $field_types[$fld_id], 'min_role' => $min_role, 'changes' => '', 'old_display' => '', 'new_display' => '');
             if (!in_array($field_types[$fld_id], self::$option_types)) {
                 // check if this is a date field
                 $fld_db_name = self::getDBValueFieldNameByType($field_types[$fld_id]);
                 // first check if there is actually a record for this field for the issue
                 $stmt = "SELECT\n                                icf_id,\n                                {$fld_db_name} as value\n                             FROM\n                                {{%issue_custom_field}}\n                             WHERE\n                                icf_iss_id=? AND\n                                icf_fld_id=?";
                 try {
                     $res = DB_Helper::getInstance()->getRow($stmt, array($issue_id, $fld_id));
                 } catch (DbException $e) {
                     return -1;
                 }
                 $icf_id = $res['icf_id'];
                 $old_value = $res['value'];
                 if ($old_value == $value) {
                     unset($updated_fields[$fld_id]);
                     continue;
                 }
                 if (empty($icf_id)) {
                     // record doesn't exist, insert new record
                     $stmt = "INSERT INTO\n                                    {{%issue_custom_field}}\n                                 (\n                                    icf_iss_id,\n                                    icf_fld_id,\n                                    {$fld_db_name}\n                                 ) VALUES (\n                                    ?, ?, ?\n                                 )";
                     $params = array($issue_id, $fld_id, $value);
                     try {
                         DB_Helper::getInstance()->query($stmt, $params);
                     } catch (DbException $e) {
                         return -1;
                     }
                 } else {
                     // record exists, update it
                     $stmt = "UPDATE\n                                    {{%issue_custom_field}}\n                                 SET\n                                    {$fld_db_name}=?\n                                 WHERE\n                                    icf_id=?";
                     $params = array($value, $icf_id);
                     try {
                         DB_Helper::getInstance()->query($stmt, $params);
                     } catch (DbException $e) {
                         return -1;
                     }
                 }
                 $updated_fields[$fld_id]['old_display'] = $old_value;
                 $updated_fields[$fld_id]['new_display'] = $value;
                 if ($field_types[$fld_id] == 'textarea') {
                     $updated_fields[$fld_id]['changes'] = '';
                 } else {
                     $updated_fields[$fld_id]['changes'] = History::formatChanges($old_value, $value);
                 }
             } else {
                 $old_value = self::getDisplayValue($issue_id, $fld_id, true);
                 // remove dummy value from checkboxes. This dummy value is required so all real values can be unchecked.
                 if ($field_types[$fld_id] == 'checkbox') {
                     $value = array_filter($value);
                 }
                 if (!is_array($old_value)) {
                     $old_value = array($old_value);
                 }
                 if (!is_array($value)) {
                     $value = array($value);
                 }
                 if (count(array_diff($old_value, $value)) > 0 || count(array_diff($value, $old_value)) > 0) {
                     $old_display_value = self::getDisplayValue($issue_id, $fld_id);
                     // need to remove all associated options from issue_custom_field and then
                     // add the selected options coming from the form
                     self::removeIssueAssociation($fld_id, $issue_id);
                     if (@count($value) > 0) {
                         self::associateIssue($issue_id, $fld_id, $value);
                     }
                     $new_display_value = self::getDisplayValue($issue_id, $fld_id);
                     $updated_fields[$fld_id]['changes'] = History::formatChanges($old_display_value, $new_display_value);
                     $updated_fields[$fld_id]['old_display'] = $old_display_value;
                     $updated_fields[$fld_id]['new_display'] = $new_display_value;
//.........这里部分代码省略.........
开发者ID:dabielkabuto,项目名称:eventum,代码行数:101,代码来源:class.custom_field.php

示例4: updateValues

 /**
  * Method used to update the values stored in the database.
  *
  * @access  public
  * @return  integer 1 if the update worked properly, any other value otherwise
  */
 function updateValues()
 {
     global $HTTP_POST_VARS;
     $prj_id = Auth::getCurrentProject();
     $issue_id = Misc::escapeInteger($HTTP_POST_VARS["issue_id"]);
     $old_values = Custom_Field::getValuesByIssue($prj_id, $issue_id);
     // get the types for all of the custom fields being submitted
     $stmt = "SELECT\n                    fld_id,\n                    fld_type\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field\n                 WHERE\n                    fld_id IN (" . implode(", ", Misc::escapeInteger(@array_keys($HTTP_POST_VARS['custom_fields']))) . ")";
     $field_types = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
     // get the titles for all of the custom fields being submitted
     $stmt = "SELECT\n                    fld_id,\n                    fld_title\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field\n                 WHERE\n                    fld_id IN (" . implode(", ", Misc::escapeInteger(@array_keys($HTTP_POST_VARS['custom_fields']))) . ")";
     $field_titles = $GLOBALS["db_api"]->dbh->getAssoc($stmt);
     $updated_fields = array();
     foreach ($HTTP_POST_VARS["custom_fields"] as $fld_id => $value) {
         $fld_id = Misc::escapeInteger($fld_id);
         // security check
         $sql = "SELECT\n                        fld_min_role\n                    FROM\n                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field\n                    WHERE\n                        fld_id = {$fld_id}";
         $min_role = $GLOBALS["db_api"]->dbh->getOne($sql);
         if ($min_role > Auth::getCurrentRole()) {
             continue;
         }
         $option_types = array('multiple', 'combo');
         if (!in_array($field_types[$fld_id], $option_types)) {
             // check if this is a date field
             if ($field_types[$fld_id] == 'date') {
                 $value = $value['Year'] . "-" . $value['Month'] . "-" . $value['Day'];
                 if ($value == '--') {
                     $value = '';
                 }
             }
             // first check if there is actually a record for this field for the issue
             $stmt = "SELECT\n                            icf_id,\n                            icf_value\n                         FROM\n                            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field\n                         WHERE\n                            icf_iss_id=" . $issue_id . " AND\n                            icf_fld_id={$fld_id}";
             $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
             if (PEAR::isError($res)) {
                 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                 return -1;
             }
             $icf_id = $res['icf_id'];
             $icf_value = $res['icf_value'];
             if ($icf_value == $value) {
                 continue;
             }
             if (empty($icf_id)) {
                 // record doesn't exist, insert new record
                 $stmt = "INSERT IGNORE INTO\n                                " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field\n                             (\n                                icf_iss_id,\n                                icf_fld_id,\n                                icf_value\n                             ) VALUES (\n                                " . $issue_id . ",\n                                {$fld_id},\n                                '" . Misc::escapeString($value) . "'\n                             )";
                 $res = $GLOBALS["db_api"]->dbh->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
                 }
             } else {
                 // record exists, update it
                 $stmt = "UPDATE\n                                " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field\n                             SET\n                                icf_value='" . Misc::escapeString($value) . "'\n                             WHERE\n                                icf_id={$icf_id}";
                 $res = $GLOBALS["db_api"]->dbh->query($stmt);
                 if (PEAR::isError($res)) {
                     Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
                     return -1;
                 }
             }
             if ($field_types[$fld_id] == 'textarea') {
                 $updated_fields[$field_titles[$fld_id]] = '';
             } else {
                 $updated_fields[$field_titles[$fld_id]] = History::formatChanges($icf_value, $value);
             }
         } else {
             $old_value = Custom_Field::getDisplayValue($HTTP_POST_VARS['issue_id'], $fld_id, true);
             if (!is_array($old_value)) {
                 $old_value = array($old_value);
             }
             if (!is_array($value)) {
                 $value = array($value);
             }
             if (count(array_diff($old_value, $value)) > 0 || count(array_diff($value, $old_value)) > 0) {
                 $old_display_value = Custom_Field::getDisplayValue($HTTP_POST_VARS['issue_id'], $fld_id);
                 // need to remove all associated options from issue_custom_field and then
                 // add the selected options coming from the form
                 Custom_Field::removeIssueAssociation($fld_id, $HTTP_POST_VARS["issue_id"]);
                 if (@count($value) > 0) {
                     Custom_Field::associateIssue($HTTP_POST_VARS["issue_id"], $fld_id, $value);
                 }
                 $new_display_value = Custom_Field::getDisplayValue($HTTP_POST_VARS['issue_id'], $fld_id);
                 $updated_fields[$field_titles[$fld_id]] = History::formatChanges($old_display_value, $new_display_value);
             }
         }
     }
     Workflow::handleCustomFieldsUpdated($prj_id, $issue_id, $old_values, Custom_Field::getValuesByIssue($prj_id, $issue_id));
     Issue::markAsUpdated($HTTP_POST_VARS["issue_id"]);
     // need to save a history entry for this
     if (count($updated_fields) > 0) {
         // log the changes
         $changes = '';
         $i = 0;
         foreach ($updated_fields as $key => $value) {
             if ($i > 0) {
//.........这里部分代码省略.........
开发者ID:juliogallardo1326,项目名称:proc,代码行数:101,代码来源:class.custom_field.php

示例5: setGroup

 /**
  * Sets the group of the issue.
  *
  * @access  public
  * @param   integer $issue_id The ID of the issue
  * @param   integer $group_id The ID of the group
  * @return  integer 1 if successful, -1 or -2 otherwise
  */
 function setGroup($issue_id, $group_id)
 {
     $issue_id = Misc::escapeInteger($issue_id);
     $group_id = Misc::escapeInteger($group_id);
     $current = Issue::getDetails($issue_id);
     if ($current["iss_grp_id"] == $group_id) {
         return -2;
     }
     $stmt = "UPDATE\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n                 SET\n                    iss_grp_id = {$group_id}\n                 WHERE\n                    iss_id = {$issue_id}";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     }
     $current_user = Auth::getUserID();
     if (empty($current_user)) {
         $current_user = APP_SYSTEM_USER_ID;
     }
     History::add($issue_id, $current_user, History::getTypeID('group_changed'), "Group changed (" . History::formatChanges(Group::getName($current["iss_grp_id"]), Group::getName($group_id)) . ") by " . User::getFullName($current_user));
     return 1;
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:29,代码来源:class.issue.php


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