function fetch($option = 'editTemplates')
 {
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance();
     if (!($this->page->session->u->isAdmin || $this->page->session->u->isSponsor || $dynTemp->authEnableEditMode($this->page->session))) {
         $inside = 'This page is only accessible to site administrators.';
     } else {
         $dynTemp->authEnableEditMode($this->page->session);
         // just make sure edit mode is enabled
         if ($option == 'editTemplates') {
             $inside = '<p><a href="?p=admin&o=populateTemplates">Update Templates from source code</a>. This is a safe update of any new templates from the source code into the database. Does not overwrite previous changes you\'ve made</p>';
             $dynTemp->loadDBTemplates();
             // need to load before we enumerate
             $dynTemp->forceAjaxEdit = true;
             // force templates to be ajax-editable
             $inside .= '<fb:editor action="" labelwidth="200">';
             foreach ($dynTemp->dbtemplates as $shortName => $template) {
                 $hackNodeName = "ajax_template_edit_{$shortName}";
                 //					$inside .= "<tr><td>$shortName</td><td>".htmlentities($code)."</td></tr>";
                 $inside .= '<fb:editor-custom label="' . $template['category'] . ' ' . $shortName . '" name="name">' . '<div style="width: 500px;">' . $dynTemp->wrapCodeForEditMode(htmlentities($template['code']), $shortName, $template['helpString'], false) . '<br clear="all" /></div>' . '<a onclick="clearTemplate(\'' . $hackNodeName . '\',\'' . $shortName . '\',false); return false;">Clear</a>' . ' | ' . '<a onclick="clearTemplate(\'' . $hackNodeName . '\',\'' . $shortName . '\',true); return false;">Reset to default</a>' . '</fb:editor-custom>';
             }
             $inside .= '</fb:editor>';
         } else {
             if ($option == 'populateTemplates') {
                 $inside .= $this->templateObj->populateTemplates();
                 // minor hack to force all template files to be processed as though they were being invoked
             }
         }
     }
     if ($this->page->isAjax) {
         return $inside;
     }
     if ($mode == 'teamWrap') {
         return $inside;
     }
     $inside = $tabs . '<div id="teamWrap">' . $inside . '<!-- end teamWrap --></div>';
     if ($this->page->isAjax) {
         return $inside;
     }
     $code = $this->page->constructPage('team', $inside, '');
     return $code;
 }
 function fetch($mode = 'fullPage')
 {
     require_once PATH_FACEBOOK . '/classes/actionTeam.class.php';
     $this->teamObj = new actionTeam($this->page);
     $tabs .= $this->teamObj->buildSubNav('rules');
     // lame!
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance($this->db);
     include PATH_TEMPLATES . '/rules.php';
     $inside .= $static;
     if ($mode == 'teamWrap') {
         return $inside;
     }
     $inside = $tabs . '<div id="teamWrap">' . $inside . '<!-- end teamWrap --></div>';
     if ($this->page->isAjax) {
         return $inside;
     }
     if (isset($_GET['currentPage'])) {
         $currentPage = $_GET['currentPage'];
     } else {
         $currentPage = 1;
     }
     $code = $this->page->constructPage('rules', $inside);
     /* switched out with constructPage above on 7-31-09 by jr
     		$code.=$this->page->buildJavaScript();
     		$code.=$this->page->setHiddenVariables();
     		$code.=$this->page->buildLoadingStatus();
     		$code.='<div id="pageBody">';
     		$code.=$this->page->buildPageTabs('team');
     		$code.='<div id="pageContent">';	
     		//$this->templateObj->registerTemplates(MODULE_ACTIVE, 'rules');		
     		$code .= $inside; // variable containing text created inside the rules.php template file 
     		$code.=$this->page->buildDialog();
     		$code.='</div><!-- end pageContent -->';
     		$code.='</div><!-- end pageBody -->';
     		*/
     return $code;
 }
 function buildFooter()
 {
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     // TODO keep common dynTemp instance
     $dynTemp = dynamicTemplate::getInstance($this->db);
     if (($this->session->isMember or $this->session->isAdmin) and $this->session->u->ncUid > 0) {
         $actCode = crypt($this->session->u->ncUid, $this->session->u->email);
         $actCode = $actCode . "c";
         // add a letter to ending period isn't broken by email programs
         $actCode = str_replace('/', '', $actCode);
         // // strip out forward slash so they don't mess up the url
         if ($this->session->isAdmin or $this->session->u->isModerator or $this->session->u->isSponsor or $this->session->u->isResearcher) {
             $isConsole = true;
             if ($this->session->isAdmin or $this->session->u->isResearcher) {
                 $isResearch = true;
             }
             $email = $this->session->u->email;
         }
         // Switched the includes around to take into account admin status
         include_once PATH_TEMPLATES . '/footer.php';
         $footer = str_replace('http://www.newscloud.com', 'http://www.newscloud.com/ver/home/' . htmlentities($this->session->u->email) . '/' . htmlentities($actCode), $footer);
     } else {
         include_once PATH_TEMPLATES . '/footer.php';
     }
     return $footer;
 }
