• 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 
00021 function getActionbarPage($userId, $pageId) {
00022 
00023         $action_query = "SELECT perm_id, perm_action, perm_text FROM `".MYSQL_DATABASE_PREFIX."permissionlist` WHERE page_module = 'page'";
00024         $action_result = mysql_query($action_query);
00025         $allow_login_query = "SELECT `value` FROM `".MYSQL_DATABASE_PREFIX."global` WHERE `attribute` = 'allow_login'";
00026         $allow_login_result = mysql_query($allow_login_query);
00027         $allow_login_result = mysql_fetch_array($allow_login_result);
00028         $actionbarPage=array();
00029         while($action_row = mysql_fetch_assoc($action_result)) {
00030                 if(getPermissions($userId, $pageId, $action_row['perm_action']))
00031                         $actionbarPage[$action_row['perm_action']]=$action_row['perm_text'];
00032         }
00033         if($userId==0) {
00034         if($allow_login_result[0]) {
00035                 $actionbarPage["login"]="Login";
00036                 $actionbarPage["login&subaction=register"]="Register";
00037                 }
00038         }
00039         else {
00040                         $actionbarPage["logout"]="Logout";
00042                 $actionbarPage["profile"]=getUserName($userId);
00043         }
00044         $actionbarPage["search"]="Search";
00045         $actionbar="<div id=\"cms-actionbarPage\">";
00046         
00047         foreach($actionbarPage as $action=>$actionname) {
00048         global $templateFolder;
00049         global $cmsFolder;
00050         $hostURLL = hostURL();
00051         if($action == "profile")
00052                 $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\" style=\"position:relative;top:3px;\"\/> $actionname</a></span>\n";
00053         else if($action == "pdf")
00054                 $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";
00055         else
00056                 $actionbar.="<span class=\"cms-actionbarPageItem\"><a class=\"robots-nofollow cms-action{$action}\" rel=\"nofollow\" href=\"./+$action\">$actionname</a></span>\n";
00057         }
00058         $actionbar.="</div>";
00059         return $actionbar;
00060 }
00064 function getActionbarModule($userId, $pageId) {
00065         $action_query = "SELECT perm_id, perm_action, perm_text FROM `".MYSQL_DATABASE_PREFIX."permissionlist` WHERE perm_action != 'create' AND page_module = '".getEffectivePageModule($pageId)."'";
00066         $action_result = mysql_query($action_query);
00067         $allow_login_query = "SELECT `value` FROM `".MYSQL_DATABASE_PREFIX."global` WHERE `attribute` = 'allow_login'";
00068         $allow_login_result = mysql_query($allow_login_query);
00069         $allow_login_result = mysql_fetch_array($allow_login_result);
00070         $actionbarPage = array();
00071         while($action_row = mysql_fetch_assoc($action_result))
00072                 if(getPermissions($userId, $pageId, $action_row['perm_action']))
00073                         $actionbarPage[$action_row['perm_action']]=$action_row['perm_text'];
00074         $actionbar="<div id=\"cms-actionbarModule\">";
00075         if(is_array($actionbarPage)>0)
00076         foreach($actionbarPage as $action=>$actionname) {
00077                 if((!$allow_login_result[0])&&($actionname=="View")&&!($userId))
00078                         continue;               
00079                 $actionbar.="<span class=\"cms-actionbarModuleItem\"><a class=\"robots-nofollow\" rel=\"nofollow\" href=\"./+$action\">$actionname</a></span>\n";
00080         }
00081         $actionbar.="</div>";
00082         return $actionbar;
00083 }
00084 

Generated on Sun Jan 2 2011 04:55:31 for Pragyan CMS by  doxygen 1.7.1