Bläddra i källkod

Minor - remove unused code

Julio Montoya 5 år sedan
förälder
incheckning
106f8eb6cb

+ 0 - 62
main/exercise/fill_blanks.class.php

@@ -1051,45 +1051,6 @@ class FillBlanks extends Question
         }
     }
 
-    /**
-     * return $text protected for use in regexp.
-     *
-     * @param string $text
-     *
-     * @return string
-     */
-    public static function getRegexpProtected($text)
-    {
-        $listRegexpCharacters = [
-            "/",
-            ".",
-            "+",
-            "*",
-            "?",
-            "[",
-            "^",
-            "]",
-            "$",
-            "(",
-            ")",
-            "{",
-            "}",
-            "=",
-            "!",
-            ">",
-            "|",
-            ":",
-            "-",
-            ")",
-        ];
-        $result = $text;
-        for ($i = 0; $i < count($listRegexpCharacters); $i++) {
-            $result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result);
-        }
-
-        return $result;
-    }
-
     /**
      * This function must be the same than the js one getSeparatorFromNumber above.
      *
@@ -1153,29 +1114,6 @@ class FillBlanks extends Question
         return $listResults;
     }
 
-    /**
-     * return the code number of the separator for the question.
-     *
-     * @param string $startSeparator
-     * @param string $endSeparator
-     *
-     * @return int
-     */
-    public function getDefaultSeparatorNumber($startSeparator, $endSeparator)
-    {
-        $listSeparators = self::getAllowedSeparator();
-        $result = 0;
-        for ($i = 0; $i < count($listSeparators); $i++) {
-            if ($listSeparators[$i][0] == $startSeparator &&
-                $listSeparators[$i][1] == $endSeparator
-            ) {
-                $result = $i;
-            }
-        }
-
-        return $result;
-    }
-
     /**
      * return the HTML display of the answer.
      *

+ 0 - 24
main/gradebook/lib/GradebookUtils.php

@@ -560,30 +560,6 @@ class GradebookUtils
         return $row;
     }
 
-    /**
-     * Remove a resource from the unique gradebook of a given course.
-     *
-     * @param    int     Link/Resource ID
-     *
-     * @return bool false on error, true on success
-     */
-    public static function get_resource_from_course_gradebook($link_id)
-    {
-        if (empty($link_id)) {
-            return false;
-        }
-        // TODO find the corresponding category (the first one for this course, ordered by ID)
-        $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
-        $sql = "SELECT * FROM $l WHERE id = ".(int) $link_id;
-        $res = Database::query($sql);
-        $row = [];
-        if (Database::num_rows($res) > 0) {
-            $row = Database::fetch_array($res, 'ASSOC');
-        }
-
-        return $row;
-    }
-
     /**
      * Return the course id.
      *

+ 0 - 35
main/inc/lib/extra_field_value.lib.php

@@ -1030,27 +1030,6 @@ class ExtraFieldValue extends Model
         Database::query($sql);
     }
 
-    /**
-     * Deletes values of a specific field for a specific item.
-     *
-     * @param int $item_id  (session id, course id, etc)
-     * @param int $field_id
-     * @assert (-1,-1) == null
-     */
-    public function delete_values_by_handler_and_field_id($item_id, $field_id)
-    {
-        $field_id = (int) $field_id;
-        $item_id = (int) $item_id;
-        $extraFieldType = $this->getExtraField()->getExtraFieldType();
-
-        $sql = "DELETE FROM {$this->table}
-                WHERE
-                    item_id = '$item_id' AND
-                    field_id = '$field_id'
-                ";
-        Database::query($sql);
-    }
-
     /**
      * Deletes all values from an item.
      *
@@ -1108,20 +1087,6 @@ class ExtraFieldValue extends Model
         return false;
     }
 
-    /**
-     * Not yet implemented - Compares the field values of two items.
-     *
-     * @param int $item_id         Item 1
-     * @param int $item_to_compare Item 2
-     *
-     * @todo
-     *
-     * @return mixed Differential array generated from the comparison
-     */
-    public function compareItemValues($item_id, $item_to_compare)
-    {
-    }
-
     /**
      * Get all values for an item.
      *

+ 0 - 4
main/inc/lib/groupmanager.lib.php

@@ -15,10 +15,6 @@ use Chamilo\CourseBundle\Entity\CGroupRelUser;
  */
 class GroupManager
 {
-    /* VIRTUAL_COURSE_CATEGORY:
-    in this category groups are created based on the virtual course of a course*/
-    const VIRTUAL_COURSE_CATEGORY = 1;
-
     /* DEFAULT_GROUP_CATEGORY:
     When group categories aren't available (platform-setting),
     all groups are created in this 'dummy'-category*/

+ 0 - 27
main/inc/lib/sessionmanager.lib.php

@@ -3287,33 +3287,6 @@ class SessionManager
         }
     }
 
