Пример #1
0
 function handler_links_admin($page)
 {
     if (!S::user()->perms()->hasFlag('admin')) {
         return PL_FORBIDDEN;
     }
     $collec = Link::all();
     $collec->select(LinkSelect::all());
     $results = $collec->split('ns');
     if (Env::has('modify')) {
         $id = Env::i('id');
         $link = $collec->get($id);
         if ($link !== false) {
             if (Env::has('image')) {
                 try {
                     $group = Group::from('partnership');
                     $group->select();
                     $image = new FrankizImage();
                     $image->insert();
                     $image->label($link->label());
                     $image->caste($group->caste('everybody'));
                     $image->image(FrankizUpload::v('image'));
                     $link->image($image);
                 } catch (Exception $e) {
                     $page->assign('err', $e->getMessage());
                 }
             }
             $link->label(Env::t('label'));
             $link->link(Env::t('link'));
             $link->description(Env::t('description'));
             $link->comment(Env::t('comment'));
         } else {
             $err = 'Le lien modifié n\'existe plus.';
             $page->assign('err', $err);
         }
     }
     $page->addCssLink('links.css');
     $page->assign('links', $results);
     $page->assign('title', 'Administrer les liens');
     $page->changeTpl('links/admin_links.tpl');
 }
Пример #2
0
 /**
  * @before _secure
  * @after _displayData
  */
 public function links()
 {
     $this->seo(array("title" => "Link Logs"));
     $view = $this->getActionView();
     $prop = RM::get("property");
     $val = RM::get("value");
     $sort = RM::get("sort", "desc");
     $sign = RM::get("sign", "equal");
     $orderBy = RM::get("order", 'created');
     $fields = (new \Link())->getColumns();
     $searching = $query = [];
     $query['user_id'] = ['$in' => $this->org->users('publisher')];
     foreach ($fields as $key => $value) {
         $search = RM::get($key);
         if (!$search) {
             continue;
         }
         $searching[$key] = $search;
         // Only allow full object ID's and rest regex searching
         if (in_array($key, ['user_id', 'ad_id', '_id'])) {
             $query[$key] = RM::get($key);
         } else {
             $query[$key] = Utils::mongoRegex($search);
         }
     }
     $dateQuery = Utils::dateQuery(['start' => $this->start, 'end' => $this->end]);
     $query['created'] = ['$gte' => $dateQuery['start'], '$lte' => $dateQuery['end']];
     $records = \Link::all($query, [], $orderBy, $sort, $this->limit, $this->page);
     $count = \Link::count($query);
     $view->set(['links' => $records, 'fields' => $fields, 'property' => $prop, 'value' => $val, 'sign' => $sign, 'sort' => $sort, 'order' => $orderBy, 'count' => $count, 'query' => $searching]);
 }
Пример #3
0
 public function run()
 {
     $collec = Link::all('usefuls');
     $collec->select(LinkSelect::all());
     $this->assign('links', $collec);
 }
Пример #4
0
 public function link()
 {
     return Link::all();
 }
Пример #5
0
 private function _reportspub($query, $start, $end, $limit, $page)
 {
     $view = $this->getActionView();
     $dateQuery = Utils::dateQuery(['start' => $start, 'end' => $end]);
     $links = \Link::all($query, [], 'created', 'desc', $limit, $page);
     $count = \Link::count($query);
     $query["created"] = Db::dateQuery($start, $end);
     $performances = \Performance::all($query, ['created', 'clicks', 'revenue'], 'created', 'desc');
     $in = [];
     foreach ($links as $l) {
         // only find clicks for the ads whose links are created
         $in[] = Utils::mongoObjectId($l->ad_id);
     }
     // find clicks
     $clickCol = Registry::get("MongoDB")->clicks;
     $records = Db::query('Click', ['adid' => ['$in' => $in], 'is_bot' => false, 'pid' => $query['user_id'], 'created' => $query['created']], ['adid', 'country']);
     $view->set(['limit' => $limit, 'page' => $page, 'count' => $count, 'start' => $start, 'end' => $end, 'links' => $links, 'performances' => $performances, 'clicks' => Click::classify($records, 'adid'), 'commission' => $this->user->commission(), 'dq' => $query['created']]);
 }
Пример #6
0
 private function links()
 {
     $class = get_class(new Link());
     $this->log($this->verb . ' Links');
     $url = $this->baseUrl . "facility_link?c:limit=1000";
     $data = $this->getCensusData($url);
     if (!$data) {
         return false;
     }
     // Collection of Eloquent objects from API
     $apiCollection = new Collection();
     foreach ($data->facility_link_list as $link) {
         $values = [];
         $values['name'] = isset($link->description) ? $link->description : null;
         $values['facility_id_a'] = isset($link->facility_id_a) ? $link->facility_id_a : null;
         $values['facility_id_b'] = isset($link->facility_id_b) ? $link->facility_id_b : null;
         $apiCollection->add(new Link($values));
     }
     $links = Link::all();
     $this->addModels($class, $links, $apiCollection);
     $this->deleteModels($class, $links, $apiCollection);
 }