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


PHP SessionManager::create_session_extra_field方法代码示例

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


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

示例1: WSCreateSession

function WSCreateSession($params)
{
    global $_user;
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $sessions_params = $params['sessions'];
    $results = array();
    $orig_session_id_value = array();
    foreach ($sessions_params as $session_param) {
        $name = trim($session_param['name']);
        $year_start = intval($session_param['year_start']);
        $month_start = intval($session_param['month_start']);
        $day_start = intval($session_param['day_start']);
        $year_end = intval($session_param['year_end']);
        $month_end = intval($session_param['month_end']);
        $day_end = intval($session_param['day_end']);
        $nb_days_access_before = intval($session_param['nb_days_access_before']);
        $nb_days_access_after = intval($session_param['nb_days_access_after']);
        $id_coach = $session_param['user_id'];
        $nolimit = $session_param['nolimit'];
        $original_session_id_name = $session_param['original_session_id_name'];
        $original_session_id_value = $session_param['original_session_id_value'];
        $orig_session_id_value[] = $session_param['original_session_id_value'];
        $extra_list = $session_param['extra'];
        $sessionId = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
        if (empty($sessionId)) {
            $results[] = 0;
            continue;
        }
        if (empty($nolimit)) {
            $date_start = "{$year_start}-" . ($month_start < 10 ? "0{$month_start}" : $month_start) . "-" . ($day_start < 10 ? "0{$day_start}" : $day_start) . ' 00:00:00';
            $date_end = "{$year_end}-" . ($month_end < 10 ? "0{$month_end}" : $month_end) . "-" . ($day_end < 10 ? "0{$day_end}" : $day_end) . ' 23:59:59';
        } else {
            $date_start = "";
            $date_end = "";
        }
        if (empty($name)) {
            $results[] = 0;
            continue;
        } elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
            $results[] = 0;
            continue;
        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
            $results[] = 0;
            continue;
        } elseif (empty($nolimit) && $date_start >= $date_end) {
            $results[] = 0;
            continue;
        } else {
            $rs = Database::query("SELECT 1 FROM {$tbl_session} WHERE name='" . addslashes($name) . "'");
            if (Database::num_rows($rs)) {
                $results[] = 0;
                continue;
            } else {
                $startDate = new DateTime($date_start);
                $endDate = new DateTime($date_end);
                $diffStart = new DateInterval($nb_days_access_before);
                $diffEnd = new DateInterval($nb_days_access_after);
                $coachStartDate = $startDate->sub($diffStart);
                $coachEndDate = $endDate->add($diffEnd);
                $id_session = SessionManager::create_session($name, $date_start, $date_end, $date_start, $date_end, $coachStartDate->format('Y-m-d H:i:s'), $coachEndDate->format('Y-m-d H:i:s'), $id_coach, 0, 0, false, null, null, 0, array(), $_user['user_id']);
                // Save new fieldlabel into course_field table.
                $field_id = SessionManager::create_session_extra_field($original_session_id_name, 1, $original_session_id_name);
                // Save the external system's id into user_field_value table.
                $res = SessionManager::update_session_extra_field_value($id_session, $original_session_id_name, $original_session_id_value);
                if (is_array($extra_list) && count($extra_list) > 0) {
                    foreach ($extra_list as $extra) {
                        $extra_field_name = $extra['field_name'];
                        $extra_field_value = $extra['field_value'];
                        // Save new fieldlabel into course_field table.
                        $field_id = SessionManager::create_session_extra_field($extra_field_name, 1, $extra_field_name);
                        // Save the external system's id into course_field_value table.
                        $res = SessionManager::update_session_extra_field_value($id_session, $extra_field_name, $extra_field_value);
                    }
                }
                $results[] = $id_session;
                continue;
            }
        }
    }
    // end principal foreach
    $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;
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:91,代码来源:registration.soap.php

