» » » SocialEngine Excalibur

SocialEngine Excalibur

SocialEngine Excalibur


, . , , , .

: se_music, . sql-:

ALTER TABLE `se_music` ADD `owner_user_id` text AFTER `music_user_id`

is_already_music(), , , user.



1. : class_user.php
: include.
:
: , , . user_message_view ().

return array

(

collaborators => &$collaborators,

pms => &$pms

);

}

:

: .

function is_already_music($music_id)

{

global $database;

$music_tb = $database->database_fetch_assoc($database->database_query(SELECT owner_user_id FROM se_music WHERE music_id={$music_id} LIMIT 1?));

$owner_user_id = $music_tb[owner_user_id];

if(substr_count($owner_user_id, $this->user_info['user_id']) == 0)

return 0;

else

return 1;

return 1;

}


, .


2. : class_music.php
:
: , , . music_list ().

if( $this->user_id ) $sql .= "

WHERE

se_music.music_user_id={$this->user_id}

;

:

: .

if( $this->user_id ) $sql .= "

WHERE

se_music.music_user_id={$this->user_id} OR FIND_IN_SET({$this->user_id}, owner_user_id);

3. : browse_music.php
:
: , , .

$music_object = new se_music();

:

: .

$music_id = $_GET['music_id'];

if( $_GET['task'] == copy && $music_id > 0)

