Ejemplo n.º 1
0
     $args['group_name'] = hm_post('group_name');
     $args['group_parent'] = hm_post('group_parent', 0);
     echo add_media_group($args);
     break;
 case 'rename_media_group':
     /** Đổi tên nhóm media */
     $args = array();
     $args['group_name'] = hm_post('group_name');
     $args['group_id'] = hm_post('group_id', 0);
     echo rename_media_group($args);
     break;
 case 'del_media_group':
     /** Xóa nhóm media */
     $args = array();
     $args['group_id'] = hm_post('group_id', 0);
     echo del_media_group($args);
     break;
 case 'add_media':
     /** Upload media */
     echo add_media();
     break;
 case 'delete_media':
     /** Delete media */
     delete_media(hm_post('id'));
     break;
 case 'multi_delete_media':
     /** Delete multi media */
     multi_delete_media(hm_post('ids'));
     break;
 case 'thumbnail_media':
     /** Trả về link thumbnail của file */
Ejemplo n.º 2
0
/** Ajax xóa thư mục */
function del_media_group($args)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    $id = $args['group_id'];
    if (is_numeric($id)) {
        /** Xóa thư mục */
        $path = BASEPATH . '/' . HM_CONTENT_DIR . '/uploads/' . get_media_group_part($id);
        DeleteDir($path);
        $tableName = DB_PREFIX . "media_groups";
        $whereArray = array('id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /** Xóa các file trong thư mục */
        $tableName = DB_PREFIX . "media";
        $whereArray = array('media_group_id' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            while ($row = $hmdb->Row()) {
                $id_media_file = $row->id;
                delete_media($id_media_file);
            }
        }
        /** Xóa thư mục con */
        $tableName = DB_PREFIX . "media_groups";
        $whereArray = array('parent' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            while ($row = $hmdb->Row()) {
                $id_sub_folder = $row->id;
                del_media_group(array('group_id' => $id_sub_folder));
            }
        }
    }
}