示例2: editSessionHelper

 /**
  * Edits a session (helper method)
  *
  * @param string Name of the session
  * @param string Start date, use the 'YYYY-MM-DD' format
  * @param string End date, use the 'YYYY-MM-DD' format
  * @param int Access delays of the coach (days before)
  * @param int Access delays of the coach (days after)
  * @param int Nolimit (0 = no limit of time, 1 = limit of time)
  * @param int Visibility
  * @param string User id field name for the coach
  * @param string User id value for the coach
  * @param string Original session id field name (use "chamilo_session_id" to use internal id)
  * @param string Original session id value
  * @param array Array of extra fields
  * @return mixed True on success, WSError otherwise
  */
 protected function editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras)
 {
     $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
     if ($session_id instanceof WSError) {
         return $session_id;
     } else {
         // Verify that coach exists and get its id
         $user_id = $this->getUserId($user_id_field_name, $user_id_value);
         if ($user_id instanceof WSError) {
             return $user_id;
         }
         $coachStartDate = null;
         if (!empty($nb_days_access_before)) {
             $day = intval($nb_days_access_before);
             $coachStartDate = date('Y-m-d ', strtotime($start_date . ' + ' . $day . ' days'));
         }
         $coachEndDate = null;
         if (!empty($nb_days_access_after)) {
             $day = intval($nb_days_access_after);
             $coachEndDate = date('Y-m-d ', strtotime($end_date . ' + ' . $day . ' days'));
         }
         $result_id = SessionManager::edit_session($session_id, $name, $start_date, $end_date, $start_date, $end_date, $coachStartDate, $coachEndDate, $user_id, 0, (int) $visibility);
         if (!is_int($result_id)) {
             return new WSError(302, 'Could not edit the session');
         } else {
             if (!empty($extras)) {
                 $extras_associative = array();
                 foreach ($extras as $extra) {
                     $extras_associative[$extra['field_name']] = $extra['field_value'];
                 }
                 // Create the extra fields
                 foreach ($extras_associative as $fname => $fvalue) {
                     SessionManager::create_session_extra_field($fname, 1, $fname);
                     SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
                 }
             }
             return true;
         }
     }
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:57,代码来源:webservice_session.php

示例3: prepareImport

 /**
  * Prepares extra fields before the import
  */
 private function prepareImport()
 {
     // Create user extra field: extra_external_user_id
     UserManager::create_extra_field($this->extraFieldIdNameList['user'], 1, 'External user id', null);
     // Create course extra field: extra_external_course_id
     CourseManager::create_course_extra_field($this->extraFieldIdNameList['course'], 1, 'External course id');
     // Create session extra field extra_external_session_id
     SessionManager::create_session_extra_field($this->extraFieldIdNameList['session'], 1, 'External session id');
     // Create calendar_event extra field extra_external_session_id
     $extraField = new ExtraField('calendar_event');
     $extraField->save(array('field_type' => ExtraField::FIELD_TYPE_TEXT, 'field_variable' => $this->extraFieldIdNameList['calendar_event'], 'field_display_text' => 'External calendar event id'));
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:15,代码来源:import_csv.php

示例4: prepareImport

 /**
  * Prepares extra fields before the import
  */
 private function prepareImport()
 {
     // Create user extra field: extra_external_user_id
     UserManager::create_extra_field($this->extraFieldIdNameList['user'], 1, 'External user id', null);
     // Create course extra field: extra_external_course_id
     CourseManager::create_course_extra_field($this->extraFieldIdNameList['course'], 1, 'External course id');
     // Create session extra field extra_external_session_id
     SessionManager::create_session_extra_field($this->extraFieldIdNameList['session'], 1, 'External session id');
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:12,代码来源:import_csv.php

示例5: WSCreateSession

function WSCreateSession($params)
{
    global $_user;
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
    $t_sfv = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
    $sessions_params = $params['sessions'];
    $results = array();
    $orig_session_id_value = array();
    foreach ($sessions_params as $session_param) {
        $name = trim($session_param['name']);
        $access_start_date = $session_param['access_start_date'];
        $access_end_date = $session_param['access_end_date'];
        /*
                $year_start = intval($session_param['year_start']);
                $month_start = intval($session_param['month_start']);
                $day_start = intval($session_param['day_start']);
                $year_end = intval($session_param['year_end']);
                $month_end = intval($session_param['month_end']);
                $day_end = intval($session_param['day_end']);*/
        //$nb_days_acess_before = intval($session_param['nb_days_access_before']);
        //$nb_days_acess_after = intval($session_param['nb_days_access_after']);
        $id_coach = $session_param['user_id'];
        $nolimit = $session_param['nolimit'];
        $original_session_id_name = $session_param['original_session_id_name'];
        $original_session_id_value = $session_param['original_session_id_value'];
        $orig_session_id_value[] = $session_param['original_session_id_value'];
        $extra_list = $session_param['extra'];
        // Check if exits remote system's session id into session_field_values table.
        $sql = "SELECT field_value\tFROM {$t_sf} sf,{$t_sfv} sfv WHERE sfv.field_id=sf.id AND field_variable='{$original_session_id_name}' AND field_value='{$original_session_id_value}'";
        $res = Database::query($sql);
        $row = Database::fetch_row($res);
        if (Database::num_rows($res) > 0) {
            $results[] = 0;
            continue;
        }
        if (empty($name)) {
            $results[] = 0;
            continue;
            /*} elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
                  $results[] = 0;
                  continue;
              } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,$day_end,$year_end))) {
                  $results[] = 0;
                  continue;
              } elseif (empty($nolimit) && $date_start >= $date_end) {
                  $results[] = 0;
                  continue;*/
        } else {
            $rs = Database::query("SELECT 1 FROM {$tbl_session} WHERE name='" . Datanbase::escape_string($name) . "'");
            if (Database::num_rows($rs)) {
                $results[] = 0;
                continue;
            } else {
                $params = array('name' => $name, 'id_coach' => $id_coach, 'session_admin_id' => $_user['user_id'], 'access_start_date' => $access_start_date, 'access_end_date' => $access_end_date);
                $id_session = SessionManager::add($params);
                //Database::query("INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, VALUES('".addslashes($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.")");
                //$id_session = Database::insert_id();
                // Save new fieldlabel into course_field table.
                $field_id = SessionManager::create_session_extra_field($original_session_id_name, 1, $original_session_id_name);
                // Save the external system's id into user_field_value table.
                $res = SessionManager::update_session_extra_field_value($id_session, $original_session_id_name, $original_session_id_value);
                if (is_array($extra_list) && count($extra_list) > 0) {
                    foreach ($extra_list as $extra) {
                        $extra_field_name = $extra['field_name'];
                        $extra_field_value = $extra['field_value'];
                        // Save new fieldlabel into course_field table.
                        $field_id = SessionManager::create_session_extra_field($extra_field_name, 1, $extra_field_name);
                        // Save the external system's id into course_field_value table.
                        $res = SessionManager::update_session_extra_field_value($id_session, $extra_field_name, $extra_field_value);
                    }
                }
                $results[] = $id_session;
                continue;
            }
        }
    }
    // end principal foreach
    $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;
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:89,代码来源:registration.soap.php

示例6: editSessionHelper

 /**
  * Edits a session (helper method)
  *
  * @param string Name of the session
  * @param string Start date, use the 'YYYY-MM-DD' format
  * @param string End date, use the 'YYYY-MM-DD' format
  * @param int Access delays of the coach (days before)
  * @param int Access delays of the coach (days after)
  * @param int Nolimit (0 = no limit of time, 1 = limit of time)
  * @param int Visibility
  * @param string User id field name for the coach
  * @param string User id value for the coach
  * @param string Original session id field name (use "chamilo_session_id" to use internal id)
  * @param string Original session id value
  * @param array Array of extra fields
  * @return mixed True on success, WSError otherwise
  */
 protected function editSessionHelper($name, $start_date, $end_date, $coach_access_start_date, $coach_access_end_date, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras)
 {
     $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
     if ($session_id instanceof WSError) {
         return $session_id;
     } else {
         // Verify that coach exists and get its id
         $user_id = $this->getUserId($user_id_field_name, $user_id_value);
         if ($user_id instanceof WSError) {
             return $user_id;
         }
         $params = array('id' => $session_id, 'name' => $name, 'access_start_date' => $start_date, 'access_end_date' => $end_date, 'coach_access_start_date' => $coach_access_start_date, 'coach_access_end_date' => $coach_access_end_date, 'visibility' => $visibility);
         $result_id = SessionManager::update($params);
         if (!is_int($result_id)) {
             return new WSError(302, 'Could not edit the session');
         } else {
             if (!empty($extras)) {
                 $extras_associative = array();
                 foreach ($extras as $extra) {
                     $extras_associative[$extra['field_name']] = $extra['field_value'];
                 }
                 // Create the extra fields
                 foreach ($extras_associative as $fname => $fvalue) {
                     SessionManager::create_session_extra_field($fname, 1, $fname);
                     SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
                 }
             }
             return true;
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:48,代码来源:webservice_session.php

示例7: WSCreateSession

function WSCreateSession($params)
{
    global $debug;
    $sessionAdminId = 1;
    if (!WSHelperVerifyKey($params)) {
        return returnError(WS_ERROR_SECRET_KEY);
    }
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    error_log(print_r($params, 1));
    $sessions_params = $params['sessions'];
    $results = array();
    $orig_session_id_value = array();
    foreach ($sessions_params as $session_param) {
        $name = trim($session_param['name']);
        $year_start = intval($session_param['year_start']);
        $month_start = intval($session_param['month_start']);
        $day_start = intval($session_param['day_start']);
        $year_end = intval($session_param['year_end']);
        $month_end = intval($session_param['month_end']);
        $day_end = intval($session_param['day_end']);
        $nb_days_access_before = intval($session_param['nb_days_access_before']);
        $nb_days_access_after = intval($session_param['nb_days_access_after']);
        $id_coach = $session_param['user_id'];
        $nolimit = $session_param['nolimit'];
        $original_session_id_name = $session_param['original_session_id_name'];
        $original_session_id_value = $session_param['original_session_id_value'];
        $orig_session_id_value[] = $session_param['original_session_id_value'];
        $extra_list = isset($session_param['extra']) ? $session_param['extra'] : '';
        $sessionId = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
        if (!empty($sessionId)) {
            if ($debug) {
                error_log("session with external session id '{$original_session_id_value}' with '{$name}' exists");
            }
            $results[] = 0;
            continue;
        }
        if (empty($nolimit)) {
            $date_start = "{$year_start}-" . ($month_start < 10 ? "0{$month_start}" : $month_start) . "-" . ($day_start < 10 ? "0{$day_start}" : $day_start) . ' 00:00:00';
            $date_end = "{$year_end}-" . ($month_end < 10 ? "0{$month_end}" : $month_end) . "-" . ($day_end < 10 ? "0{$day_end}" : $day_end) . ' 23:59:59';
        } else {
            $date_start = "";
            $date_end = "";
        }
        if (empty($name)) {
            if ($debug) {
                error_log("session has no name");
            }
            $results[] = 0;
            continue;
        } elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
            if ($debug) {
                error_log("There's an error with the start date: {$month_start} - {$day_start} - {$year_start}");
            }
            $results[] = 0;
            continue;
        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
            $results[] = 0;
            if ($debug) {
                error_log("There's an error with the end date: {$month_end} - {$day_end} - {$year_end}");
            }
            continue;
        } elseif (empty($nolimit) && $date_start >= $date_end) {
            $results[] = 0;
            if ($debug) {
                error_log("There's an error with the start and end date");
            }
            continue;
        } else {
            $rs = Database::query("SELECT 1 FROM {$tbl_session} WHERE name='" . addslashes($name) . "'");
            if (Database::num_rows($rs)) {
                if ($debug) {
                    error_log("Session with name '{$name}' already exists");
                }
                $results[] = 0;
                continue;
            } else {
                $coachStartDate = '';
                if ($date_start) {
                    $startDate = new DateTime($date_start);
                    $diffStart = new DateInterval("P" . $nb_days_access_before . "D");
                    $coachStartDate = $startDate->sub($diffStart);
                    $coachStartDate = $coachStartDate->format('Y-m-d H:i:s');
                }
                $coachEndDate = '';
                if ($date_end) {
                    $endDate = new DateTime($date_end);
                    $diffEnd = new DateInterval("P" . $nb_days_access_after . "D");
                    $coachEndDate = $endDate->add($diffEnd);
                    $coachEndDate = $coachEndDate->format('Y-m-d H:i:s');
                }
                $id_session = SessionManager::create_session($name, $date_start, $date_end, $date_start, $date_end, $coachStartDate, $coachEndDate, $id_coach, 0, 1, false, null, null, 0, array(), $sessionAdminId);
                if ($id_session) {
                    if ($debug) {
                        error_log("Session created '{$id_session}' ");
                    }
                    // Save new fieldlabel into course_field table.
                    SessionManager::create_session_extra_field($original_session_id_name, 1, $original_session_id_name);
                    // Save the external system's id into user_field_value table.
                    SessionManager::update_session_extra_field_value($id_session, $original_session_id_name, $original_session_id_value);
                    if (is_array($extra_list) && count($extra_list) > 0) {
//.........这里部分代码省略.........
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:101,代码来源:registration.soap.php

示例8: editSessionHelper

	/**
	 * Edits a session (helper method)
	 *
	 * @param string Name of the session
	 * @param string Start date, use the 'YYYY-MM-DD' format
	 * @param string End date, use the 'YYYY-MM-DD' format
	 * @param int Access delays of the coach (days before)
	 * @param int Access delays of the coach (days after)
	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
	 * @param int Visibility
	 * @param string User id field name for the coach
	 * @param string User id value for the coach
	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
	 * @param string Original session id value
	 * @param array Array of extra fields
	 * @return mixed True on success, WSError otherwise
	 */
	protected function editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
		if($session_id instanceof WSError) {
			return $session_id;
		} else {
			// Verify that coach exists and get its id
			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
			if($user_id instanceof WSError) {
				return $user_id;
			}
			// Build the date
			$start_date_array = explode('-', $start_date);
			foreach($start_date_array as &$sd_element) {
				$sd_element = intval($sd_element);
			}
			$end_date_array = explode('-', $end_date);
			foreach($end_date_array as &$ed_element) {
				$ed_element = intval($ed_element);
			}
			$result_id = SessionManager::edit_session($session_id, $name, $start_date_array[0], $start_date_array[1], $start_date_array[2], $end_date_array[0], $end_date_array[1], $end_date_array[2], (int)$nb_days_access_before, (int)$nb_days_access_after, (int)$nolimit, $user_id, 0, (int)$visibility);
			if(!is_int($result_id)) {
				return new WSError(302, 'Could not edit the session');
			} else {
				if(!empty($extras)) {
					$extras_associative = array();
					foreach($extras as $extra) {
						$extras_associative[$extra['field_name']] = $extra['field_value'];
					}
					// Create the extra fields
					foreach($extras_associative as $fname => $fvalue) {
						SessionManager::create_session_extra_field($fname, 1, $fname);
						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
					}
				}
				return true;
			}
		}
	}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:55,代码来源:webservice_session.php


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