public function __construct($view, $orgId, $id, $admin)
 {
     $this->_photoGalleryTable = new FM_Models_FM_PhotoGallery();
     $this->_photos = $this->_photoGalleryTable->getPhotosByKeys(array('orgId' => $orgId));
     //print Zend_Json::encode($this->_photos);
     $this->_albums = FM_Components_Util_PhotoAlbum::getActive($orgId);
     $org = new FM_Components_Organization(array('id' => $orgId));
     $options = $org->getOrgConfig()->getOptions();
     $this->_showAlbum = $options['showPhotoAlbum'];
     $view->headScript()->appendFile('/js/jquery/jquery.jcarousel.js', 'text/javascript');
     $view->headScript()->appendFile('/js/tooltip.js', 'text/javascript');
     $json = Zend_Json::encode($this->_photos);
     $count = count($this->_photos);
     $albums = '';
     $album_array = array();
     foreach ($this->_albums as $key => $value) {
         $ajson = Zend_Json::encode($value->getImages());
         $album_array[$value->getId()] = $value->getImages();
         $acount = count($value->getImages());
         $albums .= $view->partial('widgets/photogallery/widget.phtml', array('org' => $org, 'photos' => array_splice($value->getImages(), 0, 10), 'json' => $ajson, 'admin' => $admin, 'count' => $acount, 'id' => $value->getId(), 'albums' => $this->_albums));
     }
     $album_array = Zend_Json::encode($album_array);
     //print_r($album_array);exit;
     if ($id) {
         //print $albums;exit;
         $view->layout()->{$id} = $view->partial('widgets/photogallery/gallerywrap.phtml', array('admin' => $admin, 'galleries' => $albums, 'albums' => $this->_albums, 'album_array' => $album_array, 'default' => $this->_showAlbum));
         //$view->partial('widgets/photogallery/widget.phtml',
         //array('org'=>$org, 'photos'=>array_splice($this->_photos, 0, 10), 'json'=>$json, 'admin'=>$admin, 'count'=>$count, 'albums'=>$this->_albums));
     }
 }
 public function init()
 {
     parent::init();
     $banners = FM_Components_Banner::getSortedRandomBanners(array());
     $this->view->layout()->banners = $this->view->partial('banner/bannerleftindex.phtml', array('banners' => $banners));
     $spotlight = FM_Components_Organization::getRandom(6, false, array(), true);
     $this->view->layout()->spotlight = $this->view->partial('organization/spotlight.phtml', array('organizations' => $spotlight));
     $featuredOrganization = FM_Components_Organization::getRandom(1, true, array(8));
     $this->view->layout()->featuredOrganization = $this->view->partial('organization/indexfeatured.phtml', array('organization' => $featuredOrganization[1]));
     $this->view->layout()->header = $this->view->partial('headers/index.phtml');
 }
 public static function update($args)
 {
     $sportsTable = new FM_Models_FM_OrgdataSports();
     FM_Components_Organization::update($args);
     $orgId = $args['orgId'];
     unset($args['orgId']);
     if ($sportsTable->edit(array('orgId' => $orgId), $args)) {
         return true;
     }
     return true;
     return false;
 }
 public function ajaxupdateorgdataAction()
 {
     if ($_POST['orgId']) {
         $result = FM_Components_Organization::update($_POST);
         print $result ? '1' : '0';
         exit;
     }
 }
 public static function updateBusiness($args)
 {
     //print_r($args);exit;
     $businessDataTable = new FM_Models_FM_OrgdataBusiness();
     $orgsTable = new FM_Models_FM_BzOrgCat();
     $cats = array_key_exists('category', $args) ? $args['category'] : array();
     $args['category'] = 1;
     if (FM_Components_Organization::update($args)) {
         $orgId = $args['orgId'];
         unset($args['orgId']);
         if (is_array($cats) && count($cats)) {
             $orgsTable->remove(array('orgId' => $orgId));
             foreach ($cats as $index => $value) {
                 $orgsTable->insertRecord(array('orgId' => $orgId, 'catId' => $value));
             }
         }
         if ($businessDataTable->edit(array('orgId' => $orgId), $args)) {
             return true;
         }
     }
     return true;
 }
 public function ajaxremoveuserfromorgAction()
 {
     if (FM_Components_Organization::removeMember($_POST['oid'], $_POST['uid'])) {
         print '1';
         exit;
     } else {
         print '0';
         exit;
     }
 }
 public static function update($args)
 {
     $businessDataTable = new FM_Models_FM_OrgdataBusiness();
     $orgsTable = new FM_Models_FM_NpOrgCat();
     $cats = array_key_exists('category', $args) ? $args['category'] : array();
     if (FM_Components_Organization::update($args)) {
         $orgId = $args['orgId'];
         if (is_array($cats)) {
             $orgsTable->remove(array('orgId' => $orgId));
             foreach ($cats as $index => $value) {
                 $orgsTable->insertRecord(array('orgId' => $orgId, 'catId' => $value));
             }
         }
         return true;
     }
     return false;
 }
 public static function getRandomActive($limit = 1, $nonProfit = false, $excluding = array())
 {
     $orgData = new FM_Models_FM_Orgdata();
     $orgs = $orgData->getRandomOrg($limit, $nonProfit);
     foreach ($orgs as $org) {
         $org = new FM_Components_Organization(array('id' => $org['id']));
         foreach ($org->getCats() as $i => $id) {
             if (!in_array($id, $excluding)) {
                 $returnOrgs[] = $org;
             }
         }
     }
     return count($returnOrgs) ? $returnOrgs : FM_Components_Organization::getRandom($limit, $nonProfit, $excluding);
 }
 public function ajaxaddeventAction()
 {
     if ($this->_user && ($this->_user->getOrgId() || $this->_user->isRoot())) {
         //user is admin for this group, show edit
         if ($_POST['datetag']) {
             $_POST['starttime'] = $_POST['stimeh'] . ':' . $_POST['stimem'];
             $_POST['endtime'] = $_POST['etimeh'] . ':' . $_POST['etimem'];
             $_POST['id'] = $_POST['ceid'];
             $_POST['frontPage'] = array_key_exists('frontPage', $_POST) ? 1 : 0;
             if ($id = FM_Components_Events::saveNewEvent($_POST)) {
                 $c = new FM_Components_Events(array('eventId' => $id));
                 $rv = $c->toArray();
                 $rv['time'] = $c->getFormattedTime();
                 if (FM_Components_Organization::getOrgType($_POST['orgId']) == 4) {
                     $sport = new FM_Components_Organization(array('id' => $_POST['orgId']));
                     $users = FM_Components_SportsUser::getAll($_POST['orgId']);
                     foreach ($users as $index => $user) {
                         $headers = 'MIME-Version: 1.0' . "\r\n";
                         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                         $headers .= 'From: ' . $sport->getName() . ' administrator @ 4Monmouth.com' . "\r\n" . 'Reply-To: nobody@4monmouth.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
                         $ad = FM_Components_Util_TextAd::getRandom(6);
                         $content = $_POST['content'] . "\n" . $ad;
                         mail($user->getEmail(), 'A New Event Has Been Posted', FM_Components_EmailFormatter::sendSportsEvent($_POST, $c->getFormattedTime(), $sport), $headers);
                     }
                 }
                 $rv['date'] = date('m-d-Y', strtotime($_POST['datetag']));
                 print Zend_Json::encode($rv);
                 exit;
             } else {
                 print '0';
             }
         }
     }
     exit;
 }
 function indexAction()
 {
     $this->_helper->layout->setLayout('layout2col');
     $this->view->layout()->cols = 2;
     if ($this->_request->getParam('id') == 0 || !($org = new FM_Components_Organization(array('id' => $this->_request->getParam('id'))))) {
         $this->_redirect('/');
     }
     if ($org->getType() == 2) {
         $this->_redirect('/merchant/' . $this->_request->getParam('id'));
     }
     if ($org->getType() == 4) {
         $this->_redirect('/sports/' . $this->_request->getParam('id'));
     }
     if (!$this->_user && !$org->getActive()) {
         $this->_redirect('/');
     }
     if (!$org->getActive() && !($this->_user->isRoot() || $this->_user->frontEndAdmin())) {
         $this->_redirect('/');
     }
     $this->view->orgId = $this->_request->getParam('id');
     $orgConfig = $org->getOrgConfig();
     $siteAdmin = false;
     if ($this->_user && ($this->_user->inOrg($this->_request->getParam('id')) || $this->_user->isRoot())) {
         //user is admin for this group, show edit
         $siteAdmin = $this->_user;
     }
     //$gallery = new FM_Components_Widgets_PhotoGallery($this->view, $this->_request->getParam ( 'id' ), 'photogallery', $siteAdmin);
     $banners = FM_Components_Banner::getSortedRandomBanners(array(), 3);
     $this->view->layout()->banners = $this->view->partial('banner/bannerleftindex.phtml', array('banners' => $banners));
     $this->view->layout()->leftcol = $this->view->partial('orgs/leftcol.phtml', array('orgdata' => $this->view->partial('widgets/profile/synop.phtml', array('org' => $org)), 'banners' => $banners));
     $tg = new FM_Components_Tabs_TabGroup();
     $org = new FM_Components_Organization(array('id' => $this->_request->getParam('id')));
     $tab = new FM_Components_Tabs_Profile();
     $tab->setProfile($org->get('description'));
     $tg->addTab($tab, 'profile', 'profile', true);
     $common = $orgConfig->getTabs();
     //print_r($common);exit;
     if ($common['services']) {
         $services = new FM_Components_Tabs_Services($this->_request->getParam('id'));
         $tg->addTab($services, 'services', 'mservices', false);
     }
     if ($common['products']) {
         $pl = new FM_Components_Tabs_ProductList($this->_request->getParam('id'), $siteAdmin);
         $tg->addTab($pl, 'products', 'products', false);
     }
     if ($common['media'] || $common['video']) {
         $media = new FM_Components_Tabs_Media($this->_request->getParam('id'));
         $media->setProfile('This is the profile tab');
         $tg->addTab($media, 'media', 'media', false);
     }
     /**
     		if($common['video']) {
     			$media = new FM_Components_Tabs_Media($this->_request->getParam ( 'id' ));
     			$media->setProfile('This is the profile tab');
     			$tg->addTab($media, 'media', 'media', false);
     		}
     		**/
     if ($common['events']) {
         // CALENDAR TAB!!!!
         $calendarTab = new FM_Components_Tabs_Calendar($this->_request->getParam('id'));
         $tg->addTab($calendarTab, 'events', 'calendar', false);
     }
     if ($common['reviews']) {
         $dir = new FM_Components_Tabs_Testimonials($this->_request->getParam('id'));
         $dir->setProfile('these are directions');
         $tg->addTab($dir, 'reviews', 'testimonials', false);
     }
     if ($common['forum']) {
         $forum = new FM_Components_Tabs_Forum($this->_request->getParam('id'), $siteAdmin);
         $tg->addTab($forum, 'forum', 'forum', false);
     }
     if ($common['directions']) {
         $dir = new FM_Components_Tabs_Directions($org);
         $dir->setProfile('these are directions');
         $tg->addTab($dir, 'directions', 'directions', false);
     }
     if ($common['contact']) {
         $dir = new FM_Components_Tabs_Contact($this->_request->getParam('id'));
         $dir->setProfile('these are directions');
         $tg->addTab($dir, 'contact us', 'contact', false);
     }
     $this->view->video = false;
     $this->view->photo = false;
     if ($common['media']) {
         $this->view->layout()->photo = true;
         $gallery = new FM_Components_Widgets_PhotoGallery($this->view, $this->_request->getParam('id'), 'photogallery', $siteAdmin);
     }
     if ($common['video']) {
         $this->view->layout()->video = true;
         $videoGallery = new FM_Components_Widgets_VideoGallery($this->view, $this->_request->getParam('id'), 'videogallery', $siteAdmin);
     }
     //$tg->addTab($videoGallery , 'videogallery', 'videogallery', false);
     //print_r($videoGallery);exit;
     /**
     		if($common['testimonials']) {
     			$dir = new FM_Components_Tabs_Testimonials($this->_request->getParam ( 'id' ));
     			$dir->setProfile('these are directions');
     			$tg->addTab($dir, 'testimonials', 'testimonials', false);
     		}
     		**/
     if ($siteAdmin) {
         $adminTab = new FM_Components_Tabs_Admin();
         $admin = new FM_Components_Widgets_Admin($this->view, $orgConfig, $org);
         $adminTab->setProfile($admin->toHTML());
         $tg->addTab($adminTab, 'admin', 'admin');
     }
     $this->view->layout()->logo = $org->getLogoObj()->getFileName();
     $this->view->layout()->miniwebBanner = $mw = $org->getMiniWebBannerObj()->getFileName();
     $this->view->layout()->profiletab = $tg->toHTML();
     $this->view->layout()->comments = $this->view->partial('widgets/askus/contact.phtml');
     $this->view->pageId = 'orgs';
 }