Esempio n. 1
0
/**
 *
 **/
function toggle_active($id)
{
    global $parser, $val, $backend;
    $groups = CAT_Users::get_groups_id();
    if (!CAT_Helper_Droplet::is_allowed('modify_droplets', $groups)) {
        $backend->print_error($backend->lang()->translate("You don't have the permission to do this"));
    }
    $data = CAT_Helper_Droplet::getDroplet($id);
    $new = $data['active'] == 1 ? 0 : 1;
    $backend->db()->query('UPDATE `:prefix:mod_droplets` SET active=:active WHERE id=:id', array('active' => $new, 'id' => $id));
    return list_droplets();
}
Esempio n. 2
0
 /**
  * Check whether a page is visible or not
  * This will check page-visibility, user- and group permissions
  *
  * @access public
  * @param  integer  $page_id
  * @return boolean
  **/
 public static function isVisible($page_id)
 {
     $show_it = false;
     $page = self::properties($page_id);
     switch ($page['visibility']) {
         // never shown in FE
         case 'none':
         case 'deleted':
             $show_it = false;
             break;
             // shown if called, but not in menu
         // shown if called, but not in menu
         case 'hidden':
             if (self::selectPage() == $page_id) {
                 $show_it = true;
             }
             break;
             // always visible
         // always visible
         case 'public':
             $show_it = true;
             break;
             // shown if user is allowed
         // shown if user is allowed
         case 'private':
         case 'registered':
             if (CAT_Users::is_authenticated() == true) {
                 // check language
                 if (CAT_Registry::get('PAGE_LANGUAGES') == 'false' || (self::properties($page_id, 'language') == '' || self::properties($page_id, 'language') == LANGUAGE)) {
                     $show_it = CAT_Users::is_group_match(CAT_Users::get_groups_id(), $page['viewing_groups']) || CAT_Users::is_group_match(CAT_Users::get_user_id(), $page['viewing_users']) || CAT_Users::is_root();
                 }
             } else {
                 $show_it = false;
             }
             break;
     }
     return $show_it;
 }
Esempio n. 3
0
 /**
  * returns a list of droplets the current user is allowed to use
  *
  * @access public
  * @return array
  **/
 public static function getDroplets($with_code = false)
 {
     $self = self::getInstance();
     $groups = CAT_Users::get_groups_id();
     $rows = array();
     $fields = 't1.id, `name`, `description`, `active`, `comments`, `view_groups`, `edit_groups`';
     if ($with_code) {
         $fields .= ', `code`';
     }
     $query = $self->db()->query("SELECT {$fields} FROM `:prefix:mod_droplets` AS t1 " . "LEFT OUTER JOIN `:prefix:mod_droplets_permissions` AS t2 " . "ON t1.id=t2.id ORDER BY `name` ASC");
     if ($query->rowCount()) {
         while ($droplet = $query->fetch()) {
             // the current user needs global edit permissions, or specific edit permissions to see this droplet
             if (!CAT_Helper_Droplet::is_allowed('modify_droplets', $groups)) {
                 // get edit groups for this drople
                 if ($droplet['edit_groups']) {
                     if (CAT_Users::get_user_id() != 1 && !is_in_array($droplet['edit_groups'], $groups)) {
                         continue;
                     } else {
                         $droplet['user_can_modify_this'] = true;
                     }
                 }
             }
             $comments = str_replace(array("\r\n", "\n", "\r"), '<br />', $droplet['comments']);
             if (!strpos($comments, "[[")) {
                 $comments = '<span class="usage">' . $self->lang()->translate('Use') . ": [[" . $droplet['name'] . "]]</span><br />" . $comments;
             }
             $comments = str_replace(array("[[", "]]"), array('<b>[[', ']]</b>'), $comments);
             if ($with_code) {
                 $droplet['valid_code'] = self::check_syntax($droplet['code']);
             }
             $droplet['comments'] = $comments;
             // droplet included in search?
             //$droplet['is_in_search'] = self::is_registered_droplet_search($droplet['name']);
             // is there a data file for this droplet?
             if (file_exists(dirname(__FILE__) . '/data/' . $droplet['name'] . '.txt') || file_exists(dirname(__FILE__) . '/data/' . strtolower($droplet['name']) . '.txt') || file_exists(dirname(__FILE__) . '/data/' . strtoupper($droplet['name']) . '.txt')) {
                 $droplet['datafile'] = true;
             }
             array_push($rows, $droplet);
         }
     }
     return $rows;
 }
Esempio n. 4
0
 public function get_groups_id()
 {
     return CAT_Users::get_groups_id();
 }