Esempio n. 1
0
 public function testInsert()
 {
     for ($i = 0; $i < self::NUM_ROWS; $i++) {
         $data = array('title' => "'" . 'title-' . $i . "'", 'lastmodified' => time());
         array_push($this->insert_data, $data);
         $this->assertTrue((bool) TlonData::insert($this->table, array_values($data)));
     }
 }
Esempio n. 2
0
 /**
  * add(): Add a new user to TABLE, auto-generating password-hash and salt, and automatically
  * adding her to the 'all' group and to a group with the name '${username}_grp'.
  * @param  string $username  Username.
  * @param  string $password  Unhashed password.
  * @param  string $realname  Real name.
  * @return bool
  */
 public static function add($username, $password, $realname)
 {
     list($hash, $salt) = TlonHash::password($password);
     if (!(TlonUserGroup::add($username, TlonGroup::EVERYONE, TlonRights::READ, TlonGroup::EVERYONEINFO) && TlonUserGroup::add($username, TlonGroup::userGroupname($username), TlonRights::READ_WRITE, $realname))) {
         return false;
     }
     return TlonData::insert(self::$TABLE, array($username, $hash, $realname, $salt, null));
 }
Esempio n. 3
0
 public static function add($groupname, $document_id, $rights = TlonRights::READ_WRITE, $groupinfo = '')
 {
     if (!TlonGroup::exists($groupname)) {
         if (!TlonGroup::add($groupname, $groupinfo)) {
             return false;
         }
     }
     return TlonData::insert(self::$TABLE, array($groupname, $document_id, $rights));
 }
Esempio n. 4
0
 /**
  * add(): Make a new nonce, insert in the TABLE, and return it.
  * @return string  New nonce, or false if add failed.
  */
 public static function add()
 {
     self::clean();
     $nonce = TlonHash::hash(TlonHash::salt(), $_SERVER['REMOTE_ADDR']);
     if (TlonData::insert(self::$TABLE, array($nonce, time()))) {
         return $nonce;
     } else {
         return false;
     }
 }
Esempio n. 5
0
 public static function add($username, $groupname, $rights = TlonRights::READ_WRITE, $groupinfo = '')
 {
     if (!TlonGroup::exists($groupname)) {
         if (!TlonGroup::add($groupname, $groupinfo)) {
             return false;
         }
     }
     if (self::getByUsernameGroupname($username, $groupname)) {
         return self::edit($username, $groupname, $rights);
     } else {
         return TlonData::insert(self::$TABLE, array($username, $groupname, $rights));
     }
 }
Esempio n. 6
0
 public static function add($groupname, $info)
 {
     return TlonData::insert(self::$TABLE, array($groupname, $info));
 }
Esempio n. 7
0
 public static function add($username, $document_id)
 {
     self::delete($username, $document_id);
     return TlonData::insert(self::$TABLE, array(null, $username, $document_id, 0));
 }
Esempio n. 8
0
 public static function add($title, $content, $parent = -1)
 {
     return TlonData::insert(self::$TABLE, array(null, $title, $content, time(), $parent));
 }
Esempio n. 9
0
 public static function add($username, $document_id, $operations, $applied = false)
 {
     return TlonData::insert(self::$TABLE, array(null, $username, $document_id, time(), $operations, $applied ? 1 : 0));
 }