Exemplo n.º 1
0
 public function getSpecialAlbum(User_Model_User $user, $type)
 {
     if (!in_array($type, array('wall', 'profile', 'message'))) {
         throw new Album_Model_Exception('Unknown special album type');
     }
     $select = $this->select()->where('owner_type = ?', $user->getType())->where('owner_id = ?', $user->getIdentity())->where('type = ?', $type)->order('album_id ASC')->limit(1);
     $album = $this->fetchRow($select);
     // Create wall photos album if it doesn't exist yet
     if (null === $album) {
         $translate = Zend_Registry::get('Zend_Translate');
         $album = $this->createRow();
         $album->owner_type = 'user';
         $album->owner_id = $user->getIdentity();
         $album->title = $translate->_(ucfirst($type) . ' Photos');
         $album->type = $type;
         if ($type == 'message') {
             $album->search = 0;
         } else {
             $album->search = 1;
         }
         $album->save();
         // Authorizations
         if ($type != 'message') {
             $auth = Engine_Api::_()->authorization()->context;
             $auth->setAllowed($album, 'everyone', 'view', true);
             $auth->setAllowed($album, 'everyone', 'comment', true);
         }
     }
     return $album;
 }
Exemplo n.º 2
0
 public function getSpecialAlbum(User_Model_User $user, $type)
 {
     if (!in_array($type, array('wall', 'profile', 'message'))) {
         throw new Advalbum_Model_Exception('Unknown special album type');
     }
     $select = $this->select()->where('owner_type = ?', $user->getType())->where('owner_id = ?', $user->getIdentity())->where('type = ?', $type)->order('album_id ASC')->limit(1);
     $album = $this->fetchRow($select);
     // Create wall photos album if it doesn't exist yet
     if (null === $album) {
         $translate = Zend_Registry::get('Zend_Translate');
         $album = $this->createRow();
         $album->owner_type = 'user';
         $album->owner_id = $user->getIdentity();
         $album->title = $translate->_(ucfirst($type) . ' Photos');
         $album->type = $type;
         $album->save();
     }
     return $album;
 }
Exemplo n.º 3
0
 public function getSpecialAlbum(User_Model_User $user, $type)
 {
     if (!in_array($type, array('comment'))) {
         throw new Album_Model_Exception('Unknown special album type');
     }
     if (Engine_Api::_()->hasModuleBootstrap('sitealbum')) {
         $table = Engine_Api::_()->getDbtable('albums', 'sitealbum');
     } else {
         if (Engine_Api::_()->hasModuleBootstrap('advalbum')) {
             $table = Engine_Api::_()->getDbtable('albums', 'advalbum');
         } else {
             $table = Engine_Api::_()->getDbtable('albums', 'album');
         }
     }
     $select = $table->select()->where('owner_type = ?', $user->getType())->where('owner_id = ?', $user->getIdentity())->where('type = ?', $type)->order('album_id ASC')->limit(1);
     $album = $table->fetchRow($select);
     // Create wall photos album if it doesn't exist yet
     if (null === $album) {
         $translate = Zend_Registry::get('Zend_Translate');
         $album = $table->createRow();
         $album->owner_type = 'user';
         $album->owner_id = $user->getIdentity();
         $album->title = $translate->_(ucfirst(str_replace("_", " ", $type)) . ' Photos');
         $album->type = $type;
         $album->search = 1;
         $album->save();
         // Authorizations
         $auth = Engine_Api::_()->authorization()->context;
         $roles = array('owner', 'owner_member', 'owner_member_member', 'owner_network', 'registered', 'everyone');
         foreach ($roles as $i => $role) {
             $auth->setAllowed($album, $role, 'view', true);
             $auth->setAllowed($album, $role, 'comment', true);
         }
     }
     return $album;
 }