Esempio n. 1
0
 public function getRecord($id)
 {
     $rec = parent::getRecord($id);
     if ($rec->get('subusers_parent_id') != $this->user_id) {
         throw new Am_Exception_Security(___('Trying to load foreign subuser'));
     }
     return $rec;
 }
 function saveSearchAction()
 {
     $q = new Am_Query_User();
     $search = $this->_request->get('search');
     $q->unserialize($search['serialized']);
     if (!$q->getConditions()) {
         throw new Am_Exception_InputError("Wrong parameters passed: no conditions : " . htmlentities($this->_request->search['serialized']));
     }
     if (!strlen($this->getParam('name'))) {
         throw new Am_Exception_InputError(___("No search name passed"));
     }
     $name = $this->getParam('name');
     $id = $q->setName($name)->save();
     $this->redirectLocation(REL_ROOT_URL . '/admin-users?_u_search_load=' . $id);
 }
Esempio n. 3
0
 function onDaily(Am_Event $event)
 {
     $q = new Am_Query_User();
     $q->add(new Am_Query_Condition_Data('subusers_count', 'IS NOT NULL'));
     foreach ($q->selectPageRecords(0, 100000) as $user) {
         $this->checkAndUpdate($user);
     }
 }
Esempio n. 4
0
 function applySimpleSearch()
 {
     $search = array();
     foreach ($this->options as $string) {
         @(list($k, $id) = explode('-', $string, 2));
         $search[$k][] = $id == 'all' ? 'all' : intval($id);
     }
     $queries = array();
     // union these queries with $this->query
     $this->queryDescription = array();
     foreach ($search as $k => $items) {
         if ($k == 'all') {
             $q = new Am_Query_User();
             $q->addWhere("IFNULL(u.unsubscribed,0)=0");
             $queries = array($q);
             $this->queryDescription = array(___("All Users"));
             break;
         }
         switch ($k) {
             case 'aff':
                 $q = new Am_Query_User();
                 $q->addWhere("IFNULL(u.unsubscribed,0)=0");
                 $q->addWhere("is_affiliate>0");
                 $queries[] = $q;
                 $this->queryDescription[] = ___("All Affiliates");
                 break;
             case 'active':
             case 'expired':
                 $q = new Am_Query_User();
                 $q->addWhere("IFNULL(u.unsubscribed,0)=0");
                 $product_ids = in_array('all', $items) ? null : $items;
                 $q->add(new Am_Query_User_Condition_HaveSubscriptionTo($product_ids, $k == 'expired' ? User::STATUS_EXPIRED : User::STATUS_ACTIVE));
                 $queries[] = $q;
                 $this->queryDescription[] = ($k == 'expired' ? ___("Expired Users") : ___("Active Users")) . ($product_ids ? " " . ___("of products") . " " . join(",", $product_ids) : null);
                 break;
             case 'newsletter':
                 if (Am_Di::getInstance()->modules->isEnabled('newsletter')) {
                     $q = new Am_Query_User();
                     $q->addWhere("IFNULL(u.unsubscribed,0)=0");
                     $q->add(new Am_Query_User_Condition_SubscribedToNewsletter($items));
                     $queries[] = $q;
                     $this->queryDescription[] = ___("Users subscribed to Newsletter Threads #") . join(',', $items);
                 }
                 break;
         }
     }
     if (@$search['guest'] || @$search['newsletter']) {
         if (Am_Di::getInstance()->modules->isEnabled('newsletter')) {
             $q = new Am_Query(new NewsletterGuestTable(), 'g');
             if ($queries) {
                 $fields = Am_Di::getInstance()->userTable->getFields(true);
                 $q->clearFields();
                 $guestFields = array('name_f', 'name_l', 'email');
                 foreach ($fields as $k) {
                     $q->addField(in_array($k, $guestFields) ? $k : '(NULL)', $k);
                 }
             }
             $this->queryDescriptionGuest = ___("All Guests");
             if (!@$search['guest'] && @$search['newsletter']) {
                 $ids = join(',', $search['newsletter']);
                 $q->innerJoin('?_newsletter_guest_subscription', 'gs', "gs.guest_id=g.guest_id AND list_id IN ({$ids})");
                 $this->queryDescriptionGuest = ___("Guests having subscription to newsletters %s", $ids);
             }
             $queries[] = $q;
         }
     }
     if ($queries) {
         $this->query = array_shift($queries);
         foreach ($queries as $q) {
             $this->query->addUnion($q);
         }
     } else {
         $this->query->addWhere('0=1');
     }
     $this->queryDescription = join(' ,also ', $this->queryDescription);
 }
Esempio n. 5
0
File: Ui.php Progetto: grlf/eyedock
 function applySimpleSearch()
 {
     $search = array();
     foreach ($this->options as $string) {
         @(list($k, $id) = explode('-', $string, 2));
         $search[$k][] = $id == 'all' ? 'all' : intval($id);
     }
     $queries = array();
     // union these queries with $this->query
     $this->queryDescription = array();
     foreach ($search as $k => $items) {
         if ($k == 'all') {
             $q = new Am_Query_User();
             $q->addWhere("u.unsubscribed=0");
             $queries = array($q);
             $this->queryDescription = array(___("All Users"));
             break;
         }
         switch ($k) {
             case 'aff':
                 $q = new Am_Query_User();
                 $q->addWhere("u.unsubscribed=0");
                 $q->addWhere("is_affiliate>0");
                 $queries[] = $q;
                 $this->queryDescription[] = ___("All Affiliates");
                 break;
             case 'active':
             case 'expired':
                 $q = new Am_Query_User();
                 $q->addWhere("u.unsubscribed=0");
                 $product_ids = in_array('all', $items) ? null : $items;
                 if (!$product_ids) {
                     $q->addWhere("u.status=" . ($k == 'expired' ? User::STATUS_EXPIRED : User::STATUS_ACTIVE));
                 } else {
                     $q->add(new Am_Query_User_Condition_HaveSubscriptionTo($product_ids, $k == 'expired' ? User::STATUS_EXPIRED : User::STATUS_ACTIVE));
                 }
                 $queries[] = $q;
                 $this->queryDescription[] = ($k == 'expired' ? ___("Expired Users") : ___("Active Users")) . ($product_ids ? " " . ___("of products") . " " . join(",", $product_ids) : null);
                 break;
             case 'newsletter':
                 if (Am_Di::getInstance()->modules->isEnabled('newsletter')) {
                     $q = new Am_Query_User();
                     $q->addWhere("u.unsubscribed=0");
                     $q->add(new Am_Query_User_Condition_SubscribedToNewsletter($items));
                     $queries[] = $q;
                     $this->queryDescription[] = ___("Users subscribed to Newsletter Threads #") . join(',', $items);
                 }
                 break;
         }
     }
     if ($queries) {
         $this->query = array_shift($queries);
         foreach ($queries as $q) {
             $this->query->addUnion($q);
         }
     } else {
         $this->query->addWhere('0=1');
     }
     $this->queryDescription = join(' ,also ', $this->queryDescription);
 }
 protected function convertFieldFromSql($name)
 {
     //@todo improve performence VIA DIRECT SQL QUERY
     // insert into ?_data SELECT FROM ?_user
     $anUserQuery = new Am_Query_User();
     $total = $anUserQuery->getFoundRows();
     $perPage = 1024;
     for ($p = 0; $p < ceil($total / $perPage); $p++) {
         foreach ($anUserQuery->selectPageRecords($p, $perPage) as $record) {
             $record->data()->set($name, $record->{$name});
             $record->save();
         }
     }
     $this->dropSqlField($name);
 }