{

ob_end_clean();

$music_tb = $database->database_fetch_assoc($database->database_query(SELECT owner_user_id FROM se_music WHERE music_id={$music_id} LIMIT 1?));

$owner_user_id = trim($music_tb[owner_user_id]);

if(strrchr($owner_user_id, ,))

{

$owner_user_id_text = explode(,', $owner_user_id);

$owner_user_id_update = ;

foreach($owner_user_id_text as $owner_user_id)

{

if($owner_user_id != $user->user_info['user_id'])

$owner_user_id_update = $owner_user_id_update . . $owner_user_id . ,;

}

$owner_user_id_update = $owner_user_id_update . . $user->user_info['user_id'];

}

else

{

if($owner_user_id == $user->user_info['user_id'] || strlen($owner_user_id) == 0)

$owner_user_id_update = $user->user_info['user_id'];

if( strlen($owner_user_id) > 0 )

$owner_user_id_update = $owner_user_id . , . $user->user_info['user_id'];

}

$database->database_query(UPDATE `se_music` SET `owner_user_id` = {$owner_user_id_update} WHERE `music_id` = {$music_id} LIMIT 1?);

}

4. : user_music.php
:
: , , .

$musiclist = $music->music_list();

:

: .

if( $task == "removesong" && $music_id > 0)

{

ob_end_clean();

$music_tb = $database->database_fetch_assoc($database->database_query(SELECT owner_user_id FROM se_music WHERE music_id={$music_id} LIMIT 1?));

$owner_user_id = $music_tb[owner_user_id];

if(strrchr($owner_user_id, ,))

{

$owner_user_id_text = explode(,', $owner_user_id);

$owner_user_id_db = ;

foreach($owner_user_id_text as $owner_user_id)

{

if($owner_user_id != $user->user_info['user_id'])

$owner_user_id_db = $owner_user_id_db . . $owner_user_id . ,;

}

$owner_user_id_db = trim(substr_replace($owner_user_id_db, , strlen($owner_user_id_db) 1));

}

else

{

if($owner_user_id == $user->user_info['user_id'])

$owner_user_id_text = ;

}

$database->database_query(UPDATE `se_music` SET `owner_user_id` = {$owner_user_id_db} WHERE `music_id` = {$music_id} LIMIT 1?);

}

5. : music_ajax.php
:
: , , .
 $user_dir = $url->url_userdir($user_id);


: .
:
: , , .
 {$user_dir}

:
: .
 {$url->url_userdir($song[music_user_id])}

6. : user_music.tpl
:
: , , .

{assign var='media_dir' value=$url->url_userdir($user->user_info.user_id)}

{section name=music_loop loop=$musiclist}

:

: .

{section loop=$musiclist}

{assign var=media_dir value=$url->url_userdir($musiclist[music_loop].music_user_id)}

:

: , , .

<input type='checkbox' name='delete_music_{$musiclist[music_loop].music_id}' value='1' />


:

: .

 {if $musiclist[music_loop].music_user_id == $user->user_info.user_id}<input type='checkbox' name='delete_music_{$musiclist[music_loop].music_id}' value='1' />{/if}

:

: , , .

 <span class="seMusicTitleEdit">&nbsp;(<a href="javascript:void(0);">{lang_print id=187}</a>)</span>


:

: .

{if $musiclist[music_loop].music_user_id == $user->user_info.user_id}<span class="seMusicTitleEdit">&nbsp;(<a href="javascript:void(0);">{lang_print id=187}</a>)</span>{/if}

:

: , , .

<span class="seMusicDelete"><a href="javascript:void(0);" onclick="SocialEngine.Music.deleteMusic({$musiclist[music_loop].music_id});">{lang_print id=155}</a>&nbsp;</span>

:

: .

{if $musiclist[music_loop].music_user_id == $user->user_info.user_id}

<span class=seMusicDelete><a href=javascript:void(0); onclick=SocialEngine.Music.deleteMusic({$musiclist[music_loop].music_id});>{lang_print id=155}</a>&nbsp;</span>

{else}

<span class=seMusicDelete><a href= user_music.php?task=removesong&music_id={$musiclist[music_loop].music_id}>{lang_print id=155}</a>&nbsp;</span>

{/if}

7. : user_music.tpl
:
: , , .

{assign var='media_dir' value=$url->url_userdir($user->user_info.user_id)}

{section name=music_loop loop=$musiclist}

:

: .

{section loop=$musiclist}

{assign var=media_dir value=$url->url_userdir($musiclist[music_loop].music_user_id)}

:

: , , .

<input type='checkbox' name='delete_music_{$musiclist[music_loop].music_id}' value='1' />

:

: .

{if $musiclist[music_loop].music_user_id == $user->user_info.user_id}<input type='checkbox' name='delete_music_{$musiclist[music_loop].music_id}' value='1' />{/if}

:

: , , .

<span class="seMusicTitleEdit">&nbsp;(<a href="javascript:void(0);">{lang_print id=187}</a>)</span>

:

: .

{if $musiclist[music_loop].music_user_id == $user->user_info.user_id}<span class="seMusicTitleEdit">&nbsp;(<a href="javascript:void(0);">{lang_print id=187}</a>)</span>{/if}

:

: , , .

<span class="seMusicDelete"><a href="javascript:void(0);" onclick="SocialEngine.Music.deleteMusic({$musiclist[music_loop].music_id});">{lang_print id=155}</a>&nbsp;</span>

:

: .

{if $musiclist[music_loop].music_user_id == $user->user_info.user_id}

<span class=seMusicDelete><a href=javascript:void(0); onclick=SocialEngine.Music.deleteMusic({$musiclist[music_loop].music_id});>{lang_print id=155}</a>&nbsp;</span>

{else}

<span class=seMusicDelete><a href= user_music.php?task=removesong&music_id={$musiclist[music_loop].music_id}>{lang_print id=155}</a>&nbsp;</span>

{/if}

: class_music.php

: include.

:

music_delete($music_id)

:

: music_delete() function music_delete($music_id) return TRUE; }

function music_delete($music_id)

{

global $database, $url, $user, $admin;

if( $this->user_id )

{

$music = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_music WHERE music_user_id='{$this->user_id}' && music_id='{$music_id}'"));

}

elseif( $admin && $admin->admin_exists )

{

$music = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_music WHERE music_id='{$music_id}'"));

}

if( empty($music) )

return FALSE;

$music_tb = $database->database_fetch_assoc($database->database_query("SELECT owner_user_id FROM se_music WHERE music_id='{$music_id}' LIMIT 1"));

$owner_user_id = $music_tb[owner_user_id];

if( strlen($owner_user_id) > 0 )

{

if(strrchr($owner_user_id, ','))

{

$owner_user_id_text = explode(',', $owner_user_id);

$owner_user_id_db = "";

$new_user_music = "";

foreach($owner_user_id_text as $owner_user_id)

{

if($new_user_music == "")

$new_user_music = $owner_user_id;

if($owner_user_id != $new_user_music)

$owner_user_id_db = $owner_user_id_db . "" . $owner_user_id . ",";

}

$owner_user_id_db = trim(substr_replace($owner_user_id_db, "", strlen($owner_user_id_db) - 1));

}

else

{

$new_user_music = $owner_user_id;

$owner_user_id_db = '';

}

$userdir_old = $url->url_userdir($music['music_user_id']);

$music_file_old = "{$userdir_old}{$music['music_id']}.{$music['music_ext']}";

$userdir_new = $url->url_userdir($new_user_music);

$music_file_new = "{$userdir_new}{$music['music_id']}.{$music['music_ext']}";

if( file_exists($music_file_old) )

{

copy($music_file_old, $music_file_new);

unlink($music_file_old);

}

$database->database_query("UPDATE `se_music` SET `music_user_id` = '{$new_user_music}', `owner_user_id` = '{$owner_user_id_db}' WHERE `music_id` = '{$music_id}' LIMIT 1");

}

else

{

$userdir = $url->url_userdir($music['music_user_id']);

$music_file = "{$userdir}{$music['music_id']}.{$music['music_ext']}";

$database->database_query("DELETE FROM se_music WHERE music_id='{$music_id}' LIMIT 1");

if( file_exists($music_file) ) { unlink($music_file); }

}

return TRUE;

}



! browse_music.php , . user_music.php , .

- Autor:

: