Exemplo n.º 1
0
 function generate_inner_html()
 {
     switch ($this->mode) {
         case PRI:
             $this->outer_template = 'outer_private_side_module.tpl';
             $tmp_file = dirname(__FILE__) . '/side_inner_public.tpl';
             break;
         default:
             $tmp_file = dirname(__FILE__) . '/side_inner_public.tpl';
             break;
     }
     $inner_html_gen =& new Template($tmp_file);
     // See if we have a Flickr ID for $this->uid.
     $flickr_id = Cache::getExtCache($this->uid, "flickr_id");
     if ($flickr_id === NULL) {
         // fetch all personas from the flickr service, and see if one of them has a filled in flickr_username_email field.
         $persona = new Persona();
         $flickr_persona_ids = $persona->get_user_persona_ids_with_service($this->uid, "Flickr");
         foreach ($flickr_persona_ids as $flickr_persona_id) {
             $persona = new Persona();
             $persona->load((int) $flickr_persona_id);
             $data = $persona->get_configuration_data();
             if (!empty($data->flickr_username_email)) {
                 // found one!
                 $flickr_id = $data->flickr_username_email;
                 break;
             }
         }
         if (!empty($flickr_id)) {
             Cache::setExtCache($this->uid, "flickr_id", $flickr_id);
         }
     }
     if (empty($flickr_id)) {
         $pics = NULL;
     } else {
         // Fetch pics from cache if possible.  If not cached, the inner HTML will call ajax/flickr_pics.php to fetch them.
         $pics = Cache::getExtCache(0, "flickr_pics:{$flickr_id}");
     }
     $inner_html_gen->set('pics', $pics);
     $inner_html_gen->set('flickr_id', $flickr_id);
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }
Exemplo n.º 2
0
 public static function can_see($persona_id, $owner_uid, $viewer_uid)
 {
     Logger::log("Enter: function PersonaHelper::can_see() persona_id: {$persona_id}, owner_uid; {$owner_uid}, viewer_uid: {$viewer_uid}");
     // load the persona to see it's privacy data
     try {
         $persona = new Persona();
         $persona->load($persona_id);
     } catch (PAException $e) {
         Logger::Log($e->getMessage());
         Logger::log("Exit: function PersonaHelper::can_see() with NULL");
         return null;
         // no persona!
     }
     $data = $persona->get_configuration_data();
     $perm = intval($data->perm);
     if ($viewer_uid == 0) {
         // anon users don't have relations
         $relation = 0;
         // and are definetly not family
         $in_family = 0;
     } else {
         if ($owner_uid == $viewer_uid) {
             $relation = 2;
             $in_family = 1;
         } else {
             // $relation = Relation::get_relation($owner_uid, $viewer_uid);
             $relations = Relation::get_relations($owner_uid);
             $relation = in_array($viewer_uid, $relations);
             $in_family = Relation::is_relation_in_family($owner_uid, $viewer_uid);
         }
     }
     Logger::log("PersonaHelper::can_see() perm: {$perm}, relation: {$relation}, in_family: {$in_family}");
     if (!$perm) {
         // permissions weren't set or are 0 == nobody
         Logger::log("Exit: function PersonaHelper::can_see() with NULL");
         return null;
     } else {
         if ($perm == 1) {
             // show to world (everybody)
             Logger::log("Exit: function PersonaHelper::can_see() with Persona");
             return $persona;
         } else {
             if ($perm == 2) {
                 // show to relations
                 if ($relation) {
                     Logger::log("Exit: function PersonaHelper::can_see() with Persona");
                     return $persona;
                 }
             } else {
                 if ($perm == 3) {
                     // show to family
                     if ($in_family) {
                         Logger::log("Exit: function PersonaHelper::can_see() with Persona");
                         return $persona;
                     }
                 } else {
                     Logger::log("Exit: function PersonaHelper::can_see() with NULL");
                     return null;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
     if (preg_match($sreg, $k)) {
         $field = preg_replace($sreg, '', $k);
         $data[$field] = $v;
     }
 }
 // special for ckeckbox
 if ($myService == 'Facebook' && !isset($_POST['Facebook_agreetotos'])) {
     $data['agreetotos'] = 'no';
 }
 if ($myService == 'Flickr' && !isset($_POST['Flickr_agreetotos'])) {
     $data['agreetotos'] = 'no';
 }
 if (isset($data['persona_id']) && $data['persona_id'] > 0) {
     // load Persona
     $persona = new Persona();
     $persona->load($data['persona_id']);
     // check if Persona belongs to user
     if ($persona->user_id != $user->user_id) {
         // TODO: make meaningfull error handling here
         $msg = "The service couldn't be updated. It is not associated with your account.";
     } else {
         // edit the data
         $persona->get_configuration_data();
         $c =& $persona->configuration_data;
         foreach ($data as $k => $v) {
             $c->{$k} = $v;
             $persona->{$k} = $v;
         }
         // save the bugger
         $persona->save();
         trigger_scraper($user, $persona);
Exemplo n.º 4
0
if ($_SESSION['user']['id']) {
    $uid = (int) $_SESSION['user']['id'];
} else {
    // ah-ah no WAY :)
    Logger::log(__FILE__ . ": No Session for this visit");
}
if (!$uid || !$persona_id) {
    $msg = __FILE__ . ": No IDs for uid({$uid}) or persona_id({$persona_id}) passed";
    Logger::log($msg);
    print "ERROR: User not logged in.";
    exit;
}
// load the persona
$persona = new Persona();
try {
    $persona->load($persona_id);
} catch (Exception $e) {
    $msg = __FILE__ . ": persona({$persona_id}) does not exist";
    Logger::log($msg);
    print "ERROR: " . $msg;
    exit;
}
// check to see if user owns it
if ($persona->user_id != $uid) {
    $msg = __FILE__ . ": User({$uid}) does not own persona({$persona_id})";
    Logger::log($msg);
    print "ERROR: " . $msg;
    exit;
}
// else show it
// print_r($persona);