|
@@ -1,29 +1,28 @@
|
|
|
<?php
|
|
|
|
|
|
+
|
|
|
|
|
|
- * Legal class
|
|
|
- *
|
|
|
- * @version 1.0
|
|
|
- * @package chamilo.legal
|
|
|
+ * Class LegalManager
|
|
|
*
|
|
|
-*/
|
|
|
-
|
|
|
- * Class
|
|
|
* @package chamilo.legal
|
|
|
*/
|
|
|
-class LegalManager {
|
|
|
- private function __construct () {
|
|
|
-
|
|
|
+class LegalManager
|
|
|
+{
|
|
|
+ private function __construct ()
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
|
|
|
* Add a new Term and Condition
|
|
|
- * @param int language id
|
|
|
- * @param string the content
|
|
|
- * @param int term and condition type (0 or 1)
|
|
|
- * @param string explain changes
|
|
|
- * @return boolean sucess
|
|
|
+ * @param int $language language id
|
|
|
+ * @param string $content content
|
|
|
+ * @param int $type term and condition type (0 or 1)
|
|
|
+ * @param string $changes explain changes
|
|
|
+ * @return boolean success
|
|
|
*/
|
|
|
- public static function add ($language, $content, $type, $changes) {
|
|
|
+ public static function add($language, $content, $type, $changes)
|
|
|
+ {
|
|
|
$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$last = self::get_last_condition($language);
|
|
|
$language = Database::escape_string($language);
|
|
@@ -59,7 +58,8 @@ class LegalManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static function delete ($id) {
|
|
|
+ public static function delete($id)
|
|
|
+ {
|
|
|
|
|
|
$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$id = intval($id);
|
|
@@ -69,41 +69,52 @@ class LegalManager {
|
|
|
|
|
|
|
|
|
* Gets the last version of a Term and condition by language
|
|
|
- * @param int the language id
|
|
|
+ * @param int $language language id
|
|
|
* @return array all the info of a Term and condition
|
|
|
*/
|
|
|
|
|
|
- public static function get_last_condition_version ($language) {
|
|
|
+ public static function get_last_condition_version ($language)
|
|
|
+ {
|
|
|
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$language= Database::escape_string($language);
|
|
|
- $sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY legal_id DESC LIMIT 1 ";
|
|
|
+ $sql = "SELECT version FROM $legal_conditions_table
|
|
|
+ WHERE language_id = '".$language."'
|
|
|
+ ORDER BY legal_id DESC LIMIT 1 ";
|
|
|
$result = Database::query($sql);
|
|
|
$row = Database::fetch_array($result);
|
|
|
- if (Database::num_rows($result)>0) {
|
|
|
+ if (Database::num_rows($result) > 0) {
|
|
|
+
|
|
|
return $row['version'];
|
|
|
} else {
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
* Gets the data of a Term and condition by language
|
|
|
- * @param int the language id
|
|
|
+ * @param int $language language id
|
|
|
* @return array all the info of a Term and condition
|
|
|
*/
|
|
|
- public static function get_last_condition ($language) {
|
|
|
+ public static function get_last_condition ($language)
|
|
|
+ {
|
|
|
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$language= Database::escape_string($language);
|
|
|
- $sql = "SELECT * FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 ";
|
|
|
+ $sql = "SELECT * FROM $legal_conditions_table
|
|
|
+ WHERE language_id = '".$language."'
|
|
|
+ ORDER BY version DESC LIMIT 1 ";
|
|
|
$result = Database::query($sql);
|
|
|
+
|
|
|
return Database::fetch_array($result);
|
|
|
}
|
|
|
|
|
|
|
|
|
* Gets the last version of a Term and condition by language
|
|
|
- * @param int the language id
|
|
|
+ * @param int $language language id
|
|
|
* @return boolean | int the version or false if does not exist
|
|
|
*/
|
|
|
- public static function get_last_version ($language) {
|
|
|
+ public static function get_last_version ($language)
|
|
|
+ {
|
|
|
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$language= Database::escape_string($language);
|
|
|
$sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 ";
|
|
@@ -122,7 +133,8 @@ class LegalManager {
|
|
|
* @param array with type and content i.e array('type'=>'1', 'content'=>'hola');
|
|
|
* @return string html preview
|
|
|
*/
|
|
|
- public static function show_last_condition($term_preview) {
|
|
|
+ public static function show_last_condition($term_preview)
|
|
|
+ {
|
|
|
$preview = '';
|
|
|
switch ($term_preview['type']) {
|
|
|
|
|
@@ -175,7 +187,6 @@ class LegalManager {
|
|
|
return $preview;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
* Get the terms and condition table (only for maintenance)
|
|
|
* @param int offset
|
|
@@ -183,7 +194,8 @@ class LegalManager {
|
|
|
* @param int column
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function get_legal_data ($from, $number_of_items, $column) {
|
|
|
+ public static function get_legal_data($from, $number_of_items, $column)
|
|
|
+ {
|
|
|
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
|
|
|
$from = intval($from);
|
|
@@ -218,12 +230,14 @@ class LegalManager {
|
|
|
* Gets the number of terms and conditions available
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function count() {
|
|
|
+ public static function count()
|
|
|
+ {
|
|
|
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$sql = "SELECT count(*) as count_result FROM $legal_conditions_table ORDER BY legal_id DESC ";
|
|
|
$result = Database::query($sql);
|
|
|
$url = Database::fetch_array($result,'ASSOC');
|
|
|
$result = $url['count_result'];
|
|
|
+
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
@@ -233,12 +247,14 @@ class LegalManager {
|
|
|
* @param int The language id
|
|
|
* @return int The current type of terms and conditions
|
|
|
*/
|
|
|
- public static function get_type_of_terms_and_conditions ($legal_id,$language_id) {
|
|
|
+ public static function get_type_of_terms_and_conditions ($legal_id,$language_id)
|
|
|
+ {
|
|
|
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
|
|
|
$legal_id=Database::escape_string($legal_id);
|
|
|
$language_id=Database::escape_string($language_id);
|
|
|
- $sql='SELECT type FROM '.$legal_conditions_table.' WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
|
|
|
- $rs=Database::query($sql);
|
|
|
+ $sql = 'SELECT type FROM '.$legal_conditions_table.' WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
|
|
|
+ $rs = Database::query($sql);
|
|
|
+
|
|
|
return Database::result($rs,0,'type');
|
|
|
}
|
|
|
}
|