Example #1
0
 public static function selectByCollection($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM vehicle_collection WHERE collection_id = :collection_id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':collection_id', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $vehicleCollection = new VehicleCollection();
             $vehicleCollection->Id = (int) $row['id'];
             $vehicleCollection->Vehicle = Vehicle::select($row['vehicle_id']);
             $vehicleCollection->Collection = Collection::select($row['collection_id']);
             array_push($result, $vehicleCollection);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Example #2
0
 protected function handler_participants(Collection $activities, $fields)
 {
     $res = XDB::iterator('SELECT  id, participant
                             FROM  activities_participants
                            WHERE  id IN {?}', $activities->ids());
     $users = new Collection('User');
     $part = array();
     while ($datas = $res->next()) {
         $part[$datas['id']][] = $users->addget($datas['participant']);
     }
     foreach ($part as $key => $obj) {
         $activities->get($key)->participants($obj);
     }
     $users->select($this->subs['participants']);
 }
function smarty_function_origin_picker($params, &$smarty)
{
    $gf = new GroupFilter(new PFC_And(new PFC_Not(new GFC_Namespace(Group::NS_USER)), new GFC_User(S::user(), Rights::admin())), new GFO_Score());
    $gs = $gf->get();
    if ($params['not_only_admin']) {
        $gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::restricted())), new GFO_Score());
        $gso = $gfo->get()->diff($gs);
        $temp = new Collection();
        $temp->merge($gs)->merge($gso);
        $temp->select(GroupSelect::base());
        $smarty->assign('not_admin', $gso);
    } else {
        $gs = $gf->get()->select(GroupSelect::base());
    }
    $smarty->assign($params['out'], $gs);
}
Example #4
0
 function handler_logs_sessions($page)
 {
     $iter = XDB::iterator('SELECT  id, uid, host, ip, forward_ip, forward_host,
                                    browser, suid, flags, start
                              FROM  log_sessions
                          ORDER BY  start DESC
                             LIMIT  50');
     $sessions = array();
     $users = new Collection('User');
     while ($session = $iter->next()) {
         $user = $users->addget($session['uid']);
         $sessions[$session['id']] = array('user' => $user, 'host' => $session['host'], 'ip' => uint_to_ip($session['ip']), 'forward_host' => $session['forward_host'], 'forward_ip' => uint_to_ip($session['forward_ip']), 'browser' => $session['browser'], 'suid' => $session['suid'], 'flags' => $session['flags'], 'start' => new FrankizDateTime($session['start']));
     }
     $users->select(UserSelect::base());
     $page->assign('title', "Logs des sessions");
     $page->assign('sessions', $sessions);
     $page->changeTpl('admin/logs_sessions.tpl');
 }
function smarty_function_target_picker($params, &$smarty)
{
    // Get user groups
    $everybody_groups = S::user()->castes(Rights::everybody())->groups();
    // Get Frankiz special groups
    $fkz = new Collection('Group');
    $fkz->add(array('everybody', 'public'));
    $fkz->select(new GroupSelect(array('description')));
    // BDE, study and promo groups
    $study_groups = $everybody_groups->filter('ns', Group::NS_BDE);
    $study_groups->merge($everybody_groups->filter('ns', Group::NS_PROMO));
    $study_groups->merge($everybody_groups->filter('ns', Group::NS_STUDY));
    // Get all groups user is admin, without the user one
    $gs = S::user()->castes(Rights::admin())->groups();
    $gs->diff($fkz);
    $gs->filter(function ($g) {
        return $g->ns() != Group::NS_USER;
    });
    if ($params['even_only_friend']) {
        $gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::everybody())), new GFO_Score());
        $gso = $gfo->get()->diff($gs)->diff($fkz);
        $temp = new Collection();
        $temp->merge($gs)->merge($gso);
        $temp->select(GroupSelect::base());
        $smarty->assign('only_friend', $gso);
        $temp = new Collection();
        $temp->merge($gs)->merge($fkz)->merge($gso);
        $temp->select(GroupSelect::base());
    } else {
        $temp = new Collection();
        $temp->merge($gs)->merge($fkz);
        $temp->select(GroupSelect::base());
    }
    $smarty->assign($params['user_groups'], $gs);
    $smarty->assign($params['fkz_groups'], $fkz);
    $smarty->assign($params['study_groups'], $study_groups);
    $smarty->assign($params['own_group'], S::user()->group());
}
 public function getDoctorsListCount($latitude = 0, $longitude = 0, $query = array())
 {
     $this->data = DB::table('doctors');
     $this->data->leftJoin('doctors_details AS dhospital', 'doctors.id', '=', 'dhospital.doctor_id');
     $this->data->leftJoin('listing_hospitals', 'dhospital.detail_id', '=', 'listing_hospitals.id');
     $this->data->leftJoin('doctors_details AS dhmo', 'doctors.id', '=', 'dhmo.doctor_id');
     $this->data->leftJoin('listing_hmo', 'dhmo.detail_id', '=', 'listing_hmo.id');
     $this->data->leftJoin('doctors_specialization', 'doctors.id', '=', 'doctors_specialization.doctor_id');
     $this->data->leftJoin('location_cities', 'listing_hospitals.city', '=', 'location_cities.id');
     $this->data->leftJoin('location_provinces', 'listing_hospitals.province', '=', 'location_provinces.id');
     $this->data->select(DB::raw("doctors.*, dhospital.detail_id as hospital_id, listing_hospitals.listing_title as hospital_title, listing_hospitals.latitude, listing_hospitals.longitude, listing_hospitals.street, location_cities.city_name, location_provinces.province_name, dhmo.detail_id as hmo_id, listing_hmo.listing_title as hmo_title, doctors_specialization.specialization_id, (6371 * acos (cos ( radians(?) ) * cos( radians( listing_hospitals.latitude ) ) * cos( radians( listing_hospitals.longitude ) - radians(?) ) + sin ( radians(?) ) * sin( radians( listing_hospitals.latitude ) ))) AS distance"))->setBindings([$latitude, $longitude, $latitude]);
     $this->data->where('dhospital.detail_type', '=', 1);
     $this->data->where('dhmo.detail_type', '=', 4);
     if (isset($query['specializations'])) {
         $this->data->whereIn('doctors_specialization.specialization_id', $query['specializations']);
     }
     if (isset($query['locations'])) {
         $this->data->whereIn('listing_hospitals.city', $query['locations']);
     }
     $this->data->groupBy('doctors.id');
     // }
     return $this->data->get();
 }
