コード例 #1
0
 /**
  * Reset the flag to true for all accounts
  * @param OutputInterface $output
  */
 protected function reset($output)
 {
     try {
         \OCP\DB::beginTransaction();
         $sql = "UPDATE *PREFIX*preferences\n                        SET configvalue = 1\n                        WHERE appid = 'user_set_password' AND configkey = 'show'";
         $stmt = \OCP\DB::prepare($sql);
         $rowCount = $stmt->execute();
         \OCP\DB::commit();
         $this->consoleDisplay(' flags have been resetted to "true".');
     } catch (\Exception $e) {
         // rollBack not implemented in \OCP\DB! (ownCloud 7.0.5)
         $conn = \OCP\DB::getConnection();
         $conn->rollBack();
         $this->consoleDisplay('Fatal error: ' . $e->getMessage(), self::ERROR);
     }
 }
コード例 #2
0
 /**
  * Create a flag set to false for each existing account
  * @param OutputInterface $output
  */
 protected function Init($output)
 {
     try {
         \OCP\DB::beginTransaction();
         $sql = "INSERT INTO *PREFIX*preferences\n                        (SELECT uid, 'user_set_password', 'show', 0 FROM oc_users)\n                        ON duplicate key UPDATE configvalue = 0";
         $stmt = \OCP\DB::prepare($sql);
         $rowCount = $stmt->execute();
         \OCP\DB::commit();
         $this->consoleDisplay(' flags have been initialized to "false".');
     } catch (\Exception $e) {
         // rollBack not implemented in \OCP\DB! (ownCloud 7.0.5)
         $conn = \OCP\DB::getConnection();
         $conn->rollBack();
         $this->consoleDisplay('Fatal error: ' . $e->getMessage(), self::ERROR);
     }
 }