本文整理汇总了PHP中category_add函数的典型用法代码示例。如果您正苦于以下问题:PHP category_add函数的具体用法?PHP category_add怎么用?PHP category_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了category_add函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mc_project_add_category
/**
* Add a new category to a project
* @param string $p_username The name of the user trying to access the categories.
* @param string $p_password The password of the user.
* @param integer $p_project_id The id of the project to retrieve the categories for.
* @param string $p_category_name The name of the new category to add
* @return integer id of the new category
*/
function mc_project_add_category($p_username, $p_password, $p_project_id, $p_category_name)
{
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return new soap_fault('Client', '', 'Access Denied');
}
if (!project_exists($p_project_id)) {
return new soap_fault('Client', '', "Project '{$p_project_id}' does not exist.");
}
if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $p_project_id)) {
return new soap_fault('Client', '', 'Access Denied');
}
return category_add($p_project_id, $p_category_name);
}
示例2: if
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_CATEGORY_NO_ACTION, ERROR );
}
$rows = category_get_all_rows( $t_src_project_id );
foreach ( $rows as $row ) {
$t_name = $row['name'];
if ( category_is_unique( $t_dst_project_id, $t_name ) ) {
category_add( $t_dst_project_id, $t_name );
}
}
form_security_purge( 'manage_proj_cat_copy' );
if ( $f_project_id == ALL_PROJECTS ) {
$t_redirect_url = 'manage_proj_page.php';
} else {
$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
}
print_header_redirect( $t_redirect_url );
示例3: config_get
# --------------------------------------------------------
# $Id: manage_proj_cat_copy.php,v 1.21 2005/02/27 15:33:01 jlatour Exp $
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'category_api.php';
$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');
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_CATEGORY_NO_ACTION, ERROR);
}
}
$rows = category_get_all_rows($t_src_project_id);
foreach ($rows as $row) {
$t_category = $row['category'];
if (category_is_unique($t_dst_project_id, $t_category)) {
category_add($t_dst_project_id, $t_category);
}
}
print_header_redirect('manage_proj_edit_page.php?project_id=' . $f_project_id);
示例4: gpc_get_int
$f_project_id = gpc_get_int('project_id');
$f_name = gpc_get_string('name');
access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id);
if (is_blank($f_name)) {
error_parameters(lang_get('category'));
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
$t_names = explode('|', $f_name);
$t_category_count = count($t_names);
foreach ($t_names as $t_name) {
if (is_blank($t_name)) {
continue;
}
$t_name = trim($t_name);
if (category_is_unique($f_project_id, $t_name)) {
category_add($f_project_id, $t_name);
} else {
if (1 == $t_category_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_CATEGORY_DUPLICATE, ERROR);
}
}
}
form_security_purge('manage_proj_cat_add');
if ($f_project_id == ALL_PROJECTS) {
$t_redirect_url = 'manage_proj_page.php';
} else {
$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
示例5: mc_project_add_category
/**
* Add a new category to a project
* @param string $p_username The name of the user trying to access the categories.
* @param string $p_password The password of the user.
* @param integer $p_project_id The id of the project to retrieve the categories for.
* @param string $p_category_name The name of the new category to add.
* @return integer id of the new category
*/
function mc_project_add_category($p_username, $p_password, $p_project_id, $p_category_name)
{
global $g_project_override;
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return mci_soap_fault_access_denied();
}
if (!project_exists($p_project_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $p_project_id . '\' does not exist.');
}
$g_project_override = $p_project_id;
if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $p_project_id)) {
return mci_soap_fault_access_denied();
}
return category_add($p_project_id, $p_category_name);
}
示例6: category_all
category_all(null);
} else {
// If page = 1 the value will be 0, if page = 2 the value will be 1, ...
$from = --$page * RESULTS_PER_PAGE;
category_all($from);
}
});
// Get Specific Item Category
$rest->get('/category/:id', function ($id) use($rest) {
include_once API_ROOT . "/category.inc";
category_get($id);
});
// Add Item Category
$rest->post('/category/', function () use($rest) {
include_once API_ROOT . "/category.inc";
category_add();
});
// Edit Item Category
$rest->put('/category/:id', function ($id) use($rest) {
include_once API_ROOT . "/category.inc";
category_edit($id);
});
// Delete Item Category
$rest->delete('/category/:id', function ($id) use($rest) {
include_once API_ROOT . "/category.inc";
category_delete($id);
});
// ------------------------------- Item Categories -------------------------------
// ------------------------------- Tax Types -------------------------------
// Tax Types
// Get All Item Tax Types
示例7: form_security_validate
require_once $t_core_path . 'category_api.php';
form_security_validate('manage_proj_cat_add');
auth_reauthenticate();
$f_project_id = gpc_get_int('project_id');
$f_category = gpc_get_string('category');
access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id);
if (is_blank($f_category)) {
trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
$t_categories = explode('|', $f_category);
$t_category_count = count($t_categories);
foreach ($t_categories as $t_category) {
if (is_blank($t_category)) {
continue;
}
$t_category = trim($t_category);
if (category_is_unique($f_project_id, $t_category)) {
category_add($f_project_id, $t_category);
} else {
if (1 == $t_category_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_CATEGORY_DUPLICATE, ERROR);
}
}
}
form_security_purge('manage_proj_cat_add');
$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
print_header_redirect($t_redirect_url);
示例8: get_category_id
function get_category_id($p_project_id)
{
$t_cat_name = 'acra report';
$t_cat_id = category_get_id_by_name($t_cat_name, $p_project_id, false);
if ($t_cat_id === false) {
category_add($p_project_id, $t_cat_name);
$t_cat_id = category_get_id_by_name($t_cat_name, $p_project_id);
}
return $t_cat_id;
}