Example #7
0
 public static function all()
 {
     $res = XDB::iterator('SELECT  id, date, question, answer1, answer2, count1, count2, writer
                           FROM  qdj
                          WHERE  date!="0000-00-00" AND date<NOW()
                          ORDER  BY date DESC');
     $qdjs = new Collection('QDJ');
     $users = new Collection('User');
     while ($datas = $res->next()) {
         $datas['writer'] = $users->addget($datas['writer']);
         $datas['date'] = new FrankizDateTime($datas['date']);
         $qdjs->addget($datas['id'])->fillFromArray($datas);
     }
     $users->select(UserSelect::base());
     return $qdjs;
 }
Example #8
0
 /**
  * Select a collection from the database
  *
  * @param Collection $metas The objects to select
  * @param string $field collection field
  */
 protected function helper_collection(Collection $metas, $field)
 {
     // Retrieve link attributes
     list($l_className, $table, $l_id, $id) = $this->schema->collectionType($field);
     $_metas = array();
     foreach ($metas as $meta) {
         $_metas[$meta->id()] = new Collection($l_className);
     }
     // Get collection ids
     $iter = XDB::iterRow("SELECT  {$id}, {$l_id}\n                                FROM  {$table}\n                               WHERE  {$id} IN {?}", $metas->ids());
     $linkeds = new Collection($l_className);
     while (list($id, $l_id) = $iter->next()) {
         $linked = $linkeds->addget($l_id);
         $_metas[$id]->add($linked);
     }
     // Update metas
     foreach ($metas as $meta) {
         $meta->fillFromArray(array($field => $_metas[$meta->id()]));
     }
     if (!empty($this->subs[$field])) {
         $linkeds->select($this->subs[$field]);
     }
 }
Example #9
0
 protected function handler_questions(Collection $surveys, array $fields)
 {
     $_surveys = array();
     foreach ($surveys as $s) {
         $_surveys[$s->id()] = new Collection('SurveyQuestion');
         $_surveys[$s->id()]->order('rank', false);
     }
     $iter = XDB::iterRow("SELECT  qid, survey, type\n                                FROM  surveys_questions\n                               WHERE  survey IN {?}", $surveys->ids());
     $questions = new Collection('SurveyQuestion');
     while (list($qid, $sid, $type) = $iter->next()) {
         $className = 'SurveyQuestion' . $type;
         $question = new $className($qid);
         $questions->add($question);
         $_surveys[$sid]->add($question);
     }
     foreach ($surveys as $s) {
         $s->fillFromArray(array('questions' => $_surveys[$s->id()]));
     }
     if (!empty($questions) && !empty($this->subs['questions'])) {
         $questions->select($this->subs['questions']);
     }
 }
Example #10
0
 public function getDetails($title_id)
 {
     if (!$title_id) {
         Redirect::to("/");
     }
     $title_db = Title::with(array("gallery_image", "video", "genre", "rating", "producttype"))->find($title_id);
     if (!is_object($title_db)) {
         return Redirect::to("/");
     }
     $title_db->favorite = Favorite::where("title_id", "=", $title_id)->where("user_id", "=", Auth::user()->id)->get();
     $title = $title_db->toArray();
     //dd($title);
     // Get all Image paths for this title
     // ---------------------
     if (count($title['gallery_image']) > 0) {
         $gallery_image_path = Config::get('nbc.imageRootImagePath') . $title['gallery_image'][0]['file'];
     } else {
         $gallery_image_path = "/images/x-image-placeholder.png";
     }
     $fullpath_to_gallery_image = $gallery_image_path;
     // Get all Video paths for this title
     // ---------------------
     $video_file_path_array = array();
     if (is_array($title['video']) && count($title['video']) > 0) {
         foreach ($title['video'] as $video) {
             $videofile_path = $this->getTitleVideoPath($title['final_title']);
             $videofile_localpath = Config::get('nbc.imageRootLocalVideoPath');
             if (!$videofile_localpath && strpos($videofile_path, '://') === false) {
                 $videofile_localpath = $videofile_path;
             }
             $fileExists = false;
             // Get file headers to determine 404
             if ($videofile_localpath && file_exists($_SERVER['DOCUMENT_ROOT'] . $videofile_localpath . $video['file'])) {
                 $fileExists = true;
                 $videofile_path = $videofile_localpath;
             }
             if (!$fileExists && $videofile_localpath != $videofile_path && curl_htmlcode($videofile_path . $video['file']) != 404) {
                 $fileExists = true;
             }
             if ($fileExists) {
                 $video_file_path_array[] = array("filepath" => $videofile_path . $video['file'], "type" => $this->getVideoType($video['file']), "id" => $video['id']);
             }
         }
     }
     $cast_array = explode(",", $title['actors']);
     $directors_array = explode(",", $title['directors']);
     $producers_array = explode(",", $title['producers']);
     $writers_array = explode(",", $title['writers']);
     $awards_array = explode(",", $title['awards']);
     $genres = array();
     if (is_array($title["genre"])) {
         foreach ($title["genre"] as $genre) {
             $genres[] = $genre['name'];
         }
     }
     if ($title['rating']['name'] == "") {
         $rating = "none";
     } else {
         $rating = $title['rating']['name'];
     }
     if ($title['color'] == "1") {
         $color = "color";
     } else {
         $color = "black & white";
     }
     /* if ( strlen( $title['synopsis'] ) > 720 ) {
             $partialsynopsis = str_limit($title['synopsis'],720);
             $enable_more = 1;
        } else {
           //synop = t ( synop );
           $enable_more = 0;
           $partialsynopsis = "";
        }*/
     $user_id = Auth::user()->id;
     $collections = Collection::select('id', 'name')->where("user_id", "=", $user_id)->where('status_id', '<>', '6')->orderBy('name')->get()->toArray();
     $collection_dropdown = array();
     foreach ($collections as $collection) {
         $shortened_coll_name = str_limit($collection['name'], 25);
         $collection_dropdown[$collection['id']] = $shortened_coll_name;
     }
     $default_collection_id = $this->getUserLastCollectionUsed();
     if (isset($default_collection_id) and $default_collection_id) {
         $first_collection_id = $default_collection_id;
     } else {
         reset($collection_dropdown);
         $first_collection_id = key($collection_dropdown);
     }
     // Add insert to Report table, for reporting
     $user_id = Auth::user()->id;
     $user = User::find($user_id);
     $report = Report::create(array('date' => time(), 'action_type' => 1, 'action_user_id' => $user_id, 'object_id' => $title_id, 'report_type' => 1, 'aux_object' => $user['region_id']));
     $report = Report::create(array('date' => time(), 'action_type' => 1, 'action_user_id' => $user_id, 'object_id' => $title_id, 'report_type' => 3, 'aux_object' => $user['region_id']));
     // Unpack serialized runtimes
     if ($title['runtime_serialized'] != '') {
         $title['runtimes'] = unserialize($title['runtime_serialized']);
     } else {
         $title['runtimes'][0] = array('episode_cnt' => $title['episode_cnt'], 'runtime_minutes_cnt' => $title['runtime_minutes_cnt']);
     }
     $data = array("title" => $title, "mode" => "preview_title", "actors" => $cast_array, "directors" => $directors_array, "producers" => $producers_array, "writers" => $writers_array, "awards" => $awards_array, "genres" => $genres, "rating" => $rating, "color" => $color, 'first_collection_id' => $first_collection_id, 'collections' => $collection_dropdown, 'gallery_image_path' => $fullpath_to_gallery_image, 'video_file_path_array' => $video_file_path_array);
     //dd($enable_more);
     //dd($partialsynopsis);
     return View::make('titles.details')->with('data', $data);
 }
Example #11
0
 function handler_admin($page, $id = null, $action = null)
 {
     $page->assign('title', "Administration de l'authentification externe");
     $page->assign('remoterights_available', implode(',', Remote::availableRights()));
     // Find remote
     $remote = null;
     if ($id == 'new') {
         $remote = new Remote();
         $remote->insert();
     } elseif (Remote::isId($id)) {
         $remote = new Remote($id);
         // Delete a remote
         if ($action == 'delete') {
             $remote->delete();
             $remote = null;
         }
     }
     if (!empty($remote)) {
         $remote->select(RemoteSelect::groups());
         if (Env::has('change_remote')) {
             $remote->site(Env::t('site'));
             $remote->label(Env::t('label'));
             $remote->privkey(Env::t('privkey'));
             $rights = explode(',', Env::t('rights'));
             foreach ($rights as $k => $v) {
                 $rights[$k] = strtolower(trim($v));
             }
             $rights = array_intersect($rights, Remote::availableRights());
             $remote->rights(new PlFlagSet(implode(',', $rights)));
             $groups = new Collection('Group');
             $groups_fields = array('binets', 'frees');
             foreach ($groups_fields as $field) {
                 foreach (explode(';', Env::t($field)) as $gid) {
                     $gid = trim($gid);
                     if ($gid) {
                         $groups->add(new Group($gid));
                     }
                 }
             }
             $groups->select(GroupSelect::base());
             $remote->groups($groups);
         }
         $page->assign('remote', $remote);
         $page->changeTpl('remote/admin.tpl');
     } else {
         $remotes = Remote::selectAll(RemoteSelect::groups());
         $page->assign('remotes', $remotes);
         $page->changeTpl('remote/list.tpl');
     }
 }
Example #12
0
 public static function batchSelect(array $wikis, $options = null)
 {
     if (empty($wikis)) {
         return;
     }
     $bits = self::optionsToBits($options);
     $wikis = array_combine(self::toIds($wikis), $wikis);
     $joins = array();
     $cols = array();
     if ($bits & self::SELECT_BASE) {
         $cols['w'] = array('name', 'comments');
     }
     if ($bits & self::SELECT_COUNT || $bits & self::SELECT_VERSION) {
         $cols[-1] = array('COUNT(wv.version) AS count');
         $joins['wv'] = PlSqlJoin::left('wiki_version', '$ME.wid = w.wid');
     }
     if (!empty($cols)) {
         $iter = XDB::iterator('SELECT  w.wid AS id, ' . self::arrayToSqlCols($cols) . '
                                  FROM  wiki AS w
                                        ' . PlSqlJoin::formatJoins($joins, array()) . '
                                 WHERE  w.wid IN {?}
                              GROUP BY  w.wid', array_keys($wikis));
         while ($datas = $iter->next()) {
             $wikis[$datas['id']]->fillFromArray($datas);
         }
     }
     // Load last version
     if ($bits & self::SELECT_VERSION) {
         if (!isset($options[self::SELECT_VERSION])) {
             $opts = array('versions' => array('last'));
         } else {
             $opts = $options[self::SELECT_VERSION];
         }
         $conds = array();
         foreach ($wikis as $w) {
             if ($w->versions == null) {
                 $w->versions = array();
             }
             $versions = array();
             if (in_array('last', $opts['versions'])) {
                 $versions[] = $w->count();
             }
             foreach ($opts['versions'] as $version) {
                 if ($version != 'last') {
                     $versions[] = $version;
                 }
             }
             if (!empty($versions)) {
                 $conds[] = XDB::format('( wid = {?} AND version IN {?} )', $w->id(), $versions);
             }
         }
         $iter = XDB::iterator('SELECT  wid AS id, version, wrote, writer, content
                                  FROM  wiki_version
                                 WHERE  ' . implode(' OR ', $conds));
         $writers = new Collection('User');
         while ($datas = $iter->next()) {
             $writer = $writers->addget($datas['writer']);
             $wikis[$datas['id']]->versions[$datas['version']] = array('wrote' => $datas['wrote'], 'writer' => $writer, 'content' => $datas['content']);
         }
         if (isset($opts['options'])) {
             $writers->select($opts['options']);
         }
     }
 }
Example #13
0
 /**
  * Select a GID which identifies the visibility of a caste-user assocation
  */
 protected function handler_cuvisibility(Collection $users, $fields)
 {
     $_users = array();
     foreach ($users as $u) {
         $_users[$u->id()] = array();
     }
     $viscoll = new Collection('Group');
     $iter = XDB::iterRow('SELECT  uid, cid, visibility
                             FROM  castes_users
                            WHERE  uid IN {?}', $users->ids());
     while (list($uid, $cid, $vis) = $iter->next()) {
         $_users[$uid][$cid] = $vis;
         if ($vis != 0) {
             $viscoll->add($vis);
         }
     }
     $viscoll->select(GroupSelect::base());
     foreach ($users as $u) {
         $cuarray = array_map(function ($gid) use($viscoll) {
             return $gid == 0 ? null : $viscoll->get($gid);
         }, $_users[$u->id()]);
         $u->fillFromArray(array('cuvisibility' => $cuarray));
     }
 }
Example #14
0
 protected function handler_castes(Collection $groups, $fields)
 {
     $_groups = array();
     foreach ($groups as $g) {
         $_groups[$g->id()] = new Collection('Caste');
     }
     $iter = XDB::iterRow('SELECT  cid, `group`, rights
                             FROM  castes
                            WHERE  `group` IN {?}', $groups->ids());
     $castes = new Collection('Caste');
     while (list($cid, $group, $rights) = $iter->next()) {
         $caste = new Caste(array('id' => $cid, 'group' => $groups->get($group), 'rights' => new Rights($rights)));
         $castes->add($caste);
         $_groups[$group]->add($caste);
     }
     foreach ($groups as $g) {
         $g->fillFromArray(array('castes' => $_groups[$g->id()]));
     }
     if (!empty($castes) && !empty($this->subs['castes'])) {
         $castes->select($this->subs['castes']);
     }
 }
 public function loadFeaturedLightbox()
 {
     $collections = Collection::select('id', 'name as collection_name', 'short_name as collection_short_name', 'order_no')->rightJoin('collections_images', 'collections_images.collection_id', '=', 'collections.id')->orderBy('order_no', 'desc')->groupBy('collections.id')->distinct()->take(10)->get()->toArray();
     foreach ($collections as $key => $value) {
         $image = CollectionImage::where('collection_id', '=', $value['id'])->where('collections_images.type', '=', 'main')->leftJoin('images', 'collections_images.image_id', '=', 'images.id')->leftJoin('image_details', 'image_details.image_id', '=', 'collections_images.image_id')->groupBy('collection_id')->get()->toArray();
         if (count($image) == 0) {
             $image = CollectionImage::where('collection_id', '=', $value['id'])->leftJoin('images', 'collections_images.image_id', '=', 'images.id')->leftJoin('image_details', 'image_details.image_id', '=', 'collections_images.image_id')->groupBy('collection_id')->get()->toArray();
         }
         $collections[$key]['image'] = count($image) > 0 ? $image[0] : array();
     }
     $arrFeaturedLightbox = array();
     if (count($collections)) {
         $i = 0;
         foreach ($collections as $value) {
             $arrFeaturedLightbox[$i]['collection_id'] = $value['id'];
             $arrFeaturedLightbox[$i]['collection_short_name'] = $value['collection_short_name'];
             $arrFeaturedLightbox[$i]['collection_name'] = $value['collection_name'];
             $arrFeaturedLightbox[$i]['path'] = '/pic/thumb/' . $value['image']['short_name'] . '-' . $value['image']['image_id'] . '.jpg';
             $arrFeaturedLightbox[$i]['width'] = $value['image']['width'];
             $arrFeaturedLightbox[$i]['height'] = $value['image']['height'];
             $i++;
         }
     }
     if (Request::ajax()) {
         $html = View::make('frontend.lightbox.featured-lightboxs')->with('arrFeaturedLightbox', $arrFeaturedLightbox)->render();
         $arrReturn = ['status' => 'ok', 'message' => '', 'html' => $html];
         $response = Response::json($arrReturn);
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     return View::make('frontend.types.featured-collections')->with('arrFeaturedCollection', $arrFeaturedLightbox)->render();
 }
Example #16
0
    $groups_friend = new Collection('Group');
    while ($g_datas = $g_iter->next()) {
        $g = new Group($g_datas['binet_id']);
        if (preg_match('/ympath?isant/', $g_datas['remarque'])) {
            $groups_friend->add($g);
        } else {
            $groups_member->add($g);
        }
        $u->comments($g, conv($g_datas['remarque']));
        if ($g->id() == 1 && strlen(conv_name($u->nickname())) > 1) {
            $u->addStudy(0, $datas['promo'], (int) $datas['promo'] + 4, $datas['promo'], conv_name($u->nickname()));
        }
    }
    $temp = new Collection('Group');
    $temp->safeMerge(array($groups_member, $groups_friend));
    $temp->select(GroupSelect::castes());
    foreach ($groups_member as $g) {
        $g->caste(Rights::member())->addUser($u);
    }
    foreach ($groups_friend as $g) {
        $g->caste(Rights::friend())->addUser($u);
    }
    $k++;
    echo 'User ' . str_pad($k, 4, '0', STR_PAD_LEFT) . '/' . $users . ' : ' . str_pad($u->id(), 5, '0', STR_PAD_LEFT) . ' - ' . $datas['promo'] . ' - ' . str_pad($groups_member->count(), 2, '0', STR_PAD_LEFT) . " members - " . str_pad($groups_friend->count(), 2, '0', STR_PAD_LEFT) . " friends - " . substr(microtime(true) - $t, 0, 5) . '   ' . $u->login() . "\n";
}
echo "-----------------------------------------------\n";
XDB::execute('UPDATE account SET skin = "default"');
echo "default skin set \n";
XDB::execute('INSERT INTO users_minimodules
                          (SELECT uid, "birthday",     "COL_LEFT",   0 FROM account WHERE uid > 0)');
XDB::execute('INSERT INTO users_minimodules
Example #17
0
 function handler_group_ajax_users($page)
 {
     $group = Json::i('gid');
     $limit = 25;
     $group = Group::fromId($group);
     $users = false;
     if ($group) {
         $users = array();
         $group->select(GroupSelect::castes());
         $order = new UFO_Name(UFO_Name::LASTNAME);
         $filters = new PFC_True();
         if (strlen(Json::t('promo')) > 0) {
             $filters = new UFC_Group(explode(';', Json::v('promo')));
         }
         $uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::admin())), $filters), $order);
         $admins = $uf->get(new PlLimit($limit, (Json::i('admin_page', 1) - 1) * $limit));
         $admins_total = $uf->getTotalCount();
         $uf = new UserFilter(new PFC_And(new UFC_Caste(array($group->caste(Rights::member()), $group->caste(Rights::logic()))), $filters), $order);
         $members = $uf->get(new PlLimit($limit, (Json::i('member_page', 1) - 1) * $limit));
         $members_total = $uf->getTotalCount();
         $uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::friend())), $filters), $order);
         $friends = $uf->get(new PlLimit($limit, (Json::i('friend_page', 1) - 1) * $limit));
         $friends_total = $uf->getTotalCount();
         $all = new Collection('User');
         $all->safeMerge(array($admins, $members, $friends));
         $all->select(UserSelect::base());
         $admins_export = $admins->export(User::EXPORT_MICRO, true);
         $members_export = $members->export(User::EXPORT_MICRO, true);
         $friends_export = $friends->export(User::EXPORT_MICRO, true);
         if ($all->count() > 0) {
             $iter = XDB::iterRow('SELECT  uid, comment
                                     FROM  users_comments
                                    WHERE  gid = {?} AND uid IN {?}', $group->id(), $all->ids());
             while (list($uid, $comment) = $iter->next()) {
                 if ($admins_export[$uid]) {
                     $admins_export[$uid]['comments'] = $comment;
                 }
                 if ($members_export[$uid]) {
                     $members_export[$uid]['comments'] = $comment;
                 }
                 if ($friends_export[$uid]) {
                     $friends_export[$uid]['comments'] = $comment;
                 }
             }
         }
         $users['admin'] = array('total' => $admins_total, 'users' => $admins_export);
         $users['member'] = array('total' => $members_total, 'users' => $members_export);
         $users['friend'] = array('total' => $friends_total, 'users' => $friends_export);
     }
     $page->jsonAssign('limit', $limit);
     $page->jsonAssign('users', $users);
     return PL_JSON;
 }
