public function _share(){
$tLink=array(
'mainShare::profil' => 'Son profil',
'mainShare::photos' => 'Ses photos',
);
$oView=new _view('menu::share');
$oView->tLink=$tLink;
return $oView;
}
<ul class="menu">
<?php foreach($this->tLink as $sNav => $sLabel):?>
<li <?php if(_root::getParamNav()==$sNav):?>class="selectionne"<?php endif;?>><a href="<?php echo _root::getLink($sNav,array('user_id'=>_root::getParam('user_id')))?>"><?php echo $sLabel?></a></li>
<?php endforeach; ?>
<li><a href="<?php echo _root::getLink('mainPrivate::home')?>">Retour</a></li>
</ul>
public function isUserFiendsWith($user_id,$user_id2){
$oRow=$this->findOne('SELECT count(*) as total FROM Friends where
(user_id=? AND user_id2=? AND state='.self::STATE_ACCEPTED.')
OR
(user_id2=? AND user_id=? AND state='.self::STATE_ACCEPTED.')
',
$user_id,$user_id2,$user_id,$user_id2);
if($oRow->total >0){
return true;
}else{
return false;
}
}
public function before(){
if(!model_Friends::getInstance()->isUserFiendsWith(_root::getParam('user_id'), _root::getAuth()->getAccount()->id) ){
//si on est pas un contact de cette personne, on est redirige
_root::redirect('mainPrivate::profil');
}
$this->oLayout=new _layout('template1');
$this->oLayout->addModule('menu','menu::share');
}
public function _showshare(){
$oUsers=model_Users::getInstance()->findById( $this->id );
$oView=new _view('profil::showshare');
$oView->oUsers=$oUsers;
return $oView;
}
<div style="float:right"><img style="width:100px;border:2px solid gray" src="<?php echo $this->oUsers->profilPicture ?>" /></div>
<table class="tb_show">
<tr>
<th>lastname</th>
<td><?php echo $this->oUsers->lastname ?></td>
</tr>
<tr>
<th>firstname</th>
<td><?php echo $this->oUsers->firstname ?></td>
</tr>
<tr>
<th>mail</th>
<td><?php echo $this->oUsers->mail ?></td>
</tr>
<tr>
<th>profilPicture</th>
<td><?php echo $this->oUsers->profilPicture ?></td>
</tr>
<tr>
<th>job</th>
<td><?php echo $this->oUsers->job ?></td>
</tr>
</table>
public function _profil(){
$oModuleProfil=new module_profil;
$oModuleProfil->setId(_root::getParam('user_id'));
$oView=$oModuleProfil->_showshare();
$this->oLayout->add('main',$oView);
}
public function findAllShareByUserForUser($user_id,$usershared_id){
return $this->findMany('SELECT distinct Albums.*
FROM Share, Albums, UsersGroup
WHERE
Share.album_id = Albums.id
AND
UsersGroup.group_id = Share.group_id
AND
Albums.user_id=?
AND UsersGroup.user_id=?',$user_id,$usershared_id
);
}
private $user_id;
public function setUserId($user_id){
$this->user_id=(int)$user_id;
}
$tAlbums=model_Albums::getInstance()->findAll();
$tAlbums=model_Albums::getInstance()->findAllShareByUserForUser($this->user_id, _root::getAuth()->getAccount()->id);
public function _show(){
$oAlbums=model_Albums::getInstance()->findById( module_Albumshare::getParam('id') );
$oView=new _view('Albumshare::show');
$oView->oAlbums=$oAlbums;
$oView->tPictures=model_Pictures::getInstance()->findListByAlbum($oAlbums->id);
return $oView;
}
<script>
function hidePicture(){
var a=getById('popup');
if(a){
a.style.display='none';
}
}
function showPicture(sPath){
var a=getById('popup');
if(a){
a.style.display='block';
var b=getById('img');
if(b){
b.innerHTML='<img src="'+sPath+'"/>';
}
}
}
</script>
<h1>Album <?php echo $this->oAlbums->name ?></h1>
<?php foreach($this->tPictures as $oPicture):?>
<a href="#" onclick="showPicture('<?php echo $oPicture->path?>');"><img style="width:100px;height:100px;border:4px solid gray" src="<?php echo $oPicture->path?>" /></a>
<?php endforeach;?>
<div id="popup" style="position:absolute;display:none;border:1px solid gray;background:white">
<p style="margin:0px;background:black;text-align:right"><a style="color:white" href="#" onclick="hidePicture()" >Fermer</a></p>
<div id="img"></div>
</div>
<p><a href="<?php echo module_Albumshare::getLink('list')?>">Retour</a></p>
public function _photos(){
$user_id=_root::getParam('user_id');
$oModuleAlbum=new module_Albumshare;
$oModuleAlbum->setUserId($user_id);
$oModuleAlbum->setRootLink('mainShare::photos',array('user_id'=>$user_id));
$oView=$oModuleAlbum->_index();
$this->oLayout->add('main',$oView);
}
<h1>Mes contacts</h1>
<?php if($this->tContacts):?>
<table>
<?php foreach($this->tContacts as $oContact):?>
<tr>
<td><a href="<?php echo _root::getLink('mainShare::profil',array('user_id'=>$oContact->id))?>"><?php echo $oContact->lastname ?></a></td>
<td><a href="<?php echo _root::getLink('mainShare::profil',array('user_id'=>$oContact->id))?>"><?php echo $oContact->firstname ?></a></td>
</tr>
<?php endforeach;?>
</table>
<?php else:?>
Aucun pour le moment
<?php endif;?>
public function showForFil( $album_id){
$oAlbums=model_Albums::getInstance()->findById( $album_id );
$oView=new _view('Albums::showForFil');
$oView->oAlbums=$oAlbums;
return $oView;
}
<a href="<?php echo _root::getLink('mainShare::photos',
array(
'user_id'=>$this->oAlbums->user_id,
'albumshareid'=>$this->oAlbums->id
)
)?>">Consultez cet album partagé</a>
if(_root::getParam('share')){
$oViewAlbum=$this->showForFil($oAlbums->id);
$oPosts=new row_Posts;
$oPosts->title='Partage de photos';
$oPosts->body=$oViewAlbum->show();
$oPosts->date=date('Y-m-d');
$oPosts->time=date('H:i:s');
$oPosts->user_id=$this->user_id;
$oPosts->save();
$tPostedGroups=_root::getParam('tGroup');
//partge du post avec les groups
model_Share::getInstance()->shareUserPostWithGroups($this->user_id,$oPosts->id,$tPostedGroups);
model_Share::getInstance()->shareUserAlbumsWithGroups($this->user_id,$oAlbums->id,$tPostedGroups);
self::redirect('show',array('id'=>$oAlbums->id));
}
Lire la suite : X Design/ esthétique