本文整理汇总了PHP中version_is_unique函数的典型用法代码示例。如果您正苦于以下问题:PHP version_is_unique函数的具体用法?PHP version_is_unique怎么用?PHP version_is_unique使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了version_is_unique函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trigger_error
if (is_blank($f_version)) {
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
# We reverse the array so that if the user enters multiple versions
# they will likely appear with the last item entered at the top of the list
# (i.e. in reverse chronological order). Unless we find a way to make the
# date_order fields different for each one, however, this is fragile, since
# the DB may actually pull the rows out in any order
$t_versions = array_reverse(explode('|', $f_version));
$t_version_count = count($t_versions);
foreach ($t_versions as $t_version) {
if (is_blank($t_version)) {
continue;
}
$t_version = trim($t_version);
if (version_is_unique($t_version, $f_project_id)) {
version_add($f_project_id, $t_version);
} else {
if (1 == $t_version_count) {
# We only error out on duplicates when a single value was
# given. If multiple values were given, we just add the
# ones we can. The others already exist so it isn't really
# an error.
trigger_error(ERROR_VERSION_DUPLICATE, ERROR);
}
}
}
form_security_purge('manage_proj_ver_add');
if (true == $f_add_and_edit) {
$t_version_id = version_get_id($t_version, $f_project_id);
$t_redirect_url = 'manage_proj_ver_edit_page.php?version_id=' . $t_version_id;
示例2: mc_project_version_update
/**
* Submit the specified version details.
*
* @param string $p_username The name of the user trying to update the issue.
* @param string $p_password The password of the user.
* @param integer $p_version_id A version's id
* @param Array $p_version A ProjectVersionData structure containing information about the new verison.
* @return bool returns true or false depending on the success of the update action
*/
function mc_project_version_update($p_username, $p_password, $p_version_id, $p_version)
{
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return new soap_fault('Client', '', 'Access Denied', 'Username/password combination was incorrect');
}
if (!mci_has_administrator_access($t_user_id)) {
return new soap_fault('Client', '', 'Access Denied', 'User does not have administrator access');
}
if (is_blank($p_version_id)) {
return new soap_fault('Client', '', 'Mandatory field "version_id" was missing');
}
if (!version_exists($p_version_id)) {
return new soap_fault('Client', '', "Version '{$p_version_id}' does not exist.");
}
extract($p_version, EXTR_PREFIX_ALL, 'v');
if (is_blank($v_project_id)) {
return new soap_fault('Client', '', 'Mandatory field "project_id" was missing');
}
if (!project_exists($v_project_id)) {
return new soap_fault('Client', '', "Version '{$v_project_id}' does not exist.");
}
if (is_blank($v_name)) {
return new soap_fault('Client', '', 'Mandatory field "name" was missing');
}
# check for duplicates
$t_old_version_name = version_get_field($p_version_id, 'version');
if (strtolower($t_old_version_name) != strtolower($v_name) && !version_is_unique($v_name, $v_project_id)) {
return new soap_fault('Client', '', 'Version exists for project', 'The version you attempted to update already exists for this project');
}
if ($v_released === false) {
$v_released = VERSION_FUTURE;
} else {
$v_released = VERSION_RELEASED;
}
$t_version_data = new VersionData();
$t_version_data->id = $p_version_id;
$t_version_data->project_id = $v_project_id;
$t_version_data->version = $v_name;
$t_version_data->description = $v_description;
$t_version_data->released = $v_released;
$t_version_data->date_order = date("Y-m-d H:i:s", strtotime($v_date_order));
return version_update($t_version_data);
}
示例3: mc_project_version_update
/**
* Submit the specified version details.
*
* @param string $p_username The name of the user trying to update the issue.
* @param string $p_password The password of the user.
* @param integer $p_version_id A version's id
* @param Array $p_version A ProjectVersionData structure containing information about the new verison.
* @return bool returns true or false depending on the success of the update action
*/
function mc_project_version_update($p_username, $p_password, $p_version_id, $p_version)
{
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return mci_soap_fault_login_failed();
}
if (is_blank($p_version_id)) {
return new soap_fault('Client', '', 'Mandatory field "version_id" was missing');
}
if (!version_exists($p_version_id)) {
return new soap_fault('Client', '', "Version '{$p_version_id}' does not exist.");
}
$t_project_id = $p_version['project_id'];
$t_name = $p_version['name'];
$t_released = $p_version['released'];
$t_description = $p_version['description'];
$t_date_order = $p_version['date_order'];
if (is_blank($t_project_id)) {
return new soap_fault('Client', '', 'Mandatory field "project_id" was missing');
}
if (!project_exists($t_project_id)) {
return new soap_fault('Client', '', "Project '{$t_project_id}' does not exist.");
}
if (!mci_has_readwrite_access($t_user_id, $t_project_id)) {
return mci_soap_fault_access_denied($t_user_id);
}
if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $t_project_id)) {
return mci_soap_fault_access_denied($t_user_id);
}
if (is_blank($t_name)) {
return new soap_fault('Client', '', 'Mandatory field "name" was missing');
}
# check for duplicates
$t_old_version_name = version_get_field($p_version_id, 'version');
if (strtolower($t_old_version_name) != strtolower($t_name) && !version_is_unique($t_name, $t_project_id)) {
return new soap_fault('Client', '', 'Version exists for project', 'The version you attempted to update already exists for this project');
}
if ($t_released === false) {
$t_released = VERSION_FUTURE;
} else {
$t_released = VERSION_RELEASED;
}
$t_version_data = new VersionData();
$t_version_data->id = $p_version_id;
$t_version_data->project_id = $t_project_id;
$t_version_data->version = $t_name;
$t_version_data->description = $t_description;
$t_version_data->released = $t_released;
$t_version_data->date_order = date("Y-m-d H:i:s", strtotime($t_date_order));
return version_update($t_version_data);
}
示例4: version_update
/**
* Update the definition of a version
* @param VersionData @p_version_info
* @return true
*/
function version_update($p_version_info)
{
version_ensure_exists($p_version_info->id);
$t_old_version_name = version_get_field($p_version_info->id, 'version');
# check for duplicates
if (utf8_strtolower($t_old_version_name) != utf8_strtolower($p_version_info->version) && !version_is_unique($p_version_info->version, $p_version_info->project_id)) {
trigger_error(ERROR_VERSION_DUPLICATE, ERROR);
}
$c_version_id = db_prepare_int($p_version_info->id);
$c_version_name = $p_version_info->version;
$c_old_version_name = $t_old_version_name;
$c_description = $p_version_info->description;
$c_released = db_prepare_int($p_version_info->released);
$c_obsolete = db_prepare_bool($p_version_info->obsolete);
$c_date_order = $p_version_info->date_order;
$c_project_id = db_prepare_int($p_version_info->project_id);
$t_project_version_table = db_get_table('project_version');
$t_bug_table = db_get_table('bug');
$t_history_table = db_get_table('bug_history');
$query = "UPDATE {$t_project_version_table}\n\t\t\t\t SET version=" . db_param() . ",\n\t\t\t\t\tdescription=" . db_param() . ",\n\t\t\t\t\treleased=" . db_param() . ",\n\t\t\t\t\tdate_order=" . db_param() . ",\n\t\t\t\t\tobsolete=" . db_param() . "\n\t\t\t\t WHERE id=" . db_param();
db_query_bound($query, array($c_version_name, $c_description, $c_released, $c_date_order, $c_obsolete, $c_version_id));
if ($c_version_name != $c_old_version_name) {
$t_project_list = array($c_project_id);
if (config_get('subprojects_inherit_versions')) {
$t_project_list = array_merge($t_project_list, project_hierarchy_get_all_subprojects($c_project_id, true));
}
$t_project_list = implode(',', $t_project_list);
$query = 'UPDATE ' . $t_bug_table . ' SET version=' . db_param() . " WHERE ( project_id IN ( {$t_project_list} ) ) AND ( version=" . db_param() . ')';
db_query_bound($query, array($c_version_name, $c_old_version_name));
$query = "UPDATE {$t_bug_table}\n\t\t\t\t\t SET fixed_in_version=" . db_param() . "\n\t\t\t\t\t WHERE ( project_id IN ( {$t_project_list} ) ) AND ( fixed_in_version=" . db_param() . ')';
db_query_bound($query, array($c_version_name, $c_old_version_name));
$query = "UPDATE {$t_bug_table}\n\t\t\t\t\t SET target_version=" . db_param() . "\n\t\t\t\t\t WHERE ( project_id IN ( {$t_project_list} ) ) AND ( target_version=" . db_param() . ')';
db_query_bound($query, array($c_version_name, $c_old_version_name));
$query = "UPDATE {$t_history_table}\n\t\t\tSET old_value=" . db_param() . "\n\t\t\tWHERE field_name IN ('version','fixed_in_version','target_version')\n\t\t\t\tAND old_value=" . db_param() . "\n\t\t\t\tAND bug_id IN (SELECT id FROM {$t_bug_table} WHERE project_id IN ( {$t_project_list} ))";
db_query_bound($query, array($c_version_name, $c_old_version_name));
$query = "UPDATE {$t_history_table}\n\t\t\tSET new_value=" . db_param() . "\n\t\t\tWHERE field_name IN ('version','fixed_in_version','target_version')\n\t\t\t\tAND new_value=" . db_param() . "\n\t\t\t\tAND bug_id IN (SELECT id FROM {$t_bug_table} WHERE project_id IN ( {$t_project_list} ))";
db_query_bound($query, array($c_version_name, $c_old_version_name));
/**
* @todo We should consider using ids instead of names for foreign keys. The main advantage of using the names are:
* - for history the version history entries will still be valid even if the version is deleted in the future. -- we can ban deleting referenced versions.
* - when an issue is copied or moved from one project to another, we can keep the last version with the issue even if it doesn't exist in the new project. Also previous history entries remain valid.
* @todo We probably need to update the saved filters too?
*/
}
// db_query errors on failure so:
return true;
}
示例5: auth_reauthenticate
auth_reauthenticate();
require_once SPECMANAGEMENT_CORE_URI . 'specmanagement_database_api.php';
$specmanagement_database_api = new specmanagement_database_api();
$update = gpc_get_bool('update', false);
$addversion = gpc_get_bool('addversion', false);
/**
* Submit new version
*/
if ($addversion && isset($_POST['new_version_name']) && isset($_POST['new_version_date'])) {
$project_id = helper_get_current_project();
$new_version_date = new DateTime($_POST['new_version_date']);
$new_version_date_timestamp = date_timestamp_get($new_version_date);
$new_version_name = $_POST['new_version_name'];
$new_version_name_trimmed = trim(preg_replace('/\\s+/', ' ', $new_version_name));
if (version_is_unique($new_version_name_trimmed, $project_id) && strlen($new_version_name_trimmed) > 0) {
version_add($project_id, $new_version_name_trimmed, false, '', $new_version_date_timestamp);
}
}
/**
* Change all existing versions
*/
if ($update && isset($_POST['version_ids'])) {
$version_ids = $_POST['version_ids'];
$versions = $_POST['version'];
$date_order = $_POST['date_order'];
$type = $_POST['type'];
$description = $_POST['description'];
for ($version_index = 0; $version_index < count($version_ids); $version_index++) {
$version = version_get($version_ids[$version_index]);
$version_id = $version->id;
开发者ID:Cre-ator,项目名称:Whiteboard.SpecificationManagement-Plugin,代码行数:30,代码来源:manage_versions_update.php
示例6: version_update
function version_update($p_version_info)
{
version_ensure_exists($p_version_info->id);
$t_old_version_name = version_get_field($p_version_info->id, 'version');
# check for duplicates
if (strtolower($t_old_version_name) != strtolower($p_version_info->version) && !version_is_unique($p_version_info->version, $p_version_info->project_id)) {
trigger_error(ERROR_VERSION_DUPLICATE, ERROR);
}
$c_version_id = db_prepare_int($p_version_info->id);
$c_version_name = db_prepare_string($p_version_info->version);
$c_old_version_name = db_prepare_string($t_old_version_name);
$c_description = db_prepare_string($p_version_info->description);
$c_released = db_prepare_int($p_version_info->released);
$c_date_order = db_timestamp($p_version_info->date_order);
$c_project_id = db_prepare_int($p_version_info->project_id);
$t_project_version_table = config_get('mantis_project_version_table');
$t_bug_table = config_get('mantis_bug_table');
$query = "UPDATE {$t_project_version_table}\r\n\t\t\t\t SET version='{$c_version_name}',\r\n\t\t\t\t\tdescription='{$c_description}',\r\n\t\t\t\t\treleased='{$c_released}',\r\n\t\t\t\t\tdate_order={$c_date_order}\r\n\t\t\t\t WHERE id='{$c_version_id}'";
db_query($query);
if ($c_version_name != $c_old_version_name) {
$query = "UPDATE {$t_bug_table}\r\n\t\t\t\t\t SET version='{$c_version_name}'\r\n\t\t\t\t\t WHERE ( project_id='{$c_project_id}' ) AND ( version='{$c_old_version_name}' )";
db_query($query);
$query = "UPDATE {$t_bug_table}\r\n\t\t\t\t\t SET fixed_in_version='{$c_version_name}'\r\n\t\t\t\t\t WHERE ( project_id='{$c_project_id}' ) AND ( fixed_in_version='{$c_old_version_name}' )";
db_query($query);
$query = "UPDATE {$t_bug_table}\r\n\t\t\t\t\t SET target_version='{$c_version_name}'\r\n\t\t\t\t\t WHERE ( project_id='{$c_project_id}' ) AND ( target_version='{$c_old_version_name}' )";
db_query($query);
# @@@ We should consider using ids instead of names for foreign keys. The main advantage of using the names are:
# - for history the version history entries will still be valid even if the version is deleted in the future. -- we can ban deleting referenced versions.
# - when an issue is copied or moved from one project to another, we can keep the last version with the issue even if it doesn't exist in the new project. Also previous history entries remain valid.
# @@@ We should update the history for version, fixed_in_version, and target_version.
# @@@ We probably need to update the saved filters too?
}
# db_query() errors on failure so:
return true;
}
示例7: mc_project_version_update
/**
* Submit the specified version details.
*
* @param string $p_username The name of the user trying to update the issue.
* @param string $p_password The password of the user.
* @param integer $p_version_id A version's id.
* @param stdClass $p_version A ProjectVersionData structure containing information about the new version.
* @return boolean returns true or false depending on the success of the update action
*/
function mc_project_version_update($p_username, $p_password, $p_version_id, stdClass $p_version)
{
global $g_project_override;
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return mci_soap_fault_login_failed();
}
if (is_blank($p_version_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "version_id" was missing');
}
if (!version_exists($p_version_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'Version \'' . $p_version_id . '\' does not exist.');
}
$p_version = SoapObjectsFactory::unwrapObject($p_version);
$t_project_id = $p_version['project_id'];
$g_project_override = $t_project_id;
$t_name = $p_version['name'];
$t_released = $p_version['released'];
$t_description = $p_version['description'];
$t_date_order = isset($p_version['date_order']) ? SoapObjectsFactory::parseDateTimeString($p_version['date_order']) : null;
$t_obsolete = isset($p_version['obsolete']) ? $p_version['obsolete'] : false;
if (is_blank($t_project_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "project_id" was missing');
}
if (!project_exists($t_project_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $t_project_id . '\' does not exist.');
}
if (!mci_has_readwrite_access($t_user_id, $t_project_id)) {
return mci_soap_fault_access_denied($t_user_id);
}
if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $t_project_id)) {
return mci_soap_fault_access_denied($t_user_id);
}
if (is_blank($t_name)) {
return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "name" was missing');
}
# check for duplicates
$t_old_version_name = version_get_field($p_version_id, 'version');
if (strtolower($t_old_version_name) != strtolower($t_name) && !version_is_unique($t_name, $t_project_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'Version exists for project');
}
if ($t_released === false) {
$t_released = VERSION_FUTURE;
} else {
$t_released = VERSION_RELEASED;
}
$t_version_data = new VersionData();
$t_version_data->id = $p_version_id;
$t_version_data->project_id = $t_project_id;
$t_version_data->version = $t_name;
$t_version_data->description = $t_description;
$t_version_data->released = $t_released;
$t_version_data->date_order = $t_date_order;
$t_version_data->obsolete = $t_obsolete;
return version_update($t_version_data);
}
示例8: version_update
/**
* Update the definition of a version
* @param VersionData $p_version_info A version structure to update.
* @return void
*/
function version_update( VersionData $p_version_info ) {
version_ensure_exists( $p_version_info->id );
$t_old_version_name = version_get_field( $p_version_info->id, 'version' );
# check for duplicates
if( ( utf8_strtolower( $t_old_version_name ) != utf8_strtolower( $p_version_info->version ) ) && !version_is_unique( $p_version_info->version, $p_version_info->project_id ) ) {
trigger_error( ERROR_VERSION_DUPLICATE, ERROR );
}
$c_version_id = (int)$p_version_info->id;
$c_version_name = $p_version_info->version;
$c_old_version_name = $t_old_version_name;
$c_description = $p_version_info->description;
$c_released = (bool)$p_version_info->released;
$c_obsolete = (bool)$p_version_info->obsolete;
$c_date_order = $p_version_info->date_order;
$c_project_id = (int)$p_version_info->project_id;
$t_query = 'UPDATE {project_version}
SET version=' . db_param() . ',
description=' . db_param() . ',
released=' . db_param() . ',
date_order=' . db_param() . ',
obsolete=' . db_param() . '
WHERE id=' . db_param();
db_query( $t_query, array( $c_version_name, $c_description, $c_released, $c_date_order, $c_obsolete, $c_version_id ) );
if( $c_version_name != $c_old_version_name ) {
$t_project_list = array( $c_project_id );
if( config_get( 'subprojects_inherit_versions' ) ) {
$t_project_list = array_merge( $t_project_list, project_hierarchy_get_all_subprojects( $c_project_id, true ) );
}
$t_project_list = implode( ',', $t_project_list );
$t_query = 'UPDATE {bug} SET version=' . db_param() .
' WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( version=' . db_param() . ')';
db_query( $t_query, array( $c_version_name, $c_old_version_name ) );
$t_query = 'UPDATE {bug} SET fixed_in_version=' . db_param() . '
WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( fixed_in_version=' . db_param() . ')';
db_query( $t_query, array( $c_version_name, $c_old_version_name ) );
$t_query = 'UPDATE {bug} SET target_version=' . db_param() . '
WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( target_version=' . db_param() . ')';
db_query( $t_query, array( $c_version_name, $c_old_version_name ) );
$t_query = 'UPDATE {bug_history}
SET old_value='.db_param().'
WHERE field_name IN (\'version\',\'fixed_in_version\',\'target_version\')
AND old_value='.db_param().'
AND bug_id IN (SELECT id FROM {bug} WHERE project_id IN ( ' . $t_project_list . ' ))';
db_query( $t_query, array( $c_version_name, $c_old_version_name ) );
$t_query = 'UPDATE {bug_history}
SET new_value='.db_param().'
WHERE field_name IN (\'version\',\'fixed_in_version\',\'target_version\')
AND new_value='.db_param().'
AND bug_id IN (SELECT id FROM {bug} WHERE project_id IN ( ' . $t_project_list . ' ))';
db_query( $t_query, array( $c_version_name, $c_old_version_name ) );
# @todo We should consider using ids instead of names for foreign keys. The main advantage of using the names are:
# - for history the version history entries will still be valid even if the version is deleted in the future. -- we can ban deleting referenced versions.
# - when an issue is copied or moved from one project to another, we can keep the last version with the issue even if it doesn't exist in the new project. Also previous history entries remain valid.
# @todo We probably need to update the saved filters too?
}
}
示例9: require_api
require_api('version_api.php');
form_security_validate('manage_proj_ver_copy');
auth_reauthenticate();
$f_project_id = gpc_get_int('project_id');
$f_other_project_id = gpc_get_int('other_project_id');
$f_copy_from = gpc_get_bool('copy_from');
$f_copy_to = gpc_get_bool('copy_to');
project_ensure_exists($f_project_id);
project_ensure_exists($f_other_project_id);
access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id);
access_ensure_project_level(config_get('manage_project_threshold'), $f_other_project_id);
if ($f_copy_from) {
$t_src_project_id = $f_other_project_id;
$t_dst_project_id = $f_project_id;
} else {
if ($f_copy_to) {
$t_src_project_id = $f_project_id;
$t_dst_project_id = $f_other_project_id;
} else {
trigger_error(ERROR_VERSION_NO_ACTION, ERROR);
}
}
$t_rows = version_get_all_rows($t_src_project_id);
foreach ($t_rows as $t_row) {
if (version_is_unique($t_row['version'], $t_dst_project_id)) {
$t_version_id = version_add($t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], $t_row['date_order']);
event_signal('EVENT_MANAGE_VERSION_CREATE', array($t_version_id));
}
}
form_security_purge('manage_proj_ver_copy');
print_header_redirect('manage_proj_edit_page.php?project_id=' . $f_project_id);
示例10: version_update
function version_update($p_version_info)
{
version_ensure_exists($p_version_info->id);
$t_old_version_name = version_get_field($p_version_info->id, 'version');
# check for duplicates
if (strtolower($t_old_version_name) != strtolower($p_version_info->version) && !version_is_unique($p_version_info->version, $p_version_info->project_id)) {
trigger_error(ERROR_VERSION_DUPLICATE, ERROR);
}
$c_version_id = db_prepare_int($p_version_info->id);
$c_version_name = db_prepare_string($p_version_info->version);
$c_old_version_name = db_prepare_string($t_old_version_name);
$c_description = db_prepare_string($p_version_info->description);
$c_released = db_prepare_int($p_version_info->released);
$c_date_order = db_prepare_string($p_version_info->date_order);
$c_project_id = db_prepare_int($p_version_info->project_id);
$t_project_version_table = config_get('mantis_project_version_table');
$t_bug_table = config_get('mantis_bug_table');
$query = "UPDATE {$t_project_version_table}\n\t\t\t\t SET version='{$c_version_name}',\n\t\t\t\t\tdescription='{$c_description}',\n\t\t\t\t\treleased='{$c_released}',\n\t\t\t\t\tdate_order='{$c_date_order}'\n\t\t\t\t WHERE id='{$c_version_id}'";
db_query($query);
if ($c_version_name != $c_old_version_name) {
$query = "UPDATE {$t_bug_table}\n\t\t\t\t\t SET version='{$c_version_name}'\n\t\t\t\t\t WHERE ( project_id='{$c_project_id}' ) AND ( version='{$c_old_version_name}' )";
db_query($query);
$query = "UPDATE {$t_bug_table}\n\t\t\t\t\t SET fixed_in_version='{$c_version_name}'\n\t\t\t\t\t WHERE ( project_id='{$c_project_id}' ) AND ( fixed_in_version='{$c_old_version_name}' )";
db_query($query);
}
# db_query() errors on failure so:
return true;
}