Example #18
0
Flight::route('GET /v1/main/collection', function () {
    $company = Flight::request()->query->company;
    try {
        if ($company) {
            $array = Collection::selectByCompany($company);
        } else {
            $array = Collection::selectAll();
        }
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/collection/@id', function ($id) {
    try {
        $object = Collection::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/collection', function () {
    try {
        $object = Collection::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/collection/@id', function ($id) {
    try {
Example #19
0
 /**
  * Select all elements in the database
  * @param $fields select() parameter
  */
 public static function selectAll($fields = null)
 {
     $schema = Schema::get(get_called_class());
     $res = XDB::query('SELECT ' . $schema->id() . ' FROM ' . $schema->table());
     $col = new Collection($schema->className());
     $col->add($res->fetchColumn());
     return $col->select($fields);
 }
Example #20
0
 public function handler_defaultfilters($page)
 {
     S::user()->select(UserSelect::login());
     if (Env::has('options')) {
         $groups = new Collection('Group');
         $gids = explode(';', Env::s('promo'));
         if (Env::t('promo', '') != '') {
             $groups->add($gids);
         }
         $groups->select(GroupSelect::base());
         S::user()->defaultFilters($groups);
     }
     $page->assign('user', S::user());
     $page->addCssLink('profile.css');
     $page->assign('title', "Filtre par défaut");
     $page->changeTpl('profile/defaultfilters.tpl');
 }