protected function getPluginModules()
 {
     $exceptions = array('sf_plop_cms', 'sf_plop_dashboard');
     $return = array();
     $modules = sfPlop::getSafePluginModules(true);
     foreach ($modules as $module => $infos) {
         if (!in_array($module, $exceptions)) {
             $return[$module] = $infos['name'];
         }
     }
     return $return;
 }
 /**
  * Check admin credentials.
  * @return Boolean
  */
 protected function checkCredentials()
 {
     $module = 'sf_extranet_dashboard';
     if (!in_array($module, array_keys(sfPlop::getSafePluginModules())) && !$this->getUser()->hasCredential($module)) {
         $this->forward404();
     }
     if (!$this->getUser()->isAuthenticated()) {
         $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action'));
     }
     if (!$this->getUser()->hasCredential($module)) {
         $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
     }
     return $this->getUser()->isAuthenticated() && $this->getUser()->isSuperAdmin();
 }
 /**
  * Retrieve all the permissions.
  * @return Array with all the sfGuardPermission objects
  */
 public static function getAllPermissions()
 {
     $array = array();
     $permissions = sfGuardPermissionPeer::doSelect(new Criteria());
     foreach ($permissions as $permission) {
         if (in_array($permission->getName(), array_keys(sfPlop::getSafePluginModules()))) {
             $array[$permission->getName()] = array('id' => $permission->getId(), 'name' => $permission->getName(), 'description' => $permission->getDescription());
         }
     }
     foreach (sfPlop::getSafePluginModules() as $key => $options) {
         if (!isset($array[$key])) {
             $array[$key] = array('id' => $key, 'name' => $key, 'description' => $options['name']);
         }
     }
     return $array;
 }
 public function preExecute()
 {
     $module = 'sf_extranet_event';
     if (!in_array($module, array_keys(sfPlop::getSafePluginModules()))) {
         $this->forward404();
     }
     if (!$this->getUser()->isAuthenticated()) {
         $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action'));
     }
     if (!$this->getUser()->hasCredential($module)) {
         $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
     }
     parent::preExecute();
     $user = $this->getUser();
     $user->setCulture($user->getProfile()->getCulture());
     ProjectConfiguration::getActive()->LoadHelpers(array('I18N'));
     $this->getResponse()->setTitle(sfPlop::setMetaTitle(__('Extranet events', '', 'plopAdmin')));
 }
 public function executePermissions(sfWebRequest $request)
 {
     $module = 'sfGuardUser';
     if (!in_array($module, array_keys(sfPlop::getSafePluginModules()))) {
         $this->redirect('@sf_plop_dashboard');
     }
     if ($request->isMethod(sfRequest::POST)) {
         if ($request->isXmlHttpRequest()) {
             $this->setTemplate('ajaxPermissions');
             $this->setLayout(false);
         }
         $group_id = $request->getParameter('g');
         $user_id = $request->getParameter('u');
         $permission_id = $request->getParameter('p');
         if ($group_id) {
             $group_exists = sfPlopGuard::groupExists($group_id);
             if (!$group_exists && $request->isXmlHttpRequest()) {
                 return sfView::ERROR;
             } else {
                 if (!$group_exists) {
                     $this->redirect('@sf_plop_dashboard_permissions');
                 }
             }
         }
         if ($user_id) {
             $user_exists = sfPlopGuard::userExists($user_id);
             if (!$user_exists && $request->isXmlHttpRequest()) {
                 return sfView::ERROR;
             } else {
                 if (!$user_exists) {
                     $this->redirect('@sf_plop_dashboard_permissions');
                 }
             }
         }
         if (isset($group_exists) && isset($user_exists)) {
             $user_group = sfGuardUserGroupPeer::retrieveByPK($user_id, $group_id);
             if ($user_group) {
                 $user_group->delete();
             } else {
                 $user_group = new sfGuardUsergroup();
                 $user_group->setUserId($user_id);
                 $user_group->setGroupId($group_id);
                 $user_group->save();
                 $this->getResponse()->setStatusCode(201);
             }
         }
         if ($permission_id) {
             if ($permission_id == 'super') {
                 if (!sfPlopGuard::isLastSuperAdminUser($user_id)) {
                     $user = sfGuardUserPeer::retrieveByPK($user_id);
                     if ($user->getIsSuperAdmin()) {
                         $user->setIsSuperAdmin(false);
                     } else {
                         $user->setIsSuperAdmin(true);
                     }
                     $user->save();
                 } else {
                     $this->getResponse()->setStatusCode(202);
                     return sfView::ERROR;
                 }
             } else {
                 if (!is_int($permission_id)) {
                     $permission_exists = sfPlopGuard::permissionExists($permission_id);
                     if (!$permission_exists) {
                         $modules = sfPlop::getSafePluginModules();
                         if ($request->isXmlHttpRequest() && !isset($modules[$permission_id])) {
                             return sfView::ERROR;
                         } elseif (!isset($modules[$permission_id])) {
                             $this->redirect('@sf_plop_dashboard_permissions');
                         } else {
                             $module = $modules[$permission_id];
                         }
                         $permission = new sfGuardPermission();
                         $permission->setName($permission_id);
                         $permission->setDescription($module['name']);
                         $permission->save();
                         $permission_id = $permission->getId();
                         $this->getResponse()->setStatusCode(201);
                     } else {
                         $permission_id = sfPlopGuard::getPermission($permission_id)->getId();
                     }
                 } else {
                     $permission_exists = sfPlopGuard::permissionExists($permission_id);
                     if (!$permission_exists && $request->isXmlHttpRequest()) {
                         return sfView::ERROR;
                     } else {
                         if (!$permission_exists) {
                             $this->redirect('@sf_plop_dashboard_permissions');
                         }
                     }
                 }
                 if (isset($user_exists)) {
                     $user_permission = sfGuardUserPermissionPeer::retrieveByPK($user_id, $permission_id);
                     if ($user_permission) {
                         $user_permission->delete();
                     } else {
                         $user_permission = new sfGuardUserPermission();
                         $user_permission->setUserId($user_id);
                         $user_permission->setPermissionId($permission_id);
                         $user_permission->save();
                         $this->getResponse()->setStatusCode(201);
                     }
                 } elseif (isset($group_exists)) {
                     $group_permission = sfGuardGroupPermissionPeer::retrieveByPK($group_id, $permission_id);
                     if ($group_permission) {
                         $group_permission->delete();
                     } else {
                         $group_permission = new sfGuardGroupPermission();
                         $group_permission->setGroupId($group_id);
                         $group_permission->setPermissionId($permission_id);
                         $group_permission->save();
                         $this->getResponse()->setStatusCode(201);
                     }
                 }
             }
         }
         if (!$request->isXmlHttpRequest()) {
             $this->redirect('@sf_plop_dashboard_permissions');
         }
     }
     $this->groups = sfPlopGuard::getAllGroups();
     $this->users = sfPlopGuard::getAllUsers();
     $this->permissions = sfPlopGuard::getAllPermissions();
 }