-    /**
-     * Get the session image.
-     *
-     * @param int $id
-     *
-     * @return image path
-     */
-    public static function getSessionImage($id)
-    {
-        $id = (int) $id;
-        $extraFieldValuesTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
-        $sql = "SELECT value  FROM $extraFieldValuesTable WHERE field_id = 16 AND item_id = ".$id;
-        $result = Database::query($sql);
-        if (Database::num_rows($result) > 0) {
-            while ($row = Database::fetch_array($result, 'ASSOC')) {
-                $sessionImage = $row['value'];
-                $sessionImage = api_get_path(WEB_UPLOAD_PATH).$sessionImage;
-            }
-
-            return $sessionImage;
-        } else {
-            $sessionImage = api_get_path(WEB_IMG_PATH)."session_default.png";
-
-            return $sessionImage;
-        }
-    }
-
     /**
      * Get Hot Sessions (limit 8).
      *

+ 2 - 5
main/inc/lib/usergroup.lib.php

@@ -1364,7 +1364,8 @@ class UserGroup extends Model
      * @param string $source_file the full system name of the image from which user photos will be created
      *
      * @return mixed Returns the resulting common file name of created images which usually should be stored in database.
-     *               When an image is removed the function returns an empty string. In case of internal error or negative validation it returns FALSE.
+     *               When an image is removed the function returns an empty string.
+     *               In case of internal error or negative validation it returns FALSE.
      */
     public function update_group_picture($group_id, $file = null, $source_file = null)
     {
@@ -1513,10 +1514,6 @@ class UserGroup extends Model
                 WHERE usergroup_id = $id";
         Database::query($sql);
 
-        /*$sql = "DELETE FROM $this->usergroup_rel_
-                WHERE usergroup_id = $id";
-        Database::query($sql);*/
-
         parent::delete($id);
     }
 

+ 0 - 213
main/inc/lib/usermanager.lib.php

@@ -2512,62 +2512,6 @@ class UserManager
         return $fields;
     }
 
