本文整理汇总了PHP中ExtraFieldValue::deleteValuesByItem方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraFieldValue::deleteValuesByItem方法的具体用法?PHP ExtraFieldValue::deleteValuesByItem怎么用?PHP ExtraFieldValue::deleteValuesByItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtraFieldValue
的用法示例。
在下文中一共展示了ExtraFieldValue::deleteValuesByItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WSDeleteSession
function WSDeleteSession($params)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$session_params = $params['sessions'];
$results = array();
$orig_session_id_value = array();
foreach ($session_params as $session_param) {
$original_session_id_value = $session_param['original_session_id_value'];
$original_session_id_name = $session_param['original_session_id_name'];
$orig_session_id_value[] = $original_session_id_name;
$idChecked = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
if (empty($idChecked)) {
$results[] = 0;
continue;
}
$session_ids[] = $idChecked;
$sql = "DELETE FROM {$tbl_session} WHERE id = '{$idChecked}'";
Database::query($sql);
$sql = "DELETE FROM {$tbl_session_rel_course} WHERE session_id = '{$idChecked}'";
Database::query($sql);
$sql = "DELETE FROM {$tbl_session_rel_course_rel_user} WHERE session_id = '{$idChecked}'";
Database::query($sql);
$sql = "DELETE FROM {$tbl_session_rel_user} WHERE session_id = '{$idChecked}'";
Database::query($sql);
$results[] = 1;
continue;
}
$extraFieldValue = new ExtraFieldValue('session');
//delete from table_session_field_value from a given session_id
foreach ($session_ids as $session_id) {
$extraFieldValue->deleteValuesByItem($session_id);
}
// Preparing output.
$count_results = count($results);
$output = array();
for ($i = 0; $i < $count_results; $i++) {
$output[] = array('original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
}
return $output;
}
示例2: delete_course
//.........这里部分代码省略.........
$res = Database::query($sql);
$course = Database::fetch_array($res);
$courseId = $course['id'];
$count = 0;
if (api_is_multiple_url_enabled()) {
$url_id = 1;
if (api_get_current_access_url_id() != -1) {
$url_id = api_get_current_access_url_id();
}
UrlManager::delete_url_rel_course($courseId, $url_id);
$count = UrlManager::getCountUrlRelCourse($courseId);
}
if ($count == 0) {
self::create_database_dump($code);
$course_tables = AddCourse::get_course_tables();
// Cleaning c_x tables
if (!empty($courseId)) {
foreach ($course_tables as $table) {
$table = Database::get_course_table($table);
$sql = "DELETE FROM {$table} WHERE c_id = {$courseId} ";
Database::query($sql);
}
}
$course_dir = api_get_path(SYS_COURSE_PATH) . $course['directory'];
$archive_dir = api_get_path(SYS_ARCHIVE_PATH) . $course['directory'] . '_' . time();
if (is_dir($course_dir)) {
rename($course_dir, $archive_dir);
}
// Unsubscribe all users from the course
$sql = "DELETE FROM {$table_course_user} WHERE c_id='" . $courseId . "'";
Database::query($sql);
// Delete the course from the sessions tables
$sql = "DELETE FROM {$table_session_course} WHERE c_id='" . $courseId . "'";
Database::query($sql);
$sql = "DELETE FROM {$table_session_course_user} WHERE c_id='" . $courseId . "'";
Database::query($sql);
// Delete from Course - URL
$sql = "DELETE FROM {$table_course_rel_url} WHERE c_id = '" . $courseId . "'";
Database::query($sql);
$sql = 'SELECT survey_id FROM ' . $table_course_survey . ' WHERE course_code="' . $codeFiltered . '"';
$result_surveys = Database::query($sql);
while ($surveys = Database::fetch_array($result_surveys)) {
$survey_id = $surveys[0];
$sql = 'DELETE FROM ' . $table_course_survey_question . ' WHERE survey_id="' . $survey_id . '"';
Database::query($sql);
$sql = 'DELETE FROM ' . $table_course_survey_question_option . ' WHERE survey_id="' . $survey_id . '"';
Database::query($sql);
$sql = 'DELETE FROM ' . $table_course_survey . ' WHERE survey_id="' . $survey_id . '"';
Database::query($sql);
}
// Cleaning group categories
$groupCategories = GroupManager::get_categories($course['code']);
if (!empty($groupCategories)) {
foreach ($groupCategories as $category) {
GroupManager::delete_category($category['id'], $course['code']);
}
}
// Cleaning groups
$groups = GroupManager::get_groups();
if (!empty($groups)) {
$groupList = array_column($groups, 'id');
GroupManager::delete_groups($groupList);
}
// Delete the course from the stats tables
$sql = "DELETE FROM {$table_stats_hotpots} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_attempt} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_exercises} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_access} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_lastaccess} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_course_access} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_online} WHERE c_id = {$courseId}";
Database::query($sql);
// Do not delete rows from track_e_default as these include course
// creation and other important things that do not take much space
// but give information on the course history
//$sql = "DELETE FROM $table_stats_default WHERE c_id = $courseId";
//Database::query($sql);
$sql = "DELETE FROM {$table_stats_downloads} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_links} WHERE c_id = {$courseId}";
Database::query($sql);
$sql = "DELETE FROM {$table_stats_uploads} WHERE c_id = {$courseId}";
Database::query($sql);
// Delete the course from the database
$sql = "DELETE FROM {$table_course} WHERE code = '" . $codeFiltered . "'";
Database::query($sql);
// delete extra course fields
$extraFieldValues = new ExtraFieldValue('course');
$extraFieldValues->deleteValuesByItem($courseId);
// Add event to system log
$user_id = api_get_user_id();
Event::addEvent(LOG_COURSE_DELETE, LOG_COURSE_CODE, $code, api_get_utc_datetime(), $user_id, $courseId);
}
}
示例3: delete_user
/**
* Delete a user from the platform, and all its belongings. This is a
* very dangerous function that should only be accessible by
* super-admins. Other roles should only be able to disable a user,
* which removes access to the platform but doesn't delete anything.
* @param int The ID of th user to be deleted
* @return boolean true if user is successfully deleted, false otherwise
* @assert (null) === false
* @assert ('abc') === false
*/
public static function delete_user($user_id)
{
if ($user_id != strval(intval($user_id))) {
return false;
}
if ($user_id === false) {
return false;
}
if (!self::can_delete_user($user_id)) {
return false;
}
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$usergroup_rel_user = Database::get_main_table(TABLE_USERGROUP_REL_USER);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_session = Database::get_main_table(TABLE_MAIN_SESSION);
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$table_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_group = Database::get_course_table(TABLE_GROUP_USER);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
// Unsubscribe the user from all groups in all his courses
$sql = "SELECT c.id FROM {$table_course} c, {$table_course_user} cu\n WHERE\n cu.user_id = '" . $user_id . "' AND\n relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND\n c.id = cu.c_id";
$res = Database::query($sql);
while ($course = Database::fetch_object($res)) {
$sql = "DELETE FROM {$table_group}\n WHERE c_id = {$course->id} AND user_id = {$user_id}";
Database::query($sql);
}
// Unsubscribe user from all classes
//Classes are not longer supported
/* $sql = "DELETE FROM $table_class_user WHERE user_id = '".$user_id."'";
Database::query($sql); */
// Unsubscribe user from usergroup_rel_user
$sql = "DELETE FROM {$usergroup_rel_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Unsubscribe user from all courses
$sql = "DELETE FROM {$table_course_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Unsubscribe user from all courses in sessions
$sql = "DELETE FROM {$table_session_course_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// If the user was added as a id_coach then set the current admin as coach see BT#
$currentUserId = api_get_user_id();
$sql = "UPDATE {$table_session} SET id_coach = {$currentUserId} WHERE id_coach = '" . $user_id . "'";
Database::query($sql);
$sql = "UPDATE {$table_session} SET id_coach = {$currentUserId} WHERE session_admin_id = '" . $user_id . "'";
Database::query($sql);
// Unsubscribe user from all sessions
$sql = "DELETE FROM {$table_session_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Delete user picture
/* TODO: Logic about api_get_setting('split_users_upload_directory') == 'true'
a user has 4 different sized photos to be deleted. */
$user_info = api_get_user_info($user_id);
if (strlen($user_info['picture_uri']) > 0) {
$path = self::getUserPathById($user_id, 'system');
$img_path = $path . $user_info['picture_uri'];
if (file_exists($img_path)) {
unlink($img_path);
}
}
// Delete the personal course categories
$course_cat_table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "DELETE FROM {$course_cat_table} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Delete user from database
$sql = "DELETE FROM {$table_user} WHERE id = '" . $user_id . "'";
Database::query($sql);
// Delete user from the admin table
$sql = "DELETE FROM {$table_admin} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Delete the personal agenda-items from this user
$agenda_table = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$sql = "DELETE FROM {$agenda_table} WHERE user = '" . $user_id . "'";
Database::query($sql);
$gradebook_results_table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'DELETE FROM ' . $gradebook_results_table . ' WHERE user_id = ' . $user_id;
Database::query($sql);
$extraFieldValue = new ExtraFieldValue('user');
$extraFieldValue->deleteValuesByItem($user_id);
if (api_get_multiple_access_url()) {
$url_id = api_get_current_access_url_id();
UrlManager::delete_url_rel_user($user_id, $url_id);
} else {
//we delete the user from the url_id =1
UrlManager::delete_url_rel_user($user_id, 1);
}
if (api_get_setting('allow_social_tool') == 'true') {
$userGroup = new UserGroup();
//Delete user from portal groups
//.........这里部分代码省略.........
示例4: delete
/**
* Delete session
* @author Carlos Vargas from existing code
* @param array id_checked an array to delete sessions
* @param boolean optional, true if the function is called by a webservice, false otherwise.
* @return void Nothing, or false on error
* */
public static function delete($id_checked, $from_ws = false)
{
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$userId = api_get_user_id();
if (is_array($id_checked)) {
foreach ($id_checked as $sessionId) {
self::delete($sessionId);
}
} else {
$id_checked = intval($id_checked);
}
if (SessionManager::allowed($id_checked) && !$from_ws) {
$sql = 'SELECT session_admin_id FROM ' . $tbl_session . '
WHERE id IN (' . $id_checked . ')';
$rs = Database::query($sql);
if (Database::result($rs, 0, 0) != $userId) {
api_not_allowed(true);
}
}
Database::query("DELETE FROM {$tbl_session_rel_course} WHERE session_id IN({$id_checked})");
Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE session_id IN({$id_checked})");
Database::query("DELETE FROM {$tbl_session_rel_user} WHERE session_id IN({$id_checked})");
Database::query("DELETE FROM {$tbl_url_session} WHERE session_id IN({$id_checked})");
Database::query("DELETE FROM {$tbl_session} WHERE id IN ({$id_checked})");
$extraFieldValue = new ExtraFieldValue('session');
$extraFieldValue->deleteValuesByItem($id_checked);
/** @var \Chamilo\CoreBundle\Entity\Repository\SequenceRepository $repo */
$repo = Database::getManager()->getRepository('ChamiloCoreBundle:SequenceResource');
$repo->deleteResource($id_checked, \Chamilo\CoreBundle\Entity\SequenceResource::SESSION_TYPE);
// Add event to system log
Event::addEvent(LOG_SESSION_DELETE, LOG_SESSION_ID, $id_checked, api_get_utc_datetime(), $userId);
}