示例#4
0
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance($db);
     if (!$dynTemp->editEnabled) {
         $dynTemp->authEnableEditMode($session);
     }
     if ($dynTemp->deleteDBTemplate($shortName)) {
         $code = "Template cleared from database.";
     } else {
         $code = "Error clearing template.";
     }
 case 'repopulateTemplate':
     if (isset($_GET['shortName'])) {
         $shortName = $_GET['shortName'];
     }
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance($db);
     if (!$dynTemp->editEnabled) {
         $dynTemp->authEnableEditMode($session);
     }
     if ($dynTemp->deleteDBTemplate($shortName)) {
         $code = "Template cleared from database.";
         require_once PATH_CORE . '/classes/template.class.php';
         $templateObj = new template($db);
         $templateObj->populateTemplates();
         // hack: reloads ALL template files, SLOW
         $code = $dynTemp->useDBTemplate($shortName, 'Error, failed to repopulate.');
     } else {
         $code = "Error clearing template.";
     }
     break;
 case 'previewPublish':
 static function getInstance($db = null)
 {
     if (!self::$singleton) {
         self::$singleton = new dynamicTemplate($db);
     }
     return self::$singleton;
 }
 function registerFeedTemplates()
 {
     require_once PATH_CORE . '/classes/db.class.php';
     $this->db = new cloudDatabase();
     require_once PATH_CORE . '/classes/systemStatus.class.php';
     $ssObj = new systemStatus($this->db);
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance($this->db);
     require_once PATH_TEMPLATES . '/feeds.php';
     $ids = array();
     foreach ($feeds as $k => $v) {
         $idName = 'tbId_' . $k;
         echo $idName . '<br />';
         /*
         			if ($ssObj->getState($idName)!=''){
         				$this->facebook->api_client->feed_deactivateTemplateBundleByID($ssObj->getState($idName));
         				$this->db->query("DELETE FROM SystemStatus WHERE name='".$idName."' LIMIT 1;");	
         			} 
         */
         try {
             $id = $this->facebook->api_client->feed_registerTemplateBundle($v['oneLine'], $v['shortStory']);
             echo $id . ' registered<br><br>';
         } catch (Exception $e) {
             echo $id . ' not able to register<br><br>';
             var_dump($v);
             $this->db->log($e, PATH_LOG_FB);
             $this->db->log($errs, PATH_LOG_FB);
         }
         echo '<br><br>';
         $ssObj->insertState($idName, $id);
         $ids[] = $ssObj->getState($idName);
     }
     $idList = implode(', ', $ids);
     $code .= 'Template Bundle IDs registered: ' . $idList . '<br /><br />';
     $code .= 'If you are a developer for this application, you can see the templates registered for this app <a href="http://developers.facebook.com/tools.php?templates" target="_blank">here</a>.';
     echo $code;
 }
 function registerTemplates($module = '', $group = '')
 {
     // new: (small hack may go better elsewhere)
     // make sure dynamic template engine is available
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance($this->db);
     switch ($module) {
         case 'PHP':
             switch ($group) {
                 case 'profile':
                     include PATH_TEMPLATES . '/profileBox.php';
                     break;
                 default:
                     include PATH_TEMPLATES . '/templates.php';
                     break;
             }
             break;
         case 'FACEBOOK':
             switch ($group) {
                 case 'newswire':
                     include PATH_TEMPLATES . '/home.php';
                     include PATH_TEMPLATES . '/newswire.php';
                     break;
                 case 'home':
                 case 'appTab':
                     include_once PATH_TEMPLATES . '/home.php';
                     break;
                 case 'featuredStories':
                     include PATH_TEMPLATES . '/featuredStories.php';
                     break;
                 case 'ask':
                     include PATH_TEMPLATES . '/ask.php';
                     break;
                 case 'ideas':
                     include PATH_TEMPLATES . '/ideas.php';
                     break;
                 case 'stuff':
                     include PATH_TEMPLATES . '/stuff.php';
                     break;
                 case 'common':
                     include PATH_TEMPLATES . '/common.php';
                     break;
                 case 'read':
                     include PATH_TEMPLATES . '/read.php';
                     include PATH_TEMPLATES . '/comments.php';
                     break;
                 case 'micro':
                     include PATH_TEMPLATES . '/micro.php';
                     break;
                 case 'rewards':
                     include PATH_TEMPLATES . '/rewards.php';
                     break;
                 case 'challenges':
                     include PATH_TEMPLATES . '/challenges.php';
                     break;
                 case 'resources':
                     include PATH_TEMPLATES . '/resources.php';
                     break;
                 case 'teamactivity':
                     include PATH_TEMPLATES . '/teamactivity.php';
                     break;
                 case 'forum':
                     include PATH_TEMPLATES . '/forum.php';
                     break;
                 case 'signup':
                     include PATH_TEMPLATES . '/signup.php';
                     break;
                 case 'promos':
                     include PATH_TEMPLATES . '/promos.php';
                     break;
                 case 'rules':
                     include PATH_TEMPLATES . '/rules.php';
                     break;
                 case 'postStory':
                     include PATH_TEMPLATES . '/postStory.php';
                     break;
                 case 'publisher':
                     include PATH_TEMPLATES . '/publisher.php';
                     break;
                 case 'invite':
                     include PATH_TEMPLATES . '/invite.php';
                     break;
                 case 'research':
                     include PATH_TEMPLATES . '/research.php';
                     break;
                 case 'predict':
                     include PATH_TEMPLATES . '/predict.php';
                     break;
                 case 'winEmail':
                     include PATH_TEMPLATES . '/winEmail.php';
                     break;
                 case 'media':
                     include PATH_TEMPLATES . '/media.php';
                     break;
                 default:
                     // TODO: Add default template for facebook
                     // do nothing for now
                     break;
             }
             break;
     }
 }
 static function fetchBioEditor($fbId)
 {
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance();
     include PATH_TEMPLATES . '/commonTeam.php';
     // hack because this stuff is static and not the best ajax ever
     $code .= '<div class="panelBar clearfix"><h2>' . $commonTeam['BioPanelTitle'] . ' (Limit 500 characters)</h2>';
     if (true) {
         $code .= '<div class="bar_link"><a href="#" class="bold" onclick="saveBio(' . $fbId . '); return false;">Save</a></div>';
     }
     $code .= '</div><!-- end panelBar-->';
     require_once PATH_CORE . '/classes/user.class.php';
     $uit = new UserInfoTable();
     $ui = $uit->getRowObject();
     $ui->loadFromFbId($fbId);
     $code .= '<div class="panel_block"><textarea id="bioText" rows="7" cols="60">' . $ui->bio . '</textarea></div>';
     return $code;
 }
 function fetch($option = 'about')
 {
     require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
     $dynTemp = dynamicTemplate::getInstance($this->db);
     switch ($option) {
         case 'setAdmin':
             $this->db->delete("fbSessions");
             // only works if no admin exists with fbId
             $q1 = $this->db->queryC("SELECT * FROM User,UserInfo WHERE User.userid=UserInfo.userid AND fbId<>0 AND isAdmin=1");
             if ($q1 !== false) {
                 $static = '<p>Error: Another administrator is already registered.</p>';
             } else {
                 $this->facebook = $this->page->app->loadFacebookLibrary();
                 $fbId = $this->facebook->require_login();
                 if ($fbId != 0 and is_numeric($fbId)) {
                     $q = $this->db->queryC("SELECT userid FROM UserInfo WHERE userid={$fbId}");
                     if (!$q) {
                         // set fbId to existing userinfo
                         $q3 = $this->db->queryC("SELECT * FROM User,UserInfo WHERE User.userid=UserInfo.userid AND fbId=0 AND isAdmin=1 ORDER BY User.userid ASC LIMIT 1");
                         if ($q3 !== false) {
                             $d = $this->db->readQ($q3);
                             $this->db->update("UserInfo", "fbId={$fbId}", "userid=" . $d->userid);
                         } else {
                             $static = '<p>Error: Try using the management console to set your Facebook id and admin status manually.</p>';
                         }
                     } else {
                         // set current user as admin
                         $d = $this->db->readQ($q);
                         $userid = $d->userid;
                         $this->db->update("User", "isAdmin=1,ncUid=" . rand(1, 99999), "userid={$fbId}");
                     }
                     $static = '<p>Success: You are now registered as an admin. The next time you visit the <a href="' . URL_CANVAS . '">Facebook application</a> you will see an Admin link to the management console in the footer below.</p>';
                 } else {
                     $static = '<p>Error: Could not get your Facebook account information. Try refreshing this page</p>';
                 }
             }
             break;
         case 'testing':
             include_once PATH_TEMPLATES . '/testingNotice.php';
             break;
         case 'privacy':
         case 'tos':
             include_once PATH_TEMPLATES . '/tos.php';
             break;
         case 'consent':
             include_once PATH_TEMPLATES . '/consent.php';
             break;
         case 'rules':
             include_once PATH_TEMPLATES . '/rules.php';
             break;
         case 'faq':
             include_once PATH_TEMPLATES . '/faq.php';
             break;
         case 'offline':
             include_once PATH_TEMPLATES . '/offline.php';
             break;
         case 'maxSessions':
             include_once PATH_TEMPLATES . '/maxSessions.php';
             break;
         case 'eqex':
             if ($this->page->session->isLoaded and $this->page->session->isMember) {
                 include_once PATH_TEMPLATES . '/eqex.php';
             } else {
                 $static = '<br />' . $this->page->buildMessage('error', 'Membership Required', 'Please <a href="?p=signup">sign up for Hot Dish</a> in order to access this page.') . '<br />';
             }
             break;
         case 'cbd':
             if ($this->page->session->isLoaded and $this->page->session->isMember) {
                 include_once PATH_TEMPLATES . '/cbd.php';
             } else {
                 $static = '<br />' . $this->page->buildMessage('error', 'Membership Required', 'Please <a href="?p=signup">sign up for Hot Dish</a> in order to access this page.') . '<br />';
             }
             break;
         default:
             // about
             include_once PATH_TEMPLATES . '/about.php';
             break;
     }
     $inside .= $static;
     if ($this->page->isAjax) {
         return $inside;
     }
     $code = $this->page->constructPage('static', $inside);
     return $code;
 }
 public function authorize_editing()
 {
     $id = $this->params['id'];
     if ($id === 0) {
         set_flash(array('error' => "Sorry no current member for id: {$id}"));
         redirect(url_for($this->name, 'members'));
     }
     $sql = "SELECT User.*, UserInfo.* FROM User, UserInfo WHERE User.userid = {$id} AND User.userid = UserInfo.userid";
     if ($member_res = $this->db->query($sql)) {
         $member = mysql_fetch_assoc($member_res);
         //if (($member = $this->db->load($id))) {
         //require('views/modify_member.php');
         require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
         require_once PATH_CORE . '/classes/dynamicTemplate.class.php';
         $dynTemp = dynamicTemplate::getInstance();
         $authorized = $dynTemp->authorizeFbIdForEditing($member['fbId']);
         set_flash(array('notice' => "Authorizing {$fbId}...authorized fbIds now {$authorized}"));
         redirect(url_for('members', 'members'));
     } else {
         set_flash(array('error' => "Sorry no current member for id: {$id}"));
         redirect(url_for('members', 'members'));
     }
 }