示例#1
0
 public function userAction()
 {
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $favorites = Ml_Model_Favorites::getInstance();
     $share = Ml_Model_Share::getInstance();
     $people = Ml_Model_People::getInstance();
     $request = $this->getRequest();
     $userInfo = $registry->get('userInfo');
     $page = $request->getUserParam("page");
     $paginator = $favorites->getUserPage($userInfo['id'], 25, $page);
     //Test if there is enough pages or not
     if (!$paginator->count() && $page != 1 || $paginator->getCurrentPageNumber() != $page) {
         $this->_redirect($router->assemble(array("username" => $userInfo['alias']), "userfav_1stpage"), array("exit"));
     }
     $this->view->paginator = $paginator;
 }
示例#2
0
 public function set($uid, $ignoreUid)
 {
     $contacts = Ml_Model_Contacts::getInstance();
     $favorites = Ml_Model_Favorites::getInstance();
     $this->_dbAdapter->beginTransaction();
     try {
         $contacts->setRelationship($uid, $ignoreUid, Ml_Model_Contacts::RELATIONSHIP_TYPE_NONE);
         $contacts->setRelationship($ignoreUid, $uid, Ml_Model_Contacts::RELATIONSHIP_TYPE_NONE);
         $favorites->deleteFavoritesFrom($uid, $ignoreUid);
         $this->_dbTable->insert(array("uid" => $uid, "ignore" => $ignoreUid));
         $this->_dbAdapter->commit();
     } catch (Exception $e) {
         $this->_dbAdapter->rollBack();
         throw $e;
     }
     return $this->_dbAdapter->lastInsertId();
 }
示例#3
0
 public function infoAction()
 {
     //@todo route: do it the right way!
     $router = new Zend_Controller_Router_Rewrite();
     $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
     $router->addConfig($routeConfig, 'routes');
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $request = $this->getRequest();
     $params = $request->getParams();
     $people = Ml_Model_People::getInstance();
     $favorites = Ml_Model_Favorites::getInstance();
     $comments = Ml_Model_Comments::getInstance();
     $tags = Ml_Model_Tags::getInstance();
     $numbers = new Ml_Model_Numbers();
     $this->_helper->loadApiresource->share();
     $shareInfo = $registry->get("shareInfo");
     $userInfo = $people->getById($shareInfo['byUid']);
     $tagsList = $tags->getShareTags($shareInfo['id']);
     $countFavs = $favorites->count($shareInfo['id']);
     $countComments = $comments->count($shareInfo['id']);
     //begin of response
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("file");
     $doc->appendChild($rootElement);
     $rootElement->appendChild($doc->newTextAttribute('id', $shareInfo['id']));
     $rootElement->appendChild($doc->newTextAttribute('secret', $shareInfo['secret']));
     $rootElement->appendChild($doc->newTextAttribute('download_secret', $shareInfo['download_secret']));
     $ownerElement = $doc->createElement("owner");
     $ownerData = array("id" => $userInfo['id'], "username" => $userInfo['alias'], "realname" => $userInfo['name']);
     foreach ($ownerData as $field => $data) {
         $ownerElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($ownerElement);
     $shareData = array("title" => $shareInfo['title'], "filename" => $shareInfo['filename'], "filetype" => $shareInfo['type'], "short" => $shareInfo['short'], "description" => $shareInfo['description_filtered'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias'], "share_id" => $shareInfo['id']), "sharepage_1stpage"), "dataurl" => $config['services']['S3']['sharesBucketAddress'] . $userInfo['alias'] . "/" . $shareInfo['id'] . "-" . $shareInfo['download_secret'] . "/" . $shareInfo['filename'], "shorturl" => $config['URLshortening']['addr'] . $numbers->base58Encode($shareInfo['id']), "comments" => $countComments, "favorites" => $countFavs);
     foreach ($shareData as $field => $data) {
         $rootElement->appendChild($doc->newTextElement($field, $data));
     }
     $filesizeElement = $doc->createElement("filesize");
     $filesizeElement->appendChild($doc->newTextAttribute("bits", $shareInfo['fileSize']));
     $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($shareInfo['fileSize'] / (1024 * 8))));
     $rootElement->appendChild($filesizeElement);
     $checksumElement = $doc->createElement("checksum");
     $checksumElement->appendChild($doc->newTextAttribute("hash", "md5"));
     $checksumElement->appendChild($doc->newTextAttribute("value", $shareInfo['md5']));
     $rootElement->appendChild($checksumElement);
     $visibilityElement = $doc->createElement("visibility");
     $visibilityElement->appendChild($doc->newTextAttribute("ispublic", "1"));
     $rootElement->appendChild($visibilityElement);
     $datesData = array("posted" => $shareInfo['uploadedTime'], "lastupdate" => $shareInfo['lastChange']);
     $datesElement = $doc->createElement("dates");
     foreach ($datesData as $field => $data) {
         $datesElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($datesElement);
     $tagsElement = $doc->createElement("tags");
     foreach ($tagsList as $tag) {
         $tagElement = $doc->createElement("tag");
         $tagElement->appendChild($doc->newTextAttribute("id", $tag['id']));
         $tagElement->appendChild($doc->newTextAttribute("raw", $tag['raw']));
         $tagElement->appendChild($doc->createTextNode($tag['clean']));
         $tagsElement->appendChild($tagElement);
     }
     $rootElement->appendChild($tagsElement);
     $this->_helper->printResponse($doc);
 }
示例#4
0
 public function testingAction()
 {
     $favorites = Ml_Model_Favorites::getInstance();
     $favorites->getUserPage(1, 1, 1);
 }