Example #1
0
 public function createAlbumAction()
 {
     $request = $this->getRequest();
     $form = new Album_Form_CreateAlbum();
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
     }
     if ($request->isPost()) {
         $params = $request->getParams();
         if ($form->isValid($params)) {
             $userNs = new Zend_Session_Namespace('members');
             $params['userId'] = $userNs->userId;
             $albumM = new Album_Model_UserAlbum($params);
             $album_id = $albumM->save();
             if ($album_id > 0) {
                 /*-----tags--------*/
                 if ($params['tags'] != "") {
                     $arrTags = explode(",", $params['tags']);
                     foreach ($arrTags as $_tag) {
                         $_tag = trim($_tag);
                         $tagsM = new Application_Model_Tags();
                         $tag = $tagsM->fetchRow("tag='{$_tag}'");
                         if (false === $tag) {
                             $tagsM->setTag($_tag);
                             $tag_id = $tagsM->save();
                         } else {
                             $tag_id = $tag->getId();
                         }
                         $albumTagM = new Application_Model_AlbumTag();
                         $albumTagM->setAlbumId($album_id);
                         $albumTagM->setTagId($tag_id);
                         $albumTagM->save();
                     }
                 }
                 /*----------tags-------*/
                 $this->view->msg = "Album created successfully. Album Id : {$album_id}";
                 $form->reset();
             } else {
                 $this->view->msg = "Faild to create Album. Please try again.";
             }
         }
     }
     $this->view->form = $form;
 }
Example #2
0
 private function setModel($row)
 {
     $model = new Application_Model_AlbumTag();
     $model->setId($row->id)->setTagId($row->tag_id)->setBlogId($row->album_id);
     return $model;
 }