-    /**
-     * Build a list of extra file already uploaded in $user_folder/{$extra_field}/.
-     *
-     * @param $user_id
-     * @param $extra_field
-     * @param bool $force
-     * @param bool $showDelete
-     *
-     * @return bool|string
-     */
-    public static function build_user_extra_file_list(
-        $user_id,
-        $extra_field,
-        $force = false,
-        $showDelete = false
-    ) {
-        if (!$force && !empty($_POST['remove_'.$extra_field])) {
-            return true; // postpone reading from the filesystem
-        }
-
-        $extra_files = self::get_user_extra_files($user_id, $extra_field);
-        if (empty($extra_files)) {
-            return false;
-        }
-
-        $path_info = self::get_user_picture_path_by_id($user_id, 'web');
-        $path = $path_info['dir'];
-        $del_image = Display::returnIconPath('delete.png');
-
-        $del_text = get_lang('Delete');
-        $extra_file_list = '';
-        if (count($extra_files) > 0) {
-            $extra_file_list = '<div class="files-production"><ul id="productions">';
-            foreach ($extra_files as $file) {
-                $filename = substr($file, strlen($extra_field) + 1);
-                $extra_file_list .= '<li>'.Display::return_icon('archive.png').
-                    '<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">
-                        '.htmlentities($filename).
-                    '</a> ';
-                if ($showDelete) {
-                    $extra_file_list .= '<input 
-                        style="width:16px;" 
-                        type="image" 
-                        name="remove_extra_'.$extra_field.'['.urlencode($file).']" 
-                        src="'.$del_image.'" 
-                        alt="'.$del_text.'"
-                        title="'.$del_text.' '.htmlentities($filename).'" 
-                        onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
-                }
-            }
-            $extra_file_list .= '</ul></div>';
-        }
-
-        return $extra_file_list;
-    }
-
     /**
      * Get valid filenames in $user_folder/{$extra_field}/.
      *
@@ -2610,33 +2554,6 @@ class UserManager
         return $files; // can be an empty array
     }
 
-    /**
-     * Remove an {$extra_file} from the user folder $user_folder/{$extra_field}/.
-     *
-     * @param int    $user_id
-     * @param string $extra_field
-     * @param string $extra_file
-     *
-     * @return bool
-     */
-    public static function remove_user_extra_file($user_id, $extra_field, $extra_file)
-    {
-        $extra_file = Security::filter_filename($extra_file);
-        $path_info = self::get_user_picture_path_by_id($user_id, 'system');
-        if (strpos($extra_file, $extra_field) !== false) {
-            $path_extra_file = $path_info['dir'].$extra_file;
-        } else {
-            $path_extra_file = $path_info['dir'].$extra_field.'/'.$extra_file;
-        }
-        if (is_file($path_extra_file)) {
-            unlink($path_extra_file);
-
-            return true;
-        }
-
-        return false;
-    }
-
     /**
      * Creates a new extra field.
      *
@@ -2880,18 +2797,6 @@ class UserManager
         return $extraField->get_handler_field_info_by_tags($variable);
     }
 
-    /**
-     * @param string $type
-     *
-     * @return array
-     */
-    public static function get_all_extra_field_by_type($type)
-    {
-        $extraField = new ExtraField('user');
-
-        return $extraField->get_all_extra_field_by_type($type);
-    }
-
     /**
      * Get all the extra field information of a certain field (also the options).
      *
@@ -5418,42 +5323,6 @@ class UserManager
         return false;
     }
 
-    /**
-     * Gets the user path of user certificated.
-     *
-     * @param int The user id
-     *
-     * @return array containing path_certificate and cat_id
-     */
-    public static function get_user_path_certificate($user_id)
-    {
-        $my_certificate = [];
-        $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
-        $table_gradebook_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
-
-        $session_id = api_get_session_id();
-        $user_id = (int) $user_id;
-        if ($session_id == 0 || is_null($session_id)) {
-            $sql_session = 'AND (session_id='.intval($session_id).' OR isnull(session_id)) ';
-        } elseif ($session_id > 0) {
-            $sql_session = 'AND session_id='.intval($session_id);
-        } else {
-            $sql_session = '';
-        }
-        $sql = "SELECT tc.path_certificate,tc.cat_id,tgc.course_code,tgc.name
-                FROM $table_certificate tc, $table_gradebook_category tgc
-                WHERE tgc.id = tc.cat_id AND tc.user_id = $user_id
-                ORDER BY tc.date_certificate DESC 
-                LIMIT 5";
-
-        $rs = Database::query($sql);
-        while ($row = Database::fetch_array($rs)) {
-            $my_certificate[] = $row;
-        }
-
-        return $my_certificate;
-    }
-
     /**
      * This function check if the user is a coach inside session course.
      *
@@ -5515,32 +5384,6 @@ class UserManager
         return $icon_link;
     }
 
-    /**
-     * Returns an array of the different types of user extra fields [id => title translation].
-     *
-     * @return array
-     */
-    public static function get_user_field_types()
-    {
-        $types = [];
-        $types[self::USER_FIELD_TYPE_TEXT] = get_lang('FieldTypeText');
-        $types[self::USER_FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea');
-        $types[self::USER_FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio');
-        $types[self::USER_FIELD_TYPE_SELECT] = get_lang('FieldTypeSelect');
-        $types[self::USER_FIELD_TYPE_SELECT_MULTIPLE] = get_lang('FieldTypeSelectMultiple');
-        $types[self::USER_FIELD_TYPE_DATE] = get_lang('FieldTypeDate');
-        $types[self::USER_FIELD_TYPE_DATETIME] = get_lang('FieldTypeDatetime');
-        $types[self::USER_FIELD_TYPE_DOUBLE_SELECT] = get_lang('FieldTypeDoubleSelect');
-        $types[self::USER_FIELD_TYPE_DIVIDER] = get_lang('FieldTypeDivider');
-        $types[self::USER_FIELD_TYPE_TAG] = get_lang('FieldTypeTag');
-        $types[self::USER_FIELD_TYPE_TIMEZONE] = get_lang('FieldTypeTimezone');
-        $types[self::USER_FIELD_TYPE_SOCIAL_PROFILE] = get_lang('FieldTypeSocialProfile');
-        $types[self::USER_FIELD_TYPE_FILE] = get_lang('FieldTypeFile');
-        $types[self::USER_FIELD_TYPE_MOBILE_PHONE_NUMBER] = get_lang('FieldTypeMobilePhoneNumber');
-
-        return $types;
-    }
-
     /**
      * @param User $user
      */
@@ -5739,34 +5582,6 @@ class UserManager
         );
     }
 
