/**
  * Add the fields to the form for the query mode
  *
  * @param unknown $form
  */
 protected function addQueryFields($form)
 {
     $options = $this->options;
     $form->add('targetPattern');
     $form->add('query');
     $form->add('maxResults');
     $form->add('fields', 'widget_fields', array('label' => 'widget.form.entity.fields.label', 'namespace' => $options['namespace'], 'widget' => $options['widget']));
 }
Ejemplo n.º 2
0
 /**
  * 添加memcache缓存项
  * @see Star_Cache_Interface::add()
  */
 public function add($key, $value, $lefttime = 0)
 {
     if ($lefttime == 0) {
         return $this->memcache->add($key, $value, false);
     } else {
         return $this->memcache->add($key, $value, false, $lefttime);
     }
 }
 /**
  * 
  * 
  * @param $values
  * @return unknown
  */
 function save_cat($values)
 {
     if ($values['access']) {
         $values['access'] = 'private';
     } else {
         $values['access'] = 'public';
     }
     if (isset($values['id']) && $values['id'] != 0) {
         return $this->cats->edit($values);
     } else {
         return $this->cats->add($values);
     }
 }
Ejemplo n.º 4
0
 /**
  * Add dot
  *
  * @param \AdminBundle\Entity\Dots $dot
  *
  * @return Product
  */
 public function addDot(Dot $dot)
 {
     $dot->addProduct($this);
     $this->dots->add($dot);
 }
Ejemplo n.º 5
0
 /**
  * Add the fields to the form for the query mode.
  *
  * @param unknown $form
  */
 protected function addQueryFields($form)
 {
     $options = $this->options;
     $form->add('query');
     $form->add('fields', 'widget_fields', ['label' => 'widget.form.entity.fields.label', 'namespace' => $options['namespace'], 'widget' => $options['widget']]);
 }
    /**
     * Render index form for ACLs
     *
     * @return null
     */
    function index()
    {
        $acl_app = phpgw::get_var('acl_app', 'string');
        $start = phpgw::get_var('start', 'int');
        $query = phpgw::get_var('query', 'string');
        $s_groups = phpgw::get_var('s_groups', 'int');
        $s_users = phpgw::get_var('s_users', 'int');
        $owner = phpgw::get_var('owner', 'int');
        $acl_app_not_passed = false;
        if (!$acl_app) {
            $acl_app = 'preferences';
            $acl_app_not_passed = true;
        } else {
            $GLOBALS['phpgw']->translation->add_app($acl_app);
        }
        $GLOBALS['phpgw_info']['flags']['currentapp'] = $acl_app;
        if ($acl_app_not_passed) {
            if (is_object($GLOBALS['phpgw']->log)) {
                $GLOBALS['phpgw']->log->message(array('text' => 'F-BadmenuactionVariable, failed to pass acl_app.', 'line' => __LINE__, 'file' => __FILE__));
                $GLOBALS['phpgw']->log->commit();
            }
        }
        if (isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access'] && !isset($GLOBALS['phpgw_info']['user']['apps']['admin'])) {
            echo '<center><b>' . lang('Access not permitted') . '</b></center>';
            $GLOBALS['phpgw']->common->phpgw_exit(true);
        }
        if (!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) || !$owner) {
            $owner = $GLOBALS['phpgw_info']['user']['account_id'];
        }
        $acct = createObject('phpgwapi.accounts', $owner);
        $groups = $acct->get_list('groups');
        $users = $acct->get_list('accounts');
        $owner_name = $acct->id2name($owner);
        // get owner name for title
        $is_group = $acct->get_type($owner);
        if ($is_group == 'g') {
            $owner_name = lang('Group (%1)', $owner_name);
        }
        unset($acct);
        $this->acl = createObject('phpgwapi.acl', (int) $owner);
        $errors = '';
        if (phpgw::get_var('submit', 'bool', 'POST')) {
            $processed = $_POST['processed'];
            $to_remove = unserialize($processed);
            foreach ($to_remove as $entry) {
                $this->acl->delete($acl_app, (int) $entry);
            }
            /* Group records */
            $group_variable = phpgw::get_var("g_{$acl_app}", 'string', 'POST');
            if (!$group_variable) {
                $group_variable = array();
            }
            $totalacl = array();
            foreach ($group_variable as $rowinfo) {
                list($group_id, $rights) = explode('_', $rowinfo, 2);
                $totalacl[(int) $group_id] += (int) $rights;
            }
            /* User records */
            $user_variable = phpgw::get_var("u_{$acl_app}", 'string', 'POST');
            if (!$user_variable) {
                $user_variable = array();
            }
            foreach ($user_variable as $rowinfo) {
                list($user_id, $rights) = explode('_', $rowinfo, 2);
                $totalacl[(int) $user_id] += (int) $rights;
            }
            // Update all the ACLs at once
            foreach ($totalacl as $id => $rights) {
                if ($is_group) {
                    /* Don't allow group-grants to grant private */
                    $rights &= ~phpgwapi_acl::PRIV;
                }
                $this->acl->add($acl_app, $id, $rights);
            }
            if ($this->acl->save_repository('preferences')) {
                $errors = lang('Grants have been updated');
            } else {
                $errors = lang('ERROR: Grants have not been updated');
            }
        }
        $processed = array();
        $total = 0;
        $maxm = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
        $totalentries = count($groups) + count($users);
        if ($totalentries < $maxm) {
            $maxm = $totalentries;
        }
        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('%1 - Preferences', lang($acl_app)) . ' - ' . lang('acl') . ": {$owner_name}";
        $GLOBALS['phpgw']->common->phpgw_header();
        echo parse_navbar();
        $this->template->set_root($GLOBALS['phpgw']->common->get_tpl_dir($acl_app));
        $templates = array('preferences' => 'preference_acl.tpl', 'row_colspan' => 'preference_colspan.tpl', 'acl_row' => 'preference_acl_row.tpl');
        $this->template->set_file($templates);
        $common_hidden_vars = <<<HTML
