public function createLeaf($pagename, $type, $category, $subcategory, $songurl = null) { $types = array('default', 'basic', 'standard', 'premium', 'songs', 'video'); if (isset($this->authIdentity) && in_array($type, $types) && !empty($pagename) && !empty($category) && !empty($subcategory)) { $rand = mt_rand() . "_" . mt_rand(); $a = array(); if (strlen($rand) > 25) { $rand = substr($rand, 0, 25); } $admins = array($this->authIdentity->userid); $votes = array($this->authIdentity->userid); $creator = $this->authIdentity->userid; if ($type == 'default' || $type == 'places') { $creator = 'default'; $admins = array('default'); } $admins = serialize($admins); $votes = serialize($votes); switch ($category) { case 'musics': $propic = 3; break; case 'movies': $propic = 13; break; case 'celebrities': $propic = 12; break; case 'books': $propic = 5; break; case 'sports': $propic = 6; break; case 'games': $propic = 7; break; default: $propic = 8; } $freniz_data = array('userid' => 'leaf_' . $rand, 'type' => 'page', 'url' => 'leaf_' . $rand, 'adminpages' => 'a:0:{}', 'username' => $pagename, 'propic' => $propic); $pages_data = array('pageid' => 'leaf_' . $rand, 'pagename' => $pagename, 'type' => $type, 'category' => $category, 'subcategory' => $subcategory, 'creator' => $creator, 'admins' => $admins, 'vote' => $votes, 'date' => new Zend_Db_Expr('now()'), 'url' => 'leaf_' . $rand, 'bannedusers' => 'a:0:{}', 'pagepic' => $propic); $pagesinfo_data = array('pageid' => 'leaf_' . $rand, 'info' => 'a:0:{}', 'tabs' => 'a:0:{}', 'tags' => 'a:0:{}', 'ratings' => 'a:0:{}'); if ($type == 'songs' && isset($songurl)) { $pagesinfo_data['songurl'] = $songurl; } $this->_db->insert('freniz', $freniz_data); $this->_db->insert('pages', $pages_data); if (!($type == 'default' || $type == 'places')) { array_push($this->authIdentity->adminpages, 'leaf_' . $rand); $this->_db->update('freniz', array('adminpages' => serialize($this->authIdentity->adminpages)), array('userid=?' => $this->authIdentity->userid)); $this->_db->update('user_info', array('adminpages' => serialize($this->authIdentity->adminpages)), array('userid=?' => $this->authIdentity->userid)); $this->_db->insert('pages_info', $pagesinfo_data); $AlbumModel = new Application_Model_Album($this->_db); $UserModel = new Application_Model_Users($this->_db); $pagepicalbum = $UserModel->createAlbumData('leaf_' . $rand, 'Page Pics'); $banners = $UserModel->createAlbumData('leaf_' . $rand, 'Banners'); $chartpic = $UserModel->createAlbumData('leaf_' . $rand, 'Chart Pics', true, true); $pagepicAlbumid = $AlbumModel->insert($pagepicalbum); $bannersAlbum = $AlbumModel->insert($banners); $chartpicAlbum = $AlbumModel->insert($chartpic); $this->update(array('pagepicalbum' => $pagepicAlbumid, 'banners' => $bannersAlbum), array('pageid=?' => 'leaf_' . $rand)); } //$user=array('userid'=>'leaf_'.$rand,'type'=>'page','username'=>$pagename,'user_url'=>'leaf_'.$rand,'pagepic_url'=>'default_page.jpg','page_vote'=>$votes,'category'=>$category,'subcategory'=>$subcategory,'bids'=>0); //$usersModel=new Application_Model_Users($this->_db); $search = array('userid' => 'leaf_' . $rand, 'type' => 'page', 'username' => $pagename); $this->_db->insert('searchtable', $search); //$usersModel->buildusers(array('leaf_'.$rand=>$user)); return 'leaf_' . $rand; } else { return false; } }