• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/actionbar.lib.php

Go to the documentation of this file.
00001 <?php
00008 if(!defined('__PRAGYAN_CMS'))
00009 { 
00010         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00011         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00012         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00013         exit(1);
00014 }
00015 
00026 function getActionbarPage($userId, $pageId) {
00027 
00028         $action_query = "SELECT perm_id, perm_action, perm_text FROM `".MYSQL_DATABASE_PREFIX."permissionlist` WHERE page_module = 'page'";
00029         $action_result = mysql_query($action_query);
00030         $allow_login_query = "SELECT `value` FROM `".MYSQL_DATABASE_PREFIX."global` WHERE `attribute` = 'allow_login'";
00031         $allow_login_result = mysql_query($allow_login_query);
00032         $allow_login_result = mysql_fetch_array($allow_login_result);
00033         $actionbarPage=array();
00034         while($action_row = mysql_fetch_assoc($action_result)) {
00035                 if(getPermissions($userId, $pageId, $action_row['perm_action']))
00036                         $actionbarPage[$action_row['perm_action']]=$action_row['perm_text'];
00037         }
00038         if($userId==0) {
00039         if($allow_login_result[0]) {
00040                 $actionbarPage["login"]="Login";
00041                 $actionbarPage["login&subaction=register"]="Register";
00042                 }
00043         }
00044         else {
00045                         $actionbarPage["logout"]="Logout";
00047                 $actionbarPage["profile"]=getUserName($userId);
00048         }
00049         $actionbarPage["search"]="Search";
00050         $actionbar="<div id=\"cms-actionbarPage\">";
00051         
00052         foreach($actionbarPage as $action=>$actionname) {
00053         global $templateFolder;
00054         global $cmsFolder;
00055         $hostURLL = hostURL();
00056         if($action == "profile")
00057                 $actionbar.="<span class=\"cms-actionbarPageItem\"><a class=\"robots-nofollow cms-action{$action}\" rel=\"nofollow\" href=\"./+$action\"><img src=\"{$hostURLL}/{$cmsFolder}/{$templateFolder}/common/images/usericon.png\" \/> $actionname</a></span>\n";
00058         else if($action == "pdf")
00059                 $actionbar.="<span class=\"cms-actionbarPageItem\"><a id=\"a\" onclick=\"javascript:var x=prompt('Enter Depth (-1 for full depth)');if(x)document.getElementById('a').href = document.getElementById('a').href + '&depth=' + x; else return false;\" class=\"robots-nofollow cms-action{$action}\" rel=\"nofollow\" href=\"./+$action\">$actionname</a></span>\n";
00060         else
00061                 $actionbar.="<span class=\"cms-actionbarPageItem\"><a class=\"robots-nofollow cms-action{$action}\" rel=\"nofollow\" href=\"./+$action\">$actionname</a></span>\n";
00062         }
00063         $actionbar.="</div>";
00064         return $actionbar;
00065 }
00066 
00075 function getActionbarModule($userId, $pageId) {
00076         $action_query = "SELECT perm_id, perm_action, perm_text FROM `".MYSQL_DATABASE_PREFIX."permissionlist` WHERE perm_action != 'create' AND page_module = '".getEffectivePageModule($pageId)."'";
00077         $action_result = mysql_query($action_query);
00078         $allow_login_query = "SELECT `value` FROM `".MYSQL_DATABASE_PREFIX."global` WHERE `attribute` = 'allow_login'";
00079         $allow_login_result = mysql_query($allow_login_query);
00080         $allow_login_result = mysql_fetch_array($allow_login_result);
00081         $actionbarPage = array();
00082         while($action_row = mysql_fetch_assoc($action_result))
00083                 if(getPermissions($userId, $pageId, $action_row['perm_action']))
00084                         $actionbarPage[$action_row['perm_action']]=$action_row['perm_text'];
00085         $actionbar="<div id=\"cms-actionbarModule\">";
00086         if(is_array($actionbarPage)>0)
00087         foreach($actionbarPage as $action=>$actionname) {
00088                 if((!$allow_login_result[0])&&($actionname=="View")&&!($userId))
00089                         continue;               
00090                 $actionbar.="<span class=\"cms-actionbarModuleItem\"><a class=\"robots-nofollow\" rel=\"nofollow\" href=\"./+$action\">$actionname</a></span>\n";
00091         }
00092         $actionbar.="</div>";
00093         return $actionbar;
00094 }
00095 

Generated on Mon Mar 14 2011 05:35:29 for Pragyan CMS by  doxygen 1.7.1