\t\t\t\t<input type="hidden" name="s_groups" value="{$s_groups}">
\t\t\t\t<input type="hidden" name="s_users" value="{$s_users}">
\t\t\t\t<input type="hidden" name="maxm" value="{$maxm}">
\t\t\t\t<input type="hidden" name="totalentries" value="{$totalentries}">
\t\t\t\t<input type="hidden" name="start" value="{$start}">
\t\t\t\t<input type="hidden" name="query" value="{$query}">
\t\t\t\t<input type="hidden" name="owner" value="{$owner}">
\t\t\t\t<input type="hidden" name="acl_app" value="{$acl_app}">

HTML;
        $var = array('errors' => $errors, 'title' => '<br>', 'action_url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'preferences.uiaclprefs.index', 'acl_app' => $acl_app)), 'submit_lang' => lang('Save'), 'common_hidden_vars_form' => $common_hidden_vars, 'common_hidden_vars' => $common_hidden_vars);
        $this->template->set_var($var);
        /* This is never set so code will never execute - skwashd may08
        			if ( isset($query_result)
        				&& $query_result )
        			{
        				$common_hidden_vars .= "<input type=\"hidden\" name=\"query_result\" value=\"{$query_result}\">\n";
        			}
        			*/
        $vars = $this->template->get_undefined('row_colspan');
        foreach ($vars as $var) {
            if (preg_match('/lang_/', $var)) {
                $value = preg_replace('/lang_/', '', $var);
                $value = preg_replace('/_/', ' ', $value);
                $this->template->set_var($var, lang($value));
            }
        }
        $query = preg_quote($query);
        $row_class = 'row_off';
        $g_count = count($groups);
        if ($g_count && (int) $s_groups != $g_count) {
            $this->template->set_var('string', lang('Groups'));
            $this->template->parse('row', 'row_colspan', true);
            reset($groups);
            foreach ($groups as $group) {
                $name = $group->lid;
                if ($query) {
                    if (!preg_match("/{$query}/", $name)) {
                        continue;
                    }
                }
                $row_class = $GLOBALS['phpgw']->nextmatchs->alternate_row_class($row_class);
                $this->display_row($row_class, 'g_', $group->id, (string) $group, true);
                ++$s_groups;
                $processed[] = $group->id;
                ++$total;
                if ($total == $maxm) {
                    break;
                }
            }
        }
        if ($total != $maxm && is_array($users)) {
            $this->template->set_var('string', lang('Users'));
            $this->template->parse('row', 'row_colspan', true);
            $row_class = $GLOBALS['phpgw']->nextmatchs->alternate_row_class($row_class);
            $u_count = count($users);
            foreach ($users as $user) {
                $name = (string) $user;
                if ($query) {
                    if (!preg_match("/{$query}/", $name)) {
                        continue;
                    }
                }
                // Need to be $owner not $GLOBALS['phpgw_info']['user']['account_id']
                // or the admin can't get special grants from a group
                if ($user->id != $owner) {
                    continue;
                }
                $row_class = $GLOBALS['phpgw']->nextmatchs->alternate_row_class($row_class);
                $this->display_row($row_class, 'u_', $user->id, $name, false);
                ++$s_users;
                $processed[] = $user->id;
                ++$total;
                if ($total == $maxm) {
                    break;
                }
            }
        }
        $extra_parms = array('menuaction' => 'preferences.uiaclprefs.index', 'acl_app' => $acl_app, 's_users' => $s_users, 's_groups' => $s_groups, 'maxm' => $maxm, 'totalentries' => $totalentries, 'total' => $start + $total, 'owner' => $owner);
        $var = array('nml' => $GLOBALS['phpgw']->nextmatchs->left('/index.php', $start, $totalentries, $extra_parms), 'nmr' => $GLOBALS['phpgw']->nextmatchs->right('/index.php', $start, $totalentries, $extra_parms), 'search_value' => $query, 'search' => lang('search'), 'processed' => htmlspecialchars(serialize($processed), ENT_QUOTES, 'utf-8'));
        $this->template->set_var($var);
        $this->template->pfp('out', 'preferences');
    }
Ejemplo n.º 7
0
 /**
  * Add product
  *
  * @param \AdminBundle\Entity\Product $product
  *
  * @return Dot
  */
 public function addProduct(Product $product)
 {
     if (!$this->products->contains($product)) {
         $this->products->add($product);
     }
 }