-    /**
-     * Get the teacher (users with COURSEMANGER status) list.
-     *
-     * @return array The list
-     */
-    public static function getTeachersList()
-    {
-        $userTable = Database::get_main_table(TABLE_MAIN_USER);
-        $resultData = Database::select(
-            'user_id, lastname, firstname, username',
-            $userTable,
-            [
-            'where' => [
-                'status = ?' => COURSEMANAGER,
-            ],
-        ]
-        );
-
-        foreach ($resultData as &$teacherData) {
-            $teacherData['completeName'] = api_get_person_name(
-                $teacherData['firstname'],
-                $teacherData['lastname']
-            );
-        }
-
-        return $resultData;
-    }
-
     /**
      * @return array
      */
@@ -5962,21 +5777,6 @@ class UserManager
         return get_lang('Anonymous');
     }
 
-    /**
-     * Displays the name of the user and makes the link to the user profile.
-     *
-     * @param $userInfo
-     *
-     * @return string
-     */
-    public static function getUserProfileLinkWithPicture($userInfo)
-    {
-        return Display::url(
-            Display::img($userInfo['avatar']),
-            $userInfo['profile_url']
-        );
-    }
-
     /**
      * Get users whose name matches $firstname and $lastname.
      *
@@ -6532,19 +6332,6 @@ SQL;
         }
     }
 
-    /**
-     * @return int
-     */
-    public static function getCountActiveUsers()
-    {
-        $table = Database::get_main_table(TABLE_MAIN_USER);
-        $sql = "SELECT count(id) count FROM $table WHERE active = 1 AND status <> ".ANONYMOUS;
-        $result = Database::query($sql);
-        $row = Database::fetch_array($result);
-
-        return (int) $row['count'];
-    }
-
     /**
      * @param array $userInfo
      * @param int   $searchYear

+ 0 - 6
main/survey/ch_comment.php

@@ -13,12 +13,6 @@ class ch_comment extends survey_question
      */
     public function render(FormValidator $form, $questionData = [], $answers = '')
     {
-        if (is_array($answers)) {
-            $content = implode('', $answers);
-        } else {
-            $content = $answers;
-        }
-
         $name = 'question'.$questionData['question_id'];
         $form->addTextarea($name, null);
         $form->setDefaults([$name => $answers]);