<?php

$user_culture = $sf_user->getCulture();
?>

<ul class="w-menu menu-quick-links">
  <?php 
if ($sf_user->isAuthenticated()) {
    ?>
    <?php 
    $modules = isset($modules) ? $modules : sfPlop::getSafePluginModules();
    ?>
    <?php 
    if (count($modules) > 0) {
        ?>
      <li class="w-menu-dd">
        <span class="element"><?php 
        echo __('Modules', '', 'plopAdmin');
        ?>
</span>
        <ul>
          <?php 
        foreach ($modules as $name => $options) {
            ?>
            <?php 
            if ($sf_user->hasCredential($name)) {
                ?>
              <?php 
                $label = __($options['name'], '', 'plopAdmin');
                ?>
              <?php 
 /**
  * Retrieve the assets files and/or folders
  * @param sfWebRequest $request
  * @return Json array
  */
 public function executeWsRepository(sfWebRequest $request)
 {
     if (!$this->isUserAdmin) {
         return;
     }
     $data = array();
     $type = strtolower($request->getParameter('type', 'folder'));
     $folder = strtolower($request->getParameter('folder', null));
     $term = strtolower($request->getParameter('term', null));
     if ($type == 'folder' && !$folder) {
         $data['Assets'] = 'Assets';
         $data['Links'] = 'Links';
     } elseif ($type == 'file') {
         if ($folder == '/links') {
             // Links
             $page_query = sfPlopPageQuery::create();
             if ($term) {
                 $page_query->filterBySlug('%' . $term . '%', Criteria::LIKE);
             }
             $nodes = sfPlopPageQuery::create()->findRoot()->getBranch($page_query);
             sfProjectConfiguration::getActive()->loadHelpers('Url');
             foreach ($nodes as $node) {
                 $node->setCulture($this->getCulture());
                 $url = url_for('@sf_plop_page_show?slug=' . $node->getSlug());
                 $data[] = array('name' => $node->getTitle(), 'description' => $node->getTitle(), 'title' => $node->getTitle(), 'forward' => $url, 'url' => $url, 'type' => 'website', 'html' => '<a href="' . $url . '">' . $node->getTitle() . '</a>');
             }
         } elseif ($folder == '/assets') {
             if (in_array('sfAssetLibrary', array_keys(sfPlop::getSafePluginModules()))) {
                 // Assets
                 $asset_query = sfAssetQuery::create();
                 if ($term) {
                     $asset_query->filterByFilename('%' . $term . '%', Criteria::LIKE);
                 }
                 $assets = $asset_query->find();
                 foreach ($assets as $asset) {
                     $data[] = array('name' => $asset->getFilename(), 'title' => $asset->getFilename(), 'url' => $asset->getUrl(), 'src' => $asset->getUrl(), 'type' => $asset->getType(), 'html' => '<a href="' . $asset->getUrl() . '">' . '<img src="' . $asset->getUrl() . '" height="25" />' . $asset->getFilename() . '</a>');
                 }
             }
         }
     }
     $this->getResponse()->setContentType('text/json');
     return $this->renderText(str_replace('\\/', '/', json_encode($data)));
 }
        <?php 
    if ($i == 0) {
        ?>
          <th rowspan="<?php 
        echo count($users);
        ?>
"><?php 
        echo __('Users', '', 'plopAdmin');
        ?>
</th>
        <?php 
    }
    ?>
        <th>
          <?php 
    if (in_array('sfGuardUser', sfPlop::getSafePluginModules()) && $sf_user->hasCredential('sfGuardUser')) {
        ?>
            <?php 
        echo link_to($user->getUsername(), 'sfGuardUser/edit?id=' . $user->getId());
        ?>
          <?php 
    } else {
        ?>
            <?php 
        echo $user->getUsername();
        ?>
          <?php 
    }
    ?>
        </th>
        <td>
<?php

$user_culture = $sf_user->getCulture();
?>

<<?php 
echo html5Tag('nav');
?>
 class="nav">
  <?php 
$links = sfPlop::getSafePluginLinks();
?>
	<?php 
$modules = sfPlop::getSafePluginModules();
?>
	
	<?php 
if (count($links) > 0) {
    ?>
		<ul class="w-menu">
			<?php 
    foreach ($links as $name => $options) {
        ?>
        <?php 
        if (!isset($options['module']) || isset($options['module']) && $sf_user->hasCredential($options['module'])) {
            ?>
          <?php 
            $label = __($options['name'], '', 'plopAdmin');
            ?>
          <?php 
            if (isset($options['culture']) && $options['culture'] == 'default') {
            <?php 
    echo link_to_unless($sub == $key, __($value, '', 'plopAdmin'), '@sf_plop_dashboard_settings?sub=' . $key, 'class=element');
    ?>
          </li>
        <?php 
}
?>
      </ul>
    </li>
    <li>
      <?php 
echo link_to(__('Themes', '', 'plopAdmin'), '@sf_plop_dashboard_themes', 'class=element');
?>
    </li>
    <?php 
if (in_array('sfGuardUser', array_keys(sfPlop::getSafePluginModules()))) {
    ?>
      <li>
        <?php 
    echo link_to(__('Credentials', '', 'plopAdmin'), '@sf_plop_dashboard_permissions', 'class=element');
    ?>
      </li>
    <?php 
}
?>

    <?php 
if (sfPlop::get('sfPlopCMS_use_statistics') == true && sfPlop::get('sfPlopCMS_statistics_reports_url') != '') {
    ?>
      <li>
        <a class="element" target="_blank" href="<?php