Example #1
0
 /**
  * Oppdater forumlenke
  * @param bool $force legg til/fjern lenke
  * @return true: lenken ble oppdatert, false: lenken ble ikke oppdatert, NULL: lenken finnes ikke
  */
 public function forum_link($force = NULL)
 {
     $this->params_load();
     // finn ut om forumlenken er lagt til
     if ($force !== NULL) {
         $this->params_user->lock();
     }
     $container = new container($this->params_user->get("forums"));
     foreach ($container->items as $key => $row) {
         if ($row[0] != "ff") {
             continue;
         }
         if ($row[1] != $this->ff->id) {
             continue;
         }
         // fjerne lenken?
         if ($force === false) {
             unset($container->items[$key]);
             // fjerne hele container?
             if (count($container->items) == 0) {
                 $this->params_user->remove("forums");
             } else {
                 $this->params_user->update("forums", $container->build());
             }
             // lagre endringer
             $this->params_user->commit();
             return true;
         }
         // sjekk om lenken er oppdatert
         if ($row[2] != $this->ff->data['ff_name']) {
             $this->params_user->lock();
             $forums = $this->params_user->get("forums");
             $container = new container($forums);
             foreach ($container->items as $key => $row) {
                 if ($row[0] != "ff" || $row[1] != $this->ff->id) {
                     continue;
                 }
                 // oppdater navnet
                 $container->items[$key][2] = $this->ff->data['ff_name'];
                 $this->params_user->update("forums", $container->build());
                 $this->params_user->commit();
                 return true;
             }
             $this->params_user->commit();
             return NULL;
         }
         if ($force !== NULL) {
             $this->params_user->commit();
         }
         return false;
     }
     // legge til lenken?
     if ($force === true) {
         $container->items[] = array("ff", $this->ff->id, $this->ff->data['ff_name'], $this->ff->get_fse_id());
         $this->params_user->update("forums", $container->build());
         $this->params_user->commit();
         return true;
     }
     if ($force !== null) {
         $this->params_user->commit();
     }
     return NULL;
 }
Example #2
0
 /** Fjern fra status */
 public function status_remove()
 {
     $this->params->lock();
     $status = unserialize($this->params->get("repliers"));
     // oppdater oppføringen for denne spilleren
     if (isset($status[login::$user->player->id])) {
         unset($status[login::$user->player->id]);
     }
     // lagre
     if (is_array($status) && count($status) == 0) {
         $this->params->remove("repliers", true);
     } else {
         $this->params->update("repliers", serialize($status), true);
     }
 }